From a482ccff637c18835dc09ac42fd544d81d9c25ed Mon Sep 17 00:00:00 2001 From: Tymoteusz Czech <2625371+Tymek@users.noreply.github.com> Date: Fri, 27 Jan 2023 12:50:00 +0100 Subject: [PATCH] feat: new project health widget (#3003) ## About the changes image ## Discussion points Am I loading "potentially stale" features right? ## Other Testing Linear integration: Close 1-605 Close ID-1-605 Close ID1-605 --- .../Project/ProjectInfo/HealthWidget.tsx | 55 ++++++++++++++++++- .../Project/ProjectInfo/ProjectInfo.styles.ts | 3 +- .../Project/ProjectInfo/ProjectInfo.tsx | 7 ++- .../Project/ProjectInfo/ToggleTypesWidget.tsx | 15 +++-- 4 files changed, 71 insertions(+), 9 deletions(-) diff --git a/frontend/src/component/project/Project/ProjectInfo/HealthWidget.tsx b/frontend/src/component/project/Project/ProjectInfo/HealthWidget.tsx index 4f7752030a..e73844de1e 100644 --- a/frontend/src/component/project/Project/ProjectInfo/HealthWidget.tsx +++ b/frontend/src/component/project/Project/ProjectInfo/HealthWidget.tsx @@ -1,5 +1,6 @@ import { StyledArrowIcon, + StyledCount, StyledDivInfoContainer, StyledDivPercentageContainer, StyledLink, @@ -8,12 +9,64 @@ import { StyledSpanLinkText, } from './ProjectInfo.styles'; import PercentageCircle from 'component/common/PercentageCircle/PercentageCircle'; +import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig'; +import { Box, styled, Typography } from '@mui/material'; interface IHealthWidgetProps { projectId: string; health: number; + total?: number; + stale?: number; } -export const HealthWidget = ({ projectId, health }: IHealthWidgetProps) => { + +const StyledWarning = styled('span')<{ active?: boolean }>( + ({ theme, active }) => ({ + color: active ? theme.palette.warning.dark : 'inherit', + }) +); + +export const HealthWidget = ({ + projectId, + health, + total, + stale, +}: IHealthWidgetProps) => { + const { uiConfig } = useUiConfig(); + + if (uiConfig?.flags?.newProjectOverview) { + return ( + + + Project health + + + + + + {health}% + + + {total} toggles in total + + + + + {stale} + + {' '} + + potentially stale + + + + + View project health + + + + ); + } + return ( diff --git a/frontend/src/component/project/Project/ProjectInfo/ProjectInfo.styles.ts b/frontend/src/component/project/Project/ProjectInfo/ProjectInfo.styles.ts index 6d25433d85..54701fe6d4 100644 --- a/frontend/src/component/project/Project/ProjectInfo/ProjectInfo.styles.ts +++ b/frontend/src/component/project/Project/ProjectInfo/ProjectInfo.styles.ts @@ -71,10 +71,9 @@ export const StyledParagraphEmphasizedText = styled('p')(({ theme }) => ({ }, })); -export const StyledCount = styled('p')(({ theme }) => ({ +export const StyledCount = styled('span')(({ theme }) => ({ fontSize: theme.typography.h2.fontSize, fontWeight: 'bold', - textAlign: 'right', color: theme.palette.text.primary, })); diff --git a/frontend/src/component/project/Project/ProjectInfo/ProjectInfo.tsx b/frontend/src/component/project/Project/ProjectInfo/ProjectInfo.tsx index 812c89cd88..1662d692cc 100644 --- a/frontend/src/component/project/Project/ProjectInfo/ProjectInfo.tsx +++ b/frontend/src/component/project/Project/ProjectInfo/ProjectInfo.tsx @@ -26,7 +26,12 @@ const ProjectInfo = ({ return (