@redhat-cloud-services/frontend-components-utilities 3.2.6 → 3.2.9
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/RBAC/RBAC.js +15 -9
- package/RBACHook/RBACHook.d.ts +1 -1
- package/RBACHook/RBACHook.js +8 -4
- package/RouterParams/RouterParams.js +0 -1
- package/esm/RBAC/RBAC.js +12 -9
- package/esm/RBACHook/RBACHook.js +5 -4
- package/esm/RouterParams/RouterParams.js +0 -1
- package/esm/index.css +7 -0
- package/esm/index.scss +4 -0
- package/esm/styles/_all.css +3 -0
- package/esm/styles/_all.scss +4 -0
- package/esm/styles/_helpers.css +0 -0
- package/esm/styles/_helpers.scss +0 -0
- package/esm/styles/_mixins.css +0 -0
- package/esm/styles/_mixins.scss +79 -0
- package/esm/styles/_variables.css +3 -0
- package/esm/styles/_variables.scss +42 -0
- package/esm/useInventory/useInventory.js +2 -1
- package/package.json +1 -1
- package/useInventory/useInventory.js +4 -2
package/RBAC/RBAC.js
CHANGED
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.getRBAC = getRBAC;
|
|
9
9
|
exports.doesHavePermissions = doesHavePermissions;
|
|
10
|
+
exports["default"] = void 0;
|
|
10
11
|
|
|
11
12
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
12
13
|
|
|
@@ -21,6 +22,7 @@ function _getRBAC() {
|
|
|
21
22
|
var _insights$chrome, _insights$chrome$auth, _user$identity, _user$identity$user, _insights$chrome2;
|
|
22
23
|
|
|
23
24
|
var applicationName,
|
|
25
|
+
disableCache,
|
|
24
26
|
insights,
|
|
25
27
|
user,
|
|
26
28
|
_args = arguments;
|
|
@@ -29,34 +31,35 @@ function _getRBAC() {
|
|
|
29
31
|
switch (_context.prev = _context.next) {
|
|
30
32
|
case 0:
|
|
31
33
|
applicationName = _args.length > 0 && _args[0] !== undefined ? _args[0] : '';
|
|
34
|
+
disableCache = _args.length > 1 && _args[1] !== undefined ? _args[1] : false;
|
|
32
35
|
insights = window.insights;
|
|
33
|
-
_context.next =
|
|
36
|
+
_context.next = 5;
|
|
34
37
|
return insights === null || insights === void 0 ? void 0 : (_insights$chrome = insights.chrome) === null || _insights$chrome === void 0 ? void 0 : (_insights$chrome$auth = _insights$chrome.auth) === null || _insights$chrome$auth === void 0 ? void 0 : _insights$chrome$auth.getUser();
|
|
35
38
|
|
|
36
|
-
case
|
|
39
|
+
case 5:
|
|
37
40
|
user = _context.sent;
|
|
38
41
|
_context.t0 = (user === null || user === void 0 ? void 0 : (_user$identity = user.identity) === null || _user$identity === void 0 ? void 0 : (_user$identity$user = _user$identity.user) === null || _user$identity$user === void 0 ? void 0 : _user$identity$user.is_org_admin) || false;
|
|
39
|
-
_context.next =
|
|
40
|
-
return insights === null || insights === void 0 ? void 0 : (_insights$chrome2 = insights.chrome) === null || _insights$chrome2 === void 0 ? void 0 : _insights$chrome2.getUserPermissions(applicationName);
|
|
42
|
+
_context.next = 9;
|
|
43
|
+
return insights === null || insights === void 0 ? void 0 : (_insights$chrome2 = insights.chrome) === null || _insights$chrome2 === void 0 ? void 0 : _insights$chrome2.getUserPermissions(applicationName, disableCache);
|
|
41
44
|
|
|
42
|
-
case
|
|
45
|
+
case 9:
|
|
43
46
|
_context.t1 = _context.sent;
|
|
44
47
|
|
|
45
48
|
if (_context.t1) {
|
|
46
|
-
_context.next =
|
|
49
|
+
_context.next = 12;
|
|
47
50
|
break;
|
|
48
51
|
}
|
|
49
52
|
|
|
50
53
|
_context.t1 = null;
|
|
51
54
|
|
|
52
|
-
case
|
|
55
|
+
case 12:
|
|
53
56
|
_context.t2 = _context.t1;
|
|
54
57
|
return _context.abrupt("return", {
|
|
55
58
|
isOrgAdmin: _context.t0,
|
|
56
59
|
permissions: _context.t2
|
|
57
60
|
});
|
|
58
61
|
|
|
59
|
-
case
|
|
62
|
+
case 14:
|
|
60
63
|
case "end":
|
|
61
64
|
return _context.stop();
|
|
62
65
|
}
|
|
@@ -74,4 +77,7 @@ function doesHavePermissions(userPermissions, permissionList) {
|
|
|
74
77
|
return userPermissions.some(function (access) {
|
|
75
78
|
return permissionList.includes((access === null || access === void 0 ? void 0 : access.permission) || access);
|
|
76
79
|
});
|
|
77
|
-
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
var _default = getRBAC;
|
|
83
|
+
exports["default"] = _default;
|
package/RBACHook/RBACHook.d.ts
CHANGED
package/RBACHook/RBACHook.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.usePermissions = usePermissions;
|
|
9
|
+
exports["default"] = void 0;
|
|
9
10
|
|
|
10
11
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
12
|
|
|
@@ -17,7 +18,7 @@ var _react = require("react");
|
|
|
17
18
|
|
|
18
19
|
var _RBAC = require("../RBAC");
|
|
19
20
|
|
|
20
|
-
function usePermissions(appName, permissionsList) {
|
|
21
|
+
function usePermissions(appName, permissionsList, disableCache) {
|
|
21
22
|
var _useState = (0, _react.useState)({
|
|
22
23
|
isLoading: true
|
|
23
24
|
}),
|
|
@@ -37,7 +38,7 @@ function usePermissions(appName, permissionsList) {
|
|
|
37
38
|
switch (_context.prev = _context.next) {
|
|
38
39
|
case 0:
|
|
39
40
|
_context.next = 2;
|
|
40
|
-
return (0, _RBAC.getRBAC)(appName);
|
|
41
|
+
return (0, _RBAC.getRBAC)(appName, disableCache);
|
|
41
42
|
|
|
42
43
|
case 2:
|
|
43
44
|
_yield$getRBAC = _context.sent;
|
|
@@ -57,6 +58,9 @@ function usePermissions(appName, permissionsList) {
|
|
|
57
58
|
}
|
|
58
59
|
}, _callee);
|
|
59
60
|
}))();
|
|
60
|
-
}, [appName]);
|
|
61
|
+
}, [appName, disableCache]);
|
|
61
62
|
return permissions;
|
|
62
|
-
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
var _default = usePermissions;
|
|
66
|
+
exports["default"] = _default;
|
package/esm/RBAC/RBAC.js
CHANGED
|
@@ -9,6 +9,7 @@ function _getRBAC() {
|
|
|
9
9
|
var _insights$chrome, _insights$chrome$auth, _user$identity, _user$identity$user, _insights$chrome2;
|
|
10
10
|
|
|
11
11
|
var applicationName,
|
|
12
|
+
disableCache,
|
|
12
13
|
insights,
|
|
13
14
|
user,
|
|
14
15
|
_args = arguments;
|
|
@@ -17,34 +18,35 @@ function _getRBAC() {
|
|
|
17
18
|
switch (_context.prev = _context.next) {
|
|
18
19
|
case 0:
|
|
19
20
|
applicationName = _args.length > 0 && _args[0] !== undefined ? _args[0] : '';
|
|
21
|
+
disableCache = _args.length > 1 && _args[1] !== undefined ? _args[1] : false;
|
|
20
22
|
insights = window.insights;
|
|
21
|
-
_context.next =
|
|
23
|
+
_context.next = 5;
|
|
22
24
|
return insights === null || insights === void 0 ? void 0 : (_insights$chrome = insights.chrome) === null || _insights$chrome === void 0 ? void 0 : (_insights$chrome$auth = _insights$chrome.auth) === null || _insights$chrome$auth === void 0 ? void 0 : _insights$chrome$auth.getUser();
|
|
23
25
|
|
|
24
|
-
case
|
|
26
|
+
case 5:
|
|
25
27
|
user = _context.sent;
|
|
26
28
|
_context.t0 = (user === null || user === void 0 ? void 0 : (_user$identity = user.identity) === null || _user$identity === void 0 ? void 0 : (_user$identity$user = _user$identity.user) === null || _user$identity$user === void 0 ? void 0 : _user$identity$user.is_org_admin) || false;
|
|
27
|
-
_context.next =
|
|
28
|
-
return insights === null || insights === void 0 ? void 0 : (_insights$chrome2 = insights.chrome) === null || _insights$chrome2 === void 0 ? void 0 : _insights$chrome2.getUserPermissions(applicationName);
|
|
29
|
+
_context.next = 9;
|
|
30
|
+
return insights === null || insights === void 0 ? void 0 : (_insights$chrome2 = insights.chrome) === null || _insights$chrome2 === void 0 ? void 0 : _insights$chrome2.getUserPermissions(applicationName, disableCache);
|
|
29
31
|
|
|
30
|
-
case
|
|
32
|
+
case 9:
|
|
31
33
|
_context.t1 = _context.sent;
|
|
32
34
|
|
|
33
35
|
if (_context.t1) {
|
|
34
|
-
_context.next =
|
|
36
|
+
_context.next = 12;
|
|
35
37
|
break;
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
_context.t1 = null;
|
|
39
41
|
|
|
40
|
-
case
|
|
42
|
+
case 12:
|
|
41
43
|
_context.t2 = _context.t1;
|
|
42
44
|
return _context.abrupt("return", {
|
|
43
45
|
isOrgAdmin: _context.t0,
|
|
44
46
|
permissions: _context.t2
|
|
45
47
|
});
|
|
46
48
|
|
|
47
|
-
case
|
|
49
|
+
case 14:
|
|
48
50
|
case "end":
|
|
49
51
|
return _context.stop();
|
|
50
52
|
}
|
|
@@ -62,4 +64,5 @@ export function doesHavePermissions(userPermissions, permissionList) {
|
|
|
62
64
|
return userPermissions.some(function (access) {
|
|
63
65
|
return permissionList.includes((access === null || access === void 0 ? void 0 : access.permission) || access);
|
|
64
66
|
});
|
|
65
|
-
}
|
|
67
|
+
}
|
|
68
|
+
export default getRBAC;
|
package/esm/RBACHook/RBACHook.js
CHANGED
|
@@ -3,7 +3,7 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
3
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
4
|
import { useState, useEffect } from 'react';
|
|
5
5
|
import { getRBAC, doesHavePermissions } from '../RBAC';
|
|
6
|
-
export function usePermissions(appName, permissionsList) {
|
|
6
|
+
export function usePermissions(appName, permissionsList, disableCache) {
|
|
7
7
|
var _useState = useState({
|
|
8
8
|
isLoading: true
|
|
9
9
|
}),
|
|
@@ -24,7 +24,7 @@ export function usePermissions(appName, permissionsList) {
|
|
|
24
24
|
switch (_context.prev = _context.next) {
|
|
25
25
|
case 0:
|
|
26
26
|
_context.next = 2;
|
|
27
|
-
return getRBAC(appName);
|
|
27
|
+
return getRBAC(appName, disableCache);
|
|
28
28
|
|
|
29
29
|
case 2:
|
|
30
30
|
_yield$getRBAC = _context.sent;
|
|
@@ -44,6 +44,7 @@ export function usePermissions(appName, permissionsList) {
|
|
|
44
44
|
}
|
|
45
45
|
}, _callee);
|
|
46
46
|
}))();
|
|
47
|
-
}, [appName]);
|
|
47
|
+
}, [appName, disableCache]);
|
|
48
48
|
return permissions;
|
|
49
|
-
}
|
|
49
|
+
}
|
|
50
|
+
export default usePermissions;
|
package/esm/index.css
ADDED
package/esm/index.scss
ADDED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
@use "sass:math";
|
|
2
|
+
|
|
3
|
+
// Convert px to rem
|
|
4
|
+
// =================================================================/
|
|
5
|
+
@mixin rem($property, $values) {
|
|
6
|
+
|
|
7
|
+
// Create a couple of empty lists as output buffers.
|
|
8
|
+
$font-size: 16px;
|
|
9
|
+
$px-values: ();
|
|
10
|
+
$rem-values: ();
|
|
11
|
+
|
|
12
|
+
// Loop through the $values list
|
|
13
|
+
@each $value in $values {
|
|
14
|
+
|
|
15
|
+
// For each property value, if it's in rem or px, derive both rem and
|
|
16
|
+
// px values for it and add those to the end of the appropriate buffer.
|
|
17
|
+
// Ensure all pixel values are rounded to the nearest pixel.
|
|
18
|
+
@if type-of($value) == number and not unitless($value) and (unit($value) == px) {
|
|
19
|
+
|
|
20
|
+
// px value given - calculate rem value from font-size
|
|
21
|
+
$new-rem-value: math.div($value, $font-size);
|
|
22
|
+
$px-values: join($px-values, round($value));
|
|
23
|
+
$rem-values: join($rem-values, unquote("#{$new-rem-value}rem"));
|
|
24
|
+
|
|
25
|
+
} @else if type-of($value) == number and not unitless($value) and (unit($value) == '%') {
|
|
26
|
+
|
|
27
|
+
// % value given - don't add px or rem
|
|
28
|
+
$px-values: join($px-values, unquote(#{$value}));
|
|
29
|
+
$rem-values: join($rem-values, unquote(#{$value}));
|
|
30
|
+
|
|
31
|
+
} @else if $value == auto {
|
|
32
|
+
|
|
33
|
+
// auto - don't add px or rem
|
|
34
|
+
$px-values: join($px-values, auto);
|
|
35
|
+
$rem-values: join($rem-values, auto);
|
|
36
|
+
|
|
37
|
+
} @else {
|
|
38
|
+
|
|
39
|
+
// unitless value - use those directly as rem and calculate the px-fallback
|
|
40
|
+
$px-values: join($px-values, round($value * $font-size));
|
|
41
|
+
$rem-values: join($rem-values, unquote("#{$value}rem"));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// output the converted rules
|
|
46
|
+
#{$property}: $px-values;
|
|
47
|
+
#{$property}: $rem-values;
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
// Generate font-size in rem
|
|
54
|
+
// =================================================================/
|
|
55
|
+
@mixin font-size($size, $line: $size * 1.4) {
|
|
56
|
+
font-size: ($size);
|
|
57
|
+
font-size: math.div($size, $ins-fontSize) + rem;
|
|
58
|
+
|
|
59
|
+
@if $line == 1 {
|
|
60
|
+
line-height: 1;
|
|
61
|
+
|
|
62
|
+
} @else if $line != null {
|
|
63
|
+
line-height: $line;
|
|
64
|
+
line-height: math.div($line, $ins-fontSize) + rem;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
// Generate transition
|
|
71
|
+
// =================================================================/
|
|
72
|
+
@mixin transition($property) {
|
|
73
|
+
|
|
74
|
+
transition: $property 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
|
75
|
+
-o-transition: $property 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
|
76
|
+
-ms-transition: $property 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
|
77
|
+
-moz-transition: $property 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
|
78
|
+
-webkit-transition: $property 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
|
79
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--ins-color--orange: #ec7a08;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
// Spacing
|
|
6
|
+
$ins-padding: var(--pf-global--spacer--lg);
|
|
7
|
+
$ins-margin: var(--pf-global--spacer--xl);
|
|
8
|
+
$ins-gutter: var(--pf-global--gutter);
|
|
9
|
+
|
|
10
|
+
// Font Size
|
|
11
|
+
$ins-fontSize: var(--pf-global--FontSize--md);
|
|
12
|
+
$ins-fontSize--sm: var(--pf-global--FontSize--sm);
|
|
13
|
+
$ins-fontSize--lg: var(--pf-global--FontSize--lg);
|
|
14
|
+
$ins-fontSize--xl: var(--pf-global--FontSize--xl);
|
|
15
|
+
|
|
16
|
+
// Borders
|
|
17
|
+
$ins-borderRadius: var(--pf-global--BorderRadius--sm);
|
|
18
|
+
$ins-borderRadius--round: var(--pf-global--BorderRadius--lg);
|
|
19
|
+
|
|
20
|
+
// Grid breakpoints
|
|
21
|
+
$ins-break--xs: var(--pf-global--breakpoint--xs);
|
|
22
|
+
$ins-break--sm: var(--pf-global--breakpoint--sm);
|
|
23
|
+
$ins-break--md: var(--pf-global--breakpoint--md);
|
|
24
|
+
$ins-break--lg: var(--pf-global--breakpoint--lg);
|
|
25
|
+
$ins-break--xl: var(--pf-global--breakpoint--xl);
|
|
26
|
+
|
|
27
|
+
// Colors
|
|
28
|
+
$ins-color--red: var(--pf-global--danger-color--100);
|
|
29
|
+
$ins-color--critical: $ins-color--red;
|
|
30
|
+
|
|
31
|
+
$ins-color--orange: var(--ins-color--orange);
|
|
32
|
+
$ins-color--high: $ins-color--orange;
|
|
33
|
+
|
|
34
|
+
$ins-color--yellow: var(--pf-global--warning-color--100);
|
|
35
|
+
$ins-color--medium: $ins-color--yellow;
|
|
36
|
+
|
|
37
|
+
$ins-color--green: var(--pf-global--success-color--100);
|
|
38
|
+
$ins-color--low: $ins-color--green;
|
|
39
|
+
|
|
40
|
+
$ins-color--blue: var(--pf-global--info-color--100);
|
|
41
|
+
|
|
42
|
+
$ins-color--gray: var(--pf-global--disabled-color--200);
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
7
7
|
Object.defineProperty(exports, "__esModule", {
|
|
8
8
|
value: true
|
|
9
9
|
});
|
|
10
|
-
exports.useInventory = void 0;
|
|
10
|
+
exports["default"] = exports.useInventory = void 0;
|
|
11
11
|
|
|
12
12
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
13
13
|
|
|
@@ -149,4 +149,6 @@ var useInventory = function useInventory(_ref) {
|
|
|
149
149
|
return _objectSpread(_objectSpread({}, inventory), inventoryComponents);
|
|
150
150
|
};
|
|
151
151
|
|
|
152
|
-
exports.useInventory = useInventory;
|
|
152
|
+
exports.useInventory = useInventory;
|
|
153
|
+
var _default = useInventory;
|
|
154
|
+
exports["default"] = _default;
|