From 441fdf1c624a38eb925d5ae682bf16cc1d7197a2 Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Tue, 16 Mar 2021 13:32:11 -0700 Subject: [PATCH] IO-772 RBAC for RBAC Controls --- client/src/components/rbac-wrapper/rbac-defaults.js | 2 +- .../rbac-wrapper/rbac-wrapper.component.jsx | 12 ++++++++++-- .../shop-info/shop-info.rbac.component.jsx | 5 +++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/client/src/components/rbac-wrapper/rbac-defaults.js b/client/src/components/rbac-wrapper/rbac-defaults.js index 7efcb53bd..0da32826f 100644 --- a/client/src/components/rbac-wrapper/rbac-defaults.js +++ b/client/src/components/rbac-wrapper/rbac-defaults.js @@ -48,7 +48,7 @@ const ret = { "shiftclock:view": 2, "shop:vendors": 2, - "shop:rbac": 5, + "shop:rbac": 1, "shop:templates": 4, "temporarydocs:view": 2, diff --git a/client/src/components/rbac-wrapper/rbac-wrapper.component.jsx b/client/src/components/rbac-wrapper/rbac-wrapper.component.jsx index 81b5093c4..d9fb24870 100644 --- a/client/src/components/rbac-wrapper/rbac-wrapper.component.jsx +++ b/client/src/components/rbac-wrapper/rbac-wrapper.component.jsx @@ -28,10 +28,18 @@ function RbacWrapper({ ...restProps }) { const { t } = useTranslation(); + + console.log( + "********object :>> ", + action, + rbacDefaults[action], + bodyshop.md_rbac[action] + ); if ( (requiredAuthLevel && requiredAuthLevel <= authLevel) || - (bodyshop.md_rbac && bodyshop.md_rbac[action] <= authLevel) || - (!!!bodyshop.md_rbac && rbacDefaults[action] <= authLevel) + ((bodyshop.md_rbac && bodyshop.md_rbac[action]) || rbacDefaults[action]) <= + authLevel || + (!bodyshop.md_rbac && rbacDefaults[action] <= authLevel) ) return
{React.cloneElement(children, restProps)}
; diff --git a/client/src/components/shop-info/shop-info.rbac.component.jsx b/client/src/components/shop-info/shop-info.rbac.component.jsx index d47634888..daa189843 100644 --- a/client/src/components/shop-info/shop-info.rbac.component.jsx +++ b/client/src/components/shop-info/shop-info.rbac.component.jsx @@ -2,11 +2,12 @@ import { Form, InputNumber } from "antd"; import React from "react"; import { useTranslation } from "react-i18next"; import LayoutFormRow from "../layout-form-row/layout-form-row.component"; +import RbacWrapper from "../rbac-wrapper/rbac-wrapper.component"; export default function ShopInfoRbacComponent({ form }) { const { t } = useTranslation(); return ( -
+ -
+ ); }