diff --git a/frontend/package.json b/frontend/package.json index 509bf8d2e0..10ab139d72 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -30,7 +30,7 @@ "gen:api": "NODE_OPTIONS=\"${NODE_OPTIONS} --no-experimental-fetch\" orval --config orval.config.js", "gen:api:demo": "NODE_OPTIONS=\"${NODE_OPTIONS} --no-experimental-fetch\" UNLEASH_OPENAPI_URL=https://app.unleash-hosted.com/demo/docs/openapi.json yarn run gen:api", "gen:api:sandbox": "NODE_OPTIONS=\"${NODE_OPTIONS} --no-experimental-fetch\" UNLEASH_OPENAPI_URL=https://sandbox.getunleash.io/demo2/docs/openapi.json yarn run gen:api", - "gen:api:clean": "yarn gen:api && rm -rf src/openapi/apis && sed -i '1q' src/openapi/index.ts" + "gen:api:clean": "yarn gen:api && rm -rf src/openapi/apis && sed -i.bak '1q' src/openapi/index.ts && rm src/openapi/index.ts.bak" }, "devDependencies": { "@biomejs/biome": "1.5.1", diff --git a/frontend/src/component/application/ConnectedInstances/ConnectedInstances.tsx b/frontend/src/component/application/ConnectedInstances/ConnectedInstances.tsx index 226a2cb4fd..b9cd91cb4c 100644 --- a/frontend/src/component/application/ConnectedInstances/ConnectedInstances.tsx +++ b/frontend/src/component/application/ConnectedInstances/ConnectedInstances.tsx @@ -1,17 +1,15 @@ import { FC, useEffect, useMemo, useState } from 'react'; -import useApplication from 'hooks/api/getters/useApplication/useApplication'; import { formatDateYMDHMS } from 'utils/formatDate'; import { useRequiredPathParam } from 'hooks/useRequiredPathParam'; import { useConnectedInstancesTable } from './useConnectedInstancesTable'; import { ConnectedInstancesTable } from './ConnectedInstancesTable'; -import { IApplication } from 'interfaces/application'; import { Box, ToggleButton, ToggleButtonGroup } from '@mui/material'; import { useApplicationOverview } from 'hooks/api/getters/useApplicationOverview/useApplicationOverview'; import { useConnectedInstances } from 'hooks/api/getters/useConnectedInstances/useConnectedInstances'; +import { ApplicationEnvironmentInstancesSchemaInstancesItem } from '../../../openapi'; export const ConnectedInstances: FC = () => { const name = useRequiredPathParam('name'); - const { application } = useApplication(name); const { data: applicationOverview } = useApplicationOverview(name); const availableEnvironments = applicationOverview.environments.map( @@ -40,23 +38,17 @@ export const ConnectedInstances: FC = () => { sdkVersion, clientIp, lastSeen, - }: IApplication['instances'][number]) => ({ + }: ApplicationEnvironmentInstancesSchemaInstancesItem) => ({ instanceId, - ip: clientIp, - sdkVersion, - lastSeen: formatDateYMDHMS(lastSeen), + ip: clientIp || '', + sdkVersion: sdkVersion || '', + lastSeen: lastSeen ? formatDateYMDHMS(lastSeen) : '', }); if (!currentEnvironment) { - return application.instances.map(map); + return []; } - return application.instances - .filter( - // @ts-expect-error: the type definition here is incomplete. It - // should be updated as part of this project. - (instance) => instance.environment === currentEnvironment, - ) - .map(map); - }, [application, currentEnvironment]); + return connectedInstances.instances.map(map); + }, [JSON.stringify(connectedInstances), currentEnvironment]); const { getTableProps, getTableBodyProps, headerGroups, rows, prepareRow } = useConnectedInstancesTable(tableData); diff --git a/frontend/src/openapi/models/applicationEnvironmentInstancesSchema.ts b/frontend/src/openapi/models/applicationEnvironmentInstancesSchema.ts new file mode 100644 index 0000000000..b3b28dddb8 --- /dev/null +++ b/frontend/src/openapi/models/applicationEnvironmentInstancesSchema.ts @@ -0,0 +1,14 @@ +/** + * Generated by Orval + * Do not edit manually. + * See `gen:api` script in package.json + */ +import type { ApplicationEnvironmentInstancesSchemaInstancesItem } from './applicationEnvironmentInstancesSchemaInstancesItem'; + +/** + * Data about an application environment instances that are connected to Unleash via an SDK. + */ +export interface ApplicationEnvironmentInstancesSchema { + /** A list of instances */ + instances: ApplicationEnvironmentInstancesSchemaInstancesItem[]; +} diff --git a/frontend/src/openapi/models/applicationEnvironmentInstancesSchemaInstancesItem.ts b/frontend/src/openapi/models/applicationEnvironmentInstancesSchemaInstancesItem.ts new file mode 100644 index 0000000000..a978d59bc4 --- /dev/null +++ b/frontend/src/openapi/models/applicationEnvironmentInstancesSchemaInstancesItem.ts @@ -0,0 +1,16 @@ +/** + * Generated by Orval + * Do not edit manually. + * See `gen:api` script in package.json + */ + +export type ApplicationEnvironmentInstancesSchemaInstancesItem = { + /** An IP address identifying the instance of the application running the SDK */ + clientIp?: string; + /** A unique identifier identifying the instance of the application running the SDK. Often changes based on execution environment. For instance: two pods in Kubernetes will have two different instanceIds */ + instanceId: string; + /** The last time the application environment instance was seen */ + lastSeen?: string; + /** An SDK version identifier. Usually formatted as "unleash-client-:" */ + sdkVersion?: string; +}; diff --git a/frontend/src/openapi/models/getApplicationEnvironmentInstances404.ts b/frontend/src/openapi/models/getApplicationEnvironmentInstances404.ts new file mode 100644 index 0000000000..297b1260e2 --- /dev/null +++ b/frontend/src/openapi/models/getApplicationEnvironmentInstances404.ts @@ -0,0 +1,14 @@ +/** + * Generated by Orval + * Do not edit manually. + * See `gen:api` script in package.json + */ + +export type GetApplicationEnvironmentInstances404 = { + /** The ID of the error instance */ + id?: string; + /** A description of what went wrong. */ + message?: string; + /** The name of the error kind */ + name?: string; +}; diff --git a/frontend/src/openapi/models/index.ts b/frontend/src/openapi/models/index.ts index 57093b6462..815614a68e 100644 --- a/frontend/src/openapi/models/index.ts +++ b/frontend/src/openapi/models/index.ts @@ -90,6 +90,8 @@ export * from './advancedPlaygroundResponseSchema'; export * from './apiTokenSchema'; export * from './apiTokenSchemaType'; export * from './apiTokensSchema'; +export * from './applicationEnvironmentInstancesSchema'; +export * from './applicationEnvironmentInstancesSchemaInstancesItem'; export * from './applicationOverviewEnvironmentSchema'; export * from './applicationOverviewIssuesSchema'; export * from './applicationOverviewIssuesSchemaType'; @@ -573,6 +575,7 @@ export * from './getAllToggles403'; export * from './getApiTokensByName401'; export * from './getApiTokensByName403'; export * from './getApplication404'; +export * from './getApplicationEnvironmentInstances404'; export * from './getApplicationOverview404'; export * from './getApplicationsParams'; export * from './getArchivedFeatures401';