Skip to content

Commit

Permalink
✨ Add archetype filter for applications (#1507)
Browse files Browse the repository at this point in the history
https://issues.redhat.com/browse/MTA-1541

Signed-off-by: ibolton336 <ibolton@redhat.com>
  • Loading branch information
ibolton336 authored Nov 2, 2023
1 parent 9eb3dbd commit a797572
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 10 deletions.
19 changes: 9 additions & 10 deletions client/src/app/components/labels-from-items/labels-from-items.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,14 @@ export function LabelsFromItems<T extends { name: string }>({
}): JSX.Element {
const { t } = useTranslation();

if (items?.length ?? 0 === 0) {
return <div>{noneMessage || t("terms.none")}</div>;
if (items && items.length > 0) {
return (
<LabelGroup>
{items.map((item, index) => (
<RandomColorLabel key={index}>{item.name}</RandomColorLabel>
))}
</LabelGroup>
);
}

return (
<LabelGroup>
{items?.map((item, index) => (
<RandomColorLabel key={index}>{item.name}</RandomColorLabel>
))}
</LabelGroup>
);
return <div>{noneMessage || t("terms.none")}</div>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,35 @@ export const ApplicationsTable: React.FC = () => {
}) + "...",
getItemValue: (item) => item?.name || "",
},
{
key: "archetype",
title: t("terms.archetype"),
type: FilterType.multiselect,
placeholderText:
t("actions.filterBy", {
what: t("terms.archetype").toLowerCase(),
}) + "...",
getItemValue: (item) => {
const archetypeNames = item?.archetypes
?.map((archetype) => archetype.name)
.join("");
return archetypeNames || "";
},
selectOptions: [
...new Set(
applications
.flatMap(
(application) =>
application?.archetypes?.map((archetype) => archetype.name)
)
.filter(Boolean)
),
].map((archetypeName) => ({
key: archetypeName,
value: archetypeName,
})),
logicOperator: "OR",
},
{
key: "description",
title: t("terms.description"),
Expand Down

0 comments on commit a797572

Please sign in to comment.