1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-04-15 01:16:22 +02:00

feat: connect project health frontend with backend (#8695)

1. Connected project health frontend with backend
2. Synced orval
This commit is contained in:
Jaanus Sellin 2024-11-08 10:53:45 +02:00 committed by GitHub
parent 656483d819
commit 8a507b2eec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
34 changed files with 466 additions and 21 deletions

View File

@ -1,12 +1,9 @@
import type React from 'react';
import { useTheme, Typography } from '@mui/material';
import { styled } from '@mui/system';
import { Link } from 'react-router-dom';
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
interface ProjectHealthProps {
health: number;
}
import { useProjectStatus } from 'hooks/api/getters/useProjectStatus/useProjectStatus';
import { useRequiredPathParam } from 'hooks/useRequiredPathParam';
const HealthContainer = styled('div')(({ theme }) => ({
backgroundColor: theme.palette.envAccordion.expanded,
@ -30,7 +27,11 @@ const DescriptionText = styled(Typography)(({ theme }) => ({
color: theme.palette.text.secondary,
}));
export const ProjectHealth: React.FC<ProjectHealthProps> = ({ health }) => {
export const ProjectHealth = () => {
const projectId = useRequiredPathParam('projectId');
const {
data: { averageHealth },
} = useProjectStatus(projectId);
const { isOss } = useUiConfig();
const theme = useTheme();
const radius = 40;
@ -40,7 +41,7 @@ export const ProjectHealth: React.FC<ProjectHealthProps> = ({ health }) => {
const gapLength = 0.3;
const filledLength = 1 - gapLength;
const offset = 0.75 - gapLength / 2;
const healthLength = (health / 100) * circumference * 0.7;
const healthLength = (averageHealth / 100) * circumference * 0.7;
return (
<HealthContainer>
@ -74,12 +75,12 @@ export const ProjectHealth: React.FC<ProjectHealthProps> = ({ health }) => {
fill={theme.palette.text.primary}
fontSize='24px'
>
{health}%
{averageHealth}%
</text>
</StyledSVG>
<Typography variant='body2'>
On average, your project health has remained at {health}%
the last 4 weeks
On average, your project health has remained at{' '}
{averageHealth}% the last 4 weeks
</Typography>
</ChartRow>
<DescriptionText variant='body2'>

View File

@ -37,7 +37,7 @@ export const ProjectStatusModal = ({ open, close }: Props) => {
<SidebarModal open={open} onClose={close} label='Project status'>
<ModalContentContainer>
<HealthRow>
<ProjectHealth health={50} />
<ProjectHealth />
<ProjectResources />
</HealthRow>

View File

@ -12,6 +12,7 @@ const placeholderData: ProjectStatusSchema = {
apiTokens: 0,
segments: 0,
},
averageHealth: 0,
};
export const useProjectStatus = (projectId: string) => {

View File

@ -0,0 +1,14 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
export type AddMilestoneToReleasePlanTemplate401 = {
/** The ID of the error instance */
id?: string;
/** A description of what went wrong. */
message?: string;
/** The name of the error kind */
name?: string;
};

View File

@ -0,0 +1,14 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
export type AddMilestoneToReleasePlanTemplate403 = {
/** The ID of the error instance */
id?: string;
/** A description of what went wrong. */
message?: string;
/** The name of the error kind */
name?: string;
};

View File

@ -0,0 +1,14 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
export type AddMilestoneToReleasePlanTemplate404 = {
/** The ID of the error instance */
id?: string;
/** A description of what went wrong. */
message?: string;
/** The name of the error kind */
name?: string;
};

View File

@ -0,0 +1,14 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
export type AddStrategyToMilestone401 = {
/** The ID of the error instance */
id?: string;
/** A description of what went wrong. */
message?: string;
/** The name of the error kind */
name?: string;
};

View File

@ -0,0 +1,14 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
export type AddStrategyToMilestone403 = {
/** The ID of the error instance */
id?: string;
/** A description of what went wrong. */
message?: string;
/** The name of the error kind */
name?: string;
};

View File

@ -0,0 +1,14 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
export type AddStrategyToMilestone404 = {
/** The ID of the error instance */
id?: string;
/** A description of what went wrong. */
message?: string;
/** The name of the error kind */
name?: string;
};

View File

@ -0,0 +1,14 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
export type DeleteReleasePlanTemplate401 = {
/** The ID of the error instance */
id?: string;
/** A description of what went wrong. */
message?: string;
/** The name of the error kind */
name?: string;
};

View File

@ -0,0 +1,14 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
export type DeleteReleasePlanTemplate403 = {
/** The ID of the error instance */
id?: string;
/** A description of what went wrong. */
message?: string;
/** The name of the error kind */
name?: string;
};

View File

@ -162,4 +162,8 @@ export const DeprecatedSearchEventsSchemaType = {
'actions-created': 'actions-created',
'actions-updated': 'actions-updated',
'actions-deleted': 'actions-deleted',
'release-plan-template-created': 'release-plan-template-created',
'release-plan-template-updated': 'release-plan-template-updated',
'release-plan-template-deleted': 'release-plan-template-deleted',
'user-preference-updated': 'user-preference-updated',
} as const;

View File

@ -162,4 +162,8 @@ export const EventSchemaType = {
'actions-created': 'actions-created',
'actions-updated': 'actions-updated',
'actions-deleted': 'actions-deleted',
'release-plan-template-created': 'release-plan-template-created',
'release-plan-template-updated': 'release-plan-template-updated',
'release-plan-template-deleted': 'release-plan-template-deleted',
'user-preference-updated': 'user-preference-updated',
} as const;

View File

@ -47,6 +47,9 @@ export * from './addFeatureDependency404';
export * from './addFeatureStrategy401';
export * from './addFeatureStrategy403';
export * from './addFeatureStrategy404';
export * from './addMilestoneToReleasePlanTemplate401';
export * from './addMilestoneToReleasePlanTemplate403';
export * from './addMilestoneToReleasePlanTemplate404';
export * from './addPublicSignupTokenUser400';
export * from './addPublicSignupTokenUser409';
export * from './addRoleAccessToProject400';
@ -57,6 +60,9 @@ export * from './addRoleAccessToProject415';
export * from './addRoleToUser401';
export * from './addRoleToUser403';
export * from './addRoleToUser404';
export * from './addStrategyToMilestone401';
export * from './addStrategyToMilestone403';
export * from './addStrategyToMilestone404';
export * from './addTag400';
export * from './addTag401';
export * from './addTag403';
@ -504,6 +510,8 @@ export * from './deleteProjectApiToken400';
export * from './deleteProjectApiToken401';
export * from './deleteProjectApiToken403';
export * from './deleteProjectApiToken404';
export * from './deleteReleasePlanTemplate401';
export * from './deleteReleasePlanTemplate403';
export * from './deleteRole400';
export * from './deleteRole401';
export * from './deleteRole403';
@ -1048,6 +1056,9 @@ export * from './releasePlanSchema';
export * from './releasePlanSchemaDiscriminator';
export * from './releasePlanTemplateSchema';
export * from './releasePlanTemplateSchemaDiscriminator';
export * from './remoteMilestoneStrategy401';
export * from './remoteMilestoneStrategy403';
export * from './remoteMilestoneStrategy404';
export * from './removeEnvironment400';
export * from './removeEnvironment401';
export * from './removeEnvironmentFromProject400';
@ -1060,6 +1071,9 @@ export * from './removeFavoriteProject404';
export * from './removeGroupAccess401';
export * from './removeGroupAccess403';
export * from './removeGroupAccess404';
export * from './removeReleasePlanMilestone401';
export * from './removeReleasePlanMilestone403';
export * from './removeReleasePlanMilestone404';
export * from './removeRoleForUser401';
export * from './removeRoleForUser403';
export * from './removeRoleForUser404';
@ -1303,6 +1317,9 @@ export * from './updateLicense400';
export * from './updateLicense401';
export * from './updateLicense403';
export * from './updateLicense415';
export * from './updateMilestoneStrategy401';
export * from './updateMilestoneStrategy403';
export * from './updateMilestoneStrategy404';
export * from './updateProject400';
export * from './updateProject401';
export * from './updateProject403';
@ -1320,6 +1337,14 @@ export * from './updateProjectSchemaMode';
export * from './updatePublicSignupToken400';
export * from './updatePublicSignupToken401';
export * from './updatePublicSignupToken403';
export * from './updateReleasePlanMilestoneSchema';
export * from './updateReleasePlanMilestoneStrategySchema';
export * from './updateReleasePlanTemplate401';
export * from './updateReleasePlanTemplate403';
export * from './updateReleasePlanTemplateMilestone401';
export * from './updateReleasePlanTemplateMilestone403';
export * from './updateReleasePlanTemplateMilestone404';
export * from './updateReleasePlanTemplateSchema';
export * from './updateRole400';
export * from './updateRole401';
export * from './updateRole403';

View File

@ -4,6 +4,7 @@
* See `gen:api` script in package.json
*/
import type { ProjectActivitySchema } from './projectActivitySchema';
import type { ProjectStatusSchemaResources } from './projectStatusSchemaResources';
/**
* Schema representing the overall status of a project, including an array of activity records. Each record in the activity array contains a date and a count, providing a snapshot of the projects activity level over time.
@ -11,13 +12,11 @@ import type { ProjectActivitySchema } from './projectActivitySchema';
export interface ProjectStatusSchema {
/** Array of activity records with date and count, representing the projects daily activity statistics. */
activityCountByDate: ProjectActivitySchema;
/**
* The average health score over the last 4 weeks, indicating whether features are stale or active.
* @minimum 0
*/
averageHealth: number;
/** Key resources within the project */
/** Handwritten placeholder */
resources: {
connectedEnvironments: number;
apiTokens: number;
members: number;
segments: number;
};
resources: ProjectStatusSchemaResources;
}

View File

@ -8,6 +8,24 @@
* Key resources within the project
*/
export type ProjectStatusSchemaResources = {
/** The number of environments that have received SDK traffic in this project. */
/**
* The number of API tokens created specifically for this project.
* @minimum 0
*/
apiTokens: number;
/**
* The number of environments that have received SDK traffic in this project.
* @minimum 0
*/
connectedEnvironments: number;
/**
* The number of users who have been granted roles in this project. Does not include users who have access via groups.
* @minimum 0
*/
members: number;
/**
* The number of segments that are scoped to this project.
* @minimum 0
*/
segments: number;
};

View File

@ -31,7 +31,7 @@ export interface ReleasePlanMilestoneStrategySchema {
* A descriptive title for the strategy
* @nullable
*/
title: string | null;
title?: string | null;
/** Strategy level variants */
variants?: CreateStrategyVariantSchema[];
}

View File

@ -0,0 +1,14 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
export type RemoteMilestoneStrategy401 = {
/** The ID of the error instance */
id?: string;
/** A description of what went wrong. */
message?: string;
/** The name of the error kind */
name?: string;
};

View File

@ -0,0 +1,14 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
export type RemoteMilestoneStrategy403 = {
/** The ID of the error instance */
id?: string;
/** A description of what went wrong. */
message?: string;
/** The name of the error kind */
name?: string;
};

View File

@ -0,0 +1,14 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
export type RemoteMilestoneStrategy404 = {
/** The ID of the error instance */
id?: string;
/** A description of what went wrong. */
message?: string;
/** The name of the error kind */
name?: string;
};

View File

@ -0,0 +1,14 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
export type RemoveReleasePlanMilestone401 = {
/** The ID of the error instance */
id?: string;
/** A description of what went wrong. */
message?: string;
/** The name of the error kind */
name?: string;
};

View File

@ -0,0 +1,14 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
export type RemoveReleasePlanMilestone403 = {
/** The ID of the error instance */
id?: string;
/** A description of what went wrong. */
message?: string;
/** The name of the error kind */
name?: string;
};

View File

@ -0,0 +1,14 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
export type RemoveReleasePlanMilestone404 = {
/** The ID of the error instance */
id?: string;
/** A description of what went wrong. */
message?: string;
/** The name of the error kind */
name?: string;
};

View File

@ -0,0 +1,14 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
export type UpdateMilestoneStrategy401 = {
/** The ID of the error instance */
id?: string;
/** A description of what went wrong. */
message?: string;
/** The name of the error kind */
name?: string;
};

View File

@ -0,0 +1,14 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
export type UpdateMilestoneStrategy403 = {
/** The ID of the error instance */
id?: string;
/** A description of what went wrong. */
message?: string;
/** The name of the error kind */
name?: string;
};

View File

@ -0,0 +1,14 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
export type UpdateMilestoneStrategy404 = {
/** The ID of the error instance */
id?: string;
/** A description of what went wrong. */
message?: string;
/** The name of the error kind */
name?: string;
};

View File

@ -0,0 +1,20 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
import type { UpdateReleasePlanMilestoneStrategySchema } from './updateReleasePlanMilestoneStrategySchema';
/**
* Schema representing the update of a release plan milestone.
*/
export interface UpdateReleasePlanMilestoneSchema {
/** The name of the milestone. */
name: string;
/** The ID of the release plan/template that this milestone belongs to. */
releasePlanDefinitionId: string;
/** The order of the milestone in the release plan. */
sortOrder: number;
/** A list of strategies that are attached to this milestone. */
strategies?: UpdateReleasePlanMilestoneStrategySchema[];
}

View File

@ -0,0 +1,37 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
import type { ConstraintSchema } from './constraintSchema';
import type { ParametersSchema } from './parametersSchema';
import type { CreateStrategyVariantSchema } from './createStrategyVariantSchema';
/**
* Schema representing the update of a release plan milestone.
*/
export interface UpdateReleasePlanMilestoneStrategySchema {
/** A list of the constraints attached to the strategy. See https://docs.getunleash.io/reference/strategy-constraints */
constraints?: ConstraintSchema[];
/** The milestone strategy's ID. Milestone strategy IDs are ulids. */
id?: string;
/**
* The ID of the milestone that this strategy belongs to.
*/
milestoneId: string;
/** An object containing the parameters for the strategy */
parameters?: ParametersSchema;
/** Ids of segments to use for this strategy */
segments?: number[];
/** The order of the strategy in the list */
sortOrder: number;
/** The name of the strategy type */
strategyName: string;
/**
* A descriptive title for the strategy
* @nullable
*/
title?: string | null;
/** Strategy level variants */
variants?: CreateStrategyVariantSchema[];
}

View File

@ -0,0 +1,14 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
export type UpdateReleasePlanTemplate401 = {
/** The ID of the error instance */
id?: string;
/** A description of what went wrong. */
message?: string;
/** The name of the error kind */
name?: string;
};

View File

@ -0,0 +1,14 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
export type UpdateReleasePlanTemplate403 = {
/** The ID of the error instance */
id?: string;
/** A description of what went wrong. */
message?: string;
/** The name of the error kind */
name?: string;
};

View File

@ -0,0 +1,14 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
export type UpdateReleasePlanTemplateMilestone401 = {
/** The ID of the error instance */
id?: string;
/** A description of what went wrong. */
message?: string;
/** The name of the error kind */
name?: string;
};

View File

@ -0,0 +1,14 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
export type UpdateReleasePlanTemplateMilestone403 = {
/** The ID of the error instance */
id?: string;
/** A description of what went wrong. */
message?: string;
/** The name of the error kind */
name?: string;
};

View File

@ -0,0 +1,14 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
export type UpdateReleasePlanTemplateMilestone404 = {
/** The ID of the error instance */
id?: string;
/** A description of what went wrong. */
message?: string;
/** The name of the error kind */
name?: string;
};

View File

@ -0,0 +1,28 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
import type { CreateReleasePlanMilestoneSchema } from './createReleasePlanMilestoneSchema';
/**
* Schema representing the update of a release template.
*/
export interface UpdateReleasePlanTemplateSchema {
/**
* A description of the release template.
* @nullable
*/
description?: string | null;
/**
* The release plan/template's ID. Release template IDs are ulids.
*/
id: string;
/**
* A list of the milestones in this release template.
* @nullable
*/
milestones?: CreateReleasePlanMilestoneSchema[] | null;
/** The name of the release template. */
name: string;
}