11import React , { useState } from 'react' ;
22import { useForm } from 'react-hook-form' ;
33import { useTranslation } from 'react-i18next' ;
4- import { useNavigate } from 'react-router-dom' ;
4+ import { useNavigate , useParams } from 'react-router-dom' ;
55import { isNil } from 'lodash' ;
66import * as yup from 'yup' ;
77import { WizardProps } from '@cloudscape-design/components' ;
88
9- import { Container , FormSelect , KeyValuePairs , SpaceBetween , Wizard } from 'components' ;
9+ import { Container , FormInput , InfoLink , KeyValuePairs , SpaceBetween , Wizard } from 'components' ;
1010
11- import { useBreadcrumbs , useConfirmationDialog , useNotifications } from 'hooks' ;
12- import { useProjectFilter } from 'hooks/useProjectFilter' ;
11+ import { useBreadcrumbs , useConfirmationDialog , useHelpPanel , useNotifications } from 'hooks' ;
1312import { ROUTES } from 'routes' ;
1413import { useApplyFleetMutation } from 'services/fleet' ;
1514
15+ import { DEFAULT_FLEET_INFO } from 'pages/Project/constants' ;
1616import { useYupValidationResolver } from 'pages/Project/hooks/useYupValidationResolver' ;
1717
1818import { getMaxInstancesValidator , getMinInstancesValidator , idleDurationValidator } from './FleetFormFields/constants' ;
@@ -38,18 +38,21 @@ const fleetValidationSchema = yup.object({
3838export const FleetAdd : React . FC = ( ) => {
3939 const { t } = useTranslation ( ) ;
4040 const navigate = useNavigate ( ) ;
41+ const params = useParams ( ) ;
42+ const paramProjectName = params . projectName ?? '' ;
43+ const [ openHelpPanel ] = useHelpPanel ( ) ;
4144 const [ pushNotification ] = useNotifications ( ) ;
4245 const [ openConfirmationDialog ] = useConfirmationDialog ( ) ;
4346 const [ applyFleet , { isLoading : isApplyingFleet } ] = useApplyFleetMutation ( ) ;
4447 const [ activeStepIndex , setActiveStepIndex ] = useState ( 0 ) ;
4548 const resolver = useYupValidationResolver ( fleetValidationSchema ) ;
46- const { projectOptions } = useProjectFilter ( { localStorePrefix : 'add-fleet-page' } ) ;
4749
4850 const loading = isApplyingFleet ;
4951
5052 const formMethods = useForm < IFleetWizardForm > ( {
5153 resolver,
5254 defaultValues : {
55+ project_name : paramProjectName ,
5356 min_instances : 0 ,
5457 idle_duration : '5m' ,
5558 } ,
@@ -80,14 +83,21 @@ export const FleetAdd: React.FC = () => {
8083 } ;
8184
8285 useBreadcrumbs ( [
86+ {
87+ text : t ( 'navigation.project_other' ) ,
88+ href : ROUTES . PROJECT . LIST ,
89+ } ,
90+ {
91+ text : paramProjectName ,
92+ href : ROUTES . PROJECT . DETAILS . FORMAT ( paramProjectName ) ,
93+ } ,
8394 {
8495 text : t ( 'navigation.fleets' ) ,
8596 href : ROUTES . FLEETS . LIST ,
8697 } ,
87-
8898 {
8999 text : t ( 'common.create_wit_text' , { text : t ( 'navigation.fleet' ) } ) ,
90- href : ROUTES . FLEETS . ADD ,
100+ href : ROUTES . FLEETS . ADD . FORMAT ( paramProjectName ) ,
91101 } ,
92102 ] ) ;
93103
@@ -214,19 +224,20 @@ export const FleetAdd: React.FC = () => {
214224 content : (
215225 < Container >
216226 < SpaceBetween direction = "vertical" size = "l" >
217- < FormSelect
227+ < FormInput
218228 label = { t ( 'projects.edit.project_name' ) }
219229 control = { control }
220230 name = "project_name"
221- options = { projectOptions }
231+ readOnly
222232 disabled = { loading }
223233 />
224234 </ SpaceBetween >
225235 </ Container >
226236 ) ,
227237 } ,
228238 {
229- title : 'Fleets' ,
239+ title : 'Settings' ,
240+ info : < InfoLink onFollow = { ( ) => openHelpPanel ( DEFAULT_FLEET_INFO ) } /> ,
230241 content : (
231242 < Container >
232243 < SpaceBetween direction = "vertical" size = "l" >
0 commit comments