orc-shared 5.7.0-dev.1 → 5.7.0-dev.3
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/components/MaterialUI/DataDisplay/Modal.js +3 -3
- package/dist/components/MaterialUI/DataDisplay/TransferList.js +2 -3
- package/dist/components/MaterialUI/Inputs/Checkbox.js +3 -4
- package/dist/components/MaterialUI/Inputs/CheckboxGroup.js +5 -6
- package/dist/components/MaterialUI/Inputs/Select.js +1 -2
- package/dist/components/MaterialUI/Inputs/StandaloneRadio.js +2 -3
- package/dist/components/MaterialUI/Inputs/createInput.js +3 -4
- package/dist/components/MaterialUI/muiThemes.js +10 -11
- package/dist/hocs/withToggle.js +1 -2
- package/dist/reducers/authentication.js +3 -0
- package/dist/utils/modelValidationHelper.js +5 -6
- package/package.json +7 -3
- package/src/reducers/authentication.js +5 -0
- package/src/reducers/authentication.test.js +81 -0
|
@@ -101,7 +101,7 @@ var useStyles = (0, _styles.makeStyles)(function (theme) {
|
|
|
101
101
|
};
|
|
102
102
|
});
|
|
103
103
|
var Modal = function Modal(_ref) {
|
|
104
|
-
var _modalProps$get, _modalProps$get2
|
|
104
|
+
var _modalProps$get, _modalProps$get2;
|
|
105
105
|
var message = _ref.message,
|
|
106
106
|
modalProps = _ref.modalProps;
|
|
107
107
|
var classes = useStyles();
|
|
@@ -113,8 +113,8 @@ var Modal = function Modal(_ref) {
|
|
|
113
113
|
var actionPanel = modalProps == null ? void 0 : modalProps.get(_modalProps.default.propNames.actionPanel);
|
|
114
114
|
var backdropClickCallback = modalProps == null ? void 0 : modalProps.get(_modalProps.default.propNames.backdropClickCallback);
|
|
115
115
|
var modalType = (_modalProps$get2 = modalProps == null ? void 0 : modalProps.get(_modalProps.default.propNames.type)) != null ? _modalProps$get2 : "normal";
|
|
116
|
-
var containerCls = (0, _classnames.default)((
|
|
117
|
-
var messageCls = (0, _classnames.default)((
|
|
116
|
+
var containerCls = (0, _classnames.default)(_defineProperty(_defineProperty(_defineProperty({}, classes.containerNormal, modalType === "normal"), classes.containerWide, modalType === "wide"), classes.containerFullwidth, modalType === "fullwidth"));
|
|
117
|
+
var messageCls = (0, _classnames.default)(_defineProperty(_defineProperty({}, classes.message, modalType === "normal"), classes.messageWide, modalType === "wide" || modalType === "fullwidth"));
|
|
118
118
|
var onCloseCallback = function onCloseCallback(e, reason) {
|
|
119
119
|
if (backdropClickCallback && reason === "backdropClick") {
|
|
120
120
|
backdropClickCallback(e);
|
|
@@ -104,15 +104,14 @@ var useListStyles = (0, _styles.makeStyles)(function (theme) {
|
|
|
104
104
|
};
|
|
105
105
|
});
|
|
106
106
|
var formatState = function formatState(state, checked, from, to) {
|
|
107
|
-
var _ref3;
|
|
108
107
|
var fromSelectedItems = state[from].filter(function (_ref) {
|
|
109
108
|
var id = _ref.id;
|
|
110
109
|
return checked.includes(id);
|
|
111
110
|
});
|
|
112
|
-
return
|
|
111
|
+
return _defineProperty(_defineProperty({}, to, [].concat(state[to], fromSelectedItems)), from, state[from].filter(function (_ref2) {
|
|
113
112
|
var id = _ref2.id;
|
|
114
113
|
return !checked.includes(id);
|
|
115
|
-
}))
|
|
114
|
+
}));
|
|
116
115
|
};
|
|
117
116
|
var ScrollableCustomList = exports.ScrollableCustomList = _react.default.forwardRef(function (props, ref) {
|
|
118
117
|
var scrollEvent = function scrollEvent(evt) {
|
|
@@ -148,7 +148,6 @@ var useStyles = (0, _styles.makeStyles)(function (theme) {
|
|
|
148
148
|
};
|
|
149
149
|
});
|
|
150
150
|
var Checkbox = function Checkbox(_ref) {
|
|
151
|
-
var _classNames, _classNames2, _classNames3;
|
|
152
151
|
var checkboxProps = _ref.checkboxProps;
|
|
153
152
|
if ((0, _CheckboxProps.isCheckboxProps)(checkboxProps) === false) {
|
|
154
153
|
throw new TypeError("checkboxProps property is not of type CheckboxProps");
|
|
@@ -179,13 +178,13 @@ var Checkbox = function Checkbox(_ref) {
|
|
|
179
178
|
disabled: disabled,
|
|
180
179
|
color: "primary",
|
|
181
180
|
checkedIcon: /*#__PURE__*/_react.default.createElement("span", {
|
|
182
|
-
className: (0, _classnames.default)((
|
|
181
|
+
className: (0, _classnames.default)(_defineProperty(_defineProperty(_defineProperty({}, "".concat(classes.checkBoxIcon), !readOnly), "".concat(classes.checkBoxIconChecked), !readOnly && value), "".concat(classes.checkBoxIconReadOnlyChecked), readOnly && value))
|
|
183
182
|
}),
|
|
184
183
|
icon: /*#__PURE__*/_react.default.createElement("span", {
|
|
185
|
-
className: (0, _classnames.default)((
|
|
184
|
+
className: (0, _classnames.default)(_defineProperty(_defineProperty({}, "".concat(classes.checkBoxIcon), !readOnly), "".concat(classes.checkBoxIconReadOnly), readOnly && !value))
|
|
186
185
|
}),
|
|
187
186
|
indeterminateIcon: /*#__PURE__*/_react.default.createElement("span", {
|
|
188
|
-
className: (0, _classnames.default)((
|
|
187
|
+
className: (0, _classnames.default)(_defineProperty(_defineProperty(_defineProperty({}, "".concat(classes.checkBoxIcon), !readOnly), "".concat(classes.indeterminateIconChecked), !readOnly && indeterminate), "".concat(classes.indeterminateIconReadOnly), readOnly && indeterminate))
|
|
189
188
|
})
|
|
190
189
|
});
|
|
191
190
|
return label == null ? checkBoxMui : /*#__PURE__*/_react.default.createElement(_FormControlLabel.default, {
|
|
@@ -29,7 +29,6 @@ var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoader
|
|
|
29
29
|
return a;
|
|
30
30
|
};
|
|
31
31
|
var useStyles = (0, _styles.makeStyles)(function (theme) {
|
|
32
|
-
var _MuiFormControlLab;
|
|
33
32
|
return {
|
|
34
33
|
container: {
|
|
35
34
|
display: "flex",
|
|
@@ -39,15 +38,15 @@ var useStyles = (0, _styles.makeStyles)(function (theme) {
|
|
|
39
38
|
display: "flex",
|
|
40
39
|
flexDirection: "row",
|
|
41
40
|
flexWrap: "wrap",
|
|
42
|
-
"& .MuiFormControlLabel-root": (
|
|
41
|
+
"& .MuiFormControlLabel-root": _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, theme.breakpoints.up("xs"), {}), theme.breakpoints.up("sm"), {}), theme.breakpoints.up("md"), {
|
|
43
42
|
width: "45%"
|
|
44
|
-
}),
|
|
43
|
+
}), theme.breakpoints.up("lg"), {
|
|
45
44
|
width: "30%"
|
|
46
|
-
}),
|
|
45
|
+
}), theme.breakpoints.up("xl"), {
|
|
47
46
|
width: "20%"
|
|
48
|
-
}),
|
|
47
|
+
}), "& + .MuiFormControlLabel-root", {
|
|
49
48
|
marginTop: theme.spacing(1)
|
|
50
|
-
})
|
|
49
|
+
})
|
|
51
50
|
},
|
|
52
51
|
errorText: {
|
|
53
52
|
marginTop: theme.spacing(0.5),
|
|
@@ -243,10 +243,9 @@ var Select = function Select(_ref) {
|
|
|
243
243
|
}
|
|
244
244
|
}, positionOverride), getIconButtonMenuProps(ref.current));
|
|
245
245
|
var items = options == null ? void 0 : options.map(function (option) {
|
|
246
|
-
var _classNames;
|
|
247
246
|
var clss = option != null && option.level ? classes["level" + option.level] : "";
|
|
248
247
|
var appliedClasses = (0, _classnames.default)(classes.baseItem, clss);
|
|
249
|
-
var labelClss = (0, _classnames.default)((
|
|
248
|
+
var labelClss = (0, _classnames.default)(_defineProperty(_defineProperty({}, classes.label, true), classes.emptyLabel, option.value === "" || option.value === "~~#~~"));
|
|
250
249
|
var disabled = !!option.disabled;
|
|
251
250
|
var groupHeader = !!option.isGroupHeader;
|
|
252
251
|
if (groupHeader) {
|
|
@@ -90,7 +90,6 @@ var useStyles = (0, _styles.makeStyles)(function (theme) {
|
|
|
90
90
|
};
|
|
91
91
|
});
|
|
92
92
|
var StandaloneRadio = function StandaloneRadio(_ref) {
|
|
93
|
-
var _classNames, _classNames2;
|
|
94
93
|
var radioProps = _ref.radioProps;
|
|
95
94
|
var classes = useStyles();
|
|
96
95
|
if ((0, _standaloneRadioProps.isStandaloneRadioProps)(radioProps) === false) {
|
|
@@ -116,10 +115,10 @@ var StandaloneRadio = function StandaloneRadio(_ref) {
|
|
|
116
115
|
inputProps: inputProps,
|
|
117
116
|
name: name,
|
|
118
117
|
checkedIcon: /*#__PURE__*/_react.default.createElement("span", {
|
|
119
|
-
className: (0, _classnames.default)((
|
|
118
|
+
className: (0, _classnames.default)(_defineProperty(_defineProperty(_defineProperty({}, "".concat(classes.radioIcon), !readOnly), "".concat(classes.radioIconChecked), !readOnly && checked), "".concat(classes.radioReadOnlyChecked), readOnly && checked))
|
|
120
119
|
}),
|
|
121
120
|
icon: /*#__PURE__*/_react.default.createElement("span", {
|
|
122
|
-
className: (0, _classnames.default)((
|
|
121
|
+
className: (0, _classnames.default)(_defineProperty(_defineProperty({}, "".concat(classes.radioIcon), !readOnly), "".concat(classes.radioReadOnly), readOnly))
|
|
123
122
|
}),
|
|
124
123
|
classes: {
|
|
125
124
|
root: (0, _classnames.default)(classes.root, radioProps == null ? void 0 : radioProps.getStyle(_standaloneRadioProps.default.ruleNames.root), readOnly && checked ? classes.cursorDefault : null)
|
|
@@ -4,7 +4,6 @@ exports.__esModule = true;
|
|
|
4
4
|
exports.inputTypes = exports.default = exports.createInput = void 0;
|
|
5
5
|
var _react = _interopRequireDefault(require("react"));
|
|
6
6
|
var _index = require("./index");
|
|
7
|
-
var _propsClasses, _inputComponents, _propsPropertyName;
|
|
8
7
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
8
|
(function () {
|
|
10
9
|
var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
|
|
@@ -36,9 +35,9 @@ var inputTypes = exports.inputTypes = {
|
|
|
36
35
|
standaloneRadio: "standaloneRadio",
|
|
37
36
|
switch: "switch"
|
|
38
37
|
};
|
|
39
|
-
var propsClasses = (
|
|
40
|
-
var inputComponents = (
|
|
41
|
-
var propsPropertyName = (
|
|
38
|
+
var propsClasses = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, inputTypes.inputBase, _index.InputBaseProps), inputTypes.checkbox, _index.CheckboxProps), inputTypes.checkboxGroup, _index.CheckboxGroupProps), inputTypes.radio, _index.RadioProps), inputTypes.select, _index.SelectProps), inputTypes.standaloneRadio, _index.StandaloneRadioProps), inputTypes.switch, _index.SwitchProps);
|
|
39
|
+
var inputComponents = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, inputTypes.inputBase, _index.InputBase), inputTypes.checkbox, _index.Checkbox), inputTypes.checkboxGroup, _index.CheckboxGroup), inputTypes.radio, _index.Radio), inputTypes.select, _index.Select), inputTypes.standaloneRadio, _index.StandaloneRadio), inputTypes.switch, _index.Switch);
|
|
40
|
+
var propsPropertyName = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, inputTypes.inputBase, "inputProps"), inputTypes.checkbox, "checkboxProps"), inputTypes.checkboxGroup, "checkboxGroupProps"), inputTypes.radio, "radioProps"), inputTypes.select, "selectProps"), inputTypes.standaloneRadio, "radioProps"), inputTypes.switch, "switchProps");
|
|
42
41
|
var createInput = exports.createInput = function createInput(inputType, _ref) {
|
|
43
42
|
var props = _extends({}, (_objectDestructuringEmpty(_ref), _ref));
|
|
44
43
|
var typePropsInstance = new propsClasses[inputType]();
|
|
@@ -136,7 +136,6 @@ var setThemeProps = function setThemeProps(theme) {
|
|
|
136
136
|
});
|
|
137
137
|
};
|
|
138
138
|
var setThemeOverrides = function setThemeOverrides(theme) {
|
|
139
|
-
var _objectSpread2;
|
|
140
139
|
return _objectSpread(_objectSpread({}, theme.overrides), {}, {
|
|
141
140
|
MuiButtonBase: _objectSpread(_objectSpread({}, theme.MuiButtonBase), {}, {
|
|
142
141
|
root: _objectSpread(_objectSpread({}, theme.root), {}, {
|
|
@@ -588,7 +587,7 @@ var setThemeOverrides = function setThemeOverrides(theme) {
|
|
|
588
587
|
})
|
|
589
588
|
}),
|
|
590
589
|
MuiTab: _objectSpread(_objectSpread({}, theme.MuiTab), {}, {
|
|
591
|
-
root: _objectSpread(_objectSpread({}, theme.root), {}, (
|
|
590
|
+
root: _objectSpread(_objectSpread({}, theme.root), {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
|
|
592
591
|
backgroundColor: theme.palette.common.white,
|
|
593
592
|
color: theme.palette.grey.light,
|
|
594
593
|
border: "1px solid ".concat(theme.palette.grey.borders),
|
|
@@ -600,9 +599,9 @@ var setThemeOverrides = function setThemeOverrides(theme) {
|
|
|
600
599
|
textTransform: "uppercase",
|
|
601
600
|
flexGrow: 0,
|
|
602
601
|
borderBottom: "1px solid ".concat(theme.palette.primary.main)
|
|
603
|
-
},
|
|
602
|
+
}, theme.breakpoints.up("sm"), {
|
|
604
603
|
minWidth: 0
|
|
605
|
-
}),
|
|
604
|
+
}), "& .MuiIconButton-root", {
|
|
606
605
|
padding: theme.spacing(0),
|
|
607
606
|
flexGrow: 0,
|
|
608
607
|
minWidth: 0,
|
|
@@ -610,22 +609,22 @@ var setThemeOverrides = function setThemeOverrides(theme) {
|
|
|
610
609
|
"&:hover": {
|
|
611
610
|
backgroundColor: "transparent"
|
|
612
611
|
}
|
|
613
|
-
}),
|
|
612
|
+
}), "&.Mui-selected", {
|
|
614
613
|
color: theme.palette.primary.main,
|
|
615
614
|
borderColor: theme.palette.primary.main,
|
|
616
615
|
borderBottom: "1px solid ".concat(theme.palette.common.white)
|
|
617
|
-
}),
|
|
616
|
+
}), "&.MuiTab-labelIcon svg", {
|
|
618
617
|
marginRight: theme.spacing(1)
|
|
619
|
-
}),
|
|
618
|
+
}), "& .MuiTab-wrapper", {
|
|
620
619
|
flexDirection: "row"
|
|
621
|
-
}),
|
|
620
|
+
}), "&.MuiButtonBase-root:focus, &.MuiButtonBase-root:active", {
|
|
622
621
|
boxShadow: "none",
|
|
623
622
|
borderRadius: "4px 4px 0 0"
|
|
624
|
-
}),
|
|
623
|
+
}), "& .MuiTypography-root", {
|
|
625
624
|
fontFamily: theme.typography.button.fontFamily
|
|
626
|
-
}),
|
|
625
|
+
}), "& + &", {
|
|
627
626
|
marginLeft: "0 !important"
|
|
628
|
-
})
|
|
627
|
+
})),
|
|
629
628
|
labelIcon: _objectSpread(_objectSpread({}, theme.labelIcon), {}, {
|
|
630
629
|
minHeight: theme.spacing(4.3),
|
|
631
630
|
padding: "".concat(theme.spacing(1.4), " ").concat(theme.spacing(2), " !important"),
|
package/dist/hocs/withToggle.js
CHANGED
|
@@ -31,14 +31,13 @@ var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoader
|
|
|
31
31
|
var withToggle = function withToggle(propName) {
|
|
32
32
|
console.warn("Higher order component withToggle has been deprecated in favor of React hook useToggle");
|
|
33
33
|
return (0, _recompose.withProps)(__signature__(__signature__(function (props) {
|
|
34
|
-
var _ref;
|
|
35
34
|
var initProp = props[propName + "Init"];
|
|
36
35
|
var _useToggle = (0, _useToggle3.default)(initProp),
|
|
37
36
|
_useToggle2 = _slicedToArray(_useToggle, 3),
|
|
38
37
|
prop = _useToggle2[0],
|
|
39
38
|
toggle = _useToggle2[1],
|
|
40
39
|
reset = _useToggle2[2];
|
|
41
|
-
return
|
|
40
|
+
return _defineProperty(_defineProperty(_defineProperty({}, propName, prop), "toggle", toggle), "reset", reset);
|
|
42
41
|
}, "useToggle{[prop, toggle, reset]}", function () {
|
|
43
42
|
return [_useToggle3.default];
|
|
44
43
|
}), "useToggle{[prop, toggle, reset]}", function () {
|
|
@@ -40,6 +40,9 @@ var authenticationReducer = function authenticationReducer(state, action) {
|
|
|
40
40
|
s.set("upn", action.payload.upn);
|
|
41
41
|
s.set("name", action.payload.name);
|
|
42
42
|
var claims = action.payload.rolesClaimsValues;
|
|
43
|
+
if (action.meta && action.meta.overrideClaims) {
|
|
44
|
+
s.set("rolesClaimsValues", _immutable.default.fromJS({}));
|
|
45
|
+
}
|
|
43
46
|
claims.forEach(function (claim) {
|
|
44
47
|
var _claim$split = claim.split("/"),
|
|
45
48
|
_claim$split2 = _slicedToArray(_claim$split, 3),
|
|
@@ -5,7 +5,6 @@ exports.validationRules = exports.showError = exports.hasValidationErrors = expo
|
|
|
5
5
|
var _propertyValidator = require("./propertyValidator");
|
|
6
6
|
var _constants = require("../constants");
|
|
7
7
|
var _lodash = require("lodash");
|
|
8
|
-
var _validationRules;
|
|
9
8
|
(function () {
|
|
10
9
|
var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
|
|
11
10
|
enterModule && enterModule(module);
|
|
@@ -23,23 +22,23 @@ var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoader
|
|
|
23
22
|
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
|
|
24
23
|
return a;
|
|
25
24
|
};
|
|
26
|
-
var validationRules = exports.validationRules = (
|
|
25
|
+
var validationRules = exports.validationRules = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, _constants.validationErrorTypes.fieldIsRequired, function (value) {
|
|
27
26
|
if (value === null || value === undefined) return false;
|
|
28
27
|
if ((0, _propertyValidator.isString)(value) && (0, _propertyValidator.isStringNullOrWhitespace)(value)) return false;
|
|
29
28
|
return true;
|
|
30
|
-
}),
|
|
29
|
+
}), _constants.validationErrorTypes.fieldMustBeValidEmail, function (value) {
|
|
31
30
|
if (!value) return true;
|
|
32
31
|
var regexRule = new RegExp("^(([\\w-]+[\\.\\+])+[\\w-]+|([a-zA-Z]{1}|[\\w-]{2,}))@((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\.([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\.([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\.([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])){1}|(([a-zA-Z0-9][a-zA-Z0-9\\.\\-]+[a-zA-Z0-9])|([a-zA-Z0-9]{1,}))\\.[a-zA-Z]{2,12})$");
|
|
33
32
|
return regexRule.test(value);
|
|
34
|
-
}),
|
|
33
|
+
}), _constants.validationErrorTypes.fieldMustBeValidPhoneNumber, function (value) {
|
|
35
34
|
if (!value) return true;
|
|
36
35
|
var regexRule = new RegExp("^(\\+?\\-?[ 0-9])*$");
|
|
37
36
|
return regexRule.test(value);
|
|
38
|
-
}),
|
|
37
|
+
}), _constants.validationErrorTypes.fieldMustBeValidPhoneExtension, function (value) {
|
|
39
38
|
if (!value) return true;
|
|
40
39
|
var regexRule = new RegExp("^(\\-?\\*?\\#?[ 0-9])*$");
|
|
41
40
|
return regexRule.test(value);
|
|
42
|
-
})
|
|
41
|
+
});
|
|
43
42
|
var showError = exports.showError = function showError(field) {
|
|
44
43
|
if (field == null) return false;
|
|
45
44
|
return field.error != null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "orc-shared",
|
|
3
|
-
"version": "5.7.0-dev.
|
|
3
|
+
"version": "5.7.0-dev.3",
|
|
4
4
|
"description": "Shared code for Orckestra applications",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
"./src/": "./src/",
|
|
9
9
|
"./dist/": "./dist/"
|
|
10
10
|
},
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": ">= 18",
|
|
13
|
+
"npm": ">= 9.0.0"
|
|
14
|
+
},
|
|
11
15
|
"scripts": {
|
|
12
16
|
"build": "orc-scripts prep && npm run build:source --",
|
|
13
17
|
"build:source": "orc-scripts build --ignore \"**/*.test.js\",\"src/translations/*\" --no-copy-files",
|
|
@@ -51,10 +55,10 @@
|
|
|
51
55
|
"@testing-library/react": "^10.4.9"
|
|
52
56
|
},
|
|
53
57
|
"peerDependencies": {
|
|
54
|
-
"orc-scripts": "
|
|
58
|
+
"orc-scripts": "2.0.0-dev.2"
|
|
55
59
|
},
|
|
56
60
|
"dependencies": {
|
|
57
|
-
"orc-scripts": "
|
|
61
|
+
"orc-scripts": "2.0.0-dev.2",
|
|
58
62
|
"react-number-format": "^5.3.0"
|
|
59
63
|
},
|
|
60
64
|
"sideEffects": false,
|
|
@@ -14,6 +14,11 @@ const authenticationReducer = (state = initialState, action) => {
|
|
|
14
14
|
s.set("upn", action.payload.upn);
|
|
15
15
|
s.set("name", action.payload.name);
|
|
16
16
|
const claims = action.payload.rolesClaimsValues;
|
|
17
|
+
|
|
18
|
+
if (action.meta && action.meta.overrideClaims) {
|
|
19
|
+
s.set("rolesClaimsValues", Immutable.fromJS({}));
|
|
20
|
+
}
|
|
21
|
+
|
|
17
22
|
claims.forEach(claim => {
|
|
18
23
|
const [app, scope, role] = claim.split("/");
|
|
19
24
|
s.setIn(["rolesClaimsValues", app, scope, role], true);
|
|
@@ -81,6 +81,87 @@ describe("authentication", () => {
|
|
|
81
81
|
});
|
|
82
82
|
});
|
|
83
83
|
|
|
84
|
+
describe("storing authentication with override", () => {
|
|
85
|
+
it("clears existing roles and claims if override is true", () => {
|
|
86
|
+
const oldState = Immutable.fromJS({
|
|
87
|
+
upn: "oldupn",
|
|
88
|
+
name: "oldname",
|
|
89
|
+
rolesClaimsValues: {
|
|
90
|
+
Customer: { "*": { Reader: true } },
|
|
91
|
+
Generic: { "*": { Reader: true } },
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
const action = {
|
|
95
|
+
type: GET_AUTHENTICATION_PROFILE_SUCCESS,
|
|
96
|
+
payload: {
|
|
97
|
+
upn: "newupn",
|
|
98
|
+
name: "newname",
|
|
99
|
+
rolesClaimsValues: ["Setting/*/Reader", "Tenant/*/Reader"],
|
|
100
|
+
},
|
|
101
|
+
meta: { overrideClaims: true },
|
|
102
|
+
};
|
|
103
|
+
const newState = reducer(oldState, action);
|
|
104
|
+
return expect(newState, "to have value at", ["rolesClaimsValues"], Immutable.fromJS({
|
|
105
|
+
Setting: { "*": { Reader: true } },
|
|
106
|
+
Tenant: { "*": { Reader: true } },
|
|
107
|
+
}));
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it("does not clear existing roles and claims if override is false", () => {
|
|
111
|
+
const oldState = Immutable.fromJS({
|
|
112
|
+
upn: "oldupn",
|
|
113
|
+
name: "oldname",
|
|
114
|
+
rolesClaimsValues: {
|
|
115
|
+
Customer: { "*": { Reader: true } },
|
|
116
|
+
Generic: { "*": { Reader: true } },
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
const action = {
|
|
120
|
+
type: GET_AUTHENTICATION_PROFILE_SUCCESS,
|
|
121
|
+
payload: {
|
|
122
|
+
upn: "newupn",
|
|
123
|
+
name: "newname",
|
|
124
|
+
rolesClaimsValues: ["Setting/*/Reader", "Tenant/*/Reader"],
|
|
125
|
+
},
|
|
126
|
+
meta: { overrideClaims: false },
|
|
127
|
+
};
|
|
128
|
+
const newState = reducer(oldState, action);
|
|
129
|
+
return expect(newState, "to have value at", ["rolesClaimsValues"], Immutable.fromJS({
|
|
130
|
+
Customer: { "*": { Reader: true } },
|
|
131
|
+
Generic: { "*": { Reader: true } },
|
|
132
|
+
Setting: { "*": { Reader: true } },
|
|
133
|
+
Tenant: { "*": { Reader: true } },
|
|
134
|
+
}));
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it("does not clear existing roles and claims if override is not provided", () => {
|
|
138
|
+
const oldState = Immutable.fromJS({
|
|
139
|
+
upn: "oldupn",
|
|
140
|
+
name: "oldname",
|
|
141
|
+
rolesClaimsValues: {
|
|
142
|
+
Customer: { "*": { Reader: true } },
|
|
143
|
+
Generic: { "*": { Reader: true } },
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
const action = {
|
|
147
|
+
type: GET_AUTHENTICATION_PROFILE_SUCCESS,
|
|
148
|
+
payload: {
|
|
149
|
+
upn: "newupn",
|
|
150
|
+
name: "newname",
|
|
151
|
+
rolesClaimsValues: ["Setting/*/Reader", "Tenant/*/Reader"],
|
|
152
|
+
},
|
|
153
|
+
// meta: { overrideClaims: false }, // Intentionally omitted
|
|
154
|
+
};
|
|
155
|
+
const newState = reducer(oldState, action);
|
|
156
|
+
return expect(newState, "to have value at", ["rolesClaimsValues"], Immutable.fromJS({
|
|
157
|
+
Customer: { "*": { Reader: true } },
|
|
158
|
+
Generic: { "*": { Reader: true } },
|
|
159
|
+
Setting: { "*": { Reader: true } },
|
|
160
|
+
Tenant: { "*": { Reader: true } },
|
|
161
|
+
}));
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
|
|
84
165
|
describe("sign out", () => {
|
|
85
166
|
const { location } = window;
|
|
86
167
|
beforeAll(() => {
|