From b21ee0c8620ddaba6d9ddf6a40bf00571a4ba76b Mon Sep 17 00:00:00 2001 From: Aleix Date: Thu, 19 Sep 2024 19:06:07 +0200 Subject: [PATCH] feat: Remove admin selector (#2153) * feat: Remove admin selector * fixup! feat: Remove admin selector --- .../app/Admin/CatalogIncidentsAlertList.tsx | 9 +- catalog/ui/src/app/Catalog/AdminSelector.tsx | 88 ------------------- catalog/ui/src/app/Catalog/Catalog.tsx | 2 - 3 files changed, 6 insertions(+), 93 deletions(-) delete mode 100644 catalog/ui/src/app/Catalog/AdminSelector.tsx diff --git a/catalog/ui/src/app/Admin/CatalogIncidentsAlertList.tsx b/catalog/ui/src/app/Admin/CatalogIncidentsAlertList.tsx index 4bf4590b9..5e650b378 100644 --- a/catalog/ui/src/app/Admin/CatalogIncidentsAlertList.tsx +++ b/catalog/ui/src/app/Admin/CatalogIncidentsAlertList.tsx @@ -30,9 +30,12 @@ const CatalogIncidentsAlertList: React.FC = () => { if (catalogItemsArr && catalogIncidents) { return catalogIncidents.items.map(i => { const ci = catalogItemsArr.find(c => c.metadata.labels?.['gpte.redhat.com/asset-uuid'] === i.asset_uuid && getStageFromK8sObject(c) === i.stage); - ci.metadata.annotations[`${BABYLON_DOMAIN}/incident`] = JSON.stringify(i); - return ci; - }); + if (ci) { + ci.metadata.annotations[`${BABYLON_DOMAIN}/incident`] = JSON.stringify(i); + return ci; + } + return null; + }).filter(Boolean); } return []; }, [catalogItemsArr, catalogIncidents]); diff --git a/catalog/ui/src/app/Catalog/AdminSelector.tsx b/catalog/ui/src/app/Catalog/AdminSelector.tsx deleted file mode 100644 index d20fcede7..000000000 --- a/catalog/ui/src/app/Catalog/AdminSelector.tsx +++ /dev/null @@ -1,88 +0,0 @@ -import React, { useState } from 'react'; -import { Button, Checkbox, ExpandableSection, Form, FormGroup, Tooltip } from '@patternfly/react-core'; -import { FilterAltIcon } from '@patternfly/react-icons'; - -import './catalog-label-selector.css'; - -const CatalogCategorySelector: React.FC<{ - onSelect: (statuses: string[]) => void; - selected: string[]; -}> = ({ onSelect, selected }) => { - const [isExpanded, setIsExpanded] = useState(false); - function handleOnChange(key: string) { - if (selected.includes(key)) { - onSelect(selected.filter((s) => s !== key)); - } else { - onSelect([...selected, key]); - } - } - return ( -
- -

Admin

- {selected.length > 0 ? ( - Clear filter}> - - - ) : null} - - } - onToggle={(_event, expanded: boolean) => setIsExpanded(expanded)} - > - - handleOnChange('operational')} - /> - handleOnChange('degraded-performance')} - /> - handleOnChange('partial-outage')} - /> - handleOnChange('major-outage')} - /> - handleOnChange('under-maintenance')} - /> - -
-
- ); -}; - -export default CatalogCategorySelector; diff --git a/catalog/ui/src/app/Catalog/Catalog.tsx b/catalog/ui/src/app/Catalog/Catalog.tsx index 5bac0dcb1..0a4525440 100644 --- a/catalog/ui/src/app/Catalog/Catalog.tsx +++ b/catalog/ui/src/app/Catalog/Catalog.tsx @@ -63,7 +63,6 @@ import CatalogLabelSelector from './CatalogLabelSelector'; import CatalogNamespaceSelect from './CatalogNamespaceSelect'; import CatalogContent from './CatalogContent'; import IncidentsBanner from '@app/components/IncidentsBanner'; -import AdminSelector from './AdminSelector'; import useInterfaceConfig from '@app/utils/useInterfaceConfig'; import './catalog.css'; @@ -558,7 +557,6 @@ const Catalog: React.FC<{ userHasRequiredPropertiesToAccess: boolean }> = ({ use onSelect={onSelectLabels} selected={selectedLabels} /> - {isAdmin ? : null}