Skip to content

Commit 55dc5f6

Browse files
authored
Merge pull request #4220 from Northeastern-Electric-Racing/#4217-project-changes-tab
#4217 project changse tab updates
2 parents 233251e + 67e60b3 commit 55dc5f6

1 file changed

Lines changed: 55 additions & 24 deletions

File tree

src/frontend/src/components/ChangesList.tsx

Lines changed: 55 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,71 @@
33
* See the LICENSE file in the repository root folder for details.
44
*/
55

6-
import { Box, Link } from '@mui/material';
7-
import Typography from '@mui/material/Typography';
6+
import { Box, Link, Stack, Typography } from '@mui/material';
87
import { ImplementedChange } from 'shared';
9-
import { fullNamePipe, datePipe } from '../utils/pipes';
8+
import { datePipe, fullNamePipe } from '../utils/pipes';
109
import { Link as RouterLink } from 'react-router-dom';
1110
import { routes } from '../utils/routes';
12-
import DynamicTooltip from './DynamicTooltip';
1311

1412
interface ChangesListProps {
1513
changes: ImplementedChange[];
1614
}
1715

16+
const URL_REGEX = /(https?:\/\/\S+)/g;
17+
18+
const renderDetailWithLinks = (detail: string) =>
19+
detail.split(URL_REGEX).map((segment, idx) => {
20+
if (!/^https?:\/\//.test(segment)) return segment;
21+
const trailing = segment.match(/[.,;:!?)\]"'`]+$/)?.[0] ?? '';
22+
const url = trailing ? segment.slice(0, -trailing.length) : segment;
23+
return (
24+
<span key={idx}>
25+
<Link href={url} target="_blank" rel="noopener noreferrer" underline="hover">
26+
{url}
27+
</Link>
28+
{trailing}
29+
</span>
30+
);
31+
});
32+
1833
const ChangesList: React.FC<ChangesListProps> = ({ changes }) => {
1934
return (
20-
<Box>
21-
<ul style={{ paddingLeft: '5px', marginBottom: '0em', listStyleType: 'none' }}>
22-
{changes.map((ic, idx) => (
23-
<li key={idx}>
24-
<Box style={{ display: 'flex', flexDirection: 'row' }}>
25-
<div style={{ marginRight: '4px' }}>
26-
[
27-
<Link component={RouterLink} to={`${routes.CHANGE_REQUESTS}/${ic.changeRequestId}`}>
28-
#{ic.changeRequestIdentifier}
29-
</Link>
30-
]
31-
</div>
32-
<DynamicTooltip title={`${fullNamePipe(ic.implementer)} - ${datePipe(ic.dateImplemented)}`}>
33-
<Typography component="span">{ic.detail}</Typography>
34-
</DynamicTooltip>
35-
</Box>
36-
</li>
37-
))}
38-
</ul>
39-
</Box>
35+
<Stack component="ul" spacing={0.75} sx={{ p: 0, m: 0, listStyleType: 'none' }}>
36+
{changes.map((ic, idx) => (
37+
<Box
38+
component="li"
39+
key={idx}
40+
sx={{
41+
display: 'flex',
42+
flexDirection: { xs: 'column', sm: 'row' },
43+
alignItems: { sm: 'baseline' },
44+
gap: 1,
45+
px: 1.25,
46+
py: 0.75,
47+
borderRadius: 1,
48+
backgroundColor: (theme) => theme.palette.action.hover
49+
}}
50+
>
51+
<Link
52+
component={RouterLink}
53+
to={`${routes.CHANGE_REQUESTS}/${ic.changeRequestId}`}
54+
underline="hover"
55+
sx={{ fontWeight: 600, flexShrink: 0 }}
56+
>
57+
#{ic.changeRequestIdentifier}
58+
</Link>
59+
<Typography component="span" sx={{ wordBreak: 'break-word' }}>
60+
{renderDetailWithLinks(ic.detail)}
61+
<Typography component="span" sx={{ color: 'text.secondary', ml: 0.75 }}>
62+
{fullNamePipe(ic.implementer)}
63+
</Typography>
64+
</Typography>
65+
<Typography variant="caption" sx={{ color: 'text.secondary', whiteSpace: 'nowrap', flexShrink: 0, ml: 'auto' }}>
66+
{datePipe(ic.dateImplemented)}
67+
</Typography>
68+
</Box>
69+
))}
70+
</Stack>
4071
);
4172
};
4273

0 commit comments

Comments
 (0)