Skip to content

Commit

Permalink
feat: enable admins to change decision, preserving current functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
kriscooke committed Apr 23, 2021
1 parent 5ee53aa commit 3596c7e
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React from 'react';
import {Row, Col, ListGroup} from 'react-bootstrap';
import {Row, Button, ListGroup} from 'react-bootstrap';
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
import {
faCheck,
faComments,
faTimes,
faHourglassHalf
faHourglassHalf,
faKey
} from '@fortawesome/free-solid-svg-icons';
import {graphql, createFragmentContainer} from 'react-relay';
import {ApplicationReviewStepSelector_applicationReviewSteps} from '__generated__/ApplicationReviewStepSelector_applicationReviewSteps.graphql';
Expand All @@ -21,6 +22,7 @@ interface Props {
| 'REJECTED'
| 'REQUESTED_CHANGES';
onDecisionOrChangeRequestAction: () => void;
changeDecision?: () => void;
}

const DECISION_BS_VARIANT = {
Expand Down Expand Up @@ -48,7 +50,8 @@ export const ApplicationReviewStepSelector: React.FunctionComponent<Props> = ({
selectedStep,
onSelectStep,
decisionOrChangeRequestStatus,
onDecisionOrChangeRequestAction
onDecisionOrChangeRequestAction,
changeDecision
}) => {
const steps = applicationReviewSteps.edges;
const allStepsAreComplete = steps.every((edge) => edge.node.isComplete);
Expand All @@ -67,7 +70,7 @@ export const ApplicationReviewStepSelector: React.FunctionComponent<Props> = ({
);
return (
<Row>
<Col md={5}>
<div className="col-xxl-6 col-xl-7 col-lg-8 col-md-10">
<ListGroup as="ul" id="selector">
{steps.map((edge) => {
const {reviewStepId, isComplete} = edge.node;
Expand Down Expand Up @@ -126,7 +129,24 @@ export const ApplicationReviewStepSelector: React.FunctionComponent<Props> = ({
{DECISION_BUTTON_TEXT[decisionOrChangeRequestStatus]}
</ListGroup.Item>
</ListGroup>
</Col>
</div>
<div
id="change-decision"
className="col-md-12 col-lg-4 col-xl-5 col-xxl-6"
>
{changeDecision && (
<Button variant="link" onClick={changeDecision}>
<FontAwesomeIcon icon={faKey} style={{marginRight: 8}} />
Change decision
</Button>
)}
</div>
<style jsx>{`
#change-decision {
display: flex;
align-items: flex-end;
}
`}</style>
<style jsx global>{`
#selector .list-group-item-danger.disabled,
.list-group-item-danger:disabled {
Expand Down
4 changes: 2 additions & 2 deletions app/containers/Admin/ApplicationReview/ReviewSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export const ReviewSidebar: React.FunctionComponent<Props> = ({
description={description}
createdAt={createdAt}
createdBy={`${ciipUserByCreatedBy.firstName} ${ciipUserByCreatedBy.lastName}`}
viewOnly={applicationReviewStep?.isComplete}
viewOnly={isFinalized || applicationReviewStep?.isComplete}
isResolved={resolved}
onResolveToggle={resolveComment}
onDelete={(id) => deleteComment(id, commentType)}
Expand Down Expand Up @@ -248,7 +248,7 @@ export const ReviewSidebar: React.FunctionComponent<Props> = ({
<Button variant="link" style={{padding: 0}} onClick={toggleResolved}>
{`${showingResolved ? 'Hide' : 'Show'} resolved comments`}
</Button>
{!applicationReviewStep?.isComplete && (
{!isFinalized && !applicationReviewStep?.isComplete && (
<Button variant="primary">+ New Comment</Button>
)}
</div>
Expand Down
18 changes: 17 additions & 1 deletion app/pages/analyst/application-review.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,18 @@ class ApplicationReview extends Component<Props, State> {
const {overrideJustification} = query?.applicationRevision;
const {applicationRevisionStatus} = query?.application.reviewRevisionStatus;
const {session} = query || {};
const currentReviewIsFinalized = applicationRevisionStatus !== 'SUBMITTED';
const isUserAdmin = query?.session.userGroups.some((groupConst) =>
ADMIN_GROUP.includes(groupConst)
);
const currentReviewIsFinalized =
this.props.query?.application.reviewRevisionStatus
.applicationRevisionStatus !== 'SUBMITTED';

const handleChangeDecision = () => {
console.log(
'implement me in 2294 - should open the decision dialog with admin-only option to revert (to SUBMITTED status)'
);
};

return (
<DefaultLayout
Expand Down Expand Up @@ -147,6 +158,11 @@ class ApplicationReview extends Component<Props, State> {
}
selectedStep={this.state.selectedReviewStepId}
onSelectStep={this.selectReviewStep}
changeDecision={
isUserAdmin && currentReviewIsFinalized
? handleChangeDecision
: undefined
}
/>
<ApplicationOverrideNotification
overrideJustification={overrideJustification}
Expand Down

0 comments on commit 3596c7e

Please sign in to comment.