Skip to content

Commit c3f4c73

Browse files
authored
Merge pull request #2742 from objectcomputing/develop
Update 0.8.x from develop
2 parents 6bfba57 + db99c9f commit c3f4c73

File tree

6 files changed

+158
-123
lines changed

6 files changed

+158
-123
lines changed

web-ui/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
"eslint-plugin-react-hooks": "^4.6.0",
9090
"eslint-plugin-vitest": "^0.5.4",
9191
"globals": "^15.0.0",
92-
"happy-dom": "^15.10.1",
92+
"happy-dom": "^15.10.2",
9393
"jest-fetch-mock": "^3.0.3",
9494
"jsdom": "^24.0.0",
9595
"msw": "^2.2.13",

web-ui/src/components/guild-results/EditGuildModal.jsx

+14-12
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import {
1111
FormControlLabel,
1212
Modal,
1313
Switch,
14-
TextField
14+
TextField,
15+
Checkbox,
1516
} from '@mui/material';
1617
import Autocomplete from '@mui/material/Autocomplete';
1718
import './EditGuildModal.css';
@@ -166,18 +167,19 @@ const EditGuildModal = ({ guild = {}, open, onSave, onClose, headerText }) => {
166167
value={editedGuild.name ? editedGuild.name : ''}
167168
onChange={e => setGuild({ ...editedGuild, name: e.target.value })}
168169
/>
169-
{guild.id && <FormControlLabel
170-
control={
171-
<Switch
172-
checked={editedGuild.active}
173-
onChange={event => {
174-
const { checked } = event.target;
175-
setGuild({ ...editedGuild, active: checked });
176-
}}
177-
/>
178-
}
170+
{guild.id && (<>
171+
<Checkbox
172+
id="guild-active-input"
179173
label="Active"
180-
/>}
174+
variant="outlined"
175+
className="halfWidth"
176+
checked={editedGuild.active ? editedGuild.active : false}
177+
onChange={event => {
178+
const { checked } = event.target;
179+
setGuild({ ...editedGuild, active: checked });
180+
}}
181+
/> Active
182+
</>)}
181183
</div>
182184
<div>
183185
<FormControlLabel

web-ui/src/components/team-results/TeamResults.jsx

+31-17
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
} from '../../context/selectors';
99
import TeamsActions from './TeamsActions';
1010
import PropTypes from 'prop-types';
11-
import { TextField } from '@mui/material';
11+
import { FormControlLabel, Switch, TextField } from '@mui/material';
1212
import './TeamResults.css';
1313
import SkeletonLoader from '../skeleton_loader/SkeletonLoader';
1414
import { useQueryParameters } from '../../helpers/query-parameters';
@@ -40,22 +40,11 @@ const TeamResults = () => {
4040
const { state } = useContext(AppContext);
4141
const loading = selectTeamsLoading(state);
4242
const [addingTeam, setAddingTeam] = useState(false);
43+
const [activeTeams, setActiveTeams] = useState(true);
4344
const [searchText, setSearchText] = useState('');
4445
const [selectedTeamId, setSelectedTeamId] = useState('');
4546
const teams = selectNormalizedTeams(state, searchText);
4647

47-
const teamCards = teams.map((team, index) => {
48-
return (
49-
<TeamSummaryCard
50-
key={`team-summary-${team.id}`}
51-
index={index}
52-
team={team}
53-
onTeamSelect={setSelectedTeamId}
54-
selectedTeamId={selectedTeamId}
55-
/>
56-
);
57-
});
58-
5948
useQueryParameters([
6049
{
6150
name: 'addNew',
@@ -89,16 +78,41 @@ const TeamResults = () => {
8978
setSearchText(e.target.value);
9079
}}
9180
/>
92-
<TeamsActions isOpen={addingTeam} onOpen={setAddingTeam} />
81+
<div className="team-actions">
82+
<TeamsActions isOpen={addingTeam} onOpen={setAddingTeam} />
83+
<FormControlLabel
84+
control={
85+
<Switch
86+
checked={activeTeams}
87+
onChange={event => {
88+
const { checked } = event.target;
89+
setActiveTeams(checked);
90+
}}
91+
/>
92+
}
93+
label="Active Teams Only"
94+
/>
95+
</div>
9396
</div>
9497
<div className="teams">
9598
{loading
9699
? Array.from({ length: 20 }).map((_, index) => (
97100
<SkeletonLoader key={index} type="team" />
98101
))
99-
: teams?.length && !loading
100-
? teamCards
101-
: null}
102+
: teams.filter((team) => !activeTeams ||
103+
(activeTeams && team.active))
104+
.map((team, index) => {
105+
return (
106+
<TeamSummaryCard
107+
key={`team-summary-${team.id}`}
108+
index={index}
109+
team={team}
110+
onTeamSelect={setSelectedTeamId}
111+
selectedTeamId={selectedTeamId}
112+
/>
113+
);
114+
})
115+
}
102116
</div>
103117
</Root>
104118
);

web-ui/src/components/team-results/TeamSummaryCard.jsx

+2-53
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
Tooltip
2020
} from '@mui/material';
2121
import PropTypes from 'prop-types';
22-
import { deleteTeam, updateTeam } from '../../api/team.js';
22+
import { updateTeam } from '../../api/team.js';
2323
import SplitButton from '../split-button/SplitButton';
2424

2525
const PREFIX = 'TeamSummaryCard';
@@ -59,7 +59,6 @@ const displayName = 'TeamSummaryCard';
5959
const TeamSummaryCard = ({ team, index, onTeamSelect, selectedTeamId }) => {
6060
const { state, dispatch } = useContext(AppContext);
6161
const { teams, userProfile, csrf } = state;
62-
const [openDelete, setOpenDelete] = useState(false);
6362
const [openKudos, setOpenKudos] = useState(false);
6463
// const [selectedTeam, setSelectedTeam] = useState(null);
6564
const [tooltipIsOpen, setTooltipIsOpen] = useState(false);
@@ -81,45 +80,16 @@ const TeamSummaryCard = ({ team, index, onTeamSelect, selectedTeamId }) => {
8180
? false
8281
: leads.some(lead => lead.memberId === userProfile.memberProfile.id);
8382

84-
const handleOpenDeleteConfirmation = () => setOpenDelete(true);
8583
const handleOpenKudos = () => setOpenKudos(true);
86-
87-
const handleCloseDeleteConfirmation = () => setOpenDelete(false);
8884
const handleCloseKudos = () => setOpenKudos(false);
8985

90-
const teamId = team?.id;
91-
const deleteATeam = useCallback(async () => {
92-
if (teamId && csrf) {
93-
const result = await deleteTeam(teamId, csrf);
94-
if (result && result.payload && result.payload.status === 200) {
95-
window.snackDispatch({
96-
type: UPDATE_TOAST,
97-
payload: {
98-
severity: 'success',
99-
toast: 'Team deleted'
100-
}
101-
});
102-
let newTeams = teams.filter(team => {
103-
return team.id !== teamId;
104-
});
105-
dispatch({
106-
type: UPDATE_TEAMS,
107-
payload: newTeams
108-
});
109-
}
110-
}
111-
}, [teamId, csrf, dispatch, teams]);
112-
113-
const options =
114-
isAdmin || isTeamLead ? ['Edit Team', 'Give Kudos', 'Delete Team'] : ['Edit Team', 'Give Kudos'];
86+
const options = ['Edit Team', 'Give Kudos'];
11587

11688
const handleAction = (e, index) => {
11789
if (index === 0) {
11890
onTeamSelect(team.id);
11991
} else if (index === 1) {
12092
handleOpenKudos();
121-
} else if (index === 2) {
122-
handleOpenDeleteConfirmation();
12393
}
12494
};
12595

@@ -195,27 +165,6 @@ const TeamSummaryCard = ({ team, index, onTeamSelect, selectedTeamId }) => {
195165
{(isAdmin || isTeamLead) && (
196166
<>
197167
<SplitButton options={options} onClick={handleAction} />
198-
<Dialog
199-
open={openDelete}
200-
onClose={handleCloseDeleteConfirmation}
201-
aria-labelledby="alert-dialog-title"
202-
aria-describedby="alert-dialog-description"
203-
>
204-
<DialogTitle id="alert-dialog-title">Delete team?</DialogTitle>
205-
<DialogContent>
206-
<DialogContentText id="alert-dialog-description">
207-
Are you sure you want to delete the team?
208-
</DialogContentText>
209-
</DialogContent>
210-
<DialogActions>
211-
<Button onClick={handleCloseDeleteConfirmation} color="primary">
212-
Cancel
213-
</Button>
214-
<Button onClick={deleteATeam} color="primary" autoFocus>
215-
Yes
216-
</Button>
217-
</DialogActions>
218-
</Dialog>
219168
<KudosDialog
220169
open={openKudos}
221170
onClose={handleCloseKudos}

web-ui/src/components/team-results/__snapshots__/TeamResults.test.jsx.snap

+106-36
Original file line numberDiff line numberDiff line change
@@ -47,31 +47,66 @@ exports[`renders correctly 1`] = `
4747
<div
4848
class="team-actions"
4949
>
50-
<button
51-
class="MuiButtonBase-root MuiButton-root MuiButton-text MuiButton-textPrimary MuiButton-sizeMedium MuiButton-textSizeMedium MuiButton-colorPrimary MuiButton-root MuiButton-text MuiButton-textPrimary MuiButton-sizeMedium MuiButton-textSizeMedium MuiButton-colorPrimary css-1e6y48t-MuiButtonBase-root-MuiButton-root"
52-
tabindex="0"
53-
type="button"
50+
<div
51+
class="team-actions"
52+
>
53+
<button
54+
class="MuiButtonBase-root MuiButton-root MuiButton-text MuiButton-textPrimary MuiButton-sizeMedium MuiButton-textSizeMedium MuiButton-colorPrimary MuiButton-root MuiButton-text MuiButton-textPrimary MuiButton-sizeMedium MuiButton-textSizeMedium MuiButton-colorPrimary css-1e6y48t-MuiButtonBase-root-MuiButton-root"
55+
tabindex="0"
56+
type="button"
57+
>
58+
<span
59+
class="MuiButton-icon MuiButton-startIcon MuiButton-iconSizeMedium css-1d6wzja-MuiButton-startIcon"
60+
>
61+
<svg
62+
aria-hidden="true"
63+
class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-i4bv87-MuiSvgIcon-root"
64+
data-testid="GroupIcon"
65+
focusable="false"
66+
viewBox="0 0 24 24"
67+
>
68+
<path
69+
d="M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5c-1.66 0-3 1.34-3 3s1.34 3 3 3m-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5C6.34 5 5 6.34 5 8s1.34 3 3 3m0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5c0-2.33-4.67-3.5-7-3.5m8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5"
70+
/>
71+
</svg>
72+
</span>
73+
Add Team
74+
<span
75+
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
76+
/>
77+
</button>
78+
</div>
79+
<label
80+
class="MuiFormControlLabel-root MuiFormControlLabel-labelPlacementEnd css-j204z7-MuiFormControlLabel-root"
5481
>
5582
<span
56-
class="MuiButton-icon MuiButton-startIcon MuiButton-iconSizeMedium css-1d6wzja-MuiButton-startIcon"
83+
class="MuiSwitch-root MuiSwitch-sizeMedium css-julti5-MuiSwitch-root"
5784
>
58-
<svg
59-
aria-hidden="true"
60-
class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-i4bv87-MuiSvgIcon-root"
61-
data-testid="GroupIcon"
62-
focusable="false"
63-
viewBox="0 0 24 24"
85+
<span
86+
class="MuiButtonBase-root MuiSwitch-switchBase MuiSwitch-colorPrimary Mui-checked PrivateSwitchBase-root MuiSwitch-switchBase MuiSwitch-colorPrimary Mui-checked Mui-checked css-byenzh-MuiButtonBase-root-MuiSwitch-switchBase"
6487
>
65-
<path
66-
d="M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5c-1.66 0-3 1.34-3 3s1.34 3 3 3m-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5C6.34 5 5 6.34 5 8s1.34 3 3 3m0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5c0-2.33-4.67-3.5-7-3.5m8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5"
88+
<input
89+
checked=""
90+
class="PrivateSwitchBase-input MuiSwitch-input css-1m9pwf3"
91+
type="checkbox"
6792
/>
68-
</svg>
93+
<span
94+
class="MuiSwitch-thumb css-jsexje-MuiSwitch-thumb"
95+
/>
96+
<span
97+
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
98+
/>
99+
</span>
100+
<span
101+
class="MuiSwitch-track css-1yjjitx-MuiSwitch-track"
102+
/>
69103
</span>
70-
Add Team
71104
<span
72-
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
73-
/>
74-
</button>
105+
class="MuiTypography-root MuiTypography-body1 MuiFormControlLabel-label css-ahj2mt-MuiTypography-root"
106+
>
107+
Active Teams Only
108+
</span>
109+
</label>
75110
</div>
76111
</div>
77112
<div
@@ -128,31 +163,66 @@ exports[`renders correctly when no teams are loaded 1`] = `
128163
<div
129164
class="team-actions"
130165
>
131-
<button
132-
class="MuiButtonBase-root MuiButton-root MuiButton-text MuiButton-textPrimary MuiButton-sizeMedium MuiButton-textSizeMedium MuiButton-colorPrimary MuiButton-root MuiButton-text MuiButton-textPrimary MuiButton-sizeMedium MuiButton-textSizeMedium MuiButton-colorPrimary css-1e6y48t-MuiButtonBase-root-MuiButton-root"
133-
tabindex="0"
134-
type="button"
166+
<div
167+
class="team-actions"
168+
>
169+
<button
170+
class="MuiButtonBase-root MuiButton-root MuiButton-text MuiButton-textPrimary MuiButton-sizeMedium MuiButton-textSizeMedium MuiButton-colorPrimary MuiButton-root MuiButton-text MuiButton-textPrimary MuiButton-sizeMedium MuiButton-textSizeMedium MuiButton-colorPrimary css-1e6y48t-MuiButtonBase-root-MuiButton-root"
171+
tabindex="0"
172+
type="button"
173+
>
174+
<span
175+
class="MuiButton-icon MuiButton-startIcon MuiButton-iconSizeMedium css-1d6wzja-MuiButton-startIcon"
176+
>
177+
<svg
178+
aria-hidden="true"
179+
class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-i4bv87-MuiSvgIcon-root"
180+
data-testid="GroupIcon"
181+
focusable="false"
182+
viewBox="0 0 24 24"
183+
>
184+
<path
185+
d="M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5c-1.66 0-3 1.34-3 3s1.34 3 3 3m-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5C6.34 5 5 6.34 5 8s1.34 3 3 3m0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5c0-2.33-4.67-3.5-7-3.5m8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5"
186+
/>
187+
</svg>
188+
</span>
189+
Add Team
190+
<span
191+
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
192+
/>
193+
</button>
194+
</div>
195+
<label
196+
class="MuiFormControlLabel-root MuiFormControlLabel-labelPlacementEnd css-j204z7-MuiFormControlLabel-root"
135197
>
136198
<span
137-
class="MuiButton-icon MuiButton-startIcon MuiButton-iconSizeMedium css-1d6wzja-MuiButton-startIcon"
199+
class="MuiSwitch-root MuiSwitch-sizeMedium css-julti5-MuiSwitch-root"
138200
>
139-
<svg
140-
aria-hidden="true"
141-
class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-i4bv87-MuiSvgIcon-root"
142-
data-testid="GroupIcon"
143-
focusable="false"
144-
viewBox="0 0 24 24"
201+
<span
202+
class="MuiButtonBase-root MuiSwitch-switchBase MuiSwitch-colorPrimary Mui-checked PrivateSwitchBase-root MuiSwitch-switchBase MuiSwitch-colorPrimary Mui-checked Mui-checked css-byenzh-MuiButtonBase-root-MuiSwitch-switchBase"
145203
>
146-
<path
147-
d="M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5c-1.66 0-3 1.34-3 3s1.34 3 3 3m-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5C6.34 5 5 6.34 5 8s1.34 3 3 3m0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5c0-2.33-4.67-3.5-7-3.5m8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5"
204+
<input
205+
checked=""
206+
class="PrivateSwitchBase-input MuiSwitch-input css-1m9pwf3"
207+
type="checkbox"
148208
/>
149-
</svg>
209+
<span
210+
class="MuiSwitch-thumb css-jsexje-MuiSwitch-thumb"
211+
/>
212+
<span
213+
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
214+
/>
215+
</span>
216+
<span
217+
class="MuiSwitch-track css-1yjjitx-MuiSwitch-track"
218+
/>
150219
</span>
151-
Add Team
152220
<span
153-
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
154-
/>
155-
</button>
221+
class="MuiTypography-root MuiTypography-body1 MuiFormControlLabel-label css-ahj2mt-MuiTypography-root"
222+
>
223+
Active Teams Only
224+
</span>
225+
</label>
156226
</div>
157227
</div>
158228
<div

0 commit comments

Comments
 (0)