Skip to content

Commit

Permalink
feat(web): Add version combobox for docker service in Ansible Template
Browse files Browse the repository at this point in the history
  • Loading branch information
MiladSadeghi committed Dec 4, 2024
1 parent 3b9d06e commit b4745fe
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
7 changes: 7 additions & 0 deletions web/src/pages/ansible/docker/data/select-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@ export const OSOptions = [
label: 'Ubuntu',
},
];

export const versionOptions = [
{
label: 'Latest',
value: 'latest',
},
];
19 changes: 17 additions & 2 deletions web/src/pages/ansible/docker/docker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@ import { FormWrapper } from '@/components/form/form-wrapper';
import { FormInput } from '@/components/form/form-input';
import HostsField from './components/hosts-fields';
import { FormSelect } from '@/components/form/form-select';
import { OSOptions } from './data/select-options';
import { OSOptions, versionOptions } from './data/select-options';

const DockerAnsible: FC = () => {
const defaultValues = {
ansible_user: '',
os: { label: 'Ubuntu', value: 'ubuntu' },
hosts: [{ value: '' }],
version: {
label: 'Latest',
value: 'latest',
},
};

const methods = useForm<DockerAnsible>({
Expand All @@ -49,6 +53,7 @@ const DockerAnsible: FC = () => {
...data,
hosts: data.hosts.map((host) => host.value),
os: data.os.value,
version: data.version.value,
};

await dockerAnsibleMutate(body);
Expand Down Expand Up @@ -94,7 +99,17 @@ const DockerAnsible: FC = () => {
options={OSOptions}
/>
</div>
<HostsField />
<div className="mb-4">
<HostsField />
</div>
<div className="mb-4">
<FormSelect
name={`version`}
label="Version"
placeholder="Select..."
options={versionOptions}
/>
</div>
<button
type="submit"
disabled={dockerAnsiblePending}
Expand Down
5 changes: 5 additions & 0 deletions web/src/pages/ansible/docker/docker.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface DockerAnsibleBody {
ansible_port: number;
os: string;
hosts: string[];
version: string;
}

export interface dockerTemplateValidationError {
Expand Down Expand Up @@ -38,6 +39,10 @@ export const dockerAnsibleSchema = zod.object({
}),
)
.min(1),
version: zod.object({
label: zod.string(),
value: zod.string(),
}),
});

export type DockerAnsible = zod.infer<typeof dockerAnsibleSchema>;

0 comments on commit b4745fe

Please sign in to comment.