Skip to content

Commit 7eb6358

Browse files
authored
Merge pull request #1676 from Northeastern-Electric-Racing/#1641-other-CRs-from-user-popup
#1641 other CRs from user popup
2 parents ba58ae6 + cb24fbc commit 7eb6358

3 files changed

Lines changed: 126 additions & 1 deletion

File tree

src/frontend/src/components/ChangeRequestDetailCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ const ChangeRequestDetailCard: React.FC<ChangeRequestDetailCardProps> = ({ chang
106106
const ChangeRequestTypeView = () => determineChangeRequestTypeView(changeRequest);
107107
const pillColor = determineChangeRequestPillColor(changeRequest.type);
108108
return (
109-
<Card sx={{ width: 300, mr: 1, mb: 1, borderRadius: 5 }}>
109+
<Card sx={{ minWidth: 300, width: 300, mr: 1, mb: 1, borderRadius: 5 }}>
110110
<CardContent>
111111
<Grid container justifyContent="space-between" alignItems="center">
112112
<Grid item>

src/frontend/src/pages/ChangeRequestDetailPage/ChangeRequestDetailsView.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import LoadingIndicator from '../../components/LoadingIndicator';
3030
import ErrorPage from '../ErrorPage';
3131
import PageLayout from '../../components/PageLayout';
3232
import ChangeRequestActionMenu from './ChangeRequestActionMenu';
33+
import OtherChangeRequestsPopupTabs from './OtherChangeRequestsPopupTabs';
3334

3435
const buildDetails = (cr: ChangeRequest): ReactElement => {
3536
switch (cr.type) {
@@ -152,6 +153,7 @@ const ChangeRequestDetailsView: React.FC<ChangeRequestDetailsProps> = ({
152153
{deleteModalShow && (
153154
<DeleteChangeRequest modalShow={deleteModalShow} handleClose={handleDeleteClose} cr={changeRequest} />
154155
)}
156+
<OtherChangeRequestsPopupTabs changeRequest={changeRequest} />
155157
</PageLayout>
156158
);
157159
};
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
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 React, { useState } from 'react';
7+
import { Box, useTheme, Collapse, Tabs, Tab, Typography } from '@mui/material';
8+
import { ChangeRequest } from 'shared';
9+
import ChangeRequestDetailCard from '../../components/ChangeRequestDetailCard';
10+
import { useAllChangeRequests } from '../../hooks/change-requests.hooks';
11+
import { ExpandLess, ExpandMore } from '@mui/icons-material';
12+
import LoadingIndicator from '../../components/LoadingIndicator';
13+
import ErrorPage from '../ErrorPage';
14+
import { fullNamePipe } from '../../utils/pipes';
15+
16+
interface OtherChangeRequestsPopupTabsProps {
17+
changeRequest: ChangeRequest;
18+
}
19+
20+
const OtherChangeRequestsPopupTabs: React.FC<OtherChangeRequestsPopupTabsProps> = ({
21+
changeRequest
22+
}: OtherChangeRequestsPopupTabsProps) => {
23+
const theme = useTheme();
24+
const [tab, setTab] = useState(0);
25+
const { data: changeRequests, isError, isLoading, error } = useAllChangeRequests();
26+
27+
if (isLoading) return <LoadingIndicator />;
28+
if (isError) return <ErrorPage error={error} message={error.message} />;
29+
30+
// the CRs submitted or reviewed by the submitter of this CR
31+
const crsFromSubmitter = changeRequests
32+
?.filter(
33+
(cr) =>
34+
(cr.submitter.userId === changeRequest.submitter.userId || cr.reviewer?.userId === changeRequest.submitter.userId) &&
35+
cr.crId !== changeRequest.crId
36+
)
37+
.sort((a: ChangeRequest, b: ChangeRequest) => {
38+
return b.dateSubmitted.getTime() - a.dateSubmitted.getTime();
39+
});
40+
41+
const displayTab = (value: number, title: string) => (
42+
<Tab
43+
value={value}
44+
sx={{ borderRadius: '16px 16px 0 0' }}
45+
label={
46+
<Typography sx={{ display: 'flex' }}>
47+
{title}
48+
{tab === value ? <ExpandMore sx={{ pl: 0.5 }} /> : <ExpandLess sx={{ pl: 0.5 }} />}
49+
</Typography>
50+
}
51+
onClick={() => tab === value && setTab(0)}
52+
/>
53+
);
54+
55+
const displayCRCards = (crList: ChangeRequest[]) => (
56+
<Box
57+
sx={{
58+
display: 'flex',
59+
justifyContent: 'flex-start',
60+
padding: '20px',
61+
background: theme.palette.background.paper,
62+
borderTop: `solid 1px ${theme.palette.divider}`,
63+
borderLeft: `solid 1px ${theme.palette.divider}`,
64+
'&::-webkit-scrollbar': {
65+
height: '20px'
66+
},
67+
'&::-webkit-scrollbar-track': {
68+
backgroundColor: 'transparent'
69+
},
70+
'&::-webkit-scrollbar-thumb': {
71+
backgroundColor: theme.palette.divider,
72+
borderRadius: '20px',
73+
border: '6px solid transparent',
74+
backgroundClip: 'content-box'
75+
},
76+
overflowX: 'scroll'
77+
}}
78+
>
79+
{crList.length !== 0 ? (
80+
crList.map((cr: ChangeRequest) => <ChangeRequestDetailCard changeRequest={cr} />)
81+
) : (
82+
<Typography>No related change requests.</Typography>
83+
)}
84+
</Box>
85+
);
86+
87+
return (
88+
<Box
89+
sx={{
90+
position: 'fixed',
91+
bottom: '0px',
92+
left: '65px',
93+
width: 'calc(100% - 65px)'
94+
}}
95+
>
96+
<Tabs
97+
value={tab}
98+
onChange={(e, newValue: number) => setTab(newValue)}
99+
sx={{
100+
'.MuiTabs-indicator': {
101+
background: 'transparent'
102+
},
103+
'& button': {
104+
background: theme.palette.background.paper,
105+
border: `solid 1px ${theme.palette.divider}`,
106+
color: theme.palette.text.primary,
107+
textTransform: 'none'
108+
},
109+
'& button.Mui-selected': {
110+
color: theme.palette.text.primary,
111+
borderBottom: 'transparent'
112+
},
113+
mb: '-1px'
114+
}}
115+
>
116+
{displayTab(1, `Other CR's from ${fullNamePipe(changeRequest.submitter)}`)}
117+
</Tabs>
118+
<Collapse in={tab !== 0}>{tab === 1 && displayCRCards(crsFromSubmitter || [])}</Collapse>
119+
</Box>
120+
);
121+
};
122+
123+
export default OtherChangeRequestsPopupTabs;

0 commit comments

Comments
 (0)