mirror of
https://github.com/portainer/portainer.git
synced 2025-07-23 07:19:41 +02:00
Some checks are pending
ci / build_images (map[arch:amd64 platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
ci / build_images (map[arch:arm platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:arm64 platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:ppc64le platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:s390x platform:linux version:]) (push) Waiting to run
ci / build_manifests (push) Blocked by required conditions
/ triage (push) Waiting to run
Lint / Run linters (push) Waiting to run
Test / test-client (push) Waiting to run
Test / test-server (map[arch:amd64 platform:linux]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
Test / test-server (map[arch:arm64 platform:linux]) (push) Waiting to run
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
import { truncate } from '@/portainer/filters/filters';
|
|
import { useVolumes } from '@/react/docker/volumes/queries/useVolumes';
|
|
import { useEnvironmentId } from '@/react/hooks/useEnvironmentId';
|
|
|
|
import { Select } from '@@/form-components/ReactSelect';
|
|
|
|
export function VolumeSelector({
|
|
value,
|
|
onChange,
|
|
inputId,
|
|
}: {
|
|
value: string;
|
|
onChange: (value?: string) => void;
|
|
inputId?: string;
|
|
}) {
|
|
const environmentId = useEnvironmentId();
|
|
const volumesQuery = useVolumes(environmentId, {
|
|
select(volumes) {
|
|
return volumes.sort((vol1, vol2) => vol1.Name.localeCompare(vol2.Name));
|
|
},
|
|
});
|
|
|
|
if (!volumesQuery.data) {
|
|
return null;
|
|
}
|
|
|
|
const volumes = volumesQuery.data;
|
|
|
|
const selectedValue = volumes.find((vol) => vol.Name === value);
|
|
|
|
return (
|
|
<Select
|
|
placeholder="Select a volume"
|
|
options={volumes}
|
|
getOptionLabel={(vol) =>
|
|
`${truncate(vol.Name, 30)} - ${truncate(vol.Driver, 30)}`
|
|
}
|
|
getOptionValue={(vol) => vol.Name}
|
|
isMulti={false}
|
|
value={selectedValue}
|
|
onChange={(vol) => onChange(vol?.Name)}
|
|
inputId={inputId}
|
|
data-cy="docker-containers-volume-selector"
|
|
/>
|
|
);
|
|
}
|