@legalplace/wizardx-core 2.15.0 → 3.0.0

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 CHANGED
@@ -3,6 +3,40 @@
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
+ # [3.0.0](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@2.15.1...@legalplace/wizardx-core@3.0.0) (2023-02-08)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * bunch of fixes and package alignments api[#7559](https://git.legalplace.eu/legalplace/monorepo/issues/7559) ([7e2828f](https://git.legalplace.eu/legalplace/monorepo/commits/7e2828feda10ffdf07cacd1cc661122830faaeeb))
12
+ * fix test api[#7559](https://git.legalplace.eu/legalplace/monorepo/issues/7559) ([9a0b90a](https://git.legalplace.eu/legalplace/monorepo/commits/9a0b90ab2662debc5bacd84702f4fc722b5ea6fc))
13
+
14
+
15
+ ### Features
16
+
17
+ * adding models-v3-types package to monorepo api[#7559](https://git.legalplace.eu/legalplace/monorepo/issues/7559) ([f987580](https://git.legalplace.eu/legalplace/monorepo/commits/f987580e808e1fc04bfb8b58db8c336b1394f618))
18
+ * adding support for browser history pagination and slugs api[#7559](https://git.legalplace.eu/legalplace/monorepo/issues/7559) ([9e471ca](https://git.legalplace.eu/legalplace/monorepo/commits/9e471cadbc08df9507e0b5d9c816dd6d0bd05ed7))
19
+
20
+
21
+ ### BREAKING CHANGES
22
+
23
+ * Pagination handling changed to support slugs, store init and destrying changed too.
24
+
25
+
26
+
27
+
28
+
29
+ ## [2.15.1](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@2.15.0...@legalplace/wizardx-core@2.15.1) (2023-02-07)
30
+
31
+
32
+ ### Bug Fixes
33
+
34
+ * fix review ([271671b](https://git.legalplace.eu/legalplace/monorepo/commits/271671b2ee053097c1ed85e713fb0abf78dd2586)), closes [api#7667](https://git.legalplace.eu/legalplace/monorepo/issues/7667)
35
+
36
+
37
+
38
+
39
+
6
40
  # [2.15.0](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@2.14.1...@legalplace/wizardx-core@2.15.0) (2023-01-18)
7
41
 
8
42
 
package/dist/App.d.ts CHANGED
@@ -3,7 +3,7 @@ import type { ModelV3 } from "@legalplace/models-v3-types";
3
3
  import type { StateType } from "./types/State.type";
4
4
  import type { IWizardParams } from "./types/config.type";
5
5
  export interface AppProps {
6
- historyType: "browser" | "memory";
6
+ historyType?: "browser" | "memory";
7
7
  model?: ModelV3;
8
8
  meta?: StateType.App.Meta;
9
9
  instance?: StateType.App.Instance;
@@ -18,6 +18,7 @@ declare class WizardXCore extends React.Component<AppProps, {
18
18
  }> {
19
19
  constructor(props: AppProps);
20
20
  componentDidMount(): void;
21
+ componentWillUnmount(): void;
21
22
  render(): JSX.Element;
22
23
  }
23
24
  export default WizardXCore;
package/dist/App.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import React from "react";
3
- import { Route, Switch, Redirect, generatePath } from "react-router-dom";
3
+ import { Route, Switch, Redirect } from "react-router-dom";
4
4
  import { Provider } from "react-redux";
5
5
  import { ConnectedRouter } from "connected-react-router";
6
6
  import { getStore, createAppStore } from "./redux/store";
@@ -13,8 +13,7 @@ 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 { PathReader } from "./libs/PathReader";
17
- import { DANGEROUS_DESTROY_STORE } from "./redux/constants/app";
16
+ import { DANGEROUS_DESTROY_STORE } from ".";
18
17
  class WizardXCore extends React.Component {
19
18
  constructor(props) {
20
19
  var _a;
@@ -39,39 +38,18 @@ class WizardXCore extends React.Component {
39
38
  updateConfig(props.wizardParams);
40
39
  if (props.preloadTheme && ((_a = props.wizardParams) === null || _a === void 0 ? void 0 : _a.theme.name))
41
40
  preloadTheme(props.wizardParams.theme.name);
42
- if (!getStore(false)) {
43
- createAppStore(historyType);
44
- }
45
- else {
46
- getStore().dispatch({ type: DANGEROUS_DESTROY_STORE });
47
- }
41
+ createAppStore(historyType);
48
42
  }
49
43
  componentDidMount() {
50
- if (getConfig().permalink) {
51
- const { permalink, prefix, uniqid } = getConfig();
52
- if (uniqid === null || uniqid === void 0 ? void 0 : uniqid.trim().length) {
53
- getHistory().push(generatePath(getConfig().router.wizardInstancePath, {
54
- prefix: (prefix === null || prefix === void 0 ? void 0 : prefix.trim().length) ? prefix : undefined,
55
- permalink,
56
- uniqid,
57
- }));
58
- }
59
- else {
60
- getHistory().push(generatePath(getConfig().router.wizardPath, {
61
- prefix: (prefix === null || prefix === void 0 ? void 0 : prefix.trim().length) ? prefix : undefined,
62
- permalink,
63
- }));
64
- }
65
- }
66
- else if (PathReader.isSmartScriptPath()) {
67
- getHistory().push(window.location.pathname);
68
- }
69
44
  const { dispatch, getState } = getStore();
70
45
  const state = getState();
71
46
  dispatch(fetchModelPrerequisitesAction(getConfig().permalink || state.app.meta.permalink, getConfig().prefix || state.app.meta.prefix || ""));
72
47
  }
48
+ componentWillUnmount() {
49
+ getStore().dispatch({ type: DANGEROUS_DESTROY_STORE });
50
+ }
73
51
  render() {
74
- 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.wizardInstancePath, component: ViewComponent }, void 0), _jsx(Route, { path: getConfig().router.wizardPath, component: ViewComponent }, void 0), _jsx(Route, { path: getConfig().router.smartscriptPath, exact: true, strict: true, component: SmartScriptComponent }, void 0), !window.location.href.includes("smartscript") && (_jsx(Redirect, { to: {
52
+ 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: {
75
53
  pathname: getConfig().router.notFoundPath,
76
54
  } }, void 0))] }, void 0) }), void 0) }), void 0));
77
55
  }
@@ -55,7 +55,7 @@ describe('<View />', () => {
55
55
  currentPage: 1,
56
56
  greatestPage: 1,
57
57
  currentSectionId: 1,
58
- availableSections: [1, 2],
58
+ availableSections: [1],
59
59
  currentAppState: 'wizard',
60
60
  availableAppStates: ['wizard', 'termsheet'],
61
61
  }));
@@ -76,7 +76,7 @@ describe('<View />', () => {
76
76
  yield waitFor(() => expect(container).toContainHTML('<div><h1>Wizard test theme, WizardComponent</h1></div>'));
77
77
  }));
78
78
  it('Loads TermsheetComponent properly', () => __awaiter(void 0, void 0, void 0, function* () {
79
- store.dispatch(goPageAction(3));
79
+ store.dispatch(goPageAction(2));
80
80
  yield loadTheme();
81
81
  const { container } = render(_jsx(Provider, Object.assign({ store: store }, { children: _jsx(View, {}, void 0) }), void 0));
82
82
  yield waitFor(() => expect(container).toContainHTML('<div><h1>Wizard test theme, TermsheetComponent</h1></div>'));
@@ -128,6 +128,8 @@ const references = {
128
128
  raw: 'This content should be parsed with [var:1] value',
129
129
  },
130
130
  },
131
+ optionTags: {},
132
+ variableTags: {}
131
133
  };
132
134
  const conditions = {
133
135
  options: {
@@ -1,3 +1,4 @@
1
+ import { ROLE } from "@legalplace/typeorm-constants";
1
2
  import { parseOptionLabel, parseRawWithVariables, } from "../helpers/outputsParsing";
2
3
  import { componentConnector } from "./connector/componentConnector";
3
4
  import { isStepAvailable } from "../redux/selectors/app";
@@ -9,7 +10,7 @@ export const canOptionDisplay = (id, index, selectors) => {
9
10
  display && !selectors.selectIsSmartscriptOptionIndexHidden(id, index);
10
11
  const grantLevel = typeof option.meta.grantLevel === "string"
11
12
  ? option.meta.grantLevel
12
- : "GUEST";
13
+ : ROLE.GUEST;
13
14
  display = display && selectors.isLevelAccessibleForUser(grantLevel);
14
15
  return display;
15
16
  };
@@ -2,3 +2,4 @@ export * from "./outputsParsing";
2
2
  export * from "./preloadTheme";
3
3
  export * from "./scriptsLoader";
4
4
  export * from "./propsEqualityCheck";
5
+ export * from "./date.helper";
@@ -2,3 +2,4 @@ export * from "./outputsParsing";
2
2
  export * from "./preloadTheme";
3
3
  export * from "./scriptsLoader";
4
4
  export * from "./propsEqualityCheck";
5
+ export * from "./date.helper";
@@ -16,7 +16,7 @@ export declare class PathReader {
16
16
  getPageNumber(page: string): number;
17
17
  getSectionId(page?: number): number;
18
18
  getPagination(): {
19
- pages: (string | number)[];
19
+ pages: (string | number)[][];
20
20
  appStates: string[];
21
21
  };
22
22
  getAppStatesPages(): {
@@ -3,7 +3,8 @@ import queryString from "query-string";
3
3
  import { matchPath, generatePath } from "react-router";
4
4
  import { getConfig } from "../config";
5
5
  import { getPluginsPageAppStates } from "../PluginLoader";
6
- import { selectAvailableSections, selectAvailableAppStates, selectInstanceUniqid, } from "../redux/selectors/app";
6
+ import { selectAvailableSections, selectAvailableAppStates, selectInstanceUniqid, selectMetaFetchStatus, } from "../redux/selectors/app";
7
+ import { selectSectionReference } from "../redux/selectors/references";
7
8
  import Globals from "../Globals";
8
9
  export class PathReader {
9
10
  constructor(state) {
@@ -62,15 +63,15 @@ export class PathReader {
62
63
  getPageUrlName(page) {
63
64
  const pagesArray = this.getPagination().pages;
64
65
  if (page > pagesArray.length)
65
- return `${pagesArray[pagesArray.length - 1]}`;
66
- return `${pagesArray[page - 1]}`;
66
+ return `${pagesArray[pagesArray.length - 1][0]}`;
67
+ return `${pagesArray[page - 1][0]}`;
67
68
  }
68
69
  getPageNumber(page) {
69
70
  const { pages } = this.getPagination();
70
71
  const parsedPage = Number.isNaN(parseInt(page, 10))
71
72
  ? page
72
73
  : parseInt(page, 10);
73
- return pages.indexOf(parsedPage) + 1 || 1;
74
+ return (pages.findIndex((currentPageNames) => currentPageNames.includes(parsedPage)) + 1 || 1);
74
75
  }
75
76
  getSectionId(page = this.currentPage) {
76
77
  const availableSections = selectAvailableSections();
@@ -87,16 +88,23 @@ export class PathReader {
87
88
  let appStates = [];
88
89
  availableAppStates.forEach((currentAppState) => {
89
90
  if (currentAppState === "wizard")
90
- selectAvailableSections().forEach(() => {
91
- pages = [...pages, pages.length + 1];
91
+ selectAvailableSections().forEach((id) => {
92
+ let currentSectionPageNames = [pages.length + 1];
93
+ if (selectMetaFetchStatus() === "succeeded") {
94
+ const { slug } = selectSectionReference(id);
95
+ if (slug && slug.trim().length > 0) {
96
+ currentSectionPageNames = [slug, ...currentSectionPageNames];
97
+ }
98
+ }
99
+ pages = [...pages, currentSectionPageNames];
92
100
  appStates = [...appStates, "wizard"];
93
101
  });
94
102
  else if (Object.prototype.hasOwnProperty.call(this.getAppStatesPages(), currentAppState)) {
95
- pages = [...pages, this.getAppStatesPages()[currentAppState]];
103
+ pages = [...pages, [this.getAppStatesPages()[currentAppState]]];
96
104
  appStates = [...appStates, currentAppState];
97
105
  }
98
106
  else {
99
- pages = [...pages, pages.length + 1];
107
+ pages = [...pages, [pages.length + 1]];
100
108
  appStates = [...appStates, currentAppState];
101
109
  }
102
110
  });
@@ -34,6 +34,8 @@ describe('References actions test suit', () => {
34
34
  outputs: {},
35
35
  evaluations: {},
36
36
  boxes: {},
37
+ optionTags: {},
38
+ variableTags: {}
37
39
  };
38
40
  const action = initReferencesAction(_obj);
39
41
  expect(action).toEqual(Object.assign({ type: 'INIT_REFERENCES' }, _obj));
@@ -23,10 +23,20 @@ const initialState = {
23
23
  sections: {},
24
24
  documents: {},
25
25
  },
26
- documents: {},
27
- sections: {},
26
+ documents: {
27
+ main: {
28
+ name: "",
29
+ },
30
+ },
31
+ sections: {
32
+ main: {
33
+ 1: { id: 1, label: "", options: [] },
34
+ },
35
+ },
28
36
  defaults: {},
29
37
  evaluations: {},
38
+ optionTags: {},
39
+ variableTags: {},
30
40
  };
31
41
  const reducersEnum = {
32
42
  [INIT_REFERENCES]: initReferencesReducer,
@@ -1,10 +1,10 @@
1
1
  import * as inputs from "./inputs";
2
2
  export declare const selectorsLibrary: {
3
- selectCurrentUserLevel: () => Readonly<"ADMIN" | "MANAGER" | "USER" | "GUEST" | "SUPER" | "OPS" | undefined>;
3
+ selectCurrentUserLevel: () => Readonly<"SUPER" | "ADMIN" | "OPS" | "MANAGER" | "USER" | "GUEST" | undefined>;
4
4
  selectUserStatus: () => Readonly<"failed" | "authenticated" | "unauthenticated" | "inprogress">;
5
5
  selectUserValidToken: () => Readonly<boolean>;
6
6
  selectUserEmail: () => string;
7
- isLevelAccessibleForUser: (level: "ADMIN" | "MANAGER" | "USER" | "GUEST" | "SUPER" | "OPS") => Readonly<boolean>;
7
+ isLevelAccessibleForUser: (level: "SUPER" | "ADMIN" | "OPS" | "MANAGER" | "USER" | "GUEST") => Readonly<boolean>;
8
8
  selectIsSmartscriptOptionIndexHidden: (id: number, index: number) => Readonly<boolean>;
9
9
  selectIsSmartscriptVariableIndexHidden: (id: number, index: number) => Readonly<boolean>;
10
10
  selectReferences: () => Readonly<import("@legalplace/referencesparser/dist/libs/References.type").ReferencesType>;
@@ -28,6 +28,8 @@ const initialState = {
28
28
  outputs: {},
29
29
  evaluations: {},
30
30
  boxes: {},
31
+ optionTags: {},
32
+ variableTags: {}
31
33
  };
32
34
  describe('Inputs selectors test suit', () => {
33
35
  it('isOptionMultiple returns undefined when references are not set', () => {
@@ -1,5 +1,5 @@
1
- export declare const selectCurrentUserLevel: () => Readonly<"ADMIN" | "MANAGER" | "USER" | "GUEST" | "SUPER" | "OPS" | undefined>;
1
+ export declare const selectCurrentUserLevel: () => Readonly<"SUPER" | "ADMIN" | "OPS" | "MANAGER" | "USER" | "GUEST" | undefined>;
2
2
  export declare const selectUserStatus: () => Readonly<"failed" | "authenticated" | "unauthenticated" | "inprogress">;
3
3
  export declare const selectUserValidToken: () => Readonly<boolean>;
4
4
  export declare const selectUserEmail: () => string;
5
- export declare const isLevelAccessibleForUser: (level: "ADMIN" | "MANAGER" | "USER" | "GUEST" | "SUPER" | "OPS") => Readonly<boolean>;
5
+ export declare const isLevelAccessibleForUser: (level: "SUPER" | "ADMIN" | "OPS" | "MANAGER" | "USER" | "GUEST") => Readonly<boolean>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legalplace/wizardx-core",
3
- "version": "2.15.0",
3
+ "version": "3.0.0",
4
4
  "author": "Moncef Hammou (moncef@legalplace.fr)",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -24,8 +24,9 @@
24
24
  "@legalplace/lp-events": "1.13.0",
25
25
  "@legalplace/lplogic": "^2.1.6",
26
26
  "@legalplace/model-healthcheck": "^1.1.5",
27
- "@legalplace/referencesparser": "1.7.0",
28
- "@legalplace/storybook": "2.15.2",
27
+ "@legalplace/referencesparser": "^2.3.12",
28
+ "@legalplace/storybook": "^2.171.0",
29
+ "@legalplace/typeorm-constants": "^2.43.0",
29
30
  "@loadable/component": "^5.15.0",
30
31
  "@redux-saga/core": "^1.1.3",
31
32
  "connected-react-router": "^6.8.0",
@@ -53,9 +54,9 @@
53
54
  },
54
55
  "devDependencies": {
55
56
  "@legalplace/eslint-config": "^2.2.0",
56
- "@legalplace/models-v3-types": "^3.6.0",
57
+ "@legalplace/models-v3-types": "^4.0.0",
57
58
  "@legalplace/prettier-config": "^2.1.3",
58
- "@legalplace/typeorm-entities": "3.8.2",
59
+ "@legalplace/typeorm-entities": "^4.6.0",
59
60
  "@swc-node/jest": "^1.3.2",
60
61
  "@swc/core": "^1.2.93",
61
62
  "@swc/jest": "^0.2.4",
@@ -93,5 +94,5 @@
93
94
  "*.test.ts",
94
95
  "*.test.tsx"
95
96
  ],
96
- "gitHead": "4047f4cc45c4f443a146859bbaf5003af601d161"
97
+ "gitHead": "b1dc121743e12b48abd21b580ff8aab4543d74c7"
97
98
  }