import { useState } from 'react'; import { Registry } from '@/react/portainer/registries/types'; import { Modal, OnSubmit, openModal } from '@@/modals'; import { Button } from '@@/buttons'; import { PortainerSelect } from '@@/form-components/PortainerSelect'; interface Props { registries: Registry[]; onSubmit: OnSubmit; defaultValue: Registry['Id']; } function RegistrySelectPrompt({ onSubmit, defaultValue, registries }: Props) { const title = 'Which registry do you want to use?'; const [registryId, setRegistryId] = useState(defaultValue); const options = registries2Options(registries); return ( onSubmit()} aria-label={title}> ); } export function selectRegistry( registries: Registry[], defaultValue: Registry['Id'] ) { return openModal(RegistrySelectPrompt, { registries, defaultValue, }); } function registries2Options(registries: Registry[]) { return registries.map((r) => ({ label: r.Name, value: r.Id, })); }