-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 Update archetype tags labels to use category color (#1551)
https://issues.redhat.com/browse/MTA-1687 - Removes color until we can persist the color for tags on the backend. --------- Signed-off-by: ibolton336 <[email protected]>
- Loading branch information
1 parent
6e4ae05
commit d215b73
Showing
9 changed files
with
74 additions
and
59 deletions.
There are no files selected for viewing
50 changes: 0 additions & 50 deletions
50
client/src/app/components/labels-from-items/labels-from-items.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
client/src/app/components/labels/labels-from-items/labels-from-items.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from "react"; | ||
import { Label, LabelGroup } from "@patternfly/react-core"; | ||
import { useTranslation } from "react-i18next"; | ||
|
||
export function LabelsFromItems<T extends { name: string }>({ | ||
items, | ||
noneMessage, | ||
}: { | ||
items?: T[]; | ||
noneMessage?: string; | ||
}): JSX.Element { | ||
const { t } = useTranslation(); | ||
|
||
if (items && items.length > 0) { | ||
return ( | ||
<LabelGroup> | ||
{items.map((item, index) => ( | ||
<Label key={index}>{item.name}</Label> | ||
))} | ||
</LabelGroup> | ||
); | ||
} | ||
return <div>{noneMessage || t("terms.none")}</div>; | ||
} |
40 changes: 40 additions & 0 deletions
40
client/src/app/components/labels/labels-from-tags/labels-from-tags.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React from "react"; | ||
import { LabelGroup } from "@patternfly/react-core"; | ||
import { useTranslation } from "react-i18next"; | ||
import { ItemTagLabel } from "../item-tag-label/item-tag-label"; | ||
import { Tag } from "@app/api/models"; | ||
import { useFetchTagCategories } from "@app/queries/tags"; | ||
|
||
export function LabelsFromTags({ | ||
tags, | ||
noneMessage, | ||
}: { | ||
tags?: Tag[]; | ||
noneMessage?: string; | ||
}): JSX.Element { | ||
const { t } = useTranslation(); | ||
const { tagCategories } = useFetchTagCategories(); | ||
|
||
const findCategoryForTag = (tagId: number) => { | ||
return tagCategories.find( | ||
(category) => | ||
category.tags?.some((categoryTag) => categoryTag.id === tagId) | ||
); | ||
}; | ||
|
||
if (tags && tags.length > 0) { | ||
return ( | ||
<LabelGroup> | ||
{tags.map((tag) => { | ||
const tagCategory = findCategoryForTag(tag.id); | ||
|
||
if (!tagCategory) return null; | ||
|
||
return <ItemTagLabel key={tag.id} tag={tag} category={tagCategory} />; | ||
})} | ||
</LabelGroup> | ||
); | ||
} | ||
|
||
return <div>{noneMessage || t("terms.none")}</div>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters