Skip to content

Commit 55f0f03

Browse files
refactor(web): consolidate setup wizards into shared components
1 parent 5e6cc2b commit 55f0f03

7 files changed

Lines changed: 690 additions & 771 deletions

File tree

‎apps/web/src/components/GitActionsControl.tsx‎

Lines changed: 318 additions & 377 deletions
Large diffs are not rendered by default.

‎apps/web/src/components/cloud/ConnectOnboardingDialog.tsx‎

Lines changed: 51 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,10 @@ import { useEnvironments, usePrimaryEnvironment } from "~/state/environments";
1515
import { CloudEnvironmentConnectRows } from "./CloudEnvironmentConnectList";
1616
import { Button } from "../ui/button";
1717
import { Checkbox } from "../ui/checkbox";
18-
import {
19-
Dialog,
20-
DialogDescription,
21-
DialogFooter,
22-
DialogHeader,
23-
DialogPanel,
24-
DialogPopup,
25-
DialogTitle,
26-
} from "../ui/dialog";
18+
import { Dialog } from "../ui/dialog";
2719
import { Switch } from "../ui/switch";
2820
import { toastManager } from "../ui/toast";
29-
import { WizardSteps } from "../ui/wizard-steps";
21+
import { WizardSteps, WizardPopup, WizardHeader, WizardPanel, WizardFooter } from "../ui/wizard";
3022

3123
/**
3224
* Post-sign-in onboarding wizard for T3 Connect. Opens on every in-session
@@ -216,23 +208,29 @@ function ConfiguredConnectOnboardingDialog() {
216208
if (!open && !isApplying) complete();
217209
}}
218210
>
219-
<DialogPopup className="max-w-xl">
220-
<DialogHeader>
221-
<DialogTitle>Set up T3 Connect</DialogTitle>
222-
<DialogDescription>
223-
Mesh your devices together — publish this environment and connect the rest, all in one
224-
place.
225-
</DialogDescription>
211+
<WizardPopup>
212+
<WizardHeader
213+
title="Set up T3 Connect"
214+
description={
215+
<>
216+
Mesh your devices together — publish this environment and connect the rest, all in one
217+
place.
218+
</>
219+
}
220+
>
226221
{steps.length > 1 ? (
227222
<WizardSteps
228-
steps={steps.map((id) => ({ id, label: STEP_LABELS[id] }))}
229-
currentStep={step}
230-
disabled={isApplying}
231-
onStepSelect={setStep}
223+
steps={steps.map((id) => STEP_LABELS[id])}
224+
currentStep={steps.indexOf(step)}
225+
isStepDisabled={() => isApplying}
226+
onStepChange={(index) => {
227+
const next = steps[index];
228+
if (next) setStep(next);
229+
}}
232230
/>
233231
) : null}
234-
</DialogHeader>
235-
<DialogPanel>
232+
</WizardHeader>
233+
<WizardPanel>
236234
{step === "publish" ? (
237235
<PublishStep
238236
exposeEnvironment={exposeEnvironment}
@@ -245,38 +243,37 @@ function ConfiguredConnectOnboardingDialog() {
245243
) : (
246244
<DevicesStep />
247245
)}
248-
</DialogPanel>
249-
<DialogFooter variant="bare" className="sm:justify-between">
250-
<label className="flex cursor-pointer items-center gap-2 self-start text-xs text-muted-foreground sm:self-center">
251-
<Checkbox
252-
checked={dontShowAgain}
253-
onCheckedChange={(checked) => setDontShowAgain(checked === true)}
254-
/>
255-
Don&apos;t show this again
256-
</label>
257-
<div className="flex flex-col-reverse gap-2 sm:flex-row">
258-
{step === "publish" ? (
259-
<>
260-
<Button variant="ghost" disabled={isApplying} onClick={() => setStep("devices")}>
261-
Not now
262-
</Button>
263-
<Button
264-
disabled={
265-
isApplying || (controller.linkState.isPending && linkStateData === null)
266-
}
267-
onClick={() => void applyPublishSelection()}
268-
>
269-
{isApplying ? "Enabling…" : "Continue"}
270-
</Button>
271-
</>
272-
) : (
273-
<Button disabled={isApplying} onClick={complete}>
274-
Done
246+
</WizardPanel>
247+
<WizardFooter
248+
leading={
249+
<label className="flex cursor-pointer items-center gap-2 self-start text-xs text-muted-foreground sm:self-center">
250+
<Checkbox
251+
checked={dontShowAgain}
252+
onCheckedChange={(checked) => setDontShowAgain(checked === true)}
253+
/>
254+
Don&apos;t show this again
255+
</label>
256+
}
257+
>
258+
{step === "publish" ? (
259+
<>
260+
<Button variant="ghost" disabled={isApplying} onClick={() => setStep("devices")}>
261+
Not now
275262
</Button>
276-
)}
277-
</div>
278-
</DialogFooter>
279-
</DialogPopup>
263+
<Button
264+
disabled={isApplying || (controller.linkState.isPending && linkStateData === null)}
265+
onClick={() => void applyPublishSelection()}
266+
>
267+
{isApplying ? "Enabling…" : "Continue"}
268+
</Button>
269+
</>
270+
) : (
271+
<Button disabled={isApplying} onClick={complete}>
272+
Done
273+
</Button>
274+
)}
275+
</WizardFooter>
276+
</WizardPopup>
280277
</Dialog>
281278
);
282279
}

‎apps/web/src/components/onboarding/WelcomeWizard.tsx‎

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ import { Input } from "../ui/input";
7171
import { Tooltip, TooltipTrigger, TooltipPopup } from "../ui/tooltip";
7272
import { ScrollArea } from "../ui/scroll-area";
7373
import { Spinner } from "../ui/spinner";
74-
import { WizardPanel, WizardSteps } from "../ui/wizard";
75-
import { Dialog, DialogHeader, DialogPopup, DialogTitle } from "../ui/dialog";
74+
import { WizardPanel, WizardSteps, WizardPopup, WizardHeader } from "../ui/wizard";
75+
import { Dialog } from "../ui/dialog";
7676
import { toastManager } from "../ui/toast";
7777
import { cn } from "../../lib/utils";
7878
import { formatRelativeTime } from "../../timestampFormat";
@@ -183,71 +183,71 @@ export function WelcomeWizard({
183183

184184
return (
185185
<Dialog open disablePointerDismissal onOpenChange={(_, event) => event.cancel()}>
186-
<DialogPopup
187-
className="max-w-xl overflow-x-hidden overflow-y-auto"
186+
<WizardPopup
188187
bottomStickOnMobile={false}
189188
showCloseButton={false}
190189
initialFocus={() => document.getElementById("onboarding-pairing-url") ?? true}
191190
>
192-
<DialogTitle className="sr-only">Set up T3 Code</DialogTitle>
193-
<div className="flex min-h-0 flex-col">
194-
<DialogHeader className="gap-4">
191+
<WizardHeader
192+
title="Set up T3 Code"
193+
identity={
195194
<div className="flex items-baseline gap-1.5" role="img" aria-label="T3 Code">
196195
<T3Wordmark className="h-4 w-auto shrink-0" aria-hidden />
197196
<span className="text-[1.4rem] font-medium tracking-tight text-muted-foreground">
198197
Code
199198
</span>
200199
</div>
201-
<WizardSteps
202-
steps={ONBOARDING_STAGES}
203-
currentStep={stageIndex}
204-
isStepDisabled={(index) => isImporting || index >= stageIndex}
205-
onStepChange={(index) => {
206-
if (isImporting || index > stageIndex) return;
207-
setStep(index === 0 ? "connection" : "agents");
200+
}
201+
>
202+
<WizardSteps
203+
steps={ONBOARDING_STAGES}
204+
currentStep={stageIndex}
205+
isStepDisabled={(index) => isImporting || index >= stageIndex}
206+
onStepChange={(index) => {
207+
if (isImporting || index > stageIndex) return;
208+
setStep(index === 0 ? "connection" : "agents");
209+
}}
210+
/>
211+
</WizardHeader>
212+
213+
<WizardPanel holdHeight={isLoadingProjects}>
214+
{step === "connection" ? (
215+
<ConnectionStep
216+
expandPairingInitially={!localAvailable && !hasCloudPublicConfig()}
217+
selectedIds={selectedIds}
218+
autoSelectedComputers={autoSelectedComputers.current}
219+
onSelectionChange={setSelection}
220+
onToggleEnvironment={(environmentId, checked) =>
221+
setSelection((current) => {
222+
const next = new Set(current ?? selectedIds);
223+
if (checked) next.add(environmentId);
224+
else next.delete(environmentId);
225+
return next;
226+
})
227+
}
228+
onContinue={() =>
229+
startSetup(
230+
environments
231+
.filter((environment) => selectedIds.has(environment.environmentId))
232+
.map((environment) => environment.environmentId),
233+
)
234+
}
235+
onPaired={(environmentId) => {
236+
setSelection(new Set([...selectedIds, environmentId]));
208237
}}
209238
/>
210-
</DialogHeader>
211-
212-
<WizardPanel className="min-w-0" holdHeight={isLoadingProjects}>
213-
{step === "connection" ? (
214-
<ConnectionStep
215-
expandPairingInitially={!localAvailable && !hasCloudPublicConfig()}
216-
selectedIds={selectedIds}
217-
autoSelectedComputers={autoSelectedComputers.current}
218-
onSelectionChange={setSelection}
219-
onToggleEnvironment={(environmentId, checked) =>
220-
setSelection((current) => {
221-
const next = new Set(current ?? selectedIds);
222-
if (checked) next.add(environmentId);
223-
else next.delete(environmentId);
224-
return next;
225-
})
226-
}
227-
onContinue={() =>
228-
startSetup(
229-
environments
230-
.filter((environment) => selectedIds.has(environment.environmentId))
231-
.map((environment) => environment.environmentId),
232-
)
233-
}
234-
onPaired={(environmentId) => {
235-
setSelection(new Set([...selectedIds, environmentId]));
236-
}}
237-
/>
238-
) : step === "agents" ? (
239-
<AgentsStep environmentIds={setupIds} onContinue={() => setStep("import")} />
240-
) : (
241-
<ImportStep
242-
scans={scans}
243-
isImporting={isImporting}
244-
setIsImporting={setIsImporting}
245-
onDone={finish}
246-
/>
247-
)}
248-
</WizardPanel>
249-
</div>
250-
</DialogPopup>
239+
) : step === "agents" ? (
240+
<AgentsStep environmentIds={setupIds} onContinue={() => setStep("import")} />
241+
) : (
242+
<ImportStep
243+
scans={scans}
244+
isImporting={isImporting}
245+
setIsImporting={setIsImporting}
246+
onDone={finish}
247+
/>
248+
)}
249+
</WizardPanel>
250+
</WizardPopup>
251251
</Dialog>
252252
);
253253
}

0 commit comments

Comments
 (0)