From 2f4193ad01d0cc8b58c48445ffd7f86f8ebc2bb2 Mon Sep 17 00:00:00 2001 From: Thomas Heartman Date: Wed, 13 Nov 2024 11:47:40 +0100 Subject: [PATCH] 1-3106: add project lifecycle messages --- .../ProjectStatus/LifecycleMessages.ts | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 frontend/src/component/project/Project/ProjectStatus/LifecycleMessages.ts diff --git a/frontend/src/component/project/Project/ProjectStatus/LifecycleMessages.ts b/frontend/src/component/project/Project/ProjectStatus/LifecycleMessages.ts new file mode 100644 index 000000000000..8fbc8a875337 --- /dev/null +++ b/frontend/src/component/project/Project/ProjectStatus/LifecycleMessages.ts @@ -0,0 +1,42 @@ +import type { ProjectStatusSchemaLifecycleSummary } from 'openapi'; + +const genericMessages: Record< + keyof ProjectStatusSchemaLifecycleSummary, + string +> = { + initial: + 'Feature flags in the initial phase indicate you have created flags that is not detected in any environments which mean either integration issues or unused flags', + preLive: + 'In the pre-live phase the feature is being developed and tested in controlled environments. Once the feature is ready the flag can be enabled in production.', + live: 'The feature is being rolled out in production according to the decided strategy targeting user segments and/or using percentage rollout. ', + completed: + 'Flags that are in cleanup are potentially stale flags. View the flags to evaluate whether you should archive them in Unleash and clean up your codebase to reduce technical debt', + archived: + 'Flags that have been archived and are no longer in use, but kept for future reference.', +}; + +const mostTimeMessages: Partial< + Record +> = { + initial: + 'You spend most of your time the initial phase. This indicates you have created flags that is not detected in any environments which mean either integration issues or unused flags', + preLive: + 'You spend most of your time in the pre-live phase. This indicates time is spent on development and testing, but the feature has not been rolled out in production. ', +}; + +export const getLifecycleMessages = ( + spendsMostTimeIn: Array, +) => { + const messages = Object.entries(genericMessages).map(([stage, message]) => { + const stageKey = stage as keyof ProjectStatusSchemaLifecycleSummary; + if ( + spendsMostTimeIn.includes(stageKey) && + stageKey in mostTimeMessages + ) { + return [stageKey, mostTimeMessages[stageKey]]; + } + return [stage, message]; + }); + + return Object.fromEntries(messages); +};