import { GroupBase } from 'react-select'; import { PortainerSelect, Option, } from '@/react/components/form-components/PortainerSelect'; import { useCurrentUser } from '@/react/hooks/useUser'; import { RegistryTypes } from '@/react/portainer/registries/types/registry'; import { FormControl } from '@@/form-components/FormControl'; import { Alert } from '@@/Alert'; import { Link } from '@@/Link'; import { TextTip } from '@@/Tip/TextTip'; export type RepoValue = { repoUrl?: string; // set for traditional https helm repos name?: string; type?: RegistryTypes; }; interface Props { selectedRegistry: RepoValue | null; onRegistryChange: (registry: RepoValue | null) => void; namespace?: string; placeholder?: string; 'data-cy'?: string; isRepoAvailable: boolean; isLoading: boolean; isError: boolean; repoOptions: GroupBase>[]; } export function HelmRegistrySelect({ selectedRegistry, onRegistryChange, namespace, placeholder = 'Select a repository', 'data-cy': dataCy = 'helm-registry-select', isRepoAvailable, isLoading, isError, repoOptions, }: Props) { const { isPureAdmin } = useCurrentUser(); return ( } > placeholder={placeholder} value={selectedRegistry ?? {}} options={repoOptions} isLoading={isLoading} onChange={onRegistryChange} isClearable bindToBody data-cy={dataCy} /> {isError && Unable to load registry options.} ); } function HelmChartSourceTooltip({ isPureAdmin }: { isPureAdmin: boolean }) { if (isPureAdmin) { return ( <>
); } // Non-admin return ; } function NoReposWarning({ hasNoRepos, isLoading, namespace, isPureAdmin, }: { hasNoRepos: boolean; isLoading: boolean; namespace?: string; isPureAdmin: boolean; }) { if (!hasNoRepos || isLoading || !namespace) { return null; } return ( There are no repositories available. ); } function CreateRepoMessage({ isPureAdmin }: { isPureAdmin: boolean }) { if (isPureAdmin) { return ( <>
); } // Non-admin return ; } function CreateUserRepoMessage() { return ( <> You can define repositories in the{' '} User settings - Helm repositories . ); } function CreateGlobalRepoMessage() { return ( <> You can also define repositories in the{' '} Portainer settings . ); }