Skip to content

Commit c1d7695

Browse files
committed
add restart to create cluster wizard
1 parent 97525f6 commit c1d7695

File tree

3 files changed

+44
-16
lines changed

3 files changed

+44
-16
lines changed

www/src/components/create-cluster/CreateCluster.tsx

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import {
22
Button,
3+
Flex,
4+
IconFrame,
5+
PencilIcon,
36
ReturnIcon,
47
SendMessageIcon,
58
Stepper,
@@ -67,9 +70,7 @@ export function CreateCluster() {
6770
const curStepIndex = steps.findIndex((step) => step.key === curStep)
6871

6972
const { data, error } = useConsoleInstanceQuery({
70-
variables: {
71-
id: consoleInstanceId ?? '',
72-
},
73+
variables: { id: consoleInstanceId ?? '' },
7374
skip: !consoleInstanceId,
7475
fetchPolicy: 'cache-and-network',
7576
pollInterval: 10_000,
@@ -114,18 +115,45 @@ export function CreateCluster() {
114115
]
115116
)
116117

118+
const showClearButton =
119+
cloudOption === 'cloud' &&
120+
(curStep === CreateClusterStepKey.InstallCli ||
121+
curStep === CreateClusterStepKey.Authentication)
122+
117123
return (
118124
<CreateClusterContext.Provider value={context}>
119125
<MainWrapperSC>
120126
<SidebarWrapperSC>
121-
<Button
122-
css={{ width: '100%' }}
123-
secondary
124-
startIcon={<ReturnIcon />}
125-
onClick={() => navigate('/overview/clusters/plural-cloud')}
127+
<Flex
128+
gap="small"
129+
width="100%"
126130
>
127-
Back home
128-
</Button>
131+
<Button
132+
css={{ flex: 1 }}
133+
secondary
134+
startIcon={<ReturnIcon />}
135+
onClick={() => navigate('/overview/clusters/plural-cloud')}
136+
>
137+
Back home
138+
</Button>
139+
{showClearButton && (
140+
<IconFrame
141+
clickable
142+
type="floating"
143+
size="large"
144+
icon={<PencilIcon css={{ width: 16 }} />}
145+
tooltip="Create a new instance (this one will continue provisioning)"
146+
onClick={() => {
147+
clearCreateClusterCache()
148+
setCurStep(CreateClusterStepKey.ChooseCloud)
149+
setCloudOption('cloud')
150+
setConsoleInstanceId(null)
151+
setContinueBtn(undefined)
152+
}}
153+
css={{ flexShrink: 0 }}
154+
/>
155+
)}
156+
</Flex>
129157
<Stepper
130158
vertical
131159
steps={steps}
@@ -163,7 +191,7 @@ export function CreateCluster() {
163191
)
164192
}
165193

166-
export function clearCreateClusterState() {
194+
export function clearCreateClusterCache() {
167195
localStorage.removeItem(`plural-${CUR_CREATE_CLUSTER_STEP_KEY}`)
168196
localStorage.removeItem(`plural-${CLOUD_OPTION_KEY}`)
169197
localStorage.removeItem(`plural-${HOSTING_OPTION_KEY}`)

www/src/components/create-cluster/CreateClusterActions.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
localSteps,
1414
useCreateClusterContext,
1515
} from './CreateClusterWizard'
16-
import { clearCreateClusterState } from './CreateCluster'
16+
import { clearCreateClusterCache } from './CreateCluster'
1717

1818
export const FINISHED_CONSOLE_INSTANCE_KEY = 'plural-finished-console-instance'
1919
export const FINISHED_LOCAL_CREATE_KEY = 'plural-finished-local-create'
@@ -51,7 +51,7 @@ export function CreateClusterActions() {
5151
if (cloudOption === 'local') {
5252
localStorage.setItem(FINISHED_LOCAL_CREATE_KEY, 'true')
5353
}
54-
clearCreateClusterState()
54+
clearCreateClusterCache()
5555
navigate(
5656
`/overview/clusters/${
5757
cloudOption === 'local' ? 'self-hosted' : 'plural-cloud'

www/src/components/overview/clusters/plural-cloud/DeleteInstance.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useTheme } from 'styled-components'
22

33
import { Button, Flex, Input, Modal } from '@pluralsh/design-system'
44
import {
5-
clearCreateClusterState,
5+
clearCreateClusterCache,
66
getUnfinishedConsoleInstanceId,
77
} from 'components/create-cluster/CreateCluster'
88
import { GqlError } from 'components/utils/Alert'
@@ -52,7 +52,7 @@ function DeleteInstance({
5252
variables: { id: instance.id },
5353
onCompleted: () => {
5454
if (instance.id === getUnfinishedConsoleInstanceId()) {
55-
clearCreateClusterState()
55+
clearCreateClusterCache()
5656
}
5757
onClose()
5858
refetch()
@@ -115,7 +115,7 @@ export function useDeleteUnfinishedInstance({
115115
const id = getUnfinishedConsoleInstanceId()
116116
const [mutation, { loading, error }] = useDeleteConsoleInstanceMutation()
117117
const triggerDelete = useCallback(() => {
118-
clearCreateClusterState()
118+
clearCreateClusterCache()
119119
onClear?.()
120120
if (id && id !== 'null' && id !== 'undefined') {
121121
mutation({ variables: { id } })

0 commit comments

Comments
 (0)