diff --git a/frontend/src/components/sf-table/editors/tags-editor/index.js b/frontend/src/components/sf-table/editors/tags-editor/index.js index 7a9986d785..76bfead08a 100644 --- a/frontend/src/components/sf-table/editors/tags-editor/index.js +++ b/frontend/src/components/sf-table/editors/tags-editor/index.js @@ -8,7 +8,7 @@ import DeleteTags from './delete-tags'; import { Utils } from '../../../../utils/utils'; import { KeyCodes } from '../../../../constants'; import { gettext } from '../../../../utils/constants'; -import { getTagColor, getTagId, getTagName, getTagsByNameOrColor } from '../../../../tag/utils/cell'; +import { getTagColor, getTagId, getTagName, getTagsByName } from '../../../../tag/utils/cell'; import { getRecordIdFromRecord } from '../../../../metadata/utils/cell'; import { SELECT_OPTION_COLORS } from '../../../../metadata/constants'; import { getRowById } from '../../utils/table'; @@ -38,7 +38,7 @@ const TagsEditor = ({ const editorRef = useRef(null); const selectItemRef = useRef(null); - const displayTags = useMemo(() => getTagsByNameOrColor(allTagsRef.current, searchValue), [searchValue, allTagsRef]); + const displayTags = useMemo(() => getTagsByName(allTagsRef.current, searchValue), [searchValue, allTagsRef]); const isShowCreateBtn = useMemo(() => { if (!canAddTag || !searchValue || !Utils.isFunction(addNewTag)) return false; diff --git a/frontend/src/metadata/components/cell-editors/tags-editor/index.js b/frontend/src/metadata/components/cell-editors/tags-editor/index.js index 85b3c57f7f..c859ae33a4 100644 --- a/frontend/src/metadata/components/cell-editors/tags-editor/index.js +++ b/frontend/src/metadata/components/cell-editors/tags-editor/index.js @@ -8,7 +8,7 @@ import { Utils } from '../../../../utils/utils'; import { KeyCodes } from '../../../../constants'; import { gettext } from '../../../../utils/constants'; import { useTags } from '../../../../tag/hooks'; -import { getTagColor, getTagId, getTagName, getTagsByNameOrColor, getTagByNameOrColor } from '../../../../tag/utils/cell'; +import { getTagId, getTagName, getTagsByName, getTagByName } from '../../../../tag/utils/cell'; import { getRecordIdFromRecord } from '../../../utils/cell'; import { getRowById } from '../../../../components/sf-table/utils/table'; import { SELECT_OPTION_COLORS } from '../../../constants'; @@ -55,13 +55,13 @@ const TagsEditor = forwardRef(({ return tagsData?.rows || []; }, [tagsData]); - const displayTags = useMemo(() => getTagsByNameOrColor(tags, searchValue), [searchValue, tags]); + const displayTags = useMemo(() => getTagsByName(tags, searchValue), [searchValue, tags]); const recentlyUsedTags = useMemo(() => recentlyUsed, [recentlyUsed]); const isShowCreateBtn = useMemo(() => { if (!canAddTag) return false; if (!canEditData || !searchValue) return false; - return !getTagByNameOrColor(displayTags, searchValue); + return !getTagByName(displayTags, searchValue); }, [canEditData, displayTags, searchValue, canAddTag]); const style = useMemo(() => { @@ -278,8 +278,7 @@ const TagsEditor = forwardRef(({ if (!row) return; const value = searchValue.toLowerCase(); const tagName = getTagName(row).toLowerCase(); - const tagColor = getTagColor(row).toLowerCase(); - if (!tagName.includes(value) && !tagColor.includes(value)) return; + if (!tagName.includes(value)) return; const nodesWithAncestors = getNodesWithAncestors(node, tree).filter(node => checkIsTreeNodeShown(getTreeNodeKey(node), searchedKeyNodeFoldedMap)); searchedNodes = [...searchedNodes, ...nodesWithAncestors]; }); diff --git a/frontend/src/tag/utils/cell.js b/frontend/src/tag/utils/cell.js index f995d7bbe3..64ec9afad0 100644 --- a/frontend/src/tag/utils/cell.js +++ b/frontend/src/tag/utils/cell.js @@ -41,27 +41,23 @@ export const getTagFilesCount = (tag) => { return Array.isArray(links) ? links.length : 0; }; -export const getTagsByNameOrColor = (tags, nameOrColor) => { +export const getTagsByName = (tags, name) => { if (!Array.isArray(tags) || tags.length === 0) return []; - if (!nameOrColor) return tags; - const value = nameOrColor.toLowerCase(); + if (!name) return tags; + const value = name.toLowerCase(); return tags.filter((tag) => { const tagName = getTagName(tag); if (tagName && tagName.toLowerCase().includes(value)) return true; - const tagColor = getTagColor(tag); - if (tagColor && tagColor.toLowerCase().includes(value)) return true; return false; }); }; -export const getTagByNameOrColor = (tags, nameOrColor) => { +export const getTagByName = (tags, name) => { if (!Array.isArray(tags) || tags.length === 0) return null; - if (!nameOrColor) return null; + if (!name) return null; return tags.find((tag) => { const tagName = getTagName(tag); - if (tagName && tagName === nameOrColor) return true; - const tagColor = getTagColor(tag); - if (tagColor && tagColor === nameOrColor) return true; + if (tagName && tagName === name) return true; return false; }); };