import _ from 'lodash'; import { ArrowRight } from 'lucide-react'; import { Icon } from '@@/Icon'; import { ButtonSelector } from '@@/form-components/ButtonSelector/ButtonSelector'; import { FormError } from '@@/form-components/FormError'; import { InputGroup } from '@@/form-components/InputGroup'; import { ItemProps } from '@@/form-components/InputList'; import { InputLabeled } from '@@/form-components/Input/InputLabeled'; import { Volume } from './types'; import { useInputContext } from './context'; import { VolumeSelector } from './VolumeSelector'; export function Item({ item: volume, onChange, error, index, }: ItemProps) { const allowBindMounts = useInputContext(); return (
setValue({ containerPath: e.target.value })} size="small" className="flex-1" id={`container-path-${index}`} /> {allowBindMounts && ( { onChange({ ...volume, type, name: '' }); }} options={[ { value: 'volume', label: 'Volume' }, { value: 'bind', label: 'Bind' }, ]} aria-label="Volume type" /> )}
{volume.type === 'volume' && ( volume setValue({ name })} inputId={`volume-${index}`} /> )} {volume.type === 'bind' && ( setValue({ name: e.target.value })} id={`host-path-${index}`} /> )} aria-label="ReadWrite" value={volume.readOnly} onChange={(readOnly) => setValue({ readOnly })} options={[ { value: false, label: 'Writable' }, { value: true, label: 'Read-only' }, ]} />
{error && {_.first(Object.values(error))}}
); function setValue(partial: Partial) { onChange({ ...volume, ...partial }); } }