OpenConceptLab/ocl_issues#2576 | Source versions tab#28
Conversation
|
A couple of quick fixes made:
I noted that CIEL, which has 51 versions, seems to display all of the versions with no "Show More" action. If there needs to be that "Show More", let's consider adding it. Otherwise, the behavior works very well, and it looks nice and streamlined! |
paynejd
left a comment
There was a problem hiding this comment.
Feature meets the ticket's AC (exports, changelogs, version comparison) and exceeds it. Comments are inline as one-click suggestions. Two things worth doing before merge:
- Changelog renderer — reuse
react-markdown+remark-gfmlike TBv2 (see comment onMarkdownContent.jsx); the hand-rolled parser drops lists and breaks in-page anchor links. - Duplication — commit
6bdceebis titled "extracting common component," butSourceVersionsTabre-implements the toolbar, sticky table, action menu, and a localisHeadVersionalready inCollectionVersionsTab. Consider a sharedVersionsTableso the two don't drift (follow-up, not a blocker).
| Typography | ||
| } from '@mui/material'; | ||
|
|
||
| const renderInlineMarkdown = text => { |
There was a problem hiding this comment.
Main ask before merge — reuse a real markdown renderer for the changelog. TBv2 renders this exact /sources/$changelog/ output via react-markdown + remark-gfm (oclweb2/src/components/common/CustomMarkdown.jsx). oclweb3 has no client-side markdown component yet, so this PR hand-rolls one — but it misses constructs the changelog generator actually emits: bullet lists (oclapi2/core/sources/changelog_markdown.py:254) and in-page anchor links to table rows (:449).
Recommend adding react-markdown+remark-gfm and porting CustomMarkdown into a shared <Markdown> component — and flagging this as a design-system gap (no shared markdown component exists in oclweb3). The three suggestions below are stop-gaps if the hand-rolled parser stays.
| else if(match[5]) | ||
| tokens.push(<a key={tokens.length} href={match[6]} target="_blank" rel="noopener noreferrer">{match[5]}</a>); |
There was a problem hiding this comment.
In-page anchor links from the changelog (changelog_markdown.py:449) open a blank tab to a broken URL because every link gets target="_blank". Only force a new tab for external links:
| else if(match[5]) | |
| tokens.push(<a key={tokens.length} href={match[6]} target="_blank" rel="noopener noreferrer">{match[5]}</a>); | |
| else if(match[5]) { | |
| const isExternal = /^https?:\/\//i.test(match[6]); | |
| tokens.push(<a key={tokens.length} href={match[6]} {...(isExternal ? { target: '_blank', rel: 'noopener noreferrer' } : {})}>{match[5]}</a>); | |
| } |
|
|
||
| const heading = trimmed.match(/^(#{1,6})\s+(.+)$/); | ||
| if(heading) { | ||
| const variant = heading[1].length <= 1 ? 'h6' : 'subtitle1'; |
There was a problem hiding this comment.
## and ### both collapse to subtitle1, but the generator emits #/##/###. Preserve the hierarchy:
| const variant = heading[1].length <= 1 ? 'h6' : 'subtitle1'; | |
| const variant = { 1: 'h6', 2: 'subtitle1', 3: 'subtitle2' }[heading[1].length] || 'subtitle2'; |
| elements.push( | ||
| <Typography key={elements.length} variant="body2" sx={{ my: 1, lineHeight: 1.6 }}> | ||
| {renderInlineMarkdown(trimmed)} | ||
| </Typography> | ||
| ); | ||
| index += 1; |
There was a problem hiding this comment.
Bullet/ordered lists (the generator emits - items at changelog_markdown.py:254) fall through to the paragraph branch and render with a literal leading dash. Add a list branch before the paragraph fallthrough:
| elements.push( | |
| <Typography key={elements.length} variant="body2" sx={{ my: 1, lineHeight: 1.6 }}> | |
| {renderInlineMarkdown(trimmed)} | |
| </Typography> | |
| ); | |
| index += 1; | |
| if(/^([-*]|\d+\.)\s+/.test(trimmed)) { | |
| const ordered = /^\d+\.\s+/.test(trimmed); | |
| const items = []; | |
| while(index < lines.length && /^\s*([-*]|\d+\.)\s+/.test(lines[index])) { | |
| items.push(lines[index].trim().replace(/^([-*]|\d+\.)\s+/, '')); | |
| index += 1; | |
| } | |
| elements.push( | |
| <Box key={elements.length} component={ordered ? 'ol' : 'ul'} sx={{ my: 1, pl: 3 }}> | |
| {items.map((item, itemIndex) => ( | |
| <Typography key={itemIndex} component="li" variant="body2" sx={{ lineHeight: 1.6 }}> | |
| {renderInlineMarkdown(item)} | |
| </Typography> | |
| ))} | |
| </Box> | |
| ); | |
| continue; | |
| } | |
| elements.push( | |
| <Typography key={elements.length} variant="body2" sx={{ my: 1, lineHeight: 1.6 }}> | |
| {renderInlineMarkdown(trimmed)} | |
| </Typography> | |
| ); | |
| index += 1; |
| }; | ||
|
|
||
| const headerCellSx = { | ||
| backgroundColor: 'white', |
There was a problem hiding this comment.
Use a theme token instead of hardcoded 'white' (must stay opaque so the sticky header covers scrolling rows):
| backgroundColor: 'white', | |
| backgroundColor: 'background.paper', |
| : t('repo.source_versions_count', { count: versionsCount.toLocaleString() }); | ||
|
|
||
| return ( | ||
| <Box sx={{ height: 'calc(100vh - 285px)', overflow: 'hidden', backgroundColor: '#FFF' }}> |
There was a problem hiding this comment.
Token instead of hardcoded #FFF:
| <Box sx={{ height: 'calc(100vh - 285px)', overflow: 'hidden', backgroundColor: '#FFF' }}> | |
| <Box sx={{ height: 'calc(100vh - 285px)', overflow: 'hidden', backgroundColor: 'background.paper' }}> |
| bgcolor: '#FFF', | ||
| borderBottom: '1px solid rgba(224, 224, 224, 1)', |
There was a problem hiding this comment.
Token-ize the toolbar background and border (the rest of the file uses surface.*/divider):
| bgcolor: '#FFF', | |
| borderBottom: '1px solid rgba(224, 224, 224, 1)', | |
| bgcolor: 'background.paper', | |
| borderBottom: '1px solid', | |
| borderColor: 'divider', |
| > | ||
| <Typography | ||
| sx={{ flex: '1 1 100%', whiteSpace: 'nowrap' }} | ||
| variant="h7" |
There was a problem hiding this comment.
h7 isn't a standard MUI Typography variant (renders unstyled). Use h6:
| variant="h7" | |
| variant="h6" |
Linked Issue
Closes OpenConceptLab/ocl_issues#2576