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

🐛 UX improvements for app assessment/review discard #1525

Merged
merged 5 commits into from
Nov 10, 2023
Merged
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
5 changes: 4 additions & 1 deletion client/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
"createTags": "Create tags",
"cancelAnalysis": "Cancel analysis",
"delete": "Delete",
"discardAssessment": "Discard assessment/review",
"discardAssessment": "Discard assessment(s)",
"discardReview": "Discard review",

"downloadCsvTemplate": "Download CSV template",
"download": "Download {{what}}",
"duplicate": "Duplicate",
Expand Down Expand Up @@ -360,6 +362,7 @@
"reports": "Reports",
"repositoryType": "Repository type",
"review": "Review",
"reviewedArchetype": "Archetype reviewed",
"reviews": "Reviews",
"reviewComments": "Review comments",
"risk": "Risk",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ import {
MenuToggle,
MenuToggleElement,
Modal,
Tooltip,
Grid,
GridItem,
} from "@patternfly/react-core";
import { PencilAltIcon, TagIcon, EllipsisVIcon } from "@patternfly/react-icons";
import {
Expand All @@ -28,6 +31,7 @@ import {
ActionsColumn,
Tbody,
} from "@patternfly/react-table";
import { QuestionCircleIcon } from "@patternfly/react-icons/dist/esm/icons/question-circle-icon";

// @app components and utilities
import { AppPlaceholder } from "@app/components/AppPlaceholder";
Expand Down Expand Up @@ -184,7 +188,10 @@ export const ApplicationsTable: React.FC = () => {
Application[]
>([]);

const [assessmentOrReviewToDiscard, setAssessmentOrReviewToDiscard] =
const [assessmentToDiscard, setAssessmentToDiscard] =
React.useState<Application | null>(null);

const [reviewToDiscard, setReviewToDiscard] =
React.useState<Application | null>(null);

const {
Expand Down Expand Up @@ -257,15 +264,8 @@ export const ApplicationsTable: React.FC = () => {
onDeleteError
);

const discardAssessmentAndReview = async (application: Application) => {
const discardAssessment = async (application: Application) => {
try {
if (application.review?.id) {
await deleteReview({
id: application.review.id,
name: application.name,
});
}

if (application.assessments) {
await Promise.all(
application.assessments.map(async (assessment) => {
Expand All @@ -277,7 +277,20 @@ export const ApplicationsTable: React.FC = () => {
);
}
} catch (error) {
console.error("Error while deleting assessments and/or reviews:", error);
console.error("Error while deleting assessments:", error);
}
};

const discardReview = async (application: Application) => {
try {
if (application.review?.id) {
await deleteReview({
id: application.review.id,
name: application.name,
});
}
} catch (error) {
console.error("Error while deleting review:", error);
}
};

Expand Down Expand Up @@ -827,13 +840,27 @@ export const ApplicationsTable: React.FC = () => {
modifier="truncate"
{...getTdProps({ columnKey: "review" })}
>
<IconedStatus
preset={
isAppReviewed || hasReviewedArchetype
? "Completed"
: "NotStarted"
}
/>
<Grid>
<GridItem span={10}>
<IconedStatus
preset={
isAppReviewed || hasReviewedArchetype
? "Completed"
: "NotStarted"
}
/>
</GridItem>
<GridItem span={2}>
{hasReviewedArchetype ? (
<Tooltip
content={t("terms.reviewedArchetype")}
aria-label="review"
>
<QuestionCircleIcon />
</Tooltip>
) : null}
</GridItem>
</Grid>
</Td>
<Td
width={10}
Expand Down Expand Up @@ -879,14 +906,21 @@ export const ApplicationsTable: React.FC = () => {
title: t("actions.review"),
onClick: () => reviewSelectedApp(application),
},
...(application?.review
...(application?.assessments?.length
? [
{
title: t("actions.discardAssessment"),
onClick: () =>
setAssessmentOrReviewToDiscard(
application
),
setAssessmentToDiscard(application),
},
]
: []),
...(application?.review
? [
{
title: t("actions.discardReview"),
onClick: () =>
setReviewToDiscard(application),
},
]
: []),
Expand Down Expand Up @@ -1071,16 +1105,46 @@ export const ApplicationsTable: React.FC = () => {
what: t("terms.assessment").toLowerCase(),
})}
titleIconVariant={"warning"}
isOpen={assessmentOrReviewToDiscard !== null}
isOpen={assessmentToDiscard !== null}
message={
<span>
<Trans
i18nKey="dialog.message.discardAssessment"
values={{
applicationName: assessmentOrReviewToDiscard?.name,
applicationName: assessmentToDiscard?.name,
}}
>
The assessment(s) for{" "}
<strong>{assessmentToDiscard?.name}</strong> will be discarded.
Do you wish to continue?
</Trans>
</span>
}
confirmBtnVariant={ButtonVariant.primary}
confirmBtnLabel={t("actions.continue")}
cancelBtnLabel={t("actions.cancel")}
onCancel={() => setAssessmentToDiscard(null)}
onClose={() => setAssessmentToDiscard(null)}
onConfirm={() => {
discardAssessment(assessmentToDiscard!);
setAssessmentToDiscard(null);
}}
/>
<ConfirmDialog
title={t("dialog.title.discard", {
what: t("terms.review").toLowerCase(),
})}
titleIconVariant={"warning"}
isOpen={reviewToDiscard !== null}
message={
<span>
<Trans
i18nKey="dialog.message.discardReview"
values={{
applicationName: reviewToDiscard?.name,
}}
>
The assessment for <strong>applicationName</strong> will be
The review for <strong>{reviewToDiscard?.name}</strong> will be
discarded, as well as the review result. Do you wish to
continue?
</Trans>
Expand All @@ -1089,11 +1153,11 @@ export const ApplicationsTable: React.FC = () => {
confirmBtnVariant={ButtonVariant.primary}
confirmBtnLabel={t("actions.continue")}
cancelBtnLabel={t("actions.cancel")}
onCancel={() => setAssessmentOrReviewToDiscard(null)}
onClose={() => setAssessmentOrReviewToDiscard(null)}
onCancel={() => setReviewToDiscard(null)}
onClose={() => setReviewToDiscard(null)}
onConfirm={() => {
discardAssessmentAndReview(assessmentOrReviewToDiscard!);
setAssessmentOrReviewToDiscard(null);
discardReview(reviewToDiscard!);
setReviewToDiscard(null);
}}
/>
<ConfirmDialog
Expand Down
Loading
Loading