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

Route for individual systems #2902

Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ The types of changes are:
* Changed UI paths in the admin-ui [#2869](https://github.com/ethyca/fides/pull/2892)
* `/add-systems/new` --> `/add-systems/manual`
* `/system` --> `/systems`
* Added individual ID routes for systems [#2902](https://github.com/ethyca/fides/pull/2902)

## [2.9.1](https://github.com/ethyca/fides/compare/2.9.0...2.9.1)

Expand Down
10 changes: 4 additions & 6 deletions clients/admin-ui/cypress/e2e/systems-plus.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ describe("System management with Plus features", () => {
cy.intercept("GET", "/api/v1/system", {
fixture: "systems/systems.json",
}).as("getSystems");
cy.visit(SYSTEM_ROUTE);
});

describe("custom metadata", () => {
Expand Down Expand Up @@ -53,10 +52,7 @@ describe("System management with Plus features", () => {
});

it("can populate initial custom metadata", () => {
cy.getByTestId("system-fidesctl_system").within(() => {
cy.getByTestId("more-btn").click();
cy.getByTestId("edit-btn").click();
});
cy.visit(`${SYSTEM_ROUTE}/configure/demo_analytics_system`);

// Should not be able to save while form is untouched
cy.getByTestId("save-btn").should("be.disabled");
Expand All @@ -76,7 +72,9 @@ describe("System management with Plus features", () => {
expect(interception.request.body.id).to.eql(
"id-custom-field-pokemon-party"
);
expect(interception.request.body.resource_id).to.eql("fidesctl_system");
expect(interception.request.body.resource_id).to.eql(
"demo_analytics_system"
);
expect(interception.request.body.value).to.eql([
"Charmander",
"Eevee",
Expand Down
56 changes: 39 additions & 17 deletions clients/admin-ui/cypress/e2e/systems.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,15 +255,35 @@ describe("System management page", () => {
beforeEach(() => {
stubSystemCrud();
stubTaxonomyEntities();
cy.fixture("systems/systems.json").then((systems) => {
cy.intercept("GET", "/api/v1/system/*", {
body: systems[0],
}).as("getFidesctlSystem");
});
cy.visit(SYSTEM_ROUTE);
});

it("Can go directly to a system's edit page", () => {
cy.visit("/systems/configure/fidesctl_system");
cy.getByTestId("input-name").should("have.value", "Fidesctl System");

cy.intercept("GET", "/api/v1/system/*", {
statusCode: 404,
}).as("getNotFoundSystem");

// and can render a not found state
cy.visit("/systems/configure/system-that-does-not-exist");
cy.getByTestId("system-not-found");
});

it("Can go through the edit flow", () => {
cy.getByTestId("system-fidesctl_system").within(() => {
cy.getByTestId("more-btn").click();
cy.getByTestId("edit-btn").click();
});
cy.url().should("contain", "/systems/configure");
cy.url().should("contain", "/systems/configure/fidesctl_system");

cy.wait("@getFidesctlSystem");

// check that the form has the proper values filled in
cy.getByTestId("input-name").should("have.value", "Fidesctl System");
Expand Down Expand Up @@ -414,6 +434,11 @@ describe("System management page", () => {
beforeEach(() => {
stubSystemCrud();
stubTaxonomyEntities();
cy.fixture("systems/systems.json").then((systems) => {
cy.intercept("GET", "/api/v1/system/*", {
body: systems[0],
}).as("getFidesctlSystem");
});
Comment on lines +437 to +441
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that we had different fixtures for 1️⃣ getting a list of systems vs 2️⃣ getting just one system. the tests were pretty dependent on the first system from the list of systems (1️⃣ ), so I made sure to keep that around and index into it, rather than relying on 2️⃣ which had data the tests didn't expect and would've required more changes

});

it("warns when a data use is being added that is already used", () => {
Expand Down Expand Up @@ -443,15 +468,13 @@ describe("System management page", () => {
});

it("warns when a data use is being edited to one that is already used", () => {
cy.intercept("GET", "/api/v1/system", {
fixture: "systems/systems_with_data_uses.json",
}).as("getSystemsWithDataUses");
cy.visit(SYSTEM_ROUTE);
cy.wait("@getSystemsWithDataUses");
cy.getByTestId("system-fidesctl_system").within(() => {
cy.getByTestId("more-btn").click();
cy.getByTestId("edit-btn").click();
cy.fixture("systems/systems_with_data_uses.json").then((systems) => {
cy.intercept("GET", "/api/v1/system/*", {
body: systems[0],
}).as("getFidesctlSystemWithDataUses");
});
cy.visit(`${SYSTEM_ROUTE}/configure/fidesctl_system`);
cy.wait("@getFidesctlSystemWithDataUses");

cy.getByTestId("tab-Data uses").click();
cy.getByTestId("add-btn").click();
Expand All @@ -470,15 +493,14 @@ describe("System management page", () => {

describe("delete privacy declaration", () => {
beforeEach(() => {
cy.intercept("GET", "/api/v1/system", {
fixture: "systems/systems_with_data_uses.json",
}).as("getSystemsWithDataUses");
cy.visit(SYSTEM_ROUTE);
cy.wait("@getSystemsWithDataUses");
cy.getByTestId("system-fidesctl_system").within(() => {
cy.getByTestId("more-btn").click();
cy.getByTestId("edit-btn").click();
cy.fixture("systems/systems_with_data_uses.json").then((systems) => {
cy.intercept("GET", "/api/v1/system/*", {
body: systems[0],
}).as("getFidesctlSystemWithDataUses");
});
cy.visit(`${SYSTEM_ROUTE}/configure/fidesctl_system`);
cy.wait("@getFidesctlSystemWithDataUses");

cy.getByTestId("tab-Data uses").click();
});

Expand Down
2 changes: 1 addition & 1 deletion clients/admin-ui/src/features/system/SystemCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const SystemCard = ({ system }: SystemCardProps) => {

const handleEdit = () => {
dispatch(setActiveSystem(system));
router.push(`${SYSTEM_ROUTE}/configure`);
router.push(`${SYSTEM_ROUTE}/configure/${system.fides_key}`);
};

const handleDelete = async () => {
Expand Down
28 changes: 0 additions & 28 deletions clients/admin-ui/src/pages/systems/configure.tsx

This file was deleted.

75 changes: 75 additions & 0 deletions clients/admin-ui/src/pages/systems/configure/[id].tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import {
Box,
Breadcrumb,
BreadcrumbItem,
Heading,
Spinner,
Text,
} from "@fidesui/react";
import type { NextPage } from "next";
import NextLink from "next/link";
import { useRouter } from "next/router";
import { useEffect } from "react";

import { useAppDispatch } from "~/app/hooks";
import { SYSTEM_ROUTE } from "~/constants";
import Layout from "~/features/common/Layout";
import {
setActiveSystem,
useGetSystemByFidesKeyQuery,
} from "~/features/system";
import EditSystemFlow from "~/features/system/EditSystemFlow";

const ConfigureSystem: NextPage = () => {
const router = useRouter();
const dispatch = useAppDispatch();
let systemId = "";
if (router.query.id) {
systemId = Array.isArray(router.query.id)
? router.query.id[0]
: router.query.id;
}

const { data: system, isLoading } = useGetSystemByFidesKeyQuery(systemId, {
skip: !systemId,
});

useEffect(() => {
dispatch(setActiveSystem(system));
}, [system, dispatch]);

if (isLoading) {
return (
<Layout title="Systems">
<Spinner />
</Layout>
);
}

return (
<Layout title="Systems">
<Heading mb={2} fontSize="2xl" fontWeight="semibold">
Configure your system
</Heading>
<Box mb={8}>
<Breadcrumb fontWeight="medium" fontSize="sm" color="gray.600">
<BreadcrumbItem>
<NextLink href={SYSTEM_ROUTE}>System Connections</NextLink>
</BreadcrumbItem>
<BreadcrumbItem>
<NextLink href="#">Configure your connection</NextLink>
</BreadcrumbItem>
</Breadcrumb>
</Box>
{!system ? (
<Text data-testid="system-not-found">
Could not find a system with id {systemId}
</Text>
) : (
<EditSystemFlow />
)}
</Layout>
);
};

export default ConfigureSystem;