From 50fd7c62868747c4d67e368eab5bd0d6dd0ad6b3 Mon Sep 17 00:00:00 2001 From: Chaim Lev-Ari Date: Thu, 23 May 2024 13:15:36 +0300 Subject: [PATCH] feat(docker/containers): limit items on volume selector [EE-7077] (#11845) --- .../form-components/ReactSelect.css | 2 +- .../form-components/ReactSelect.tsx | 106 +++++++++++++++++- .../CreateView/VolumesTab/VolumeSelector.tsx | 10 +- 3 files changed, 109 insertions(+), 9 deletions(-) diff --git a/app/react/components/form-components/ReactSelect.css b/app/react/components/form-components/ReactSelect.css index 29b4b94b2..0f64114df 100644 --- a/app/react/components/form-components/ReactSelect.css +++ b/app/react/components/form-components/ReactSelect.css @@ -96,7 +96,7 @@ border-bottom-left-radius: 0; } -.input-group .portainer-selector-root .portainer-selector__control:not(:last-child) { +.input-group .portainer-selector-root .portainer-selector__control:not(:last-child, .portainer-selector__control--menu-is-open) { border-top-right-radius: 0; border-bottom-right-radius: 0; } diff --git a/app/react/components/form-components/ReactSelect.tsx b/app/react/components/form-components/ReactSelect.tsx index 8b12edbb5..3ec4429b9 100644 --- a/app/react/components/form-components/ReactSelect.tsx +++ b/app/react/components/form-components/ReactSelect.tsx @@ -1,12 +1,16 @@ import ReactSelectCreatable, { CreatableProps as ReactSelectCreatableProps, } from 'react-select/creatable'; +import ReactSelectAsync, { + AsyncProps as ReactSelectAsyncProps, +} from 'react-select/async'; import ReactSelect, { GroupBase, + OptionsOrGroups, Props as ReactSelectProps, } from 'react-select'; import clsx from 'clsx'; -import { RefAttributes } from 'react'; +import { RefAttributes, useMemo } from 'react'; import ReactSelectType from 'react-select/dist/declarations/src/Select'; import './ReactSelect.css'; @@ -56,9 +60,24 @@ export function Select< className, isCreatable = false, size = 'md', + ...props -}: Props & AutomationTestingProps) { +}: Props & + AutomationTestingProps & { + isItemVisible?: (item: Option, search: string) => boolean; + }) { const Component = isCreatable ? ReactSelectCreatable : ReactSelect; + const { options } = props; + + if ((options?.length || 0) > 1000) { + return ( + + ); + } return ( ); } + +export function Async< + Option = DefaultOption, + IsMulti extends boolean = false, + Group extends GroupBase