@griddo/ax 12.15.1-astro-rc.0 → 12.17.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/README.md +1 -0
- package/config/__tests__/getCSSModuleLocalIdent.test.js +30 -0
- package/config/griddo-config/index.js +3 -2
- package/config/webpack/getCSSModuleLocalIdent.js +10 -0
- package/config/webpack.config.js +1 -1
- package/package.json +8 -6
- package/public/img/logos/logoGriddoDxp.svg +22 -0
- package/public/img/logos/logoGriddoG.svg +10 -0
- package/src/GlobalStore.tsx +32 -25
- package/src/__tests__/GlobalStore.session.test.tsx +98 -0
- package/src/__tests__/api/global.test.ts +64 -0
- package/src/__tests__/api/session.test.ts +311 -0
- package/src/__tests__/api/sessionRenewal.test.ts +705 -0
- package/src/__tests__/api/utils.test.ts +373 -0
- package/src/__tests__/components/Fields/FileField/FileField.test.tsx +33 -6
- package/src/__tests__/components/Fields/TranslateButton/TranslateButton.test.tsx +121 -4
- package/src/__tests__/components/FieldsBehavior/FieldsBehavior.test.tsx +5 -3
- package/src/__tests__/components/Login/BrandPalette.test.tsx +145 -0
- package/src/__tests__/components/Login/Login.test.tsx +2 -33
- package/src/__tests__/components/Login/LoginCollapsible.test.tsx +271 -0
- package/src/__tests__/components/Login/LoginDropdownCard.test.tsx +311 -0
- package/src/__tests__/components/Login/LoginFooter.test.tsx +128 -0
- package/src/__tests__/components/Login/LoginGriddoId.test.tsx +213 -0
- package/src/__tests__/components/Login/LoginInlineError.test.tsx +116 -0
- package/src/__tests__/components/Login/RecoveryModal/RecoveryModal.test.tsx +3 -4
- package/src/__tests__/components/SsoDenied/SsoDenied.test.tsx +86 -0
- package/src/__tests__/config/webpackAliases.test.ts +18 -0
- package/src/__tests__/containers/App/reducer.griddoId.test.ts +18 -0
- package/src/__tests__/containers/App/session.test.ts +397 -0
- package/src/__tests__/containers/App/signInOut.test.ts +159 -0
- package/src/__tests__/helpers/griddoId.test.ts +56 -0
- package/src/__tests__/hooks/useShouldBeSaved.test.tsx +78 -0
- package/src/__tests__/locales/loginLocale.test.ts +37 -0
- package/src/__tests__/modules/App/Routing/NavMenu.test.tsx +54 -0
- package/src/__tests__/modules/App/Routing/PrivateRoute.test.tsx +64 -0
- package/src/__tests__/modules/App/Routing/Routing.startup.test.tsx +79 -0
- package/src/__tests__/modules/Login/Login.test.tsx +169 -0
- package/src/__tests__/modules/Login/loginError.uc.test.tsx +294 -0
- package/src/__tests__/modules/Login/signInOut.test.tsx +125 -0
- package/src/__tests__/modules/Redirects/RedirectPanel/RedirectPanel.test.tsx +9 -0
- package/src/__tests__/modules/Redirects/Redirects/Redirects.create.test.tsx +19 -0
- package/src/__tests__/modules/Redirects/Redirects/Redirects.edit.test.tsx +19 -0
- package/src/__tests__/modules/Redirects/Redirects/Redirects.filter.test.tsx +19 -0
- package/src/__tests__/modules/SsoDenied/SsoDenied.test.tsx +30 -0
- package/src/__tests__/routes/publicRoutes.test.ts +36 -0
- package/src/api/global.tsx +24 -1
- package/src/api/session.tsx +197 -0
- package/src/api/sessionRenewal.tsx +114 -0
- package/src/api/utils.tsx +22 -12
- package/src/{helpers/categoryColumns.tsx → components/CategoryCell/buildCategoryColumns.tsx} +3 -2
- package/src/components/Circle/index.tsx +1 -1
- package/src/components/Circle/style.tsx +4 -2
- package/src/components/ErrorPage/index.tsx +1 -1
- package/src/components/ErrorPage/style.tsx +11 -9
- package/src/components/ErrorToast/index.tsx +2 -0
- package/src/components/Fields/TranslateButton/index.tsx +4 -9
- package/src/{helpers/fields.tsx → components/FieldsBehavior/getFieldByPath.tsx} +1 -1
- package/src/components/FieldsBehavior/index.tsx +3 -1
- package/src/components/Login/LoginFooter/index.tsx +16 -0
- package/src/components/Login/LoginFooter/style.tsx +17 -0
- package/src/components/Login/LoginForm/index.tsx +147 -79
- package/src/components/Login/LoginForm/style.tsx +147 -24
- package/src/components/Login/LoginGriddoId/index.tsx +56 -0
- package/src/components/Login/LoginGriddoId/style.tsx +35 -0
- package/src/components/Login/LoginSSO/index.tsx +4 -7
- package/src/components/Login/LoginSSO/style.tsx +10 -26
- package/src/components/Login/LoginSlider/style.tsx +5 -5
- package/src/components/Login/index.tsx +35 -6
- package/src/components/Login/style.tsx +40 -24
- package/src/components/Notification/index.tsx +3 -1
- package/src/components/SsoDenied/index.tsx +46 -0
- package/src/components/SsoDenied/style.tsx +37 -0
- package/src/components/index.tsx +11 -7
- package/src/containers/App/actions.tsx +114 -6
- package/src/containers/App/interfaces.tsx +2 -2
- package/src/containers/App/reducer.tsx +9 -0
- package/src/containers/Users/actions.tsx +28 -24
- package/src/helpers/griddoId.ts +28 -0
- package/src/helpers/index.tsx +4 -5
- package/src/hooks/forms.tsx +8 -5
- package/src/locales/en-US.ts +13 -0
- package/src/locales/es-ES.ts +13 -0
- package/src/locales/index.ts +9 -1
- package/src/modules/App/Routing/NavMenu/index.tsx +4 -4
- package/src/modules/Content/PageItem/index.tsx +6 -8
- package/src/modules/Login/index.tsx +33 -14
- package/src/modules/SsoDenied/index.tsx +9 -0
- package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/index.tsx +6 -8
- package/src/modules/StructuredData/StructuredDataList/StructuredDataItem/index.tsx +9 -11
- package/src/modules/Users/UserEdit/index.tsx +9 -2
- package/src/routes/publicRoutes.tsx +3 -0
- package/src/themes/brandPalette.ts +16 -0
- package/public/img/logos/logoSQY.svg +0 -3
package/README.md
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The class names of client CSS modules must never need escaping in a selector.
|
|
3
|
+
* css-loader escapes them, and postcss-selector-parser >= 7.2.0 escapes them again
|
|
4
|
+
* (`.x__u\+nIs` lands in the CSS as `.x__u\\\+nIs`), so the rule stops matching
|
|
5
|
+
* the class the JS puts in the HTML.
|
|
6
|
+
*/
|
|
7
|
+
const getCSSModuleLocalIdent = require("../webpack/getCSSModuleLocalIdent");
|
|
8
|
+
|
|
9
|
+
// css-loader passes the loader context and `{ context: rootContext, ... }`.
|
|
10
|
+
const localIdent = (file, localName) =>
|
|
11
|
+
getCSSModuleLocalIdent({ rootContext: "/project", resourcePath: `/project/${file}` }, "", localName, {
|
|
12
|
+
context: "/project",
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
describe("getCSSModuleLocalIdent", () => {
|
|
16
|
+
test.each([
|
|
17
|
+
// react-dev-utils hashes in standard base64: `tgnq+` and `dX/xb`
|
|
18
|
+
["src/Search/styles.module.css", "header"],
|
|
19
|
+
["src/Search/styles.module.css", "content"],
|
|
20
|
+
// characters css-loader escapes can also come from the folder or the class
|
|
21
|
+
["src/Search (copy)/index.module.css", "menu"],
|
|
22
|
+
["src/Search/styles.module.scss", "a+b"],
|
|
23
|
+
])("%s .%s only uses [A-Za-z0-9_-]", (file, localName) => {
|
|
24
|
+
expect(localIdent(file, localName)).toMatch(/^[A-Za-z0-9_-]+$/);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test("keeps the react-dev-utils name when it has nothing to escape", () => {
|
|
28
|
+
expect(localIdent("src/Search/styles.module.css", "container")).toBe("styles_container__1dPva");
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -54,7 +54,7 @@ const getComponentsLibAliases = () => {
|
|
|
54
54
|
return Object.keys(xsConfig?.compilerOptions?.paths).reduce(
|
|
55
55
|
(currentAlias, pathKey) => {
|
|
56
56
|
const [aliasKey] = pathKey.split("/");
|
|
57
|
-
const [pathAtJsConfig] = xsConfig
|
|
57
|
+
const [pathAtJsConfig] = xsConfig.compilerOptions.paths[pathKey];
|
|
58
58
|
|
|
59
59
|
const [relativePathToDir] = pathAtJsConfig.split("/*");
|
|
60
60
|
|
|
@@ -88,6 +88,7 @@ const griddoAxAliases = {
|
|
|
88
88
|
"@ax/types": path.resolve(__dirname, "../../src/types"),
|
|
89
89
|
"@ax/schemas": path.resolve(__dirname, "../../src/schemas"),
|
|
90
90
|
"@ax/locales": path.resolve(__dirname, "../../src/locales"),
|
|
91
|
+
"@ax/themes": path.resolve(__dirname, "../../src/themes"),
|
|
91
92
|
"@ax/constants": path.resolve(__dirname, "../../src/constants"),
|
|
92
93
|
};
|
|
93
94
|
|
|
@@ -99,7 +100,7 @@ const thereAreAliasConflicts = () =>
|
|
|
99
100
|
isComponentLibraryEnv && findCommonElements(Object.keys(griddoAxAliases), Object.keys(getComponentsLibAliases()));
|
|
100
101
|
|
|
101
102
|
const mergeComponentsAliases = (...arrs) => {
|
|
102
|
-
const keys = arrs.
|
|
103
|
+
const keys = arrs.flatMap((arr) => Object.keys(arr));
|
|
103
104
|
|
|
104
105
|
const merged = {};
|
|
105
106
|
keys.map((key) => (merged[key] = [arrs.map((a) => a[key]).filter((a) => a !== undefined)].flat()));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const getCRALocalIdent = require("react-dev-utils/getCSSModuleLocalIdent");
|
|
2
|
+
|
|
3
|
+
// Class names for client CSS modules, made only of characters that never need escaping.
|
|
4
|
+
//
|
|
5
|
+
// react-dev-utils names them `[name]_[local]__[hash]` with a standard base64 hash, so about
|
|
6
|
+
// one class in thirteen gets a `+`. css-loader escapes it (`.x__u\+nIs`) and, from 7.2.0 on,
|
|
7
|
+
// postcss-selector-parser escapes it again (`.x__u\\\+nIs`): the CSS rule stops matching the
|
|
8
|
+
// class the JS puts in the HTML (postcss/postcss-selector-parser#362). With nothing to escape,
|
|
9
|
+
// the selector comes out the same whatever version the client project installs.
|
|
10
|
+
module.exports = (...args) => getCRALocalIdent(...args).replace(/[^A-Za-z0-9_-]/g, "_");
|
package/config/webpack.config.js
CHANGED
|
@@ -10,7 +10,7 @@ const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|
|
10
10
|
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
|
|
11
11
|
const { WebpackManifestPlugin } = require("webpack-manifest-plugin");
|
|
12
12
|
const InterpolateHtmlPlugin = require("react-dev-utils/InterpolateHtmlPlugin");
|
|
13
|
-
const getCSSModuleLocalIdent = require("
|
|
13
|
+
const getCSSModuleLocalIdent = require("./webpack/getCSSModuleLocalIdent");
|
|
14
14
|
const paths = require("./paths");
|
|
15
15
|
const modules = require("./modules");
|
|
16
16
|
const getClientEnvironment = require("./env");
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@griddo/ax",
|
|
3
3
|
"description": "Griddo Author Experience",
|
|
4
|
-
"version": "12.
|
|
4
|
+
"version": "12.17.0",
|
|
5
5
|
"homepage": "https://griddo.io",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"test:ci": "vitest run --no-file-parallelism",
|
|
23
23
|
"test:coverage": "vitest run --coverage",
|
|
24
24
|
"typecheck": "tsc --noEmit",
|
|
25
|
+
"mutation": "stryker run",
|
|
25
26
|
"lint": "biome check",
|
|
26
27
|
"format:write": "biome format --write"
|
|
27
28
|
},
|
|
@@ -127,7 +128,9 @@
|
|
|
127
128
|
},
|
|
128
129
|
"devDependencies": {
|
|
129
130
|
"@biomejs/biome": "2.5.15",
|
|
130
|
-
"@griddo/core": "12.
|
|
131
|
+
"@griddo/core": "12.17.0",
|
|
132
|
+
"@stryker-mutator/core": "^10.0.0",
|
|
133
|
+
"@stryker-mutator/vitest-runner": "^10.0.0",
|
|
131
134
|
"@types/redux-mock-store": "1.5.0",
|
|
132
135
|
"@vitest/coverage-v8": "4.1.11",
|
|
133
136
|
"axios-mock-adapter": "1.22.0",
|
|
@@ -138,7 +141,7 @@
|
|
|
138
141
|
"vitest-styled-components": "1.0.0"
|
|
139
142
|
},
|
|
140
143
|
"peerDependencies": {
|
|
141
|
-
"@griddo/core": "12.
|
|
144
|
+
"@griddo/core": "12.17.0"
|
|
142
145
|
},
|
|
143
146
|
"babel": {
|
|
144
147
|
"presets": [
|
|
@@ -169,8 +172,7 @@
|
|
|
169
172
|
"tsconfig.paths.json"
|
|
170
173
|
],
|
|
171
174
|
"publishConfig": {
|
|
172
|
-
"access": "public"
|
|
173
|
-
"tag": "astro"
|
|
175
|
+
"access": "public"
|
|
174
176
|
},
|
|
175
|
-
"gitHead": "
|
|
177
|
+
"gitHead": "1e18f44b4350e247602f567aea2d1f422b4bfb5b"
|
|
176
178
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<svg width="152.05" height="36" viewBox="0 0 152.05 36" fill="none" xmlns="http://www.w3.org/2000/svg" role="img">
|
|
2
|
+
<title>griddo dxp</title>
|
|
3
|
+
<g>
|
|
4
|
+
<g>
|
|
5
|
+
<path d="M29.8831 10.8372L26.8687 13.8612C26.439 13.4302 25.7937 13.299 25.2231 13.5341C24.6508 13.7675 24.2856 14.3212 24.2856 14.9294V24.7172H20.0196V9.15052H24.2856V9.36178C24.7832 9.2306 25.2876 9.15052 25.8022 9.15052C27.3374 9.15052 28.8064 9.75874 29.8831 10.8372Z" fill="white"/>
|
|
6
|
+
<path d="M36.2577 9.1795H31.9815V24.6984H36.2577V9.1795Z" fill="white"/>
|
|
7
|
+
<path d="M36.2953 0.066581H32.0191V4.58136H36.2953V0.066581Z" fill="white"/>
|
|
8
|
+
<path d="M50.0319 2.00422e-06L50.0234 10.0024C48.9467 9.45039 47.7494 9.16076 46.5317 9.16927C43.322 9.16927 40.4401 11.1456 39.2802 14.1424C38.1186 17.1391 38.9337 20.5397 41.3096 22.7034C43.6872 24.8569 47.1482 25.3254 50.0217 23.8841C50.0217 23.8841 50.0268 23.8841 50.0302 23.8824V24.7069H54.2979V2.00422e-06H50.0302H50.0319ZM50.0234 16.9432C50.0234 18.8718 48.4593 20.446 46.5232 20.446C44.5872 20.446 43.0231 18.882 43.0231 16.9432C43.0231 15.0044 44.5855 13.4404 46.5232 13.4404C48.461 13.4404 50.0234 15.0044 50.0234 16.9432Z" fill="white"/>
|
|
9
|
+
<path d="M68.0276 23.8789V24.7069H72.2954V2.00422e-06H68.0276V10.0041L68.0123 9.99897C66.9374 9.44868 65.7435 9.16076 64.5275 9.16927C61.3178 9.16927 58.4359 11.1456 57.276 14.1424C56.1144 17.1391 56.9295 20.5397 59.3054 22.7034C61.6829 24.8569 65.1457 25.3254 68.0191 23.8841L68.0276 23.8789ZM64.519 20.446C62.5813 20.446 61.0189 18.882 61.0189 16.9432C61.0189 15.0044 62.5813 13.4404 64.519 13.4404C66.4567 13.4404 68.0191 15.0044 68.0191 16.9432C68.0191 18.882 66.455 20.446 64.519 20.446Z" fill="white"/>
|
|
10
|
+
<path d="M82.5351 9.16088C79.3899 9.16088 76.564 11.052 75.3566 13.9568C74.1593 16.8599 74.8233 20.2042 77.0412 22.4241C79.2592 24.644 82.6013 25.3085 85.5019 24.1108C88.4026 22.9114 90.2944 20.0747 90.2944 16.9263C90.2944 12.6364 86.8232 9.16259 82.5368 9.16259L82.5351 9.16088ZM82.5351 20.4274C81.1221 20.4274 79.84 19.5756 79.3067 18.2637C78.7633 16.9519 79.0638 15.4543 80.0641 14.4525C81.0661 13.4508 82.5725 13.1509 83.8733 13.6944C85.1844 14.2379 86.0352 15.5105 86.0352 16.9263C86.025 18.8651 84.4626 20.4291 82.5351 20.4291V20.4274Z" fill="white"/>
|
|
11
|
+
<path d="M17.5224 13.4047V9.16252H15.4081C14.3093 9.16252 13.2479 9.60037 12.4667 10.3858C12.3971 10.4573 12.3343 10.5272 12.2731 10.597L12.2544 10.6158L12.2239 10.5919C10.9213 9.6651 9.35042 9.16252 7.74217 9.17103C4.7855 9.17103 2.09037 10.856 0.786106 13.5223C-0.502871 16.1715 -0.188694 19.3182 1.59618 21.6506C1.60976 21.6727 1.62505 21.6932 1.64373 21.717C1.63524 21.7221 1.62165 21.7358 1.62165 21.7358L1.55542 21.7954C0.0983118 23.1618 -0.38739 25.2777 0.329275 27.162L0.346257 27.2063C1.0833 29.0872 2.89534 30.3292 4.91967 30.3292H10.5664C10.9502 30.3292 11.2559 30.6376 11.2559 31.0209C11.2559 31.4042 10.9502 31.7126 10.5664 31.7126H5.62954V35.9548H10.5664C13.287 35.9548 15.4845 33.7502 15.4845 31.0209C15.4845 28.2916 13.287 26.087 10.5664 26.087H4.91967C4.53756 26.087 4.23187 25.7803 4.23187 25.3953C4.23187 25.0103 4.53756 24.7053 4.91967 24.7053H6.94229C7.02381 24.7053 7.10532 24.7087 7.18854 24.7087L7.74217 24.6951C11.1115 24.6951 14.0852 22.5143 15.1109 19.2944C15.4149 18.3403 15.5253 17.3999 15.4845 16.4322C15.4828 16.3589 15.4794 16.284 15.4743 16.2107L15.4845 13.4047H17.5224ZM7.74217 20.4597L7.44328 20.4427L7.26156 20.4188C5.55312 20.1837 4.23187 18.7134 4.23187 16.9279C4.23187 14.9789 5.79936 13.4047 7.74217 13.4047C9.52364 13.4047 10.9892 14.7234 11.2236 16.4441L11.2338 16.5565L11.2559 16.9382C11.2559 18.8787 9.68837 20.4597 7.74217 20.4597Z" fill="white"/>
|
|
12
|
+
</g>
|
|
13
|
+
</g>
|
|
14
|
+
<g transform="translate(100.9 0)">
|
|
15
|
+
<g>
|
|
16
|
+
<path d="M21.8715 9.1401L18.3563 9.1403L18.3561 12.0899L29.0315 24.8124L32.5013 24.8128L32.547 21.8626L21.8715 9.1401Z" fill="white"/>
|
|
17
|
+
<path d="M32.5472 12.0898L32.5471 9.14013L29.0318 9.14L18.3564 21.8625L18.3564 24.8123L21.8718 24.8123L32.5472 12.0898Z" fill="white"/>
|
|
18
|
+
<path d="M40.0174 33.8508L40.0259 23.8484C41.1026 24.4004 42.2998 24.69 43.5175 24.6815C46.7272 24.6815 49.6091 22.7052 50.7691 19.7084C51.9307 16.7116 51.1155 13.3111 48.7396 11.1474C46.3621 8.99391 42.901 8.52539 40.0276 9.96671C40.0276 9.96671 40.0225 9.96672 40.0191 9.96842V9.14383H35.7514V33.8508H40.0191H40.0174ZM40.0259 16.9076C40.0259 14.979 41.59 13.4048 43.526 13.4048C45.462 13.4048 47.0261 14.9688 47.0261 16.9076C47.0261 18.8464 45.4637 20.4103 43.526 20.4103C41.5883 20.4103 40.0259 18.8464 40.0259 16.9076Z" fill="white"/>
|
|
19
|
+
<path d="M11.2747 23.8789V24.7069H15.5424V0H11.2747V10.0041L11.2594 9.99897C10.1844 9.44868 8.99053 9.16075 7.77458 9.16927C4.56487 9.16927 1.68293 11.1456 0.523022 14.1423C-0.638586 17.1391 0.176574 20.5397 2.55244 22.7034C4.93 24.8569 8.39275 25.3254 11.2662 23.8841L11.2747 23.8789ZM7.76609 20.446C5.82838 20.446 4.26598 18.882 4.26598 16.9432C4.26598 15.0044 5.82838 13.4404 7.76609 13.4404C9.7038 13.4404 11.2662 15.0044 11.2662 16.9432C11.2662 18.882 9.7021 20.446 7.76609 20.446Z" fill="white"/>
|
|
20
|
+
</g>
|
|
21
|
+
</g>
|
|
22
|
+
</svg>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<svg preserveAspectRatio="none" overflow="visible" style="display: block;" width="16" height="24" viewBox="0 0 16 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<title>Griddo</title>
|
|
3
|
+
<path id="Vector" d="M16 3.80007V0H14.0694C13.0661 0 12.0969 0.392216 11.3836 1.09576C11.32 1.15986 11.2626 1.22243 11.2068 1.285L11.1897 1.30179L11.1618 1.28042C9.97241 0.450203 8.53801 -1.86278e-06 7.06949 0.00762881C4.36972 0.00762881 1.90875 1.51697 0.717805 3.90538C-0.459179 6.27852 -0.172299 9.09729 1.45749 11.1866C1.4699 11.2064 1.48385 11.2247 1.50091 11.2461C1.49316 11.2507 1.48075 11.2629 1.48075 11.2629L1.42027 11.3163C0.08977 12.5403 -0.353731 14.4357 0.300666 16.1236L0.316173 16.1633C0.989179 17.8482 2.64378 18.9607 4.49222 18.9607H9.64831C9.99877 18.9607 10.2779 19.2369 10.2779 19.5803C10.2779 19.9237 9.99877 20.1999 9.64831 20.1999H5.14042V24H9.64831C12.1325 24 14.1392 22.0252 14.1392 19.5803C14.1392 17.1354 12.1325 15.1606 9.64831 15.1606H4.49222C4.14331 15.1606 3.86419 14.8859 3.86419 14.541C3.86419 14.1961 4.14331 13.9229 4.49222 13.9229H6.33911C6.41354 13.9229 6.48798 13.926 6.56396 13.926L7.06949 13.9138C10.1461 13.9138 12.8614 11.9603 13.798 9.07592C14.0756 8.22129 14.1764 7.37886 14.1392 6.51202C14.1376 6.44639 14.1345 6.37925 14.1299 6.31362L14.1392 3.80007H16ZM7.06949 10.1198L6.79657 10.1045L6.63064 10.0832C5.07063 9.87256 3.86419 8.55551 3.86419 6.95612C3.86419 5.21022 5.29549 3.80007 7.06949 3.80007C8.69618 3.80007 10.0344 4.98131 10.2484 6.5227L10.2577 6.62342L10.2779 6.96528C10.2779 8.70354 8.8466 10.1198 7.06949 10.1198Z" fill="url(#paint0_linear_0_5)"/>
|
|
4
|
+
<defs>
|
|
5
|
+
<linearGradient id="paint0_linear_0_5" x1="16" y1="0" x2="3.8597e-07" y2="24" gradientUnits="userSpaceOnUse">
|
|
6
|
+
<stop stop-color="#FAF9F6"/>
|
|
7
|
+
<stop offset="1" stop-color="white"/>
|
|
8
|
+
</linearGradient>
|
|
9
|
+
</defs>
|
|
10
|
+
</svg>
|
package/src/GlobalStore.tsx
CHANGED
|
@@ -1,32 +1,34 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { IRootState } from "@ax/types";
|
|
2
|
+
|
|
2
3
|
import { connectRouter, routerMiddleware } from "connected-react-router";
|
|
3
|
-
import {
|
|
4
|
-
import storage from "redux-persist/lib/storage"; // defaults to localStorage for web
|
|
5
|
-
import { setStore } from "./storeRegistry";
|
|
4
|
+
import { type Action, applyMiddleware, combineReducers, createStore, type Reducer, type StoreEnhancer } from "redux";
|
|
6
5
|
import { composeWithDevTools } from "redux-devtools-extension";
|
|
6
|
+
import { type PersistConfig, type Persistor, persistReducer, persistStore } from "redux-persist";
|
|
7
|
+
import storage from "redux-persist/lib/storage"; // defaults to localStorage for web
|
|
7
8
|
import thunk from "redux-thunk";
|
|
8
9
|
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { navigationReducer, navigationInitialState } from "./containers/Navigation/Defaults/reducer";
|
|
14
|
-
import { structuredDataReducer, structuredDataInitialState } from "./containers/StructuredData/reducer";
|
|
15
|
-
import { languagesReducer, languagesInitialState } from "./containers/Settings/Languages/reducer";
|
|
16
|
-
import { dataPacksReducer, dataPacksInitialState } from "./containers/Settings/DataPacks/reducer";
|
|
17
|
-
import { socialReducer, socialInitialState } from "./containers/Settings/Social/reducer";
|
|
18
|
-
import { usersReducer, usersInitialState } from "./containers/Users/reducer";
|
|
19
|
-
import { galleryReducer, galleryInitialState } from "./containers/Gallery/reducer";
|
|
20
|
-
import { domainsReducer, domainsInitialState } from "./containers/Domains/reducer";
|
|
21
|
-
import { redirectsReducer, redirectsInitialState } from "./containers/Redirects/reducer";
|
|
22
|
-
import { analyticsReducer, analyticsInitialState } from "./containers/Analytics/reducer";
|
|
23
|
-
import { integrationsReducer, integrationsInitialState } from "./containers/Integrations/reducer";
|
|
24
|
-
import { fileDriveReducer, fileDriveInitialState } from "./containers/FileDrive/reducer";
|
|
25
|
-
import { formsReducer, formsInitialState } from "./containers/Forms/reducer";
|
|
26
|
-
import { activityLogReducer, activityLogInitialState } from "./containers/ActivityLog/reducer";
|
|
10
|
+
import { createSessionStorage, registerSessionBridge } from "./api/session";
|
|
11
|
+
import { activityLogInitialState, activityLogReducer } from "./containers/ActivityLog/reducer";
|
|
12
|
+
import { analyticsInitialState, analyticsReducer } from "./containers/Analytics/reducer";
|
|
13
|
+
import { logoutAndNavigate, setSessionTokens } from "./containers/App/actions";
|
|
27
14
|
import { LOGOUT } from "./containers/App/constants";
|
|
28
|
-
|
|
29
|
-
import
|
|
15
|
+
import { appInitialState, appReducer } from "./containers/App/reducer";
|
|
16
|
+
import { domainsInitialState, domainsReducer } from "./containers/Domains/reducer";
|
|
17
|
+
import { fileDriveInitialState, fileDriveReducer } from "./containers/FileDrive/reducer";
|
|
18
|
+
import { formsInitialState, formsReducer } from "./containers/Forms/reducer";
|
|
19
|
+
import { galleryInitialState, galleryReducer } from "./containers/Gallery/reducer";
|
|
20
|
+
import { integrationsInitialState, integrationsReducer } from "./containers/Integrations/reducer";
|
|
21
|
+
import { navigationInitialState, navigationReducer } from "./containers/Navigation/Defaults/reducer";
|
|
22
|
+
import { menuInitialState, menuReducer } from "./containers/Navigation/Menu/reducer";
|
|
23
|
+
import { pageEditorInitialState, pageEditorReducer } from "./containers/PageEditor/reducer";
|
|
24
|
+
import { redirectsInitialState, redirectsReducer } from "./containers/Redirects/reducer";
|
|
25
|
+
import { dataPacksInitialState, dataPacksReducer } from "./containers/Settings/DataPacks/reducer";
|
|
26
|
+
import { languagesInitialState, languagesReducer } from "./containers/Settings/Languages/reducer";
|
|
27
|
+
import { socialInitialState, socialReducer } from "./containers/Settings/Social/reducer";
|
|
28
|
+
import { sitesInitialState, sitesReducer } from "./containers/Sites/reducer";
|
|
29
|
+
import { structuredDataInitialState, structuredDataReducer } from "./containers/StructuredData/reducer";
|
|
30
|
+
import { usersInitialState, usersReducer } from "./containers/Users/reducer";
|
|
31
|
+
import { setStore } from "./storeRegistry";
|
|
30
32
|
|
|
31
33
|
const blacklist = ["router", "menu", "app", "languages"];
|
|
32
34
|
export class GlobalStore {
|
|
@@ -34,7 +36,8 @@ export class GlobalStore {
|
|
|
34
36
|
|
|
35
37
|
private authPersistConfig = {
|
|
36
38
|
key: "app",
|
|
37
|
-
|
|
39
|
+
// Una pestaña con estado viejo no pisa el par de sesión más nuevo (ver `api/session`).
|
|
40
|
+
storage: createSessionStorage(storage),
|
|
38
41
|
blacklist: ["error", "isLoggingIn", "isRehydrated", "isSaving", "loadingCount", "user"],
|
|
39
42
|
};
|
|
40
43
|
|
|
@@ -96,6 +99,10 @@ export class GlobalStore {
|
|
|
96
99
|
}
|
|
97
100
|
const store = createStore(persistReducer(this.persistConfig, rootReducer), middleware);
|
|
98
101
|
setStore(store);
|
|
102
|
+
registerSessionBridge({
|
|
103
|
+
onRenewed: (session) => store.dispatch(setSessionTokens(session)),
|
|
104
|
+
onExpired: () => store.dispatch(logoutAndNavigate() as any),
|
|
105
|
+
});
|
|
99
106
|
const persistor: Persistor = persistStore(store);
|
|
100
107
|
return { store, persistor };
|
|
101
108
|
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { createMemoryHistory } from "history";
|
|
2
|
+
|
|
3
|
+
import { endSession, notifySessionRenewed, resetSessionState, setSession } from "../api/session";
|
|
4
|
+
import { GlobalStore } from "../GlobalStore";
|
|
5
|
+
import history from "../routes/history";
|
|
6
|
+
|
|
7
|
+
const KEY = "persist:app";
|
|
8
|
+
|
|
9
|
+
const persistedApp = (fields: Record<string, unknown>) =>
|
|
10
|
+
JSON.stringify({
|
|
11
|
+
...Object.fromEntries(Object.entries(fields).map(([k, v]) => [k, JSON.stringify(v)])),
|
|
12
|
+
_persist: JSON.stringify({ version: -1, rehydrated: true }),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const bootstrap = async () => {
|
|
16
|
+
const { store, persistor } = new GlobalStore().configureStore(createMemoryHistory() as any);
|
|
17
|
+
await vi.waitFor(() => expect(persistor.getState().bootstrapped).toBe(true));
|
|
18
|
+
return { store, persistor };
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
localStorage.clear();
|
|
23
|
+
resetSessionState();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
describe("puente de sesión con el store", () => {
|
|
27
|
+
it("una renovación se refleja en el store (token, refresh y versión)", async () => {
|
|
28
|
+
const { store } = await bootstrap();
|
|
29
|
+
|
|
30
|
+
notifySessionRenewed({ token: "new", refreshToken: "r-new", updatedAt: 42 });
|
|
31
|
+
|
|
32
|
+
expect(store.getState().app).toMatchObject({ token: "new", refreshToken: "r-new", sessionUpdatedAt: 42 });
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("el cierre por 401 navega a /logout una sola vez", async () => {
|
|
36
|
+
const push = vi.spyOn(history, "push").mockImplementation(() => undefined);
|
|
37
|
+
await bootstrap();
|
|
38
|
+
|
|
39
|
+
endSession();
|
|
40
|
+
endSession();
|
|
41
|
+
await Promise.resolve();
|
|
42
|
+
|
|
43
|
+
expect(push).toHaveBeenCalledTimes(1);
|
|
44
|
+
expect(push).toHaveBeenCalledWith("/logout", undefined);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
describe("migración del estado persistido", () => {
|
|
49
|
+
it("una sesión anterior al despliegue (sin refresh ni versión) se rehidrata sin perder el estado", async () => {
|
|
50
|
+
localStorage.setItem(
|
|
51
|
+
KEY,
|
|
52
|
+
persistedApp({ token: "legacy-jwt", lang: { locale: "es-ES", id: 1 }, hasAnimation: true }),
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
const { store } = await bootstrap();
|
|
56
|
+
|
|
57
|
+
expect(store.getState().app).toMatchObject({
|
|
58
|
+
token: "legacy-jwt",
|
|
59
|
+
refreshToken: "",
|
|
60
|
+
sessionUpdatedAt: 0,
|
|
61
|
+
lang: { locale: "es-ES", id: 1 },
|
|
62
|
+
hasAnimation: true,
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
describe("persistencia entre pestañas", () => {
|
|
68
|
+
it("una pestaña con estado viejo no sobrescribe el par nuevo que renovó otra pestaña", async () => {
|
|
69
|
+
localStorage.setItem(KEY, persistedApp({ token: "old", refreshToken: "r-old", sessionUpdatedAt: 10 }));
|
|
70
|
+
const { store, persistor } = await bootstrap();
|
|
71
|
+
|
|
72
|
+
// otra pestaña renueva y escribe su par (más nuevo)
|
|
73
|
+
localStorage.setItem(KEY, persistedApp({ token: "new", refreshToken: "r-new", sessionUpdatedAt: 20 }));
|
|
74
|
+
|
|
75
|
+
// esta pestaña, con su par viejo en memoria, persiste un cambio cualquiera
|
|
76
|
+
store.dispatch({ type: "app/SET_HAS_ANIMATION", payload: { hasAnimation: true } });
|
|
77
|
+
await persistor.flush();
|
|
78
|
+
|
|
79
|
+
const stored = JSON.parse(localStorage.getItem(KEY) as string);
|
|
80
|
+
expect(JSON.parse(stored.token)).toBe("new");
|
|
81
|
+
expect(JSON.parse(stored.refreshToken)).toBe("r-new");
|
|
82
|
+
expect(JSON.parse(stored.sessionUpdatedAt)).toBe(20);
|
|
83
|
+
expect(JSON.parse(stored.hasAnimation)).toBe(true);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("una cuota llena al persistir no rompe la sesión en memoria", async () => {
|
|
87
|
+
const { store, persistor } = await bootstrap();
|
|
88
|
+
setSession("jwt", "r");
|
|
89
|
+
vi.spyOn(Storage.prototype, "setItem").mockImplementation(() => {
|
|
90
|
+
throw new DOMException("full", "QuotaExceededError");
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
store.dispatch({ type: "app/SET_HAS_ANIMATION", payload: { hasAnimation: true } });
|
|
94
|
+
await expect(persistor.flush()).resolves.not.toThrow();
|
|
95
|
+
|
|
96
|
+
expect(store.getState().app.hasAnimation).toBe(true);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { global } from "../../api";
|
|
2
|
+
import { registerSessionBridge, resetSessionState, setSession } from "../../api/session";
|
|
3
|
+
|
|
4
|
+
const mockedAxios = vi.hoisted(() => vi.fn());
|
|
5
|
+
vi.mock("axios", () => ({ default: mockedAxios }));
|
|
6
|
+
|
|
7
|
+
beforeEach(() => {
|
|
8
|
+
localStorage.clear();
|
|
9
|
+
resetSessionState();
|
|
10
|
+
registerSessionBridge({});
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
describe("global.logout", () => {
|
|
14
|
+
it("envía POST /logout con el acceso (aunque caducado) y el refresh en el cuerpo", async () => {
|
|
15
|
+
mockedAxios.mockResolvedValue({ status: 204 });
|
|
16
|
+
|
|
17
|
+
await global.logout({ token: "expired", refreshToken: "r1" });
|
|
18
|
+
|
|
19
|
+
const config = mockedAxios.mock.calls[0][0] as any;
|
|
20
|
+
expect(config.url).toMatch(/\/logout$/);
|
|
21
|
+
expect(config.method).toBe("POST");
|
|
22
|
+
expect(config.headers.Authorization).toBe("bearer expired");
|
|
23
|
+
expect(config.data).toEqual({ refreshToken: "r1" });
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("sin refresh envía solo el acceso", async () => {
|
|
27
|
+
mockedAxios.mockResolvedValue({ status: 204 });
|
|
28
|
+
|
|
29
|
+
await global.logout({ token: "jwt", refreshToken: null });
|
|
30
|
+
|
|
31
|
+
expect((mockedAxios.mock.calls[0][0] as any).data).toEqual({});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("un 401 del logout no dispara renovación ni cierre", async () => {
|
|
35
|
+
const onExpired = vi.fn();
|
|
36
|
+
registerSessionBridge({ onExpired });
|
|
37
|
+
setSession("jwt", "r1");
|
|
38
|
+
mockedAxios.mockRejectedValue(Object.assign(new Error("401"), { response: { status: 401, data: {} } }));
|
|
39
|
+
|
|
40
|
+
const response = await global.logout({ token: "jwt", refreshToken: "r1" });
|
|
41
|
+
|
|
42
|
+
expect(response.status).toBe(401);
|
|
43
|
+
expect(mockedAxios).toHaveBeenCalledTimes(1);
|
|
44
|
+
expect(onExpired).not.toHaveBeenCalled();
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
describe("exclusiones de renovación", () => {
|
|
49
|
+
it.each([
|
|
50
|
+
["login (y SSO)", () => global.login({ username: "a", password: "b" })],
|
|
51
|
+
["password/init", () => global.createPassword(3, { password: "x" } as any)],
|
|
52
|
+
])("%s: su 401 es un error normal", async (_name, call) => {
|
|
53
|
+
const onExpired = vi.fn();
|
|
54
|
+
registerSessionBridge({ onExpired });
|
|
55
|
+
setSession("jwt", "r1");
|
|
56
|
+
mockedAxios.mockRejectedValue(Object.assign(new Error("401"), { response: { status: 401, data: {} } }));
|
|
57
|
+
|
|
58
|
+
const response = await call();
|
|
59
|
+
|
|
60
|
+
expect(response.status).toBe(401);
|
|
61
|
+
expect(mockedAxios).toHaveBeenCalledTimes(1);
|
|
62
|
+
expect(onExpired).not.toHaveBeenCalled();
|
|
63
|
+
});
|
|
64
|
+
});
|