Skip to content

Commit

Permalink
🐛 Add lists of associated apps & archetypes (#1470)
Browse files Browse the repository at this point in the history
https://issues.redhat.com/browse/MTA-1384?filter=12422675

Signed-off-by: ibolton336 <ibolton@redhat.com>
  • Loading branch information
ibolton336 authored Oct 12, 2023
1 parent 53ecc75 commit 02a81ce
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 11 deletions.
2 changes: 2 additions & 0 deletions client/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@
"terms": {
"accepted": "Accepted",
"acceptedAppsAndDeps": "Accepted applications and dependencies",
"associatedApplications": "Associated applications",
"associatedArchetypes": "Associated archetypes",
"add": "Add",
"additionalNotesOrComments": "Additional notes or comments",
"adoptionCandidateDistribution": "Assessment confidence and risk",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ import {
Text,
Title,
Label,
LabelGroup,
} from "@patternfly/react-core";
import spacing from "@patternfly/react-styles/css/utilities/Spacing/spacing";

import { EmptyTextMessage } from "@app/components/EmptyTextMessage";
import { EFFORT_ESTIMATE_LIST, PROPOSED_ACTION_LIST } from "@app/Constants";
import { Task } from "@app/api/models";
import { Ref, Task } from "@app/api/models";
import { ApplicationRisk } from "./application-risk";
import {
ApplicationDetailDrawer,
Expand Down Expand Up @@ -52,6 +53,18 @@ export const ApplicationDetailDrawerAssessment: React.FC<
default: "14ch",
}}
>
<DescriptionListGroup>
<DescriptionListTerm>{t("terms.archetypes")}</DescriptionListTerm>
<DescriptionListDescription>
{application?.archetypes?.length ?? 0 > 0 ? (
<ArchetypeLabels
archetypeRefs={application?.archetypes as Ref[]}
/>
) : (
<EmptyTextMessage message={t("terms.none")} />
)}
</DescriptionListDescription>
</DescriptionListGroup>
<DescriptionListGroup>
<DescriptionListTerm>
{t("terms.proposedAction")}
Expand Down Expand Up @@ -134,3 +147,17 @@ export const ApplicationDetailDrawerAssessment: React.FC<
/>
);
};
const ArchetypeLabels: React.FC<{ archetypeRefs?: Ref[] }> = ({
archetypeRefs,
}) =>
(archetypeRefs?.length ?? 0) === 0 ? null : (
<LabelGroup>
{(archetypeRefs as Ref[])
.sort((a, b) => a.name.localeCompare(b.name))
.map((ref) => (
<Label color="grey" key={ref.id}>
{ref.name}
</Label>
))}
</LabelGroup>
);
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import "./archetype-detail-drawer.css";
import React, { useMemo } from "react";
import { useTranslation } from "react-i18next";

Expand All @@ -16,12 +17,10 @@ import {
} from "@patternfly/react-core";
import spacing from "@patternfly/react-styles/css/utilities/Spacing/spacing";

import { Archetype, Tag, TagRef } from "@app/api/models";
import { Archetype, Ref, Tag, TagRef } from "@app/api/models";
import { EmptyTextMessage } from "@app/components/EmptyTextMessage";
import { PageDrawerContent } from "@app/components/PageDrawerContext";
import { useFetchTagCategories } from "@app/queries/tags";

import "./archetype-detail-drawer.css";
import { dedupeArrayOfObjects } from "@app/utils/utils";

export interface IArchetypeDetailDrawerProps {
Expand All @@ -35,12 +34,6 @@ const ArchetypeDetailDrawer: React.FC<IArchetypeDetailDrawerProps> = ({
}) => {
const { t } = useTranslation();

const { tagCategories } = useFetchTagCategories();
const tags = useMemo(
() => tagCategories.flatMap((tc) => tc.tags).filter(Boolean),
[tagCategories]
);

const manualTags: TagRef[] = useMemo(() => {
const rawManualTags: TagRef[] =
archetype?.tags?.filter((t) => !t?.source) ?? [];
Expand All @@ -52,7 +45,7 @@ const ArchetypeDetailDrawer: React.FC<IArchetypeDetailDrawerProps> = ({
archetype?.tags?.filter((t) => t?.source === "assessment") ?? [];
return dedupeArrayOfObjects<TagRef>(rawAssessmentTags, "name");
}, [archetype?.tags]);

console.log("archetype", archetype);
return (
<PageDrawerContent
isExpanded={!!archetype}
Expand Down Expand Up @@ -80,6 +73,17 @@ const ArchetypeDetailDrawer: React.FC<IArchetypeDetailDrawerProps> = ({
</DescriptionListDescription>
</DescriptionListGroup>

<DescriptionListGroup>
<DescriptionListTerm>{t("terms.applications")}</DescriptionListTerm>
<DescriptionListDescription>
{archetype?.applications?.length ?? 0 > 0 ? (
<ApplicationLabels applicationRefs={archetype?.applications} />
) : (
<EmptyTextMessage message={t("terms.none")} />
)}
</DescriptionListDescription>
</DescriptionListGroup>

<DescriptionListGroup>
<DescriptionListTerm>{t("terms.tagsCriteria")}</DescriptionListTerm>
<DescriptionListDescription>
Expand Down Expand Up @@ -164,6 +168,21 @@ const ArchetypeDetailDrawer: React.FC<IArchetypeDetailDrawerProps> = ({
);
};

const ApplicationLabels: React.FC<{ applicationRefs?: Ref[] }> = ({
applicationRefs,
}) =>
(applicationRefs?.length ?? 0) === 0 ? null : (
<LabelGroup>
{(applicationRefs as Ref[])
.sort((a, b) => a.name.localeCompare(b.name))
.map((ref) => (
<Label color="grey" key={ref.id}>
{ref.name}
</Label>
))}
</LabelGroup>
);

const TagLabels: React.FC<{ tags?: Tag[] }> = ({ tags }) =>
(tags?.length ?? 0) === 0 ? null : (
<LabelGroup>
Expand Down

0 comments on commit 02a81ce

Please sign in to comment.