techsbcn-storybook 0.9.2 → 0.10.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/README.md +0 -1
- package/dist/components/navigation/VerticalNav/VerticalNav.d.ts +1 -1
- package/dist/components/navigation/VerticalNav/VerticalNavItem.d.ts +1 -1
- package/dist/components/navigation/VerticalNav/VerticalNavItemCollapse.d.ts +1 -1
- package/dist/data/SelectMock.d.ts +1 -1
- package/dist/data/enums/scopes.d.ts +5 -0
- package/dist/data/index.d.ts +1 -0
- package/dist/stories/MainWrapper/MainWrapper.stories.d.ts +1 -1
- package/dist/techsbcn-storybook.cjs.development.js +14 -2
- package/dist/techsbcn-storybook.cjs.development.js.map +1 -1
- package/dist/techsbcn-storybook.cjs.production.min.js +1 -1
- package/dist/techsbcn-storybook.cjs.production.min.js.map +1 -1
- package/dist/techsbcn-storybook.esm.js +14 -2
- package/dist/techsbcn-storybook.esm.js.map +1 -1
- package/package.json +3 -1
- package/src/components/navigation/VerticalNav/VerticalNav.tsx +1 -1
- package/src/components/navigation/VerticalNav/VerticalNavItem.tsx +1 -1
- package/src/components/navigation/VerticalNav/VerticalNavItemCollapse.tsx +1 -1
- package/src/components/tables/SearchComponent/SearchComponent.tsx +2 -2
- package/src/data/SelectMock.tsx +1 -1
- package/src/data/enums/scopes.ts +5 -0
- package/src/data/index.ts +1 -0
- package/src/helpers/CheckPermission.tsx +12 -0
- package/src/stories/Layouts/MainLayoutSimple.stories.tsx +13 -1
- package/src/stories/MainWrapper/MainWrapper.stories.tsx +31 -2
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ export interface NavigationProps {
|
|
|
14
14
|
}
|
|
15
15
|
interface VerticalNavProps {
|
|
16
16
|
items: NavigationProps[];
|
|
17
|
-
userPermisions?: string[];
|
|
17
|
+
userPermisions?: string[] | string;
|
|
18
18
|
onHide?: () => void;
|
|
19
19
|
}
|
|
20
20
|
export declare const VerticalNav: React.FC<VerticalNavProps>;
|
|
@@ -2,7 +2,7 @@ import { NavigationProps } from './VerticalNav';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
interface VerticalNavItemProps {
|
|
4
4
|
item: NavigationProps;
|
|
5
|
-
userPermisions?: string[];
|
|
5
|
+
userPermisions?: string[] | string;
|
|
6
6
|
onHide?: () => void;
|
|
7
7
|
}
|
|
8
8
|
declare const _default: React.NamedExoticComponent<VerticalNavItemProps>;
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { NavigationProps } from './VerticalNav';
|
|
3
3
|
interface VerticalNavItemCollapseProps {
|
|
4
4
|
item: NavigationProps;
|
|
5
|
-
userPermisions?: string[];
|
|
5
|
+
userPermisions?: string[] | string;
|
|
6
6
|
onHide?: () => void;
|
|
7
7
|
}
|
|
8
8
|
declare const _default: React.NamedExoticComponent<VerticalNavItemCollapseProps>;
|
|
@@ -5,5 +5,5 @@ interface ColourOption {
|
|
|
5
5
|
}
|
|
6
6
|
export declare const colourOptions: ColourOption[];
|
|
7
7
|
export declare const ResponseHandler: (response: any) => any;
|
|
8
|
-
export declare const SearchSimple: (
|
|
8
|
+
export declare const SearchSimple: (_filters: SearchFilters) => Promise<SearchResult<SearchSimpleResult>>;
|
|
9
9
|
export {};
|
package/dist/data/index.d.ts
CHANGED
|
@@ -108,7 +108,7 @@ var DoubleFilter = function DoubleFilter(filters) {
|
|
|
108
108
|
};
|
|
109
109
|
|
|
110
110
|
var SearchComponent = function SearchComponent(props) {
|
|
111
|
-
var _useState = React.useState(
|
|
111
|
+
var _useState = React.useState(!props.searchBar && !!props.filters),
|
|
112
112
|
isOpen = _useState[0],
|
|
113
113
|
setIsOpen = _useState[1];
|
|
114
114
|
|
|
@@ -207,7 +207,7 @@ var SearchComponent = function SearchComponent(props) {
|
|
|
207
207
|
},
|
|
208
208
|
display: "flex",
|
|
209
209
|
width: "100%"
|
|
210
|
-
}, props.searchBar, props.filters && React__default.createElement(material.Box, {
|
|
210
|
+
}, props.searchBar, props.filters && props.searchBar && React__default.createElement(material.Box, {
|
|
211
211
|
onClick: function onClick() {
|
|
212
212
|
return setIsOpen(!isOpen);
|
|
213
213
|
},
|
|
@@ -608,6 +608,10 @@ var MainLayoutSimple = function MainLayoutSimple(props) {
|
|
|
608
608
|
var checkPermission = function checkPermission(persmisionAvailable, userRoles) {
|
|
609
609
|
if (persmisionAvailable === null || persmisionAvailable === undefined || persmisionAvailable.length === 0) {
|
|
610
610
|
return true;
|
|
611
|
+
} else {
|
|
612
|
+
if (userRoles === undefined || userRoles === null || userRoles === 0) {
|
|
613
|
+
return false;
|
|
614
|
+
}
|
|
611
615
|
}
|
|
612
616
|
|
|
613
617
|
if (userRoles && Array.isArray(userRoles) && Array.isArray(persmisionAvailable)) {
|
|
@@ -616,6 +620,14 @@ var checkPermission = function checkPermission(persmisionAvailable, userRoles) {
|
|
|
616
620
|
});
|
|
617
621
|
}
|
|
618
622
|
|
|
623
|
+
if (userRoles && !Array.isArray(userRoles) && !Array.isArray(persmisionAvailable)) {
|
|
624
|
+
return userRoles === persmisionAvailable;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
if (userRoles && !Array.isArray(userRoles) && Array.isArray(persmisionAvailable)) {
|
|
628
|
+
return persmisionAvailable.indexOf(userRoles) >= 0;
|
|
629
|
+
}
|
|
630
|
+
|
|
619
631
|
return userRoles.indexOf(persmisionAvailable) >= 0;
|
|
620
632
|
};
|
|
621
633
|
|