@legalplace/wizardx-core 4.0.6 → 4.1.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 +31 -0
- package/dist/App.js +2 -2
- package/dist/ThemeLoader.test.js +3 -3
- package/dist/componentsConnectors/connectBox.test.js +25 -17
- package/dist/componentsConnectors/connectDocument.test.js +64 -51
- package/dist/helpers/index.d.ts +1 -0
- package/dist/helpers/index.js +1 -0
- package/dist/helpers/sagaCancelOnResetState.d.ts +1 -0
- package/dist/helpers/sagaCancelOnResetState.js +10 -0
- package/dist/helpers/urlSearchParams.d.ts +3 -0
- package/dist/helpers/urlSearchParams.js +1 -0
- package/dist/redux/actions/app.d.ts +1 -0
- package/dist/redux/actions/app.js +4 -1
- package/dist/redux/actions/library.d.ts +1 -0
- package/dist/redux/constants/app.d.ts +1 -1
- package/dist/redux/constants/app.js +1 -1
- package/dist/redux/middlewares/smartscriptMiddleware.js +9 -0
- package/dist/redux/reducers/app.d.ts +1 -1
- package/dist/redux/reducers/app.js +3 -1
- package/dist/redux/reducers/conditions.js +3 -0
- package/dist/redux/reducers/inputs.js +3 -0
- package/dist/redux/reducers/mandatories.js +3 -0
- package/dist/redux/reducers/pluginsStore.js +3 -0
- package/dist/redux/reducers/references.js +3 -0
- package/dist/redux/reducers/smartscript.js +3 -0
- package/dist/redux/reducers/user.js +3 -0
- package/dist/redux/sagas/fetchModel.js +3 -2
- package/dist/redux/sagas/fetchModel.test.js +74 -1
- package/dist/redux/sagas/homogeneousRadioInputsSaga.js +2 -1
- package/dist/redux/sagas/initInputs.js +2 -1
- package/dist/redux/sagas/initPlugins.js +2 -1
- package/dist/redux/sagas/saveData.js +2 -1
- package/dist/redux/sagas/setDefaults.js +2 -1
- package/dist/redux/sagas/setUserEmail.js +2 -1
- package/dist/redux/selectors/selectors.js +2 -2
- package/dist/redux/store.js +6 -9
- package/dist/service/api.manager.js +3 -2
- package/dist/service/auth.service.js +2 -1
- package/dist/types/Actions.type.d.ts +10 -7
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,37 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [4.1.1](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@4.1.0...@legalplace/wizardx-core@4.1.1) (2023-06-13)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* fix unit test api[#8673](https://git.legalplace.eu/legalplace/monorepo/issues/8673) ([1aa09b9](https://git.legalplace.eu/legalplace/monorepo/commits/1aa09b9cb9bd002af18bdfefdc950cdf8d5850dc)), closes [api#8637](https://git.legalplace.eu/legalplace/monorepo/issues/8637)
|
|
12
|
+
* fixing store reinit api[#8637](https://git.legalplace.eu/legalplace/monorepo/issues/8637) ([966eb26](https://git.legalplace.eu/legalplace/monorepo/commits/966eb265b9825730c91a5b5d9bbf544f26bc0e0f))
|
|
13
|
+
* fixing tests api[#8637](https://git.legalplace.eu/legalplace/monorepo/issues/8637) ([b6500c3](https://git.legalplace.eu/legalplace/monorepo/commits/b6500c30f8e76a1430d9208862401dfbe30b3c9f))
|
|
14
|
+
* handling store reset side effect on sagas api[#8637](https://git.legalplace.eu/legalplace/monorepo/issues/8637) ([cbc2ec9](https://git.legalplace.eu/legalplace/monorepo/commits/cbc2ec94194f374caab115d227791998e1384ee6))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
# [4.1.0](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@4.0.6...@legalplace/wizardx-core@4.1.0) (2023-06-01)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Bug Fixes
|
|
24
|
+
|
|
25
|
+
* change import path of getQueryParamsObject ([5826799](https://git.legalplace.eu/legalplace/monorepo/commits/58267996520a4514e001f72c1d70245276199fdf)), closes [api#8730](https://git.legalplace.eu/legalplace/monorepo/issues/8730)
|
|
26
|
+
* delete unused caracter from request ([d090cb5](https://git.legalplace.eu/legalplace/monorepo/commits/d090cb5820a4112715c7faf71064b4063d7ae233)), closes [api#8730](https://git.legalplace.eu/legalplace/monorepo/issues/8730)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Features
|
|
30
|
+
|
|
31
|
+
* get token from url params ([a514d25](https://git.legalplace.eu/legalplace/monorepo/commits/a514d2571f7eeaaf594fa669f2cadd40a7ab76b8)), closes [api#7991](https://git.legalplace.eu/legalplace/monorepo/issues/7991) [api#8730](https://git.legalplace.eu/legalplace/monorepo/issues/8730)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
6
37
|
## [4.0.6](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@4.0.5...@legalplace/wizardx-core@4.0.6) (2023-05-25)
|
|
7
38
|
|
|
8
39
|
**Note:** Version bump only for package @legalplace/wizardx-core
|
package/dist/App.js
CHANGED
|
@@ -13,8 +13,8 @@ import ViewComponent from "./components/View";
|
|
|
13
13
|
import PluginRoute from "./components/PluginRoute";
|
|
14
14
|
import SmartScriptComponent from "./components/SmartScript";
|
|
15
15
|
import { clearPlugins } from "./PluginLoader";
|
|
16
|
-
import { DANGEROUS_DESTROY_STORE } from "./redux/constants/app";
|
|
17
16
|
import { PathReader } from "./libs/PathReader";
|
|
17
|
+
import { resetStateAction } from "./redux/actions/app";
|
|
18
18
|
class WizardXCore extends React.Component {
|
|
19
19
|
constructor(props) {
|
|
20
20
|
var _a;
|
|
@@ -49,7 +49,7 @@ class WizardXCore extends React.Component {
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
componentWillUnmount() {
|
|
52
|
-
getStore().dispatch(
|
|
52
|
+
getStore().dispatch(resetStateAction());
|
|
53
53
|
}
|
|
54
54
|
render() {
|
|
55
55
|
return (_jsx(Provider, Object.assign({ store: getStore() }, { children: _jsx(ConnectedRouter, Object.assign({ history: getHistory() }, { children: _jsxs(Switch, { children: [_jsx(Route, { path: "/p/:path", component: PluginRoute }, void 0), _jsx(Route, { path: getConfig().router.smartscriptPath, exact: true, strict: true, component: SmartScriptComponent }, void 0), _jsx(Route, { path: getConfig().router.wizardInstancePath, component: ViewComponent }, void 0), _jsx(Route, { path: getConfig().router.wizardPath, component: ViewComponent }, void 0), !window.location.href.includes("smartscript") && (_jsx(Redirect, { to: {
|
package/dist/ThemeLoader.test.js
CHANGED
|
@@ -54,12 +54,12 @@ describe('loadTheme', () => {
|
|
|
54
54
|
expect(loadTheme(undefined, true)).resolves.toEqual(undefined);
|
|
55
55
|
}));
|
|
56
56
|
it('loadTheme throws an error if theme param is invalid', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
57
|
-
expect(loadTheme('madeUpTheme')).rejects.toEqual(new Error(
|
|
57
|
+
expect(loadTheme('madeUpTheme')).rejects.toEqual(new Error("We are unable to load the theme, please make sure the theme param is valid"));
|
|
58
58
|
}));
|
|
59
59
|
it('loadTheme throws an error if theme param is invalid', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
60
|
-
expect(loadTheme('jestTestTheme/faltyIndexLoader')).rejects.toEqual(new Error(
|
|
60
|
+
expect(loadTheme('jestTestTheme/faltyIndexLoader')).rejects.toEqual(new Error("Unable to retrieve theme index"));
|
|
61
61
|
}));
|
|
62
62
|
it('loadTheme throws an error if loader result is invalid', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
63
|
-
expect(loadTheme('jestTestTheme/faltyIndex')).rejects.toEqual(new Error(
|
|
63
|
+
expect(loadTheme('jestTestTheme/faltyIndex')).rejects.toEqual(new Error("Unable to retrieve theme index"));
|
|
64
64
|
}));
|
|
65
65
|
});
|
|
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
import renderer from 'react-test-renderer';
|
|
11
|
+
import renderer, { act } from 'react-test-renderer';
|
|
12
12
|
import { initOptionAction, initVariableAction } from '../redux/actions/inputs';
|
|
13
13
|
import { getStore, createAppStore } from '../redux/store';
|
|
14
14
|
import { initReferencesAction } from '../redux/actions/references';
|
|
@@ -150,27 +150,35 @@ describe('connectBox test suit', () => {
|
|
|
150
150
|
let store;
|
|
151
151
|
let connectBox;
|
|
152
152
|
beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
153
|
+
act(() => {
|
|
154
|
+
createAppStore('memory');
|
|
155
|
+
store = getStore();
|
|
156
|
+
store.dispatch(initReferencesAction(references));
|
|
157
|
+
store.dispatch(initVariableAction(1, ['My Test Variable']));
|
|
158
|
+
store.dispatch(initConditionsAction(conditions));
|
|
159
|
+
store.dispatch(initOptionAction(1, [true]));
|
|
160
|
+
connectBox = require('./connectBox').connectBox;
|
|
161
|
+
});
|
|
160
162
|
}));
|
|
161
|
-
it('Should parse variables', () => {
|
|
162
|
-
|
|
163
|
-
|
|
163
|
+
it('Should parse variables', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
164
|
+
let component;
|
|
165
|
+
act(() => {
|
|
166
|
+
const ConnectedBox = connectBox((props) => {
|
|
167
|
+
return _jsx("h1", { children: props.content }, void 0);
|
|
168
|
+
});
|
|
169
|
+
component = renderer.create(_jsx(ConnectedBox, { store: store, id: 1, index: 0 }, void 0));
|
|
164
170
|
});
|
|
165
|
-
const component = renderer.create(_jsx(ConnectedBox, { store: store, id: 1, index: 0 }, void 0));
|
|
166
171
|
expect(component.toTree().rendered.props.content).toEqual('This content should be parsed with My Test Variable value');
|
|
167
|
-
});
|
|
172
|
+
}));
|
|
168
173
|
it('Should not parse on false condition', () => {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
174
|
+
let component;
|
|
175
|
+
act(() => {
|
|
176
|
+
store.dispatch(updateOptionConditionsAction(1, 0, false));
|
|
177
|
+
const ConnectedBox = connectBox((props) => {
|
|
178
|
+
return _jsx("h1", { children: props.content }, void 0);
|
|
179
|
+
});
|
|
180
|
+
component = renderer.create(_jsx(ConnectedBox, { store: store, id: 1, index: 0 }, void 0));
|
|
172
181
|
});
|
|
173
|
-
const component = renderer.create(_jsx(ConnectedBox, { store: store, id: 1, index: 0 }, void 0));
|
|
174
182
|
expect(component.toTree().rendered.props.content).toEqual('');
|
|
175
183
|
});
|
|
176
184
|
it('Should retrun props properly', () => {
|
|
@@ -8,75 +8,88 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
import * as fs from
|
|
12
|
-
import renderer from
|
|
13
|
-
import { ReferencesParser } from
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import { IntputsInitiator } from
|
|
19
|
-
import {
|
|
11
|
+
import * as fs from "fs";
|
|
12
|
+
import renderer, { act } from "react-test-renderer";
|
|
13
|
+
import { ReferencesParser } from "@legalplace/referencesparser";
|
|
14
|
+
import { runSaga } from "redux-saga";
|
|
15
|
+
import { call } from "redux-saga/effects";
|
|
16
|
+
import { getStore, createAppStore } from "../redux/store";
|
|
17
|
+
import { initReferencesAction } from "../redux/actions/references";
|
|
18
|
+
import { IntputsInitiator } from "../libs/InputsInitiator";
|
|
19
|
+
import { initInputsAction } from "../redux/actions/inputs";
|
|
20
|
+
import { initInputsDecorator } from "../redux/sagas/initInputs";
|
|
20
21
|
const ovc = {
|
|
21
22
|
options: { 1: [true], 2: [true, true], 3: [true, false], 4: [false, true] },
|
|
22
23
|
variables: {
|
|
23
|
-
1: [
|
|
24
|
-
2: [
|
|
25
|
-
3: [
|
|
24
|
+
1: ["My VAR1"],
|
|
25
|
+
2: ["My VAR 2 1st", "My VAR 2 2nd"],
|
|
26
|
+
3: ["My VAR 3 1st", "My VAR 3 2nd"],
|
|
26
27
|
},
|
|
27
28
|
};
|
|
28
|
-
describe(
|
|
29
|
+
describe("connectDocument test suit", () => {
|
|
29
30
|
let store;
|
|
30
31
|
let connectDocument;
|
|
31
32
|
beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
const variablesIds = Object.keys(inputs.variables);
|
|
48
|
-
for (let i = 0; i < variablesIds.length; i += 1) {
|
|
49
|
-
const variableId = variablesIds[i];
|
|
50
|
-
const values = inputs.variables[variableId];
|
|
51
|
-
store.dispatch(initVariableAction(parseInt(variableId, 10), values));
|
|
52
|
-
}
|
|
33
|
+
yield act(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
+
createAppStore("memory");
|
|
35
|
+
const model = JSON.parse(fs.readFileSync("./src/misc/test_models/connectDocument.testmodel.json", "utf8"));
|
|
36
|
+
connectDocument = (yield import("./connectDocument")).connectDocument;
|
|
37
|
+
const references = new ReferencesParser(model).getReferences();
|
|
38
|
+
const inputs = new IntputsInitiator(references, ovc).getInputs();
|
|
39
|
+
store = getStore();
|
|
40
|
+
store.dispatch(initReferencesAction(references));
|
|
41
|
+
yield runSaga({
|
|
42
|
+
dispatch: (action) => store.dispatch(action),
|
|
43
|
+
getState: () => store.getState(),
|
|
44
|
+
}, function* initInputs() {
|
|
45
|
+
yield call(initInputsDecorator, initInputsAction(inputs, references));
|
|
46
|
+
}).toPromise();
|
|
47
|
+
}));
|
|
53
48
|
}));
|
|
54
|
-
it(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
49
|
+
it("Should retrun props properly", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
50
|
+
let component;
|
|
51
|
+
yield act(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
52
|
+
const ConnectDocument = connectDocument((props) => (_jsx("h1", { children: props.document }, void 0)));
|
|
53
|
+
component = renderer.create(_jsx(ConnectDocument, { store: store, document: "main" }, void 0));
|
|
54
|
+
}));
|
|
55
|
+
const tree = component === null || component === void 0 ? void 0 : component.toTree();
|
|
56
|
+
if (!(tree === null || tree === void 0 ? void 0 : tree.rendered)) {
|
|
57
|
+
throw Error("Component not rendered while testing");
|
|
58
|
+
}
|
|
59
|
+
const { props } = Array.isArray(tree.rendered)
|
|
60
|
+
? tree.rendered[0]
|
|
61
|
+
: tree.rendered;
|
|
60
62
|
const { document, outputs } = props;
|
|
61
63
|
expect({ document, outputs }).toStrictEqual({
|
|
62
|
-
document:
|
|
64
|
+
document: "main",
|
|
63
65
|
outputs: {
|
|
64
|
-
|
|
66
|
+
"output-5-0": "<p>Should output <strong>Variable 1</strong> My VAR1</p>\n",
|
|
67
|
+
"output-7-0": "<p>Output for Option 1, Should display Variable 2 & 3 when Option 1 is selected, My VAR 2 1st My VAR 3 1st</p>\n",
|
|
68
|
+
"output-8-1": "<p>Output for Option 2, Should display Variable 2 & 3 when Option 2 is selected, My VAR 2 2nd My VAR 3 2nd</p>\n",
|
|
65
69
|
},
|
|
66
70
|
});
|
|
67
71
|
}));
|
|
68
|
-
it(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
it("Should use main as default", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
73
|
+
let component;
|
|
74
|
+
yield act(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
75
|
+
const ConnectDocument = connectDocument((props) => (_jsx("h1", { children: props.document }, void 0)));
|
|
76
|
+
component = renderer.create(_jsx(ConnectDocument, { store: store, document: "default" }, void 0));
|
|
77
|
+
}));
|
|
78
|
+
const tree = component === null || component === void 0 ? void 0 : component.toTree();
|
|
79
|
+
if (!(tree === null || tree === void 0 ? void 0 : tree.rendered)) {
|
|
80
|
+
throw Error("Component not rendered while testing");
|
|
81
|
+
}
|
|
82
|
+
const { props } = Array.isArray(tree.rendered)
|
|
83
|
+
? tree.rendered[0]
|
|
84
|
+
: tree.rendered;
|
|
74
85
|
const { document, outputs } = props;
|
|
75
86
|
expect({ document, outputs }).toStrictEqual({
|
|
76
|
-
document:
|
|
87
|
+
document: "main",
|
|
77
88
|
outputs: {
|
|
78
|
-
|
|
89
|
+
"output-5-0": "<p>Should output <strong>Variable 1</strong> My VAR1</p>\n",
|
|
90
|
+
"output-7-0": "<p>Output for Option 1, Should display Variable 2 & 3 when Option 1 is selected, My VAR 2 1st My VAR 3 1st</p>\n",
|
|
91
|
+
"output-8-1": "<p>Output for Option 2, Should display Variable 2 & 3 when Option 2 is selected, My VAR 2 2nd My VAR 3 2nd</p>\n",
|
|
79
92
|
},
|
|
80
93
|
});
|
|
81
|
-
});
|
|
94
|
+
}));
|
|
82
95
|
});
|
package/dist/helpers/index.d.ts
CHANGED
package/dist/helpers/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function cancelOnResetState<T extends (...args: any[]) => any>(task: T): T;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { call, race, take } from "redux-saga/effects";
|
|
2
|
+
import { RESET_STATE } from "../redux/constants/app";
|
|
3
|
+
export function cancelOnResetState(task) {
|
|
4
|
+
return function* wrappedTask(...args) {
|
|
5
|
+
yield race({
|
|
6
|
+
task: call(task, ...args),
|
|
7
|
+
cancel: take(RESET_STATE),
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const getQueryParamsObject = (searchParams = window.location.search) => Array.from(new URLSearchParams(searchParams)).reduce((queryParamsObject, currentParams) => (Object.assign(Object.assign({}, queryParamsObject), { [currentParams[0]]: currentParams[1] })), {});
|
|
@@ -24,3 +24,4 @@ export declare const updateAvailableSectionsAction: (availableSections: number[]
|
|
|
24
24
|
export declare const updateCurrentSectionIdAction: (currentSectionId: number) => ActionsType.App.updateCurrentSectionId;
|
|
25
25
|
export declare const initCustomizationMetaAction: (meta: Exclude<ModelV3["customization"]["meta"], undefined>) => ActionsType.App.initCustomizationMeta;
|
|
26
26
|
export declare const initCustomizationAutoDefaultAction: (disableAutoDefault: StateType.App.Customization["disableAutoDefault"]) => ActionsType.App.initCustomizationAutoDefault;
|
|
27
|
+
export declare const resetStateAction: () => ActionsType.App.resetState;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { INIT_META, INIT_INSTANCE, UPDATE_INSTANCE_PAID, INIT_PAGINATION, GO_PAGE, GO_NEXT_PAGE, GO_PREVIOUS_PAGE, UPDATE_AVAILABLE_SECTIONS, UPDATE_CURRENT_APPSTATE, UPDATE_CURRENT_SECTION_ID, FETCH_MODEL_SUCCEEDED, FETCH_MODEL_FAILED, SET_DATA_STATUS, UPDATE_AVAILABLE_APPSTATES, INIT_CUSTOMIZATION_META, FETCH_MODEL_UNHEALTHY, FETCH_MODEL_USER_LOCKED, INIT_CUSTOMIZATION_AUTO_DEFAULT, UPDATE_INSTANCE, SET_FETCH_STATUS, FETCH_MODEL_NONBLOCKING, SET_MODEL_UUID, } from "../constants/app";
|
|
1
|
+
import { INIT_META, INIT_INSTANCE, UPDATE_INSTANCE_PAID, INIT_PAGINATION, GO_PAGE, GO_NEXT_PAGE, GO_PREVIOUS_PAGE, UPDATE_AVAILABLE_SECTIONS, UPDATE_CURRENT_APPSTATE, UPDATE_CURRENT_SECTION_ID, FETCH_MODEL_SUCCEEDED, FETCH_MODEL_FAILED, SET_DATA_STATUS, UPDATE_AVAILABLE_APPSTATES, INIT_CUSTOMIZATION_META, FETCH_MODEL_UNHEALTHY, FETCH_MODEL_USER_LOCKED, INIT_CUSTOMIZATION_AUTO_DEFAULT, UPDATE_INSTANCE, SET_FETCH_STATUS, FETCH_MODEL_NONBLOCKING, SET_MODEL_UUID, RESET_STATE, } from "../constants/app";
|
|
2
2
|
export const initMetaAction = (meta) => (Object.assign({ type: INIT_META }, meta));
|
|
3
3
|
export const setModelUuidAction = (modelUuid) => ({
|
|
4
4
|
type: SET_MODEL_UUID,
|
|
@@ -71,3 +71,6 @@ export const initCustomizationAutoDefaultAction = (disableAutoDefault) => ({
|
|
|
71
71
|
type: INIT_CUSTOMIZATION_AUTO_DEFAULT,
|
|
72
72
|
disableAutoDefault,
|
|
73
73
|
});
|
|
74
|
+
export const resetStateAction = () => ({
|
|
75
|
+
type: RESET_STATE,
|
|
76
|
+
});
|
|
@@ -67,4 +67,5 @@ export declare const actionsLibrary: {
|
|
|
67
67
|
updateCurrentSectionIdAction: (currentSectionId: number) => import("../..").ActionsType.App.updateCurrentSectionId;
|
|
68
68
|
initCustomizationMetaAction: (meta: import("@legalplace/models-v3-types").CustomizationMetaDefault) => import("../..").ActionsType.App.initCustomizationMeta;
|
|
69
69
|
initCustomizationAutoDefaultAction: (disableAutoDefault: boolean | undefined) => import("../..").ActionsType.App.initCustomizationAutoDefault;
|
|
70
|
+
resetStateAction: () => import("../..").ActionsType.App.resetState;
|
|
70
71
|
};
|
|
@@ -20,5 +20,5 @@ export declare const UPDATE_CURRENT_SECTION_ID = "UPDATE_CURRENT_SECTION_ID";
|
|
|
20
20
|
export declare const UPDATE_AVAILABLE_SECTIONS = "UPDATE_AVAILABLE_SECTIONS";
|
|
21
21
|
export declare const INIT_CUSTOMIZATION_META = "INIT_CUSTOMIZATION_META";
|
|
22
22
|
export declare const INIT_CUSTOMIZATION_AUTO_DEFAULT = "INIT_CUSTOMIZATION_AUTO_DEFAULT";
|
|
23
|
-
export declare const
|
|
23
|
+
export declare const RESET_STATE = "RESET_STATE";
|
|
24
24
|
export declare const INIT_PLUGINS = "@@INIT_PLUGINS";
|
|
@@ -20,5 +20,5 @@ export const UPDATE_CURRENT_SECTION_ID = "UPDATE_CURRENT_SECTION_ID";
|
|
|
20
20
|
export const UPDATE_AVAILABLE_SECTIONS = "UPDATE_AVAILABLE_SECTIONS";
|
|
21
21
|
export const INIT_CUSTOMIZATION_META = "INIT_CUSTOMIZATION_META";
|
|
22
22
|
export const INIT_CUSTOMIZATION_AUTO_DEFAULT = "INIT_CUSTOMIZATION_AUTO_DEFAULT";
|
|
23
|
-
export const
|
|
23
|
+
export const RESET_STATE = "RESET_STATE";
|
|
24
24
|
export const INIT_PLUGINS = "@@INIT_PLUGINS";
|
|
@@ -7,6 +7,7 @@ import { PathReader } from "../../libs/PathReader";
|
|
|
7
7
|
import { initSmartscriptTriggersAction } from "../actions/smartscript";
|
|
8
8
|
import { updateOptionAction, updateVariableAction } from "../actions/inputs";
|
|
9
9
|
import { smartScriptLoadedMessage } from "../../constants/smartscript";
|
|
10
|
+
import { RESET_STATE } from "../constants/app";
|
|
10
11
|
let iframe = null;
|
|
11
12
|
const watchEnableSmartScript = (mpi, next, action) => {
|
|
12
13
|
next(action);
|
|
@@ -52,6 +53,13 @@ const watchEnableSmartScript = (mpi, next, action) => {
|
|
|
52
53
|
});
|
|
53
54
|
document.body.append(iframe);
|
|
54
55
|
};
|
|
56
|
+
const watchResetState = (mpi, next, action) => {
|
|
57
|
+
next(action);
|
|
58
|
+
if (iframe) {
|
|
59
|
+
document.body.removeChild(iframe);
|
|
60
|
+
iframe = null;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
55
63
|
const watchUpdateOptionInput = (mpi, next, action) => {
|
|
56
64
|
var _a;
|
|
57
65
|
next(action);
|
|
@@ -108,6 +116,7 @@ const watchInitInputs = (mpi, next, action) => {
|
|
|
108
116
|
};
|
|
109
117
|
const watchersEnum = {
|
|
110
118
|
[ENABLE_SMARTSCRIPT]: watchEnableSmartScript,
|
|
119
|
+
[RESET_STATE]: watchResetState,
|
|
111
120
|
[UPDATE_OPTION_INPUT]: watchUpdateOptionInput,
|
|
112
121
|
[UPDATE_VARIABLE_INPUT]: watchUpdateVariableInput,
|
|
113
122
|
[ADD_MULTIPLE_OCCURENCY]: watchUpdateOptionInput,
|
|
@@ -5,5 +5,5 @@ export declare type WizardReducerActions = ActionsType.App.updateAvailableSectio
|
|
|
5
5
|
export declare type CustomizationsReducerActions = ActionsType.App.initCustomizationMeta | ActionsType.App.initCustomizationAutoDefault;
|
|
6
6
|
export declare type MetaReducerActions = ActionsType.App.initMeta | ActionsType.App.fetchModelSucceeded | ActionsType.App.fetchModelFailed;
|
|
7
7
|
export declare type InstanceReducerActions = ActionsType.App.initInstance | ActionsType.App.updateInstancePaid | ActionsType.App.setDataStatus;
|
|
8
|
-
export declare type appReducerActions = PaginationReducerActions | MetaReducerActions | WizardReducerActions | CustomizationsReducerActions | InstanceReducerActions;
|
|
8
|
+
export declare type appReducerActions = PaginationReducerActions | MetaReducerActions | WizardReducerActions | CustomizationsReducerActions | InstanceReducerActions | ActionsType.App.resetState;
|
|
9
9
|
export declare const appReducer: (state: StateType.App | undefined, action: appReducerActions) => StateType.App;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { initPaginationReducer } from "./app/pagination/initPagination";
|
|
2
|
-
import { INIT_PAGINATION, GO_PAGE, GO_NEXT_PAGE, GO_PREVIOUS_PAGE, INIT_META, INIT_INSTANCE, UPDATE_INSTANCE_PAID, UPDATE_AVAILABLE_SECTIONS, FETCH_MODEL_FAILED, FETCH_MODEL_SUCCEEDED, SET_DATA_STATUS, UPDATE_AVAILABLE_APPSTATES, INIT_CUSTOMIZATION_META, FETCH_MODEL_UNHEALTHY, FETCH_MODEL_USER_LOCKED, INIT_CUSTOMIZATION_AUTO_DEFAULT, UPDATE_INSTANCE, FETCH_MODEL_NONBLOCKING, SET_MODEL_UUID, } from "../constants/app";
|
|
2
|
+
import { INIT_PAGINATION, GO_PAGE, GO_NEXT_PAGE, GO_PREVIOUS_PAGE, INIT_META, INIT_INSTANCE, UPDATE_INSTANCE_PAID, UPDATE_AVAILABLE_SECTIONS, FETCH_MODEL_FAILED, FETCH_MODEL_SUCCEEDED, SET_DATA_STATUS, UPDATE_AVAILABLE_APPSTATES, INIT_CUSTOMIZATION_META, FETCH_MODEL_UNHEALTHY, FETCH_MODEL_USER_LOCKED, INIT_CUSTOMIZATION_AUTO_DEFAULT, UPDATE_INSTANCE, FETCH_MODEL_NONBLOCKING, SET_MODEL_UUID, RESET_STATE, } from "../constants/app";
|
|
3
3
|
import { goPageReducer } from "./app/pagination/goPage";
|
|
4
4
|
import { goNextPageReducer } from "./app/pagination/goNextPage";
|
|
5
5
|
import { goPreviousPageReducer } from "./app/pagination/goPreviousPage";
|
|
@@ -71,6 +71,8 @@ const reducersEnum = {
|
|
|
71
71
|
[INIT_CUSTOMIZATION_META]: initCustomizationMetaReducer,
|
|
72
72
|
};
|
|
73
73
|
export const appReducer = (state = initialState, action) => {
|
|
74
|
+
if (action.type === RESET_STATE)
|
|
75
|
+
return initialState;
|
|
74
76
|
const reducer = reducersEnum[action.type];
|
|
75
77
|
if (typeof reducer === "function") {
|
|
76
78
|
return reducer.apply(null, [state, action]);
|
|
@@ -10,6 +10,7 @@ import { addMultipleOccurencyReducer } from "./conditions/addMultipleOccurency";
|
|
|
10
10
|
import { updateOptionValidatorConditionReducer } from "./conditions/updateOptionValidatorCondition";
|
|
11
11
|
import { updateVariableValidatorConditionReducer } from "./conditions/updateVariableValidatorCondition";
|
|
12
12
|
import { deleteMultipleOccurencyReducer } from "./conditions/deleteMultipleOccurency";
|
|
13
|
+
import { RESET_STATE } from "../constants/app";
|
|
13
14
|
const initialState = {
|
|
14
15
|
options: {},
|
|
15
16
|
variables: {},
|
|
@@ -34,6 +35,8 @@ const reducersEnum = {
|
|
|
34
35
|
[ADD_MULTIPLE_OCCURENCY]: addMultipleOccurencyReducer,
|
|
35
36
|
};
|
|
36
37
|
export const conditionsReducer = (state = initialState, action) => {
|
|
38
|
+
if (action.type === RESET_STATE)
|
|
39
|
+
return initialState;
|
|
37
40
|
const reducer = reducersEnum[action.type];
|
|
38
41
|
if (typeof reducer === "function")
|
|
39
42
|
return reducer.apply(null, [state, action]);
|
|
@@ -5,6 +5,7 @@ import { initVariableReducer } from "./inputs/initVariable";
|
|
|
5
5
|
import { updateVariableInputReducer } from "./inputs/updateVariableInput";
|
|
6
6
|
import { addMultipleOccurencyReducer } from "./inputs/addMultipleOccurency";
|
|
7
7
|
import { deleteMultipleOccurencyReducer } from "./inputs/deleteMultipleOccurency";
|
|
8
|
+
import { RESET_STATE } from "../constants/app";
|
|
8
9
|
const initialState = {
|
|
9
10
|
options: {},
|
|
10
11
|
variables: {},
|
|
@@ -18,6 +19,8 @@ const reducersEnum = {
|
|
|
18
19
|
[DELETE_MULTIPLE_OCCURENCY]: deleteMultipleOccurencyReducer,
|
|
19
20
|
};
|
|
20
21
|
export const inputsReducer = (state = initialState, action) => {
|
|
22
|
+
if (action.type === RESET_STATE)
|
|
23
|
+
return initialState;
|
|
21
24
|
const reducer = reducersEnum[action.type];
|
|
22
25
|
if (typeof reducer === "function")
|
|
23
26
|
return reducer.apply(null, [state, action]);
|
|
@@ -8,6 +8,7 @@ import { setMandatoryIgnoreReducer } from "./mandatories/setMandatoryIgnore";
|
|
|
8
8
|
import { setMandatorySectionReducer } from "./mandatories/setMandatorySection";
|
|
9
9
|
import { setMandatoryOptionReducer } from "./mandatories/setMandatoryOption";
|
|
10
10
|
import { setMandatoryVariableReducer } from "./mandatories/setMandatoryVariable";
|
|
11
|
+
import { RESET_STATE } from "../constants/app";
|
|
11
12
|
const initialState = {
|
|
12
13
|
ignore: true,
|
|
13
14
|
sections: {},
|
|
@@ -25,6 +26,8 @@ const reducersEnum = {
|
|
|
25
26
|
[SET_MANDATORY_VARIABLE]: setMandatoryVariableReducer,
|
|
26
27
|
};
|
|
27
28
|
export const mandatoriesReducer = (state = initialState, action) => {
|
|
29
|
+
if (action.type === RESET_STATE)
|
|
30
|
+
return initialState;
|
|
28
31
|
const reducer = reducersEnum[action.type];
|
|
29
32
|
if (typeof reducer === "function")
|
|
30
33
|
return reducer.apply(null, [state, action]);
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { getPluginsStoreReducers } from "../../PluginLoader";
|
|
2
|
+
import { RESET_STATE } from "../constants/app";
|
|
2
3
|
export const pluginsStoreReducer = (state = {}, action) => {
|
|
4
|
+
if (action.type === RESET_STATE)
|
|
5
|
+
return {};
|
|
3
6
|
const pluginsStoreReducers = getPluginsStoreReducers();
|
|
4
7
|
const plugins = Object.keys(pluginsStoreReducers);
|
|
5
8
|
const newState = Object.assign({}, state);
|
|
@@ -2,6 +2,7 @@ import { initReferencesReducer } from "./references/initReferences";
|
|
|
2
2
|
import { updateOptionMetaReducer } from "./references/updateOptionMeta";
|
|
3
3
|
import { updateVariableMetaReducer } from "./references/updateVariableMeta";
|
|
4
4
|
import { INIT_REFERENCES, UPDATE_OPTION_META, UPDATE_VARIABLE_META, } from "../constants/references";
|
|
5
|
+
import { RESET_STATE } from "../constants/app";
|
|
5
6
|
const initialState = {
|
|
6
7
|
options: {},
|
|
7
8
|
variables: {},
|
|
@@ -44,6 +45,8 @@ const reducersEnum = {
|
|
|
44
45
|
[UPDATE_VARIABLE_META]: updateVariableMetaReducer,
|
|
45
46
|
};
|
|
46
47
|
export const referencesReducer = (state = initialState, action) => {
|
|
48
|
+
if (action.type === RESET_STATE)
|
|
49
|
+
return initialState;
|
|
47
50
|
const reducer = reducersEnum[action.type];
|
|
48
51
|
if (typeof reducer === "function")
|
|
49
52
|
return reducer.apply(null, [state, action]);
|
|
@@ -3,6 +3,7 @@ import { enableSmartScriptReducer } from "./smartscript/enableSmartScript";
|
|
|
3
3
|
import { initSmartscriptTriggersReducer } from "./smartscript/initSmartScriptTriggers";
|
|
4
4
|
import { updateSmartscriptOptionHiddenReducer } from "./smartscript/updateSmartscriptOptionHidden";
|
|
5
5
|
import { updateSmartscriptVariableHiddenReducer } from "./smartscript/updateSmartscriptVariableHidden";
|
|
6
|
+
import { RESET_STATE } from "../constants/app";
|
|
6
7
|
const initialState = {
|
|
7
8
|
enabled: false,
|
|
8
9
|
triggers: {
|
|
@@ -21,6 +22,8 @@ const reducersEnum = {
|
|
|
21
22
|
[UPDATE_SMARTSCRIPT_VARIABLE_HIDDEN]: updateSmartscriptVariableHiddenReducer,
|
|
22
23
|
};
|
|
23
24
|
export const smartscriptReducer = (state = initialState, action) => {
|
|
25
|
+
if (action.type === RESET_STATE)
|
|
26
|
+
return initialState;
|
|
24
27
|
const reducer = reducersEnum[action.type];
|
|
25
28
|
if (typeof reducer === "function")
|
|
26
29
|
return reducer.apply(null, [state, action]);
|
|
@@ -2,6 +2,7 @@ import { setUserValidTokenReducer } from "./user/setUserValidToken";
|
|
|
2
2
|
import { SET_USER_VALID_TOKEN, INIT_USER, SET_USER_STATUS, } from "../constants/user";
|
|
3
3
|
import { initUserReducer } from "./user/initUser";
|
|
4
4
|
import { setUserStatusReducer } from "./user/setUserStatus";
|
|
5
|
+
import { RESET_STATE } from "../constants/app";
|
|
5
6
|
const initialState = {
|
|
6
7
|
status: "unauthenticated",
|
|
7
8
|
email: "",
|
|
@@ -15,6 +16,8 @@ const reducersEnum = {
|
|
|
15
16
|
[SET_USER_VALID_TOKEN]: setUserValidTokenReducer,
|
|
16
17
|
};
|
|
17
18
|
export const userReducer = (state = initialState, action) => {
|
|
19
|
+
if (action.type === RESET_STATE)
|
|
20
|
+
return initialState;
|
|
18
21
|
const reducer = reducersEnum[action.type];
|
|
19
22
|
if (typeof reducer === "function") {
|
|
20
23
|
return reducer.apply(null, [state, action]);
|
|
@@ -20,6 +20,7 @@ import { enableSmartscriptAction } from "../actions/smartscript";
|
|
|
20
20
|
import { FETCH_MODEL, FETCH_MODEL_PREREQUISITES, } from "../constants/sagas/model";
|
|
21
21
|
import { fetchModelAction } from "../actions/sagas/model";
|
|
22
22
|
import { initInputsDecorator } from "./initInputs";
|
|
23
|
+
import { cancelOnResetState } from "../../helpers/sagaCancelOnResetState";
|
|
23
24
|
const cookies = new Cookies();
|
|
24
25
|
function* setFetchModelToNonBlocking(firstCurrentAppState) {
|
|
25
26
|
yield put(initPaginationAction({
|
|
@@ -323,7 +324,7 @@ function* fetchModelDecorator(action) {
|
|
|
323
324
|
}
|
|
324
325
|
}
|
|
325
326
|
function* fetchModelSaga() {
|
|
326
|
-
yield takeLatest(FETCH_MODEL_PREREQUISITES, fetchModelPrerequisites);
|
|
327
|
-
yield takeLatest(FETCH_MODEL, fetchModelDecorator);
|
|
327
|
+
yield takeLatest(FETCH_MODEL_PREREQUISITES, cancelOnResetState(fetchModelPrerequisites));
|
|
328
|
+
yield takeLatest(FETCH_MODEL, cancelOnResetState(fetchModelDecorator));
|
|
328
329
|
}
|
|
329
330
|
export default fetchModelSaga;
|
|
@@ -1,7 +1,17 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import * as fs from 'fs';
|
|
2
11
|
import { createAppStore, getStore } from '../store';
|
|
3
12
|
import { initMetaAction, initInstanceAction } from '../actions/app';
|
|
4
13
|
import { fetchModelPrerequisitesAction } from '../actions/sagas/model';
|
|
14
|
+
import { ReferencesParser } from '@legalplace/referencesparser';
|
|
5
15
|
const permalink = 'test-model';
|
|
6
16
|
const uniqid = 'myMockUniqid';
|
|
7
17
|
const mockApiEndpoint = 'https://api.mock/api/v1/';
|
|
@@ -19,7 +29,18 @@ jest.mock('../../config', () => ({
|
|
|
19
29
|
wizardInstancePath: '/:permalink/questionnaire/:uniqid([0-9a-zA-Z]+)/:page([0-9]+|sommaire)',
|
|
20
30
|
},
|
|
21
31
|
appStates: ['wizard'],
|
|
32
|
+
plugins: {},
|
|
33
|
+
theme: {
|
|
34
|
+
name: "legacy"
|
|
35
|
+
}
|
|
22
36
|
}),
|
|
37
|
+
updateConfig: () => { }
|
|
38
|
+
}));
|
|
39
|
+
jest.mock('../../Globals.ts', () => ({
|
|
40
|
+
__esModule: true,
|
|
41
|
+
default: {
|
|
42
|
+
loadTheme: () => __awaiter(void 0, void 0, void 0, function* () { return ({ default: {} }); })
|
|
43
|
+
}
|
|
23
44
|
}));
|
|
24
45
|
describe('Fetch model saga', () => {
|
|
25
46
|
let store;
|
|
@@ -46,7 +67,59 @@ describe('Fetch model saga', () => {
|
|
|
46
67
|
fetchMock.resetMocks();
|
|
47
68
|
});
|
|
48
69
|
it('Sends fetch client config request to API', () => {
|
|
49
|
-
fetchMock.
|
|
70
|
+
fetchMock.mockResponse((request) => __awaiter(void 0, void 0, void 0, function* () {
|
|
71
|
+
switch (request.url) {
|
|
72
|
+
case "https://api.mock/api/v1/client-config?permalink=test-model&disableOnBoarding=true":
|
|
73
|
+
return JSON.stringify({
|
|
74
|
+
clientConfig: {
|
|
75
|
+
domain: "api.mock",
|
|
76
|
+
prefix: null,
|
|
77
|
+
metadata: {}
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
case "https://api.mock/api/v1/wizard/contractv1/config/test-model/myMockUniqid":
|
|
81
|
+
return JSON.stringify({
|
|
82
|
+
modelUuid: "mock-uuid"
|
|
83
|
+
});
|
|
84
|
+
case "https://api.mock/api/v1/wizard/contractv1/model/mock-uuid":
|
|
85
|
+
return JSON.stringify({
|
|
86
|
+
references: new ReferencesParser(model).getReferences(),
|
|
87
|
+
meta: {
|
|
88
|
+
id: 1,
|
|
89
|
+
title: "Mock Model",
|
|
90
|
+
modelVersion: 1,
|
|
91
|
+
productType: "contract",
|
|
92
|
+
metdata: null
|
|
93
|
+
},
|
|
94
|
+
customization: {
|
|
95
|
+
disableAutoDefault: true,
|
|
96
|
+
meta: {
|
|
97
|
+
isTwoSteps: false,
|
|
98
|
+
disableDownloads: false,
|
|
99
|
+
scenario: {},
|
|
100
|
+
contractType: {
|
|
101
|
+
socialType: "individual",
|
|
102
|
+
privacy: "public"
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
dataStorage: {
|
|
106
|
+
extendedDuration: false
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
ovc: {
|
|
110
|
+
options: {},
|
|
111
|
+
variables: {}
|
|
112
|
+
},
|
|
113
|
+
smartScript: false
|
|
114
|
+
});
|
|
115
|
+
case "https://api.mock/api/v1/wizard/contractv1/test-model/myMockUniqid":
|
|
116
|
+
return JSON.stringify({
|
|
117
|
+
model,
|
|
118
|
+
meta
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
return "{}";
|
|
122
|
+
}));
|
|
50
123
|
store.dispatch(fetchModelPrerequisitesAction(permalink));
|
|
51
124
|
expect(fetchMock.mock.calls.length).toEqual(1);
|
|
52
125
|
expect(fetchMock.mock.calls[0][0]).toEqual(`${mockApiEndpoint}client-config?permalink=${permalink}&disableOnBoarding=true`);
|
|
@@ -3,6 +3,7 @@ import { UPDATE_OPTION_INPUT } from "../constants/inputs";
|
|
|
3
3
|
import { selectRadioSiblings } from "../selectors/references";
|
|
4
4
|
import { updateOptionAction } from "../actions/inputs";
|
|
5
5
|
import { selectOptionInputByIndex } from "../selectors/inputs";
|
|
6
|
+
import { cancelOnResetState } from "../../helpers/sagaCancelOnResetState";
|
|
6
7
|
function* homogeneousRadioInputsDecorator(action) {
|
|
7
8
|
const { id, index, value } = action;
|
|
8
9
|
if (value === true) {
|
|
@@ -17,6 +18,6 @@ function* homogeneousRadioInputsDecorator(action) {
|
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
20
|
function* homogeneousRadioInputsSaga() {
|
|
20
|
-
yield takeLatest(UPDATE_OPTION_INPUT, homogeneousRadioInputsDecorator);
|
|
21
|
+
yield takeLatest(UPDATE_OPTION_INPUT, cancelOnResetState(homogeneousRadioInputsDecorator));
|
|
21
22
|
}
|
|
22
23
|
export default homogeneousRadioInputsSaga;
|
|
@@ -8,6 +8,7 @@ import { ConditionsInitiator } from "../../libs/ConditionsInitiator";
|
|
|
8
8
|
import { selectOptionRelations, selectVariableReference, } from "../selectors/references";
|
|
9
9
|
import { checkDateValidity } from "../../helpers/date.helper";
|
|
10
10
|
import { checkPhoneNumberValidity } from "../../helpers/phoneNumber.helper";
|
|
11
|
+
import { cancelOnResetState } from "../../helpers/sagaCancelOnResetState";
|
|
11
12
|
const getValues = (arr1, arr2) => arr1.map((v, index) => arr2[index] || v);
|
|
12
13
|
export function* initInputsDecorator(action) {
|
|
13
14
|
const state = yield select((s) => s);
|
|
@@ -72,6 +73,6 @@ export function* initInputsDecorator(action) {
|
|
|
72
73
|
yield put(initConditionsAction(conditions));
|
|
73
74
|
}
|
|
74
75
|
function* initInputsSaga() {
|
|
75
|
-
yield takeLatest(INIT_INPUTS, initInputsDecorator);
|
|
76
|
+
yield takeLatest(INIT_INPUTS, cancelOnResetState(initInputsDecorator));
|
|
76
77
|
}
|
|
77
78
|
export default initInputsSaga;
|
|
@@ -2,6 +2,7 @@ import { call, takeLeading } from "redux-saga/effects";
|
|
|
2
2
|
import { getPluginsStoreSagas } from "../../PluginLoader";
|
|
3
3
|
import { INIT_PLUGINS } from "../constants";
|
|
4
4
|
import { getSagaMiddleware } from "./middleware";
|
|
5
|
+
import { cancelOnResetState } from "../../helpers/sagaCancelOnResetState";
|
|
5
6
|
function* initPluginsDecorator() {
|
|
6
7
|
try {
|
|
7
8
|
const pluginsStoreSagas = getPluginsStoreSagas();
|
|
@@ -19,6 +20,6 @@ function* initPluginsDecorator() {
|
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
22
|
function* initPluginsSaga() {
|
|
22
|
-
yield takeLeading(INIT_PLUGINS, initPluginsDecorator);
|
|
23
|
+
yield takeLeading(INIT_PLUGINS, cancelOnResetState(initPluginsDecorator));
|
|
23
24
|
}
|
|
24
25
|
export default initPluginsSaga;
|
|
@@ -5,6 +5,7 @@ import { SAVE_DATA } from "../constants/sagas/data";
|
|
|
5
5
|
import { selectInputs } from "../selectors/inputs";
|
|
6
6
|
import { OvcConverter } from "../../libs/OvcConverter";
|
|
7
7
|
import { updateInstanceArguments } from "../../service/api.manager";
|
|
8
|
+
import { cancelOnResetState } from "../../helpers/sagaCancelOnResetState";
|
|
8
9
|
function* saveDataDecorator(action) {
|
|
9
10
|
try {
|
|
10
11
|
yield put(setDataStatus("saving"));
|
|
@@ -31,6 +32,6 @@ function* saveDataDecorator(action) {
|
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
34
|
function* saveDataSaga() {
|
|
34
|
-
yield takeLeading(SAVE_DATA, saveDataDecorator);
|
|
35
|
+
yield takeLeading(SAVE_DATA, cancelOnResetState(saveDataDecorator));
|
|
35
36
|
}
|
|
36
37
|
export default saveDataSaga;
|
|
@@ -5,6 +5,7 @@ import { selectOptionInput, selectOptionInputByIndex, } from "../selectors/input
|
|
|
5
5
|
import { updateOptionAction } from "../actions/inputs";
|
|
6
6
|
import { goPageAction } from "../actions/app";
|
|
7
7
|
import { selectOptionConditionValue } from "../selectors/conditions";
|
|
8
|
+
import { cancelOnResetState } from "../../helpers/sagaCancelOnResetState";
|
|
8
9
|
function setOptionsDefaults(id, defaults, parentIndexes) {
|
|
9
10
|
let ActionsToDispatch = [];
|
|
10
11
|
const currentConditions = selectOptionConditionValue(id);
|
|
@@ -97,6 +98,6 @@ function* setDefaultOptions() {
|
|
|
97
98
|
}
|
|
98
99
|
}
|
|
99
100
|
function* setDefaultsSaga() {
|
|
100
|
-
yield takeLatest("SET_DEFAULTS", setDefaultOptions);
|
|
101
|
+
yield takeLatest("SET_DEFAULTS", cancelOnResetState(setDefaultOptions));
|
|
101
102
|
}
|
|
102
103
|
export default setDefaultsSaga;
|
|
@@ -10,6 +10,7 @@ import { OvcConverter } from "../../libs/OvcConverter";
|
|
|
10
10
|
import { setUserEmailSucceeded } from "../actions/sagas/user";
|
|
11
11
|
import { EMAIL_REGEX } from "../../constants/emailValidation";
|
|
12
12
|
import { selectUserStatus, selectUserEmail } from "../selectors/user";
|
|
13
|
+
import { cancelOnResetState } from "../../helpers/sagaCancelOnResetState";
|
|
13
14
|
const canalHeaders = {
|
|
14
15
|
"lp-referrer": window.document.referrer,
|
|
15
16
|
"lp-origin": window.location.href,
|
|
@@ -112,6 +113,6 @@ function* setUserEmailDecorator(action) {
|
|
|
112
113
|
}
|
|
113
114
|
}
|
|
114
115
|
function* setUserEmailSaga() {
|
|
115
|
-
yield takeLatest(SET_USER_EMAIL, setUserEmailDecorator);
|
|
116
|
+
yield takeLatest(SET_USER_EMAIL, cancelOnResetState(setUserEmailDecorator));
|
|
116
117
|
}
|
|
117
118
|
export default setUserEmailSaga;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RESET_STATE } from "../constants/app";
|
|
2
2
|
import selectorsCache from "./cache";
|
|
3
3
|
let SelectorsStateTrack = -1;
|
|
4
4
|
let globalMPI;
|
|
@@ -31,7 +31,7 @@ export function createSelector(selector, cacheKey) {
|
|
|
31
31
|
}
|
|
32
32
|
export const selectorsMiddleware = (mpi) => (next) => (action) => {
|
|
33
33
|
const result = next(action);
|
|
34
|
-
if (action.type ===
|
|
34
|
+
if (action.type === RESET_STATE) {
|
|
35
35
|
selectorsCache.clear();
|
|
36
36
|
}
|
|
37
37
|
globalMPI = mpi;
|
package/dist/redux/store.js
CHANGED
|
@@ -23,12 +23,14 @@ import { smartscriptReducer } from "./reducers/smartscript";
|
|
|
23
23
|
import smartscriptMiddleware from "./middlewares/smartscriptMiddleware";
|
|
24
24
|
import thirdPartyScriptsMiddleware from "./middlewares/thirdpartyScriptsMiddleware";
|
|
25
25
|
import { pluginsStoreReducer } from "./reducers/pluginsStore";
|
|
26
|
-
import { DANGEROUS_DESTROY_STORE } from "./constants/app";
|
|
27
26
|
import { getSagaMiddleware } from "./sagas/middleware";
|
|
28
27
|
let store;
|
|
29
|
-
let history = null;
|
|
30
28
|
export const createAppStore = (historyType = "browser") => {
|
|
31
|
-
|
|
29
|
+
if (store !== undefined) {
|
|
30
|
+
createHistory(historyType);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const history = createHistory(historyType);
|
|
32
34
|
const wizardxReducers = combineReducers({
|
|
33
35
|
router: connectRouter(history),
|
|
34
36
|
app: appReducer,
|
|
@@ -40,17 +42,12 @@ export const createAppStore = (historyType = "browser") => {
|
|
|
40
42
|
smartscript: smartscriptReducer,
|
|
41
43
|
pluginsStore: pluginsStoreReducer,
|
|
42
44
|
});
|
|
43
|
-
const rootReducer = (state, action) => {
|
|
44
|
-
if (action.type === DANGEROUS_DESTROY_STORE)
|
|
45
|
-
return wizardxReducers(undefined, action);
|
|
46
|
-
return wizardxReducers(state, action);
|
|
47
|
-
};
|
|
48
45
|
const sagaMiddleware = getSagaMiddleware();
|
|
49
46
|
const appliedMiddlewares = applyMiddleware(pluginsHookMiddleware, routerMiddleware(history), sagaMiddleware, paginationWatcherMiddleware, selectorsMiddleware, conditionsWatcherMiddleware, prefillerWatcherMiddleware, evaluationsWatcherMiddleware, multiplesActionsMiddleware, mandatoriesWatcherMiddleware, smartscriptMiddleware, thirdPartyScriptsMiddleware);
|
|
50
47
|
const middlewares = Globals.appEnv !== "production"
|
|
51
48
|
? composeWithDevTools(appliedMiddlewares)
|
|
52
49
|
: appliedMiddlewares;
|
|
53
|
-
store = createStore(
|
|
50
|
+
store = createStore(wizardxReducers, middlewares);
|
|
54
51
|
sagasRunner(sagaMiddleware);
|
|
55
52
|
subscribeListeners(store);
|
|
56
53
|
};
|
|
@@ -108,14 +108,15 @@ export const getCreateInstanceArguments = (permalink, searchParams, modelVersion
|
|
|
108
108
|
return createInstanceArguments;
|
|
109
109
|
};
|
|
110
110
|
export const getClientConfigArguments = (permalink, uniqid) => {
|
|
111
|
+
const userToken = getAuthToken();
|
|
111
112
|
const apiEndpoint = getConfig().apiEndpoint + (/\/$/.test(getConfig().apiEndpoint) ? "" : "/");
|
|
112
|
-
const route = `${apiEndpoint}client-config${permalink ? `?permalink=${permalink}` : ""}${uniqid ? "&disableOnBoarding=true" : ""}`;
|
|
113
|
+
const route = `${apiEndpoint}client-config${permalink ? `?permalink=${permalink}` : ""}${uniqid ? "&disableOnBoarding=true" : ""}${userToken ? `&token=${userToken}` : ""}`;
|
|
113
114
|
return [
|
|
114
115
|
route,
|
|
115
116
|
{
|
|
116
117
|
headers: {
|
|
117
118
|
"Content-Type": "application/json",
|
|
118
|
-
Authorization: `Bearer ${
|
|
119
|
+
Authorization: `Bearer ${userToken}`,
|
|
119
120
|
},
|
|
120
121
|
credentials: "include",
|
|
121
122
|
},
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import Cookies from "universal-cookie";
|
|
2
|
+
import { getQueryParamsObject } from "../helpers/urlSearchParams";
|
|
2
3
|
const cookies = new Cookies();
|
|
3
|
-
export const getAuthToken = () => cookies.get("token");
|
|
4
|
+
export const getAuthToken = () => { var _a; return ((_a = getQueryParamsObject()) === null || _a === void 0 ? void 0 : _a.token) || cookies.get("token"); };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ModelV3, OptionV3, VariableV3 } from "@legalplace/models-v3-types";
|
|
2
2
|
import type { StateType } from "./State.type";
|
|
3
|
-
import type { UPDATE_AVAILABLE_SECTIONS, UPDATE_AVAILABLE_APPSTATES, GO_PREVIOUS_PAGE, GO_NEXT_PAGE, GO_PAGE, INIT_PAGINATION, UPDATE_INSTANCE_PAID, INIT_INSTANCE, UPDATE_INSTANCE, INIT_META, UPDATE_CURRENT_APPSTATE, UPDATE_CURRENT_SECTION_ID, FETCH_MODEL_SUCCEEDED, FETCH_MODEL_FAILED, SET_DATA_STATUS, SET_FETCH_STATUS, INIT_CUSTOMIZATION_META, FETCH_MODEL_UNHEALTHY, FETCH_MODEL_USER_LOCKED, INIT_CUSTOMIZATION_AUTO_DEFAULT, FETCH_MODEL_NONBLOCKING, SET_MODEL_UUID } from "../redux/constants/app";
|
|
3
|
+
import type { UPDATE_AVAILABLE_SECTIONS, UPDATE_AVAILABLE_APPSTATES, GO_PREVIOUS_PAGE, GO_NEXT_PAGE, GO_PAGE, INIT_PAGINATION, UPDATE_INSTANCE_PAID, INIT_INSTANCE, UPDATE_INSTANCE, INIT_META, UPDATE_CURRENT_APPSTATE, UPDATE_CURRENT_SECTION_ID, FETCH_MODEL_SUCCEEDED, FETCH_MODEL_FAILED, SET_DATA_STATUS, SET_FETCH_STATUS, INIT_CUSTOMIZATION_META, FETCH_MODEL_UNHEALTHY, FETCH_MODEL_USER_LOCKED, INIT_CUSTOMIZATION_AUTO_DEFAULT, FETCH_MODEL_NONBLOCKING, SET_MODEL_UUID, RESET_STATE } from "../redux/constants/app";
|
|
4
4
|
import type { INIT_USER, SET_USER_STATUS, SET_USER_VALID_TOKEN } from "../redux/constants/user";
|
|
5
5
|
import type { INIT_REFERENCES, UPDATE_VARIABLE_META, UPDATE_OPTION_META } from "../redux/constants/references";
|
|
6
6
|
import type { INIT_INPUTS, INIT_OPTION, UPDATE_OPTION_INPUT, INIT_VARIABLE, UPDATE_VARIABLE_INPUT, ADD_MULTIPLE_OCCURENCY, DELETE_MULTIPLE_OCCURENCY } from "../redux/constants/inputs";
|
|
@@ -95,6 +95,9 @@ export declare namespace ActionsType {
|
|
|
95
95
|
type: typeof INIT_CUSTOMIZATION_AUTO_DEFAULT;
|
|
96
96
|
disableAutoDefault: StateType.App.Customization["disableAutoDefault"];
|
|
97
97
|
}
|
|
98
|
+
interface resetState {
|
|
99
|
+
type: typeof RESET_STATE;
|
|
100
|
+
}
|
|
98
101
|
}
|
|
99
102
|
namespace User {
|
|
100
103
|
interface initUser extends Omit<StateType.User, "status"> {
|
|
@@ -332,9 +335,9 @@ export declare namespace ActionsType {
|
|
|
332
335
|
}
|
|
333
336
|
}
|
|
334
337
|
}
|
|
335
|
-
export declare type ConditionsActions = ActionsType.Conditions.initConditions | ActionsType.Conditions.updateOptionCondition | ActionsType.Conditions.updateVariableCondition | ActionsType.Conditions.updateSectionCondition | ActionsType.Conditions.updateVariableValidatorCondition | ActionsType.Conditions.updatePrefillerCondition | ActionsType.Conditions.updateOptionValidatorCondition;
|
|
336
|
-
export declare type UserActions = ActionsType.User.initUser | ActionsType.User.setUserStatus;
|
|
337
|
-
export declare type ReferencesActions = ActionsType.References.initReferences | ActionsType.References.updateOptionMeta | ActionsType.References.updateVariableMeta;
|
|
338
|
-
export declare type InputsActions = ActionsType.Inputs.initVariable | ActionsType.Inputs.updateVariableInput | ActionsType.Inputs.initOption | ActionsType.Inputs.updateOptionInput;
|
|
339
|
-
export declare type MandatoriesActions = ActionsType.Mandatories.initMandatoryOption | ActionsType.Mandatories.initMandatoryVariable | ActionsType.Mandatories.setMandatoryIgnore | ActionsType.Mandatories.setMandatorySection | ActionsType.Mandatories.setMandatoryOption | ActionsType.Mandatories.setMandatoryVariable;
|
|
340
|
-
export declare type SmartScriptActions = ActionsType.SmartScript.enableSmartScript | ActionsType.SmartScript.initSmartscriptTriggers;
|
|
338
|
+
export declare type ConditionsActions = ActionsType.Conditions.initConditions | ActionsType.Conditions.updateOptionCondition | ActionsType.Conditions.updateVariableCondition | ActionsType.Conditions.updateSectionCondition | ActionsType.Conditions.updateVariableValidatorCondition | ActionsType.Conditions.updatePrefillerCondition | ActionsType.Conditions.updateOptionValidatorCondition | ActionsType.App.resetState;
|
|
339
|
+
export declare type UserActions = ActionsType.User.initUser | ActionsType.User.setUserStatus | ActionsType.App.resetState;
|
|
340
|
+
export declare type ReferencesActions = ActionsType.References.initReferences | ActionsType.References.updateOptionMeta | ActionsType.References.updateVariableMeta | ActionsType.App.resetState;
|
|
341
|
+
export declare type InputsActions = ActionsType.Inputs.initVariable | ActionsType.Inputs.updateVariableInput | ActionsType.Inputs.initOption | ActionsType.Inputs.updateOptionInput | ActionsType.App.resetState;
|
|
342
|
+
export declare type MandatoriesActions = ActionsType.Mandatories.initMandatoryOption | ActionsType.Mandatories.initMandatoryVariable | ActionsType.Mandatories.setMandatoryIgnore | ActionsType.Mandatories.setMandatorySection | ActionsType.Mandatories.setMandatoryOption | ActionsType.Mandatories.setMandatoryVariable | ActionsType.App.resetState;
|
|
343
|
+
export declare type SmartScriptActions = ActionsType.SmartScript.enableSmartScript | ActionsType.SmartScript.initSmartscriptTriggers | ActionsType.App.resetState;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legalplace/wizardx-core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.1",
|
|
4
4
|
"author": "Moncef Hammou (moncef@legalplace.fr)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -95,5 +95,5 @@
|
|
|
95
95
|
"*.test.ts",
|
|
96
96
|
"*.test.tsx"
|
|
97
97
|
],
|
|
98
|
-
"gitHead": "
|
|
98
|
+
"gitHead": "bd2903cd97947bd0e8912f5c728ac21f0b8b2a53"
|
|
99
99
|
}
|