Skip to content

Commit

Permalink
add deploy local steps
Browse files Browse the repository at this point in the history
  • Loading branch information
jsladerman committed Aug 28, 2024
1 parent 3d6d032 commit 1501e6b
Show file tree
Hide file tree
Showing 7 changed files with 158 additions and 45 deletions.
29 changes: 22 additions & 7 deletions www/src/components/create-cluster/CreateCluster.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,30 @@ export function CreateCluster() {
const [curStep, setCurStep] = useState<CreateClusterStepKey>(
CreateClusterStepKey.HostingOptions
)
const [hostingOption, setHostingOption] = useState<'local' | 'cloud'>('cloud')
const [hostingOption, setHostingOption] = useState<'local' | 'cloud'>('local')
const [finishEnabled, setFinishEnabled] = useState(false)
const steps = hostingOption === 'local' ? localSteps : cloudSteps
const curStepIndex = steps.findIndex((step) => step.key === curStep)

const context = useMemo(
() => ({
curStep,
setCurStep,
hostingOption,
setHostingOption,
finishEnabled,
setFinishEnabled,
}),
[
curStep,
setCurStep,
hostingOption,
setHostingOption,
finishEnabled,
setFinishEnabled,
]
)

return (
<MainWrapperSC>
<SidebarWrapperSC>
Expand Down Expand Up @@ -60,12 +80,7 @@ export function CreateCluster() {
Contact sales
</Button>
</ContentHeaderSC>
<CreateClusterContext.Provider
value={useMemo(
() => ({ curStep, setCurStep, hostingOption, setHostingOption }),
[curStep, setCurStep, hostingOption, setHostingOption]
)}
>
<CreateClusterContext.Provider value={context}>
<OnboardingCard title={steps[curStepIndex]?.stepTitle}>
{steps[curStepIndex]?.component}
<CreateClusterActions />
Expand Down
16 changes: 14 additions & 2 deletions www/src/components/create-cluster/CreateClusterActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@ import {

export function CreateClusterActions() {
const theme = useTheme()
const { curStep, setCurStep, hostingOption } = useCreateClusterContext()
const { curStep, setCurStep, hostingOption, finishEnabled } =
useCreateClusterContext()

const steps = hostingOption === 'local' ? localSteps : cloudSteps
const curStepIndex = steps.findIndex((step) => step.key === curStep)
const prevStep = steps[curStepIndex - 1]?.key
const nextStep = steps[curStepIndex + 1]?.key

const handleFinish = () => {
// TODO
}

return (
<>
<Divider
Expand Down Expand Up @@ -45,8 +50,15 @@ export function CreateClusterActions() {
Back
</Button>
)}
{nextStep && (
{nextStep ? (
<Button onClick={() => setCurStep(nextStep)}>Continue</Button>
) : (
<Button
disabled={!finishEnabled}
onClick={handleFinish}
>
Finish
</Button>
)}
</Flex>
</Flex>
Expand Down
2 changes: 2 additions & 0 deletions www/src/components/create-cluster/CreateClusterWizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ type CreateClusterContextType = {
setHostingOption: (option: HostingOption) => void
curStep: CreateClusterStepKey
setCurStep: (step: CreateClusterStepKey) => void
finishEnabled: boolean
setFinishEnabled: (enabled: boolean) => void
}

export const CreateClusterContext = createContext<
Expand Down
66 changes: 65 additions & 1 deletion www/src/components/create-cluster/steps/DeployLocallyStep.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,67 @@
import { Callout, Checkbox, Codeline, Flex } from '@pluralsh/design-system'
import { CSSProp, useTheme } from 'styled-components'

import { useCreateClusterContext } from '../CreateClusterWizard'

export function DeployLocallyStep() {
return <div>DeployLocallyStep</div>
const theme = useTheme()
const { finishEnabled, setFinishEnabled } = useCreateClusterContext()

return (
<Flex
direction="column"
gap="xlarge"
>
<Callout title="This command may take 30 or more minutes to complete">
We recommend keeping this tab open and proceeding once your control
plane is deployed.
</Callout>
<Flex
direction="column"
gap="small"
>
<span css={theme.partials.text.body2}>
Now that you've installed the Plural CLI, all that's needed is to run
one command. This will provide everything you need to run your control
plane.
</span>
<Codeline css={{ background: theme.colors['fill-two'] }}>
plural up
</Codeline>
<span css={theme.partials.text.body2}>
For a full guide on properly deploying your cloud instance and cluster
with `plural up`,{' '}
<a
css={theme.partials.text.inlineLink}
href="https://docs.plural.sh/"
target="_blank"
rel="noreferrer"
>
visit our documentation.
</a>
</span>
</Flex>
<Flex
direction="column"
gap="small"
css={{ marginTop: theme.spacing.medium }}
>
<Checkbox
small
checked={finishEnabled}
onChange={(e) => setFinishEnabled(e.target.checked)}
css={
{
'& .label': {
userSelect: 'none',
},
} as CSSProp
}
>
The `plural up` command has finished running.
<span css={{ color: theme.colors['text-danger'] }}>*</span>
</Checkbox>
</Flex>
</Flex>
)
}
19 changes: 3 additions & 16 deletions www/src/components/create-cluster/steps/HostingOptionsStep.tsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,24 @@
import { CloudIcon, Flex } from '@pluralsh/design-system'
import { CloudIcon, ConsoleIcon, Flex } from '@pluralsh/design-system'
import { CloudOption } from 'components/shell/onboarding/sections/cloud/CloudOption'

import { useTheme } from 'styled-components'

import { useCreateClusterContext } from '../CreateClusterWizard'

export function HostingOptionsStep() {
const theme = useTheme()
const { hostingOption, setHostingOption } = useCreateClusterContext()

return (
<Flex gap="large">
<CloudOption
selected={hostingOption === 'local'}
onClick={() => setHostingOption('local')}
icon={
<CloudIcon
size={40}
color={theme.colors['text-light']}
/>
}
icon={<CloudIcon size={40} />}
header="Deploy Yourself"
description="Host your control plane in your own cloud."
/>
<CloudOption
selected={hostingOption === 'cloud'}
onClick={() => setHostingOption('cloud')}
icon={
<CloudIcon
size={40}
color={theme.colors['text-light']}
/>
}
icon={<ConsoleIcon size={40} />}
header="Use Plural Cloud"
description="Host your control plane in a Plural Cloud instance."
/>
Expand Down
22 changes: 21 additions & 1 deletion www/src/components/create-cluster/steps/InstallCliStep.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
import { Callout, Flex } from '@pluralsh/design-system'
import { CliInstallationBaseInfo } from 'components/shell/onboarding/sections/cli/CLIInstallationStep'

import { useCreateClusterContext } from '../CreateClusterWizard'

export function InstallCliStep() {
return <div>InstallCliStep</div>
const { hostingOption } = useCreateClusterContext()

return (
<Flex
direction="column"
gap="xlarge"
>
{hostingOption === 'cloud' && (
<Callout title="The next two steps are in your local terminal">
This will help to setup and properly configure the control plane and
Plural Cloud instance with your local environment.
</Callout>
)}
<CliInstallationBaseInfo />
</Flex>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
TabList,
TabPanel,
} from '@pluralsh/design-system'
import { useTheme } from 'styled-components'

const TAB_MAC = 'TAB_MAC'
const TAB_CURL = 'TAB_CURL'
Expand Down Expand Up @@ -43,6 +44,29 @@ const DIRECTORY = [
]

function CliInstallation({ onBack, onNext }) {
return (
<>
<CliInstallationBaseInfo />
<Flex
gap="medium"
justify="space-between"
borderTop="1px solid border"
paddingTop="large"
marginTop="xlarge"
>
<Button
secondary
onClick={onBack}
>
Back
</Button>
<Button onClick={onNext}>Continue</Button>
</Flex>
</>
)
}
export function CliInstallationBaseInfo() {
const theme = useTheme()
const [tab, setTab] = useState(TAB_MAC)
const tabStateRef = useRef<any>(null)
const currentTab = useMemo(() => DIRECTORY.find((t) => t.key === tab), [tab])
Expand Down Expand Up @@ -110,9 +134,14 @@ function CliInstallation({ onBack, onNext }) {
<>
<Div marginTop="small">
{tab === TAB_MAC ? (
<Codeline>{currentTab?.command}</Codeline>
<Codeline css={{ background: theme.colors['fill-two'] }}>
{currentTab?.command}
</Codeline>
) : (
<Code onSelectedTabChange={() => {}}>
<Code
css={{ background: theme.colors['fill-two'] }}
onSelectedTabChange={() => {}}
>
{currentTab?.command || ''}
</Code>
)}
Expand Down Expand Up @@ -184,22 +213,6 @@ function CliInstallation({ onBack, onNext }) {
</>
)}
</TabPanel>

<Flex
gap="medium"
justify="space-between"
borderTop="1px solid border"
paddingTop="large"
marginTop="xlarge"
>
<Button
secondary
onClick={onBack}
>
Back
</Button>
<Button onClick={onNext}>Continue</Button>
</Flex>
</>
)
}
Expand Down

0 comments on commit 1501e6b

Please sign in to comment.