Skip to content

Commit

Permalink
feat: connect project health frontend with backend (#8695)
Browse files Browse the repository at this point in the history
1. Connected project health frontend with backend
2. Synced orval
  • Loading branch information
sjaanus authored Nov 8, 2024
1 parent 656483d commit 8a507b2
Show file tree
Hide file tree
Showing 34 changed files with 466 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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;
Expand All @@ -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>
Expand Down Expand Up @@ -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'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const placeholderData: ProjectStatusSchema = {
apiTokens: 0,
segments: 0,
},
averageHealth: 0,
};

export const useProjectStatus = (projectId: string) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
};
Original file line number Diff line number Diff line change
@@ -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;
};
Original file line number Diff line number Diff line change
@@ -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;
};
14 changes: 14 additions & 0 deletions frontend/src/openapi/models/addStrategyToMilestone401.ts
Original file line number Diff line number Diff line change
@@ -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;
};
14 changes: 14 additions & 0 deletions frontend/src/openapi/models/addStrategyToMilestone403.ts
Original file line number Diff line number Diff line change
@@ -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;
};
14 changes: 14 additions & 0 deletions frontend/src/openapi/models/addStrategyToMilestone404.ts
Original file line number Diff line number Diff line change
@@ -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;
};
14 changes: 14 additions & 0 deletions frontend/src/openapi/models/deleteReleasePlanTemplate401.ts
Original file line number Diff line number Diff line change
@@ -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;
};
14 changes: 14 additions & 0 deletions frontend/src/openapi/models/deleteReleasePlanTemplate403.ts
Original file line number Diff line number Diff line change
@@ -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;
};
Original file line number Diff line number Diff line change
Expand Up @@ -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;
4 changes: 4 additions & 0 deletions frontend/src/openapi/models/eventSchemaType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
25 changes: 25 additions & 0 deletions frontend/src/openapi/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -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';
Expand All @@ -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';
Expand Down
15 changes: 7 additions & 8 deletions frontend/src/openapi/models/projectStatusSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@
* 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 project’s activity level over time.
*/
export interface ProjectStatusSchema {
/** Array of activity records with date and count, representing the project’s 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;
}
20 changes: 19 additions & 1 deletion frontend/src/openapi/models/projectStatusSchemaResources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
}
14 changes: 14 additions & 0 deletions frontend/src/openapi/models/remoteMilestoneStrategy401.ts
Original file line number Diff line number Diff line change
@@ -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;
};
14 changes: 14 additions & 0 deletions frontend/src/openapi/models/remoteMilestoneStrategy403.ts
Original file line number Diff line number Diff line change
@@ -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;
};
14 changes: 14 additions & 0 deletions frontend/src/openapi/models/remoteMilestoneStrategy404.ts
Original file line number Diff line number Diff line change
@@ -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;
};
Loading

0 comments on commit 8a507b2

Please sign in to comment.