From 22c629138b8b338071ded6f34bc6cb1249203046 Mon Sep 17 00:00:00 2001 From: Moshe Immermam Date: Thu, 31 Oct 2024 22:39:59 +0200 Subject: [PATCH] fix: undefined error in permissions table --- .../Permissions/PermissionsTable.tsx | 12 ++++++-- .../Permissions/PermissionsView.tsx | 4 +-- src/pages/incident/IncidentListPage.tsx | 2 +- src/ui/MRTDataTable/MRTDataTable.tsx | 30 ++++++++++--------- 4 files changed, 29 insertions(+), 19 deletions(-) diff --git a/src/components/Permissions/PermissionsTable.tsx b/src/components/Permissions/PermissionsTable.tsx index d3a3adbbc..b83eb3d2d 100644 --- a/src/components/Permissions/PermissionsTable.tsx +++ b/src/components/Permissions/PermissionsTable.tsx @@ -11,6 +11,7 @@ import PlaybookSpecIcon from "../Playbooks/Settings/PlaybookSpecIcon"; import { TopologyLink } from "../Topology/TopologyLink"; import { permissionObjectList } from "./ManagePermissions/Forms/FormikPermissionSelectResourceFields"; import { permissionsActionsList } from "./PermissionsView"; +import { BsBan } from "react-icons/bs"; const permissionsTableColumns: MRT_ColumnDef[] = [ { @@ -90,8 +91,15 @@ const permissionsTableColumns: MRT_ColumnDef[] = [ return (
- {actionLabel ?? action} - {deny && } + + {actionLabel ?? action} + {deny && ( + + )} +
); } diff --git a/src/components/Permissions/PermissionsView.tsx b/src/components/Permissions/PermissionsView.tsx index a26769fdb..c0f32e0d0 100644 --- a/src/components/Permissions/PermissionsView.tsx +++ b/src/components/Permissions/PermissionsView.tsx @@ -21,8 +21,8 @@ export const permissionsActionsList: FormikSelectDropdownOption[] = [ { value: "ActionDelete", label: "delete" }, { value: "ActionAll", label: "*" }, { value: "ActionCRUD", label: "create,read,update,delete" }, - { value: "ActionRun", label: "run" }, - { value: "ActionApprove", label: "approve" } + { value: "ActionRun", label: "playbook:run" }, + { value: "ActionApprove", label: "playbook:approve" } ]; type PermissionsViewProps = { diff --git a/src/pages/incident/IncidentListPage.tsx b/src/pages/incident/IncidentListPage.tsx index 50fe61f8b..50648989a 100644 --- a/src/pages/incident/IncidentListPage.tsx +++ b/src/pages/incident/IncidentListPage.tsx @@ -1,6 +1,6 @@ import { useQuery } from "@tanstack/react-query"; import { useState } from "react"; -import { AiFillPlusCircle } from "react-icons/ai/"; +import { AiFillPlusCircle } from "react-icons/ai"; import { useNavigate, useSearchParams } from "react-router-dom"; import { getIncidentsSummary } from "../../api/services/incident"; import FilterIncidents from "../../components/Incidents/FilterIncidents/FilterIncidents"; diff --git a/src/ui/MRTDataTable/MRTDataTable.tsx b/src/ui/MRTDataTable/MRTDataTable.tsx index 2d3c451b9..4f8840290 100644 --- a/src/ui/MRTDataTable/MRTDataTable.tsx +++ b/src/ui/MRTDataTable/MRTDataTable.tsx @@ -7,17 +7,13 @@ import { MRT_ColumnDef, MRT_Row, MRT_TableInstance, - useMantineReactTable + useMantineReactTable, + MantineReactTable, + MRT_TableOptions } from "mantine-react-table"; -import dynamic from "next/dynamic"; import useReactTablePaginationState from "../DataTable/Hooks/useReactTablePaginationState"; import useReactTableSortState from "../DataTable/Hooks/useReactTableSortState"; -const MantineReactTable = dynamic( - () => import("mantine-react-table").then((mod) => mod.MantineReactTable), - { ssr: false } -); - type MRTDataTableProps = {}> = { data: T[]; columns: MRT_ColumnDef[]; @@ -50,7 +46,7 @@ export default function MRTDataTable = {}>({ onRowClick = () => {}, isLoading = false, disablePagination = false, - enableServerSideSorting = undefined, + enableServerSideSorting = false, enableServerSidePagination = false, enableGrouping = false, manualPageCount, @@ -65,7 +61,7 @@ export default function MRTDataTable = {}>({ const { pageIndex, pageSize, setPageIndex } = useReactTablePaginationState(); const [sortState, setSortState] = useReactTableSortState(); - const table = useMantineReactTable({ + const options = { data: data, columns: columns, enableGlobalFilter: false, @@ -74,6 +70,7 @@ export default function MRTDataTable = {}>({ enableSelectAll: false, enableFullScreenToggle: false, layoutMode: "grid", + enableTopToolbar: false, enableColumnResizing: true, enableStickyHeader: true, enableTableFooter: true, @@ -108,7 +105,7 @@ export default function MRTDataTable = {}>({ } }), enablePagination: !disablePagination, - enableExpandAll: true, + enableExpandAll: enableGrouping, mantineTableContainerProps: { sx: { flex: "1 1 0" @@ -133,9 +130,11 @@ export default function MRTDataTable = {}>({ return acc; }, {}) }, - initialState: { - expanded: expandAllRows ? true : undefined - }, + initialState: expandAllRows + ? { + expanded: true + } + : undefined, mantinePaginationProps: { rowsPerPageOptions: ["50", "100", "200"] }, @@ -145,8 +144,11 @@ export default function MRTDataTable = {}>({ mantineExpandAllButtonProps: { size: "xs" }, + renderDetailPanel - }); + } as MRT_TableOptions; + + const table = useMantineReactTable(options); // @ts-expect-error return ;