diff --git a/components/AdminMessages.tsx b/components/AdminMessages.tsx index dadcc67..1f46e3a 100644 --- a/components/AdminMessages.tsx +++ b/components/AdminMessages.tsx @@ -13,7 +13,7 @@ export default function AdminMessages(props: AdminMessagesProps) { props.setActiveAdminMessages(adminMessagesCopy); } - return (
+ return (
{props.adminMessages && props.adminMessages.map((activeMessage, index) => (
diff --git a/components/KernDropdown.tsx b/components/KernDropdown.tsx index c40160c..969d1df 100644 --- a/components/KernDropdown.tsx +++ b/components/KernDropdown.tsx @@ -4,11 +4,11 @@ import { KernDropdownProps } from '../types/dropdown'; import { combineClassNames } from '../../javascript-functions/general'; import { SELECT_ALL, checkDropdownProps, getActiveNegateGroupColor, getDropdownDisplayText, prepareDropdownOptionsToArray, reduceColorProperty, setOptionsWithSearchBar } from '../helpers/dropdown-helper'; import { Tooltip } from '@nextui-org/react'; -import { IconChevronDown, IconDotsVertical, IconExternalLink, IconLoader } from '@tabler/icons-react'; +import { IconChevronDown, IconDotsVertical, IconExternalLink } from '@tabler/icons-react'; import { IconTrashXFilled } from '@tabler/icons-react'; import useOnClickOutside from '../hooks/useHooks/useOnClickOutside'; -import * as TablerIcons from '@tabler/icons-react'; import { useDefaults } from '../hooks/useDefaults'; +import SVGIcon from './SVGIcon'; const DEFAULTS = { fontSizeClass: 'text-xs' }; @@ -18,7 +18,7 @@ export default function KernDropdown(props: KernDropdownProps) { const [dropdownCaptions, setDropdownCaptions] = useState([]); const [disabledOptions, setDisabledOptions] = useState([]); const [backgroundColors, setBackgroundColors] = useState([]); - const [searchText, setSearchText] = useState(props.searchDefaultValue ?? ''); + const [searchText, setSearchText] = useState(''); const [isOpen, setIsOpen] = useState(false); const [selectedCheckboxes, setSelectedCheckboxes] = useState([]); const [position, setPosition] = useState(null); @@ -38,6 +38,10 @@ export default function KernDropdown(props: KernDropdownProps) { props.onSearchChange(searchText) }, [props.onSearchChange, searchText]); + useEffect(() => { + setSearchText(props.searchDefaultValue ?? ''); + }, [props.searchDefaultValue]); + useEffect(() => { const prepareOptions = prepareDropdownOptionsToArray(props.options, props.hasSearchBar, props.valuePropertyPath); if (props.hasSearchBar) { @@ -279,18 +283,3 @@ function HoverBox(props: { position: any, hoverBox: any }) {
} ) } - -function SVGIcon({ icon, size, strokeWidth, useFillForIcons }) { - const Icon = TablerIcons[icon]; - if (Icon) { - return ( - - ) - } else { - return - } -} \ No newline at end of file diff --git a/components/SVGIcon.tsx b/components/SVGIcon.tsx new file mode 100644 index 0000000..5d51a2d --- /dev/null +++ b/components/SVGIcon.tsx @@ -0,0 +1,43 @@ +import { IconBolt, IconChevronDown, IconCode, IconDotsVertical, IconExternalLink, IconFileInfo, IconFilePencil, IconLoader, IconPlayerPlayFilled, IconSquare, IconSquareCheck, IconTrash } from '@tabler/icons-react'; + +export const SUPPORTED_ICONS = ['IconCode', 'IconBolt', 'IconSquareCheck', 'IconSquare', 'IconPlayerPlayFilled', 'IconTrash', 'IconExternalLink', + 'IconLoader', 'IconFilePencil', 'IconFileInfo' +] + +type SVGIconProps = { + icon: string, + size?: number, + strokeWidth?: number, + useFillForIcons?: boolean +} + +export default function SVGIcon(props: SVGIconProps) { + switch (props.icon) { + case 'IconCode': + return + case 'IconBolt': + return + case 'IconSquareCheck': + return + case 'IconSquare': + return + case 'IconPlayerPlayFilled': + return + case 'IconTrash': + return + case 'IconExternalLink': + return + case 'IconChevronDown': + return + case 'IconDotsVertical': + return + case 'IconLoader': + return + case 'IconFilePencil': + return + case 'IconFileInfo': + return + default: return + } + +} \ No newline at end of file diff --git a/helpers/dropdown-helper.ts b/helpers/dropdown-helper.ts index fa1a46a..41a73e0 100644 --- a/helpers/dropdown-helper.ts +++ b/helpers/dropdown-helper.ts @@ -1,3 +1,4 @@ +import { SUPPORTED_ICONS } from "../components/SVGIcon"; import { KernDropdownProps } from "../types/dropdown"; export const SELECT_ALL = 'Select all'; @@ -67,8 +68,12 @@ export function checkDropdownProps(props: KernDropdownProps) { throw new Error('Dropdown: linkList should be used with optionsHaveLink'); } else if (props.hoverBoxList && !props.optionsHaveHoverBox) { throw new Error('Dropdown: hoverBoxList should be used with optionsHaveHoverBox'); - } else if (props.iconsArray && (props.iconsArray.length != props.options.length)) { - throw new Error('Dropdown: iconsArray length must be equal to options length'); + } else if (props.iconsArray) { + if (props.iconsArray.length != props.options.length) { + throw new Error('Dropdown: iconsArray length must be equal to options length'); + } else if (props.iconsArray.some((icon: string) => !SUPPORTED_ICONS.includes(icon))) { + throw new Error('Dropdown: icon not yet supported'); + } } else if (props.useFillForIcons && (props.useFillForIcons.length != props.options.length)) { throw new Error('Dropdown: useFillForIcons length must be equal to options length'); } @@ -135,4 +140,4 @@ export function getActiveNegateGroupColor(group: any) { } return '#4e46e5'; -} \ No newline at end of file +} diff --git a/hooks/web-socket/constants.ts b/hooks/web-socket/constants.ts index 766019b..37003a7 100644 --- a/hooks/web-socket/constants.ts +++ b/hooks/web-socket/constants.ts @@ -91,7 +91,7 @@ export const WHITELIST_LOOKUP_REFINERY = { [CurrentPageSubKey.NONE]: ['labeling_task_updated', 'labeling_task_created', 'label_created', 'label_deleted', 'labeling_task_deleted', 'information_source_deleted', 'information_source_updated', 'model_callback_update_statistics', 'embedding_deleted', 'embedding', 'payload_finished', 'payload_failed', 'payload_created', 'payload_update_statistics'] }, [CurrentPage.HEURISTICS]: { - [CurrentPageSubKey.NONE]: ['labeling_task_updated', 'labeling_task_created', 'labeling_task_deleted', 'information_source_created', 'information_source_updated', 'information_source_deleted', 'payload_finished', 'payload_failed', 'payload_created', 'payload_update_statistics', 'embedding_deleted', 'weak_supervision_started', 'weak_supervision_finished'], + [CurrentPageSubKey.NONE]: ['labeling_task_updated', 'labeling_task_created', 'labeling_task_deleted', 'information_source_created', 'information_source_updated', 'information_source_deleted', 'payload_finished', 'payload_failed', 'payload_created', 'payload_update_statistics', 'embedding_deleted', 'weak_supervision_started', 'weak_supervision_finished', 'tokenization'], }, [CurrentPage.EDIT_RECORDS]: {