+
+
+
`;
diff --git a/web-ui/src/components/edit_skills/EditSkillsCard.test.jsx b/web-ui/src/components/edit_skills/EditSkillsCard.test.jsx
index f5a2301ab..84f732624 100644
--- a/web-ui/src/components/edit_skills/EditSkillsCard.test.jsx
+++ b/web-ui/src/components/edit_skills/EditSkillsCard.test.jsx
@@ -35,7 +35,7 @@ const initialState = {
guilds: [],
teams: [],
roles: [],
- userRoles: [],
+ memberRoles: [],
memberSkills: [],
index: 0,
memberProfiles: [
diff --git a/web-ui/src/components/guides/GuideLink.jsx b/web-ui/src/components/guides/GuideLink.jsx
index 180af0da0..674cfc22b 100644
--- a/web-ui/src/components/guides/GuideLink.jsx
+++ b/web-ui/src/components/guides/GuideLink.jsx
@@ -17,6 +17,7 @@ const propTypes = {
const GuideLink = props => {
return (
{
+const GuidesPanel = () => {
+ const { state } = useContext(AppContext);
+ const csrf = selectCsrfToken(state);
+ const userRoles = selectCurrentUserRoles(state);
+ const allRoles = selectRoles(state);
+
+ const [documents, setDocuments] = useState([]);
+
useEffect(() => {
const getDocuments = async () => {
- if (mockuments && mockuments.length > 0) {
- setDocuments(mockuments);
- } else {
- const memberRoleId = allRoles.find(role => role.role === roleName)?.id;
- const res = await getDocumentsForRoleId(memberRoleId, csrf);
- const responseBody = res.payload?.data && !res.error
- ? res.payload.data
- : undefined;
- setDocuments(responseBody?.length > 0 ? responseBody : fallback);
+ const docs = [];
+ if(userRoles) {
+ for (const roleName of userRoles) {
+ const memberRoleId = allRoles.find(role => role.role === roleName)?.id;
+ const res = await getDocumentsForRoleId(memberRoleId, csrf);
+ const responseBody = res.payload?.data && !res.error
+ ? res.payload.data
+ : undefined;
+ if (responseBody?.length > 0) {
+ docs.push(...responseBody);
+ }
+ }
}
+
+ setDocuments(docs.length > 0 ? docs : fallback);
};
if (csrf) {
getDocuments();
}
- }, [csrf]);
-};
+ }, [allRoles, userRoles, csrf, setDocuments, getDocumentsForRoleId]);
-export const generate = (title, documents) => {
return (
-
- } title={title} />
-
- {documents.map(doc => (
-
- ))}
-
-
- );
-};
-
-const GuidesPanel = () => {
- const { state } = useContext(AppContext);
- const csrf = selectCsrfToken(state);
-
- const [documents, setDocuments] = useState([]);
- fetchDocumentsForRole('MEMBER', selectRoles(state), csrf, setDocuments, fallbackPdfs, state.mockuments);
-
- return generate('Team Member Resources', documents);
+
+ } title={"Check-In Resources"} />
+
+ {documents.map(doc => (
+
+ ))}
+
+
+ );;
};
export default GuidesPanel;
diff --git a/web-ui/src/components/guides/GuidesPanel.test.jsx b/web-ui/src/components/guides/GuidesPanel.test.jsx
index a525ad413..5c4760b87 100644
--- a/web-ui/src/components/guides/GuidesPanel.test.jsx
+++ b/web-ui/src/components/guides/GuidesPanel.test.jsx
@@ -2,13 +2,15 @@ import React from 'react';
import { MemoryRouter } from 'react-router-dom';
import GuidesPanel from './GuidesPanel';
import { AppContextProvider } from '../../context/AppContext.jsx';
+import {setupServer} from "msw/node";
+import {http, HttpResponse} from "msw";
const initialState = {
state: {
csrf: 'O_3eLX2-e05qpS_yOeg1ZVAs9nDhspEi',
userProfile: {
name: 'holmes',
- role: ['MEMBER'],
+ role: ['MEMBER', 'PDL'],
imageUrl:
'https://upload.wikimedia.org/wikipedia/commons/7/74/SNL_MrBill_Doll.jpg'
},
@@ -16,26 +18,49 @@ const initialState = {
{ id: 1, role: 'MEMBER' },
{ id: 2, role: 'PDL' }
],
- mockuments: [
- {
- id: 'mockument-1',
- name: 'Expectations Discussion Guide for Team Members',
- url: '/pdfs/Expectations_Discussion_Guide_for_Team_Members.pdf',
- description: 'My description'
- },
- {
- id: 'mockument-2',
- name: 'Expectations Worksheet',
- url: '/pdfs/Expectations_Worksheet.pdf'
- }
- ],
teams: []
}
};
+const mockuments = [
+ {
+ id: 'mockument-1',
+ name: 'Expectations Discussion Guide for Team Members',
+ url: '/pdfs/Expectations_Discussion_Guide_for_Team_Members.pdf',
+ description: 'My description'
+ },
+ {
+ id: 'mockument-2',
+ name: 'Expectations Worksheet',
+ url: '/pdfs/Expectations_Worksheet.pdf',
+ description: 'My worksheet'
+ }
+];
+
+const pdlMockuments = [
+ {
+ id: 'mockument-3',
+ name: 'Expectations Discussion Guide for PDLs',
+ url: '/pdfs/Expectations_Discussion_Guide_for_PDLs.pdf',
+ description: 'My PDL description'
+ }
+];
+
+const server = setupServer(
+ http.get('http://localhost:8080/services/document/1', () => {
+ return HttpResponse.json(mockuments);
+ }),
+ http.get('http://localhost:8080/services/document/2', () => {
+ return HttpResponse.json(pdlMockuments);
+ })
+);
+
+beforeAll(() => server.listen({ onUnhandledRequest(request, print) {} }));
+afterEach(() => server.resetHandlers());
+afterAll(() => server.close());
-it('renders correctly', () => {
- snapshot(
+it('renders correctly', async () => {
+ await waitForSnapshot('mockument-3',
diff --git a/web-ui/src/components/guides/PDLGuidesPanel.jsx b/web-ui/src/components/guides/PDLGuidesPanel.jsx
deleted file mode 100644
index fb0a69e81..000000000
--- a/web-ui/src/components/guides/PDLGuidesPanel.jsx
+++ /dev/null
@@ -1,41 +0,0 @@
-import { useContext, useState } from 'react';
-
-import { AppContext } from '../../context/AppContext';
-import { selectCsrfToken, selectRoles, selectUserProfile } from '../../context/selectors.js';
-
-import { fetchDocumentsForRole, generate } from './GuidesPanel.jsx';
-import './GuidesPanel.css';
-
-const fallbackPdfs = [
- {
- id: '1',
- name: 'Development Discussion Guide for PDLs',
- url: '/pdfs/Development_Discussion_Guide_for_PDLs.pdf'
- },
- {
- id: '2',
- name: 'Expectations Discussion Guide for PDLs',
- url: '/pdfs/Expectations_Discussion_Guide_for_PDLs.pdf'
- },
- {
- id: '3',
- name: 'Feedback Discussion Guide for PDLs',
- url: '/pdfs/Feedback_Discussion_Guide_for_PDLs.pdf'
- }
-];
-
-const PDLGuidesPanel = () => {
- const { state } = useContext(AppContext);
- const csrf = selectCsrfToken(state);
- const isPdl = selectUserProfile(state)?.role?.includes('PDL');
- const [documents, setDocuments] = useState(fallbackPdfs);
-
- if (isPdl) {
- fetchDocumentsForRole('PDL', selectRoles(state), csrf, setDocuments, fallbackPdfs, state.mockuments);
- return generate('Development Lead Guides', documents);
- } else {
- return null;
- }
-};
-
-export default PDLGuidesPanel;
diff --git a/web-ui/src/components/guides/PDLGuidesPanel.test.jsx b/web-ui/src/components/guides/PDLGuidesPanel.test.jsx
deleted file mode 100644
index 51f38ba3d..000000000
--- a/web-ui/src/components/guides/PDLGuidesPanel.test.jsx
+++ /dev/null
@@ -1,61 +0,0 @@
-import React from 'react';
-import { AppContextProvider } from '../../context/AppContext';
-import PDLGuidesPanel from './PDLGuidesPanel';
-import { Router } from 'react-router-dom';
-import { createBrowserHistory } from 'history';
-
-const initialState = {
- state: {
- csrf: 'O_3eLX2-e05qpS_yOeg1ZVAs9nDhspEi',
- userProfile: {
- name: 'holmes',
- role: ['MEMBER'],
- imageUrl:
- 'https://upload.wikimedia.org/wikipedia/commons/7/74/SNL_MrBill_Doll.jpg'
- },
- roles: [
- { id: 1, role: 'MEMBER' },
- { id: 2, role: 'PDL' }
- ],
- mockuments: [
- {
- id: 'mockument-1',
- name: 'Development Discussion Guide for PDLs',
- url: '/pdfs/Development_Discussion_Guide_for_PDLs.pdf'
- }
- ],
- teams: []
- }
-};
-
-const pdlState = {
- state: {
- ...initialState.state,
- userProfile: {
- ...initialState.state.userProfile,
- role: ['MEMBER', 'PDL']
- }
- }
-};
-
-it('renders correctly', () => {
- const customHistory = createBrowserHistory();
- snapshot(
-
-
-
-
-
- );
-});
-
-it('doesn\'t render for non-pdls', () => {
- const customHistory = createBrowserHistory();
- snapshot(
-
-
-
-
-
- );
-});
diff --git a/web-ui/src/components/guides/__snapshots__/GuideLink.test.jsx.snap b/web-ui/src/components/guides/__snapshots__/GuideLink.test.jsx.snap
index 6e6280cdc..9d502125f 100644
--- a/web-ui/src/components/guides/__snapshots__/GuideLink.test.jsx.snap
+++ b/web-ui/src/components/guides/__snapshots__/GuideLink.test.jsx.snap
@@ -4,6 +4,7 @@ exports[`renders correctly 1`] = `
@@ -38,6 +38,7 @@ exports[`renders correctly 1`] = `
>
@@ -58,17 +59,44 @@ exports[`renders correctly 1`] = `
Expectations Worksheet
+
+ My worksheet
+
+
+
+
+
+
+ Expectations Discussion Guide for PDLs
+
+
+ My PDL description
+
diff --git a/web-ui/src/components/guild-results/EditGuildModal.spec.jsx b/web-ui/src/components/guild-results/EditGuildModal.spec.jsx
index bbc3943f2..9aeffb75f 100644
--- a/web-ui/src/components/guild-results/EditGuildModal.spec.jsx
+++ b/web-ui/src/components/guild-results/EditGuildModal.spec.jsx
@@ -59,17 +59,17 @@ const initialState = {
name: 'Current User',
firstName: 'Current',
lastName: 'User',
+ id: currentUserProfile.id,
role: ['MEMBER'],
imageUrl:
'https://upload.wikimedia.org/wikipedia/commons/7/74/SNL_MrBill_Doll.jpg',
- memberProfile: currentUserProfile
},
checkins: [],
guilds: [testGuild, emptyGuild],
teams: [],
skills: [],
roles: [],
- userRoles: [],
+ memberRoles: [],
memberSkills: [],
index: 0,
memberProfiles: [
diff --git a/web-ui/src/components/guild-results/GuildSummaryCard.jsx b/web-ui/src/components/guild-results/GuildSummaryCard.jsx
index 5b59c657c..8b1b7dc62 100644
--- a/web-ui/src/components/guild-results/GuildSummaryCard.jsx
+++ b/web-ui/src/components/guild-results/GuildSummaryCard.jsx
@@ -6,6 +6,7 @@ import { styled } from '@mui/material/styles';
import { AppContext } from '../../context/AppContext';
import { UPDATE_GUILDS, UPDATE_TOAST } from '../../context/actions';
+import { selectIsAdmin, selectCurrentUser } from '../../context/selectors';
import EditGuildModal from './EditGuildModal';
import {
@@ -57,7 +58,7 @@ const StyledCard = styled(Card)(() => ({
const inactiveStyle = {
'color': 'var(--action-disabled)',
- 'font-size': '0.75em',
+ 'fontSize': '0.75em',
};
const propTypes = {
@@ -72,11 +73,11 @@ const displayName = 'GuildSummaryCard';
const GuildSummaryCard = ({ guild, index, isOpen, onGuildSelect }) => {
const { state, dispatch } = useContext(AppContext);
- const { guilds, userProfile, csrf } = state;
+ const { guilds, csrf } = state;
const [open, setOpen] = useState(isOpen);
const [tooltipIsOpen, setTooltipIsOpen] = useState(false);
- const isAdmin =
- userProfile && userProfile.role && userProfile.role.includes('ADMIN');
+ const isAdmin = selectIsAdmin(state);
+ const currentUser = selectCurrentUser(state);
let leads =
guild.guildMembers == null
@@ -90,7 +91,7 @@ const GuildSummaryCard = ({ guild, index, isOpen, onGuildSelect }) => {
const isGuildLead =
leads === null
? false
- : leads.some(lead => lead.memberId === userProfile.memberProfile.id);
+ : leads.some(lead => lead.memberId === currentUser.id);
const handleOpen = () => {
setOpen(true);
diff --git a/web-ui/src/components/guild-results/GuildSummaryCard.test.jsx b/web-ui/src/components/guild-results/GuildSummaryCard.test.jsx
index bd7b5c6ce..c6f534b6d 100644
--- a/web-ui/src/components/guild-results/GuildSummaryCard.test.jsx
+++ b/web-ui/src/components/guild-results/GuildSummaryCard.test.jsx
@@ -28,17 +28,18 @@ const initialState = {
state: {
userProfile: {
name: 'holmes',
- memberProfile: {
- id: '3fa4-5717-4562-b3fc-2c963f66afa9',
- pdlId: '',
- title: 'Tester',
- workEmail: 'test@tester.com'
- },
+ id: '3fa4-5717-4562-b3fc-2c963f66afa9',
role: ['MEMBER'],
imageUrl:
'https://upload.wikimedia.org/wikipedia/commons/7/74/SNL_MrBill_Doll.jpg'
},
- guilds
+ guilds,
+ memberProfiles: [{
+ id: '3fa4-5717-4562-b3fc-2c963f66afa9',
+ pdlId: '',
+ title: 'Tester',
+ workEmail: 'test@tester.com'
+ }]
}
};
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 a24fc8510..cca303011 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
@@ -38,7 +38,7 @@ import {
selectCsrfToken,
selectCurrentMembers,
selectActiveGuilds,
- selectMappedUserRoles,
+ selectMappedMemberRoles,
selectRoles,
selectSkills,
selectSubordinates,
@@ -320,11 +320,11 @@ const MemberSelectorDialog = ({
);
break;
case FilterType.ROLE:
- const mappedUserRoles = selectMappedUserRoles(state);
+ const mappedMemberRoles = selectMappedMemberRoles(state);
filteredMemberList = filteredMemberList.filter(
member =>
- member.id in mappedUserRoles &&
- mappedUserRoles[member.id].has(filter.role)
+ member.id in mappedMemberRoles &&
+ mappedMemberRoles[member.id].has(filter.role)
);
break;
case FilterType.SKILL:
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 c919b7894..4db49171b 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
@@ -63,7 +63,7 @@ const initialState = {
guilds: [testGuild],
teams: [],
roles: [],
- userRoles: [],
+ memberRoles: [],
memberSkills: [],
index: 0
};
diff --git a/web-ui/src/components/member_selector/member_selector_dialog/MemberSelectorDialog.test.jsx b/web-ui/src/components/member_selector/member_selector_dialog/MemberSelectorDialog.test.jsx
index 44caecfea..7a012b78d 100644
--- a/web-ui/src/components/member_selector/member_selector_dialog/MemberSelectorDialog.test.jsx
+++ b/web-ui/src/components/member_selector/member_selector_dialog/MemberSelectorDialog.test.jsx
@@ -50,7 +50,7 @@ const initialState = {
guilds: [],
teams: [],
roles: [],
- userRoles: [],
+ memberRoles: [],
memberSkills: [],
index: 0
}
diff --git a/web-ui/src/components/menu/Menu.jsx b/web-ui/src/components/menu/Menu.jsx
index 442ebe8fd..fdcd21a18 100644
--- a/web-ui/src/components/menu/Menu.jsx
+++ b/web-ui/src/components/menu/Menu.jsx
@@ -28,6 +28,7 @@ import {
selectCanEditAllOrganizationMembers,
selectHasUploadHoursPermission,
selectHasPermissionAssignmentPermission,
+ selectCurrentUser,
} from '../../context/selectors';
import { UPDATE_TOAST } from '../../context/actions';
@@ -108,8 +109,7 @@ function Menu({ children }) {
const { state, dispatch } = useContext(AppContext);
const { userProfile } = state;
const csrf = selectCsrfToken(state);
- const { id, workEmail } =
- userProfile && userProfile.memberProfile ? userProfile.memberProfile : {};
+ const { id, workEmail } = selectCurrentUser(state);
const hasReportPermission = selectHasReportPermission(state);
const canViewFeedbackAnswer = selectCanViewFeedbackAnswerPermission(state);
const canViewFeedbackRequest = selectCanViewFeedbackRequestPermission(state);
diff --git a/web-ui/src/components/menu/Menu.test.jsx b/web-ui/src/components/menu/Menu.test.jsx
index e3851f4cf..d6faf0262 100644
--- a/web-ui/src/components/menu/Menu.test.jsx
+++ b/web-ui/src/components/menu/Menu.test.jsx
@@ -10,17 +10,20 @@ const initialState = {
state: {
userProfile: {
name: 'holmes',
- memberProfile: {
- id: testId,
- pdlId: '',
- title: 'Tester',
- workEmail: 'test@tester.com'
- },
+ id: testId,
role: ['MEMBER'],
permissions: [],
imageUrl:
'https://upload.wikimedia.org/wikipedia/commons/7/74/SNL_MrBill_Doll.jpg'
- }
+ },
+ memberProfiles: [
+ {
+ id: testId,
+ pdlId: '',
+ title: 'Tester',
+ workEmail: 'test@tester.com'
+ }
+ ]
}
};
@@ -28,16 +31,20 @@ const adminState = {
state: {
userProfile: {
name: 'holmes',
- memberProfile: {
- pdlId: '',
- title: 'Tester',
- workEmail: 'test@tester.com'
- },
+ id: testId,
role: ['MEMBER', 'ADMIN'],
permissions: [{ permission: 'CAN_VIEW_SKILLS_REPORT' }],
imageUrl:
'https://upload.wikimedia.org/wikipedia/commons/7/74/SNL_MrBill_Doll.jpg'
- }
+ },
+ memberProfiles: [
+ {
+ id: testId,
+ pdlId: '',
+ title: 'Tester',
+ workEmail: 'test@tester.com'
+ }
+ ]
}
};
@@ -45,16 +52,20 @@ const pdlState = {
state: {
userProfile: {
name: 'holmes',
- memberProfile: {
- pdlId: '',
- title: 'Tester',
- workEmail: 'test@tester.com'
- },
+ id: testId,
role: ['MEMBER', 'PDL'],
permissions: [],
imageUrl:
'https://upload.wikimedia.org/wikipedia/commons/7/74/SNL_MrBill_Doll.jpg'
- }
+ },
+ memberProfiles: [
+ {
+ id: testId,
+ pdlId: '',
+ title: 'Tester',
+ workEmail: 'test@tester.com'
+ }
+ ]
}
};
diff --git a/web-ui/src/components/menu/__snapshots__/Menu.test.jsx.snap b/web-ui/src/components/menu/__snapshots__/Menu.test.jsx.snap
index fdf4f9215..1f6edf659 100644
--- a/web-ui/src/components/menu/__snapshots__/Menu.test.jsx.snap
+++ b/web-ui/src/components/menu/__snapshots__/Menu.test.jsx.snap
@@ -450,7 +450,7 @@ exports[`
> renders correctly for admin 1`] = `