From a225086bdb9f16f04a4479427538190a298d205e Mon Sep 17 00:00:00 2001 From: Chad Elliott Date: Thu, 7 Nov 2024 12:11:45 -0600 Subject: [PATCH 1/3] Show only active teams and guilds when creating the member selector dialog or kudos dialog. --- web-ui/src/components/kudos_dialog/KudosDialog.jsx | 4 ++-- .../MemberSelectorDialog.jsx | 8 ++++---- web-ui/src/context/selectors.js | 14 ++++++++++++-- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/web-ui/src/components/kudos_dialog/KudosDialog.jsx b/web-ui/src/components/kudos_dialog/KudosDialog.jsx index 79b6aa5842..92cc98a41a 100644 --- a/web-ui/src/components/kudos_dialog/KudosDialog.jsx +++ b/web-ui/src/components/kudos_dialog/KudosDialog.jsx @@ -29,7 +29,7 @@ import { AppContext } from '../../context/AppContext'; import { selectCsrfToken, selectCurrentUser, - selectNormalizedTeams, + selectActiveTeams, selectOrderedCurrentMemberProfiles, selectProfile } from '../../context/selectors'; @@ -65,7 +65,7 @@ const KudosDialog = ({ open, recipient, teamId, onClose }) => { ); const currentUser = selectCurrentUser(state); - const teams = selectNormalizedTeams(state, ''); + const teams = selectActiveTeams(state); const memberProfiles = selectOrderedCurrentMemberProfiles(state); const handleSubmit = useCallback(() => { diff --git a/web-ui/src/components/member_selector/member_selector_dialog/MemberSelectorDialog.jsx b/web-ui/src/components/member_selector/member_selector_dialog/MemberSelectorDialog.jsx index 79cd42f71b..a24fc85109 100644 --- a/web-ui/src/components/member_selector/member_selector_dialog/MemberSelectorDialog.jsx +++ b/web-ui/src/components/member_selector/member_selector_dialog/MemberSelectorDialog.jsx @@ -37,14 +37,14 @@ import { AppContext } from '../../../context/AppContext'; import { selectCsrfToken, selectCurrentMembers, - selectGuilds, + selectActiveGuilds, selectMappedUserRoles, selectRoles, selectSkills, selectSubordinates, selectSupervisors, selectTeamMembersBySupervisorId, - selectTeams + selectActiveTeams, } from '../../../context/selectors'; import { UPDATE_TOAST } from '../../../context/actions'; import { getMembersByTeam } from '../../../api/team'; @@ -172,14 +172,14 @@ const MemberSelectorDialog = ({ const getFilterOptions = () => { switch (filterType) { case FilterType.TEAM: - const teams = selectTeams(state); + const teams = selectActiveTeams(state); return { options: teams, label: team => team.name, equals: (team1, team2) => team1.id === team2.id }; case FilterType.GUILD: - const guilds = selectGuilds(state); + const guilds = selectActiveGuilds(state); return { options: guilds, label: guild => guild.name, diff --git a/web-ui/src/context/selectors.js b/web-ui/src/context/selectors.js index 725aa4a776..9ecfb34ed9 100644 --- a/web-ui/src/context/selectors.js +++ b/web-ui/src/context/selectors.js @@ -686,11 +686,21 @@ export const selectNormalizedTeams = createSelector( }) ); +export const selectActiveTeams = createSelector( + selectTeams, + (teams, searchText) => teams?.filter(team => team.active) +); + +export const selectActiveGuilds = createSelector( + selectGuilds, + (guilds, searchText) => guilds?.filter(guild => guild.active) +); + export const selectMyGuilds = createSelector( selectCurrentUserId, selectGuilds, (id, guilds) => - guilds?.filter(guild => + guilds?.filter(guild => guild.active && guild.guildMembers?.some(member => member.memberId === id) ) ); @@ -699,7 +709,7 @@ export const selectMyTeams = createSelector( selectCurrentUserId, selectTeams, (id, teams) => - teams?.filter(team => + teams?.filter(team => team.active && team.teamMembers?.some(member => member.memberId === id) ) ); From c9e9f15700fedef41294ab0ae4870a8be4bac43b Mon Sep 17 00:00:00 2001 From: Chad Elliott Date: Thu, 7 Nov 2024 12:12:29 -0600 Subject: [PATCH 2/3] Modified the active/inactive indicator on the Team Summary Card to be like the Guild Summary Card. --- .../team-results/TeamSummaryCard.jsx | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/web-ui/src/components/team-results/TeamSummaryCard.jsx b/web-ui/src/components/team-results/TeamSummaryCard.jsx index c60abe631a..450390b4bc 100644 --- a/web-ui/src/components/team-results/TeamSummaryCard.jsx +++ b/web-ui/src/components/team-results/TeamSummaryCard.jsx @@ -16,7 +16,8 @@ import { DialogContent, DialogContentText, DialogTitle, - Tooltip + Tooltip, + Typography, } from '@mui/material'; import PropTypes from 'prop-types'; import { updateTeam } from '../../api/team.js'; @@ -34,7 +35,8 @@ const StyledCard = styled(Card)({ width: '340px', display: 'flex', flexDirection: 'column', - justifyContent: 'space-between' + justifyContent: 'space-between', + position: 'relative', }, [`& .${classes.header}`]: { width: '100%' @@ -46,6 +48,11 @@ const StyledCard = styled(Card)({ } }); +const inactiveStyle = { + 'color': 'var(--action-disabled)', + 'font-size': '0.75em', +}; + const propTypes = { team: PropTypes.shape({ id: PropTypes.string, @@ -101,7 +108,7 @@ const TeamSummaryCard = ({ team, index, onTeamSelect, selectedTeamId }) => { title: classes.title, subheader: classes.title }} - title={team.name + (team.active ? ' (Active)' : ' (Inactive)')} + title={team.name} subheader={ { } /> + {!team.active && ( + + Inactive + + )} {team.teamMembers == null ? ( Team Leads: None Assigned From 0789090019c23ee18ccbaeba4168779fd9a64097 Mon Sep 17 00:00:00 2001 From: Chad Elliott Date: Thu, 7 Nov 2024 12:25:08 -0600 Subject: [PATCH 3/3] Updated snapshots. --- .../guild-results/EditGuildModal.spec.jsx | 6 +++-- .../MemberSelectorDialog.spec.jsx | 3 ++- .../TeamSummaryCard.test.jsx.snap | 27 ++++++++++++++----- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/web-ui/src/components/guild-results/EditGuildModal.spec.jsx b/web-ui/src/components/guild-results/EditGuildModal.spec.jsx index 0473bb1e01..dced872d30 100644 --- a/web-ui/src/components/guild-results/EditGuildModal.spec.jsx +++ b/web-ui/src/components/guild-results/EditGuildModal.spec.jsx @@ -34,12 +34,14 @@ const testGuild = { guildMembers: [ { id: 125, name: 'Guild Member' }, { id: 126, name: 'Other Member' } - ] + ], + active: true, }; const emptyGuild = { name: 'Test Guild', - description: 'A guild used for testing.' + description: 'A guild used for testing.', + active: true, }; const currentUserProfile = { diff --git a/web-ui/src/components/member_selector/member_selector_dialog/MemberSelectorDialog.spec.jsx b/web-ui/src/components/member_selector/member_selector_dialog/MemberSelectorDialog.spec.jsx index 5e5f8cc157..9d36237959 100644 --- a/web-ui/src/components/member_selector/member_selector_dialog/MemberSelectorDialog.spec.jsx +++ b/web-ui/src/components/member_selector/member_selector_dialog/MemberSelectorDialog.spec.jsx @@ -39,7 +39,8 @@ const testGuild = { name: 'Test Guild', description: 'A guild used for testing.', guildLeads: [{ id: 124, name: managerProfile.name }], - guildMembers: [] + guildMembers: [], + active: true, }; const initialState = { diff --git a/web-ui/src/components/team-results/__snapshots__/TeamSummaryCard.test.jsx.snap b/web-ui/src/components/team-results/__snapshots__/TeamSummaryCard.test.jsx.snap index be253e7eb9..6b55c57066 100644 --- a/web-ui/src/components/team-results/__snapshots__/TeamSummaryCard.test.jsx.snap +++ b/web-ui/src/components/team-results/__snapshots__/TeamSummaryCard.test.jsx.snap @@ -3,7 +3,7 @@ exports[`renders correctly 1`] = `
- string (Inactive) + string +

+ Inactive +

Team Leads: @@ -52,7 +57,7 @@ exports[`renders correctly 1`] = ` exports[`renders correctly for ADMIN 1`] = `
- string (Inactive) + string +

+ Inactive +

Team Leads: @@ -142,7 +152,7 @@ exports[`renders correctly for ADMIN 1`] = ` exports[`renders correctly for team lead 1`] = `
- stuff (Inactive) + stuff +

+ Inactive +

Team Leads: