-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 Archetype table, applications column is now a link (#2024)
When an archetype matches at least 1 application, render a link in the application columns that will navigate the user to the application table with a filter applied to show all of the applications matched to the archetype. The `Link` component is now shared between the archetype table and the archetype detail drawer. Resolves: https://issues.redhat.com/browse/MTA-1390 Signed-off-by: Scott J Dickerson <[email protected]>
- Loading branch information
Showing
4 changed files
with
55 additions
and
59 deletions.
There are no files selected for viewing
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
25 changes: 0 additions & 25 deletions
25
client/src/app/pages/archetypes/components/archetype-applications-column.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
46 changes: 46 additions & 0 deletions
46
client/src/app/pages/archetypes/components/link-to-archetype-applications.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,46 @@ | ||
import React from "react"; | ||
import { useTranslation } from "react-i18next"; | ||
import { Link } from "react-router-dom"; | ||
import { Text } from "@patternfly/react-core"; | ||
|
||
import type { Archetype } from "@app/api/models"; | ||
import { serializeFilterUrlParams } from "@app/hooks/table-controls"; | ||
import { Paths } from "@app/Paths"; | ||
|
||
const getApplicationsUrl = (archetypeName?: string) => { | ||
if (!archetypeName) return ""; | ||
|
||
const filterValues = { | ||
archetypes: [archetypeName], | ||
}; | ||
|
||
const serializedParams = serializeFilterUrlParams(filterValues); | ||
|
||
const queryString = serializedParams.filters | ||
? `filters=${serializedParams.filters}` | ||
: ""; | ||
return `${Paths.applications}?${queryString}`; | ||
}; | ||
|
||
const LinkToArchetypeApplications: React.FC<{ | ||
archetype: Archetype | null | undefined; | ||
noApplicationsMessage?: React.ReactNode; | ||
}> = ({ archetype, noApplicationsMessage }) => { | ||
const { t } = useTranslation(); | ||
|
||
const hasApplications = (archetype?.applications?.length ?? 0) > 0; | ||
|
||
return !hasApplications && noApplicationsMessage ? ( | ||
<>{noApplicationsMessage}</> | ||
) : !hasApplications && !noApplicationsMessage ? ( | ||
<Text>{t("message.archetypeNoApplications")}</Text> | ||
) : ( | ||
<Link to={getApplicationsUrl(archetype?.name)}> | ||
{t("message.archetypeApplicationCount", { | ||
count: archetype?.applications?.length ?? 0, | ||
})} | ||
</Link> | ||
); | ||
}; | ||
|
||
export default LinkToArchetypeApplications; |