Skip to content

Commit

Permalink
✨ Add assessment/review status to archetype table
Browse files Browse the repository at this point in the history
Review states:
1. Completed - a review exists
2. NotStarted

Assessment states:
1. Completed - all required assessments done (based on 'assessed' flag)
2. InProgress - some assessments done
3. NotStarted

Signed-off-by: Radoslaw Szwajkowski <[email protected]>
  • Loading branch information
rszwajko committed Mar 8, 2024
1 parent 3e3d690 commit cb38a68
Showing 1 changed file with 49 additions and 6 deletions.
55 changes: 49 additions & 6 deletions client/src/app/pages/archetypes/archetypes-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ import {
useLocalTableControls,
} from "@app/hooks/table-controls";
import {
ARCHETYPES_QUERY_KEY,
ARCHETYPE_QUERY_KEY,
useDeleteArchetypeMutation,
useFetchArchetypes,
} from "@app/queries/archetypes";
Expand All @@ -69,11 +71,14 @@ import {
} from "@app/rbac";
import { checkAccess } from "@app/utils/rbac-utils";
import keycloak from "@app/keycloak";
import { IconedStatus } from "@app/components/IconedStatus";
import { useQueryClient } from "@tanstack/react-query";

const Archetypes: React.FC = () => {
const { t } = useTranslation();
const history = useHistory();
const { pushNotification } = React.useContext(NotificationsContext);
const queryClient = useQueryClient();

const [openCreateArchetype, setOpenCreateArchetype] =
useState<boolean>(false);
Expand Down Expand Up @@ -143,6 +148,8 @@ const Archetypes: React.FC = () => {
variant: "danger",
});
}
queryClient.invalidateQueries([ARCHETYPES_QUERY_KEY]);
queryClient.invalidateQueries([ARCHETYPE_QUERY_KEY, archetype.id]);
};

const onDeleteReviewSuccess = (name: string) => {
Expand All @@ -159,13 +166,16 @@ const Archetypes: React.FC = () => {
);

const discardReview = async (archetype: Archetype) => {
if (!archetype.review?.id) {
return;
}
try {
if (archetype.review?.id) {
await deleteReview({
id: archetype.review.id,
name: archetype.name,
});
}
await deleteReview({
id: archetype.review.id,
name: archetype.name,
});
queryClient.invalidateQueries([ARCHETYPES_QUERY_KEY]);
queryClient.invalidateQueries([ARCHETYPE_QUERY_KEY, archetype.id]);
} catch (error) {
console.error("Error while deleting review:", error);
pushNotification({
Expand Down Expand Up @@ -193,6 +203,8 @@ const Archetypes: React.FC = () => {
tags: t("terms.tags"),
maintainers: t("terms.maintainers"),
applications: t("terms.applications"),
assessment: t("terms.assessment"),
review: t("terms.review"),
},

isFilterEnabled: true,
Expand Down Expand Up @@ -380,6 +392,11 @@ const Archetypes: React.FC = () => {
<Th {...getThProps({ columnKey: "tags" })} />
<Th {...getThProps({ columnKey: "maintainers" })} />
<Th {...getThProps({ columnKey: "applications" })} />
<Th
{...getThProps({ columnKey: "assessment" })}
width={10}
/>
<Th {...getThProps({ columnKey: "review" })} width={10} />
</TableHeaderContentWithControls>
</Tr>
</Thead>
Expand Down Expand Up @@ -427,6 +444,32 @@ const Archetypes: React.FC = () => {
<Td {...getTdProps({ columnKey: "applications" })}>
<ArchetypeApplicationsColumn archetype={archetype} />
</Td>
<Td
width={15}
modifier="truncate"
{...getTdProps({ columnKey: "assessment" })}
>
<IconedStatus
preset={
archetype.assessed
? "Completed"
: archetype?.assessments?.length
? "InProgress"
: "NotStarted"
}
/>
</Td>
<Td
width={15}
modifier="truncate"
{...getTdProps({ columnKey: "review" })}
>
<IconedStatus
preset={
archetype.review ? "Completed" : "NotStarted"
}
/>
</Td>
<Td isActionCell>
{(archetypeWriteAccess ||
assessmentWriteAccess ||
Expand Down

0 comments on commit cb38a68

Please sign in to comment.