diff --git a/src/fireedge/src/client/components/Cards/BackupJobCard.js b/src/fireedge/src/client/components/Cards/BackupJobCard.js index d9e8f74ef5..a93982de55 100644 --- a/src/fireedge/src/client/components/Cards/BackupJobCard.js +++ b/src/fireedge/src/client/components/Cards/BackupJobCard.js @@ -33,6 +33,7 @@ import { Group, HighPriority, Lock, User } from 'iconoir-react' import COLOR from 'client/constants/color' import PropTypes from 'prop-types' +import { useAuth } from 'client/features/Auth' const haveValues = function (object) { return Object.values(object).length > 0 @@ -49,6 +50,7 @@ const BackupJobCard = memo( */ ({ template, rootProps, onClickLabel, onDeleteLabel }) => { const classes = rowStyles() + const { labels: userLabels } = useAuth() const { ID, @@ -118,13 +120,19 @@ const BackupJobCard = memo( const labels = useMemo( () => - getUniqueLabels(LABELS).map((label) => ({ - text: label, - dataCy: `label-${label}`, - stateColor: getColorFromString(label), - onClick: onClickLabel, - onDelete: onDeleteLabel, - })), + getUniqueLabels(LABELS).reduce((acc, label) => { + if (userLabels?.includes(label)) { + acc.push({ + text: label, + dataCy: `label-${label}`, + stateColor: getColorFromString(label), + onClick: onClickLabel, + onDelete: onDeleteLabel, + }) + } + + return acc + }, []), [LABELS, onClickLabel, onDeleteLabel] ) diff --git a/src/fireedge/src/client/components/Cards/DatastoreCard.js b/src/fireedge/src/client/components/Cards/DatastoreCard.js index 5004fe7008..7191e20de7 100644 --- a/src/fireedge/src/client/components/Cards/DatastoreCard.js +++ b/src/fireedge/src/client/components/Cards/DatastoreCard.js @@ -48,7 +48,7 @@ import { getErrorMessage, getUniqueLabels, } from 'client/models/Helper' -import { useViews } from 'client/features/Auth' +import { useAuth, useViews } from 'client/features/Auth' const DatastoreCard = memo( /** @@ -61,6 +61,7 @@ const DatastoreCard = memo( */ ({ datastore: ds, rootProps, onClickLabel, onDeleteLabel }) => { const classes = rowStyles() + const { labels: userLabels } = useAuth() const { [RESOURCE_NAMES.DATASTORE]: dsView } = useViews() const enableEditLabels = @@ -88,13 +89,19 @@ const DatastoreCard = memo( const labels = useMemo( () => - getUniqueLabels(LABELS).map((label) => ({ - text: label, - dataCy: `label-${label}`, - stateColor: getColorFromString(label), - onClick: onClickLabel, - onDelete: enableEditLabels && onDeleteLabel, - })), + getUniqueLabels(LABELS).reduce((acc, label) => { + if (userLabels?.includes(label)) { + acc.push({ + text: label, + dataCy: `label-${label}`, + stateColor: getColorFromString(label), + onClick: onClickLabel, + onDelete: enableEditLabels && onDeleteLabel, + }) + } + + return acc + }, []), [LABELS, enableEditLabels, onClickLabel, onDeleteLabel] ) diff --git a/src/fireedge/src/client/components/Cards/HostCard.js b/src/fireedge/src/client/components/Cards/HostCard.js index 6337536797..7ea795eb1c 100644 --- a/src/fireedge/src/client/components/Cards/HostCard.js +++ b/src/fireedge/src/client/components/Cards/HostCard.js @@ -32,6 +32,7 @@ import { getColorFromString, getUniqueLabels } from 'client/models/Helper' import { Host, HOST_THRESHOLD, T } from 'client/constants' import { getAllocatedInfo, getState } from 'client/models/Host' +import { useAuth } from 'client/features/Auth' const HostCard = memo( /** @@ -45,6 +46,7 @@ const HostCard = memo( */ ({ host, rootProps, actions, onClickLabel, onDeleteLabel }) => { const classes = rowStyles() + const { labels: userLabels } = useAuth() const { ID, NAME, @@ -57,13 +59,19 @@ const HostCard = memo( const labels = useMemo( () => - getUniqueLabels(LABELS).map((label) => ({ - text: label, - dataCy: `label-${label}`, - stateColor: getColorFromString(label), - onClick: onClickLabel, - onDelete: onDeleteLabel, - })), + getUniqueLabels(LABELS).reduce((acc, label) => { + if (userLabels?.includes(label)) { + acc.push({ + text: label, + dataCy: `label-${label}`, + stateColor: getColorFromString(label), + onClick: onClickLabel, + onDelete: onDeleteLabel, + }) + } + + return acc + }, []), [LABELS, onClickLabel, onDeleteLabel] ) diff --git a/src/fireedge/src/client/components/Cards/MarketplaceAppCard.js b/src/fireedge/src/client/components/Cards/MarketplaceAppCard.js index 22ddb5beba..7b7de845b9 100644 --- a/src/fireedge/src/client/components/Cards/MarketplaceAppCard.js +++ b/src/fireedge/src/client/components/Cards/MarketplaceAppCard.js @@ -19,7 +19,7 @@ import PropTypes from 'prop-types' import { Lock, User, Group, Cart } from 'iconoir-react' import { Typography } from '@mui/material' -import { useViews } from 'client/features/Auth' +import { useAuth, useViews } from 'client/features/Auth' import MultipleTags from 'client/components/MultipleTags' import { StatusCircle, StatusChip } from 'client/components/Status' import { Tr } from 'client/components/HOC' @@ -46,6 +46,7 @@ const MarketplaceAppCard = memo( */ ({ app, rootProps, onClickLabel, onDeleteLabel }) => { const classes = rowStyles() + const { labels: userLabels } = useAuth() const { [RESOURCE_NAMES.VM]: vmView } = useViews() const enableEditLabels = @@ -72,13 +73,19 @@ const MarketplaceAppCard = memo( const labels = useMemo( () => - getUniqueLabels(LABELS).map((label) => ({ - text: label, - dataCy: `label-${label}`, - stateColor: getColorFromString(label), - onClick: onClickLabel, - onDelete: enableEditLabels && onDeleteLabel, - })), + getUniqueLabels(LABELS).reduce((acc, label) => { + if (userLabels?.includes(label)) { + acc.push({ + text: label, + dataCy: `label-${label}`, + stateColor: getColorFromString(label), + onClick: onClickLabel, + onDelete: enableEditLabels && onDeleteLabel, + }) + } + + return acc + }, []), [LABELS, enableEditLabels, onClickLabel, onDeleteLabel] ) diff --git a/src/fireedge/src/client/components/Cards/NetworkCard.js b/src/fireedge/src/client/components/Cards/NetworkCard.js index 8c2978609c..c4b5993300 100644 --- a/src/fireedge/src/client/components/Cards/NetworkCard.js +++ b/src/fireedge/src/client/components/Cards/NetworkCard.js @@ -25,7 +25,7 @@ import { } from 'iconoir-react' import { Box, Stack, Typography, Tooltip } from '@mui/material' -import { useViews } from 'client/features/Auth' +import { useAuth, useViews } from 'client/features/Auth' import MultipleTags from 'client/components/MultipleTags' import { StatusCircle, @@ -65,6 +65,7 @@ const NetworkCard = memo( */ ({ network, rootProps, actions, onClickLabel, onDeleteLabel }) => { const classes = rowStyles() + const { labels: userLabels } = useAuth() const { [RESOURCE_NAMES.VM]: vmView } = useViews() const enableEditLabels = @@ -91,12 +92,19 @@ const NetworkCard = memo( const labels = useMemo( () => - getUniqueLabels(LABELS).map((label) => ({ - text: label, - stateColor: getColorFromString(label), - onClick: onClickLabel, - onDelete: enableEditLabels && onDeleteLabel, - })), + getUniqueLabels(LABELS).reduce((acc, label) => { + if (userLabels?.includes(label)) { + acc.push({ + text: label, + dataCy: `label-${label}`, + stateColor: getColorFromString(label), + onClick: onClickLabel, + onDelete: enableEditLabels && onDeleteLabel, + }) + } + + return acc + }, []), [LABELS, enableEditLabels, onDeleteLabel] ) diff --git a/src/fireedge/src/client/components/Cards/SecurityGroupCard.js b/src/fireedge/src/client/components/Cards/SecurityGroupCard.js index 5cfd3dc141..c86c1976f3 100644 --- a/src/fireedge/src/client/components/Cards/SecurityGroupCard.js +++ b/src/fireedge/src/client/components/Cards/SecurityGroupCard.js @@ -23,6 +23,7 @@ import MultipleTags from 'client/components/MultipleTags' import { rowStyles } from 'client/components/Tables/styles' import { SecurityGroup, T } from 'client/constants' import { getColorFromString, getUniqueLabels } from 'client/models/Helper' +import { useAuth } from 'client/features/Auth' import { Tr } from 'client/components/HOC' const getTotalOfResources = (resources) => @@ -40,6 +41,7 @@ const SecurityGroupCard = memo( */ ({ securityGroup, rootProps, actions, onClickLabel, onDeleteLabel }) => { const classes = rowStyles() + const { labels: userLabels } = useAuth() const { ID, @@ -63,12 +65,19 @@ const SecurityGroupCard = memo( const labels = useMemo( () => - getUniqueLabels(LABELS).map((label) => ({ - text: label, - stateColor: getColorFromString(label), - onClick: onClickLabel, - onDelete: onDeleteLabel, - })), + getUniqueLabels(LABELS).reduce((acc, label) => { + if (userLabels?.includes(label)) { + acc.push({ + text: label, + dataCy: `label-${label}`, + stateColor: getColorFromString(label), + onClick: onClickLabel, + onDelete: onDeleteLabel, + }) + } + + return acc + }, []), [LABELS, onDeleteLabel] ) diff --git a/src/fireedge/src/client/components/Cards/ServiceTemplateCard.js b/src/fireedge/src/client/components/Cards/ServiceTemplateCard.js index 17a64cc5f5..74cbdf47ef 100644 --- a/src/fireedge/src/client/components/Cards/ServiceTemplateCard.js +++ b/src/fireedge/src/client/components/Cards/ServiceTemplateCard.js @@ -19,7 +19,7 @@ import PropTypes from 'prop-types' import { Network, Package } from 'iconoir-react' import { Typography } from '@mui/material' -import { useViews } from 'client/features/Auth' +import { useAuth, useViews } from 'client/features/Auth' import MultipleTags from 'client/components/MultipleTags' import Timer from 'client/components/Timer' import { Tr } from 'client/components/HOC' @@ -43,6 +43,7 @@ const ServiceTemplateCard = memo( */ ({ template, rootProps, actions, onDeleteLabel }) => { const classes = rowStyles() + const { labels: userLabels } = useAuth() const { [RESOURCE_NAMES.SERVICE_TEMPLATE]: serviceView } = useViews() const enableEditLabels = @@ -73,11 +74,19 @@ const ServiceTemplateCard = memo( const uniqueLabels = useMemo( () => - getUniqueLabels(labels).map((label) => ({ - text: label, - stateColor: getColorFromString(label), - onDelete: enableEditLabels && onDeleteLabel, - })), + getUniqueLabels(labels).reduce((acc, label) => { + if (userLabels?.includes(label)) { + acc.push({ + text: label, + dataCy: `label-${label}`, + stateColor: getColorFromString(label), + onDelete: enableEditLabels && onDeleteLabel, + }) + } + + return acc + }, []), + [labels, enableEditLabels, onDeleteLabel] ) diff --git a/src/fireedge/src/client/components/Cards/VirtualDataCenterCard.js b/src/fireedge/src/client/components/Cards/VirtualDataCenterCard.js index c20a3ee984..078135fbd1 100644 --- a/src/fireedge/src/client/components/Cards/VirtualDataCenterCard.js +++ b/src/fireedge/src/client/components/Cards/VirtualDataCenterCard.js @@ -26,7 +26,7 @@ import { } from 'iconoir-react' import MultipleTags from 'client/components/MultipleTags' -import { useViews } from 'client/features/Auth' +import { useAuth, useViews } from 'client/features/Auth' import { Tr } from 'client/components/HOC' import { StatusCircle } from 'client/components/Status' @@ -50,6 +50,7 @@ const VirtualDataCenterCard = memo( */ ({ template, rootProps, onClickLabel, onDeleteLabel }) => { const classes = rowStyles() + const { labels: userLabels } = useAuth() const { [RESOURCE_NAMES.VDC]: vdcView } = useViews() const enableEditLabels = @@ -111,12 +112,19 @@ const VirtualDataCenterCard = memo( const labels = useMemo( () => - getUniqueLabels(LABELS).map((label) => ({ - text: label, - stateColor: getColorFromString(label), - onClick: onClickLabel, - onDelete: enableEditLabels && onDeleteLabel, - })), + getUniqueLabels(LABELS).reduce((acc, label) => { + if (userLabels?.includes(label)) { + acc.push({ + text: label, + dataCy: `label-${label}`, + stateColor: getColorFromString(label), + onClick: onClickLabel, + onDelete: enableEditLabels && onDeleteLabel, + }) + } + + return acc + }, []), [LABELS, enableEditLabels, onClickLabel, onDeleteLabel] ) diff --git a/src/fireedge/src/client/components/Cards/VirtualMachineCard.js b/src/fireedge/src/client/components/Cards/VirtualMachineCard.js index e4941fce8d..0e8e80ecf2 100644 --- a/src/fireedge/src/client/components/Cards/VirtualMachineCard.js +++ b/src/fireedge/src/client/components/Cards/VirtualMachineCard.js @@ -33,7 +33,7 @@ import MultipleTags from 'client/components/MultipleTags' import { StatusChip, StatusCircle } from 'client/components/Status' import { rowStyles } from 'client/components/Tables/styles' import Timer from 'client/components/Timer' -import { useViews } from 'client/features/Auth' +import { useAuth, useViews } from 'client/features/Auth' import { ACTIONS, RESOURCE_NAMES, T, VM } from 'client/constants' import { @@ -66,6 +66,7 @@ const VirtualMachineCard = memo( }) => { const classes = rowStyles() const { [RESOURCE_NAMES.VM]: vmView } = useViews() + const { labels: userLabels } = useAuth() const enableEditLabels = vmView?.actions?.[ACTIONS.EDIT_LABELS] === true && !!onDeleteLabel @@ -129,12 +130,20 @@ const VirtualMachineCard = memo( const labels = useMemo( () => - getUniqueLabels(LABELS).map((label) => ({ - text: label, - stateColor: getColorFromString(label), - onClick: onClickLabel, - onDelete: enableEditLabels && onDeleteLabel, - })), + getUniqueLabels(LABELS).reduce((acc, label) => { + if (userLabels?.includes(label)) { + acc.push({ + text: label, + dataCy: `label-${label}`, + stateColor: getColorFromString(label), + onClick: onClickLabel, + onDelete: enableEditLabels && onDeleteLabel, + }) + } + + return acc + }, []), + [LABELS, enableEditLabels, onClickLabel, onDeleteLabel] ) diff --git a/src/fireedge/src/client/components/Cards/VmTemplateCard.js b/src/fireedge/src/client/components/Cards/VmTemplateCard.js index c7480d0745..022b6da358 100644 --- a/src/fireedge/src/client/components/Cards/VmTemplateCard.js +++ b/src/fireedge/src/client/components/Cards/VmTemplateCard.js @@ -19,7 +19,7 @@ import PropTypes from 'prop-types' import { User, Group, Lock } from 'iconoir-react' import { Typography } from '@mui/material' -import { useViews } from 'client/features/Auth' +import { useAuth, useViews } from 'client/features/Auth' import MultipleTags from 'client/components/MultipleTags' import Timer from 'client/components/Timer' import Image from 'client/components/Image' @@ -55,6 +55,7 @@ const VmTemplateCard = memo( ({ template, rootProps, onClickLabel, onDeleteLabel }) => { const classes = rowStyles() const { [RESOURCE_NAMES.VM_TEMPLATE]: templateView } = useViews() + const { labels: userLabels } = useAuth() const enableEditLabels = templateView?.actions?.[ACTIONS.EDIT_LABELS] === true && !!onDeleteLabel @@ -81,12 +82,19 @@ const VmTemplateCard = memo( const labels = useMemo( () => - getUniqueLabels(LABELS).map((label) => ({ - text: label, - stateColor: getColorFromString(label), - onClick: onClickLabel, - onDelete: enableEditLabels && onDeleteLabel, - })), + getUniqueLabels(LABELS).reduce((acc, label) => { + if (userLabels?.includes(label)) { + acc.push({ + text: label, + dataCy: `label-${label}`, + stateColor: getColorFromString(label), + onClick: onClickLabel, + onDelete: enableEditLabels && onDeleteLabel, + }) + } + + return acc + }, []), [LABELS, enableEditLabels, onClickLabel, onDeleteLabel] ) diff --git a/src/fireedge/src/client/components/Tables/Backups/row.js b/src/fireedge/src/client/components/Tables/Backups/row.js index eb76b66eb5..8ee4e116b5 100644 --- a/src/fireedge/src/client/components/Tables/Backups/row.js +++ b/src/fireedge/src/client/components/Tables/Backups/row.js @@ -15,6 +15,7 @@ * ------------------------------------------------------------------------- */ /* eslint-disable jsdoc/require-jsdoc */ import PropTypes from 'prop-types' +import { useAuth } from 'client/features/Auth' import { useMemo, useCallback } from 'react' import imageApi, { useUpdateImageMutation } from 'client/features/OneApi/image' @@ -46,6 +47,7 @@ import * as Helper from 'client/models/Helper' const Row = ({ original, value, onClickLabel, ...props }) => { const [update] = useUpdateImageMutation() + const { labels: userLabels } = useAuth() const state = imageApi.endpoints.getImages.useQueryState(undefined, { selectFromResult: ({ data = [] }) => @@ -95,12 +97,19 @@ const Row = ({ original, value, onClickLabel, ...props }) => { const multiTagLabels = useMemo( () => - getUniqueLabels(LABELS).map((label) => ({ - text: label, - stateColor: getColorFromString(label), - onClick: onClickLabel, - onDelete: handleDeleteLabel, - })), + getUniqueLabels(LABELS).reduce((acc, label) => { + if (userLabels?.includes(label)) { + acc.push({ + text: label, + dataCy: `label-${label}`, + stateColor: getColorFromString(label), + onClick: onClickLabel, + onDelete: handleDeleteLabel, + }) + } + + return acc + }, []), [LABELS, handleDeleteLabel, onClickLabel] ) diff --git a/src/fireedge/src/client/components/Tables/Enhanced/Utils/GlobalLabel/index.js b/src/fireedge/src/client/components/Tables/Enhanced/Utils/GlobalLabel/index.js index 2627229038..d358f24fec 100644 --- a/src/fireedge/src/client/components/Tables/Enhanced/Utils/GlobalLabel/index.js +++ b/src/fireedge/src/client/components/Tables/Enhanced/Utils/GlobalLabel/index.js @@ -95,7 +95,7 @@ const GlobalLabel = ({ ) const allFilterLabels = useMemo(() => { - const all = [...userLabels, ...unknownPageLabels, ...currentLabelFilters] + const all = [...userLabels, ...currentLabelFilters] const unique = [...new Set(all)] return sortByFilteredFirst(unique, currentLabelFilters) diff --git a/src/fireedge/src/client/components/Tables/Images/row.js b/src/fireedge/src/client/components/Tables/Images/row.js index 4dc640e1ab..412da2b823 100644 --- a/src/fireedge/src/client/components/Tables/Images/row.js +++ b/src/fireedge/src/client/components/Tables/Images/row.js @@ -28,6 +28,7 @@ import { import { Typography } from '@mui/material' import MultipleTags from 'client/components/MultipleTags' import imageApi, { useUpdateImageMutation } from 'client/features/OneApi/image' +import { useAuth } from 'client/features/Auth' import Timer from 'client/components/Timer' import { StatusCircle, StatusChip } from 'client/components/Status' @@ -46,6 +47,8 @@ import * as Helper from 'client/models/Helper' const Row = ({ original, value, onClickLabel, ...props }) => { const [update] = useUpdateImageMutation() + const { labels: userLabels } = useAuth() + const classes = rowStyles() const { id: ID, @@ -89,12 +92,19 @@ const Row = ({ original, value, onClickLabel, ...props }) => { const multiTagLabels = useMemo( () => - getUniqueLabels(LABELS).map((label) => ({ - text: label, - stateColor: getColorFromString(label), - onClick: onClickLabel, - onDelete: handleDeleteLabel, - })), + getUniqueLabels(LABELS).reduce((acc, label) => { + if (userLabels?.includes(label)) { + acc.push({ + text: label, + dataCy: `label-${label}`, + stateColor: getColorFromString(label), + onClick: onClickLabel, + onDelete: handleDeleteLabel, + }) + } + + return acc + }, []), [LABELS, handleDeleteLabel, onClickLabel] ) diff --git a/src/fireedge/src/client/components/Tables/VNetworks/actions.js b/src/fireedge/src/client/components/Tables/VNetworks/actions.js index bb2873fddb..a572a4a029 100644 --- a/src/fireedge/src/client/components/Tables/VNetworks/actions.js +++ b/src/fireedge/src/client/components/Tables/VNetworks/actions.js @@ -129,7 +129,6 @@ const Actions = () => { accessor: VN_ACTIONS.INSTANTIATE_DIALOG, dataCy: `vnet-${VN_ACTIONS.INSTANTIATE_DIALOG}`, tooltip: T.Instantiate, - selected: true, icon: PlayOutline, options: [ {