diff --git a/client/public/locales/en/translation.json b/client/public/locales/en/translation.json index a26eb9ebb9..37ec58db06 100644 --- a/client/public/locales/en/translation.json +++ b/client/public/locales/en/translation.json @@ -502,7 +502,8 @@ "user": "User", "version": "Version", "workPriority": "Work priority", - "YAMLTemplate": "YAML template" + "YAMLTemplate": "YAML template", + "ok": "OK" }, "titles": { "archetypeDrawer": "Archetype details", diff --git a/client/src/app/components/Icons/IconedStatus.tsx b/client/src/app/components/Icons/IconedStatus.tsx index 984031d995..4c81a283eb 100644 --- a/client/src/app/components/Icons/IconedStatus.tsx +++ b/client/src/app/components/Icons/IconedStatus.tsx @@ -62,11 +62,12 @@ export const IconedStatus: React.FC = ({ tooltipCount = 0, }: IIconedStatusProps) => { const { t } = useTranslation(); + const messages = buildPresetLabels(t); const presets: IconedStatusPresetType = { InProgressInheritedReviews: { icon: , status: "info", - label: t("terms.inProgress"), + label: messages.InProgressInheritedReviews.label, tooltipMessage: t("message.inheritedReviewTooltip", { count: tooltipCount, }), @@ -75,7 +76,7 @@ export const IconedStatus: React.FC = ({ InProgressInheritedAssessments: { icon: , status: "info", - label: t("terms.inProgress"), + label: messages.InProgressInheritedAssessments.label, tooltipMessage: t("message.inheritedAssessmentTooltip", { count: tooltipCount, }), @@ -84,7 +85,7 @@ export const IconedStatus: React.FC = ({ InheritedReviews: { icon: , status: "success", - label: t("terms.completed"), + label: messages.InheritedReviews.label, tooltipMessage: t("message.inheritedReviewTooltip", { count: tooltipCount, }), @@ -93,7 +94,7 @@ export const IconedStatus: React.FC = ({ InheritedAssessments: { icon: , status: "success", - label: t("terms.completed"), + label: messages.InheritedAssessments.label, tooltipMessage: t("message.inheritedAssessmentTooltip", { count: tooltipCount, }), @@ -102,36 +103,36 @@ export const IconedStatus: React.FC = ({ Canceled: { icon: , status: "info", - label: t("terms.canceled"), + label: messages.Canceled.label, }, Completed: { icon: , status: "success", - label: t("terms.completed"), + label: messages.Completed.label, }, CompletedWithErrors: { icon: , status: "warning", - label: t("terms.completedWithErrors"), + label: messages.CompletedWithErrors.label, }, Error: { icon: , status: "danger", - label: t("terms.error"), + label: messages.Error.label, }, Failed: { icon: , status: "danger", - label: t("terms.failed"), + label: messages.Failed.label, }, InProgress: { icon: , status: "info", - label: t("terms.inProgress"), + label: messages.InProgress.label, }, NotStarted: { icon: , - label: t("terms.notStarted"), + label: messages.NotStarted.label, }, Ok: { icon: , @@ -140,7 +141,7 @@ export const IconedStatus: React.FC = ({ Scheduled: { icon: , status: "info", - label: t("terms.scheduled"), + label: messages.Scheduled.label, }, Unknown: { icon: , @@ -162,3 +163,22 @@ export const IconedStatus: React.FC = ({ /> ); }; + +export const buildPresetLabels = ( + t: (key: string) => string +): Record => ({ + 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 +}); diff --git a/client/src/app/pages/applications/components/application-analysis-status.tsx b/client/src/app/pages/applications/components/application-analysis-status.tsx index 4462aacaff..a0ea6bd883 100644 --- a/client/src/app/pages/applications/components/application-analysis-status.tsx +++ b/client/src/app/pages/applications/components/application-analysis-status.tsx @@ -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; } @@ -34,3 +37,13 @@ export const ApplicationAnalysisStatus: React.FC< > = ({ state }) => { return ; }; + +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; +};