From ddb2386a8a9469337073a26f9b57e71f64baf93c Mon Sep 17 00:00:00 2001 From: rashidakanchwala <37628668+rashidakanchwala@users.noreply.github.com> Date: Fri, 25 Oct 2024 11:11:23 +0100 Subject: [PATCH] Fix FE when `tag` name is `undefined` (#2146) Partly resolves #2106 --- src/selectors/tags.js | 3 ++- src/utils/index.js | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/selectors/tags.js b/src/selectors/tags.js index d2a55869d7..7f040c7c4d 100644 --- a/src/selectors/tags.js +++ b/src/selectors/tags.js @@ -1,5 +1,6 @@ import { createSelector } from 'reselect'; import { getPipelineTagIDs } from './pipeline'; +import { prettifyName } from '../utils'; const getNodeTags = (state) => state.node.tags; const getTagName = (state) => state.tag.name; @@ -14,7 +15,7 @@ export const getTagData = createSelector( (tagIDs, tagName, tagActive, tagEnabled) => tagIDs.sort().map((id) => ({ id, - name: tagName[id], + name: tagName[id] || prettifyName(id), active: Boolean(tagActive[id]), enabled: Boolean(tagEnabled[id]), })) diff --git a/src/utils/index.js b/src/utils/index.js index 2b3e1b9061..83804e0a6c 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -121,6 +121,9 @@ export const stripNamespace = (str) => { * @returns {String} The string with or without replaced values */ export const prettifyName = (str) => { + if (!str) { + return ''; + } const replacedString = str .replace(/-/g, ' ') .replace(/_/g, ' ')