feat(gitops): add autocomplete to ref selector [EE-6245] (#10935)

pull/11031/head
Chaim Lev-Ari 2024-01-28 15:55:10 +02:00 committed by GitHub
parent 2826a4ce39
commit 1561814fe5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 4 deletions

View File

@ -1,7 +1,7 @@
import { StackId } from '@/react/common/stacks/types'; import { StackId } from '@/react/common/stacks/types';
import { useGitRefs } from '@/react/portainer/gitops/queries/useGitRefs'; import { useGitRefs } from '@/react/portainer/gitops/queries/useGitRefs';
import { Select } from '@@/form-components/Input'; import { PortainerSelect } from '@@/form-components/PortainerSelect';
import { getAuthentication } from '../utils'; import { getAuthentication } from '../utils';
@ -43,6 +43,11 @@ export function RefSelector({
refs.unshift('refs/heads/main'); refs.unshift('refs/heads/main');
} }
if (refs.includes('refs/heads/master')) {
refs.splice(refs.indexOf('refs/heads/master'), 1);
refs.unshift('refs/heads/master');
}
return refs.map((t: string) => ({ return refs.map((t: string) => ({
value: t, value: t,
label: t, label: t,
@ -58,12 +63,11 @@ export function RefSelector({
); );
return ( return (
<Select <PortainerSelect
value={value} value={value}
options={refs || [{ value: 'refs/heads/main', label: 'refs/heads/main' }]} options={refs || [{ value: 'refs/heads/main', label: 'refs/heads/main' }]}
onChange={(e) => onChange(e.target.value)} onChange={(e) => e && onChange(e)}
data-cy="component-gitRefInput" data-cy="component-gitRefInput"
required
/> />
); );
} }