Skip to content

Commit

Permalink
chore: add creatable filter popover select
Browse files Browse the repository at this point in the history
  • Loading branch information
bimalgrg519 committed Jan 16, 2025
1 parent c10197c commit 5ac727c
Showing 1 changed file with 37 additions and 38 deletions.
75 changes: 37 additions & 38 deletions ui/web-v2/src/components/FilterPopover/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { messages } from '../../lang/messages';
import { classNames } from '../../utils/css';
import { FilterTypes } from '../FeatureList';
import { Select } from '../Select';
import { CreatableSelect } from '../CreatableSelect';

export type FilterType = 'maintainer' | 'hasExperiment' | 'enabled';

Expand Down Expand Up @@ -120,46 +121,44 @@ export const FilterPopover: FC<FilterPopoverProps> = memo(
<div className="mx-3 pt-[6px]">
{f(messages.feature.clause.operator.equal)}
</div>
<Select
placeholder={f(
selectedFilterType?.value === FilterTypes.TAGS
? messages.tags.tagsPlaceholder
: messages.select
)}
closeMenuOnSelect={isMultiFilter ? false : true}
className={classNames(
isMultiFilter
? 'min-w-[270px]'
: isFilterTypeMaintainer
{isMultiFilter ? (
<CreatableSelect
placeholder={f(messages.tags.tagsPlaceholder)}
options={values}
defaultValues={multiValueOption}
onChange={(o: Option[]) => {
setMultiValueOption(o);
}}
closeMenuOnSelect={false}
className={classNames('min-w-[270px]')}
/>
) : (
<Select
placeholder={f(messages.select)}
closeMenuOnSelect={true}
className={classNames(
isFilterTypeMaintainer
? 'min-w-[220px]'
: 'min-w-[106px]'
)}
options={values}
styles={{
menu: ({ ...css }) => ({
width: 'max-content',
minWidth: '100%',
...css
}),
singleValue: ({ ...otherStyles }) => ({
...otherStyles
})
}}
value={isMultiFilter ? multiValueOption : valueOption}
onChange={(o) => {
if (isMultiFilter) {
setMultiValueOption(o);
} else {
setValueOption(o);
}
}}
isSearchable={
selectedFilterType?.value === FilterTypes.TAGS ||
isFilterTypeMaintainer
}
isMulti={isMultiFilter}
clearable={isFilterTypeMaintainer}
/>
)}
options={values}
styles={{
menu: ({ ...css }) => ({
width: 'max-content',
minWidth: '100%',
...css
}),
singleValue: ({ ...otherStyles }) => ({
...otherStyles
})
}}
value={valueOption}
onChange={(o) => setValueOption(o)}
isSearchable={isFilterTypeMaintainer}
isMulti={isMultiFilter}
clearable={isFilterTypeMaintainer}
/>
)}
<div className={classNames('flex-none ml-4')}>
<button
type="button"
Expand Down

0 comments on commit 5ac727c

Please sign in to comment.