diff --git a/web/src/cde/components/CreateGitspace/components/SelectMachine/SelectMachine.tsx b/web/src/cde/components/CreateGitspace/components/SelectMachine/SelectMachine.tsx index e17613e364..934faeb6d7 100644 --- a/web/src/cde/components/CreateGitspace/components/SelectMachine/SelectMachine.tsx +++ b/web/src/cde/components/CreateGitspace/components/SelectMachine/SelectMachine.tsx @@ -15,7 +15,7 @@ */ import React, { useEffect } from 'react' -import { Layout, Text } from '@harnessio/uicore' +import { Container, Layout, Text } from '@harnessio/uicore' import { Menu, MenuItem } from '@blueprintjs/core' import { Cpu } from 'iconoir-react' import { useFormikContext } from 'formik' @@ -59,7 +59,7 @@ export const SelectMachine = ({ options, defaultValue }: SelectMachineInterface) }) useEffect(() => { - if (defaultValue && gitspaceId) { + if (defaultValue && !gitspaceId) { onChange('infra_provider_resource_id', defaultValue.id) } }, [defaultValue?.id, gitspaceId]) @@ -67,60 +67,62 @@ export const SelectMachine = ({ options, defaultValue }: SelectMachineInterface) const data = (machineTypes?.find(item => item.id === machine) || {}) as (typeof machineTypes)[0] return ( - - - - {getString('cde.machine')} - {data.label || getString('cde.machine')} - - - } - errorMessage={errors.infra_provider_resource_id} - formikName="infra_provider_resource_id" - renderMenu={ - - - {machineTypes.length ? ( - <> - {machineTypes.map(item => { - return ( - - {item.label?.toUpperCase()} - - - {getString('cde.cpu')}: {item.cpu?.toUpperCase()} - - - {getString('cde.memory')}: {item.memory?.toUpperCase()} - - - {getString('cde.disk')}: {item.disk?.toUpperCase()} - - - - } - onClick={() => { - onChange('infra_provider_resource_id', item.id || '') - }} - /> - ) - })} - - ) : ( - <> - {getString('cde.regionSelectWarning')} - - )} - - - } - /> + + + + + {getString('cde.machine')} + {data.label || getString('cde.machine')} + + + } + errorMessage={errors.infra_provider_resource_id} + formikName="infra_provider_resource_id" + renderMenu={ + + + {machineTypes.length ? ( + <> + {machineTypes.map(item => { + return ( + + {item.label?.toUpperCase()} + + + {getString('cde.cpu')}: {item.cpu?.toUpperCase()} + + + {getString('cde.memory')}: {item.memory?.toUpperCase()} + + + {getString('cde.disk')}: {item.disk?.toUpperCase()} + + + + } + onClick={() => { + onChange('infra_provider_resource_id', item.id || '') + }} + /> + ) + })} + + ) : ( + <> + {getString('cde.regionSelectWarning')} + + )} + + + } + /> + ) } diff --git a/web/src/cde/components/CreateGitspace/components/SelectRegion/SelectRegion.tsx b/web/src/cde/components/CreateGitspace/components/SelectRegion/SelectRegion.tsx index e4ffa4a2bf..34ed5e624f 100644 --- a/web/src/cde/components/CreateGitspace/components/SelectRegion/SelectRegion.tsx +++ b/web/src/cde/components/CreateGitspace/components/SelectRegion/SelectRegion.tsx @@ -15,7 +15,7 @@ */ import React, { useEffect, useState } from 'react' -import { Layout, Text } from '@harnessio/uicore' +import { Container, Layout, Text } from '@harnessio/uicore' import { Menu, MenuItem } from '@blueprintjs/core' import { Map } from 'iconoir-react' import { useFormikContext } from 'formik' @@ -67,51 +67,53 @@ export const SelectRegion = ({ options, disabled, defaultValue }: SelectRegionIn }, [defaultValue?.label?.toLowerCase()]) return ( - - - - {getString('cde.region')} - {metadata?.region || getString('cde.region')} - - - } - formikName="metadata.region" - errorMessage={ - ( - errors['metadata'] as unknown as { - [key: string]: string - } - )?.region as unknown as string - } - renderMenu={ - - - {options.map(({ label }) => { - return ( - {label.toUpperCase()}} - onClick={() => { - onChange('metadata.region', label.toLowerCase()) - onChange('infra_provider_resource_id', undefined) - }} - onMouseOver={(e: React.MouseEvent) => { - setRegionState(e.currentTarget.innerText) - }} - /> - ) - })} - - - - - - } - /> + + + + + {getString('cde.region')} + {metadata?.region || getString('cde.region')} + + + } + formikName="metadata.region" + errorMessage={ + ( + errors['metadata'] as unknown as { + [key: string]: string + } + )?.region as unknown as string + } + renderMenu={ + + + {options.map(({ label }) => { + return ( + {label.toUpperCase()}} + onClick={() => { + onChange('metadata.region', label.toLowerCase()) + onChange('infra_provider_resource_id', undefined) + }} + onMouseOver={(e: React.MouseEvent) => { + setRegionState(e.currentTarget.innerText) + }} + /> + ) + })} + + + + + + } + /> + ) } diff --git a/web/src/cde/components/CreateGitspace/components/SelectRepository/SelectRepository.tsx b/web/src/cde/components/CreateGitspace/components/SelectRepository/SelectRepository.tsx index 6c586437d4..aa49303985 100644 --- a/web/src/cde/components/CreateGitspace/components/SelectRepository/SelectRepository.tsx +++ b/web/src/cde/components/CreateGitspace/components/SelectRepository/SelectRepository.tsx @@ -149,53 +149,55 @@ export const SelectRepository = ({ disabled }: { disabled?: boolean }) => { ) return ( - } - icon={'code'} - errorMessage={errors.code_repo_url} - formikName="code_repo_url" - tooltipProps={{ - onClose: () => { - setError(undefined) - setRepoMetadata(undefined) + + } + icon={'code'} + errorMessage={errors.code_repo_url} + formikName="code_repo_url" + tooltipProps={{ + onClose: () => { + setError(undefined) + setRepoMetadata(undefined) + } + }} + disabled={disabled} + renderMenu={ + + + {getString('cde.repository.pasteRepo')} + + {getString('cde.repository.pasterRepoSubtext')} + + + { + const target = event.target as HTMLInputElement + await onChange(target.value) + }} + /> + {error && {error}} + {Boolean(repoMetadata) && ( + + )} + + {getString('cde.or')} + + {getString('cde.noRepo')} {getString('cde.createRepo')} + + + } - }} - disabled={disabled} - renderMenu={ - - - {getString('cde.repository.pasteRepo')} - - {getString('cde.repository.pasterRepoSubtext')} - - - { - const target = event.target as HTMLInputElement - await onChange(target.value) - }} - /> - {error && {error}} - {Boolean(repoMetadata) && ( - - )} - - {getString('cde.or')} - - {getString('cde.noRepo')} {getString('cde.createRepo')} - - - - } - /> + /> + ) }