Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/ AC Console - Show assigned secondary AC(s) #2203

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 62 additions & 28 deletions components/webfield/AreaChairConsole.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ const AreaChairConsole = ({ appContext }) => {
const [activeTabId, setActiveTabId] = useState(
decodeURIComponent(window.location.hash) || `#assigned-${pluralizeString(submissionName)}`
)
const [sacLinkText, setSacLinkText] = useState('')
const [sacSecondaryACLinkText, setSacSecondaryACLinkText] = useState('')

const edgeBrowserUrl = proposedAssignmentTitle
? edgeBrowserProposedUrl
Expand All @@ -209,47 +209,55 @@ const AreaChairConsole = ({ appContext }) => {
return name ? name.fullname : prettyId(reviewerProfile.id)
}

const getSACLinkText = async () => {
if (!acConsoleData.sacProfiles?.length) return
const sacName = prettyField(seniorAreaChairsId?.split('/')?.pop())
const singluarSACName = sacName.endsWith('s') ? sacName.slice(0, -1) : sacName
const sacText = `Your assigned ${inflect(
acConsoleData.sacProfiles.length,
`${singluarSACName} is`,
`${singluarSACName}s are`
const getRoleLinkText = async (profiles, roleName) => {
if (!profiles?.length) return ''
const singluarRoleName = roleName.endsWith('s') ? roleName.slice(0, -1) : roleName
const text = `Your assigned ${inflect(
profiles.length,
`${singluarRoleName} is`,
`${singluarRoleName}s are`
)}`

let sacEmails = []
let emails = []
if (preferredEmailInvitationId) {
try {
const sacEmailPs = acConsoleData.sacProfiles.map((sacProfile) =>
const emailPs = profiles.map((profile) =>
api
.get(
'/edges',
{ invitation: preferredEmailInvitationId, head: sacProfile.id },
{ invitation: preferredEmailInvitationId, head: profile.id },
{ accessToken }
)
.then((result) => result.edges[0]?.tail)
)
sacEmails = await Promise.all(sacEmailPs)
emails = await Promise.all(emailPs)
} catch (error) {
/* empty */
}
}
const sacProfileLinks = acConsoleData.sacProfiles.map(
(sacProfile, index) =>
`<a href="${getProfileLink(sacProfile.id)}" >${prettyId(sacProfile.id)}</a>${
sacEmails[index] ? `(${sacEmails[index]})` : ''
const profileLinks = profiles.map(
(profile, index) =>
`<a href="${getProfileLink(profile.id)}" >${prettyId(profile.id)}</a>${
emails[index] ? `(${emails[index]})` : ''
}`
)
setSacLinkText(
`<p class="dark">${sacText} ${prettyList(
sacProfileLinks,
'long',
'conjunction',
false
)}</p>`
return `<p class="dark">${text} ${prettyList(
profileLinks,
'long',
'conjunction',
false
)}</p>`
}

const getSACSecondaryACLinkText = async () => {
const sacRoleLinkText = await getRoleLinkText(
acConsoleData.sacProfiles,
prettyField(seniorAreaChairsId?.split('/')?.pop())
)
const secondaryRoleLinkText = await getRoleLinkText(
acConsoleData.secondaryAreaChairsProfiles,
prettyField(secondaryAreaChairName)
)
setSacSecondaryACLinkText(`${sacRoleLinkText}${secondaryRoleLinkText}`)
}

const loadData = async () => {
Expand Down Expand Up @@ -375,6 +383,22 @@ const AreaChairConsole = ({ appContext }) => {
: Promise.resolve([])
// #endregion

// #region secondary ACs
const secondaryAreaChairsP = secondaryAreaChairName
? api
.get(
'/edges',
{
invitation: `${venueId}/${secondaryAreaChairName}/-/Assignment`,
head: user.profile.id,
domain: group.domain,
},
{ accessToken }
)
.then((result) => result?.edges?.map((edge) => edge.tail) ?? [])
: Promise.resolve([])
// #endregion

// #region get ithenticate edges
const ithenticateEdgesP = ithenticateInvitationId
? api
Expand All @@ -394,6 +418,7 @@ const AreaChairConsole = ({ appContext }) => {
reviewerGroupsP,
assignedSACsP,
ithenticateEdgesP,
secondaryAreaChairsP,
])

// #region get assigned reviewer , sac and all reviewer group members profiles
Expand Down Expand Up @@ -572,6 +597,12 @@ const AreaChairConsole = ({ appContext }) => {
result[2].includes(p.email)
)

const secondaryAreaChairsProfiles = allProfiles.filter(
(p) =>
p.content.names.some((q) => result[4].includes(q.username)) ||
result[4].includes(p.email)
)

const assignedPaperRows = tableRows.filter((p) =>
areaChairPaperNums.includes(p.note.number)
)
Expand All @@ -589,6 +620,9 @@ const AreaChairConsole = ({ appContext }) => {
sacProfiles: sacProfiles.map((sacProfile) => ({
id: sacProfile.id,
})),
secondaryAreaChairsProfiles: secondaryAreaChairsProfiles.map((p) => ({
id: p.id,
})),
})
} catch (error) {
promptError(`loading data: ${error.message}`)
Expand Down Expand Up @@ -786,8 +820,8 @@ const AreaChairConsole = ({ appContext }) => {
}, [acConsoleData.notes])

useEffect(() => {
getSACLinkText()
}, [acConsoleData.sacProfiles])
getSACSecondaryACLinkText()
}, [acConsoleData.sacProfiles, acConsoleData.secondaryAreaChairsProfiles])

useEffect(() => {
const validTabIds = [
Expand Down Expand Up @@ -832,7 +866,7 @@ const AreaChairConsole = ({ appContext }) => {
<>
<BasicHeader
title={header?.title}
instructions={`${headerInstructions}${sacLinkText}`}
instructions={`${headerInstructions}${sacSecondaryACLinkText}`}
/>

<Tabs>
Expand Down
62 changes: 59 additions & 3 deletions unitTests/AreaChairConsole.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ describe('AreaChairConsole', () => {
})
})

test('show assigned SACs in header instuction (No preferred email edge)', async () => {
test('show assigned SACs and assigned Secondary Area Chairs in header instuction (No preferred email edge)', async () => {
api.getAll = jest.fn((path) => {
switch (path) {
case '/groups': // all groups
Expand All @@ -270,6 +270,14 @@ describe('AreaChairConsole', () => {
if (!param.domain) {
return Promise.resolve({ edges: [] }) // call to get sac emails from edges
}
if (param.invitation.includes('Secondary_Senior_Program_Committee')) {
return Promise.resolve({
edges: [
{ tail: '~Secondary_Senior_Program_Committee1' },
{ tail: '[email protected]' },
],
})
}
return Promise.resolve({
edges: [{ tail: '~Senior_AC1' }, { tail: '[email protected]' }],
})
Expand All @@ -289,6 +297,13 @@ describe('AreaChairConsole', () => {
emails: ['[email protected]'],
},
},
{
id: '~Secondary_Senior_Program_Committee1',
content: {
names: [{ username: '~Secondary_Senior_Program_Committee1' }],
emails: ['[email protected]'],
},
},
],
}
: {
Expand All @@ -301,6 +316,14 @@ describe('AreaChairConsole', () => {
},
email: '[email protected]',
},
{
id: '~Secondary_Senior_Program_Committee2',
content: {
names: [{ username: '~Secondary_Senior_Program_Committee2' }],
emails: ['[email protected]'],
},
email: '[email protected]',
},
],
}
)
Expand Down Expand Up @@ -353,10 +376,15 @@ describe('AreaChairConsole', () => {
'Your assigned Area Chairs are <a href="/profile?id=~Senior_AC1" >Senior AC</a> and <a href="/profile?id=~Senior_AC2" >Senior AC</a>'
)
)
expect(global.marked).toHaveBeenCalledWith(
expect.stringContaining(
'Your assigned Secondary Senior Program Committees are <a href="/profile?id=~Secondary_Senior_Program_Committee1" >Secondary Senior Program Committee</a> and <a href="/profile?id=~Secondary_Senior_Program_Committee2" >Secondary Senior Program Committee</a>'
)
)
})
})

test('show assigned SACs in header instuction (With preferred email edge)', async () => {
test('show assigned SACs and assigned Secondary Area Chair in header instuction (With preferred email edge)', async () => {
api.getAll = jest.fn((path) => {
switch (path) {
case '/groups': // all groups
Expand All @@ -371,7 +399,7 @@ describe('AreaChairConsole', () => {
switch (path) {
case '/groups': // reviewer groups
return Promise.resolve({ groups: [] })
case '/edges': // sac assignments
case '/edges': // sac and secondary ac assignments
if (param.head === '~Senior_AC1') {
return Promise.resolve({
edges: [{ head: '~Senior_AC1', tail: '[email protected]' }],
Expand All @@ -382,6 +410,22 @@ describe('AreaChairConsole', () => {
edges: [{ head: '~Senior_AC2', tail: '[email protected]' }],
}) // call to get sac emails from edges
}
if (param.head === '~Secondary_Senior_Program_Committee1') {
return Promise.resolve({
edges: [
{
head: '~Secondary_Senior_Program_Committee1',
tail: '[email protected]',
},
],
}) // call to get sac emails from edges
}
if (param.invitation.includes('Secondary_Senior_Program_Committee')) {
// secondary ac assignments
return Promise.resolve({
edges: [{ tail: '~Secondary_Senior_Program_Committee1' }],
})
}
return Promise.resolve({
edges: [{ tail: '~Senior_AC1' }, { tail: '[email protected]' }],
})
Expand All @@ -401,6 +445,13 @@ describe('AreaChairConsole', () => {
emails: ['[email protected]'],
},
},
{
id: '~Secondary_Senior_Program_Committee1',
content: {
names: [{ username: '~Secondary_Senior_Program_Committee1' }],
emails: ['[email protected]'],
},
},
],
}
: {
Expand Down Expand Up @@ -466,6 +517,11 @@ describe('AreaChairConsole', () => {
'Your assigned Area Chairs are <a href="/profile?id=~Senior_AC1" >Senior AC</a>([email protected]) and <a href="/profile?id=~Senior_AC2" >Senior AC</a>([email protected])'
)
)
expect(global.marked).toHaveBeenCalledWith(
expect.stringContaining(
'Your assigned Secondary Senior Program Committee is <a href="/profile?id=~Secondary_Senior_Program_Committee1" >Secondary Senior Program Committee</a>([email protected])'
)
)
})
})

Expand Down
Loading