Skip to content

Commit

Permalink
Various 2.9.0 fixes (#2864)
Browse files Browse the repository at this point in the history
  • Loading branch information
allisonking authored Mar 17, 2023
1 parent 95d6e4e commit 8440636
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 78 deletions.
7 changes: 0 additions & 7 deletions clients/admin-ui/cypress/e2e/home.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@ describe("Home page", () => {

describe("permissions", () => {
beforeEach(() => {
// For these tests, let's say we always have systems and connectors
cy.intercept("GET", "/api/v1/system", {
fixture: "systems/systems.json",
}).as("getSystems");
cy.intercept("GET", "/api/v1/connection*", {
fixture: "connectors/list.json",
}).as("getConnectors");
stubPlus(true);
});

Expand Down
5 changes: 5 additions & 0 deletions clients/admin-ui/src/features/common/custom-fields/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ export const useCustomFields = ({
*/
const upsertCustomFields = useCallback(
async (formValues: CustomFieldsFormValues) => {
if (!isEnabled) {
return;
}

// When creating an resource, the fides key may have initially been blank. But by the time the
// form is submitted it must not be blank (not undefined, not an empty string).
const fidesKey = formValues.fides_key || resourceFidesKey;
Expand Down Expand Up @@ -190,6 +194,7 @@ export const useCustomFields = ({
}
},
[
isEnabled,
definitionIdToCustomField,
deleteCustomFieldMutationTrigger,
errorAlert,
Expand Down
4 changes: 2 additions & 2 deletions clients/admin-ui/src/features/common/nav/v2/NavSideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export const NavSideBar = () => {
const router = useRouter();
const nav = useNav({ path: router.pathname });

// Don't render the sidebar if no group is active or if the group only has one link.
if (!nav.active || nav.active.children.length <= 1) {
// Don't render the sidebar if no group is active
if (!nav.active) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const ALL_SCOPES = [
ScopeRegistryEnum.SYSTEM_UPDATE,
ScopeRegistryEnum.CTL_DATASET_CREATE,
ScopeRegistryEnum.USER_UPDATE,
ScopeRegistryEnum.USER_READ,
ScopeRegistryEnum.DATA_CATEGORY_CREATE,
];

Expand Down Expand Up @@ -116,11 +117,6 @@ describe("configureNavGroups", () => {
title: "Home",
children: [{ title: "Home", path: "/" }],
});

expect(navGroups[1]).toMatchObject({
title: "Management",
children: [{ title: "About Fides", path: "/management/about" }],
});
});

it("conditionally shows request manager using scopes", () => {
Expand Down
6 changes: 5 additions & 1 deletion clients/admin-ui/src/features/common/nav/v2/nav-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ export const NAV_CONFIG: NavConfigGroup[] = [
ScopeRegistryEnum.USER_PERMISSION_UPDATE,
],
},
{ title: "About Fides", path: "/management/about", scopes: [] },
{
title: "About Fides",
path: "/management/about",
scopes: [ScopeRegistryEnum.USER_READ], // temporary scope while we don't have a scope for beta features
},
],
},
];
Expand Down
8 changes: 2 additions & 6 deletions clients/admin-ui/src/home/HomeContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,17 @@ const COLUMNS = 3;

const HomeContent: React.FC = () => {
const router = useRouter();
const { connectionsCount, systemsCount, plus } = useFeatures();
const hasConnections = connectionsCount > 0;
const hasSystems = systemsCount > 0;
const { plus } = useFeatures();
const userScopes = useAppSelector(selectThisUsersScopes);

const list = useMemo(
() =>
configureTiles({
config: MODULE_CARD_ITEMS,
hasPlus: plus,
hasConnections,
hasSystems,
userScopes,
}),
[hasConnections, hasSystems, plus, userScopes]
[plus, userScopes]
);

return (
Expand Down
47 changes: 0 additions & 47 deletions clients/admin-ui/src/home/tile-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ describe("configureTiles", () => {
const tiles = configureTiles({
config: MODULE_CARD_ITEMS,
hasPlus: false,
hasSystems: true,
userScopes: ALL_SCOPES_FOR_TILES,
});

Expand All @@ -29,54 +28,11 @@ describe("configureTiles", () => {
const tiles = configureTiles({
config: MODULE_CARD_ITEMS,
hasPlus: true,
hasSystems: true,
userScopes: ALL_SCOPES_FOR_TILES,
});
expect(tiles.filter((t) => t.href === "/datamap").length).toEqual(1);
});

it("can exclude tiles that require systems or connectors", () => {
const tiles = configureTiles({
config: MODULE_CARD_ITEMS,
hasPlus: true,
hasSystems: false,
hasConnections: false,
userScopes: ALL_SCOPES_FOR_TILES,
});
expect(tiles.map((t) => t.name)).toEqual([
"Add systems",
"Configure privacy requests",
]);
});

it("can include tiles that require systems", () => {
const tiles = configureTiles({
config: MODULE_CARD_ITEMS,
hasPlus: true,
hasSystems: true,
userScopes: ALL_SCOPES_FOR_TILES,
});
expect(tiles.map((t) => t.name)).toEqual([
"View data map",
"Add systems",
"View systems",
"Configure privacy requests",
]);
});

it("can include tiles that require connectors", () => {
const tiles = configureTiles({
config: MODULE_CARD_ITEMS,
hasConnections: true,
userScopes: ALL_SCOPES_FOR_TILES,
});
expect(tiles.map((t) => t.name)).toEqual([
"Add systems",
"Configure privacy requests",
"Review privacy requests",
]);
});

describe("configure by scopes", () => {
it("returns no tiles if user has no scopes", () => {
const tiles = configureTiles({
Expand Down Expand Up @@ -116,7 +72,6 @@ describe("configureTiles", () => {
const tiles = configureTiles({
config: MODULE_CARD_ITEMS,
hasPlus: true,
hasSystems: true,
userScopes: [ScopeRegistryEnum.DATAMAP_READ],
});
expect(tiles.map((t) => t.name)).toEqual(["View data map"]);
Expand All @@ -125,7 +80,6 @@ describe("configureTiles", () => {
it("conditionally shows reviewing privacy requests", () => {
const tiles = configureTiles({
config: MODULE_CARD_ITEMS,
hasConnections: true,
userScopes: [ScopeRegistryEnum.PRIVACY_REQUEST_REVIEW],
});
expect(tiles.map((t) => t.name)).toEqual(["Review privacy requests"]);
Expand All @@ -134,7 +88,6 @@ describe("configureTiles", () => {
it("can combine scopes to show multiple tiles", () => {
const tiles = configureTiles({
config: MODULE_CARD_ITEMS,
hasConnections: true,
userScopes: [
ScopeRegistryEnum.PRIVACY_REQUEST_REVIEW,
ScopeRegistryEnum.CONNECTION_CREATE_OR_UPDATE,
Expand Down
10 changes: 0 additions & 10 deletions clients/admin-ui/src/home/tile-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ export const configureTiles = ({
config,
userScopes,
hasPlus = false,
hasSystems = false,
hasConnections = false,
}: {
config: ModuleCardConfig[];
userScopes: ScopeRegistryEnum[];
Expand All @@ -21,14 +19,6 @@ export const configureTiles = ({
filteredConfig = filteredConfig.filter((c) => !c.requiresPlus);
}

if (!hasSystems) {
filteredConfig = filteredConfig.filter((c) => !c.requiresSystems);
}

if (!hasConnections) {
filteredConfig = filteredConfig.filter((c) => !c.requiresConnections);
}

const filteredByScope: ModuleCardConfig[] = [];
filteredConfig.forEach((moduleConfig) => {
if (moduleConfig.scopes.length === 0) {
Expand Down

0 comments on commit 8440636

Please sign in to comment.