From fdc9c95c81113a363386da905ff6ba18b4829fea Mon Sep 17 00:00:00 2001 From: Dan Labrecque Date: Wed, 10 Jan 2024 17:40:57 -0500 Subject: [PATCH] Update table selection functionality for Platform projects https://issues.redhat.com/browse/COST-3818 --- .../platformProjects/platformProjects.tsx | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/routes/settings/platformProjects/platformProjects.tsx b/src/routes/settings/platformProjects/platformProjects.tsx index 2bd16617e..5b35480a2 100644 --- a/src/routes/settings/platformProjects/platformProjects.tsx +++ b/src/routes/settings/platformProjects/platformProjects.tsx @@ -107,17 +107,18 @@ const PlatformProjects: React.FC = ({ canWrite }) => { }; const getToolbar = (categories: SettingsData[]) => { - const hasEnabledItem = selectedItems.find(item => item.enabled); - const hasDisabledItem = selectedItems.find(item => !item.enabled); + const hasEnabledPlatformGroup = selectedItems.find(item => item.group === 'Platform' && !item.default); + const hasDisabledPlatformGroup = selectedItems.find(item => item.group !== 'Platform' && !item.default); const itemsTotal = settings?.meta ? settings.meta.count : 0; + const unAvailableCategories = categories.filter(item => item.default); return ( = ({ canWrite }) => { } else if (action === 'page') { const newSelectedItems = [...selectedItems]; getCategories().map(val => { - if (!newSelectedItems.find(item => item.project === val.project)) { + if (!newSelectedItems.find(item => item.project === val.project) && !val.default) { newSelectedItems.push(val); } }); @@ -175,10 +176,14 @@ const PlatformProjects: React.FC = ({ canWrite }) => { const handleOnRemove = () => { if (selectedItems.length > 0) { - const payload = selectedItems.map(item => ({ - project: item.project, - group: null, - })); + const payload = selectedItems.map(item => { + if (!item.default) { + return { + project: item.project, + group: item.group, + }; + } + }); setSelectedItems([], () => { dispatch(settingsActions.updateSettings(SettingsType.platformProjectsRemove, payload as any)); });