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

[MERGE] main -> staging post TT release. #720

Merged
merged 2 commits into from
Dec 2, 2024
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
22 changes: 22 additions & 0 deletions src/admin/components/Actions/ListActionsCreateFilter.tsx
Original file line number Diff line number Diff line change
@@ -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) => (
<TopToolbar>
<When condition={isSuperAdmin}>
<CreateButton className="filter-button-page-admin" />
</When>
<FilterButton className="filter-button-page-admin" />
<When condition={!!onExport}>
<Button className="button-page-admin" label="Export" startIcon={<DownloadIcon />} onClick={onExport} />
</When>
</TopToolbar>
);

export default ListActionsCreateFilter;
6 changes: 4 additions & 2 deletions src/admin/modules/user/components/UserList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -90,6 +91,7 @@ const UserDataGrid = () => {

export const UserList = () => {
const [exporting, setExporting] = useState<boolean>(false);
const { isSuperAdmin } = useGetUserRole();

const userDataProvider = useDataProvider<UserDataProvider>();

Expand All @@ -106,7 +108,7 @@ export const UserList = () => {
</Text>
</Stack>

<List actions={<ListActions onExport={handleExport} />} filters={filters}>
<List actions={<ListActionsCreateFilter isSuperAdmin={isSuperAdmin} onExport={handleExport} />} filters={filters}>
<UserDataGrid />
</List>

Expand Down
24 changes: 1 addition & 23 deletions src/admin/modules/user/components/UserShowAside.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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);
Expand Down Expand Up @@ -66,10 +53,6 @@ export const UserShowAside = () => {
}
});

const handleCreateUser = () => {
redirect("create", "user");
};

return (
<>
<Aside title="User Review">
Expand All @@ -94,11 +77,6 @@ export const UserShowAside = () => {
<Divider />
<Box pt={2}>
<Stack direction="row" alignItems="center" gap={2} flexWrap="wrap">
<When condition={isSuperAdmin}>
<Button variant="contained" onClick={handleCreateUser}>
Create User
</Button>
</When>
<Button
variant="contained"
onClick={() =>
Expand Down
Loading