Skip to content

Commit

Permalink
Bugfix: Display message when user not admin (#5884)
Browse files Browse the repository at this point in the history
* add 'isUserAdmin' value to admin page query

* add message with useful links for non-admins

* add translations

* fix bool logic

* fix tests
  • Loading branch information
lcampbell2 authored Nov 14, 2024
1 parent 79d0c64 commit 303c80d
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 12 deletions.
26 changes: 26 additions & 0 deletions frontend/src/admin/AdminPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,32 @@ export default function AdminPage() {
)
}

if (!data?.isUserAdmin) {
return (
<Stack align="center" mx="auto">
<Text fontSize="3xl" fontWeight="bold">
<Trans>You currently have no admin affiliations.</Trans>
</Text>
<Flex fontSize="xl">
<Text mr="2">
<Trans>Search for your organization to request an invite</Trans>
</Text>
<Button size="xl" variant="link" as={RouteLink} to="/organizations" color="blue.500">
<Trans>here.</Trans>
</Button>
</Flex>
<Flex fontSize="xl">
<Text mr="2">
<Trans>Is your organization not using Tracker yet?</Trans>
</Text>
<Button size="xl" variant="link" as={RouteLink} to="/create-organization" color="blue.500">
<Trans>Click here.</Trans>
</Button>
</Flex>
</Stack>
)
}

const changeActiveMenu = (val) => {
if (activeMenu !== val) {
history.replace(`/admin/${val}`)
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/admin/__tests__/AdminPage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ function mocks() {
],
},
isUserSuperAdmin: true,
isUserAdmin: true,
},
},
},
Expand Down Expand Up @@ -215,6 +216,7 @@ function mocks() {
],
},
isUserSuperAdmin: true,
isUserAdmin: true,
},
},
},
Expand Down
1 change: 1 addition & 0 deletions frontend/src/graphql/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -1145,6 +1145,7 @@ export const ADMIN_PAGE = gql`
}
}
}
isUserAdmin
isUserSuperAdmin
}
`
Expand Down
32 changes: 26 additions & 6 deletions frontend/src/locales/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ msgstr "Asset State"
msgid "Asset States"
msgstr "Asset States"

#: src/admin/AdminPage.js:197
#: src/admin/AdminPage.js:223
#: src/admin/AuditLogTable.js:95
msgid "Audit Logs"
msgstr "Audit Logs"
Expand Down Expand Up @@ -826,6 +826,10 @@ msgstr "Click for additional information on statuses, tags, and filters."
msgid "Click for guidance on getting started with Tracker and frequently asked questions."
msgstr "Click for guidance on getting started with Tracker and frequently asked questions."

#: src/admin/AdminPage.js:138
msgid "Click here."
msgstr "Click here."

#: src/userOnboarding/config/tourSteps.js:106
msgid "Click to view detailed scan results and guidance."
msgstr "Click to view detailed scan results and guidance."
Expand Down Expand Up @@ -998,7 +1002,7 @@ msgstr "Create an Account"
msgid "Create an organization"
msgstr "Create an organization"

#: src/admin/AdminPage.js:139
#: src/admin/AdminPage.js:165
#: src/app/App.js:353
#: src/createOrganization/CreateOrganizationPage.js:237
msgid "Create Organization"
Expand Down Expand Up @@ -1969,6 +1973,10 @@ msgstr "Heartbleed Vulnerable"
#~ msgid "Here you can filter the list of organizations to only show verified organizations"
#~ msgstr "Here you can filter the list of organizations to only show verified organizations"

#: src/admin/AdminPage.js:130
msgid "here."
msgstr "here."

#: src/admin/AdminDomains.js:174
#: src/organizationDetails/OrganizationDomains.js:101
#~ msgid "Hidden"
Expand Down Expand Up @@ -2475,6 +2483,10 @@ msgstr "Is DKIM aligned. Can be true or false."
msgid "Is SPF aligned. Can be true or false."
msgstr "Is SPF aligned. Can be true or false."

#: src/admin/AdminPage.js:135
msgid "Is your organization not using Tracker yet?"
msgstr "Is your organization not using Tracker yet?"

#: src/guidance/WebTLSResults.js:476
msgid "Issuer:"
msgstr "Issuer:"
Expand Down Expand Up @@ -3170,7 +3182,7 @@ msgstr "Organization:"
msgid "Organization(s):"
msgstr "Organization(s):"

#: src/admin/AdminPage.js:195
#: src/admin/AdminPage.js:221
#: src/app/App.js:134
#: src/app/App.js:252
#: src/app/FloatingMenu.js:103
Expand Down Expand Up @@ -3782,6 +3794,10 @@ msgstr "Search for an organization"
msgid "Search for domains here."
msgstr "Search for domains here."

#: src/admin/AdminPage.js:127
msgid "Search for your organization to request an invite"
msgstr "Search for your organization to request an invite"

#: src/dmarc/DmarcReportPage.js:439
msgid "Search Fully Aligned Items"
msgstr "Search Fully Aligned Items"
Expand Down Expand Up @@ -3826,7 +3842,7 @@ msgstr "Select a state that best describes the asset in relation to your organiz
msgid "Select an organization"
msgstr "Select an organization"

#: src/admin/AdminPage.js:160
#: src/admin/AdminPage.js:186
msgid "Select an organization to view admin options"
msgstr "Select an organization to view admin options"

Expand Down Expand Up @@ -4320,7 +4336,7 @@ msgstr "Summary"
msgid "Summary Tier:"
msgstr "Summary Tier:"

#: src/admin/AdminPage.js:192
#: src/admin/AdminPage.js:218
msgid "Super Admin Menu:"
msgstr "Super Admin Menu:"

Expand Down Expand Up @@ -5107,7 +5123,7 @@ msgstr "User-designated tags appear here."
msgid "User:"
msgstr "User:"

#: src/admin/AdminPage.js:196
#: src/admin/AdminPage.js:222
#: src/admin/AdminPanel.js:24
#: src/organizationDetails/OrganizationDetails.js:152
msgid "Users"
Expand Down Expand Up @@ -5453,6 +5469,10 @@ msgstr "You are current visiting a staging environment, used for testing purpose
#~ msgid "You can search for an organization here"
#~ msgstr "You can search for an organization here"

#: src/admin/AdminPage.js:123
msgid "You currently have no admin affiliations."
msgstr "You currently have no admin affiliations."

#: src/guidance/GuidancePage.js:109
msgid "You have successfully added {domainName} to myTracker."
msgstr "You have successfully added {domainName} to myTracker."
Expand Down
32 changes: 26 additions & 6 deletions frontend/src/locales/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ msgstr "État des actifs"
msgid "Asset States"
msgstr "Estados del activo"

#: src/admin/AdminPage.js:197
#: src/admin/AdminPage.js:223
#: src/admin/AuditLogTable.js:95
msgid "Audit Logs"
msgstr "Journaux d'audit"
Expand Down Expand Up @@ -814,6 +814,10 @@ msgstr "Cliquez pour plus d'informations sur les statuts, les étiquettes et les
msgid "Click for guidance on getting started with Tracker and frequently asked questions."
msgstr "Cliquez pour obtenir des conseils sur la façon de démarrer avec Tracker et les questions les plus fréquentes."

#: src/admin/AdminPage.js:138
msgid "Click here."
msgstr "Cliquez ici."

#: src/userOnboarding/config/tourSteps.js:106
msgid "Click to view detailed scan results and guidance."
msgstr "Cliquez pour voir les résultats détaillés de l'examen et les conseils."
Expand Down Expand Up @@ -986,7 +990,7 @@ msgstr "Créer un compte"
msgid "Create an organization"
msgstr "Créer une organisation"

#: src/admin/AdminPage.js:139
#: src/admin/AdminPage.js:165
#: src/app/App.js:353
#: src/createOrganization/CreateOrganizationPage.js:237
msgid "Create Organization"
Expand Down Expand Up @@ -1929,6 +1933,10 @@ msgstr "Vulnérabilité Heartbleed"
#~ msgid "Here you can filter the list of organizations to only show verified organizations"
#~ msgstr "Vous pouvez filtrer la liste des organisations pour n'afficher que les organisations vérifiées."

#: src/admin/AdminPage.js:130
msgid "here."
msgstr "ici."

#: src/admin/AdminDomains.js:174
#: src/organizationDetails/OrganizationDomains.js:101
#~ msgid "Hidden"
Expand Down Expand Up @@ -2435,6 +2443,10 @@ msgstr "Est aligné sur la norme DKIM. Peut être vrai ou faux."
msgid "Is SPF aligned. Can be true or false."
msgstr "Est aligné sur le SPF. Peut être vrai ou faux."

#: src/admin/AdminPage.js:135
msgid "Is your organization not using Tracker yet?"
msgstr "Votre organisation n'utilise pas encore Tracker ?"

#: src/guidance/WebTLSResults.js:476
msgid "Issuer:"
msgstr "Émetteur :"
Expand Down Expand Up @@ -3122,7 +3134,7 @@ msgstr "Organisation:"
msgid "Organization(s):"
msgstr "Organisation(s) :"

#: src/admin/AdminPage.js:195
#: src/admin/AdminPage.js:221
#: src/app/App.js:134
#: src/app/App.js:252
#: src/app/FloatingMenu.js:103
Expand Down Expand Up @@ -3730,6 +3742,10 @@ msgstr "Rechercher une organisation"
msgid "Search for domains here."
msgstr "Recherchez des domaines ici."

#: src/admin/AdminPage.js:127
msgid "Search for your organization to request an invite"
msgstr "Recherchez votre organisation pour demander une invitation"

#: src/dmarc/DmarcReportPage.js:439
msgid "Search Fully Aligned Items"
msgstr "Recherche d'éléments entièrement alignés"
Expand Down Expand Up @@ -3770,7 +3786,7 @@ msgstr "Sélectionnez l'état qui décrit le mieux l'actif par rapport à votre
msgid "Select an organization"
msgstr "Sélectionnez une organisation"

#: src/admin/AdminPage.js:160
#: src/admin/AdminPage.js:186
msgid "Select an organization to view admin options"
msgstr "Sélectionnez une organisation pour voir les options d'administration"

Expand Down Expand Up @@ -4262,7 +4278,7 @@ msgstr "Résumé"
msgid "Summary Tier:"
msgstr "Résumé Tier :"

#: src/admin/AdminPage.js:192
#: src/admin/AdminPage.js:218
msgid "Super Admin Menu:"
msgstr "Super Admin Menu :"

Expand Down Expand Up @@ -5021,7 +5037,7 @@ msgstr "Les balises désignées par l'utilisateur apparaissent ici."
msgid "User:"
msgstr "Utilisateur:"

#: src/admin/AdminPage.js:196
#: src/admin/AdminPage.js:222
#: src/admin/AdminPanel.js:24
#: src/organizationDetails/OrganizationDetails.js:152
msgid "Users"
Expand Down Expand Up @@ -5351,6 +5367,10 @@ msgstr "Vous visitez actuellement un environnement de démonstration, utilisé u
#~ msgid "You can search for an organization here"
#~ msgstr "Vous pouvez rechercher une organisation ici"

#: src/admin/AdminPage.js:123
msgid "You currently have no admin affiliations."
msgstr "Vous n'avez actuellement aucune affiliation administrative."

#: src/guidance/GuidancePage.js:109
msgid "You have successfully added {domainName} to myTracker."
msgstr "Vous avez ajouté avec succès {domainName} à myTracker."
Expand Down

0 comments on commit 303c80d

Please sign in to comment.