Skip to content

Commit

Permalink
Chore/rename dashboard files to insights (#6662)
Browse files Browse the repository at this point in the history
Renames everything related to `executive dashboard` to `insights`

Closes: # [1-2213](https://linear.app/unleash/issue/1-2213/rename-in-fe)

---------

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
  • Loading branch information
andreas-unleash committed Mar 21, 2024
1 parent 8532e08 commit 9be15d4
Show file tree
Hide file tree
Showing 61 changed files with 183 additions and 167 deletions.
Expand Up @@ -6,10 +6,10 @@ import {
allOption,
ProjectSelect,
} from 'component/common/ProjectSelect/ProjectSelect';
import { useExecutiveDashboard } from 'hooks/api/getters/useExecutiveSummary/useExecutiveSummary';
import { DashboardHeader } from './components/DashboardHeader/DashboardHeader';
import { useDashboardData } from './hooks/useDashboardData';
import { Charts } from './Charts';
import { useInsights } from 'hooks/api/getters/useInsights/useInsights';
import { InsightsHeader } from './components/InsightsHeader/InsightsHeader';
import { useInsightsData } from './hooks/useInsightsData';
import { InsightsCharts } from './InsightsCharts';

const StickyWrapper = styled(Box, {
shouldForwardProp: (prop) => prop !== 'scrolled',
Expand All @@ -22,9 +22,9 @@ const StickyWrapper = styled(Box, {
transition: 'padding 0.3s ease',
}));

export const ExecutiveDashboard: VFC = () => {
export const Insights: VFC = () => {
const [scrolled, setScrolled] = useState(false);
const { executiveDashboardData, loading, error } = useExecutiveDashboard();
const { insights, loading, error } = useInsights();
const stateConfig = {
projects: withDefault(ArrayParam, [allOption.id]),
};
Expand All @@ -36,7 +36,7 @@ export const ExecutiveDashboard: VFC = () => {
? (state.projects.filter(Boolean) as string[])
: [];

const dashboardData = useDashboardData(executiveDashboardData, projects);
const insightsData = useInsightsData(insights, projects);

const handleScroll = () => {
if (!scrolled && window.scrollY > 0) {
Expand All @@ -53,7 +53,7 @@ export const ExecutiveDashboard: VFC = () => {
return (
<>
<StickyWrapper scrolled={scrolled}>
<DashboardHeader
<InsightsHeader
actions={
<ProjectSelect
selectedProjects={projects}
Expand All @@ -64,7 +64,11 @@ export const ExecutiveDashboard: VFC = () => {
}
/>
</StickyWrapper>
<Charts loading={loading} projects={projects} {...dashboardData} />
<InsightsCharts
loading={loading}
projects={projects}
{...insightsData}
/>
</>
);
};
Expand Up @@ -12,26 +12,26 @@ import { TimeToProduction } from './componentsStat/TimeToProduction/TimeToProduc
import { TimeToProductionChart } from './componentsChart/TimeToProductionChart/TimeToProductionChart';
import { MetricsSummaryChart } from './componentsChart/MetricsSummaryChart/MetricsSummaryChart';
import { UpdatesPerEnvironmentTypeChart } from './componentsChart/UpdatesPerEnvironmentTypeChart/UpdatesPerEnvironmentTypeChart';
import type { ExecutiveSummarySchema } from '../../openapi';
import type { InstanceInsightsSchema } from 'openapi';
import type { GroupedDataByProject } from './hooks/useGroupedProjectTrends';
import { Box, styled } from '@mui/material';
import { allOption } from '../common/ProjectSelect/ProjectSelect';
import type { VFC } from 'react';
import { chartInfo } from './chart-info';

interface IChartsProps {
flagTrends: ExecutiveSummarySchema['flagTrends'];
projectsData: ExecutiveSummarySchema['projectFlagTrends'];
flagTrends: InstanceInsightsSchema['flagTrends'];
projectsData: InstanceInsightsSchema['projectFlagTrends'];
groupedProjectsData: GroupedDataByProject<
ExecutiveSummarySchema['projectFlagTrends']
InstanceInsightsSchema['projectFlagTrends']
>;
metricsData: ExecutiveSummarySchema['metricsSummaryTrends'];
metricsData: InstanceInsightsSchema['metricsSummaryTrends'];
groupedMetricsData: GroupedDataByProject<
ExecutiveSummarySchema['metricsSummaryTrends']
InstanceInsightsSchema['metricsSummaryTrends']
>;
users: ExecutiveSummarySchema['users'];
userTrends: ExecutiveSummarySchema['userTrends'];
environmentTypeTrends: ExecutiveSummarySchema['environmentTypeTrends'];
users: InstanceInsightsSchema['users'];
userTrends: InstanceInsightsSchema['userTrends'];
environmentTypeTrends: InstanceInsightsSchema['environmentTypeTrends'];
summary: {
total: number;
active: number;
Expand Down Expand Up @@ -64,7 +64,7 @@ const ChartWidget = styled(Widget)(({ theme }) => ({
},
}));

export const Charts: VFC<IChartsProps> = ({
export const InsightsCharts: VFC<IChartsProps> = ({
projects,
users,
summary,
Expand Down
Expand Up @@ -49,7 +49,7 @@ const StyledActionsSmallScreen = styled('div')(({ theme }) => ({
marginTop: theme.spacing(2),
}));

export const DashboardHeader: VFC<DashboardHeaderProps> = ({ actions }) => {
export const InsightsHeader: VFC<DashboardHeaderProps> = ({ actions }) => {
const showInactiveUsers = useUiFlag('showInactiveUsers');
const theme = useTheme();
const isSmallScreen = useMediaQuery(theme.breakpoints.down('md'));
Expand Down
@@ -1,12 +1,15 @@
import { useMemo, type VFC } from 'react';
import 'chartjs-adapter-date-fns';
import { useTheme } from '@mui/material';
import type { ExecutiveSummarySchema } from 'openapi';
import { LineChart, NotEnoughData } from '../../components/LineChart/LineChart';
import { usePlaceholderData } from 'component/executiveDashboard/hooks/usePlaceholderData';
import type { InstanceInsightsSchema } from 'openapi';
import {
LineChart,
NotEnoughData,
} from 'component/insights/components/LineChart/LineChart';
import { usePlaceholderData } from 'component/insights/hooks/usePlaceholderData';

interface IFlagsChartProps {
flagTrends: ExecutiveSummarySchema['flagTrends'];
flagTrends: InstanceInsightsSchema['flagTrends'];
isLoading?: boolean;
}

Expand Down
@@ -1,14 +1,17 @@
import { useMemo, type VFC } from 'react';
import 'chartjs-adapter-date-fns';
import type { ExecutiveSummarySchema } from 'openapi';
import { LineChart, NotEnoughData } from '../../components/LineChart/LineChart';
import { useProjectChartData } from 'component/executiveDashboard/hooks/useProjectChartData';
import { usePlaceholderData } from 'component/executiveDashboard/hooks/usePlaceholderData';
import type { GroupedDataByProject } from '../../hooks/useGroupedProjectTrends';
import type { InstanceInsightsSchema } from 'openapi';
import {
LineChart,
NotEnoughData,
} from 'component/insights/components/LineChart/LineChart';
import { useProjectChartData } from 'component/insights/hooks/useProjectChartData';
import { usePlaceholderData } from 'component/insights/hooks/usePlaceholderData';
import type { GroupedDataByProject } from 'component/insights/hooks/useGroupedProjectTrends';

interface IFlagsProjectChartProps {
projectFlagTrends: GroupedDataByProject<
ExecutiveSummarySchema['projectFlagTrends']
InstanceInsightsSchema['projectFlagTrends']
>;
}

Expand Down
@@ -1,7 +1,7 @@
import type { VFC } from 'react';
import type { ExecutiveSummarySchemaMetricsSummaryTrendsItem } from 'openapi';
import type { InstanceInsightsSchemaMetricsSummaryTrendsItem } from 'openapi';
import { Box, Divider, Paper, styled, Typography } from '@mui/material';
import type { TooltipState } from '../../../components/LineChart/ChartTooltip/ChartTooltip';
import type { TooltipState } from 'component/insights/components/LineChart/ChartTooltip/ChartTooltip';

const StyledTooltipItemContainer = styled(Paper)(({ theme }) => ({
padding: theme.spacing(2),
Expand Down Expand Up @@ -66,7 +66,7 @@ export const MetricsSummaryTooltip: VFC<{ tooltip: TooltipState | null }> = ({
label: point.label,
title: point.dataset.label,
color: point.dataset.borderColor,
value: point.raw as ExecutiveSummarySchemaMetricsSummaryTrendsItem & {
value: point.raw as InstanceInsightsSchemaMetricsSummaryTrendsItem & {
total: number;
},
};
Expand Down
@@ -1,7 +1,7 @@
import type { ExecutiveSummarySchema } from 'openapi';
import type { InstanceInsightsSchema } from 'openapi';

export function aggregateDataPerDate(
items: ExecutiveSummarySchema['metricsSummaryTrends'],
items: InstanceInsightsSchema['metricsSummaryTrends'],
) {
return items.reduce(
(acc, item) => {
Expand Down
@@ -1,22 +1,22 @@
import { useMemo, type VFC } from 'react';
import 'chartjs-adapter-date-fns';

import type { ExecutiveSummarySchema } from 'openapi';
import type { InstanceInsightsSchema } from 'openapi';
import {
fillGradientPrimary,
LineChart,
NotEnoughData,
} from '../../components/LineChart/LineChart';
} from 'component/insights/components/LineChart/LineChart';
import { MetricsSummaryTooltip } from './MetricsChartTooltip/MetricsChartTooltip';
import { useMetricsSummary } from '../../hooks/useMetricsSummary';
import { usePlaceholderData } from 'component/executiveDashboard/hooks/usePlaceholderData';
import type { GroupedDataByProject } from '../../hooks/useGroupedProjectTrends';
import { useMetricsSummary } from 'component/insights/hooks/useMetricsSummary';
import { usePlaceholderData } from 'component/insights/hooks/usePlaceholderData';
import type { GroupedDataByProject } from 'component/insights/hooks/useGroupedProjectTrends';
import { useTheme } from '@mui/material';
import { aggregateDataPerDate } from './MetricsChartTooltip/aggregate-metrics-by-day';

interface IMetricsSummaryChartProps {
metricsSummaryTrends: GroupedDataByProject<
ExecutiveSummarySchema['metricsSummaryTrends']
InstanceInsightsSchema['metricsSummaryTrends']
>;
isAggregate?: boolean;
}
Expand Down
@@ -1,9 +1,9 @@
import type { VFC } from 'react';
import type { ExecutiveSummarySchemaProjectFlagTrendsItem } from 'openapi';
import type { InstanceInsightsSchemaProjectFlagTrendsItem } from 'openapi';
import { Box, Divider, Paper, Typography, styled } from '@mui/material';
import { Badge } from 'component/common/Badge/Badge';
import type { TooltipState } from '../../../components/LineChart/ChartTooltip/ChartTooltip';
import { HorizontalDistributionChart } from '../../../components/HorizontalDistributionChart/HorizontalDistributionChart';
import type { TooltipState } from 'component/insights/components/LineChart/ChartTooltip/ChartTooltip';
import { HorizontalDistributionChart } from 'component/insights/components/HorizontalDistributionChart/HorizontalDistributionChart';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';

const StyledTooltipItemContainer = styled(Paper)(({ theme }) => ({
Expand Down Expand Up @@ -89,7 +89,7 @@ export const HealthTooltip: VFC<{ tooltip: TooltipState | null }> = ({
label: point.label,
title: point.dataset.label,
color: point.dataset.borderColor,
value: point.raw as ExecutiveSummarySchemaProjectFlagTrendsItem,
value: point.raw as InstanceInsightsSchemaProjectFlagTrendsItem,
};
});

Expand Down
@@ -1,19 +1,19 @@
import 'chartjs-adapter-date-fns';
import { useMemo, type VFC } from 'react';
import type { ExecutiveSummarySchema } from 'openapi';
import type { InstanceInsightsSchema } from 'openapi';
import { HealthTooltip } from './HealthChartTooltip/HealthChartTooltip';
import { useProjectChartData } from 'component/executiveDashboard/hooks/useProjectChartData';
import { useProjectChartData } from 'component/insights/hooks/useProjectChartData';
import {
fillGradientPrimary,
LineChart,
NotEnoughData,
} from 'component/executiveDashboard/components/LineChart/LineChart';
} from 'component/insights/components/LineChart/LineChart';
import { useTheme } from '@mui/material';
import type { GroupedDataByProject } from '../../hooks/useGroupedProjectTrends';
import type { GroupedDataByProject } from 'component/insights/hooks/useGroupedProjectTrends';

interface IProjectHealthChartProps {
projectFlagTrends: GroupedDataByProject<
ExecutiveSummarySchema['projectFlagTrends']
InstanceInsightsSchema['projectFlagTrends']
>;
isAggregate?: boolean;
}
Expand Down
@@ -1,21 +1,21 @@
import { useMemo, type VFC } from 'react';
import 'chartjs-adapter-date-fns';
import type { ExecutiveSummarySchema } from 'openapi';
import type { InstanceInsightsSchema } from 'openapi';
import {
fillGradientPrimary,
LineChart,
NotEnoughData,
} from '../../components/LineChart/LineChart';
import { useProjectChartData } from '../../hooks/useProjectChartData';
import type { GroupedDataByProject } from '../../hooks/useGroupedProjectTrends';
import { usePlaceholderData } from '../../hooks/usePlaceholderData';
} from 'component/insights/components/LineChart/LineChart';
import { useProjectChartData } from 'component/insights/hooks/useProjectChartData';
import type { GroupedDataByProject } from 'component/insights/hooks/useGroupedProjectTrends';
import { usePlaceholderData } from 'component/insights/hooks/usePlaceholderData';
import { TimeToProductionTooltip } from './TimeToProductionTooltip/TimeToProductionTooltip';
import { useTheme } from '@mui/material';
import { medianTimeToProduction } from './median-time-to-production';

interface ITimeToProductionChartProps {
projectFlagTrends: GroupedDataByProject<
ExecutiveSummarySchema['projectFlagTrends']
InstanceInsightsSchema['projectFlagTrends']
>;
isAggregate?: boolean;
}
Expand Down
@@ -1,8 +1,8 @@
import type { VFC } from 'react';
import type { ExecutiveSummarySchemaProjectFlagTrendsItem } from 'openapi';
import type { InstanceInsightsSchemaProjectFlagTrendsItem } from 'openapi';
import { Box, Paper, Typography, styled } from '@mui/material';
import { Badge } from 'component/common/Badge/Badge';
import type { TooltipState } from '../../../components/LineChart/ChartTooltip/ChartTooltip';
import type { TooltipState } from 'component/insights/components/LineChart/ChartTooltip/ChartTooltip';

const StyledTooltipItemContainer = styled(Paper)(({ theme }) => ({
padding: theme.spacing(2),
Expand Down Expand Up @@ -62,7 +62,7 @@ export const TimeToProductionTooltip: VFC<{ tooltip: TooltipState | null }> = ({
label: point.label,
title: point.dataset.label,
color: point.dataset.borderColor,
value: point.raw as ExecutiveSummarySchemaProjectFlagTrendsItem,
value: point.raw as InstanceInsightsSchemaProjectFlagTrendsItem,
};
});

Expand Down
@@ -1,13 +1,13 @@
import { medianTimeToProduction } from './median-time-to-production';
import type { ExecutiveSummarySchema } from 'openapi';
import type { InstanceInsightsSchema } from 'openapi';

describe('medianTimeToProduction', () => {
it('calculates the median with a single date and an odd number of projects', () => {
const projectsData = [
{ date: '2023-03-21', timeToProduction: 10 },
{ date: '2023-03-21', timeToProduction: 20 },
{ date: '2023-03-21', timeToProduction: 30 },
] as unknown as ExecutiveSummarySchema['projectFlagTrends'];
] as unknown as InstanceInsightsSchema['projectFlagTrends'];
const expected = { '2023-03-21': 20 };
expect(medianTimeToProduction(projectsData)).toEqual(expected);
});
Expand All @@ -18,7 +18,7 @@ describe('medianTimeToProduction', () => {
{ date: '2023-03-22', timeToProduction: 20 },
{ date: '2023-03-22', timeToProduction: 30 },
{ date: '2023-03-22', timeToProduction: 40 },
] as unknown as ExecutiveSummarySchema['projectFlagTrends'];
] as unknown as InstanceInsightsSchema['projectFlagTrends'];
const expected = { '2023-03-22': 25 };
expect(medianTimeToProduction(projectsData)).toEqual(expected);
});
Expand All @@ -31,7 +31,7 @@ describe('medianTimeToProduction', () => {
{ date: '2023-03-24', timeToProduction: 20 },
{ date: '2023-03-24', timeToProduction: 30 },
{ date: '2023-03-25', timeToProduction: 25 },
] as unknown as ExecutiveSummarySchema['projectFlagTrends'];
] as unknown as InstanceInsightsSchema['projectFlagTrends'];
const expected = {
'2023-03-23': 10,
'2023-03-24': 20,
Expand Down
@@ -1,11 +1,11 @@
import type { ExecutiveSummarySchema } from 'openapi';
import type { InstanceInsightsSchema } from 'openapi';

type GroupedDataByDate<T> = Record<string, T[]>;

type DateResult<T> = Record<string, T>;

export function medianTimeToProduction(
projectsData: ExecutiveSummarySchema['projectFlagTrends'],
projectsData: InstanceInsightsSchema['projectFlagTrends'],
): DateResult<number> {
const groupedData: GroupedDataByDate<number> = {};
projectsData.forEach((item) => {
Expand Down
Expand Up @@ -2,21 +2,24 @@ import { useMemo, type VFC } from 'react';
import 'chartjs-adapter-date-fns';
import { useTheme } from '@mui/material';
import type {
ExecutiveSummarySchema,
ExecutiveSummarySchemaEnvironmentTypeTrendsItem,
InstanceInsightsSchema,
InstanceInsightsSchemaEnvironmentTypeTrendsItem,
} from 'openapi';
import { LineChart, NotEnoughData } from '../../components/LineChart/LineChart';
import { usePlaceholderData } from 'component/executiveDashboard/hooks/usePlaceholderData';
import {
LineChart,
NotEnoughData,
} from 'component/insights/components/LineChart/LineChart';
import { usePlaceholderData } from 'component/insights/hooks/usePlaceholderData';
import { UpdatesPerEnvironmentTypeChartTooltip } from './UpdatesPerEnvironmentTypeChartTooltip/UpdatesPerEnvironmentTypeChartTooltip';

interface IUpdatesPerEnvironmnetTypeChart {
environmentTypeTrends: ExecutiveSummarySchema['environmentTypeTrends'];
environmentTypeTrends: InstanceInsightsSchema['environmentTypeTrends'];
isLoading?: boolean;
}

const groupByDate = (
items: ExecutiveSummarySchemaEnvironmentTypeTrendsItem[],
): Record<string, ExecutiveSummarySchemaEnvironmentTypeTrendsItem[]> => {
items: InstanceInsightsSchemaEnvironmentTypeTrendsItem[],
): Record<string, InstanceInsightsSchemaEnvironmentTypeTrendsItem[]> => {
if (!items) {
return {};
}
Expand All @@ -33,7 +36,7 @@ const groupByDate = (

return acc;
},
{} as Record<string, ExecutiveSummarySchemaEnvironmentTypeTrendsItem[]>,
{} as Record<string, InstanceInsightsSchemaEnvironmentTypeTrendsItem[]>,
);

return grouped;
Expand Down

0 comments on commit 9be15d4

Please sign in to comment.