From fd87fd4e7daec61a86eb004b8dab20d35fe43cd8 Mon Sep 17 00:00:00 2001
From: Tymoteusz Czech <2625371+Tymek@users.noreply.github.com>
Date: Mon, 26 Feb 2024 15:51:14 +0100
Subject: [PATCH] Insights UI (#6341)
- style for headers in Insights dashboard and project selector
- fixed React element key issue in gauge chart
- fixed React attribute issue in Health stats
- active/inactive user stats from backend
---
.../executiveDashboard/ExecutiveDashboard.tsx | 32 ++++++++++----
.../executiveDashboard/Gauge/Gauge.tsx | 9 ++--
.../HealthStats/HealthStats.tsx | 22 +++++-----
.../ProjectSelect/ProjectSelect.tsx | 18 ++++++--
.../UserStats/UserStats.tsx | 43 ++++++++++++-------
5 files changed, 79 insertions(+), 45 deletions(-)
diff --git a/frontend/src/component/executiveDashboard/ExecutiveDashboard.tsx b/frontend/src/component/executiveDashboard/ExecutiveDashboard.tsx
index e6dd57714403..d517208ac9f2 100644
--- a/frontend/src/component/executiveDashboard/ExecutiveDashboard.tsx
+++ b/frontend/src/component/executiveDashboard/ExecutiveDashboard.tsx
@@ -24,6 +24,7 @@ import {
ExecutiveSummarySchemaProjectFlagTrendsItem,
} from '../../openapi';
import { HealthStats } from './HealthStats/HealthStats';
+import { Badge } from 'component/common/Badge/Badge';
const StyledGrid = styled(Box)(({ theme }) => ({
display: 'grid',
@@ -128,15 +129,28 @@ export const ExecutiveDashboard: VFC = () => {
({ paddingBottom: theme.spacing(4) })}>
- Dashboard
+ ({
+ display: 'flex',
+ alignItems: 'center',
+ gap: theme.spacing(1),
+ })}
+ >
+ Insights{' '}
+ Beta
}
/>
-
+
{
{
@@ -199,7 +213,7 @@ export const ExecutiveDashboard: VFC = () => {
diff --git a/frontend/src/component/executiveDashboard/Gauge/Gauge.tsx b/frontend/src/component/executiveDashboard/Gauge/Gauge.tsx
index d0d059d8f128..17867b51e326 100644
--- a/frontend/src/component/executiveDashboard/Gauge/Gauge.tsx
+++ b/frontend/src/component/executiveDashboard/Gauge/Gauge.tsx
@@ -1,4 +1,4 @@
-import { VFC } from 'react';
+import { Fragment, VFC } from 'react';
import { Box, useTheme } from '@mui/material';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
@@ -55,9 +55,8 @@ const GaugeLines = () => {
const end = polarToCartesian(0, 0, endRadius, angle);
return (
- <>
+
{
strokeLinecap='round'
/>
- )
- >
+
);
})}
>
diff --git a/frontend/src/component/executiveDashboard/HealthStats/HealthStats.tsx b/frontend/src/component/executiveDashboard/HealthStats/HealthStats.tsx
index 821847742be3..b742e636ee1d 100644
--- a/frontend/src/component/executiveDashboard/HealthStats/HealthStats.tsx
+++ b/frontend/src/component/executiveDashboard/HealthStats/HealthStats.tsx
@@ -39,7 +39,7 @@ export const HealthStats: VFC = ({
cy='129'
r='121'
stroke={theme.palette.charts.health.orbit}
- stroke-width='3'
+ strokeWidth='3'
/>
= ({
width='238'
height='238'
filterUnits='userSpaceOnUse'
- color-interpolation-filters='sRGB'
+ colorInterpolationFilters='sRGB'
>
-
+
= ({
width='124'
height='124'
filterUnits='userSpaceOnUse'
- color-interpolation-filters='sRGB'
+ colorInterpolationFilters='sRGB'
>
-
+
= ({
width='106'
height='106'
filterUnits='userSpaceOnUse'
- color-interpolation-filters='sRGB'
+ colorInterpolationFilters='sRGB'
>
-
+
= ({
width='106'
height='106'
filterUnits='userSpaceOnUse'
- color-interpolation-filters='sRGB'
+ colorInterpolationFilters='sRGB'
>
-
+
= ({
gradientUnits='userSpaceOnUse'
>
diff --git a/frontend/src/component/executiveDashboard/ProjectSelect/ProjectSelect.tsx b/frontend/src/component/executiveDashboard/ProjectSelect/ProjectSelect.tsx
index 88d58a43329f..a444eccb3e68 100644
--- a/frontend/src/component/executiveDashboard/ProjectSelect/ProjectSelect.tsx
+++ b/frontend/src/component/executiveDashboard/ProjectSelect/ProjectSelect.tsx
@@ -1,17 +1,24 @@
import { ComponentProps, Dispatch, SetStateAction, VFC } from 'react';
-import { Autocomplete, Box, styled, TextField } from '@mui/material';
+import {
+ Autocomplete,
+ Box,
+ styled,
+ TextField,
+ Typography,
+} from '@mui/material';
import { renderOption } from '../../playground/Playground/PlaygroundForm/renderOption';
import useProjects from '../../../hooks/api/getters/useProjects/useProjects';
const StyledBox = styled(Box)(({ theme }) => ({
- width: '25%',
- marginLeft: '75%',
marginBottom: theme.spacing(4),
marginTop: theme.spacing(4),
[theme.breakpoints.down('lg')]: {
width: '100%',
marginLeft: 0,
},
+ display: 'flex',
+ justifyContent: 'space-between',
+ alignItems: 'center',
}));
interface IOption {
@@ -74,13 +81,16 @@ export const ProjectSelect: VFC = ({
return (
+
+ Insights per project
+
(
)}
diff --git a/frontend/src/component/executiveDashboard/UserStats/UserStats.tsx b/frontend/src/component/executiveDashboard/UserStats/UserStats.tsx
index 91c19f908a4d..013ecb32386b 100644
--- a/frontend/src/component/executiveDashboard/UserStats/UserStats.tsx
+++ b/frontend/src/component/executiveDashboard/UserStats/UserStats.tsx
@@ -1,8 +1,8 @@
+import React, { type FC } from 'react';
import { ChevronRight } from '@mui/icons-material';
import { Box, Typography, styled } from '@mui/material';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
import { useUiFlag } from 'hooks/useUiFlag';
-import React from 'react';
import { Link } from 'react-router-dom';
const StyledUserContainer = styled(Box)(({ theme }) => ({
@@ -71,10 +71,15 @@ const StyledLink = styled(Link)({
interface IUserStatsProps {
count: number;
+ active?: number;
+ inactive?: number;
}
-export const UserStats: React.FC = ({ count }) => {
+export const UserStats: FC = ({ count, active, inactive }) => {
const showInactiveUsers = useUiFlag('showInactiveUsers');
+ const showDistribution =
+ showInactiveUsers && active !== undefined && inactive !== undefined;
+ const activeUsersPercentage = ((active || 0) / count) * 100;
return (
<>
@@ -86,23 +91,25 @@ export const UserStats: React.FC = ({ count }) => {
-
+
>
@@ -135,9 +142,9 @@ const StyledUserDistributionLine = styled(Box)(
}),
);
-const UserDistribution = () => {
+const UserDistribution = ({ activeUsersPercentage = 100 }) => {
const getLineWidth = () => {
- return [80, 20];
+ return [activeUsersPercentage, 100 - activeUsersPercentage];
};
const [activeWidth, inactiveWidth] = getLineWidth();
@@ -175,7 +182,6 @@ const StyledUserDistIndicator = styled(Box)(
: theme.palette.warning.border,
borderRadius: `2px`,
marginRight: theme.spacing(1),
- marginTop: theme.spacing(0.8),
}),
);
@@ -208,12 +214,19 @@ const UserDistributionInfo: React.FC = ({
}) => {
return (
-
-
- {type === 'active' ? 'Active' : 'Inactive'} users
-
+
+
+
+ {type === 'active' ? 'Active' : 'Inactive'} users
+
+
{percentage}%