@banch0u/core-project-test-repository 2.3.15 → 2.3.17
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.
|
@@ -6,8 +6,8 @@ import style from "./index.module.scss";
|
|
|
6
6
|
import { Select as AntdSelect, Divider } from "antd";
|
|
7
7
|
import { FormItemInputContext } from "antd/es/form/context";
|
|
8
8
|
import Button from "../Button";
|
|
9
|
+
import DisabledContext from "antd/es/config-provider/DisabledContext";
|
|
9
10
|
var Select = function Select(_ref) {
|
|
10
|
-
var _ref2;
|
|
11
11
|
var children = _ref.children,
|
|
12
12
|
className = _ref.className,
|
|
13
13
|
size = _ref.size,
|
|
@@ -27,7 +27,8 @@ var Select = function Select(_ref) {
|
|
|
27
27
|
width = _ref.width,
|
|
28
28
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
29
29
|
var formItemContext = useContext(FormItemInputContext);
|
|
30
|
-
var
|
|
30
|
+
var configDisabled = useContext(DisabledContext);
|
|
31
|
+
var mergedDisabled = Boolean(customDisabled || (formItemContext === null || formItemContext === void 0 ? void 0 : formItemContext.disabled) || configDisabled);
|
|
31
32
|
var getClassName = function getClassName() {
|
|
32
33
|
if (className) return className;
|
|
33
34
|
switch (size) {
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
+
import { createAsyncThunk, createSlice } from "@reduxjs/toolkit";
|
|
4
|
+
import Services from "./service";
|
|
5
|
+
import { setLoading } from "../global";
|
|
6
|
+
import { errorMessage } from "../../../utils/message";
|
|
7
|
+
var initialState = {
|
|
8
|
+
// map: { "archive.navs.create": true, "archive.navs.delete": false, ... }
|
|
9
|
+
policy: {},
|
|
10
|
+
// whether initial check was completed (useful to avoid running again)
|
|
11
|
+
checked: false,
|
|
12
|
+
// optional: errors
|
|
13
|
+
error: null
|
|
14
|
+
};
|
|
15
|
+
export var checkPolicies = createAsyncThunk("policies/checkPolicies",
|
|
16
|
+
/*#__PURE__*/
|
|
17
|
+
// policies: array of policy strings
|
|
18
|
+
function () {
|
|
19
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(policies, _ref) {
|
|
20
|
+
var dispatch, rejectWithValue, response, results, items, errMsg, _t;
|
|
21
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
22
|
+
while (1) switch (_context.prev = _context.next) {
|
|
23
|
+
case 0:
|
|
24
|
+
dispatch = _ref.dispatch, rejectWithValue = _ref.rejectWithValue;
|
|
25
|
+
_context.prev = 1;
|
|
26
|
+
dispatch(setLoading(true));
|
|
27
|
+
_context.next = 2;
|
|
28
|
+
return Services.checkPolicies(policies);
|
|
29
|
+
case 2:
|
|
30
|
+
response = _context.sent;
|
|
31
|
+
// normalize into the same { [policyName]: boolean } shape the old
|
|
32
|
+
// per-policy implementation produced
|
|
33
|
+
results = {};
|
|
34
|
+
items = Array.isArray(response === null || response === void 0 ? void 0 : response.data) ? response.data : [];
|
|
35
|
+
items.forEach(function (item) {
|
|
36
|
+
if (item && typeof item.name === "string") {
|
|
37
|
+
results[item.name] = !!item.hasAccess;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// make sure every requested policy is present in the map even if the
|
|
42
|
+
// backend omitted it, so consumers can rely on the key existing
|
|
43
|
+
policies.forEach(function (name) {
|
|
44
|
+
if (!(name in results)) {
|
|
45
|
+
results[name] = false;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
dispatch(setLoading(false));
|
|
49
|
+
return _context.abrupt("return", results);
|
|
50
|
+
case 3:
|
|
51
|
+
_context.prev = 3;
|
|
52
|
+
_t = _context["catch"](1);
|
|
53
|
+
dispatch(setLoading(false));
|
|
54
|
+
errMsg = _t && _t.response && _t.response.data && _t.response.data.message || _t.message || "Policy check failed";
|
|
55
|
+
errorMessage(errMsg);
|
|
56
|
+
return _context.abrupt("return", rejectWithValue(errMsg));
|
|
57
|
+
case 4:
|
|
58
|
+
case "end":
|
|
59
|
+
return _context.stop();
|
|
60
|
+
}
|
|
61
|
+
}, _callee, null, [[1, 3]]);
|
|
62
|
+
}));
|
|
63
|
+
return function (_x, _x2) {
|
|
64
|
+
return _ref2.apply(this, arguments);
|
|
65
|
+
};
|
|
66
|
+
}());
|
|
67
|
+
var policy = createSlice({
|
|
68
|
+
name: "policy",
|
|
69
|
+
initialState: initialState,
|
|
70
|
+
reducers: {
|
|
71
|
+
// optional manual setter if needed
|
|
72
|
+
setPolicies: function setPolicies(state, action) {
|
|
73
|
+
state.policy = action.payload;
|
|
74
|
+
state.checked = true;
|
|
75
|
+
state.error = null;
|
|
76
|
+
},
|
|
77
|
+
resetPolicies: function resetPolicies(state) {
|
|
78
|
+
state.policy = {};
|
|
79
|
+
state.checked = false;
|
|
80
|
+
state.error = null;
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
extraReducers: function extraReducers(builder) {
|
|
84
|
+
builder.addCase(checkPolicies.fulfilled, function (state, action) {
|
|
85
|
+
state.policy = action.payload || {};
|
|
86
|
+
state.checked = true;
|
|
87
|
+
state.error = null;
|
|
88
|
+
}).addCase(checkPolicies.rejected, function (state, action) {
|
|
89
|
+
var _action$error;
|
|
90
|
+
state.error = action.payload || ((_action$error = action.error) === null || _action$error === void 0 ? void 0 : _action$error.message);
|
|
91
|
+
state.checked = true; // we attempted check but failed
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
var _policy$actions = policy.actions,
|
|
96
|
+
setPolicies = _policy$actions.setPolicies,
|
|
97
|
+
resetPolicies = _policy$actions.resetPolicies;
|
|
98
|
+
export { setPolicies, resetPolicies };
|
|
99
|
+
export default policy.reducer;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
4
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
5
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
6
|
+
import api from "../../../utils/axios";
|
|
7
|
+
var Services = /*#__PURE__*/_createClass(function Services() {
|
|
8
|
+
_classCallCheck(this, Services);
|
|
9
|
+
});
|
|
10
|
+
_defineProperty(Services, "checkPolicy", /*#__PURE__*/function () {
|
|
11
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(policy) {
|
|
12
|
+
var response, _error$response, _t;
|
|
13
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
14
|
+
while (1) switch (_context.prev = _context.next) {
|
|
15
|
+
case 0:
|
|
16
|
+
_context.prev = 0;
|
|
17
|
+
_context.next = 1;
|
|
18
|
+
return api.post("/profile/policycheck", {
|
|
19
|
+
policy: policy
|
|
20
|
+
});
|
|
21
|
+
case 1:
|
|
22
|
+
response = _context.sent;
|
|
23
|
+
if (!((response === null || response === void 0 ? void 0 : response.status) === 204)) {
|
|
24
|
+
_context.next = 2;
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
return _context.abrupt("return", true);
|
|
28
|
+
case 2:
|
|
29
|
+
if (!((response === null || response === void 0 ? void 0 : response.status) === 404)) {
|
|
30
|
+
_context.next = 3;
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
return _context.abrupt("return", false);
|
|
34
|
+
case 3:
|
|
35
|
+
return _context.abrupt("return", false);
|
|
36
|
+
case 4:
|
|
37
|
+
_context.prev = 4;
|
|
38
|
+
_t = _context["catch"](0);
|
|
39
|
+
if (!(((_error$response = _t.response) === null || _error$response === void 0 ? void 0 : _error$response.status) === 404)) {
|
|
40
|
+
_context.next = 5;
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
return _context.abrupt("return", false);
|
|
44
|
+
case 5:
|
|
45
|
+
throw _t;
|
|
46
|
+
case 6:
|
|
47
|
+
case "end":
|
|
48
|
+
return _context.stop();
|
|
49
|
+
}
|
|
50
|
+
}, _callee, null, [[0, 4]]);
|
|
51
|
+
}));
|
|
52
|
+
return function (_x) {
|
|
53
|
+
return _ref.apply(this, arguments);
|
|
54
|
+
};
|
|
55
|
+
}());
|
|
56
|
+
_defineProperty(Services, "checkPolicies", /*#__PURE__*/function () {
|
|
57
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(policies) {
|
|
58
|
+
var response;
|
|
59
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
60
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
61
|
+
case 0:
|
|
62
|
+
_context2.next = 1;
|
|
63
|
+
return api.post("/profile/policiescheck", {
|
|
64
|
+
policies: policies
|
|
65
|
+
});
|
|
66
|
+
case 1:
|
|
67
|
+
response = _context2.sent;
|
|
68
|
+
return _context2.abrupt("return", response === null || response === void 0 ? void 0 : response.data);
|
|
69
|
+
case 2:
|
|
70
|
+
case "end":
|
|
71
|
+
return _context2.stop();
|
|
72
|
+
}
|
|
73
|
+
}, _callee2);
|
|
74
|
+
}));
|
|
75
|
+
return function (_x2) {
|
|
76
|
+
return _ref2.apply(this, arguments);
|
|
77
|
+
};
|
|
78
|
+
}());
|
|
79
|
+
export default Services;
|
package/dist/store/store.js
CHANGED
|
@@ -6,7 +6,8 @@ import { notification } from "./slices/notification";
|
|
|
6
6
|
import { companyInfo } from "./slices/companyInfo";
|
|
7
7
|
import { questionnaire } from "./slices/questionnaire";
|
|
8
8
|
import { employees } from "./slices/employees";
|
|
9
|
+
import policy from "./slices/policy";
|
|
9
10
|
export var store = configureStore({
|
|
10
|
-
reducer: _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, employees.name, employees.reducer), notification.name, notification.reducer), global.name, global.reducer), auth.name, auth.reducer), companyInfo.name, companyInfo.reducer), questionnaire.name, questionnaire.reducer)
|
|
11
|
+
reducer: _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, employees.name, employees.reducer), notification.name, notification.reducer), global.name, global.reducer), auth.name, auth.reducer), companyInfo.name, companyInfo.reducer), questionnaire.name, questionnaire.reducer), "policy", policy)
|
|
11
12
|
});
|
|
12
13
|
export default store;
|