Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions changelog/7942-eng-3461-router-link-legacy-behavior.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
type: Developer Experience
description: Replaced deprecated `next/link` `legacyBehavior`/`passHref` usage in the Admin UI with a shared `RouterLink` component for internal navigation.
pr: 7942
labels: []
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,20 @@ describe("Action center", () => {
// TODO: [HJ-337] uncomment when Add button is implemented
// cy.getByTestId(`add-button-${webMonitorKey}`).should("exist");
// Review button
cy.getByTestId(`review-button-${webMonitorKey}`).should(
"have.attr",
"href",
`${ACTION_CENTER_ROUTE}/${APIMonitorType.WEBSITE}/${webMonitorKey}`,
);
cy.getByTestId(`review-button-${integrationMonitorKey}`).should(
"have.attr",
"href",
`${ACTION_CENTER_ROUTE}/${APIMonitorType.DATASTORE}/${integrationMonitorKey}`,
);
cy.getByTestId(`review-button-${webMonitorKey}`)
.closest("a")
.should(
"have.attr",
"href",
`${ACTION_CENTER_ROUTE}/${APIMonitorType.WEBSITE}/${webMonitorKey}`,
);
cy.getByTestId(`review-button-${integrationMonitorKey}`)
.closest("a")
.should(
"have.attr",
"href",
`${ACTION_CENTER_ROUTE}/${APIMonitorType.DATASTORE}/${integrationMonitorKey}`,
);
});
it.skip("Should paginate results", () => {
// TODO: mock pagination and also test skeleton loading state
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Button, Flex, Form, Input } from "fidesui";
import NextLink from "next/link";
import { useMemo } from "react";

import { RouterLink } from "~/features/common/nav/RouterLink";
import { CONTROLS_ROUTE } from "~/features/common/nav/routes";

import type { Control } from "./access-policies.slice";
Expand Down Expand Up @@ -59,9 +59,9 @@ const ControlForm = ({
<Button type="primary" htmlType="submit" loading={isSubmitting}>
{isEditing ? "Save" : "Create control"}
</Button>
<NextLink href={CONTROLS_ROUTE} passHref>
<RouterLink href={CONTROLS_ROUTE}>
<Button>Cancel</Button>
</NextLink>
</RouterLink>
</Flex>
</Form>
);
Expand Down
26 changes: 8 additions & 18 deletions clients/admin-ui/src/features/access-policies/PolicyCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,16 @@ import {
Tag,
Text,
Tooltip,
Typography,
} from "fidesui";
import NextLink from "next/link";

import { RouterLink } from "~/features/common/nav/RouterLink";
import { ACCESS_POLICY_EDIT_ROUTE } from "~/features/common/nav/routes";

import DecisionTag from "./DecisionTag";
import styles from "./PolicyCard.module.scss";
import { AccessPolicyListItem } from "./types";
import { formatRelativeTime } from "./utils";

const { Link: LinkText } = Typography;

interface PolicyCardProps {
policy: AccessPolicyListItem;
onToggle: (policy: AccessPolicyListItem) => void;
Expand All @@ -34,25 +31,18 @@ const PolicyCard = ({ policy, onToggle }: PolicyCardProps) => {
{/* Header */}
<Flex justify="space-between" align="flex-start">
<Flex gap="small" align="center" className="min-w-0">
{/* legacyBehavior is required: Typography.Link renders <a>, and
Next.js 13 Link also renders <a> — without it we'd get nested anchors */}
<NextLink
<RouterLink
href={{
pathname: ACCESS_POLICY_EDIT_ROUTE,
query: { id: policy.id },
}}
passHref
legacyBehavior
strong
ellipsis
variant="primary"
className={styles.policyName}
>
<LinkText
strong
ellipsis
variant="primary"
className={styles.policyName}
>
{policy.name}
</LinkText>
</NextLink>
{policy.name}
</RouterLink>
</Flex>
<Flex gap="small" align="center" className="shrink-0">
{policy.is_recommendation && (
Expand Down
Loading
Loading