Skip to content

Commit

Permalink
Invert the expected case
Browse files Browse the repository at this point in the history
  • Loading branch information
ibolton336 committed Feb 21, 2024
1 parent edd8406 commit 4ebdfb3
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 37 deletions.
4 changes: 2 additions & 2 deletions client/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -256,16 +256,16 @@
"analysis": "Analysis",
"answer": "Answer",
"application": "Application",
"application_plural": "Applications",
"applicationReview": "Application review",
"application(s)": "Application(s)",
"applications": "Applications",
"applicationImports": "Application imports",
"applicationName": "Application name",
"archetypeName": "Archetype name",
"applicationInformation": "Application information",
"applications": "Applications",
"archetype": "Archetype",
"archetypes": "Archetypes",
"archetypes_singular": "Archetype",
"archetypes_plural": "Archetypes",
"artifact": "Artifact",
"artifactAssociated": "Associated artifact",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,9 @@ export const ApplicationsTable: React.FC = () => {
selectOptions: [
...new Set(
applications
.flatMap((application) =>
application?.archetypes?.map((archetype) => archetype.name)
.flatMap(
(application) =>
application?.archetypes?.map((archetype) => archetype.name)
)
.filter(Boolean)
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ import { RiskLabel } from "@app/components/RiskLabel";
import { ApplicationDetailFields } from "./application-detail-fields";
import { useFetchArchetypes } from "@app/queries/archetypes";
import { AssessedArchetypes } from "./components/assessed-archetypes";
import { serializeFilterUrlParams } from "@app/hooks/table-controls";
import { Paths } from "@app/Paths";

export interface IApplicationDetailDrawerProps
extends Pick<IPageDrawerContentProps, "onCloseClick"> {
Expand Down Expand Up @@ -194,16 +192,15 @@ export const ApplicationDetailDrawer: React.FC<
<DescriptionListDescription>
{application?.archetypes?.length ? (
<>
<Link to={getArchetypesUrl(application?.name)}>
{application.archetypes.length}{" "}
{t("terms.archetypes", {
count: application.archetypes.length,
context:
application.archetypes.length > 1
? "plural"
: "singular",
}).toLocaleLowerCase()}{" "}
</Link>
<DescriptionListDescription>
{application.archetypes.length ?? 0 > 0 ? (
<ArchetypeLabels
archetypeRefs={application.archetypes as Ref[]}
/>
) : (
<EmptyTextMessage message={t("terms.none")} />
)}
</DescriptionListDescription>
</>
) : (
<EmptyTextMessage message={t("terms.none")} />
Expand Down Expand Up @@ -453,16 +450,3 @@ const ArchetypeLabels: React.FC<{ archetypeRefs?: Ref[] }> = ({
const ArchetypeItem: React.FC<{ archetype: Archetype }> = ({ archetype }) => {
return <Label color="grey">{archetype.name}</Label>;
};

const getArchetypesUrl = (applicationName: string) => {
const filterValues = {
"application.name": [applicationName],
};

const serializedParams = serializeFilterUrlParams(filterValues);

const queryString = serializedParams.filters
? `filters=${serializedParams.filters}`
: "";
return `${Paths.archetypes}?${queryString}`;
};
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ import { LabelsFromItems } from "@app/components/labels/labels-from-items/labels
import { ReviewFields } from "@app/pages/applications/components/application-detail-drawer/review-fields";
import { RiskLabel } from "@app/components/RiskLabel";
import { LabelsFromTags } from "@app/components/labels/labels-from-tags/labels-from-tags";
import { serializeFilterUrlParams } from "@app/hooks/table-controls";
import { Paths } from "@app/Paths";
import { Link } from "react-router-dom";

export interface IArchetypeDetailDrawerProps {
onCloseClick: () => void;
Expand Down Expand Up @@ -103,10 +106,19 @@ const ArchetypeDetailDrawer: React.FC<IArchetypeDetailDrawerProps> = ({
{t("terms.applications")}
</DescriptionListTerm>
<DescriptionListDescription>
{archetype?.applications?.length ?? 0 > 0 ? (
<ApplicationLabels
applicationRefs={archetype?.applications}
/>
{archetype?.applications?.length ? (
<>
<Link to={getApplicationsUrl(archetype?.name)}>
{archetype.applications.length}{" "}
{t("terms.application", {
count: archetype.applications.length,
context:
archetype.applications.length > 1
? "plural"
: "singular",
}).toLocaleLowerCase()}{" "}
</Link>
</>
) : (
<EmptyTextMessage message={t("terms.none")} />
)}
Expand Down Expand Up @@ -223,10 +235,6 @@ const ArchetypeDetailDrawer: React.FC<IArchetypeDetailDrawerProps> = ({
);
};

const ApplicationLabels: React.FC<{ applicationRefs?: Ref[] }> = ({
applicationRefs,
}) => <LabelsFromItems items={applicationRefs as Ref[]} />;

const TagLabels: React.FC<{ tags?: Tag[] }> = ({ tags }) => (
<LabelsFromTags tags={tags} />
);
Expand All @@ -240,3 +248,16 @@ const StakeholderGroupsLabels: React.FC<{ archetype: Archetype }> = ({
}) => <LabelsFromItems items={archetype.stakeholderGroups as Ref[]} />;

export default ArchetypeDetailDrawer;

const getApplicationsUrl = (archetypeName: string) => {
const filterValues = {
archetypes: [archetypeName],
};

const serializedParams = serializeFilterUrlParams(filterValues);

const queryString = serializedParams.filters
? `filters=${serializedParams.filters}`
: "";
return `${Paths.applications}?${queryString}`;
};

0 comments on commit 4ebdfb3

Please sign in to comment.