Skip to content

Commit 6291cc0

Browse files
authored
Merge pull request #1749 from Northeastern-Electric-Racing/#1650-standard-cr-page
#1650 standard cr page
2 parents ac5ca76 + d3c082b commit 6291cc0

17 files changed

Lines changed: 246 additions & 242 deletions

src/frontend/src/components/ChangeRequestDetailCard.tsx

Lines changed: 3 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
*/
55

66
import { Card, CardContent, Grid, Typography, useTheme } from '@mui/material';
7-
import Chip from '@mui/material/Chip';
8-
import { green, blue, red, grey, purple } from '@mui/material/colors';
97
import { Box, Stack } from '@mui/system';
108
import { Link } from '@mui/material';
119
import {
@@ -19,55 +17,8 @@ import {
1917
import { routes } from '../utils/routes';
2018
import { Link as RouterLink } from 'react-router-dom';
2119
import { fullNamePipe } from '../utils/pipes';
22-
import { ChangeRequestTypeTextPipe, ChangeRequestStatusTextPipe } from '../utils/enum-pipes';
23-
24-
const determineChangeRequestStatusPillColor = (status: ChangeRequestStatus) => {
25-
switch (status) {
26-
case ChangeRequestStatus.Implemented:
27-
return blue[600];
28-
case ChangeRequestStatus.Accepted:
29-
return green[600];
30-
case ChangeRequestStatus.Denied:
31-
return red[400];
32-
case ChangeRequestStatus.Open:
33-
return purple[400];
34-
default:
35-
return grey[500];
36-
}
37-
};
38-
39-
const ChangeRequestTypePill = ({ type }: { type: ChangeRequestType }) => {
40-
return (
41-
<Chip
42-
size="small"
43-
label={ChangeRequestTypeTextPipe(type)}
44-
variant="filled"
45-
sx={{
46-
fontSize: 12,
47-
color: 'white',
48-
backgroundColor: red[600],
49-
width: 100
50-
}}
51-
/>
52-
);
53-
};
54-
55-
const ChangeRequestStatusPill = ({ status }: { status: ChangeRequestStatus }) => {
56-
const statusPillColor = determineChangeRequestStatusPillColor(status);
57-
return (
58-
<Chip
59-
size="small"
60-
label={ChangeRequestStatusTextPipe(status)}
61-
variant="filled"
62-
sx={{
63-
fontSize: 12,
64-
color: 'white',
65-
backgroundColor: statusPillColor,
66-
width: 100
67-
}}
68-
/>
69-
);
70-
};
20+
import ChangeRequestTypePill from './ChangeRequestTypePill';
21+
import ChangeRequestStatusPill from './ChangeRequestStatusPill';
7122

7223
const CRCardDescription = ({ cr }: { cr: ChangeRequest }) => {
7324
const theme = useTheme();
@@ -118,7 +69,7 @@ interface ChangeRequestDetailCardProps {
11869

11970
const ChangeRequestDetailCard: React.FC<ChangeRequestDetailCardProps> = ({ changeRequest }) => {
12071
return (
121-
<Card sx={{ width: 325, mr: 2, borderRadius: 3, mb: 2 }}>
72+
<Card sx={{ minWidth: 325, maxWidth: 325, mr: 2, borderRadius: 3, mb: 2 }}>
12273
<CardContent>
12374
<Grid container justifyContent="space-between" alignItems="flex-start">
12475
<Grid item xs mb={1} mt={-1.5}>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* This file is part of NER's FinishLine and licensed under GNU AGPLv3.
3+
* See the LICENSE file in the repository root folder for details.
4+
*/
5+
6+
import Chip from '@mui/material/Chip';
7+
import { green, blue, red, grey, purple } from '@mui/material/colors';
8+
import { ChangeRequestStatus } from 'shared';
9+
import { ChangeRequestStatusTextPipe } from '../utils/enum-pipes';
10+
11+
const determineChangeRequestStatusPillColor = (status: ChangeRequestStatus) => {
12+
switch (status) {
13+
case ChangeRequestStatus.Implemented:
14+
return blue[600];
15+
case ChangeRequestStatus.Accepted:
16+
return green[600];
17+
case ChangeRequestStatus.Denied:
18+
return red[400];
19+
case ChangeRequestStatus.Open:
20+
return purple[400];
21+
default:
22+
return grey[500];
23+
}
24+
};
25+
26+
const ChangeRequestStatusPill = ({ status }: { status: ChangeRequestStatus }) => {
27+
const statusPillColor = determineChangeRequestStatusPillColor(status);
28+
return (
29+
<Chip
30+
size="small"
31+
label={ChangeRequestStatusTextPipe(status)}
32+
variant="filled"
33+
sx={{
34+
fontSize: 12,
35+
color: 'white',
36+
backgroundColor: statusPillColor,
37+
width: 100
38+
}}
39+
/>
40+
);
41+
};
42+
43+
export default ChangeRequestStatusPill;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Chip } from '@mui/material';
2+
import { ChangeRequestType } from 'shared';
3+
import { ChangeRequestTypeTextPipe } from '../utils/enum-pipes';
4+
import { red } from '@mui/material/colors';
5+
6+
const ChangeRequestTypePill = ({ type }: { type: ChangeRequestType }) => {
7+
return (
8+
<Chip
9+
size="small"
10+
label={ChangeRequestTypeTextPipe(type)}
11+
variant="filled"
12+
sx={{
13+
fontSize: 12,
14+
color: 'white',
15+
backgroundColor: red[600],
16+
width: 100
17+
}}
18+
/>
19+
);
20+
};
21+
22+
export default ChangeRequestTypePill;

src/frontend/src/components/InfoBlock.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,24 @@
55

66
import Typography from '@mui/material/Typography';
77
import { Grid } from '@mui/material';
8+
import { ReactNode } from 'react';
89

910
interface InfoBlockProps {
1011
title: string;
12+
icon?: ReactNode;
1113
}
1214

1315
/**
1416
* Custom component for a consistent page-building block.
1517
* @param title The title of the block on the page
1618
* @param children The children of the block
1719
*/
18-
const InfoBlock: React.FC<InfoBlockProps> = ({ title, children }) => {
20+
const InfoBlock: React.FC<InfoBlockProps> = ({ title, icon, children }) => {
1921
return (
2022
<Grid container spacing={1}>
21-
<Grid item xs={12}>
23+
<Grid item xs={12} display="flex" gap="5px" alignItems="center">
2224
<Typography sx={{ fontWeight: 'bold', fontSize: '19px' }}>{title}</Typography>
25+
{icon}
2326
</Grid>
2427
<Grid item xs={12}>
2528
{children}

src/frontend/src/components/PageLayout.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { Box } from '@mui/system';
1111

1212
interface PageLayoutProps {
1313
title?: string;
14+
chips?: ReactNode;
1415
hidePageTitle?: boolean;
1516
previousPages?: LinkItem[];
1617
headerRight?: ReactNode;
@@ -21,6 +22,7 @@ interface PageLayoutProps {
2122
const PageLayout: React.FC<PageLayoutProps> = ({
2223
children,
2324
title,
25+
chips,
2426
hidePageTitle = false,
2527
previousPages = [],
2628
headerRight,
@@ -33,7 +35,9 @@ const PageLayout: React.FC<PageLayoutProps> = ({
3335
<title>{`FinishLine ${title && `| ${title}`}`}</title>
3436
<meta name="description" content="FinishLine Project Management Dashboard" />
3537
</Helmet>
36-
{!hidePageTitle && title && <PageTitle sticky={stickyHeader} {...{ title, previousPages, headerRight, tabs }} />}
38+
{!hidePageTitle && title && (
39+
<PageTitle sticky={stickyHeader} {...{ title, chips, previousPages, headerRight, tabs }} />
40+
)}
3741
{children}
3842
</Box>
3943
);

src/frontend/src/layouts/PageTitle/PageTitle.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import PageBreadcrumbs from './PageBreadcrumbs';
1010

1111
interface PageTitleProps {
1212
title: string;
13+
chips?: ReactNode;
1314
previousPages: LinkItem[];
1415
headerRight?: ReactNode;
1516
tabs?: ReactElement;
@@ -23,7 +24,7 @@ interface PageTitleProps {
2324
* @param headerRight The button to display on the right side of the page title
2425
* @param tabs The tabs on the page to display.
2526
*/
26-
const PageTitle: React.FC<PageTitleProps> = ({ title, previousPages, headerRight, tabs, sticky }) => {
27+
const PageTitle: React.FC<PageTitleProps> = ({ title, chips, previousPages, headerRight, tabs, sticky }) => {
2728
const theme = useTheme();
2829

2930
return (
@@ -39,13 +40,18 @@ const PageTitle: React.FC<PageTitleProps> = ({ title, previousPages, headerRight
3940
zIndex={1}
4041
bgcolor={theme.palette.background.default}
4142
>
42-
<Grid container rowSpacing={1}>
43-
<Grid item xs={6} md={4}>
44-
<Typography variant="h4" fontSize={30}>
45-
{title}
46-
</Typography>
43+
<Grid container>
44+
<Grid container item xs={6} md={tabs ? 4 : 8} display="flex" alignItems={'center'} rowGap={2}>
45+
<Grid item xs={12} md={chips ? 4 : 12}>
46+
<Typography variant="h4" fontSize={30}>
47+
{title}
48+
</Typography>
49+
</Grid>
50+
<Grid item xs={chips ? 12 : 0} md={chips ? 6 : 0}>
51+
{chips}
52+
</Grid>
4753
</Grid>
48-
<Grid item xs={0} md={4} sx={{ display: { xs: 'none', md: 'block' } }}>
54+
<Grid item xs={0} md={tabs ? 4 : 0} sx={{ display: { xs: 'none', md: 'block' } }}>
4955
{tabs}
5056
</Grid>
5157
<Grid item xs={6} md={4} textAlign={['left', 'right']}>

src/frontend/src/pages/ChangeRequestDetailPage/ActivationDetails.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,29 @@ import { datePipe, fullNamePipe } from '../../utils/pipes';
88
import Grid from '@mui/material/Grid';
99
import Typography from '@mui/material/Typography';
1010
import InfoBlock from '../../components/InfoBlock';
11+
import HandymanIcon from '@mui/icons-material/Handyman';
12+
import WorkIcon from '@mui/icons-material/Work';
13+
import CalendarTodayIcon from '@mui/icons-material/CalendarToday';
1114

1215
interface ActivationDetailsProps {
1316
cr: ActivationChangeRequest;
1417
}
1518

1619
const ActivationDetails: React.FC<ActivationDetailsProps> = ({ cr }) => {
1720
return (
18-
<Grid container>
19-
<Grid item xs={6} md={2}>
20-
<InfoBlock title={'Project Lead'}>
21+
<Grid container rowSpacing={'10px'} mb="40px">
22+
<Grid item xs={6} md={6}>
23+
<InfoBlock title={'Project Lead'} icon={<HandymanIcon />}>
2124
<Typography>{fullNamePipe(cr.projectLead)}</Typography>
2225
</InfoBlock>
2326
</Grid>
24-
<Grid item xs={6} md={2}>
25-
<InfoBlock title={'Project Manager'}>
27+
<Grid item xs={6} md={6}>
28+
<InfoBlock title={'Project Manager'} icon={<WorkIcon />}>
2629
<Typography>{fullNamePipe(cr.projectManager)}</Typography>
2730
</InfoBlock>
2831
</Grid>
29-
<Grid item xs={6} md={2}>
30-
<InfoBlock title={'Start Date'}>
32+
<Grid item xs={6} md={6}>
33+
<InfoBlock title={'Start Date'} icon={<CalendarTodayIcon />}>
3134
<Typography>{datePipe(cr.startDate)}</Typography>
3235
</InfoBlock>
3336
</Grid>

0 commit comments

Comments
 (0)