@redhat-cloud-services/frontend-components 3.9.6 → 3.9.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/ConditionalFilter/ConditionalFilter.js +1 -1
- package/DownloadButton/DownloadButton.spec.ct.js +8 -1
- package/InsightsLabel/InsightsLabel.d.ts +0 -1
- package/InsightsLabel/InsightsLabel.js +3 -4
- package/RBACProvider/RBACProvider.d.ts +5 -0
- package/RBACProvider/RBACProvider.js +103 -0
- package/RBACProvider/index.d.ts +1 -0
- package/RBACProvider/index.js +14 -0
- package/RBACProvider/package.json +1 -0
- package/esm/ConditionalFilter/ConditionalFilter.js +1 -1
- package/esm/DownloadButton/DownloadButton.spec.ct.js +8 -1
- package/esm/InsightsLabel/InsightsLabel.js +3 -4
- package/esm/RBACProvider/RBACProvider.js +80 -0
- package/esm/RBACProvider/index.js +2 -0
- package/esm/index.css +0 -21
- package/esm/index.js +1 -0
- package/esm/index.scss +0 -1
- package/index.css +0 -21
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/index.scss +0 -1
- package/package.json +1 -1
- package/InsightsLabel/labels.css +0 -20
- package/InsightsLabel/labels.scss +0 -21
- package/esm/InsightsLabel/labels.css +0 -20
- package/esm/InsightsLabel/labels.scss +0 -21
|
@@ -81,7 +81,7 @@ var ConditionalFilter = function (_a) {
|
|
|
81
81
|
!shouldRenderNewLayout && (react_1.default.createElement(react_1.Fragment, null, !items || (items && items.length <= 0) ? (react_1.default.createElement("div", { className: (0, classnames_1.default)('ins-c-conditional-filter', {
|
|
82
82
|
desktop: useMobileLayout,
|
|
83
83
|
}) },
|
|
84
|
-
react_1.default.createElement(TextFilter_1.default, { id: id, isDisabled: isDisabled, onChange: function (e) { return onChangeCallback(e,
|
|
84
|
+
react_1.default.createElement(TextFilter_1.default, { id: id, isDisabled: isDisabled, onChange: function (e) { return onChangeCallback(e, e.target.value); }, placeholder: placeholder, value: currentValue ? String(currentValue) : undefined, "widget-type": "InsightsInput" }))) : (react_1.default.createElement(react_core_1.Split, { className: (0, classnames_1.default)('ins-c-conditional-filter', {
|
|
85
85
|
desktop: useMobileLayout,
|
|
86
86
|
}) },
|
|
87
87
|
items.length > 1 && (react_1.default.createElement(react_core_1.SplitItem, null,
|
|
@@ -13,12 +13,19 @@ describe('DownloadButton component', function () {
|
|
|
13
13
|
it('renders the dropdown', function () {
|
|
14
14
|
cy.get('.pf-c-dropdown');
|
|
15
15
|
});
|
|
16
|
-
it('on download callback fired', function () {
|
|
16
|
+
it('on download CSV callback fired', function () {
|
|
17
17
|
var onSelectSpy = cy.spy().as('onSelectSpy');
|
|
18
18
|
(0, react_2.mount)(react_1.default.createElement(__1.DownloadButton, { onSelect: onSelectSpy }));
|
|
19
19
|
cy.get('div[data-ouia-component-id="Export"] > button').click();
|
|
20
20
|
cy.get('div[data-ouia-component-id="Export"] > ul > li > button[data-ouia-component-id="DownloadCSV"]').click();
|
|
21
21
|
cy.get('@onSelectSpy').should('have.been.called.with', 'csv');
|
|
22
22
|
});
|
|
23
|
+
it('on download JSON callback fired', function () {
|
|
24
|
+
var onSelectSpy = cy.spy().as('onSelectSpy');
|
|
25
|
+
(0, react_2.mount)(react_1.default.createElement(__1.DownloadButton, { onSelect: onSelectSpy }));
|
|
26
|
+
cy.get('div[data-ouia-component-id="Export"] > button').click();
|
|
27
|
+
cy.get('div[data-ouia-component-id="Export"] > ul > li > button[data-ouia-component-id="DownloadJSON"]').click();
|
|
28
|
+
cy.get('@onSelectSpy').should('have.been.called.with', 'json');
|
|
29
|
+
});
|
|
23
30
|
});
|
|
24
31
|
//# sourceMappingURL=DownloadButton.spec.ct.js.map
|
|
@@ -25,7 +25,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
25
25
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
26
|
};
|
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
require("./labels.css");
|
|
29
28
|
var react_icons_1 = require("@patternfly/react-icons");
|
|
30
29
|
var react_icons_2 = require("@patternfly/react-icons");
|
|
31
30
|
var react_icons_3 = require("@patternfly/react-icons");
|
|
@@ -34,13 +33,13 @@ var react_core_1 = require("@patternfly/react-core");
|
|
|
34
33
|
var react_1 = __importDefault(require("react"));
|
|
35
34
|
var VALUE_TO_STATE = {
|
|
36
35
|
1: { icon: react_1.default.createElement(react_icons_1.AngleDoubleDownIcon, null), text: 'Low', color: 'blue' },
|
|
37
|
-
2: { icon: react_1.default.createElement(react_icons_4.EqualsIcon, null), text: 'Moderate', color:
|
|
36
|
+
2: { icon: react_1.default.createElement(react_icons_4.EqualsIcon, null), text: 'Moderate', color: 'gold' },
|
|
38
37
|
3: { icon: react_1.default.createElement(react_icons_2.AngleDoubleUpIcon, null), text: 'Important', color: 'orange' },
|
|
39
38
|
4: { icon: react_1.default.createElement(react_icons_3.CriticalRiskIcon, null), text: 'Critical', color: 'red' },
|
|
40
39
|
};
|
|
41
40
|
var InsightsLabel = function (_a) {
|
|
42
|
-
var _b = _a.value, value = _b === void 0 ? 1 : _b, text = _a.text, hideIcon = _a.hideIcon,
|
|
43
|
-
return (react_1.default.createElement(react_core_1.Label, __assign({}, rest, props, {
|
|
41
|
+
var _b = _a.value, value = _b === void 0 ? 1 : _b, text = _a.text, hideIcon = _a.hideIcon, rest = _a.rest, props = __rest(_a, ["value", "text", "hideIcon", "rest"]);
|
|
42
|
+
return (react_1.default.createElement(react_core_1.Label, __assign({}, rest, props, { color: VALUE_TO_STATE[value].color, icon: !hideIcon && VALUE_TO_STATE[value].icon }), text || VALUE_TO_STATE[value].text));
|
|
44
43
|
};
|
|
45
44
|
exports.default = InsightsLabel;
|
|
46
45
|
//# sourceMappingURL=InsightsLabel.js.map
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
26
|
+
if (mod && mod.__esModule) return mod;
|
|
27
|
+
var result = {};
|
|
28
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
29
|
+
__setModuleDefault(result, mod);
|
|
30
|
+
return result;
|
|
31
|
+
};
|
|
32
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
33
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
34
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
35
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
36
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
37
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
38
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
42
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
43
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
44
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
45
|
+
function step(op) {
|
|
46
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
47
|
+
while (_) try {
|
|
48
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
49
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
50
|
+
switch (op[0]) {
|
|
51
|
+
case 0: case 1: t = op; break;
|
|
52
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
53
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
54
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
55
|
+
default:
|
|
56
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
57
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
58
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
59
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
60
|
+
if (t[2]) _.ops.pop();
|
|
61
|
+
_.trys.pop(); continue;
|
|
62
|
+
}
|
|
63
|
+
op = body.call(thisArg, _);
|
|
64
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
65
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
69
|
+
exports.RBACProvider = void 0;
|
|
70
|
+
var react_1 = __importStar(require("react"));
|
|
71
|
+
var react_core_1 = require("@patternfly/react-core");
|
|
72
|
+
var RBAC_1 = require("@redhat-cloud-services/frontend-components-utilities/RBAC");
|
|
73
|
+
var hasAccessWithUserPermissions = function (userPermissions) {
|
|
74
|
+
return function (requiredPermissions, checkAll) {
|
|
75
|
+
if (checkAll === void 0) { checkAll = true; }
|
|
76
|
+
return checkAll ? (0, RBAC_1.hasAllPermissions)(userPermissions, requiredPermissions) : (0, RBAC_1.doesHavePermissions)(userPermissions, requiredPermissions);
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
var RBACProvider = function (_a) {
|
|
80
|
+
var appName = _a.appName, children = _a.children;
|
|
81
|
+
var _b = (0, react_1.useState)(RBAC_1.initialPermissions), permissionState = _b[0], setPermissionState = _b[1];
|
|
82
|
+
var fetchPermissions = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
83
|
+
var _a, isOrgAdmin, userPermissions;
|
|
84
|
+
return __generator(this, function (_b) {
|
|
85
|
+
switch (_b.label) {
|
|
86
|
+
case 0: return [4, (0, RBAC_1.getRBAC)(appName, true)];
|
|
87
|
+
case 1:
|
|
88
|
+
_a = _b.sent(), isOrgAdmin = _a.isOrgAdmin, userPermissions = _a.permissions;
|
|
89
|
+
setPermissionState(function (currentPerms) { return (__assign(__assign({}, currentPerms), { isLoading: false, isOrgAdmin: isOrgAdmin, permissions: userPermissions })); });
|
|
90
|
+
return [2];
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}); };
|
|
94
|
+
(0, react_1.useEffect)(function () {
|
|
95
|
+
if (appName) {
|
|
96
|
+
fetchPermissions();
|
|
97
|
+
}
|
|
98
|
+
}, [appName]);
|
|
99
|
+
return (react_1.default.createElement(RBAC_1.RBACContext.Provider, { value: __assign(__assign({}, permissionState), { hasAccess: hasAccessWithUserPermissions((permissionState === null || permissionState === void 0 ? void 0 : permissionState.permissions) || []) }) }, !permissionState.isLoading ? (children) : (react_1.default.createElement(react_core_1.Bullseye, null,
|
|
100
|
+
react_1.default.createElement(react_core_1.Spinner, { size: "xl" })))));
|
|
101
|
+
};
|
|
102
|
+
exports.RBACProvider = RBACProvider;
|
|
103
|
+
//# sourceMappingURL=RBACProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './RBACProvider';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./RBACProvider"), exports);
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"main":"index.js","module":"../esm/RBACProvider/index.js","typings":"index.d.ts"}
|
|
@@ -57,7 +57,7 @@ var ConditionalFilter = function (_a) {
|
|
|
57
57
|
!shouldRenderNewLayout && (React.createElement(Fragment, null, !items || (items && items.length <= 0) ? (React.createElement("div", { className: classNames('ins-c-conditional-filter', {
|
|
58
58
|
desktop: useMobileLayout,
|
|
59
59
|
}) },
|
|
60
|
-
React.createElement(TextFilter, { id: id, isDisabled: isDisabled, onChange: function (e) { return onChangeCallback(e,
|
|
60
|
+
React.createElement(TextFilter, { id: id, isDisabled: isDisabled, onChange: function (e) { return onChangeCallback(e, e.target.value); }, placeholder: placeholder, value: currentValue ? String(currentValue) : undefined, "widget-type": "InsightsInput" }))) : (React.createElement(Split, { className: classNames('ins-c-conditional-filter', {
|
|
61
61
|
desktop: useMobileLayout,
|
|
62
62
|
}) },
|
|
63
63
|
items.length > 1 && (React.createElement(SplitItem, null,
|
|
@@ -8,12 +8,19 @@ describe('DownloadButton component', function () {
|
|
|
8
8
|
it('renders the dropdown', function () {
|
|
9
9
|
cy.get('.pf-c-dropdown');
|
|
10
10
|
});
|
|
11
|
-
it('on download callback fired', function () {
|
|
11
|
+
it('on download CSV callback fired', function () {
|
|
12
12
|
var onSelectSpy = cy.spy().as('onSelectSpy');
|
|
13
13
|
mount(React.createElement(DownloadButton, { onSelect: onSelectSpy }));
|
|
14
14
|
cy.get('div[data-ouia-component-id="Export"] > button').click();
|
|
15
15
|
cy.get('div[data-ouia-component-id="Export"] > ul > li > button[data-ouia-component-id="DownloadCSV"]').click();
|
|
16
16
|
cy.get('@onSelectSpy').should('have.been.called.with', 'csv');
|
|
17
17
|
});
|
|
18
|
+
it('on download JSON callback fired', function () {
|
|
19
|
+
var onSelectSpy = cy.spy().as('onSelectSpy');
|
|
20
|
+
mount(React.createElement(DownloadButton, { onSelect: onSelectSpy }));
|
|
21
|
+
cy.get('div[data-ouia-component-id="Export"] > button').click();
|
|
22
|
+
cy.get('div[data-ouia-component-id="Export"] > ul > li > button[data-ouia-component-id="DownloadJSON"]').click();
|
|
23
|
+
cy.get('@onSelectSpy').should('have.been.called.with', 'json');
|
|
24
|
+
});
|
|
18
25
|
});
|
|
19
26
|
//# sourceMappingURL=DownloadButton.spec.ct.js.map
|
|
@@ -20,7 +20,6 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
20
20
|
}
|
|
21
21
|
return t;
|
|
22
22
|
};
|
|
23
|
-
import '../InsightsLabel/labels.css';
|
|
24
23
|
import { AngleDoubleDownIcon } from '@patternfly/react-icons';
|
|
25
24
|
import { AngleDoubleUpIcon } from '@patternfly/react-icons';
|
|
26
25
|
import { CriticalRiskIcon } from '@patternfly/react-icons';
|
|
@@ -29,13 +28,13 @@ import { Label } from '@patternfly/react-core';
|
|
|
29
28
|
import React from 'react';
|
|
30
29
|
var VALUE_TO_STATE = {
|
|
31
30
|
1: { icon: React.createElement(AngleDoubleDownIcon, null), text: 'Low', color: 'blue' },
|
|
32
|
-
2: { icon: React.createElement(EqualsIcon, null), text: 'Moderate', color:
|
|
31
|
+
2: { icon: React.createElement(EqualsIcon, null), text: 'Moderate', color: 'gold' },
|
|
33
32
|
3: { icon: React.createElement(AngleDoubleUpIcon, null), text: 'Important', color: 'orange' },
|
|
34
33
|
4: { icon: React.createElement(CriticalRiskIcon, null), text: 'Critical', color: 'red' },
|
|
35
34
|
};
|
|
36
35
|
var InsightsLabel = function (_a) {
|
|
37
|
-
var _b = _a.value, value = _b === void 0 ? 1 : _b, text = _a.text, hideIcon = _a.hideIcon,
|
|
38
|
-
return (React.createElement(Label, __assign({}, rest, props, {
|
|
36
|
+
var _b = _a.value, value = _b === void 0 ? 1 : _b, text = _a.text, hideIcon = _a.hideIcon, rest = _a.rest, props = __rest(_a, ["value", "text", "hideIcon", "rest"]);
|
|
37
|
+
return (React.createElement(Label, __assign({}, rest, props, { color: VALUE_TO_STATE[value].color, icon: !hideIcon && VALUE_TO_STATE[value].icon }), text || VALUE_TO_STATE[value].text));
|
|
39
38
|
};
|
|
40
39
|
export default InsightsLabel;
|
|
41
40
|
//# sourceMappingURL=InsightsLabel.js.map
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (_) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
import React, { useEffect, useState } from 'react';
|
|
49
|
+
import { Bullseye, Spinner } from '@patternfly/react-core';
|
|
50
|
+
import { RBACContext, doesHavePermissions, getRBAC, hasAllPermissions, initialPermissions, } from '@redhat-cloud-services/frontend-components-utilities/RBAC';
|
|
51
|
+
var hasAccessWithUserPermissions = function (userPermissions) {
|
|
52
|
+
return function (requiredPermissions, checkAll) {
|
|
53
|
+
if (checkAll === void 0) { checkAll = true; }
|
|
54
|
+
return checkAll ? hasAllPermissions(userPermissions, requiredPermissions) : doesHavePermissions(userPermissions, requiredPermissions);
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
export var RBACProvider = function (_a) {
|
|
58
|
+
var appName = _a.appName, children = _a.children;
|
|
59
|
+
var _b = useState(initialPermissions), permissionState = _b[0], setPermissionState = _b[1];
|
|
60
|
+
var fetchPermissions = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
61
|
+
var _a, isOrgAdmin, userPermissions;
|
|
62
|
+
return __generator(this, function (_b) {
|
|
63
|
+
switch (_b.label) {
|
|
64
|
+
case 0: return [4, getRBAC(appName, true)];
|
|
65
|
+
case 1:
|
|
66
|
+
_a = _b.sent(), isOrgAdmin = _a.isOrgAdmin, userPermissions = _a.permissions;
|
|
67
|
+
setPermissionState(function (currentPerms) { return (__assign(__assign({}, currentPerms), { isLoading: false, isOrgAdmin: isOrgAdmin, permissions: userPermissions })); });
|
|
68
|
+
return [2];
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}); };
|
|
72
|
+
useEffect(function () {
|
|
73
|
+
if (appName) {
|
|
74
|
+
fetchPermissions();
|
|
75
|
+
}
|
|
76
|
+
}, [appName]);
|
|
77
|
+
return (React.createElement(RBACContext.Provider, { value: __assign(__assign({}, permissionState), { hasAccess: hasAccessWithUserPermissions((permissionState === null || permissionState === void 0 ? void 0 : permissionState.permissions) || []) }) }, !permissionState.isLoading ? (children) : (React.createElement(Bullseye, null,
|
|
78
|
+
React.createElement(Spinner, { size: "xl" })))));
|
|
79
|
+
};
|
|
80
|
+
//# sourceMappingURL=RBACProvider.js.map
|
package/esm/index.css
CHANGED
|
@@ -251,27 +251,6 @@ i.ins-battery svg {
|
|
|
251
251
|
outline: inherit !important;
|
|
252
252
|
}
|
|
253
253
|
|
|
254
|
-
.pf-c-label {
|
|
255
|
-
--ins-c-label--gold-bg: #fdf7e7;
|
|
256
|
-
--inc-c-label--content-gold: var(--pf-global--palette--gold-700);
|
|
257
|
-
--inc-c-label--icon-gold: #F4C145;
|
|
258
|
-
--inc-c-label--border-gold: var(--pf-global--palette--gold-100) ;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
.ins-c-label-2.pf-c-label {
|
|
262
|
-
background-color: var(--ins-c-label--gold-bg);
|
|
263
|
-
}
|
|
264
|
-
.ins-c-label-2.pf-c-label .pf-c-label__content {
|
|
265
|
-
color: var(--inc-c-label--content-gold);
|
|
266
|
-
}
|
|
267
|
-
.ins-c-label-2.pf-c-label .pf-c-label__content .pf-c-label__icon {
|
|
268
|
-
color: var(--inc-c-label--icon-gold);
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
.ins-c-label-2.pf-c-label .pf-c-label__content::before {
|
|
272
|
-
border: 1px solid var(--inc-c-label--border-gold);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
254
|
.Icon404 {
|
|
276
255
|
height: 150px;
|
|
277
256
|
}
|
package/esm/index.js
CHANGED
package/esm/index.scss
CHANGED
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
@import './FilterChips/filter-chips.scss';
|
|
9
9
|
@import './FilterHooks/tagFilterHook.scss';
|
|
10
10
|
@import './Filters/filter-dropdown.scss';
|
|
11
|
-
@import './InsightsLabel/labels.scss';
|
|
12
11
|
@import './InvalidObject/icon-404.scss';
|
|
13
12
|
@import './InvalidObject/invalidObject.scss';
|
|
14
13
|
@import './Main/main.scss';
|
package/index.css
CHANGED
|
@@ -251,27 +251,6 @@ i.ins-battery svg {
|
|
|
251
251
|
outline: inherit !important;
|
|
252
252
|
}
|
|
253
253
|
|
|
254
|
-
.pf-c-label {
|
|
255
|
-
--ins-c-label--gold-bg: #fdf7e7;
|
|
256
|
-
--inc-c-label--content-gold: var(--pf-global--palette--gold-700);
|
|
257
|
-
--inc-c-label--icon-gold: #F4C145;
|
|
258
|
-
--inc-c-label--border-gold: var(--pf-global--palette--gold-100) ;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
.ins-c-label-2.pf-c-label {
|
|
262
|
-
background-color: var(--ins-c-label--gold-bg);
|
|
263
|
-
}
|
|
264
|
-
.ins-c-label-2.pf-c-label .pf-c-label__content {
|
|
265
|
-
color: var(--inc-c-label--content-gold);
|
|
266
|
-
}
|
|
267
|
-
.ins-c-label-2.pf-c-label .pf-c-label__content .pf-c-label__icon {
|
|
268
|
-
color: var(--inc-c-label--icon-gold);
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
.ins-c-label-2.pf-c-label .pf-c-label__content::before {
|
|
272
|
-
border: 1px solid var(--inc-c-label--border-gold);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
254
|
.Icon404 {
|
|
276
255
|
height: 150px;
|
|
277
256
|
}
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -50,4 +50,5 @@ __exportStar(require("./FilterHooks"), exports);
|
|
|
50
50
|
__exportStar(require("./AsyncComponent"), exports);
|
|
51
51
|
__exportStar(require("./Ouia"), exports);
|
|
52
52
|
__exportStar(require("./ErrorBoundary"), exports);
|
|
53
|
+
__exportStar(require("./RBACProvider"), exports);
|
|
53
54
|
//# sourceMappingURL=index.js.map
|
package/index.scss
CHANGED
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
@import './FilterChips/filter-chips.scss';
|
|
9
9
|
@import './FilterHooks/tagFilterHook.scss';
|
|
10
10
|
@import './Filters/filter-dropdown.scss';
|
|
11
|
-
@import './InsightsLabel/labels.scss';
|
|
12
11
|
@import './InvalidObject/icon-404.scss';
|
|
13
12
|
@import './InvalidObject/invalidObject.scss';
|
|
14
13
|
@import './Main/main.scss';
|
package/package.json
CHANGED
package/InsightsLabel/labels.css
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
.pf-c-label {
|
|
2
|
-
--ins-c-label--gold-bg: #fdf7e7;
|
|
3
|
-
--inc-c-label--content-gold: var(--pf-global--palette--gold-700);
|
|
4
|
-
--inc-c-label--icon-gold: #F4C145;
|
|
5
|
-
--inc-c-label--border-gold: var(--pf-global--palette--gold-100) ;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
.ins-c-label-2.pf-c-label {
|
|
9
|
-
background-color: var(--ins-c-label--gold-bg);
|
|
10
|
-
}
|
|
11
|
-
.ins-c-label-2.pf-c-label .pf-c-label__content {
|
|
12
|
-
color: var(--inc-c-label--content-gold);
|
|
13
|
-
}
|
|
14
|
-
.ins-c-label-2.pf-c-label .pf-c-label__content .pf-c-label__icon {
|
|
15
|
-
color: var(--inc-c-label--icon-gold);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.ins-c-label-2.pf-c-label .pf-c-label__content::before {
|
|
19
|
-
border: 1px solid var(--inc-c-label--border-gold);
|
|
20
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
.pf-c-label {
|
|
2
|
-
--ins-c-label--gold-bg: #fdf7e7;
|
|
3
|
-
--inc-c-label--content-gold: var(--pf-global--palette--gold-700);
|
|
4
|
-
--inc-c-label--icon-gold: #F4C145;
|
|
5
|
-
--inc-c-label--border-gold: var(--pf-global--palette--gold-100)
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
.ins-c-label-2.pf-c-label {
|
|
9
|
-
background-color: var(--ins-c-label--gold-bg);
|
|
10
|
-
.pf-c-label__content {
|
|
11
|
-
color: var(--inc-c-label--content-gold);
|
|
12
|
-
.pf-c-label__icon {
|
|
13
|
-
color: var(--inc-c-label--icon-gold);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
.ins-c-label-2.pf-c-label {
|
|
18
|
-
.pf-c-label__content::before {
|
|
19
|
-
border: 1px solid var(--inc-c-label--border-gold);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
.pf-c-label {
|
|
2
|
-
--ins-c-label--gold-bg: #fdf7e7;
|
|
3
|
-
--inc-c-label--content-gold: var(--pf-global--palette--gold-700);
|
|
4
|
-
--inc-c-label--icon-gold: #F4C145;
|
|
5
|
-
--inc-c-label--border-gold: var(--pf-global--palette--gold-100) ;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
.ins-c-label-2.pf-c-label {
|
|
9
|
-
background-color: var(--ins-c-label--gold-bg);
|
|
10
|
-
}
|
|
11
|
-
.ins-c-label-2.pf-c-label .pf-c-label__content {
|
|
12
|
-
color: var(--inc-c-label--content-gold);
|
|
13
|
-
}
|
|
14
|
-
.ins-c-label-2.pf-c-label .pf-c-label__content .pf-c-label__icon {
|
|
15
|
-
color: var(--inc-c-label--icon-gold);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.ins-c-label-2.pf-c-label .pf-c-label__content::before {
|
|
19
|
-
border: 1px solid var(--inc-c-label--border-gold);
|
|
20
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
.pf-c-label {
|
|
2
|
-
--ins-c-label--gold-bg: #fdf7e7;
|
|
3
|
-
--inc-c-label--content-gold: var(--pf-global--palette--gold-700);
|
|
4
|
-
--inc-c-label--icon-gold: #F4C145;
|
|
5
|
-
--inc-c-label--border-gold: var(--pf-global--palette--gold-100)
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
.ins-c-label-2.pf-c-label {
|
|
9
|
-
background-color: var(--ins-c-label--gold-bg);
|
|
10
|
-
.pf-c-label__content {
|
|
11
|
-
color: var(--inc-c-label--content-gold);
|
|
12
|
-
.pf-c-label__icon {
|
|
13
|
-
color: var(--inc-c-label--icon-gold);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
.ins-c-label-2.pf-c-label {
|
|
18
|
-
.pf-c-label__content::before {
|
|
19
|
-
border: 1px solid var(--inc-c-label--border-gold);
|
|
20
|
-
}
|
|
21
|
-
}
|