show all tables to ADMIN users

This commit is contained in:
Shams mosowi
2021-06-13 19:11:57 +10:00
parent 068a3cd5f4
commit b1f0f5e479

View File

@@ -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<DataGridHandle>(null);