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

Remove scan results button when user has no affiliations #5270

Closed
wants to merge 1 commit into from
Closed
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
52 changes: 27 additions & 25 deletions frontend/src/domains/DomainCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function DomainCard({
}) {
const location = useLocation()
const toast = useToast()
const { isLoggedIn, isEmailValidated } = useUserVar()
const { isLoggedIn, isEmailValidated, hasAffiliation } = useUserVar()

const [favouriteDomain, { _loading, _error }] = useMutation(FAVOURITE_DOMAIN, {
onError: ({ message }) => {
Expand Down Expand Up @@ -208,38 +208,40 @@ export function DomainCard({
</Box>
<Divider variant="card" display={{ md: 'none' }} />

<Stack
fontSize="sm"
justifySelf="flex-end"
alignSelf="stretch"
justifyContent="center"
ml={{ base: 0, md: '4' }}
>
<Button
variant="primary"
as={RouteLink}
to={{
pathname: isLoggedIn() ? `/domains/${url}` : '/sign-in',
state: { from: location.pathname },
}}
px="10"
{hasAffiliation() && (
<Stack
fontSize="sm"
justifySelf="flex-end"
alignSelf="stretch"
justifyContent="center"
ml={{ base: 0, md: '4' }}
>
<Text whiteSpace="noWrap">
<Trans>View Results</Trans>
</Text>
</Button>
{hasDMARCReport && (
<Button
variant="primary"
as={RouteLink}
to={`/domains/${url}/dmarc-report/LAST30DAYS/${new Date().getFullYear()}`}
to={{
pathname: isLoggedIn() ? `/domains/${url}` : '/sign-in',
state: { from: location.pathname },
}}
px="10"
>
<Text whiteSpace="noWrap">
<Trans>DMARC Report</Trans>
<Trans>View Results</Trans>
</Text>
</Button>
)}
</Stack>
{hasDMARCReport && (
<Button
variant="primary"
as={RouteLink}
to={`/domains/${url}/dmarc-report/LAST30DAYS/${new Date().getFullYear()}`}
>
<Text whiteSpace="noWrap">
<Trans>DMARC Report</Trans>
</Text>
</Button>
)}
</Stack>
)}
<Stack ml={4}>
{isEmailValidated() && userHasPermission && <ScanDomainButton domainUrl={url} />}
{isLoggedIn() &&
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/domains/__tests__/DomainsPage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ describe('<DomainsPage />', () => {
jwt: null,
tfaSendMethod: null,
userName: null,
affiliations: { totalCount: 1 },
})}
>
<ChakraProvider theme={theme}>
Expand Down Expand Up @@ -326,6 +327,7 @@ describe('<DomainsPage />', () => {
userVar={makeVar({
userName: 'testUser@test.com',
emailValidated: true,
affiliations: { totalCount: 1 },
})}
>
<ChakraProvider theme={theme}>
Expand Down