From 10c21461bdb2208e4f2c98dc9eea5d6e2906fa06 Mon Sep 17 00:00:00 2001 From: andreas-unleash Date: Mon, 21 Aug 2023 14:52:32 +0300 Subject: [PATCH] feat: Last seen for toggles that have an old usage reported (#4538) Last seen for toggles that have an old usage reported and no environment Closes: # [1-1276] (https://linear.app/unleash/issue/1-1276/last-seen-for-toggles-that-have-an-old-usage-reported-and-that-are) ![Screenshot 2023-08-21 at 14 40 42](https://github.com/Unleash/unleash/assets/104830839/bfa20993-3d52-4c34-959d-f3e34b5c5b47) Signed-off-by: andreas-unleash --- .../FeatureEnvironmentSeenCell.tsx | 5 +- .../cells/FeatureSeenCell/LastSeenTooltip.tsx | 123 ++++++++++++------ .../FeatureEnvironmentSeen.tsx | 1 + 3 files changed, 88 insertions(+), 41 deletions(-) diff --git a/frontend/src/component/common/Table/cells/FeatureSeenCell/FeatureEnvironmentSeenCell.tsx b/frontend/src/component/common/Table/cells/FeatureSeenCell/FeatureEnvironmentSeenCell.tsx index c28d9798fb..eadb37691f 100644 --- a/frontend/src/component/common/Table/cells/FeatureSeenCell/FeatureEnvironmentSeenCell.tsx +++ b/frontend/src/component/common/Table/cells/FeatureSeenCell/FeatureEnvironmentSeenCell.tsx @@ -9,7 +9,10 @@ interface IFeatureSeenCellProps { export const FeatureEnvironmentSeenCell: VFC = ({ feature, }) => { - const environments = Object.values(feature.environments); + const environments = Boolean(feature.environments) + ? Object.values(feature.environments) + : []; + return ( ; @@ -63,10 +64,14 @@ interface ILastSeenTooltipProps { export const LastSeenTooltip = ({ environments, + featureLastSeen, ...rest }: ILastSeenTooltipProps) => { const getColor = useLastSeenColors(); const [, defaultTextColor] = getColor(); + const environmentsHaveLastSeen = environments?.some(environment => + Boolean(environment.lastSeenAt) + ); return ( @@ -75,46 +80,84 @@ export const LastSeenTooltip = ({ Usage is reported from connected applications through metrics - {environments && - environments.map(({ name, lastSeenAt }) => ( - - - {name} - - - { - const [, textColor] = - getColor(unit); - return ( - - {`${value} ${unit}${ - value !== 1 ? 's' : '' - } ${suffix}`} - - ); - }} + + {environments?.map(({ name, lastSeenAt }) => ( + + + {name} + + + { + const [, textColor] = + getColor(unit); + return ( + + {`${value} ${unit}${ + value !== 1 + ? 's' + : '' + } ${suffix}`} + + ); + }} + /> + } + elseShow={ + + no usage + + } /> - } - elseShow={ - - no usage - - } - /> - - - ))} + + + ))} + + } + elseShow={ + { + const [, textColor] = getColor(unit); + return ( + + {`Reported ${value} ${unit}${ + value !== 1 ? 's' : '' + } ${suffix}`} + + ); + }} + /> + } + /> ); }; diff --git a/frontend/src/component/feature/FeatureView/FeatureEnvironmentSeen/FeatureEnvironmentSeen.tsx b/frontend/src/component/feature/FeatureView/FeatureEnvironmentSeen/FeatureEnvironmentSeen.tsx index 58fb7d6747..00a037dd30 100644 --- a/frontend/src/component/feature/FeatureView/FeatureEnvironmentSeen/FeatureEnvironmentSeen.tsx +++ b/frontend/src/component/feature/FeatureView/FeatureEnvironmentSeen/FeatureEnvironmentSeen.tsx @@ -91,6 +91,7 @@ export const FeatureEnvironmentSeen = ({ sx={sx} tooltip={ }