@@ -4,10 +4,8 @@ import {
44 useRevalidateApiResource ,
55} from '../../lib/api/useApiResource' ;
66import { ErrorDialogHandle } from '../Shared/ErrorMessageBox.tsx' ;
7- import { APIError } from '../../lib/api/error' ;
87
98import {
10- CreateWorkspace ,
119 CreateWorkspaceResource ,
1210 CreateWorkspaceType ,
1311} from '../../lib/api/types/crate/createWorkspace' ;
@@ -20,19 +18,20 @@ import { useTranslation } from 'react-i18next';
2018import { zodResolver } from '@hookform/resolvers/zod' ;
2119import { useForm } from 'react-hook-form' ;
2220import { validationSchemaProjectWorkspace } from '../../lib/api/validations/schemas.ts' ;
23- import {
24- CreateProjectWorkspaceDialog ,
25- MetadataAndMembersForm ,
26- OnCreatePayload ,
27- } from '../Dialogs/CreateProjectWorkspaceDialog.tsx' ;
21+ import { MetadataAndMembersForm } from '../Dialogs/CreateProjectWorkspaceDialog.tsx' ;
2822import {
2923 Bar ,
3024 Button ,
3125 Dialog ,
26+ Grid ,
27+ List ,
28+ ListItemStandard ,
29+ Text ,
3230 Wizard ,
3331 WizardStep ,
3432} from '@ui5/webcomponents-react' ;
35- import { KubectlInfoButton } from '../Dialogs/KubectlCommandInfo/KubectlInfoButton.tsx' ;
33+ import YamlViewer from '../Yaml/YamlViewer.tsx' ;
34+ import { stringify } from 'yaml' ;
3635
3736export type CreateDialogProps = {
3837 name : string ;
@@ -55,7 +54,9 @@ export const CreateManagedControlPlaneWizardContainer: FC<
5554 handleSubmit,
5655 resetField,
5756 setValue,
58- formState : { errors } ,
57+ reset,
58+ getValues,
59+ formState : { errors, isValid } ,
5960 watch,
6061 } = useForm < CreateDialogProps > ( {
6162 resolver : zodResolver ( validationSchemaProjectWorkspace ) ,
@@ -66,9 +67,15 @@ export const CreateManagedControlPlaneWizardContainer: FC<
6667 members : [ ] ,
6768 } ,
6869 } ) ;
69- const { t } = useTranslation ( ) ;
70+ const resetFormAndClose = ( ) => {
71+ reset ( ) ;
72+ setSelectedStep ( 1 ) ;
73+ setIsOpen ( false ) ;
74+ } ;
75+ console . log ( errors ) ;
76+ // const { t } = useTranslation();
7077 const { user } = useAuth ( ) ;
71- const [ selectedStep , useSelectedStep ] = useState ( 1 ) ;
78+ const [ selectedStep , setSelectedStep ] = useState ( 1 ) ;
7279 const username = user ?. email ;
7380
7481 const clearForm = useCallback ( ( ) => {
@@ -87,15 +94,20 @@ export const CreateManagedControlPlaneWizardContainer: FC<
8794 clearForm ( ) ;
8895 }
8996 } , [ resetField , setValue , username , isOpen , clearForm ] ) ;
90- const namespace = projectnameToNamespace ( project ) ;
91- const toast = useToast ( ) ;
92-
93- const { trigger } = useApiResourceMutation < CreateWorkspaceType > (
94- CreateWorkspaceResource ( namespace ) ,
95- ) ;
96- const revalidate = useRevalidateApiResource ( ListWorkspaces ( project ) ) ;
97- const errorDialogRef = useRef < ErrorDialogHandle > ( null ) ;
9897
98+ const onNextClick = ( ) => {
99+ console . log ( 'test' ) ;
100+ handleSubmit (
101+ ( ) => {
102+ console . log ( 'valid' ) ;
103+ setSelectedStep ( 2 ) ;
104+ } ,
105+ ( ) => {
106+ console . log ( 'not valid' ) ;
107+ console . log ( errors ) ;
108+ } ,
109+ ) ( ) ;
110+ } ;
99111 return (
100112 < Dialog
101113 stretch = { true }
@@ -107,8 +119,11 @@ export const CreateManagedControlPlaneWizardContainer: FC<
107119 design = "Footer"
108120 endContent = {
109121 < div style = { { display : 'flex' , alignItems : 'center' , gap : '8px' } } >
110- < Button design = "Emphasized" onClick = { ( ) => { } } >
111- { t ( 'CreateProjectWorkspaceDialog.createButton' ) }
122+ < Button design = { 'Negative' } onClick = { resetFormAndClose } >
123+ Close
124+ </ Button >
125+ < Button design = "Emphasized" onClick = { onNextClick } >
126+ Next
112127 </ Button >
113128 </ div >
114129 }
@@ -123,6 +138,9 @@ export const CreateManagedControlPlaneWizardContainer: FC<
123138 disabled = { false }
124139 selected = { selectedStep === 1 }
125140 data-step = { '1' }
141+ onClick = { ( ) => {
142+ setSelectedStep ( 1 ) ;
143+ } }
126144 >
127145 < MetadataAndMembersForm
128146 members = { watch ( 'members' ) }
@@ -134,10 +152,52 @@ export const CreateManagedControlPlaneWizardContainer: FC<
134152 < WizardStep
135153 icon = { 'activities' }
136154 titleText = "Summarize"
137- disabled = { false }
155+ disabled = { ! isValid }
138156 selected = { selectedStep === 2 }
139157 data-step = { '2' }
140- > </ WizardStep >
158+ onClick = { ( ) => {
159+ setSelectedStep ( 1 ) ;
160+ } }
161+ >
162+ < h1 > Summarize</ h1 >
163+ < Grid defaultSpan = "XL6 L6 M6 S6" >
164+ < div >
165+ < List headerText = { 'Metadata' } >
166+ < ListItemStandard
167+ text = { 'Name:' }
168+ additionalText = { getValues ( 'name' ) }
169+ />
170+ < ListItemStandard
171+ title = { 'Metadata' }
172+ text = { 'Display name:' }
173+ additionalText = { getValues ( 'displayName' ) }
174+ />
175+ < ListItemStandard
176+ text = { 'Charging target:' }
177+ additionalText = { getValues ( 'chargingTarget' ) }
178+ /> { ' ' }
179+ < ListItemStandard text = { 'Namespace:' } additionalText = { '' } /> { ' ' }
180+ < ListItemStandard text = { 'Region:' } additionalText = { '' } />
181+ </ List >
182+ < br />
183+ < List headerText = { 'Members' } >
184+ { getValues ( 'members' ) . map ( ( member ) => (
185+ < ListItemStandard
186+ key = { member . name }
187+ text = { member . name }
188+ additionalText = { member . kind }
189+ />
190+ ) ) }
191+ </ List >
192+ </ div >
193+ < div >
194+ < YamlViewer
195+ yamlString = { stringify ( getValues ( 'members' ) ) }
196+ filename = { 'test' }
197+ />
198+ </ div >
199+ </ Grid >
200+ </ WizardStep >
141201 </ Wizard >
142202 </ Dialog >
143203 ) ;
0 commit comments