Skip to content

Commit

Permalink
[EASI-4330] GRB reviewer admin view (#2683)
Browse files Browse the repository at this point in the history
* GRB reviewers query

* useAuth hook to check job codes / roles

* GRB reviewer view

* Fix unit tests

* Summary unit test

* RequestOverview unit test

* useAuth unit test

* Move IsGrbViewContext to separate file

* Documentation and cleanup

* Moved nav item filtering to file

Moved filtering of navigation links to src/views/GovernanceReviewTeam/subNavItems.ts so that it always returns correct items

* Remove useAuth hook
  • Loading branch information
aterstriep committed Jul 10, 2024
1 parent 52cf9fd commit f038c86
Show file tree
Hide file tree
Showing 16 changed files with 548 additions and 302 deletions.
44 changes: 44 additions & 0 deletions src/data/mock/systemIntake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { DateTime } from 'luxon';

import { CMSOffice } from 'constants/enums/cmsDivisionsAndOffices';
import GetGovernanceTaskListQuery from 'queries/GetGovernanceTaskListQuery';
import GetSystemIntakeGrbReviewersQuery from 'queries/GetSystemIntakeGrbReviewersQuery';
import GetSystemIntakeQuery from 'queries/GetSystemIntakeQuery';
import GetSystemIntakesWithLCIDS from 'queries/GetSystemIntakesWithLCIDS';
import { GetSystemIntakeContactsQuery } from 'queries/SystemIntakeContactsQueries';
Expand All @@ -18,6 +19,10 @@ import {
GetSystemIntakeContactsQuery as GetSystemIntakeContactsType,
GetSystemIntakeContactsQueryVariables
} from 'queries/types/GetSystemIntakeContactsQuery';
import {
GetSystemIntakeGrbReviewers,
GetSystemIntakeGrbReviewersVariables
} from 'queries/types/GetSystemIntakeGrbReviewers';
import { GetSystemIntakesTable_systemIntakes as TableSystemIntake } from 'queries/types/GetSystemIntakesTable';
import {
GetSystemIntakesWithLCIDS as GetSystemIntakesWithLCIDSType,
Expand Down Expand Up @@ -618,3 +623,42 @@ export const getGovernanceTaskListQuery = (
}
}
});

export const getSystemIntakeGrbReviewersQuery: MockedQuery<
GetSystemIntakeGrbReviewers,
GetSystemIntakeGrbReviewersVariables
> = {
request: {
query: GetSystemIntakeGrbReviewersQuery,
variables: { id: systemIntakeId }
},
result: {
data: {
systemIntake: {
__typename: 'SystemIntake',
id: systemIntakeId,
grbReviewers: [
{
__typename: 'SystemIntakeGRBReviewer',
id: '0432800e-2393-4067-b954-0e3671042b6a',
userAccount: {
__typename: 'UserAccount',
id: '06296dc5-2e6f-44ad-93d6-971137762cda',
username: systemIntake.euaUserId!
}
},

{
__typename: 'SystemIntakeGRBReviewer',
id: 'bcf4bc5f-f305-4c23-9d1c-79bf9e9b181c',
userAccount: {
__typename: 'UserAccount',
id: '629e0090-20b2-431e-a3eb-dd9ce7ce7a45',
username: 'TXJK'
}
}
]
}
}
}
};
35 changes: 0 additions & 35 deletions src/hooks/useAuth.ts

This file was deleted.

23 changes: 23 additions & 0 deletions src/queries/GetSystemIntakeGrbReviewersQuery.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { gql } from '@apollo/client';

export const SystemIntakeGrbReviewer = gql`
fragment SystemIntakeGrbReviewer on SystemIntakeGRBReviewer {
id
userAccount {
id
username
}
}
`;

export default gql`
${SystemIntakeGrbReviewer}
query GetSystemIntakeGrbReviewers($id: UUID!) {
systemIntake(id: $id) {
id
grbReviewers {
...SystemIntakeGrbReviewer
}
}
}
`;
37 changes: 37 additions & 0 deletions src/queries/types/GetSystemIntakeGrbReviewers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.

// ====================================================
// GraphQL query operation: GetSystemIntakeGrbReviewers
// ====================================================

export interface GetSystemIntakeGrbReviewers_systemIntake_grbReviewers_userAccount {
__typename: "UserAccount";
id: UUID;
/**
* The unique username of this user account
*/
username: string;
}

export interface GetSystemIntakeGrbReviewers_systemIntake_grbReviewers {
__typename: "SystemIntakeGRBReviewer";
id: UUID;
userAccount: GetSystemIntakeGrbReviewers_systemIntake_grbReviewers_userAccount;
}

export interface GetSystemIntakeGrbReviewers_systemIntake {
__typename: "SystemIntake";
id: UUID;
grbReviewers: GetSystemIntakeGrbReviewers_systemIntake_grbReviewers[];
}

export interface GetSystemIntakeGrbReviewers {
systemIntake: GetSystemIntakeGrbReviewers_systemIntake | null;
}

export interface GetSystemIntakeGrbReviewersVariables {
id: UUID;
}
23 changes: 23 additions & 0 deletions src/queries/types/SystemIntakeGrbReviewer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.

// ====================================================
// GraphQL fragment: SystemIntakeGrbReviewer
// ====================================================

export interface SystemIntakeGrbReviewer_userAccount {
__typename: "UserAccount";
id: UUID;
/**
* The unique username of this user account
*/
username: string;
}

export interface SystemIntakeGrbReviewer {
__typename: "SystemIntakeGRBReviewer";
id: UUID;
userAccount: SystemIntakeGrbReviewer_userAccount;
}
28 changes: 16 additions & 12 deletions src/views/AdditionalInformation/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useContext } from 'react';
import { useTranslation } from 'react-i18next';
import { Alert } from '@trussworks/react-uswds';
import classNames from 'classnames';
Expand All @@ -11,6 +11,7 @@ import { SystemIntake } from 'queries/types/SystemIntake';
import { RequestRelationType } from 'types/graphql-global-types';
import { RequestType } from 'types/requestType';
import formatContractNumbers from 'utils/formatContractNumbers';
import IsGrbViewContext from 'views/GovernanceReviewTeam/IsGrbViewContext';

const AdditionalInformation = ({
request,
Expand All @@ -23,6 +24,8 @@ const AdditionalInformation = ({

const parentRoute = type === 'itgov' ? 'governance-review-team' : 'trb';

const isGrbView = useContext(IsGrbViewContext);

return (
<div>
<PageHeading className="margin-y-0">{t('title')}</PageHeading>
Expand Down Expand Up @@ -71,17 +74,18 @@ const AdditionalInformation = ({
</Alert>
)}

{(request.relationType === null ||
request.relationType === RequestRelationType.NEW_SYSTEM) && (
<UswdsReactLink
to={`/${parentRoute}/${request.id}/additional-information/link`}
className={classNames('usa-button', {
'usa-button--outline': request.relationType !== null
})}
>
{t('linkSystem')}
</UswdsReactLink>
)}
{!isGrbView &&
(request.relationType === null ||
request.relationType === RequestRelationType.NEW_SYSTEM) && (
<UswdsReactLink
to={`/${parentRoute}/${request.id}/additional-information/link`}
className={classNames('usa-button', {
'usa-button--outline': request.relationType !== null
})}
>
{t('linkSystem')}
</UswdsReactLink>
)}

{type !== 'itgov' && // Hide the contract number field from itgov, see Note [EASI-4160 Disable Contract Number Linking]
request.relationType !== null &&
Expand Down
2 changes: 1 addition & 1 deletion src/views/App/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const AppRoutes = () => {

{/* GRT/GRB Routes */}
<SecureRoute
path="/governance-review-team"
path="/(governance-review-team|governance-review-board)/:id"
component={GovernanceReviewTeam}
/>

Expand Down
22 changes: 14 additions & 8 deletions src/views/GovernanceReviewTeam/BusinessCaseReview/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useContext } from 'react';
import { useTranslation } from 'react-i18next';
import { DateTime } from 'luxon';

Expand All @@ -13,6 +13,8 @@ import { GovernanceRequestFeedback } from 'queries/types/GovernanceRequestFeedba
import { BusinessCaseModel } from 'types/businessCase';
import { getFiscalYear } from 'utils/date';

import IsGrbViewContext from '../IsGrbViewContext';

type BusinessCaseReviewProps = {
businessCase: BusinessCaseModel;
grtFeedbacks?: GovernanceRequestFeedback[] | null;
Expand All @@ -25,6 +27,8 @@ const BusinessCaseReview = ({
const { t } = useTranslation('governanceReviewTeam');
const filename = `Business case for ${businessCase.requestName}.pdf`;

const isGrbView = useContext(IsGrbViewContext);

if (!businessCase.id) {
return (
<div data-testid="business-case-review-not-found">
Expand Down Expand Up @@ -94,13 +98,15 @@ const BusinessCaseReview = ({
}
</PDFExport>

<UswdsReactLink
className="usa-button margin-top-5"
variant="unstyled"
to={`/governance-review-team/${businessCase.systemIntakeId}/actions`}
>
Take an action
</UswdsReactLink>
{!isGrbView && (
<UswdsReactLink
className="usa-button margin-top-5"
variant="unstyled"
to={`/governance-review-team/${businessCase.systemIntakeId}/actions`}
>
{t('action:takeAnAction')}
</UswdsReactLink>
)}
</div>
);
};
Expand Down
23 changes: 15 additions & 8 deletions src/views/GovernanceReviewTeam/IntakeReview/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useContext } from 'react';
import { useTranslation } from 'react-i18next';

import UswdsReactLink from 'components/LinkWrapper';
Expand All @@ -7,6 +7,8 @@ import PDFExport from 'components/PDFExport';
import SystemIntakeReview from 'components/SystemIntakeReview';
import { SystemIntake } from 'queries/types/SystemIntake';

import IsGrbViewContext from '../IsGrbViewContext';

type IntakeReviewProps = {
systemIntake: SystemIntake;
};
Expand All @@ -15,6 +17,8 @@ const IntakeReview = ({ systemIntake }: IntakeReviewProps) => {
const { t } = useTranslation('governanceReviewTeam');
const filename = `System intake for ${systemIntake.requestName}.pdf`;

const isGrbView = useContext(IsGrbViewContext);

return (
<div data-testid="intake-review">
<PageHeading className="margin-top-0">{t('general:intake')}</PageHeading>
Expand All @@ -25,13 +29,16 @@ const IntakeReview = ({ systemIntake }: IntakeReviewProps) => {
>
<SystemIntakeReview systemIntake={systemIntake} />
</PDFExport>
<UswdsReactLink
className="usa-button margin-top-5"
variant="unstyled"
to={`/governance-review-team/${systemIntake.id}/actions`}
>
Take an action
</UswdsReactLink>

{!isGrbView && (
<UswdsReactLink
className="usa-button margin-top-5"
variant="unstyled"
to={`/governance-review-team/${systemIntake.id}/actions`}
>
{t('action:takeAnAction')}
</UswdsReactLink>
)}
</div>
);
};
Expand Down
10 changes: 10 additions & 0 deletions src/views/GovernanceReviewTeam/IsGrbViewContext.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { createContext } from 'react';

/**
* Context for rendering GRB reviewer views
*
* Set to `true` if user is GRB reviewer and does not have GOVTEAM job code
*/
const IsGrbViewContext = createContext<boolean>(false);

export default IsGrbViewContext;
Loading

0 comments on commit f038c86

Please sign in to comment.