-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GEN-1795]: add filters by programming language (#1869)
- Loading branch information
1 parent
ee42a22
commit f75e804
Showing
6 changed files
with
75 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export * from './error-dropdown'; | ||
export * from './language-dropdown'; | ||
export * from './monitor-dropdown'; | ||
export * from './namespace-dropdown'; | ||
export * from './type-dropdown'; |
34 changes: 34 additions & 0 deletions
34
frontend/webapp/components/common/dropdowns/language-dropdown/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React, { useMemo } from 'react'; | ||
import { useSourceCRUD } from '@/hooks'; | ||
import { DropdownOption } from '@/types'; | ||
import { Dropdown } from '@/reuseable-components'; | ||
|
||
interface Props { | ||
title?: string; | ||
value?: DropdownOption[]; | ||
onSelect: (val: DropdownOption) => void; | ||
onDeselect: (val: DropdownOption) => void; | ||
isMulti?: boolean; | ||
required?: boolean; | ||
showSearch?: boolean; | ||
} | ||
|
||
export const LanguageDropdown: React.FC<Props> = ({ title = 'Programming Languages', value, onSelect, onDeselect, ...props }) => { | ||
const { sources } = useSourceCRUD(); | ||
|
||
const options = useMemo(() => { | ||
const payload: DropdownOption[] = []; | ||
|
||
sources.forEach(({ instrumentedApplicationDetails: { containers } }) => { | ||
containers.forEach(({ language }) => { | ||
if (!payload.find((opt) => opt.id === language)) { | ||
payload.push({ id: language, value: language }); | ||
} | ||
}); | ||
}); | ||
|
||
return payload.sort((a, b) => a.id.localeCompare(b.id)); | ||
}, [sources]); | ||
|
||
return <Dropdown title={title} placeholder='All' options={options} value={value} onSelect={onSelect} onDeselect={onDeselect} {...props} />; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters