orc-shared 5.10.1-dev.3 → 5.10.1-dev.5
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/AppFrame/Topbar.js +5 -5
- package/dist/utils/ListHelper.js +15 -5
- package/package.json +1 -1
- package/src/components/AppFrame/Topbar.js +4 -3
- package/src/components/AppFrame/Topbar.test.js +104 -34
- package/src/utils/ListHelper.js +24 -1
- package/src/utils/ListHelper.test.js +60 -0
|
@@ -165,7 +165,7 @@ var sanitizeEnvironmentCode = exports.sanitizeEnvironmentCode = function sanitiz
|
|
|
165
165
|
}
|
|
166
166
|
return envCode; // other names will be used as-is
|
|
167
167
|
};
|
|
168
|
-
var getAppEnvironmentInfo = exports.getAppEnvironmentInfo = function getAppEnvironmentInfo(currentLocation, uiContainerName) {
|
|
168
|
+
var getAppEnvironmentInfo = exports.getAppEnvironmentInfo = function getAppEnvironmentInfo(currentLocation, uiContainerName, enableHeaderColors) {
|
|
169
169
|
var environmentCode = null;
|
|
170
170
|
var sanitizedEnvironmentCode = null;
|
|
171
171
|
var isDeployedLocalDevEnv = false;
|
|
@@ -187,8 +187,8 @@ var getAppEnvironmentInfo = exports.getAppEnvironmentInfo = function getAppEnvir
|
|
|
187
187
|
// environmentCode = "prd";
|
|
188
188
|
|
|
189
189
|
sanitizedEnvironmentCode = sanitizeEnvironmentCode(environmentCode);
|
|
190
|
-
if (!sanitizedEnvironmentCode ||
|
|
191
|
-
// we never want a different color / text for
|
|
190
|
+
if (!sanitizedEnvironmentCode || !enableHeaderColors) {
|
|
191
|
+
// we never want a different color / text for unknown environment
|
|
192
192
|
return {
|
|
193
193
|
name: "",
|
|
194
194
|
cssClassCategory: null
|
|
@@ -237,8 +237,8 @@ var CurrentApp = exports.CurrentApp = function CurrentApp(_ref) {
|
|
|
237
237
|
iconUri = _ref.iconUri;
|
|
238
238
|
var classes = useStyles();
|
|
239
239
|
var containerInfo = (0, _react.useMemo)(function () {
|
|
240
|
-
var _document$querySelect;
|
|
241
|
-
return getAppEnvironmentInfo(window.location.hostname, (_document$querySelect = document.querySelector('meta[name="cdn-container-name"]')) == null ? void 0 : _document$querySelect.getAttribute("content"));
|
|
240
|
+
var _document$querySelect, _document$querySelect2, _document$querySelect3;
|
|
241
|
+
return getAppEnvironmentInfo(window.location.hostname, (_document$querySelect = document.querySelector('meta[name="cdn-container-name"]')) == null ? void 0 : _document$querySelect.getAttribute("content"), ((_document$querySelect2 = (_document$querySelect3 = document.querySelector('meta[name="header-colors"]')) == null ? void 0 : _document$querySelect3.getAttribute("content")) != null ? _document$querySelect2 : "true") === "true");
|
|
242
242
|
}, []);
|
|
243
243
|
var name;
|
|
244
244
|
if (containerInfo.name) {
|
package/dist/utils/ListHelper.js
CHANGED
|
@@ -6,7 +6,7 @@ var _immutable = _interopRequireDefault(require("immutable"));
|
|
|
6
6
|
var _lodash = require("lodash");
|
|
7
7
|
var _ListHelper;
|
|
8
8
|
var _excluded = ["resetList", "scope", "filters", "sorting"],
|
|
9
|
-
_excluded2 = ["sorting", "filters", "scope", "page", "nextPageToLoad", "index", "list", "totalCount"];
|
|
9
|
+
_excluded2 = ["sorting", "filters", "scope", "page", "nextPageToLoad", "index", "list", "totalCount", "searchRequested"];
|
|
10
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
11
|
(function () {
|
|
12
12
|
var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
|
|
@@ -30,13 +30,16 @@ var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoader
|
|
|
30
30
|
return a;
|
|
31
31
|
};
|
|
32
32
|
var ListInfoPropertyName = exports.ListInfoPropertyName = "listInfo";
|
|
33
|
-
var standardInfoKeys = ["scope", "page", "filters", "sorting", "totalCount", "nextPageToLoad", "index", "list"];
|
|
33
|
+
var standardInfoKeys = ["scope", "page", "filters", "sorting", "totalCount", "nextPageToLoad", "index", "list", "searchRequested"];
|
|
34
34
|
var ListReducerHelper = /*#__PURE__*/function () {
|
|
35
35
|
function ListReducerHelper(groupPropertyName) {
|
|
36
36
|
var _this = this;
|
|
37
37
|
_defineProperty(this, "setNextPageToLoad", function (state, nextPageToLoad) {
|
|
38
38
|
return state.setIn([_this.groupPropertyName, "nextPageToLoad"], nextPageToLoad);
|
|
39
39
|
});
|
|
40
|
+
_defineProperty(this, "setSearchRequested", function (state, searchRequested) {
|
|
41
|
+
return state.setIn([_this.groupPropertyName, "searchRequested"], searchRequested);
|
|
42
|
+
});
|
|
40
43
|
_defineProperty(this, "setResults", function (state, listInfo, forceReset) {
|
|
41
44
|
if (forceReset === void 0) {
|
|
42
45
|
forceReset = false;
|
|
@@ -79,6 +82,7 @@ var ListReducerHelper = /*#__PURE__*/function () {
|
|
|
79
82
|
s.setIn([_this.groupPropertyName, "scope"], scope != null ? scope : null);
|
|
80
83
|
s.setIn([_this.groupPropertyName, "filters"], _immutable.default.fromJS(filters != null ? filters : null));
|
|
81
84
|
s.setIn([_this.groupPropertyName, "sorting"], _immutable.default.fromJS(sorting != null ? sorting : null));
|
|
85
|
+
s.setIn([_this.groupPropertyName, "searchRequested"], false);
|
|
82
86
|
var otherKeys = Object.keys(others);
|
|
83
87
|
s.get(_this.groupPropertyName).keySeq().forEach(function (key) {
|
|
84
88
|
if (!standardInfoKeys.includes(key) && !otherKeys.includes(key)) {
|
|
@@ -109,7 +113,7 @@ var ListReducerHelper = /*#__PURE__*/function () {
|
|
|
109
113
|
if (propertiesToKeep === void 0) {
|
|
110
114
|
propertiesToKeep = {};
|
|
111
115
|
}
|
|
112
|
-
var updatedState = state.setIn([_this.groupPropertyName, "nextPageToLoad"], 1).setIn([_this.groupPropertyName, "index"], _immutable.default.fromJS({})).setIn([_this.groupPropertyName, "list"], _immutable.default.fromJS([])).setIn([_this.groupPropertyName, "totalCount"], 0);
|
|
116
|
+
var updatedState = state.setIn([_this.groupPropertyName, "nextPageToLoad"], 1).setIn([_this.groupPropertyName, "searchRequested"], false).setIn([_this.groupPropertyName, "index"], _immutable.default.fromJS({})).setIn([_this.groupPropertyName, "list"], _immutable.default.fromJS([])).setIn([_this.groupPropertyName, "totalCount"], 0);
|
|
113
117
|
if (!propertiesToKeep.filters) {
|
|
114
118
|
updatedState = updatedState.setIn([_this.groupPropertyName, "filters"], null);
|
|
115
119
|
}
|
|
@@ -145,7 +149,8 @@ var ListSelectorHelper = /*#__PURE__*/function () {
|
|
|
145
149
|
currentPage: listInfo.get("page"),
|
|
146
150
|
currentFilters: (_listInfo$get = listInfo.get("filters")) == null ? void 0 : _listInfo$get.toJS(),
|
|
147
151
|
currentSorting: (_listInfo$get2 = listInfo.get("sorting")) == null ? void 0 : _listInfo$get2.toJS(),
|
|
148
|
-
totalCount: listInfo.get("totalCount")
|
|
152
|
+
totalCount: listInfo.get("totalCount"),
|
|
153
|
+
searchRequested: listInfo.get("searchRequested")
|
|
149
154
|
};
|
|
150
155
|
listInfo.mapKeys(function (key, value) {
|
|
151
156
|
if (standardInfoKeys.includes(key)) {
|
|
@@ -165,6 +170,9 @@ var ListSelectorHelper = /*#__PURE__*/function () {
|
|
|
165
170
|
_defineProperty(this, "getNextPageToLoad", function (state) {
|
|
166
171
|
return state.getIn([_this2.groupPropertyName, "nextPageToLoad"]);
|
|
167
172
|
});
|
|
173
|
+
_defineProperty(this, "getSearchRequested", function (state) {
|
|
174
|
+
return state.getIn([_this2.groupPropertyName, "searchRequested"]);
|
|
175
|
+
});
|
|
168
176
|
this.groupPropertyName = groupPropertyName;
|
|
169
177
|
}
|
|
170
178
|
var _proto2 = ListSelectorHelper.prototype;
|
|
@@ -200,6 +208,7 @@ var ListHelper = /*#__PURE__*/function () {
|
|
|
200
208
|
index = _ref4.index,
|
|
201
209
|
list = _ref4.list,
|
|
202
210
|
totalCount = _ref4.totalCount,
|
|
211
|
+
searchRequested = _ref4.searchRequested,
|
|
203
212
|
additionalValues = _objectWithoutProperties(_ref4, _excluded2);
|
|
204
213
|
return _defineProperty({}, _this3.groupPropertyName, _objectSpread({
|
|
205
214
|
sorting: sorting != null ? sorting : null,
|
|
@@ -209,7 +218,8 @@ var ListHelper = /*#__PURE__*/function () {
|
|
|
209
218
|
nextPageToLoad: nextPageToLoad != null ? nextPageToLoad : 1,
|
|
210
219
|
index: index != null ? index : {},
|
|
211
220
|
list: list != null ? list : [],
|
|
212
|
-
totalCount: totalCount != null ? totalCount : 0
|
|
221
|
+
totalCount: totalCount != null ? totalCount : 0,
|
|
222
|
+
searchRequested: searchRequested != null ? searchRequested : false
|
|
213
223
|
}, additionalValues));
|
|
214
224
|
});
|
|
215
225
|
this.groupPropertyName = groupPropertyName;
|
package/package.json
CHANGED
|
@@ -123,7 +123,7 @@ export const sanitizeEnvironmentCode = envCode => {
|
|
|
123
123
|
return envCode; // other names will be used as-is
|
|
124
124
|
};
|
|
125
125
|
|
|
126
|
-
export const getAppEnvironmentInfo = (currentLocation, uiContainerName) => {
|
|
126
|
+
export const getAppEnvironmentInfo = (currentLocation, uiContainerName, enableHeaderColors) => {
|
|
127
127
|
let environmentCode = null;
|
|
128
128
|
let sanitizedEnvironmentCode = null;
|
|
129
129
|
let isDeployedLocalDevEnv = false;
|
|
@@ -149,8 +149,8 @@ export const getAppEnvironmentInfo = (currentLocation, uiContainerName) => {
|
|
|
149
149
|
|
|
150
150
|
sanitizedEnvironmentCode = sanitizeEnvironmentCode(environmentCode);
|
|
151
151
|
|
|
152
|
-
if (!sanitizedEnvironmentCode ||
|
|
153
|
-
// we never want a different color / text for
|
|
152
|
+
if (!sanitizedEnvironmentCode || !enableHeaderColors) {
|
|
153
|
+
// we never want a different color / text for unknown environment
|
|
154
154
|
return {
|
|
155
155
|
name: "",
|
|
156
156
|
cssClassCategory: null,
|
|
@@ -212,6 +212,7 @@ export const CurrentApp = ({ displayName, iconUri }) => {
|
|
|
212
212
|
return getAppEnvironmentInfo(
|
|
213
213
|
window.location.hostname,
|
|
214
214
|
document.querySelector('meta[name="cdn-container-name"]')?.getAttribute("content"),
|
|
215
|
+
(document.querySelector('meta[name="header-colors"]')?.getAttribute("content") ?? "true") === "true",
|
|
215
216
|
);
|
|
216
217
|
}, []);
|
|
217
218
|
|
|
@@ -314,36 +314,62 @@ describe("getAppEnvironmentInfo", () => {
|
|
|
314
314
|
});
|
|
315
315
|
|
|
316
316
|
it.each([
|
|
317
|
-
[null, "prd", "", null],
|
|
318
|
-
["", "prd", "", null],
|
|
319
|
-
["prd", null, "", null],
|
|
320
|
-
["prd", "", "", null],
|
|
321
|
-
["prd", "prd", "", null],
|
|
322
|
-
["prd", "qa", "1.2-alpha888/qa", "qa"],
|
|
323
|
-
["prd", "int", "1.2-alpha888/int", "qa"],
|
|
324
|
-
["qa", "prd", "qa", "qa"],
|
|
325
|
-
["qa", "qa", "qa — 1.2-alpha888/qa", "qa"],
|
|
326
|
-
["qa", "int", "qa — 1.2-alpha888/int", "qa"],
|
|
327
|
-
["int", "prd", "int", "int"],
|
|
328
|
-
["int", "qa", "int — 1.2-alpha888/qa", "int"],
|
|
329
|
-
["int", "int", "int — 1.2-alpha888/int", "int"],
|
|
330
|
-
["stg", "prd", "stg", "stg"],
|
|
331
|
-
["stg", "stg", "stg — 1.2-alpha888/stg", "stg"],
|
|
332
|
-
["stg", "int", "stg — 1.2-alpha888/int", "stg"],
|
|
333
|
-
["demo1", "prd", "demo1", "int"],
|
|
334
|
-
["demo1", "stg", "demo1 — 1.2-alpha888/stg", "int"],
|
|
335
|
-
["demo1", "int", "demo1 — 1.2-alpha888/int", "int"],
|
|
336
|
-
["rel", "prd", "",
|
|
337
|
-
["rel", "stg", "",
|
|
338
|
-
["rel", "int", "",
|
|
339
|
-
["localdev", "prd", "localdev", "localdev"],
|
|
340
|
-
["localdev", "qa", "localdev", "localdev"],
|
|
317
|
+
[null, "prd", true, "", null],
|
|
318
|
+
["", "prd", true, "", null],
|
|
319
|
+
["prd", null, true, "", null],
|
|
320
|
+
["prd", "", true, "", null],
|
|
321
|
+
["prd", "prd", true, "", null],
|
|
322
|
+
["prd", "qa", true, "1.2-alpha888/qa", "qa"],
|
|
323
|
+
["prd", "int", true, "1.2-alpha888/int", "qa"],
|
|
324
|
+
["qa", "prd", true, "qa", "qa"],
|
|
325
|
+
["qa", "qa", true, "qa — 1.2-alpha888/qa", "qa"],
|
|
326
|
+
["qa", "int", true, "qa — 1.2-alpha888/int", "qa"],
|
|
327
|
+
["int", "prd", true, "int", "int"],
|
|
328
|
+
["int", "qa", true, "int — 1.2-alpha888/qa", "int"],
|
|
329
|
+
["int", "int", true, "int — 1.2-alpha888/int", "int"],
|
|
330
|
+
["stg", "prd", true, "stg", "stg"],
|
|
331
|
+
["stg", "stg", true, "stg — 1.2-alpha888/stg", "stg"],
|
|
332
|
+
["stg", "int", true, "stg — 1.2-alpha888/int", "stg"],
|
|
333
|
+
["demo1", "prd", true, "demo1", "int"],
|
|
334
|
+
["demo1", "stg", true, "demo1 — 1.2-alpha888/stg", "int"],
|
|
335
|
+
["demo1", "int", true, "demo1 — 1.2-alpha888/int", "int"],
|
|
336
|
+
["rel", "prd", true, "rel", "int"],
|
|
337
|
+
["rel", "stg", true, "rel — 1.2-alpha888/stg", "int"],
|
|
338
|
+
["rel", "int", true, "rel — 1.2-alpha888/int", "int"],
|
|
339
|
+
["localdev", "prd", true, "localdev", "localdev"],
|
|
340
|
+
["localdev", "qa", true, "localdev", "localdev"],
|
|
341
|
+
|
|
342
|
+
[null, "prd", false, "", null],
|
|
343
|
+
["", "prd", false, "", null],
|
|
344
|
+
["prd", null, false, "", null],
|
|
345
|
+
["prd", "", false, "", null],
|
|
346
|
+
["prd", "prd", false, "", null],
|
|
347
|
+
["prd", "qa", false, "", null],
|
|
348
|
+
["prd", "int", false, "", null],
|
|
349
|
+
["qa", "prd", false, "", null],
|
|
350
|
+
["qa", "qa", false, "", null],
|
|
351
|
+
["qa", "int", false, "", null],
|
|
352
|
+
["int", "prd", false, "", null],
|
|
353
|
+
["int", "qa", false, "", null],
|
|
354
|
+
["int", "int", false, "", null],
|
|
355
|
+
["stg", "prd", false, "", null],
|
|
356
|
+
["stg", "stg", false, "", null],
|
|
357
|
+
["stg", "int", false, "", null],
|
|
358
|
+
["demo1", "prd", false, "", null],
|
|
359
|
+
["demo1", "stg", false, "", null],
|
|
360
|
+
["demo1", "int", false, "", null],
|
|
361
|
+
["rel", "prd", false, "", null],
|
|
362
|
+
["rel", "stg", false, "", null],
|
|
363
|
+
["rel", "int", false, "", null],
|
|
364
|
+
["localdev", "prd", false, "", null],
|
|
365
|
+
["localdev", "qa", false, "", null],
|
|
341
366
|
])(
|
|
342
|
-
"getAppEnvironmentInfo for %s url
|
|
343
|
-
(envCode, uiContainerName, expectedName, expectedCssClassCategory) => {
|
|
367
|
+
"getAppEnvironmentInfo for %s url, %s UI container and %s header-colors",
|
|
368
|
+
(envCode, uiContainerName, headerColors, expectedName, expectedCssClassCategory) => {
|
|
344
369
|
const info = getAppEnvironmentInfo(
|
|
345
370
|
envCode ? `oco.${envCode}.platform.orckestra.cloud` : envCode,
|
|
346
371
|
uiContainerName,
|
|
372
|
+
headerColors,
|
|
347
373
|
);
|
|
348
374
|
|
|
349
375
|
const expected = {
|
|
@@ -355,8 +381,8 @@ describe("getAppEnvironmentInfo", () => {
|
|
|
355
381
|
},
|
|
356
382
|
);
|
|
357
383
|
|
|
358
|
-
it("getAppEnvironmentInfo for localdev (occ-dev-oco.develop.orckestra.cloud) and prd UI container", () => {
|
|
359
|
-
const info = getAppEnvironmentInfo("occ-dev-oco.develop.orckestra.cloud", "prd");
|
|
384
|
+
it("getAppEnvironmentInfo for localdev (occ-dev-oco.develop.orckestra.cloud) and prd UI container and with header colors", () => {
|
|
385
|
+
const info = getAppEnvironmentInfo("occ-dev-oco.develop.orckestra.cloud", "prd", true);
|
|
360
386
|
|
|
361
387
|
const expected = {
|
|
362
388
|
name: "localdev",
|
|
@@ -366,8 +392,8 @@ describe("getAppEnvironmentInfo", () => {
|
|
|
366
392
|
expect(info, "to equal", expected);
|
|
367
393
|
});
|
|
368
394
|
|
|
369
|
-
it("getAppEnvironmentInfo for localdev (occ-dev-oco.develop.orckestra.cloud) and qa UI container", () => {
|
|
370
|
-
const info = getAppEnvironmentInfo("occ-dev-oco.develop.orckestra.cloud", "qa");
|
|
395
|
+
it("getAppEnvironmentInfo for localdev (occ-dev-oco.develop.orckestra.cloud) and qa UI container and with header colors", () => {
|
|
396
|
+
const info = getAppEnvironmentInfo("occ-dev-oco.develop.orckestra.cloud", "qa", true);
|
|
371
397
|
|
|
372
398
|
const expected = {
|
|
373
399
|
name: "localdev — 1.2-alpha888/qa",
|
|
@@ -377,8 +403,8 @@ describe("getAppEnvironmentInfo", () => {
|
|
|
377
403
|
expect(info, "to equal", expected);
|
|
378
404
|
});
|
|
379
405
|
|
|
380
|
-
it("getAppEnvironmentInfo for localdev (local.develop.orckestra.cloud) and prd UI container", () => {
|
|
381
|
-
const info = getAppEnvironmentInfo("local.develop.orckestra.cloud", "prd");
|
|
406
|
+
it("getAppEnvironmentInfo for localdev (local.develop.orckestra.cloud) and prd UI container and with header colors", () => {
|
|
407
|
+
const info = getAppEnvironmentInfo("local.develop.orckestra.cloud", "prd", true);
|
|
382
408
|
|
|
383
409
|
const expected = {
|
|
384
410
|
name: "localdev",
|
|
@@ -388,8 +414,8 @@ describe("getAppEnvironmentInfo", () => {
|
|
|
388
414
|
expect(info, "to equal", expected);
|
|
389
415
|
});
|
|
390
416
|
|
|
391
|
-
it("getAppEnvironmentInfo for localdev (localhost) and prd UI container", () => {
|
|
392
|
-
const info = getAppEnvironmentInfo("localhost", "prd");
|
|
417
|
+
it("getAppEnvironmentInfo for localdev (localhost) and prd UI container and with header colors", () => {
|
|
418
|
+
const info = getAppEnvironmentInfo("localhost", "prd", true);
|
|
393
419
|
|
|
394
420
|
const expected = {
|
|
395
421
|
name: "localdev",
|
|
@@ -398,4 +424,48 @@ describe("getAppEnvironmentInfo", () => {
|
|
|
398
424
|
|
|
399
425
|
expect(info, "to equal", expected);
|
|
400
426
|
});
|
|
427
|
+
|
|
428
|
+
it("getAppEnvironmentInfo for localdev (occ-dev-oco.develop.orckestra.cloud) and prd UI container and without header colors", () => {
|
|
429
|
+
const info = getAppEnvironmentInfo("occ-dev-oco.develop.orckestra.cloud", "prd", false);
|
|
430
|
+
|
|
431
|
+
const expected = {
|
|
432
|
+
name: "",
|
|
433
|
+
cssClassCategory: null,
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
expect(info, "to equal", expected);
|
|
437
|
+
});
|
|
438
|
+
|
|
439
|
+
it("getAppEnvironmentInfo for localdev (occ-dev-oco.develop.orckestra.cloud) and qa UI container and without header colors", () => {
|
|
440
|
+
const info = getAppEnvironmentInfo("occ-dev-oco.develop.orckestra.cloud", "qa", false);
|
|
441
|
+
|
|
442
|
+
const expected = {
|
|
443
|
+
name: "",
|
|
444
|
+
cssClassCategory: null,
|
|
445
|
+
};
|
|
446
|
+
|
|
447
|
+
expect(info, "to equal", expected);
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
it("getAppEnvironmentInfo for localdev (local.develop.orckestra.cloud) and prd UI container and without header colors", () => {
|
|
451
|
+
const info = getAppEnvironmentInfo("local.develop.orckestra.cloud", "prd", false);
|
|
452
|
+
|
|
453
|
+
const expected = {
|
|
454
|
+
name: "",
|
|
455
|
+
cssClassCategory: null,
|
|
456
|
+
};
|
|
457
|
+
|
|
458
|
+
expect(info, "to equal", expected);
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
it("getAppEnvironmentInfo for localdev (localhost) and prd UI container and without header colors", () => {
|
|
462
|
+
const info = getAppEnvironmentInfo("localhost", "prd", false);
|
|
463
|
+
|
|
464
|
+
const expected = {
|
|
465
|
+
name: "",
|
|
466
|
+
cssClassCategory: null,
|
|
467
|
+
};
|
|
468
|
+
|
|
469
|
+
expect(info, "to equal", expected);
|
|
470
|
+
});
|
|
401
471
|
});
|
package/src/utils/ListHelper.js
CHANGED
|
@@ -3,7 +3,17 @@ import { isObject } from "lodash";
|
|
|
3
3
|
|
|
4
4
|
export const ListInfoPropertyName = "listInfo";
|
|
5
5
|
|
|
6
|
-
const standardInfoKeys = [
|
|
6
|
+
const standardInfoKeys = [
|
|
7
|
+
"scope",
|
|
8
|
+
"page",
|
|
9
|
+
"filters",
|
|
10
|
+
"sorting",
|
|
11
|
+
"totalCount",
|
|
12
|
+
"nextPageToLoad",
|
|
13
|
+
"index",
|
|
14
|
+
"list",
|
|
15
|
+
"searchRequested",
|
|
16
|
+
];
|
|
7
17
|
|
|
8
18
|
class ListReducerHelper {
|
|
9
19
|
constructor(groupPropertyName) {
|
|
@@ -14,6 +24,10 @@ class ListReducerHelper {
|
|
|
14
24
|
return state.setIn([this.groupPropertyName, "nextPageToLoad"], nextPageToLoad);
|
|
15
25
|
};
|
|
16
26
|
|
|
27
|
+
setSearchRequested = (state, searchRequested) => {
|
|
28
|
+
return state.setIn([this.groupPropertyName, "searchRequested"], searchRequested);
|
|
29
|
+
};
|
|
30
|
+
|
|
17
31
|
setResults = (state, listInfo, forceReset = false) => {
|
|
18
32
|
return state.withMutations(s => {
|
|
19
33
|
const page = s.getIn([this.groupPropertyName, "nextPageToLoad"]);
|
|
@@ -51,6 +65,7 @@ class ListReducerHelper {
|
|
|
51
65
|
s.setIn([this.groupPropertyName, "scope"], scope ?? null);
|
|
52
66
|
s.setIn([this.groupPropertyName, "filters"], Immutable.fromJS(filters ?? null));
|
|
53
67
|
s.setIn([this.groupPropertyName, "sorting"], Immutable.fromJS(sorting ?? null));
|
|
68
|
+
s.setIn([this.groupPropertyName, "searchRequested"], false);
|
|
54
69
|
|
|
55
70
|
const otherKeys = Object.keys(others);
|
|
56
71
|
|
|
@@ -90,6 +105,7 @@ class ListReducerHelper {
|
|
|
90
105
|
resetListInfo = (state, propertiesToKeep = {}) => {
|
|
91
106
|
let updatedState = state
|
|
92
107
|
.setIn([this.groupPropertyName, "nextPageToLoad"], 1)
|
|
108
|
+
.setIn([this.groupPropertyName, "searchRequested"], false)
|
|
93
109
|
.setIn([this.groupPropertyName, "index"], Immutable.fromJS({}))
|
|
94
110
|
.setIn([this.groupPropertyName, "list"], Immutable.fromJS([]))
|
|
95
111
|
.setIn([this.groupPropertyName, "totalCount"], 0);
|
|
@@ -128,6 +144,7 @@ class ListSelectorHelper {
|
|
|
128
144
|
currentFilters: listInfo.get("filters")?.toJS(),
|
|
129
145
|
currentSorting: listInfo.get("sorting")?.toJS(),
|
|
130
146
|
totalCount: listInfo.get("totalCount"),
|
|
147
|
+
searchRequested: listInfo.get("searchRequested"),
|
|
131
148
|
};
|
|
132
149
|
|
|
133
150
|
listInfo.mapKeys((key, value) => {
|
|
@@ -152,6 +169,10 @@ class ListSelectorHelper {
|
|
|
152
169
|
getNextPageToLoad = state => {
|
|
153
170
|
return state.getIn([this.groupPropertyName, "nextPageToLoad"]);
|
|
154
171
|
};
|
|
172
|
+
|
|
173
|
+
getSearchRequested = state => {
|
|
174
|
+
return state.getIn([this.groupPropertyName, "searchRequested"]);
|
|
175
|
+
};
|
|
155
176
|
}
|
|
156
177
|
|
|
157
178
|
class ListHelper {
|
|
@@ -182,6 +203,7 @@ class ListHelper {
|
|
|
182
203
|
index,
|
|
183
204
|
list,
|
|
184
205
|
totalCount,
|
|
206
|
+
searchRequested,
|
|
185
207
|
...additionalValues
|
|
186
208
|
} = {}) => {
|
|
187
209
|
return {
|
|
@@ -194,6 +216,7 @@ class ListHelper {
|
|
|
194
216
|
index: index ?? {},
|
|
195
217
|
list: list ?? [],
|
|
196
218
|
totalCount: totalCount ?? 0,
|
|
219
|
+
searchRequested: searchRequested ?? false,
|
|
197
220
|
...additionalValues,
|
|
198
221
|
},
|
|
199
222
|
};
|
|
@@ -14,6 +14,7 @@ describe("createInitialListInfo", () => {
|
|
|
14
14
|
index: {},
|
|
15
15
|
list: [],
|
|
16
16
|
totalCount: 0,
|
|
17
|
+
searchRequested: false,
|
|
17
18
|
},
|
|
18
19
|
});
|
|
19
20
|
});
|
|
@@ -33,6 +34,7 @@ describe("createInitialListInfo", () => {
|
|
|
33
34
|
index: {},
|
|
34
35
|
list: [],
|
|
35
36
|
totalCount: 0,
|
|
37
|
+
searchRequested: false,
|
|
36
38
|
prop1: 123,
|
|
37
39
|
prop2: { subprop: "a" },
|
|
38
40
|
},
|
|
@@ -49,6 +51,7 @@ describe("createInitialListInfo", () => {
|
|
|
49
51
|
index: { c: 1 },
|
|
50
52
|
list: [1, 2, 3],
|
|
51
53
|
totalCount: 10,
|
|
54
|
+
searchRequested: false,
|
|
52
55
|
prop1: 123,
|
|
53
56
|
prop2: { subprop: "a" },
|
|
54
57
|
});
|
|
@@ -62,6 +65,7 @@ describe("createInitialListInfo", () => {
|
|
|
62
65
|
index: { c: 1 },
|
|
63
66
|
list: [1, 2, 3],
|
|
64
67
|
totalCount: 10,
|
|
68
|
+
searchRequested: false,
|
|
65
69
|
prop1: 123,
|
|
66
70
|
prop2: { subprop: "a" },
|
|
67
71
|
},
|
|
@@ -82,6 +86,7 @@ describe("createListInfoFrom", () => {
|
|
|
82
86
|
index: {},
|
|
83
87
|
list: [],
|
|
84
88
|
totalCount: 0,
|
|
89
|
+
searchRequested: false,
|
|
85
90
|
},
|
|
86
91
|
});
|
|
87
92
|
});
|
|
@@ -101,6 +106,7 @@ describe("createListInfoFrom", () => {
|
|
|
101
106
|
index: {},
|
|
102
107
|
list: [],
|
|
103
108
|
totalCount: 0,
|
|
109
|
+
searchRequested: false,
|
|
104
110
|
prop1: 123,
|
|
105
111
|
prop2: { subprop: "a" },
|
|
106
112
|
},
|
|
@@ -117,6 +123,7 @@ describe("createListInfoFrom", () => {
|
|
|
117
123
|
index: { c: 1 },
|
|
118
124
|
list: [1, 2, 3],
|
|
119
125
|
totalCount: 10,
|
|
126
|
+
searchRequested: false,
|
|
120
127
|
prop1: 123,
|
|
121
128
|
prop2: { subprop: "a" },
|
|
122
129
|
});
|
|
@@ -130,6 +137,7 @@ describe("createListInfoFrom", () => {
|
|
|
130
137
|
index: { c: 1 },
|
|
131
138
|
list: [1, 2, 3],
|
|
132
139
|
totalCount: 10,
|
|
140
|
+
searchRequested: false,
|
|
133
141
|
prop1: 123,
|
|
134
142
|
prop2: { subprop: "a" },
|
|
135
143
|
},
|
|
@@ -148,6 +156,7 @@ describe("ListSelectorHelper", () => {
|
|
|
148
156
|
index: { c: 1 },
|
|
149
157
|
list: [1, 2, 3],
|
|
150
158
|
totalCount: 10,
|
|
159
|
+
searchRequested: true,
|
|
151
160
|
prop1: 123,
|
|
152
161
|
prop2: { subprop: "a" },
|
|
153
162
|
}),
|
|
@@ -168,6 +177,11 @@ describe("ListSelectorHelper", () => {
|
|
|
168
177
|
expect(value, "to equal", Immutable.fromJS({ c: 1 }));
|
|
169
178
|
});
|
|
170
179
|
|
|
180
|
+
it("getSearchRequested", () => {
|
|
181
|
+
const value = ListHelper.selector.getSearchRequested(initialState);
|
|
182
|
+
expect(value, "to equal", true);
|
|
183
|
+
});
|
|
184
|
+
|
|
171
185
|
it("getCurrentInfo", () => {
|
|
172
186
|
const value = ListHelper.selector.getCurrentInfo(initialState);
|
|
173
187
|
expect(value, "to equal", {
|
|
@@ -176,6 +190,7 @@ describe("ListSelectorHelper", () => {
|
|
|
176
190
|
currentScope: "canada",
|
|
177
191
|
currentPage: 1,
|
|
178
192
|
totalCount: 10,
|
|
193
|
+
searchRequested: true,
|
|
179
194
|
prop1: 123,
|
|
180
195
|
prop2: { subprop: "a" },
|
|
181
196
|
});
|
|
@@ -191,6 +206,7 @@ describe("ListSelectorHelper", () => {
|
|
|
191
206
|
currentScope: "canada",
|
|
192
207
|
currentPage: 1,
|
|
193
208
|
totalCount: 10,
|
|
209
|
+
searchRequested: true,
|
|
194
210
|
prop1: 123,
|
|
195
211
|
prop2: { subprop: "a" },
|
|
196
212
|
});
|
|
@@ -204,6 +220,7 @@ describe("ListSelectorHelper", () => {
|
|
|
204
220
|
currentScope: undefined,
|
|
205
221
|
currentPage: undefined,
|
|
206
222
|
totalCount: undefined,
|
|
223
|
+
searchRequested: undefined,
|
|
207
224
|
});
|
|
208
225
|
});
|
|
209
226
|
});
|
|
@@ -219,6 +236,7 @@ describe("ListReducerHelper", () => {
|
|
|
219
236
|
index: { c: 1 },
|
|
220
237
|
list: [1, 2, 3],
|
|
221
238
|
totalCount: 10,
|
|
239
|
+
searchRequested: false,
|
|
222
240
|
prop1: 123,
|
|
223
241
|
prop2: { subprop: "a" },
|
|
224
242
|
}),
|
|
@@ -239,6 +257,30 @@ describe("ListReducerHelper", () => {
|
|
|
239
257
|
index: { c: 1 },
|
|
240
258
|
list: [1, 2, 3],
|
|
241
259
|
totalCount: 10,
|
|
260
|
+
searchRequested: false,
|
|
261
|
+
prop1: 123,
|
|
262
|
+
prop2: { subprop: "a" },
|
|
263
|
+
}),
|
|
264
|
+
),
|
|
265
|
+
);
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
it("setSearchRequested", () => {
|
|
269
|
+
const newState = ListHelper.reducer.setSearchRequested(initialState, true);
|
|
270
|
+
expect(
|
|
271
|
+
newState,
|
|
272
|
+
"to equal",
|
|
273
|
+
Immutable.fromJS(
|
|
274
|
+
ListHelper.createListInfoFrom({
|
|
275
|
+
sorting: { a: 1 },
|
|
276
|
+
filters: { b: 1 },
|
|
277
|
+
scope: "canada",
|
|
278
|
+
page: 1,
|
|
279
|
+
nextPageToLoad: 2,
|
|
280
|
+
index: { c: 1 },
|
|
281
|
+
list: [1, 2, 3],
|
|
282
|
+
totalCount: 10,
|
|
283
|
+
searchRequested: true,
|
|
242
284
|
prop1: 123,
|
|
243
285
|
prop2: { subprop: "a" },
|
|
244
286
|
}),
|
|
@@ -269,6 +311,7 @@ describe("ListReducerHelper", () => {
|
|
|
269
311
|
index: { d: 1 },
|
|
270
312
|
list: [4, 5, 6],
|
|
271
313
|
totalCount: 222,
|
|
314
|
+
searchRequested: undefined,
|
|
272
315
|
prop1: 123,
|
|
273
316
|
prop2: { subprop: "a" },
|
|
274
317
|
}),
|
|
@@ -300,6 +343,7 @@ describe("ListReducerHelper", () => {
|
|
|
300
343
|
index: {},
|
|
301
344
|
list: [4, 5, 6],
|
|
302
345
|
totalCount: 222,
|
|
346
|
+
searchRequested: undefined,
|
|
303
347
|
prop1: 123,
|
|
304
348
|
prop2: { subprop: "a" },
|
|
305
349
|
}),
|
|
@@ -327,6 +371,7 @@ describe("ListReducerHelper", () => {
|
|
|
327
371
|
index: { c: 1, d: 1 },
|
|
328
372
|
list: [1, 2, 3, 4, 5, 6],
|
|
329
373
|
totalCount: 222,
|
|
374
|
+
searchRequested: undefined,
|
|
330
375
|
prop1: 123,
|
|
331
376
|
prop2: { subprop: "a" },
|
|
332
377
|
}),
|
|
@@ -354,6 +399,7 @@ describe("ListReducerHelper", () => {
|
|
|
354
399
|
index: { d: 1 },
|
|
355
400
|
list: [4, 5, 6],
|
|
356
401
|
totalCount: 222,
|
|
402
|
+
searchRequested: undefined,
|
|
357
403
|
prop1: 123,
|
|
358
404
|
prop2: { subprop: "a" },
|
|
359
405
|
}),
|
|
@@ -384,6 +430,7 @@ describe("ListReducerHelper", () => {
|
|
|
384
430
|
index: {},
|
|
385
431
|
list: [],
|
|
386
432
|
totalCount: 0,
|
|
433
|
+
searchRequested: false,
|
|
387
434
|
prop1: 456,
|
|
388
435
|
prop2: { subprop: "b" },
|
|
389
436
|
}),
|
|
@@ -414,6 +461,7 @@ describe("ListReducerHelper", () => {
|
|
|
414
461
|
index: { c: 1 },
|
|
415
462
|
list: [1, 2, 3],
|
|
416
463
|
totalCount: 10,
|
|
464
|
+
searchRequested: false,
|
|
417
465
|
prop1: 456,
|
|
418
466
|
prop2: { subprop: "b" },
|
|
419
467
|
}),
|
|
@@ -444,6 +492,7 @@ describe("ListReducerHelper", () => {
|
|
|
444
492
|
index: { c: 1 },
|
|
445
493
|
list: [1, 2, 3],
|
|
446
494
|
totalCount: 10,
|
|
495
|
+
searchRequested: false,
|
|
447
496
|
prop1: 456,
|
|
448
497
|
prop3: 789,
|
|
449
498
|
}),
|
|
@@ -472,6 +521,7 @@ describe("ListReducerHelper", () => {
|
|
|
472
521
|
index: { c: 1 },
|
|
473
522
|
list: [1, 2, 3],
|
|
474
523
|
totalCount: 10,
|
|
524
|
+
searchRequested: false,
|
|
475
525
|
}),
|
|
476
526
|
),
|
|
477
527
|
);
|
|
@@ -500,6 +550,7 @@ describe("ListReducerHelper", () => {
|
|
|
500
550
|
index: { c: 1 },
|
|
501
551
|
list: [1, 2, 3],
|
|
502
552
|
totalCount: 10,
|
|
553
|
+
searchRequested: false,
|
|
503
554
|
prop1: 456,
|
|
504
555
|
prop2: { subprop: "b" },
|
|
505
556
|
}),
|
|
@@ -522,6 +573,7 @@ describe("ListReducerHelper", () => {
|
|
|
522
573
|
index: { c: 1 },
|
|
523
574
|
list: [1, 2, 3],
|
|
524
575
|
totalCount: 10,
|
|
576
|
+
searchRequested: false,
|
|
525
577
|
}),
|
|
526
578
|
),
|
|
527
579
|
);
|
|
@@ -542,6 +594,7 @@ describe("ListReducerHelper", () => {
|
|
|
542
594
|
index: { c: 1, d: 888 },
|
|
543
595
|
list: [1, 2, 3],
|
|
544
596
|
totalCount: 10,
|
|
597
|
+
searchRequested: false,
|
|
545
598
|
prop1: 123,
|
|
546
599
|
prop2: { subprop: "a" },
|
|
547
600
|
}),
|
|
@@ -564,6 +617,7 @@ describe("ListReducerHelper", () => {
|
|
|
564
617
|
index: { c: 1 },
|
|
565
618
|
list: [1, 2, 3, 888],
|
|
566
619
|
totalCount: 10,
|
|
620
|
+
searchRequested: false,
|
|
567
621
|
prop1: 123,
|
|
568
622
|
prop2: { subprop: "a" },
|
|
569
623
|
}),
|
|
@@ -586,6 +640,7 @@ describe("ListReducerHelper", () => {
|
|
|
586
640
|
index: { c: 888 },
|
|
587
641
|
list: [1, 2, 3],
|
|
588
642
|
totalCount: 10,
|
|
643
|
+
searchRequested: false,
|
|
589
644
|
prop1: 123,
|
|
590
645
|
prop2: { subprop: "a" },
|
|
591
646
|
}),
|
|
@@ -608,6 +663,7 @@ describe("ListReducerHelper", () => {
|
|
|
608
663
|
index: { c: 1 },
|
|
609
664
|
list: [1, 2, 3],
|
|
610
665
|
totalCount: 10,
|
|
666
|
+
searchRequested: false,
|
|
611
667
|
prop1: 123,
|
|
612
668
|
prop2: { subprop: "a" },
|
|
613
669
|
}),
|
|
@@ -630,6 +686,7 @@ describe("ListReducerHelper", () => {
|
|
|
630
686
|
index: {},
|
|
631
687
|
list: [1, 2, 3],
|
|
632
688
|
totalCount: 10,
|
|
689
|
+
searchRequested: false,
|
|
633
690
|
prop1: 123,
|
|
634
691
|
prop2: { subprop: "a" },
|
|
635
692
|
}),
|
|
@@ -652,6 +709,7 @@ describe("ListReducerHelper", () => {
|
|
|
652
709
|
index: { c: 1 },
|
|
653
710
|
list: [1, 2, 3],
|
|
654
711
|
totalCount: 10,
|
|
712
|
+
searchRequested: false,
|
|
655
713
|
prop1: 123,
|
|
656
714
|
prop2: { subprop: "a" },
|
|
657
715
|
}),
|
|
@@ -674,6 +732,7 @@ describe("ListReducerHelper", () => {
|
|
|
674
732
|
index: {},
|
|
675
733
|
list: [],
|
|
676
734
|
totalCount: 0,
|
|
735
|
+
searchRequested: false,
|
|
677
736
|
prop1: 123,
|
|
678
737
|
prop2: { subprop: "a" },
|
|
679
738
|
}),
|
|
@@ -701,6 +760,7 @@ describe("ListReducerHelper", () => {
|
|
|
701
760
|
index: {},
|
|
702
761
|
list: [],
|
|
703
762
|
totalCount: 0,
|
|
763
|
+
searchRequested: false,
|
|
704
764
|
prop1: 123,
|
|
705
765
|
prop2: { subprop: "a" },
|
|
706
766
|
}),
|