Skip to content

Commit 9d1ede0

Browse files
committed
cp dines
1 parent 38e5721 commit 9d1ede0

2 files changed

Lines changed: 32 additions & 39 deletions

File tree

src/commands/devbox/create.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ const CreateDevboxUI: React.FC<{
4444
return (
4545
<>
4646
<Banner />
47-
<Header title="Create Devbox" />
4847
{loading && <SpinnerComponent message="Creating..." />}
4948
{result && (
5049
<>

src/components/DevboxCreatePage.tsx

Lines changed: 32 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ interface DevboxCreatePageProps {
1616
}
1717

1818
type FormField =
19+
| 'create'
1920
| 'name'
2021
| 'architecture'
2122
| 'resource_size'
@@ -41,7 +42,7 @@ interface FormData {
4142
}
4243

4344
export const DevboxCreatePage: React.FC<DevboxCreatePageProps> = ({ onBack, onCreate }) => {
44-
const [currentField, setCurrentField] = React.useState<FormField>('name');
45+
const [currentField, setCurrentField] = React.useState<FormField>('create');
4546
const [formData, setFormData] = React.useState<FormData>({
4647
name: '',
4748
architecture: 'arm64',
@@ -63,14 +64,15 @@ export const DevboxCreatePage: React.FC<DevboxCreatePageProps> = ({ onBack, onCr
6364
const [result, setResult] = React.useState<any>(null);
6465
const [error, setError] = React.useState<Error | null>(null);
6566

66-
const baseFields: Array<{ key: FormField; label: string; type: 'text' | 'select' | 'metadata' }> = [
67+
const baseFields: Array<{ key: FormField; label: string; type: 'text' | 'select' | 'metadata' | 'action' }> = [
68+
{ key: 'create', label: 'Devbox Create', type: 'action' },
6769
{ key: 'name', label: 'Name', type: 'text' },
6870
{ key: 'architecture', label: 'Architecture', type: 'select' },
6971
{ key: 'resource_size', label: 'Resource Size', type: 'select' },
7072
];
7173

7274
// Add custom resource fields if CUSTOM_SIZE is selected
73-
const customFields: Array<{ key: FormField; label: string; type: 'text' | 'select' | 'metadata' }> =
75+
const customFields: Array<{ key: FormField; label: string; type: 'text' | 'select' | 'metadata' | 'action' }> =
7476
formData.resource_size === 'CUSTOM_SIZE'
7577
? [
7678
{ key: 'custom_cpu', label: 'CPU Cores (2-16, even)', type: 'text' },
@@ -79,7 +81,7 @@ export const DevboxCreatePage: React.FC<DevboxCreatePageProps> = ({ onBack, onCr
7981
]
8082
: [];
8183

82-
const remainingFields: Array<{ key: FormField; label: string; type: 'text' | 'select' | 'metadata' }> = [
84+
const remainingFields: Array<{ key: FormField; label: string; type: 'text' | 'select' | 'metadata' | 'action' }> = [
8385
{ key: 'keep_alive', label: 'Keep Alive (seconds)', type: 'text' },
8486
{ key: 'blueprint_id', label: 'Blueprint ID (optional)', type: 'text' },
8587
{ key: 'snapshot_id', label: 'Snapshot ID (optional)', type: 'text' },
@@ -135,6 +137,12 @@ export const DevboxCreatePage: React.FC<DevboxCreatePageProps> = ({ onBack, onCr
135137
return;
136138
}
137139

140+
// Handle Enter on create field
141+
if (currentField === 'create' && key.return) {
142+
handleCreate();
143+
return;
144+
}
145+
138146
// Handle metadata section
139147
if (inMetadataSection) {
140148
const metadataKeys = Object.keys(formData.metadata);
@@ -375,7 +383,6 @@ export const DevboxCreatePage: React.FC<DevboxCreatePageProps> = ({ onBack, onCr
375383
{ label: 'Devboxes' },
376384
{ label: 'Create', active: true }
377385
]} />
378-
<Header title="Create Devbox" />
379386
<SuccessMessage
380387
message="Devbox created successfully!"
381388
details={`ID: ${result.id}\nName: ${result.name || '(none)'}\nStatus: ${result.status}`}
@@ -397,7 +404,6 @@ export const DevboxCreatePage: React.FC<DevboxCreatePageProps> = ({ onBack, onCr
397404
{ label: 'Devboxes' },
398405
{ label: 'Create', active: true }
399406
]} />
400-
<Header title="Create Devbox" />
401407
<ErrorMessage message="Failed to create devbox" error={error} />
402408
<Box marginTop={1}>
403409
<Text color="gray" dimColor>
@@ -416,7 +422,6 @@ export const DevboxCreatePage: React.FC<DevboxCreatePageProps> = ({ onBack, onCr
416422
{ label: 'Devboxes' },
417423
{ label: 'Create', active: true }
418424
]} />
419-
<Header title="Create Devbox" />
420425
<SpinnerComponent message="Creating devbox..." />
421426
</>
422427
);
@@ -429,13 +434,27 @@ export const DevboxCreatePage: React.FC<DevboxCreatePageProps> = ({ onBack, onCr
429434
{ label: 'Devboxes' },
430435
{ label: 'Create', active: true }
431436
]} />
432-
<Header title="Create Devbox" />
433437

434438
<Box flexDirection="column" marginBottom={1}>
435439
{fields.map((field, index) => {
436440
const isActive = currentField === field.key;
437441
const fieldData = formData[field.key as keyof FormData];
438442

443+
if (field.type === 'action') {
444+
return (
445+
<Box key={field.key} marginBottom={0}>
446+
<Text color={isActive ? 'green' : 'gray'} bold={isActive}>
447+
{isActive ? figures.pointer : ' '} {field.label}
448+
</Text>
449+
{isActive && (
450+
<Text color="gray" dimColor>
451+
{' '}[Enter to create]
452+
</Text>
453+
)}
454+
</Box>
455+
);
456+
}
457+
439458
if (field.type === 'text') {
440459
return (
441460
<Box key={field.key} marginBottom={0}>
@@ -614,37 +633,12 @@ export const DevboxCreatePage: React.FC<DevboxCreatePageProps> = ({ onBack, onCr
614633
</Box>
615634
)}
616635

617-
<Box flexDirection="column" borderStyle="round" borderColor="green" paddingX={1} paddingY={0} marginTop={1}>
618-
<Text color="green" bold>{figures.info} Summary</Text>
619-
<Text dimColor>Name: {formData.name || '(auto-generated)'}</Text>
620-
<Text dimColor>Architecture: {formData.architecture}</Text>
621-
{formData.resource_size && <Text dimColor>Resources: {formData.resource_size}</Text>}
622-
{formData.resource_size === 'CUSTOM_SIZE' && formData.custom_cpu && (
623-
<Text dimColor> CPU: {formData.custom_cpu} cores</Text>
624-
)}
625-
{formData.resource_size === 'CUSTOM_SIZE' && formData.custom_memory && (
626-
<Text dimColor> Memory: {formData.custom_memory} GB</Text>
627-
)}
628-
{formData.resource_size === 'CUSTOM_SIZE' && formData.custom_disk && (
629-
<Text dimColor> Disk: {formData.custom_disk} GB</Text>
630-
)}
631-
<Text dimColor>Keep Alive: {formData.keep_alive}s ({Math.floor(parseInt(formData.keep_alive || '0') / 60)}m)</Text>
632-
{formData.blueprint_id && <Text dimColor>Blueprint: {formData.blueprint_id}</Text>}
633-
{formData.snapshot_id && <Text dimColor>Snapshot: {formData.snapshot_id}</Text>}
634-
<Text dimColor>Metadata: {Object.keys(formData.metadata).length} item(s)</Text>
635-
</Box>
636-
637636
{!inMetadataSection && (
638-
<>
639-
<Box borderStyle="single" borderColor="green" paddingX={1} paddingY={0} marginTop={1}>
640-
<Text color="green" bold>{figures.play} Press [Ctrl+S] to create this devbox</Text>
641-
</Box>
642-
<Box marginTop={1}>
643-
<Text color="gray" dimColor>
644-
{figures.arrowUp}{figures.arrowDown} Navigate • [Ctrl+S] Create • [q] Cancel
645-
</Text>
646-
</Box>
647-
</>
637+
<Box marginTop={1}>
638+
<Text color="gray" dimColor>
639+
{figures.arrowUp}{figures.arrowDown} Navigate • [Enter] Create • [q] Cancel
640+
</Text>
641+
</Box>
648642
)}
649643
</>
650644
);

0 commit comments

Comments
 (0)