Skip to content

Commit 92baed7

Browse files
authored
Merge branch 'develop' into #1457-JackMitchellCredits
2 parents 7d00e2d + 6e0eeab commit 92baed7

7 files changed

Lines changed: 84 additions & 7 deletions

File tree

src/frontend/src/pages/CreateChangeRequestPage/CreateChangeRequestView.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import NERFailButton from '../../components/NERFailButton';
3636
import NERSuccessButton from '../../components/NERSuccessButton';
3737
import { wbsNamePipe } from '../../utils/pipes';
3838
import PageLayout from '../../components/PageLayout';
39+
import { wbsNumComparator } from 'shared/src/validate-wbs';
3940

4041
interface CreateChangeRequestViewProps {
4142
wbsNum: string;
@@ -103,6 +104,7 @@ const CreateChangeRequestsView: React.FC<CreateChangeRequestViewProps> = ({
103104
if (isError) return <ErrorPage message={error?.message} />;
104105

105106
const projectOptions: { label: string; id: string }[] = [];
107+
106108
const wbsDropdownOptions: { label: string; id: string }[] = [];
107109

108110
projects.forEach((project: Project) => {
@@ -122,6 +124,8 @@ const CreateChangeRequestsView: React.FC<CreateChangeRequestViewProps> = ({
122124
});
123125
});
124126

127+
wbsDropdownOptions.sort((wbsNum1, wbsNum2) => wbsNumComparator(wbsNum1.id, wbsNum2.id));
128+
125129
const wbsAutocompleteOnChange = (
126130
_event: React.SyntheticEvent<Element, Event>,
127131
value: { label: string; id: string } | null

src/frontend/src/pages/CreditsPage/CreditsPage.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ const CreditsPage: React.FC = () => {
8888
{ name: 'Daniel Yu', color: '#bdc0c7' },
8989
{ name: 'Jake Wu-Chen', color: '#bdc0c7' },
9090
{ name: 'William Seward', color: '#e53774' },
91+
{ name: 'Quinn Louie', color: '#3281a8' },
9192
{ name: 'Liu von Engelbrechten', color: '#2969f2' },
9293
{
9394
name: 'Zach Norman',
@@ -136,6 +137,9 @@ const CreditsPage: React.FC = () => {
136137
{ name: 'Lily Shiomitsu', color: '#008080' },
137138
{ name: 'Kevin Yang', color: '#0000FF' },
138139
{ name: 'Jack Mitchell', color: '808000' },
140+
{ name: 'Zoey Guo', color: '#E34949' },
141+
{ name: 'Qihong Wu', color: '#87CEEB' },
142+
{ name: 'Jessica Zhao', color: '#6495ED' },
139143
{ name: 'Neel Raut', color: '#023665' },
140144
{ name: 'Qihong Wu', color: '#87CEEB' },
141145
{ name: 'Megan Lai', color: '#52B2BF' },

src/frontend/src/pages/SettingsPage/UserSecureSettings/UserSecureSettings.tsx

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import PageBlock from '../../../layouts/PageBlock';
1111
import ErrorPage from '../../ErrorPage';
1212
import NERSuccessButton from '../../../components/NERSuccessButton';
1313
import NERFailButton from '../../../components/NERFailButton';
14-
import { Grid, IconButton } from '@mui/material';
14+
import { Grid, IconButton, Box } from '@mui/material';
1515
import { useToast } from '../../../hooks/toasts.hooks';
1616
import UserSecureSettingsView from './UserSecureSettingsView';
1717
import UserSecureSettingsEdit from './UserSecureSettingsEdit';
@@ -71,12 +71,17 @@ const UserSecureSettings: React.FC<SecureSettingsProps> = ({ currentSettings })
7171
<EditIcon fontSize="small" />
7272
</IconButton>
7373
) : (
74-
<div className="d-flex flex-row">
74+
<Box
75+
className="d-flex flex-row"
76+
sx={{
77+
display: { xs: 'none', sm: 'flex' }
78+
}}
79+
>
7580
<NERFailButton onClick={() => setEdit(false)}>Cancel</NERFailButton>
7681
<NERSuccessButton sx={{ ml: 2 }} type="submit" form="update-user-settings">
7782
Save
7883
</NERSuccessButton>
79-
</div>
84+
</Box>
8085
)
8186
}
8287
>
@@ -87,6 +92,19 @@ const UserSecureSettings: React.FC<SecureSettingsProps> = ({ currentSettings })
8792
<UserSecureSettingsEdit currentSettings={currentSettings} onSubmit={handleConfirm} />
8893
)}
8994
</Grid>
95+
{edit && (
96+
<Box
97+
sx={{
98+
display: { xs: 'flex', sm: 'none' },
99+
marginTop: '20px'
100+
}}
101+
>
102+
<NERFailButton onClick={() => setEdit(false)}>Cancel</NERFailButton>
103+
<NERSuccessButton sx={{ ml: 2 }} type="submit" form="update-user-settings">
104+
Save
105+
</NERSuccessButton>
106+
</Box>
107+
)}
90108
</PageBlock>
91109
);
92110
};

src/frontend/src/pages/SettingsPage/UserSettings/UserSettings.tsx

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import UserSettingsEdit from './UserSettingsEdit';
1414
import UserSettingsView from './UserSettingsView';
1515
import NERSuccessButton from '../../../components/NERSuccessButton';
1616
import NERFailButton from '../../../components/NERFailButton';
17-
import { Grid, IconButton } from '@mui/material';
17+
import { Grid, IconButton, Box } from '@mui/material';
1818
import { useToast } from '../../../hooks/toasts.hooks';
1919

2020
interface UserSettingsProps {
@@ -63,12 +63,16 @@ const UserSettings: React.FC<UserSettingsProps> = ({ currentSettings }) => {
6363
<EditIcon fontSize="small" />
6464
</IconButton>
6565
) : (
66-
<div className="d-flex flex-row">
66+
<Box
67+
sx={{
68+
display: { xs: 'none', sm: 'flex' }
69+
}}
70+
>
6771
<NERFailButton onClick={() => setEdit(false)}>Cancel</NERFailButton>
6872
<NERSuccessButton sx={{ ml: 2 }} type="submit" form="update-user-settings">
6973
Save
7074
</NERSuccessButton>
71-
</div>
75+
</Box>
7276
)
7377
}
7478
>
@@ -79,6 +83,20 @@ const UserSettings: React.FC<UserSettingsProps> = ({ currentSettings }) => {
7983
<UserSettingsEdit currentSettings={currentSettings} onSubmit={handleConfirm} />
8084
)}
8185
</Grid>
86+
{edit && (
87+
<Box
88+
className="d-flex flex-col"
89+
sx={{
90+
display: { xs: 'flex', sm: 'none' },
91+
marginTop: '20px'
92+
}}
93+
>
94+
<NERFailButton onClick={() => setEdit(false)}>Cancel</NERFailButton>
95+
<NERSuccessButton sx={{ ml: 2 }} type="submit" form="update-user-settings">
96+
Save
97+
</NERSuccessButton>
98+
</Box>
99+
)}
82100
</PageBlock>
83101
);
84102
};

src/frontend/src/tests/pages/SettingsPage/UserSettings/UserSettings.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,6 @@ describe('user settings component', () => {
9797
mockUserSettingsHook(false, false, exampleUserSettingsLight);
9898
renderComponent();
9999
fireEvent.click(screen.getByRole('button'));
100-
expect(screen.queryAllByRole('button').map((e) => e.innerHTML)).toStrictEqual(['Cancel', 'Save']);
100+
expect(screen.queryAllByRole('button').map((e) => e.innerHTML)).toStrictEqual(['Cancel', 'Save', 'Cancel', 'Save']);
101101
});
102102
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { wbsNumComparator } from 'shared';
2+
import '@testing-library/jest-dom/extend-expect';
3+
4+
describe('wbsNumComparator', () => {
5+
it('should correctly compare two WBS Numbers', () => {
6+
expect(wbsNumComparator('1.1.3', '1.3.4')).toBe(-1);
7+
expect(wbsNumComparator('1.2.1', '1.2.1')).toBe(0);
8+
expect(wbsNumComparator('1.3.4', '1.1.3')).toBe(1);
9+
expect(wbsNumComparator('2.3.4', '1.1.3')).toBe(1);
10+
expect(wbsNumComparator('1.3.4', '2.1.3')).toBe(-1);
11+
});
12+
});

src/shared/src/validate-wbs.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,27 @@
55

66
import { WbsNumber } from './types/project-types';
77

8+
/**
9+
* Compares two wbs numbers in ascending order
10+
*
11+
* @param wbsNum1 WBS number to compare
12+
* @param wbsNum2 WBS number to compare
13+
*/
14+
export const wbsNumComparator = (wbsNum1: string, wbsNum2: string) => {
15+
const wbsParts1 = wbsNum1.split('.').map(Number);
16+
const wbsParts2 = wbsNum2.split('.').map(Number);
17+
18+
for (let i = 0; i < wbsParts1.length; i++) {
19+
if (wbsParts1[i] < wbsParts2[i]) {
20+
return -1;
21+
} else if (wbsParts1[i] > wbsParts2[i]) {
22+
return 1;
23+
}
24+
}
25+
26+
return 0;
27+
};
28+
829
/**
930
* Ensure the provided wbsNum is a valid Work Breakdown Structure Number
1031
*

0 commit comments

Comments
 (0)