File tree Expand file tree Collapse file tree 4 files changed +62
-6
lines changed
workspaces/frontend/src/app
pages/WorkspaceKinds/details Expand file tree Collapse file tree 4 files changed +62
-6
lines changed Original file line number Diff line number Diff line change 11import * as React from 'react' ;
22import { useNotebookAPI } from '~/app/hooks/useNotebookAPI' ;
33import { Workspace , WorkspaceKind } from '~/shared/api/backendApiTypes' ;
4- import { WorkspaceCountPerKindImagePodConfig } from '~/app/types' ;
4+ import { WorkspaceCountPerOption } from '~/app/types' ;
55
6- export type WorkspaceCountPerKind = Record <
7- WorkspaceKind [ 'name' ] ,
8- WorkspaceCountPerKindImagePodConfig
9- > ;
6+ export type WorkspaceCountPerKind = Record < WorkspaceKind [ 'name' ] , WorkspaceCountPerOption > ;
107
118export const useWorkspaceCountPerKind = ( ) : WorkspaceCountPerKind => {
129 const { api } = useNotebookAPI ( ) ;
@@ -22,6 +19,7 @@ export const useWorkspaceCountPerKind = (): WorkspaceCountPerKind => {
2219 count : 0 ,
2320 countByImage : { } ,
2421 countByPodConfig : { } ,
22+ countByNamespace : { } ,
2523 } ;
2624 acc [ workspace . workspaceKind . name ] . count =
2725 ( acc [ workspace . workspaceKind . name ] . count || 0 ) + 1 ;
@@ -37,6 +35,8 @@ export const useWorkspaceCountPerKind = (): WorkspaceCountPerKind => {
3735 ( acc [ workspace . workspaceKind . name ] . countByPodConfig [
3836 workspace . podTemplate . options . podConfig . current . id
3937 ] || 0 ) + 1 ;
38+ acc [ workspace . workspaceKind . name ] . countByNamespace [ workspace . namespace ] =
39+ ( acc [ workspace . workspaceKind . name ] . countByNamespace [ workspace . namespace ] || 0 ) + 1 ;
4040 return acc ;
4141 } , { } ) ;
4242 setWorkspaceCountPerKind ( countPerKind ) ;
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import {
1414} from '@patternfly/react-core' ;
1515import { WorkspaceKind } from '~/shared/api/backendApiTypes' ;
1616import { WorkspaceCountPerKind } from '~/app/hooks/useWorkspaceCountPerKind' ;
17+ import { WorkspaceKindDetailsNamespaces } from '~/app/pages/WorkspaceKinds/details/WorkspaceKindDetailsNamespaces' ;
1718import { WorkspaceKindDetailsOverview } from './WorkspaceKindDetailsOverview' ;
1819import { WorkspaceKindDetailsImages } from './WorkspaceKindDetailsImages' ;
1920import { WorkspaceKindDetailsPodConfigs } from './WorkspaceKindDetailsPodConfigs' ;
@@ -67,6 +68,12 @@ export const WorkspaceKindDetails: React.FunctionComponent<WorkspaceKindDetailsP
6768 tabContentId = "podConfigsTabContent"
6869 aria-label = "Pod Configs"
6970 />
71+ < Tab
72+ eventKey = { 3 }
73+ title = { < TabTitleText > Namespaces</ TabTitleText > }
74+ tabContentId = "namespacesTabContent"
75+ aria-label = "Namespaces"
76+ />
7077 </ Tabs >
7178 </ DrawerPanelBody >
7279
@@ -110,6 +117,20 @@ export const WorkspaceKindDetails: React.FunctionComponent<WorkspaceKindDetailsP
110117 />
111118 </ TabContentBody >
112119 </ TabContent >
120+ < TabContent
121+ key = { 3 }
122+ eventKey = { 3 }
123+ id = "namespacesTabContent"
124+ activeKey = { activeTabKey }
125+ hidden = { activeTabKey !== 3 }
126+ >
127+ < TabContentBody hasPadding >
128+ < WorkspaceKindDetailsNamespaces
129+ workspaceKind = { workspaceKind }
130+ workspaceCountPerKind = { workspaceCountPerKind }
131+ />
132+ </ TabContentBody >
133+ </ TabContent >
113134 </ DrawerPanelBody >
114135 </ DrawerPanelContent >
115136 ) ;
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import { List , ListItem } from '@patternfly/react-core' ;
3+ import { WorkspaceKind } from '~/shared/api/backendApiTypes' ;
4+ import { WorkspaceCountPerKind } from '~/app/hooks/useWorkspaceCountPerKind' ;
5+
6+ type WorkspaceDetailsNamespacesProps = {
7+ workspaceKind : WorkspaceKind ;
8+ workspaceCountPerKind : WorkspaceCountPerKind ;
9+ } ;
10+
11+ export const WorkspaceKindDetailsNamespaces : React . FunctionComponent <
12+ WorkspaceDetailsNamespacesProps
13+ > = ( { workspaceKind, workspaceCountPerKind } ) => (
14+ < List isPlain >
15+ { Object . keys (
16+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
17+ workspaceCountPerKind [ workspaceKind . name ]
18+ ? workspaceCountPerKind [ workspaceKind . name ] . countByNamespace
19+ : [ ] ,
20+ ) . map ( ( namespace , rowIndex ) => (
21+ < ListItem key = { rowIndex } >
22+ { namespace } :{ ' ' }
23+ {
24+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
25+ workspaceCountPerKind [ workspaceKind . name ]
26+ ? workspaceCountPerKind [ workspaceKind . name ] . countByNamespace [ namespace ]
27+ : 0
28+ }
29+ { ' Workspaces' }
30+ </ ListItem >
31+ ) ) }
32+ </ List >
33+ ) ;
Original file line number Diff line number Diff line change 44 WorkspacePodConfigValue ,
55 WorkspacePodVolumeMount ,
66 WorkspacePodSecretMount ,
7+ Workspace ,
78} from '~/shared/api/backendApiTypes' ;
89
910export interface WorkspacesColumnNames {
@@ -47,8 +48,9 @@ export interface WorkspaceFormData {
4748 properties : WorkspaceFormProperties ;
4849}
4950
50- export interface WorkspaceCountPerKindImagePodConfig {
51+ export interface WorkspaceCountPerOption {
5152 count : number ;
5253 countByImage : Record < WorkspaceImageConfigValue [ 'id' ] , number > ;
5354 countByPodConfig : Record < WorkspacePodConfigValue [ 'id' ] , number > ;
55+ countByNamespace : Record < Workspace [ 'namespace' ] , number > ;
5456}
You can’t perform that action at this time.
0 commit comments