Skip to content

Commit

Permalink
feat: Sort disabled items to end of catalog (#2142)
Browse files Browse the repository at this point in the history
  • Loading branch information
aleixhub authored Sep 17, 2024
1 parent 6697939 commit 3573c8e
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions catalog/ui/src/app/Catalog/Catalog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ import {
HIDDEN_LABELS,
CUSTOM_LABELS,
setLastFilter,
getIsDisabled,
getStatus,
} from './catalog-utils';
import CatalogCategorySelector from './CatalogCategorySelector';
import CatalogInterfaceDescription from './CatalogInterfaceDescription';
Expand Down Expand Up @@ -403,13 +405,23 @@ const Catalog: React.FC<{ userHasRequiredPropertiesToAccess: boolean }> = ({ use
return [catalogItemsFuse, catalogItemsCpy];
}, [catalogItems, selectedCategory, selectedLabels, compareCatalogItems, selectedAdminFilter]);

const catalogItemsResult = useMemo(
() =>
searchString
? _catalogItems.search("'" + searchString.split(' ').join(" '")).map((x) => x.item)
: _catalogItemsCpy,
[searchString, _catalogItems, _catalogItemsCpy]
);
const catalogItemsResult = useMemo(() => {
const items = searchString
? _catalogItems.search("'" + searchString.split(' ').join(" '")).map((x) => x.item)
: _catalogItemsCpy;
const operationalItems = [];
const disabledItems = [];
for (let catalogItem of items) {
const isDisabled = getIsDisabled(catalogItem);
const { code: status } = getStatus(catalogItem);
if (status === 'under-maintenance' || isDisabled) {
disabledItems.push(catalogItem);
} else {
operationalItems.push(catalogItem);
}
}
return operationalItems.concat(disabledItems);
}, [searchString, _catalogItems, _catalogItemsCpy]);

const openCatalogItem =
openCatalogItemName && openCatalogItemNamespaceName
Expand Down

0 comments on commit 3573c8e

Please sign in to comment.