feat(ws): added namespaces tab to workspace kind details (#406)
Signed-off-by: paulovmr <832830+paulovmr@users.noreply.github.com>
This commit is contained in:
parent
248c242f84
commit
7c660e41ba
|
@ -1,12 +1,9 @@
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { useNotebookAPI } from '~/app/hooks/useNotebookAPI';
|
import { useNotebookAPI } from '~/app/hooks/useNotebookAPI';
|
||||||
import { Workspace, WorkspaceKind } from '~/shared/api/backendApiTypes';
|
import { Workspace, WorkspaceKind } from '~/shared/api/backendApiTypes';
|
||||||
import { WorkspaceCountPerKindImagePodConfig } from '~/app/types';
|
import { WorkspaceCountPerOption } from '~/app/types';
|
||||||
|
|
||||||
export type WorkspaceCountPerKind = Record<
|
export type WorkspaceCountPerKind = Record<WorkspaceKind['name'], WorkspaceCountPerOption>;
|
||||||
WorkspaceKind['name'],
|
|
||||||
WorkspaceCountPerKindImagePodConfig
|
|
||||||
>;
|
|
||||||
|
|
||||||
export const useWorkspaceCountPerKind = (): WorkspaceCountPerKind => {
|
export const useWorkspaceCountPerKind = (): WorkspaceCountPerKind => {
|
||||||
const { api } = useNotebookAPI();
|
const { api } = useNotebookAPI();
|
||||||
|
@ -22,6 +19,7 @@ export const useWorkspaceCountPerKind = (): WorkspaceCountPerKind => {
|
||||||
count: 0,
|
count: 0,
|
||||||
countByImage: {},
|
countByImage: {},
|
||||||
countByPodConfig: {},
|
countByPodConfig: {},
|
||||||
|
countByNamespace: {},
|
||||||
};
|
};
|
||||||
acc[workspace.workspaceKind.name].count =
|
acc[workspace.workspaceKind.name].count =
|
||||||
(acc[workspace.workspaceKind.name].count || 0) + 1;
|
(acc[workspace.workspaceKind.name].count || 0) + 1;
|
||||||
|
@ -37,6 +35,8 @@ export const useWorkspaceCountPerKind = (): WorkspaceCountPerKind => {
|
||||||
(acc[workspace.workspaceKind.name].countByPodConfig[
|
(acc[workspace.workspaceKind.name].countByPodConfig[
|
||||||
workspace.podTemplate.options.podConfig.current.id
|
workspace.podTemplate.options.podConfig.current.id
|
||||||
] || 0) + 1;
|
] || 0) + 1;
|
||||||
|
acc[workspace.workspaceKind.name].countByNamespace[workspace.namespace] =
|
||||||
|
(acc[workspace.workspaceKind.name].countByNamespace[workspace.namespace] || 0) + 1;
|
||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
setWorkspaceCountPerKind(countPerKind);
|
setWorkspaceCountPerKind(countPerKind);
|
||||||
|
|
|
@ -14,6 +14,7 @@ import {
|
||||||
} from '@patternfly/react-core';
|
} from '@patternfly/react-core';
|
||||||
import { WorkspaceKind } from '~/shared/api/backendApiTypes';
|
import { WorkspaceKind } from '~/shared/api/backendApiTypes';
|
||||||
import { WorkspaceCountPerKind } from '~/app/hooks/useWorkspaceCountPerKind';
|
import { WorkspaceCountPerKind } from '~/app/hooks/useWorkspaceCountPerKind';
|
||||||
|
import { WorkspaceKindDetailsNamespaces } from '~/app/pages/WorkspaceKinds/details/WorkspaceKindDetailsNamespaces';
|
||||||
import { WorkspaceKindDetailsOverview } from './WorkspaceKindDetailsOverview';
|
import { WorkspaceKindDetailsOverview } from './WorkspaceKindDetailsOverview';
|
||||||
import { WorkspaceKindDetailsImages } from './WorkspaceKindDetailsImages';
|
import { WorkspaceKindDetailsImages } from './WorkspaceKindDetailsImages';
|
||||||
import { WorkspaceKindDetailsPodConfigs } from './WorkspaceKindDetailsPodConfigs';
|
import { WorkspaceKindDetailsPodConfigs } from './WorkspaceKindDetailsPodConfigs';
|
||||||
|
@ -67,6 +68,12 @@ export const WorkspaceKindDetails: React.FunctionComponent<WorkspaceKindDetailsP
|
||||||
tabContentId="podConfigsTabContent"
|
tabContentId="podConfigsTabContent"
|
||||||
aria-label="Pod Configs"
|
aria-label="Pod Configs"
|
||||||
/>
|
/>
|
||||||
|
<Tab
|
||||||
|
eventKey={3}
|
||||||
|
title={<TabTitleText>Namespaces</TabTitleText>}
|
||||||
|
tabContentId="namespacesTabContent"
|
||||||
|
aria-label="Namespaces"
|
||||||
|
/>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
</DrawerPanelBody>
|
</DrawerPanelBody>
|
||||||
|
|
||||||
|
@ -110,6 +117,20 @@ export const WorkspaceKindDetails: React.FunctionComponent<WorkspaceKindDetailsP
|
||||||
/>
|
/>
|
||||||
</TabContentBody>
|
</TabContentBody>
|
||||||
</TabContent>
|
</TabContent>
|
||||||
|
<TabContent
|
||||||
|
key={3}
|
||||||
|
eventKey={3}
|
||||||
|
id="namespacesTabContent"
|
||||||
|
activeKey={activeTabKey}
|
||||||
|
hidden={activeTabKey !== 3}
|
||||||
|
>
|
||||||
|
<TabContentBody hasPadding>
|
||||||
|
<WorkspaceKindDetailsNamespaces
|
||||||
|
workspaceKind={workspaceKind}
|
||||||
|
workspaceCountPerKind={workspaceCountPerKind}
|
||||||
|
/>
|
||||||
|
</TabContentBody>
|
||||||
|
</TabContent>
|
||||||
</DrawerPanelBody>
|
</DrawerPanelBody>
|
||||||
</DrawerPanelContent>
|
</DrawerPanelContent>
|
||||||
);
|
);
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
import React from 'react';
|
||||||
|
import { List, ListItem } from '@patternfly/react-core';
|
||||||
|
import { WorkspaceKind } from '~/shared/api/backendApiTypes';
|
||||||
|
import { WorkspaceCountPerKind } from '~/app/hooks/useWorkspaceCountPerKind';
|
||||||
|
|
||||||
|
type WorkspaceDetailsNamespacesProps = {
|
||||||
|
workspaceKind: WorkspaceKind;
|
||||||
|
workspaceCountPerKind: WorkspaceCountPerKind;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const WorkspaceKindDetailsNamespaces: React.FunctionComponent<
|
||||||
|
WorkspaceDetailsNamespacesProps
|
||||||
|
> = ({ workspaceKind, workspaceCountPerKind }) => (
|
||||||
|
<List isPlain>
|
||||||
|
{Object.keys(
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||||
|
workspaceCountPerKind[workspaceKind.name]
|
||||||
|
? workspaceCountPerKind[workspaceKind.name].countByNamespace
|
||||||
|
: [],
|
||||||
|
).map((namespace, rowIndex) => (
|
||||||
|
<ListItem key={rowIndex}>
|
||||||
|
{namespace}:{' '}
|
||||||
|
{
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||||
|
workspaceCountPerKind[workspaceKind.name]
|
||||||
|
? workspaceCountPerKind[workspaceKind.name].countByNamespace[namespace]
|
||||||
|
: 0
|
||||||
|
}
|
||||||
|
{' Workspaces'}
|
||||||
|
</ListItem>
|
||||||
|
))}
|
||||||
|
</List>
|
||||||
|
);
|
|
@ -4,6 +4,7 @@ import {
|
||||||
WorkspacePodConfigValue,
|
WorkspacePodConfigValue,
|
||||||
WorkspacePodVolumeMount,
|
WorkspacePodVolumeMount,
|
||||||
WorkspacePodSecretMount,
|
WorkspacePodSecretMount,
|
||||||
|
Workspace,
|
||||||
} from '~/shared/api/backendApiTypes';
|
} from '~/shared/api/backendApiTypes';
|
||||||
|
|
||||||
export interface WorkspacesColumnNames {
|
export interface WorkspacesColumnNames {
|
||||||
|
@ -47,8 +48,9 @@ export interface WorkspaceFormData {
|
||||||
properties: WorkspaceFormProperties;
|
properties: WorkspaceFormProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface WorkspaceCountPerKindImagePodConfig {
|
export interface WorkspaceCountPerOption {
|
||||||
count: number;
|
count: number;
|
||||||
countByImage: Record<WorkspaceImageConfigValue['id'], number>;
|
countByImage: Record<WorkspaceImageConfigValue['id'], number>;
|
||||||
countByPodConfig: Record<WorkspacePodConfigValue['id'], number>;
|
countByPodConfig: Record<WorkspacePodConfigValue['id'], number>;
|
||||||
|
countByNamespace: Record<Workspace['namespace'], number>;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue