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

✨Build presets & map analysis state functions #2152

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion client/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,8 @@
"user": "User",
"version": "Version",
"workPriority": "Work priority",
"YAMLTemplate": "YAML template"
"YAMLTemplate": "YAML template",
"ok": "OK"
},
"titles": {
"archetypeDrawer": "Archetype details",
Expand Down
44 changes: 32 additions & 12 deletions client/src/app/components/Icons/IconedStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,12 @@ export const IconedStatus: React.FC<IIconedStatusProps> = ({
tooltipCount = 0,
}: IIconedStatusProps) => {
const { t } = useTranslation();
const messages = buildPresetLabels(t);
const presets: IconedStatusPresetType = {
InProgressInheritedReviews: {
icon: <InProgressIcon />,
status: "info",
label: t("terms.inProgress"),
label: messages.InProgressInheritedReviews.label,
tooltipMessage: t("message.inheritedReviewTooltip", {
count: tooltipCount,
}),
Expand All @@ -75,7 +76,7 @@ export const IconedStatus: React.FC<IIconedStatusProps> = ({
InProgressInheritedAssessments: {
icon: <InProgressIcon />,
status: "info",
label: t("terms.inProgress"),
label: messages.InProgressInheritedAssessments.label,
tooltipMessage: t("message.inheritedAssessmentTooltip", {
count: tooltipCount,
}),
Expand All @@ -84,7 +85,7 @@ export const IconedStatus: React.FC<IIconedStatusProps> = ({
InheritedReviews: {
icon: <CheckCircleIcon />,
status: "success",
label: t("terms.completed"),
label: messages.InheritedReviews.label,
tooltipMessage: t("message.inheritedReviewTooltip", {
count: tooltipCount,
}),
Expand All @@ -93,7 +94,7 @@ export const IconedStatus: React.FC<IIconedStatusProps> = ({
InheritedAssessments: {
icon: <CheckCircleIcon />,
status: "success",
label: t("terms.completed"),
label: messages.InheritedAssessments.label,
tooltipMessage: t("message.inheritedAssessmentTooltip", {
count: tooltipCount,
}),
Expand All @@ -102,36 +103,36 @@ export const IconedStatus: React.FC<IIconedStatusProps> = ({
Canceled: {
icon: <TimesCircleIcon />,
status: "info",
label: t("terms.canceled"),
label: messages.Canceled.label,
},
Completed: {
icon: <CheckCircleIcon />,
status: "success",
label: t("terms.completed"),
label: messages.Completed.label,
},
CompletedWithErrors: {
icon: <ExclamationTriangleIcon />,
status: "warning",
label: t("terms.completedWithErrors"),
label: messages.CompletedWithErrors.label,
},
Error: {
icon: <ExclamationCircleIcon />,
status: "danger",
label: t("terms.error"),
label: messages.Error.label,
},
Failed: {
icon: <ExclamationCircleIcon />,
status: "danger",
label: t("terms.failed"),
label: messages.Failed.label,
},
InProgress: {
icon: <InProgressIcon />,
status: "info",
label: t("terms.inProgress"),
label: messages.InProgress.label,
},
NotStarted: {
icon: <TimesCircleIcon />,
label: t("terms.notStarted"),
label: messages.NotStarted.label,
},
Ok: {
icon: <CheckCircleIcon />,
Expand All @@ -140,7 +141,7 @@ export const IconedStatus: React.FC<IIconedStatusProps> = ({
Scheduled: {
icon: <InProgressIcon />,
status: "info",
label: t("terms.scheduled"),
label: messages.Scheduled.label,
},
Unknown: {
icon: <UnknownIcon />,
Expand All @@ -162,3 +163,22 @@ export const IconedStatus: React.FC<IIconedStatusProps> = ({
/>
);
};

export const buildPresetLabels = (
t: (key: string) => string
): Record<IconedStatusPreset, { label: string }> => ({
InProgressInheritedReviews: { label: t("terms.inProgress") },
InProgressInheritedAssessments: { label: t("terms.inProgress") },
InheritedReviews: { label: t("terms.completed") },
InheritedAssessments: { label: t("terms.completed") },
Canceled: { label: t("terms.canceled") },
Completed: { label: t("terms.completed") },
CompletedWithErrors: { label: t("terms.completedWithErrors") },
Error: { label: t("terms.error") },
Failed: { label: t("terms.failed") },
InProgress: { label: t("terms.inProgress") },
NotStarted: { label: t("terms.notStarted") },
Scheduled: { label: t("terms.scheduled") },
Ok: { label: t("terms.ok") }, // Add Ok with a label
Unknown: { label: t("terms.unknown") }, // Add Unknown with a label
});
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import React from "react";

import { TaskState } from "@app/api/models";
import { IconedStatus, IconedStatusPreset } from "@app/components/Icons";

import {
buildPresetLabels,
IconedStatus,
IconedStatusPreset,
} from "@app/components/Icons";
export interface ApplicationAnalysisStatusProps {
state: TaskState;
}
Expand Down Expand Up @@ -34,3 +37,13 @@ export const ApplicationAnalysisStatus: React.FC<
> = ({ state }) => {
return <IconedStatus preset={getTaskStatus(state)} />;
};

export const mapAnalysisStateToLabel = (
value: TaskState,
t: (key: string) => string
) => {
const presetKey: IconedStatusPreset = getTaskStatus(value);
const presets = buildPresetLabels(t);
const label = presets[presetKey]?.label ?? presets.Unknown.label;
return label;
};
Loading