From b1f0f5e47949140b0d0be5e3d02079d7719af2f7 Mon Sep 17 00:00:00 2001 From: Shams mosowi Date: Sun, 13 Jun 2021 19:11:57 +1000 Subject: [PATCH] show all tables to ADMIN users --- www/src/contexts/FiretableContext.tsx | 36 ++++++++++++++++----------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/www/src/contexts/FiretableContext.tsx b/www/src/contexts/FiretableContext.tsx index 2526ed83..8c0f2f4e 100644 --- a/www/src/contexts/FiretableContext.tsx +++ b/www/src/contexts/FiretableContext.tsx @@ -13,7 +13,7 @@ import { useSnackContext } from "./SnackContext"; import { SideDrawerRef } from "components/SideDrawer"; import { ColumnMenuRef } from "components/Table/ColumnMenu"; import { ImportWizardRef } from "components/Wizards/ImportWizard"; -import _find from 'lodash/find'; +import _find from "lodash/find"; export type Table = { collection: string; name: string; @@ -111,7 +111,8 @@ export const FiretableContextProvider: React.FC = ({ children }) => { const filteredTables = _sortBy(tables, "name") .filter( (table) => - !table.roles || table.roles.some((role) => userRoles.includes(role)) + userRoles.includes("ADMIN") || + table.roles.some((role) => userRoles.includes(role)) ) .map((table) => ({ ...table, @@ -157,20 +158,25 @@ export const FiretableContextProvider: React.FC = ({ children }) => { [fieldName]: value, _ft_updatedAt, _ft_updatedBy, - } - tableActions.row.update(ref,update, () => { - if (onSuccess) onSuccess(ref, fieldName, value); - },(error) => { - if (error.code === "permission-denied") { - open({ - message: `You don't have permissions to make this change`, - variant: "error", - duration: 2000, - position: { horizontal: "center", vertical: "top" }, - }); + }; + tableActions.row.update( + ref, + update, + () => { + if (onSuccess) onSuccess(ref, fieldName, value); + }, + (error) => { + if (error.code === "permission-denied") { + open({ + message: `You don't have permissions to make this change`, + variant: "error", + duration: 2000, + position: { horizontal: "center", vertical: "top" }, + }); + } } - }) - } + ); + }; // A ref to the data grid. Contains data grid functions const dataGridRef = useRef(null);