Skip to content

Commit

Permalink
✨ Add archetype filter for applications
Browse files Browse the repository at this point in the history
  • Loading branch information
ibolton336 committed Nov 1, 2023
1 parent 2f8d58f commit 7050b40
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 11 deletions.
23 changes: 12 additions & 11 deletions client/src/app/components/labels-from-items/labels-from-items.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,17 @@ export function LabelsFromItems<T extends { name: string }>({
noneMessage?: string;
}): JSX.Element {
const { t } = useTranslation();

if (items?.length ?? 0 === 0) {
return <div>{noneMessage || t("terms.none")}</div>;
console.log("items", items);

// Check if items is not undefined and has length greater than 0
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 7050b40

Please sign in to comment.