From 2df8bc50c351a617963da9643f9bb0286b2ab0ce Mon Sep 17 00:00:00 2001
From: cesarLima1 <105736261+cesarLima1@users.noreply.github.com>
Date: Wed, 27 Nov 2024 12:10:56 -0400
Subject: [PATCH] [TM-1385] change position of create user button to user list
in admin view (#709)
---
.../Actions/ListActionsCreateFilter.tsx | 22 +++++++++++++++++
.../modules/user/components/UserList.tsx | 6 +++--
.../modules/user/components/UserShowAside.tsx | 24 +------------------
3 files changed, 27 insertions(+), 25 deletions(-)
create mode 100644 src/admin/components/Actions/ListActionsCreateFilter.tsx
diff --git a/src/admin/components/Actions/ListActionsCreateFilter.tsx b/src/admin/components/Actions/ListActionsCreateFilter.tsx
new file mode 100644
index 000000000..d47a81d90
--- /dev/null
+++ b/src/admin/components/Actions/ListActionsCreateFilter.tsx
@@ -0,0 +1,22 @@
+import DownloadIcon from "@mui/icons-material/GetApp";
+import { Button, CreateButton, FilterButton, TopToolbar } from "react-admin";
+import { When } from "react-if";
+
+interface ListActionsCreateFilterProps {
+ isSuperAdmin?: boolean;
+ onExport?: () => void;
+}
+
+const ListActionsCreateFilter = ({ isSuperAdmin, onExport }: ListActionsCreateFilterProps) => (
+
+
+
+
+
+
+ } onClick={onExport} />
+
+
+);
+
+export default ListActionsCreateFilter;
diff --git a/src/admin/modules/user/components/UserList.tsx b/src/admin/modules/user/components/UserList.tsx
index 4bc4005a7..82d671795 100644
--- a/src/admin/modules/user/components/UserList.tsx
+++ b/src/admin/modules/user/components/UserList.tsx
@@ -17,8 +17,9 @@ import {
} from "react-admin";
import { UserDataProvider } from "@/admin/apiProvider/dataProviders/userDataProvider";
-import ListActions from "@/admin/components/Actions/ListActions";
+import ListActionsCreateFilter from "@/admin/components/Actions/ListActionsCreateFilter";
import ExportProcessingAlert from "@/admin/components/Alerts/ExportProcessingAlert";
+import { useGetUserRole } from "@/admin/hooks/useGetUserRole";
import Menu from "@/components/elements/Menu/Menu";
import { MENU_PLACEMENT_BOTTOM_LEFT } from "@/components/elements/Menu/MenuVariant";
import Text from "@/components/elements/Text/Text";
@@ -90,6 +91,7 @@ const UserDataGrid = () => {
export const UserList = () => {
const [exporting, setExporting] = useState(false);
+ const { isSuperAdmin } = useGetUserRole();
const userDataProvider = useDataProvider();
@@ -106,7 +108,7 @@ export const UserList = () => {
-
} filters={filters}>
+
} filters={filters}>
diff --git a/src/admin/modules/user/components/UserShowAside.tsx b/src/admin/modules/user/components/UserShowAside.tsx
index 4f3452063..98eceb699 100644
--- a/src/admin/modules/user/components/UserShowAside.tsx
+++ b/src/admin/modules/user/components/UserShowAside.tsx
@@ -1,20 +1,9 @@
import { Box, Button, Divider, Grid, Stack, Typography } from "@mui/material";
import { useState } from "react";
-import {
- BooleanField,
- RaRecord,
- SelectField,
- TextField,
- useNotify,
- useRedirect,
- useRefresh,
- useShowContext
-} from "react-admin";
-import { When } from "react-if";
+import { BooleanField, RaRecord, SelectField, TextField, useNotify, useRefresh, useShowContext } from "react-admin";
import Aside from "@/admin/components/Aside/Aside";
import { ConfirmationDialog } from "@/admin/components/Dialogs/ConfirmationDialog";
-import { useGetUserRole } from "@/admin/hooks/useGetUserRole";
import { ResetPasswordDialog } from "@/admin/modules/user/components/ResetPasswordDialog";
import {
usePatchV2AdminUsersVerifyUUID,
@@ -29,8 +18,6 @@ import { userPrimaryRoleChoices } from "../const";
export const UserShowAside = () => {
const notify = useNotify();
const refresh = useRefresh();
- const redirect = useRedirect();
- const { isSuperAdmin } = useGetUserRole();
const [showResetPasswordDialog, setShowResetPasswordDialog] = useState(false);
const [showVerifyEmailDialog, setShowVerifyEmailDialog] = useState(false);
@@ -66,10 +53,6 @@ export const UserShowAside = () => {
}
});
- const handleCreateUser = () => {
- redirect("create", "user");
- };
-
return (
<>