Skip to content

Commit

Permalink
🐛 Address in progress inherited status gap
Browse files Browse the repository at this point in the history
Signed-off-by: ibolton336 <[email protected]>
  • Loading branch information
ibolton336 committed Jan 3, 2024
1 parent 0f64970 commit 414863d
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 8 deletions.
32 changes: 31 additions & 1 deletion client/src/app/components/IconedStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import TopologyIcon from "@patternfly/react-icons/dist/esm/icons/topology-icon";

export type IconedStatusPreset =
| "InheritedReviews"
| "InProgressInheritedReviews"
| "InProgressInheritedAssessments"
| "InheritedAssessments"
| "Canceled"
| "Completed"
Expand Down Expand Up @@ -52,6 +54,22 @@ export const IconedStatus: React.FC<IIconedStatusProps> = ({
}: IIconedStatusProps) => {
const { t } = useTranslation();
const presets: IconedStatusPresetType = {
InProgressInheritedReviews: {
icon: <InProgressIcon />,
status: "info",
label: t("terms.inProgress"),
tooltipMessage: t("message.inheritedReviewTooltip", {
count: tooltipCount,
}),
},
InProgressInheritedAssessments: {
icon: <InProgressIcon />,
status: "info",
label: t("terms.inProgress"),
tooltipMessage: t("message.inheritedAssessmentTooltip", {
count: tooltipCount,
}),
},
InheritedReviews: {
icon: <CheckCircleIcon />,
status: "success",
Expand Down Expand Up @@ -131,6 +149,15 @@ export const IconedStatus: React.FC<IIconedStatusProps> = ({
return t("message.inheritedAssessmentTooltip", {
count: tooltipCount,
});
case "InProgressInheritedReviews":
return t("message.inheritedReviewTooltip", {
count: tooltipCount,
});
case "InProgressInheritedAssessments":
return t("message.inheritedAssessmentTooltip", {
count: tooltipCount,
});

default:
return "";
}
Expand All @@ -149,7 +176,10 @@ export const IconedStatus: React.FC<IIconedStatusProps> = ({
</IconWithOptionalTooltip>
</FlexItem>
<FlexItem>{label || presetProps?.label}</FlexItem>
{(preset === "InheritedReviews" || preset === "InheritedAssessments") && (
{(preset === "InheritedReviews" ||
preset === "InheritedAssessments" ||
preset === "InProgressInheritedAssessments" ||
preset === "InProgressInheritedReviews") && (
<FlexItem>
<Tooltip content={getTooltipContent()}>
<TopologyIcon />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@ export const ApplicationAssessmentStatus: React.FC<
return archetypes?.find((archetype) => archetype.id === archetypeRef.id);
});

const hasAssessedArchetype = applicationArchetypes?.some(
const someArchetypesAssessed = applicationArchetypes?.some(
(archetype) => !!archetype?.assessments?.length ?? 0 > 0
);
const areAllArchetypesAssessed =
applicationArchetypes?.every(
(archetype) => archetype?.assessments?.length ?? 0 > 0
) ?? false;

const {
assessments,
Expand All @@ -42,16 +46,22 @@ export const ApplicationAssessmentStatus: React.FC<

let statusPreset: IconedStatusPreset = "NotStarted"; // Default status
let tooltipCount: number = 0;

const assessedArchetypeCount =
applicationArchetypes?.filter(
(archetype) => archetype?.assessments?.length ?? 0 > 0
).length || 0;

const isDirectlyAssessed =
application.assessed && (application.assessments?.length ?? 0) > 0;

if (isDirectlyAssessed) {
statusPreset = "Completed";
} else if (hasAssessedArchetype) {
} else if (areAllArchetypesAssessed) {
statusPreset = "InheritedAssessments";
const assessedArchetypeCount =
applicationArchetypes?.filter(
(archetype) => archetype?.assessments?.length ?? 0 > 0
).length || 0;
tooltipCount = assessedArchetypeCount;
} else if (someArchetypesAssessed) {
statusPreset = "InProgressInheritedAssessments";
tooltipCount = assessedArchetypeCount;
} else if (
assessments?.some(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,18 @@ export const ApplicationReviewStatus: React.FC<
let statusPreset: IconedStatusPreset;
let tooltipCount = 0;

const areAllArchetypesReviewed =
applicationArchetypes?.every((archetype) => !!archetype?.review) ?? false;
const someArchetypesReviewed =
applicationArchetypes?.some((archetype) => !!archetype?.review) ?? false;

if (isAppReviewed) {
statusPreset = "Completed";
} else if (reviewedArchetypeCount > 0) {
} else if (areAllArchetypesReviewed) {
tooltipCount = reviewedArchetypeCount;
statusPreset = "InheritedReviews";
} else if (someArchetypesReviewed) {
statusPreset = "InProgressInheritedReviews";
tooltipCount = reviewedArchetypeCount;
} else {
statusPreset = "NotStarted";
Expand Down

0 comments on commit 414863d

Please sign in to comment.