Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add app name filter to archetypes page & drawer link #1673

Merged
merged 2 commits into from
Feb 22, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Invert the expected case
Signed-off-by: Ian Bolton <ibolton@redhat.com>
ibolton336 committed Feb 22, 2024
commit b8f74f1444f0d2fe5d9b056e087cb31a4fb66932
4 changes: 2 additions & 2 deletions client/public/locales/en/translation.json
Original file line number Diff line number Diff line change
@@ -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",
Original file line number Diff line number Diff line change
@@ -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)
),
Original file line number Diff line number Diff line change
@@ -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"> {
@@ -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")} />
@@ -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
@@ -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;
@@ -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")} />
)}
@@ -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} />
);
@@ -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}`;
};

Unchanged files with check annotations Beta

);
export interface IRoute {
path: string;
comp: React.ComponentType<any>;

Check warning on line 66 in client/src/app/Routes.tsx

GitHub Actions / unit-test (18.x)

Unexpected any. Specify a different type
exact?: boolean;
routes?: undefined;
}
identity?: Ref;
createTime?: string;
createUser?: string;
id: any;

Check warning on line 215 in client/src/app/api/models.ts

GitHub Actions / unit-test (18.x)

Unexpected any. Specify a different type
enabled: boolean;
}
export interface TaskgroupTask {
name: string;
data: any;

Check warning on line 372 in client/src/app/api/models.ts

GitHub Actions / unit-test (18.x)

Unexpected any. Specify a different type
application: Ref;
}
id,
path,
formData,
file,

Check warning on line 372 in client/src/app/api/rest.ts

GitHub Actions / unit-test (18.x)

'file' is defined but never used. Allowed unused args must match /^_/u
}: {
id: number;
path: string;
formData: any;

Check warning on line 376 in client/src/app/api/rest.ts

GitHub Actions / unit-test (18.x)

Unexpected any. Specify a different type
file: any;

Check warning on line 377 in client/src/app/api/rest.ts

GitHub Actions / unit-test (18.x)

Unexpected any. Specify a different type
}) => {
return axios.post<Taskgroup>(
`${TASKGROUPS}/${id}/bucket/${path}`,
export class APIClient {
public static request<T>(
path: string,
body: any = null,

Check warning on line 6 in client/src/app/axios-config/apiClient.tsx

GitHub Actions / unit-test (18.x)

Unexpected any. Specify a different type
method:
| "get"
| "post"