1
- import * as React from 'react' ;
2
- import { Content , Divider , Split , SplitItem } from '@patternfly/react-core' ;
3
- import { useMemo } from 'react' ;
1
+ import React , { useState , useRef , useMemo } from 'react' ;
2
+ import { Content , Divider } from '@patternfly/react-core' ;
4
3
import { WorkspaceKind } from '~/shared/types' ;
5
4
import { WorkspaceCreationKindDetails } from '~/app/pages/Workspaces/Creation/kind/WorkspaceCreationKindDetails' ;
6
5
import { WorkspaceCreationKindList } from '~/app/pages/Workspaces/Creation/kind/WorkspaceCreationKindList' ;
6
+ import { WorkspaceCreationDrawer } from '~/app/pages/Workspaces/Creation/WorkspaceCreationDrawer' ;
7
7
8
8
interface WorkspaceCreationKindSelectionProps {
9
9
selectedKind : WorkspaceKind | undefined ;
@@ -13,6 +13,24 @@ interface WorkspaceCreationKindSelectionProps {
13
13
const WorkspaceCreationKindSelection : React . FunctionComponent <
14
14
WorkspaceCreationKindSelectionProps
15
15
> = ( { selectedKind, onSelect } ) => {
16
+ const [ isExpanded , setIsExpanded ] = useState ( false ) ;
17
+ const drawerRef = useRef < HTMLSpanElement > ( undefined ) ;
18
+
19
+ const onExpand = ( ) => {
20
+ if ( drawerRef . current ) {
21
+ drawerRef . current . focus ( ) ;
22
+ }
23
+ } ;
24
+
25
+ const onClick = ( kind ?: WorkspaceKind ) => {
26
+ setIsExpanded ( true ) ;
27
+ return onSelect ( kind ) ;
28
+ } ;
29
+
30
+ const onCloseClick = ( ) => {
31
+ setIsExpanded ( false ) ;
32
+ } ;
33
+
16
34
/* Replace mocks below for BFF call */
17
35
const mockedWorkspaceKind : WorkspaceKind = useMemo (
18
36
( ) => ( {
@@ -152,16 +170,19 @@ const WorkspaceCreationKindSelection: React.FunctionComponent<
152
170
< Content style = { { height : '100%' } } >
153
171
< p > Select a workspace kind to use for the workspace.</ p >
154
172
< Divider />
155
- < Split hasGutter >
156
- < SplitItem isFilled >
157
- < WorkspaceCreationKindList
158
- allWorkspaceKinds = { allWorkspaceKinds }
159
- selectedKind = { selectedKind }
160
- onSelect = { onSelect }
161
- />
162
- </ SplitItem >
163
- < SplitItem style = { { minWidth : '200px' } } > { kindDetailsContent } </ SplitItem >
164
- </ Split >
173
+ < WorkspaceCreationDrawer
174
+ title = "Workspace kind"
175
+ info = { kindDetailsContent }
176
+ isExpanded = { isExpanded }
177
+ onCloseClick = { onCloseClick }
178
+ onExpand = { onExpand }
179
+ >
180
+ < WorkspaceCreationKindList
181
+ allWorkspaceKinds = { allWorkspaceKinds }
182
+ selectedKind = { selectedKind }
183
+ onSelect = { onClick }
184
+ />
185
+ </ WorkspaceCreationDrawer >
165
186
</ Content >
166
187
) ;
167
188
} ;
0 commit comments