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

Replace hamburger menu with delete icon in user management table #2958

Merged
merged 3 commits into from
Apr 6, 2023
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ The types of changes are:

### Changed
* Updated the check for if a user can assign owner roles to be scope-based instead of role-based [#2964](https://github.com/ethyca/fides/pull/2964)
* Replaced menu in user management table with delete icon [#2958](https://github.com/ethyca/fides/pull/2958)

### Developer Experience
* Nox commands for git tagging to support feature branch builds [#2979](https://github.com/ethyca/fides/pull/2979)
Expand Down
10 changes: 1 addition & 9 deletions clients/admin-ui/cypress/e2e/user-management.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@ describe("User management", () => {
cy.visit("/user-management");
cy.wait("@getAllUsers");

// try via the menu button
cy.getByTestId(`row-${USER_1_ID}`).within(() => {
cy.getByTestId("menu-btn").should("not.exist");
});

// try via clicking the row
cy.getByTestId(`row-${USER_1_ID}`).click();
cy.url().should("not.contain", "profile");
Expand Down Expand Up @@ -211,10 +206,7 @@ describe("User management", () => {
it("can delete a user via the menu", () => {
cy.visit("/user-management");
cy.getByTestId(`row-${USER_1_ID}`).within(() => {
cy.getByTestId("menu-btn").click();
});
cy.getByTestId(`menu-${USER_1_ID}`).within(() => {
cy.getByTestId("delete-btn").click();
cy.getByTestId("delete-user-btn").click();
});
cy.getByTestId("delete-user-modal");
cy.getByTestId("submit-btn").should("be.disabled");
Expand Down
57 changes: 11 additions & 46 deletions clients/admin-ui/src/features/user-management/UserManagementRow.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
import {
Badge,
Button,
ButtonGroup,
Menu,
MenuButton,
MenuItem,
MenuList,
MoreIcon,
Portal,
IconButton,
Td,
Text,
Tr,
useDisclosure,
} from "@fidesui/react";
import { TrashCanSolidIcon } from "common/Icon/TrashCanSolidIcon";
import { useRouter } from "next/router";
import React from "react";
import {
Expand Down Expand Up @@ -123,46 +117,17 @@ const UserManagementRow: React.FC<UserManagementRowProps> = ({ user }) => {
<Td pl={0} py={1} onClick={handleEditUser}>
{user.created_at ? new Date(user.created_at).toUTCString() : null}
</Td>
<Restrict
scopes={[
ScopeRegistryEnum.USER_UPDATE,
ScopeRegistryEnum.USER_DELETE,
]}
>
<Restrict scopes={[ScopeRegistryEnum.USER_DELETE]}>
<Td pr={0} py={1} textAlign="end" position="relative">
<ButtonGroup>
<Menu>
<MenuButton
as={Button}
size="xs"
bg="white"
data-testid="menu-btn"
>
<MoreIcon color="gray.700" w={18} h={18} />
</MenuButton>
<Portal>
<MenuList shadow="xl" data-testid={`menu-${user.id}`}>
<Restrict scopes={[ScopeRegistryEnum.USER_UPDATE]}>
<MenuItem
_focus={{ color: "complimentary.500", bg: "gray.100" }}
onClick={handleEditUser}
data-testid="edit-btn"
>
<Text fontSize="sm">Edit</Text>
</MenuItem>
</Restrict>
<Restrict scopes={[ScopeRegistryEnum.USER_DELETE]}>
<MenuItem
_focus={{ color: "complimentary.500", bg: "gray.100" }}
onClick={deleteModal.onOpen}
data-testid="delete-btn"
>
<Text fontSize="sm">Delete</Text>
</MenuItem>
</Restrict>
</MenuList>
</Portal>
</Menu>
<IconButton
eastandwestwind marked this conversation as resolved.
Show resolved Hide resolved
aria-label="delete"
icon={<TrashCanSolidIcon />}
variant="outline"
size="sm"
onClick={deleteModal.onOpen}
data-testid="delete-user-btn"
/>
</ButtonGroup>
</Td>
</Restrict>
Expand Down