-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
configure cloud instance step progress
- Loading branch information
1 parent
1501e6b
commit d91b97f
Showing
4 changed files
with
138 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 124 additions & 1 deletion
125
www/src/components/create-cluster/steps/ConfigureCloudInstanceStep.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,126 @@ | ||
import { | ||
Button, | ||
Callout, | ||
Flex, | ||
FormField, | ||
Input, | ||
ListBoxItem, | ||
Select, | ||
} from '@pluralsh/design-system' | ||
import { CloudProvider, ConsoleSize } from 'generated/graphql' | ||
import { useLayoutEffect, useState } from 'react' | ||
import styled, { useTheme } from 'styled-components' | ||
|
||
import { | ||
CreateClusterStepKey, | ||
useCreateClusterContext, | ||
} from '../CreateClusterWizard' | ||
|
||
export function ConfigureCloudInstanceStep() { | ||
return <div>ConfigureCloudInstanceStep</div> | ||
const theme = useTheme() | ||
const { setCurStep, setContinueBtn } = useCreateClusterContext() | ||
|
||
const [clusterName, setClusterName] = useState('') | ||
const [clusterSize, setClusterSize] = useState<ConsoleSize>(ConsoleSize.Small) | ||
const [cloudProvider, setCloudProvider] = useState<CloudProvider>( | ||
CloudProvider.Aws | ||
) | ||
const [region, setRegion] = useState<string | undefined>(regions[0]) | ||
|
||
const canSubmit = !!( | ||
clusterName && | ||
clusterSize && | ||
cloudProvider && | ||
(cloudProvider === CloudProvider.Aws ? region : true) | ||
) | ||
|
||
// using layout effect to avoid flickering | ||
useLayoutEffect(() => { | ||
setContinueBtn( | ||
<Button | ||
key="create" | ||
disabled={!canSubmit} | ||
onClick={() => setCurStep(CreateClusterStepKey.InstallCli)} | ||
> | ||
Continue | ||
</Button> | ||
) | ||
|
||
return () => { | ||
setContinueBtn(undefined) | ||
} | ||
}, [canSubmit, setContinueBtn, setCurStep]) | ||
|
||
return ( | ||
<Flex | ||
flexDirection="column" | ||
gap="medium" | ||
> | ||
<Callout | ||
css={{ marginBottom: theme.spacing.medium }} | ||
title="Your Console may take a few minutes to deploy." | ||
> | ||
After completing this step it may take a few minutes for your Console to | ||
deploy. It will run in the background as you proceed. | ||
</Callout> | ||
<FormFieldSC label="Cluster name"> | ||
<Input | ||
placeholder="Enter cluster name" | ||
value={clusterName} | ||
onChange={(e) => setClusterName(e.target.value)} | ||
/> | ||
</FormFieldSC> | ||
<FormFieldSC label="Cluster size"> | ||
<Select | ||
selectedKey={clusterSize} | ||
onSelectionChange={(size) => setClusterSize(size as ConsoleSize)} | ||
> | ||
{Object.values(ConsoleSize) | ||
.reverse() | ||
.map((value) => ( | ||
<ListBoxItem | ||
key={value} | ||
label={value} | ||
/> | ||
))} | ||
</Select> | ||
</FormFieldSC> | ||
<FormFieldSC label="Cloud"> | ||
<Select | ||
selectedKey={cloudProvider} | ||
onSelectionChange={(cloudProvider) => | ||
setCloudProvider(cloudProvider as CloudProvider) | ||
} | ||
> | ||
{Object.values(CloudProvider).map((value) => ( | ||
<ListBoxItem | ||
key={value} | ||
label={value} | ||
/> | ||
))} | ||
</Select> | ||
</FormFieldSC> | ||
{cloudProvider === CloudProvider.Aws && ( | ||
<FormFieldSC label="Region"> | ||
<Select | ||
selectedKey={region} | ||
onSelectionChange={(region) => setRegion(region as string)} | ||
> | ||
{regions.map((region) => ( | ||
<ListBoxItem | ||
key={region} | ||
label={region} | ||
/> | ||
))} | ||
</Select> | ||
</FormFieldSC> | ||
)} | ||
</Flex> | ||
) | ||
} | ||
|
||
const FormFieldSC = styled(FormField)(({ theme }) => ({ | ||
color: theme.colors.text, | ||
})) | ||
|
||
const regions = ['us-east-1'] |