Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion app/components/form/fields/FileField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export function FileField<
required = false,
accept,
description,
disabled,
}: {
id: string
name: TName
Expand All @@ -34,6 +35,7 @@ export function FileField<
required?: boolean
accept?: string
description?: string | React.ReactNode
disabled?: boolean
}) {
return (
<Controller
Expand All @@ -55,7 +57,14 @@ export function FileField<
<TextInputHint id={`${id}-help-text`}>{description}</TextInputHint>
)}
</div>
<FileInput id={id} className="mt-2" accept={accept} {...rest} error={!!error} />
<FileInput
id={id}
className="mt-2"
accept={accept}
disabled={disabled}
{...rest}
error={!!error}
/>
<ErrorMessage error={error} label={label} />
</div>
)}
Expand Down
17 changes: 15 additions & 2 deletions app/components/form/fields/SshKeysField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@ const CloudInitMessage = () => (
/>
)

export function SshKeysField({ control }: { control: Control<InstanceCreateInput> }) {
export function SshKeysField({
control,
isSubmitting,
}: {
control: Control<InstanceCreateInput>
isSubmitting: boolean
}) {
const keys = usePrefetchedApiQuery('currentUserSshKeyList', {}).data?.items || []
const [showAddSshKey, setShowAddSshKey] = useState(false)

Expand Down Expand Up @@ -85,6 +91,7 @@ export function SshKeysField({ control }: { control: Control<InstanceCreateInput
control={control}
value={key.id}
key={key.id}
disabled={isSubmitting}
>
{key.name}
</CheckboxField>
Expand All @@ -101,12 +108,18 @@ export function SshKeysField({ control }: { control: Control<InstanceCreateInput
onChange={() =>
onChange(value.length < keys.length ? keys.map((key) => key.id) : [])
}
disabled={isSubmitting}
>
<span className="select-none">Select all</span>
</Checkbox>

<div className="space-x-3">
<Button variant="ghost" size="sm" onClick={() => setShowAddSshKey(true)}>
<Button
variant="ghost"
size="sm"
onClick={() => setShowAddSshKey(true)}
disabled={isSubmitting}
>
Add SSH Key
</Button>
</div>
Expand Down
7 changes: 4 additions & 3 deletions app/forms/instance-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -276,13 +276,13 @@ export function CreateInstanceForm() {
</Tabs.Content>

<Tabs.Content value="highCPU">
<RadioFieldDyn name="presetId" label="" control={control}>
<RadioFieldDyn name="presetId" label="" control={control} disabled={isSubmitting}>
{renderLargeRadioCards('highCPU')}
</RadioFieldDyn>
</Tabs.Content>

<Tabs.Content value="highMemory">
<RadioFieldDyn name="presetId" label="" control={control}>
<RadioFieldDyn name="presetId" label="" control={control} disabled={isSubmitting}>
{renderLargeRadioCards('highMemory')}
</RadioFieldDyn>
</Tabs.Content>
Expand Down Expand Up @@ -419,7 +419,7 @@ export function CreateInstanceForm() {
<FormDivider />
<Form.Heading id="authentication">Authentication</Form.Heading>

<SshKeysField control={control} />
<SshKeysField control={control} isSubmitting={isSubmitting} />

<FormDivider />
<Form.Heading id="advanced">Advanced</Form.Heading>
Expand Down Expand Up @@ -478,6 +478,7 @@ const AdvancedAccordion = ({
name="userData"
label="User Data"
control={control}
disabled={isSubmitting}
/>
</AccordionItem>
</Accordion.Root>
Expand Down