@beinformed/ui 1.25.1-beta.0 → 1.25.1
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/CHANGELOG.md +8 -0
- package/esm/redux/_modularui/ModularUIReducer.js +3 -5
- package/esm/redux/_modularui/ModularUIReducer.js.map +1 -1
- package/lib/redux/_modularui/ModularUIReducer.js +3 -5
- package/lib/redux/_modularui/ModularUIReducer.js.flow +2 -3
- package/lib/redux/_modularui/ModularUIReducer.js.map +1 -1
- package/lib/redux/_modularui/__tests__/reducer.spec.js.flow +4 -2
- package/package.json +1 -1
- package/src/redux/_modularui/ModularUIReducer.js +2 -3
- package/src/redux/_modularui/__tests__/reducer.spec.js +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [1.25.1](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.25.1-beta.1...v1.25.1) (2023-01-03)
|
|
6
|
+
|
|
7
|
+
### [1.25.1-beta.1](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.25.1-beta.0...v1.25.1-beta.1) (2023-01-03)
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
- **remove-model:** refactor removal of model ([26fa8b6](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/26fa8b616d826a3a4bdb72a93a14406fa5d244bf))
|
|
12
|
+
|
|
5
13
|
### [1.25.1-beta.0](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.25.0...v1.25.1-beta.0) (2023-01-03)
|
|
6
14
|
|
|
7
15
|
### Bug Fixes
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _findInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find";
|
|
2
2
|
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
3
|
+
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
|
|
3
4
|
import { IllegalArgumentException } from "../../exceptions";
|
|
4
5
|
import { MODULARUI_STATUS } from "../../constants/Constants";
|
|
5
6
|
import { ApplicationModel } from "../../models";
|
|
@@ -73,11 +74,8 @@ const updateModel = (state, model) => {
|
|
|
73
74
|
/**
|
|
74
75
|
*/
|
|
75
76
|
const removeKey = (modelKey, state) => {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
[modelKey]: _,
|
|
79
|
-
...newState
|
|
80
|
-
} = state;
|
|
77
|
+
const newState = _Object$assign({}, state);
|
|
78
|
+
delete newState[modelKey];
|
|
81
79
|
return newState;
|
|
82
80
|
};
|
|
83
81
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModularUIReducer.js","names":["IllegalArgumentException","MODULARUI_STATUS","ApplicationModel","updateStatus","state","key","status","LOADING","lastModification","Date","now","setModel","model","getModelKey","connectKey","updateModel","modelKey","Error","removeKey","
|
|
1
|
+
{"version":3,"file":"ModularUIReducer.js","names":["IllegalArgumentException","MODULARUI_STATUS","ApplicationModel","updateStatus","state","key","status","LOADING","lastModification","Date","now","setModel","model","getModelKey","connectKey","updateModel","modelKey","Error","removeKey","newState","resetModularUI","initialState","ModularUIReducer","action","type","payload"],"sources":["../../../src/redux/_modularui/ModularUIReducer.js"],"sourcesContent":["// @flow\nimport { IllegalArgumentException } from \"../../exceptions\";\nimport { MODULARUI_STATUS } from \"../../constants/Constants\";\nimport { ApplicationModel } from \"../../models\";\n\nimport type { Reducer } from \"redux\";\nimport type { ReduxAction } from \"../types\";\nimport type { ModularUIState } from \"./types\";\nimport type { ModularUIModel } from \"../../models\";\n\n/**\n */\nconst updateStatus = (\n state: ModularUIState,\n { key, status }: { key: string, status: $Keys<typeof MODULARUI_STATUS> }\n) => {\n // model should always be available when status is not loading\n if (status !== MODULARUI_STATUS.LOADING && !state[key]) {\n return state;\n }\n\n return {\n ...state,\n [key]: {\n ...state[key],\n status,\n lastModification: Date.now(),\n },\n };\n};\n\n/**\n */\nconst setModel = (\n state: ModularUIState,\n { key, model }: { key: string, model: ?ModularUIModel }\n) => {\n if (!state[key]) {\n return state;\n }\n\n if (model) {\n return {\n ...state,\n [key]: {\n ...state[key],\n model,\n lastModification: Date.now(),\n },\n };\n }\n\n throw new IllegalArgumentException(\"No model for setModel\");\n};\n\n/**\n */\nconst getModelKey = (state: ModularUIState, model: ModularUIModel) =>\n Object.keys(state).find((key) => {\n const connectKey = state[key]?.model?.connectKey ?? \"\";\n return connectKey === model.connectKey;\n });\n\n/**\n */\nconst updateModel = (state: ModularUIState, model: ModularUIModel) => {\n const modelKey = getModelKey(state, model);\n\n if (modelKey) {\n return setModel(state, { key: modelKey, model });\n }\n\n throw new Error(\n `ModularUIReducer: Cannot update model with key ${model.connectKey}`\n );\n};\n\n/**\n */\nconst removeKey = (modelKey: string, state: ModularUIState): ModularUIState => {\n const newState = Object.assign({}, state);\n delete newState[modelKey];\n return newState;\n};\n\n/**\n * Remove all but application models\n */\nconst resetModularUI = (state: ModularUIState) => {\n const newState: ModularUIState = {};\n\n for (const key in state) {\n if (state[key].model instanceof ApplicationModel) {\n newState[key] = { ...state[key] };\n }\n }\n\n return newState;\n};\n\nconst initialState: ModularUIState = {};\n\n/**\n * Modular UI Reducer\n */\nexport const ModularUIReducer: Reducer<ModularUIState, ReduxAction> = (\n state = initialState,\n action\n) => {\n if (!action) {\n return state;\n }\n\n switch (action.type) {\n case \"MODULARUI/RESET\":\n return resetModularUI(state);\n\n case \"MODULARUI/STATUS\":\n return updateStatus(state, action.payload);\n\n case \"MODULARUI/SET\":\n return setModel(state, action.payload);\n\n case \"MODULARUI/UPDATE\":\n return updateModel(state, action.payload);\n\n case \"MODULARUI/REMOVE_KEY\":\n return removeKey(action.payload, state);\n\n default:\n return state;\n }\n};\n"],"mappings":";;;AACA,SAASA,w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5C,KAAK,eAAe;MAClB,OAAOd,QAAQ,CAACP,KAAK,EAAEmB,MAAM,CAACE,OAAO,CAAC;IAExC,KAAK,kBAAkB;MACrB,OAAOV,WAAW,CAACX,KAAK,EAAEmB,MAAM,CAACE,OAAO,CAAC;IAE3C,KAAK,sBAAsB;MACzB,OAAOP,SAAS,CAACK,MAAM,CAACE,OAAO,EAAErB,KAAK,CAAC;IAEzC;MACE,OAAOA,KAAK;EAAC;AAEnB,CAAC"}
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.ModularUIReducer = void 0;
|
|
8
8
|
var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find"));
|
|
9
9
|
var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
|
|
10
|
+
var _assign = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/assign"));
|
|
10
11
|
var _exceptions = require("../../exceptions");
|
|
11
12
|
var _Constants = require("../../constants/Constants");
|
|
12
13
|
var _models = require("../../models");
|
|
@@ -80,11 +81,8 @@ const updateModel = (state, model) => {
|
|
|
80
81
|
/**
|
|
81
82
|
*/
|
|
82
83
|
const removeKey = (modelKey, state) => {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
[modelKey]: _,
|
|
86
|
-
...newState
|
|
87
|
-
} = state;
|
|
84
|
+
const newState = (0, _assign.default)({}, state);
|
|
85
|
+
delete newState[modelKey];
|
|
88
86
|
return newState;
|
|
89
87
|
};
|
|
90
88
|
|
|
@@ -78,9 +78,8 @@ const updateModel = (state: ModularUIState, model: ModularUIModel) => {
|
|
|
78
78
|
/**
|
|
79
79
|
*/
|
|
80
80
|
const removeKey = (modelKey: string, state: ModularUIState): ModularUIState => {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
const newState = Object.assign({}, state);
|
|
82
|
+
delete newState[modelKey];
|
|
84
83
|
return newState;
|
|
85
84
|
};
|
|
86
85
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModularUIReducer.js","names":["updateStatus","state","key","status","MODULARUI_STATUS","LOADING","lastModification","Date","now","setModel","model","IllegalArgumentException","getModelKey","connectKey","updateModel","modelKey","Error","removeKey","
|
|
1
|
+
{"version":3,"file":"ModularUIReducer.js","names":["updateStatus","state","key","status","MODULARUI_STATUS","LOADING","lastModification","Date","now","setModel","model","IllegalArgumentException","getModelKey","connectKey","updateModel","modelKey","Error","removeKey","newState","resetModularUI","ApplicationModel","initialState","ModularUIReducer","action","type","payload"],"sources":["../../../src/redux/_modularui/ModularUIReducer.js"],"sourcesContent":["// @flow\nimport { IllegalArgumentException } from \"../../exceptions\";\nimport { MODULARUI_STATUS } from \"../../constants/Constants\";\nimport { ApplicationModel } from \"../../models\";\n\nimport type { Reducer } from \"redux\";\nimport type { ReduxAction } from \"../types\";\nimport type { ModularUIState } from \"./types\";\nimport type { ModularUIModel } from \"../../models\";\n\n/**\n */\nconst updateStatus = (\n state: ModularUIState,\n { key, status }: { key: string, status: $Keys<typeof MODULARUI_STATUS> }\n) => {\n // model should always be available when status is not loading\n if (status !== MODULARUI_STATUS.LOADING && !state[key]) {\n return state;\n }\n\n return {\n ...state,\n [key]: {\n ...state[key],\n status,\n lastModification: Date.now(),\n },\n };\n};\n\n/**\n */\nconst setModel = (\n state: ModularUIState,\n { key, model }: { key: string, model: ?ModularUIModel }\n) => {\n if (!state[key]) {\n return state;\n }\n\n if (model) {\n return {\n ...state,\n [key]: {\n ...state[key],\n model,\n lastModification: Date.now(),\n },\n };\n }\n\n throw new IllegalArgumentException(\"No model for setModel\");\n};\n\n/**\n */\nconst getModelKey = (state: ModularUIState, model: ModularUIModel) =>\n Object.keys(state).find((key) => {\n const connectKey = state[key]?.model?.connectKey ?? \"\";\n return connectKey === model.connectKey;\n });\n\n/**\n */\nconst updateModel = (state: ModularUIState, model: ModularUIModel) => {\n const modelKey = getModelKey(state, model);\n\n if (modelKey) {\n return setModel(state, { key: modelKey, model });\n }\n\n throw new Error(\n `ModularUIReducer: Cannot update model with key ${model.connectKey}`\n );\n};\n\n/**\n */\nconst removeKey = (modelKey: string, state: ModularUIState): ModularUIState => {\n const newState = Object.assign({}, state);\n delete newState[modelKey];\n return newState;\n};\n\n/**\n * Remove all but application models\n */\nconst resetModularUI = (state: ModularUIState) => {\n const newState: ModularUIState = {};\n\n for (const key in state) {\n if (state[key].model instanceof ApplicationModel) {\n newState[key] = { ...state[key] };\n }\n }\n\n return newState;\n};\n\nconst initialState: ModularUIState = {};\n\n/**\n * Modular UI Reducer\n */\nexport const ModularUIReducer: Reducer<ModularUIState, ReduxAction> = (\n state = initialState,\n action\n) => {\n if (!action) {\n return state;\n }\n\n switch (action.type) {\n case \"MODULARUI/RESET\":\n return resetModularUI(state);\n\n case \"MODULARUI/STATUS\":\n return updateStatus(state, action.payload);\n\n case \"MODULARUI/SET\":\n return setModel(state, action.payload);\n\n case \"MODULARUI/UPDATE\":\n return updateModel(state, action.payload);\n\n case \"MODULARUI/REMOVE_KEY\":\n return removeKey(action.payload, state);\n\n default:\n return state;\n }\n};\n"],"mappings":";;;;;;;;;;AACA;AACA;AACA;AAOA;AACA;AACA,MAAMA,YAAY,GAAG,CACnBC,KAAqB,WAElB;EAAA,IADH;IAAEC,GAAG;IAAEC;EAAgE,CAAC;EAExE;EACA,IAAIA,MAAM,KAAKC,2BAAgB,CAACC,OAAO,IAAI,CAACJ,KAAK,CAACC,GAAG,CAAC,EAAE;IACtD,OAAOD,KAAK;EACd;EAEA,OAAO;IACL,GAAGA,KAAK;IACR,CAACC,GAAG,GAAG;MACL,GAAGD,KAAK,CAACC,GAAG,CAAC;MACbC,MAAM;MACNG,gBAAgB,EAAEC,IAAI,CAACC,GAAG;IAC5B;EACF,CAAC;AACH,CAAC;;AAED;AACA;AACA,MAAMC,QAAQ,GAAG,CACfR,KAAqB,YAElB;EAAA,IADH;IAAEC,GAAG;IAAEQ;EAA+C,CAAC;EAEvD,IAA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AC,CAAC;EAEnC,KAAK,MAAMhB,GAAG,IAAID,KAAK,EAAE;IACvB,IAAIA,KAAK,CAACC,GAAG,CAAC,CAACQ,KAAK,YAAYU,wBAAgB,EAAE;MAChDF,QAAQ,CAAChB,GAAG,CAAC,GAAG;QAAE,GAAGD,KAAK,CAACC,GAAG;MAAE,CAAC;IACnC;EACF;EAEA,OAAOgB,QAAQ;AACjB,CAAC;AAED,MAAMG,YAA4B,GAAG,CAAC,CAAC;;AAEvC;AACA;AACA;AACO,MAAMC,gBAAsD,GAAG,YAGjE;EAAA,IAFHrB,KAAK,uEAAGoB,YAAY;EAAA,IACpBE,MAAM;EAEN,IAAI,CAACA,MAAM,EAAE;IACX,OAAOtB,KAAK;EACd;EAEA,QAAQsB,MAAM,CAACC,IAAI;IACjB,KAAK,iBAAiB;MACpB,OAAOL,cAAc,CAAClB,KAAK,CAAC;IAE9B,KAAK,kBAAkB;MACrB,OAAOD,YAAY,CAACC,KAAK,EAAEsB,MAAM,CAACE,OAAO,CAAC;IAE5C,KAAK,eAAe;MAClB,OAAOhB,QAAQ,CAACR,KAAK,EAAEsB,MAAM,CAACE,OAAO,CAAC;IAExC,KAAK,kBAAkB;MACrB,OAAOX,WAAW,CAACb,KAAK,EAAEsB,MAAM,CAACE,OAAO,CAAC;IAE3C,KAAK,sBAAsB;MACzB,OAAOR,SAAS,CAACM,MAAM,CAACE,OAAO,EAAExB,KAAK,CAAC;IAEzC;MACE,OAAOA,KAAK;EAAC;AAEnB,CAAC;AAAC"}
|
|
@@ -2,6 +2,7 @@ import { ModularUIReducer } from "../ModularUIReducer";
|
|
|
2
2
|
import { MODULARUI_STATUS } from "../../../constants";
|
|
3
3
|
|
|
4
4
|
import application from "../../../models/application/__mock__/application";
|
|
5
|
+
import tab from "../../../models/tab/__mock__/tab";
|
|
5
6
|
|
|
6
7
|
describe("modularui reducer", () => {
|
|
7
8
|
it("should return the initial state", () => {
|
|
@@ -119,14 +120,15 @@ describe("modularui reducer", () => {
|
|
|
119
120
|
|
|
120
121
|
it("should handle MODULARUI/REMOVE_KEY", () => {
|
|
121
122
|
application.connectKey = "modelKey";
|
|
123
|
+
tab.connectKey = "tabKey";
|
|
122
124
|
expect(
|
|
123
125
|
ModularUIReducer(
|
|
124
|
-
{ modelKey: { model: application } },
|
|
126
|
+
{ modelKey: { model: application }, tabKey: { model: tab } },
|
|
125
127
|
{
|
|
126
128
|
type: "MODULARUI/REMOVE_KEY",
|
|
127
129
|
payload: "modelKey",
|
|
128
130
|
}
|
|
129
131
|
)
|
|
130
|
-
).toStrictEqual({});
|
|
132
|
+
).toStrictEqual({ tabKey: { model: tab } });
|
|
131
133
|
});
|
|
132
134
|
});
|
package/package.json
CHANGED
|
@@ -78,9 +78,8 @@ const updateModel = (state: ModularUIState, model: ModularUIModel) => {
|
|
|
78
78
|
/**
|
|
79
79
|
*/
|
|
80
80
|
const removeKey = (modelKey: string, state: ModularUIState): ModularUIState => {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
const newState = Object.assign({}, state);
|
|
82
|
+
delete newState[modelKey];
|
|
84
83
|
return newState;
|
|
85
84
|
};
|
|
86
85
|
|
|
@@ -2,6 +2,7 @@ import { ModularUIReducer } from "../ModularUIReducer";
|
|
|
2
2
|
import { MODULARUI_STATUS } from "../../../constants";
|
|
3
3
|
|
|
4
4
|
import application from "../../../models/application/__mock__/application";
|
|
5
|
+
import tab from "../../../models/tab/__mock__/tab";
|
|
5
6
|
|
|
6
7
|
describe("modularui reducer", () => {
|
|
7
8
|
it("should return the initial state", () => {
|
|
@@ -119,14 +120,15 @@ describe("modularui reducer", () => {
|
|
|
119
120
|
|
|
120
121
|
it("should handle MODULARUI/REMOVE_KEY", () => {
|
|
121
122
|
application.connectKey = "modelKey";
|
|
123
|
+
tab.connectKey = "tabKey";
|
|
122
124
|
expect(
|
|
123
125
|
ModularUIReducer(
|
|
124
|
-
{ modelKey: { model: application } },
|
|
126
|
+
{ modelKey: { model: application }, tabKey: { model: tab } },
|
|
125
127
|
{
|
|
126
128
|
type: "MODULARUI/REMOVE_KEY",
|
|
127
129
|
payload: "modelKey",
|
|
128
130
|
}
|
|
129
131
|
)
|
|
130
|
-
).toStrictEqual({});
|
|
132
|
+
).toStrictEqual({ tabKey: { model: tab } });
|
|
131
133
|
});
|
|
132
134
|
});
|