From 822851814ac1d6af03814f42bbe29b5162d5ea11 Mon Sep 17 00:00:00 2001 From: Jaanus Sellin Date: Fri, 23 Feb 2024 13:01:49 +0200 Subject: [PATCH] feat: application overview issues schema (#6329) --- .../PaginatedApplicationList.tsx | 2 +- src/lib/openapi/index.ts | 2 ++ .../application-overview-issues-schema.ts | 30 +++++++++++++++++++ .../spec/application-overview-schema.test.ts | 4 +++ .../spec/application-overview-schema.ts | 10 +++++++ 5 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 src/lib/openapi/spec/application-overview-issues-schema.ts diff --git a/frontend/src/component/application/ApplicationList/PaginatedApplicationList.tsx b/frontend/src/component/application/ApplicationList/PaginatedApplicationList.tsx index 6d62999ab5..b81727336f 100644 --- a/frontend/src/component/application/ApplicationList/PaginatedApplicationList.tsx +++ b/frontend/src/component/application/ApplicationList/PaginatedApplicationList.tsx @@ -1,5 +1,5 @@ import { useMemo } from 'react'; -import { Avatar, CircularProgress, Icon, Link } from '@mui/material'; +import { Avatar, Icon, Link } from '@mui/material'; import { Warning } from '@mui/icons-material'; import { styles as themeStyles } from 'component/common'; import { PageContent } from 'component/common/PageContent/PageContent'; diff --git a/src/lib/openapi/index.ts b/src/lib/openapi/index.ts index 753764e285..fcbd3f42d2 100644 --- a/src/lib/openapi/index.ts +++ b/src/lib/openapi/index.ts @@ -200,6 +200,7 @@ import { projectApplicationSdkSchema } from './spec/project-application-sdk-sche import { rolesSchema } from './spec/roles-schema'; import { applicationOverviewSchema } from './spec/application-overview-schema'; import { applicationOverviewEnvironmentSchema } from './spec/application-overview-environment-schema'; +import { applicationOverviewIssuesSchema } from './spec/application-overview-issues-schema'; // Schemas must have an $id property on the form "#/components/schemas/mySchema". export type SchemaId = (typeof schemas)[keyof typeof schemas]['$id']; @@ -248,6 +249,7 @@ export const schemas: UnleashSchemas = { apiTokensSchema, applicationSchema, applicationOverviewSchema, + applicationOverviewIssuesSchema, applicationOverviewEnvironmentSchema, applicationUsageSchema, applicationsSchema, diff --git a/src/lib/openapi/spec/application-overview-issues-schema.ts b/src/lib/openapi/spec/application-overview-issues-schema.ts new file mode 100644 index 0000000000..59ed456564 --- /dev/null +++ b/src/lib/openapi/spec/application-overview-issues-schema.ts @@ -0,0 +1,30 @@ +import { FromSchema } from 'json-schema-to-ts'; + +export const applicationOverviewIssuesSchema = { + $id: '#/components/schemas/applicationOverviewIssuesSchema', + type: 'object', + description: 'This list of issues that might be wrong with the application', + additionalProperties: false, + required: ['type', 'items'], + properties: { + type: { + type: 'string', + enum: ['missingFeature', 'missingStrategy'], + description: 'The name of this action.', + }, + items: { + type: 'array', + items: { + type: 'string', + }, + description: + 'The list of issues that might be wrong with the application', + example: ['feature1', 'feature2'], + }, + }, + components: {}, +} as const; + +export type ApplicationOverviewIssuesSchema = FromSchema< + typeof applicationOverviewIssuesSchema +>; diff --git a/src/lib/openapi/spec/application-overview-schema.test.ts b/src/lib/openapi/spec/application-overview-schema.test.ts index 2255b64449..7edf749bc8 100644 --- a/src/lib/openapi/spec/application-overview-schema.test.ts +++ b/src/lib/openapi/spec/application-overview-schema.test.ts @@ -4,6 +4,10 @@ test('applicationOverviewSchema', () => { const app = { projects: ['default', 'dx'], featureCount: 12, + issues: [ + { type: 'missingFeature', items: ['feature1'] }, + { type: 'missingStrategy', items: ['strategy1'] }, + ], environments: [ { name: 'production', diff --git a/src/lib/openapi/spec/application-overview-schema.ts b/src/lib/openapi/spec/application-overview-schema.ts index cbdf038494..6c484e7b77 100644 --- a/src/lib/openapi/spec/application-overview-schema.ts +++ b/src/lib/openapi/spec/application-overview-schema.ts @@ -1,5 +1,6 @@ import { FromSchema } from 'json-schema-to-ts'; import { applicationOverviewEnvironmentSchema } from './application-overview-environment-schema'; +import { applicationOverviewIssuesSchema } from './application-overview-issues-schema'; export const applicationOverviewSchema = { $id: '#/components/schemas/applicationOverviewSchema', @@ -31,10 +32,19 @@ export const applicationOverviewSchema = { $ref: '#/components/schemas/applicationOverviewEnvironmentSchema', }, }, + issues: { + description: + 'This list of issues that might be wrong with the application', + type: 'array', + items: { + $ref: '#/components/schemas/applicationOverviewIssuesSchema', + }, + }, }, components: { schemas: { applicationOverviewEnvironmentSchema, + applicationOverviewIssuesSchema, }, }, } as const;