techsbcn-storybook 2.13.0 → 2.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/helpers/PermissionHelpers.d.ts +1 -0
- package/dist/helpers/index.d.ts +1 -0
- package/dist/index.js +8 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const hasPermission: (permission: string) => boolean;
|
package/dist/helpers/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -770,6 +770,9 @@ var addNotification = ({
|
|
|
770
770
|
action: duration === null ? (key) => /* @__PURE__ */ React10__default.default.createElement(material.IconButton, { size: "small", color: "inherit", "aria-label": "close", onClick: () => notistack.closeSnackbar(key) }, /* @__PURE__ */ React10__default.default.createElement(CloseIcon__default.default, { fontSize: "small" })) : void 0
|
|
771
771
|
});
|
|
772
772
|
var removeNotification = (id) => notistack.closeSnackbar(id);
|
|
773
|
+
|
|
774
|
+
// src/helpers/PermissionHelpers.tsx
|
|
775
|
+
var hasPermission = (permission) => getSession()?.role.includes(permission) ?? false;
|
|
773
776
|
var Spinner = () => /* @__PURE__ */ React10__default.default.createElement(material.Box, { sx: { textAlign: "center" } }, /* @__PURE__ */ React10__default.default.createElement(material.CircularProgress, { color: "primary", size: 20 }));
|
|
774
777
|
|
|
775
778
|
// src/components/tables/ImageTableComponent/ImageTableComponent.tsx
|
|
@@ -1616,11 +1619,11 @@ var NavIcon = (props) => {
|
|
|
1616
1619
|
// src/components/navigation/VerticalNav/VerticalNavItem.tsx
|
|
1617
1620
|
var VerticalNavItem = (props) => {
|
|
1618
1621
|
const { pathname } = reactRouter.useLocation();
|
|
1619
|
-
const
|
|
1622
|
+
const hasPermission2 = React10.useMemo(
|
|
1620
1623
|
() => checkPermission(props.item.persmisionAvailable, props.userPermisions),
|
|
1621
1624
|
[props.item.persmisionAvailable, props.userPermisions]
|
|
1622
1625
|
);
|
|
1623
|
-
if (!
|
|
1626
|
+
if (!hasPermission2) {
|
|
1624
1627
|
return null;
|
|
1625
1628
|
}
|
|
1626
1629
|
const isActive = !!reactRouter.matchPath({ path: props.item.end ? props.item.route || "" : `${props.item.route}/*` }, pathname);
|
|
@@ -1680,11 +1683,11 @@ var VerticalNavItemCollapse = (props) => {
|
|
|
1680
1683
|
const handleClick = () => {
|
|
1681
1684
|
setOpen(!open);
|
|
1682
1685
|
};
|
|
1683
|
-
const
|
|
1686
|
+
const hasPermission2 = React10.useMemo(
|
|
1684
1687
|
() => checkPermission(props.item.persmisionAvailable, props.userPermisions),
|
|
1685
1688
|
[props.item.persmisionAvailable, props.userPermisions]
|
|
1686
1689
|
);
|
|
1687
|
-
if (!
|
|
1690
|
+
if (!hasPermission2) {
|
|
1688
1691
|
return null;
|
|
1689
1692
|
}
|
|
1690
1693
|
return /* @__PURE__ */ React10__default.default.createElement(material.Box, { className: "nav-item-collapse" }, /* @__PURE__ */ React10__default.default.createElement(
|
|
@@ -3020,6 +3023,7 @@ exports.getImageByBase64 = getImageByBase64;
|
|
|
3020
3023
|
exports.getImageByBlob = getImageByBlob;
|
|
3021
3024
|
exports.getJwtToken = getJwtToken;
|
|
3022
3025
|
exports.getSession = getSession;
|
|
3026
|
+
exports.hasPermission = hasPermission;
|
|
3023
3027
|
exports.logout = logout;
|
|
3024
3028
|
exports.readFileAsBase64 = readFileAsBase64;
|
|
3025
3029
|
exports.redirectDownload = redirectDownload;
|