@griddo/ax 1.63.5 → 1.64.2

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.
Files changed (130) hide show
  1. package/config/griddo-config/cx-polyfills/builder.ssr.js +6 -0
  2. package/config/griddo-config/cx-polyfills/componentsBundle.js +4 -0
  3. package/config/{griddo-config.js → griddo-config/index.js} +36 -15
  4. package/config/griddo-config/ssrHelpers.js +47 -0
  5. package/config/jest/componentsMock.js +29 -0
  6. package/config/jest/fileMock.js +1 -0
  7. package/config/jest/setup.js +5 -0
  8. package/config/jest/styleMock.js +1 -0
  9. package/config/jest/test-utils.js +17 -0
  10. package/config/paths.js +36 -5
  11. package/config/webpack.config.js +1 -1
  12. package/config/webpackDevServer.config.js +4 -1
  13. package/config/webpackSchemas.config.js +4 -1
  14. package/package.json +33 -59
  15. package/scripts/build.js +9 -2
  16. package/src/__mocks__/reducers/analyticsState.tsx +14 -0
  17. package/src/__mocks__/reducers/pageEditor.tsx +30 -0
  18. package/src/api/sites.tsx +28 -6
  19. package/src/api/structuredData.tsx +1 -1
  20. package/src/api/users.tsx +5 -4
  21. package/src/components/ActionMenu/style.tsx +2 -0
  22. package/src/components/Browser/index.tsx +9 -5
  23. package/src/{modules/Content/PageItem/atoms.tsx → components/CategoryCell/index.tsx} +4 -6
  24. package/src/components/CategoryCell/style.tsx +11 -0
  25. package/src/components/Fields/AnalyticsField/PageAnalytics/index.tsx +19 -19
  26. package/src/components/Fields/AnalyticsField/StructuredDataAnalytics/atoms.tsx +26 -16
  27. package/src/components/Fields/AnalyticsField/StructuredDataAnalytics/index.tsx +8 -13
  28. package/src/components/Fields/AnalyticsField/index.test.tsx +100 -0
  29. package/src/components/Fields/AnalyticsField/index.tsx +9 -2
  30. package/src/components/Fields/AnalyticsField/utils.tsx +2 -2
  31. package/src/components/Fields/ArrayFieldGroup/ArrayFieldItem/style.tsx +2 -1
  32. package/src/components/Fields/CheckField/index.test.tsx +95 -0
  33. package/src/components/Fields/CheckField/index.tsx +9 -3
  34. package/src/components/Fields/CheckField/style.tsx +32 -24
  35. package/src/components/Fields/CheckGroup/index.test.tsx +274 -0
  36. package/src/components/Fields/CheckGroup/index.tsx +2 -1
  37. package/src/components/Fields/FileField/FileDragAndDrop/style.tsx +3 -2
  38. package/src/components/Fields/FileField/style.tsx +2 -1
  39. package/src/components/Fields/MultiCheckSelect/style.tsx +18 -18
  40. package/src/components/Fields/NoteField/style.tsx +9 -9
  41. package/src/components/Fields/ReferenceField/AutoPanel/AutoItem/index.tsx +1 -1
  42. package/src/components/Fields/Select/style.tsx +41 -37
  43. package/src/components/Fields/TagField/index.test.tsx +136 -0
  44. package/src/components/Fields/TagField/index.tsx +8 -12
  45. package/src/components/Fields/TextArea/index.test.tsx +69 -0
  46. package/src/components/Fields/TextArea/index.tsx +4 -13
  47. package/src/components/Fields/TextArea/style.tsx +2 -2
  48. package/src/components/Fields/TextField/index.test.tsx +144 -0
  49. package/src/components/Fields/TextField/index.tsx +23 -19
  50. package/src/components/Fields/TextField/style.tsx +16 -7
  51. package/src/components/Fields/UniqueCheck/index.test.tsx +43 -0
  52. package/src/components/Fields/UrlField/utils.tsx +8 -6
  53. package/src/components/FieldsBehavior/index.tsx +0 -2
  54. package/src/components/FieldsBehavior/style.tsx +21 -21
  55. package/src/components/Gallery/GalleryFilters/Orientation/style.tsx +2 -1
  56. package/src/components/Gallery/GalleryFilters/SortBy/style.tsx +2 -1
  57. package/src/components/Icon/index.tsx +12 -10
  58. package/src/components/IconAction/index.tsx +7 -1
  59. package/src/components/IconAction/style.tsx +10 -10
  60. package/src/components/SearchField/index.tsx +11 -8
  61. package/src/components/SearchField/style.tsx +21 -12
  62. package/src/components/TableFilters/CategoryFilter/index.tsx +1 -1
  63. package/src/components/TableFilters/CategoryFilter/style.tsx +2 -1
  64. package/src/components/TableFilters/DateFilter/style.tsx +2 -1
  65. package/src/components/TableFilters/LiveFilter/index.tsx +2 -2
  66. package/src/components/TableFilters/LiveFilter/style.tsx +2 -1
  67. package/src/components/TableFilters/NameFilter/style.tsx +2 -1
  68. package/src/components/TableFilters/SiteFilter/index.tsx +38 -24
  69. package/src/components/TableFilters/SiteFilter/style.tsx +2 -1
  70. package/src/components/TableFilters/StatusFilter/style.tsx +2 -1
  71. package/src/components/TableFilters/TranslationsFilter/style.tsx +2 -1
  72. package/src/components/TableFilters/TypeFilter/style.tsx +2 -1
  73. package/src/components/Tag/index.tsx +9 -7
  74. package/src/components/Tag/style.tsx +20 -8
  75. package/src/components/index.tsx +4 -2
  76. package/src/containers/App/reducer.tsx +0 -2
  77. package/src/containers/PageEditor/actions.tsx +2 -2
  78. package/src/containers/Sites/actions.tsx +30 -19
  79. package/src/containers/Users/actions.tsx +10 -2
  80. package/src/containers/Users/reducer.tsx +3 -1
  81. package/src/helpers/fields.tsx +2 -4
  82. package/src/helpers/index.tsx +3 -0
  83. package/src/helpers/themes.tsx +9 -0
  84. package/src/modules/Analytics/GroupPanel/utils.tsx +3 -3
  85. package/src/modules/App/Routing/NavMenu/index.tsx +13 -12
  86. package/src/modules/Content/PageItem/index.tsx +31 -9
  87. package/src/modules/Content/PageItem/style.tsx +0 -7
  88. package/src/modules/Content/atoms.tsx +78 -0
  89. package/src/modules/Content/index.tsx +104 -33
  90. package/src/modules/Content/style.tsx +10 -7
  91. package/src/modules/GlobalEditor/PageBrowser/index.tsx +0 -4
  92. package/src/modules/GlobalEditor/index.tsx +3 -3
  93. package/src/modules/Navigation/Defaults/DefaultsEditor/Editor/DefaultsBrowser/index.tsx +0 -4
  94. package/src/modules/PageEditor/PageBrowser/index.tsx +0 -4
  95. package/src/modules/PageEditor/atoms.tsx +74 -0
  96. package/src/modules/PageEditor/index.tsx +30 -9
  97. package/src/modules/PageEditor/style.tsx +4 -0
  98. package/src/modules/PublicPreview/index.tsx +3 -5
  99. package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/TemplateEditor/Editor/TemplateBrowser/index.tsx +0 -4
  100. package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/TemplateEditor/Editor/index.tsx +2 -3
  101. package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/index.tsx +1 -1
  102. package/src/modules/Settings/Globals/index.tsx +3 -3
  103. package/src/modules/StructuredData/Form/index.tsx +2 -4
  104. package/src/modules/StructuredData/StructuredDataList/BulkHeader/TableHeader/index.tsx +22 -18
  105. package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/atoms.tsx +3 -24
  106. package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/index.tsx +2 -2
  107. package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/style.tsx +0 -7
  108. package/src/modules/StructuredData/StructuredDataList/OptionTable/index.tsx +2 -4
  109. package/src/modules/StructuredData/StructuredDataList/StructuredDataItem/index.tsx +46 -14
  110. package/src/modules/StructuredData/StructuredDataList/hooks.tsx +21 -9
  111. package/src/modules/StructuredData/StructuredDataList/index.tsx +48 -20
  112. package/src/modules/Users/Profile/index.tsx +12 -7
  113. package/src/modules/Users/UserCreate/SiteItem/index.tsx +44 -0
  114. package/src/modules/Users/UserCreate/SiteItem/style.tsx +30 -0
  115. package/src/modules/Users/UserCreate/index.tsx +120 -10
  116. package/src/modules/Users/UserCreate/style.tsx +54 -1
  117. package/src/modules/Users/UserEdit/index.tsx +53 -15
  118. package/src/modules/Users/UserForm/index.tsx +152 -5
  119. package/src/modules/Users/UserForm/style.tsx +40 -2
  120. package/src/modules/Users/UserList/BulkHeader/TableHeader/index.tsx +40 -2
  121. package/src/modules/Users/UserList/BulkHeader/TableHeader/style.tsx +0 -1
  122. package/src/modules/Users/UserList/BulkHeader/index.tsx +10 -1
  123. package/src/modules/Users/UserList/UserItem/index.tsx +70 -15
  124. package/src/modules/Users/UserList/hooks.tsx +58 -1
  125. package/src/modules/Users/UserList/index.tsx +80 -34
  126. package/src/modules/Users/index.tsx +18 -11
  127. package/src/routes/site.tsx +8 -0
  128. package/src/types/index.tsx +7 -0
  129. package/tsconfig.json +2 -0
  130. package/scripts/test.js +0 -45
@@ -0,0 +1,6 @@
1
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
2
+ const onRenderBody = () => {};
3
+
4
+ export default {
5
+ onRenderBody,
6
+ };
@@ -0,0 +1,4 @@
1
+ export * from "__componentsConfig";
2
+ export * from "__componentsIndex";
3
+ export { default as builderSSR } from "__ssrConfig";
4
+ export * as ssrHelpers from "__ssrHelpers";
@@ -1,3 +1,4 @@
1
+ const fs = require("fs");
1
2
  const path = require("path");
2
3
  const findUp = require("find-up");
3
4
 
@@ -5,11 +6,21 @@ const pkgDir = require("pkg-dir");
5
6
 
6
7
  const isComponentLibraryEnv = __dirname.includes("node_modules");
7
8
 
9
+ const componentsBundlePolyfillPath = path.resolve(__dirname, "./cx-polyfills/componentsBundle.js");
10
+
8
11
  const resolveComponentsPath = (customPath = "") =>
9
12
  isComponentLibraryEnv
10
13
  ? path.resolve(pkgDir.sync(process.cwd()), customPath)
11
14
  : path.resolve(pkgDir.sync(__dirname), "../griddo-components", customPath);
12
15
 
16
+ const resolveBuilderSSRPath = () => {
17
+ const builderSSRPolyfillPath = path.resolve(__dirname, "./cx-polyfills/builder.ssr.js");
18
+ const builderSSRPath = resolveComponentsPath("builder.ssr.js");
19
+ const builderSSRPathExists = fs.existsSync(builderSSRPath);
20
+
21
+ return builderSSRPathExists ? builderSSRPath : builderSSRPolyfillPath;
22
+ };
23
+
13
24
  const getComponentsJSConfig = () => {
14
25
  const jsConfigPath = findUp.sync("jsconfig.json", { cwd: resolveComponentsPath() });
15
26
  const tsConfigPath = findUp.sync("tsconfig.json", { cwd: resolveComponentsPath() });
@@ -34,24 +45,28 @@ const getComponentsLibAliases = () => {
34
45
  [aliasKey]: absolutePath,
35
46
  };
36
47
  },
37
- { components: `${resolveComponentsPath()}/src/index.js` }
48
+ {
49
+ components: componentsBundlePolyfillPath,
50
+ __componentsIndex: resolveComponentsPath("src/index.js"),
51
+ __componentsConfig: resolveComponentsPath("griddo.config.js"),
52
+ __ssrConfig: resolveBuilderSSRPath(),
53
+ __ssrHelpers: path.resolve(__dirname, "./ssrHelpers"),
54
+ }
38
55
  );
39
56
  };
40
57
 
41
- // TODO: Separar los imports de components de los de AX
42
58
  const griddoAxAliases = {
43
- "@ax/api": path.resolve(__dirname, "../src/api/"),
44
- "@ax/components": path.resolve(__dirname, "../src/components"),
45
- "@ax/containers": path.resolve(__dirname, "../src/containers"),
46
- "@ax/forms": path.resolve(__dirname, "../src/forms"),
47
- "@ax/guards": path.resolve(__dirname, "../src/guards"),
48
- "@ax/helpers": path.resolve(__dirname, "../src/helpers/"),
49
- "@ax/hooks": path.resolve(__dirname, "../src/hooks/"),
50
- "@ax/modules": path.resolve(__dirname, "../src/modules"),
51
- "@ax/routes": path.resolve(__dirname, "../src/routes"),
52
- "@ax/types": path.resolve(__dirname, "../src/types"),
53
- "@ax/schemas": path.resolve(__dirname, "../src/schemas"),
54
- ...getComponentsLibAliases(),
59
+ "@ax/api": path.resolve(__dirname, "../../src/api/"),
60
+ "@ax/components": path.resolve(__dirname, "../../src/components"),
61
+ "@ax/containers": path.resolve(__dirname, "../../src/containers"),
62
+ "@ax/forms": path.resolve(__dirname, "../../src/forms"),
63
+ "@ax/guards": path.resolve(__dirname, "../../src/guards"),
64
+ "@ax/helpers": path.resolve(__dirname, "../../src/helpers/"),
65
+ "@ax/hooks": path.resolve(__dirname, "../../src/hooks/"),
66
+ "@ax/modules": path.resolve(__dirname, "../../src/modules"),
67
+ "@ax/routes": path.resolve(__dirname, "../../src/routes"),
68
+ "@ax/types": path.resolve(__dirname, "../../src/types"),
69
+ "@ax/schemas": path.resolve(__dirname, "../../src/schemas"),
55
70
  };
56
71
 
57
72
  const griddoComponentsLibAliases = getComponentsLibAliases();
@@ -70,6 +85,10 @@ const mergeComponentsAliases = (...arrs) => {
70
85
  return merged;
71
86
  };
72
87
 
88
+ /* Components Static Paths */
89
+ const componentsStaticPath = resolveComponentsPath("static");
90
+ const componentsStaticPathExists = fs.existsSync(componentsStaticPath);
91
+
73
92
  module.exports = {
74
93
  isComponentLibraryEnv,
75
94
  componentsPath: resolveComponentsPath(),
@@ -80,6 +99,8 @@ module.exports = {
80
99
  griddoAxAliases,
81
100
  thereAreAliasConflicts,
82
101
  mergeComponentsAliases,
83
- projectAliases: griddoAxAliases,
102
+ projectAliases: { ...griddoAxAliases, ...griddoComponentsLibAliases },
84
103
  // projectAliases: mergeComponentsAliases(griddoComponentsLibAliases, griddoAxAliases),
104
+ componentsStaticPath,
105
+ componentsStaticPathExists,
85
106
  };
@@ -0,0 +1,47 @@
1
+ /* eslint-disable @typescript-eslint/no-empty-function */
2
+
3
+ export const setHeadComponents = (props) => {
4
+ const headKeyIdentifier = "data-head-component";
5
+ const headValueIdentifier = "griddo-instance-head-component";
6
+ const headElementsIdentifier = `[${headKeyIdentifier}="${headValueIdentifier}"]`;
7
+
8
+ [...document.querySelectorAll(headElementsIdentifier)].map((e) => e.remove());
9
+
10
+ props.map((tag) => {
11
+ const element = document.createElement(tag.type);
12
+ element.setAttribute(headKeyIdentifier, headValueIdentifier);
13
+
14
+ Object.keys(tag.props).map((attKey) => {
15
+ if (attKey === "dangerouslySetInnerHTML") {
16
+ return (element.innerHTML = tag.props.dangerouslySetInnerHTML.__html);
17
+ }
18
+ return element.setAttribute(attKey, tag.props[attKey]);
19
+ });
20
+
21
+ document.head.appendChild(element);
22
+ });
23
+
24
+ return props;
25
+ };
26
+
27
+ export const setHtmlAttributes = (props) => {
28
+ return props;
29
+ };
30
+
31
+ export const setBodyAttributes = (props) => {
32
+ return props;
33
+ };
34
+
35
+ export const setPreBodyComponents = (props) => {
36
+ return props;
37
+ };
38
+
39
+ export const setPostBodyComponents = (props) => {
40
+ return props;
41
+ };
42
+
43
+ export const setBodyProps = (props) => {
44
+ return props;
45
+ };
46
+
47
+ export const pathname = "ax-editor";
@@ -0,0 +1,29 @@
1
+ module.exports = {
2
+ schemas: {key: 'schema definition'},
3
+ parseTheme: theme => {
4
+ const color = "#000";
5
+ const gradient = "#000";
6
+ const shadow = "#000";
7
+ const mq = "#000";
8
+ const textStyle = "#000";
9
+ const breakpoints = "#000";
10
+ const fontFamily = "#000";
11
+
12
+ const returnObject = {
13
+ ...theme,
14
+ fontFamily,
15
+ color,
16
+ colors: color,
17
+ gradient,
18
+ shadow,
19
+ mq,
20
+ textStyle,
21
+ breakpoints,
22
+ fontSizes: "#000",
23
+ negateSpacing: "#000",
24
+ halfSpacing: "#000",
25
+ negateHalfSpacing: "#000",
26
+ };
27
+ return returnObject;
28
+ }
29
+ };
@@ -0,0 +1 @@
1
+ module.exports = 'test-file-stub'
@@ -0,0 +1,5 @@
1
+ require('babel-plugin-require-context-hook/register')()
2
+
3
+ module.exports = () =>{
4
+ global.IS_REACT_ACT_ENVIRONMENT = true;
5
+ }
@@ -0,0 +1 @@
1
+ module.exports = {};
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import { render } from '@testing-library/react';
3
+ import { Provider } from 'react-redux';
4
+
5
+ // custom render that includes redux provider
6
+ const customRender = (ui, {store, ...renderOptions} = {}) => {
7
+ const wrapper = ({children}) => {
8
+ return <Provider store={store}>{children}</Provider>
9
+ }
10
+
11
+ return render(ui, { wrapper: wrapper, ...renderOptions})
12
+ }
13
+
14
+ // re-export everything
15
+ export * from '@testing-library/react';
16
+ // override render method
17
+ export { customRender as render }
package/config/paths.js CHANGED
@@ -1,8 +1,9 @@
1
1
  const path = require("path");
2
- const fs = require("fs");
2
+ const fs = require("fs-extra");
3
3
  const getPublicUrlOrPath = require("react-dev-utils/getPublicUrlOrPath");
4
+ const chalk = require("react-dev-utils/chalk");
4
5
 
5
- const { resolveComponentsPath } = require("./griddo-config");
6
+ const { resolveComponentsPath, componentsStaticPath, componentsStaticPathExists } = require("./griddo-config");
6
7
 
7
8
  // Make sure any symlinks in the project folder are resolved:
8
9
  // https://github.com/facebook/create-react-app/issues/637
@@ -48,12 +49,38 @@ const resolveModule = (resolveFn, filePath) => {
48
49
  return resolveFn(`${filePath}.js`);
49
50
  };
50
51
 
52
+ /* Static & Public Folder */
53
+ const appPublic = resolveApp("public");
54
+ const appHtml = resolveApp("public/index.html");
55
+ const appWebpackCache = resolveApp("node_modules/.cache");
56
+ const appStaticAssetsCache = componentsStaticPathExists ? path.resolve(appWebpackCache, "axStatic") : appPublic;
57
+
58
+ function prepareAssetsFolders() {
59
+ if (!componentsStaticPathExists) return;
60
+
61
+ console.log();
62
+ console.log(chalk.yellow(`Building Static Assets cache`));
63
+ console.log(componentsStaticPath);
64
+ console.log(appStaticAssetsCache);
65
+ console.log();
66
+
67
+ fs.mkdirpSync(appStaticAssetsCache);
68
+
69
+ fs.copySync(componentsStaticPath, appStaticAssetsCache, {
70
+ dereference: true,
71
+ });
72
+ fs.copySync(appPublic, appStaticAssetsCache, {
73
+ dereference: true,
74
+ filter: (file) => file !== appHtml,
75
+ });
76
+ }
77
+
51
78
  module.exports = {
52
79
  dotenv: resolveApp(".env"),
53
80
  appPath: resolveApp("."),
54
81
  appBuild: path.resolve(process.cwd(), buildPath),
55
- appPublic: resolveApp("public"),
56
- appHtml: resolveApp("public/index.html"),
82
+ appPublic,
83
+ appHtml,
57
84
  appIndexJs: resolveModule(resolveApp, "src/index"),
58
85
  appPackageJson: resolveApp("package.json"),
59
86
  appSrc: resolveApp("src"),
@@ -64,10 +91,14 @@ module.exports = {
64
91
  testsSetup: resolveModule(resolveApp, "src/setupTests"),
65
92
  proxySetup: resolveApp("src/setupProxy.js"),
66
93
  appNodeModules: resolveApp("node_modules"),
67
- appWebpackCache: resolveApp("node_modules/.cache"),
94
+ appWebpackCache,
68
95
  appTsBuildInfoFile: resolveApp("node_modules/.cache/tsconfig.tsbuildinfo"),
69
96
  swSrc: resolveModule(resolveApp, "src/service-worker"),
70
97
  publicUrlOrPath,
98
+ componentsStaticPath,
99
+ componentsStaticPathExists,
100
+ appStaticAssetsCache,
101
+ prepareAssetsFolders,
71
102
  };
72
103
 
73
104
  module.exports.moduleFileExtensions = moduleFileExtensions;
@@ -407,7 +407,7 @@ module.exports = function (webpackEnv) {
407
407
  exclude: /@babel(?:\/|\\{1,2})runtime/,
408
408
  loader: require.resolve("babel-loader"),
409
409
  options: {
410
- babelrc: false,
410
+ babelrc: true,
411
411
  configFile: false,
412
412
  compact: false,
413
413
  presets: [[require.resolve("babel-preset-react-app/dependencies"), { helpers: true }]],
@@ -13,6 +13,9 @@ const sockPath = process.env.WDS_SOCKET_PATH; // default: '/sockjs-node'
13
13
  const sockPort = process.env.WDS_SOCKET_PORT;
14
14
 
15
15
  module.exports = function (proxy, allowedHost) {
16
+ // Merge `public` and `static` paths for development
17
+ paths.prepareAssetsFolders();
18
+
16
19
  return {
17
20
  // WebpackDevServer 2.4.3 introduced a security fix that prevents remote
18
21
  // websites from potentially accessing local content through DNS rebinding:
@@ -50,7 +53,7 @@ module.exports = function (proxy, allowedHost) {
50
53
  // for files like `favicon.ico`, `manifest.json`, and libraries that are
51
54
  // for some reason broken when imported through webpack. If you just want to
52
55
  // use an image, put it in `src` and `import` it from JavaScript instead.
53
- contentBase: paths.appPublic,
56
+ contentBase: paths.appStaticAssetsCache,
54
57
  contentBasePublicPath: paths.publicUrlOrPath,
55
58
  // By default files from `contentBase` will not trigger a page reload.
56
59
  watchContentBase: true,
@@ -23,7 +23,10 @@ const createConfig = ({ input, output }) => ({
23
23
  use: {
24
24
  loader: "babel-loader",
25
25
  options: {
26
- presets: ["@babel/preset-env"],
26
+ presets: [
27
+ ['@babel/preset-env', {targets: {node: 'current'}}],
28
+ '@babel/preset-typescript'
29
+ ]
27
30
  },
28
31
  },
29
32
  },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@griddo/ax",
3
3
  "description": "Griddo Author Experience",
4
- "version": "1.63.5",
4
+ "version": "1.64.2",
5
5
  "authors": [
6
6
  "Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
7
7
  "Carlos Torres <carlos.torres@secuoyas.com>",
@@ -28,23 +28,28 @@
28
28
  "build": "node scripts/build.js",
29
29
  "build:dev": "env-cmd -f env/.env.development node scripts/build.js",
30
30
  "build:bitbucket": "env-cmd -f env/.env npm run build",
31
- "test": "node scripts/test.js",
31
+ "test": "jest",
32
+ "test:watch": "jest --watch",
33
+ "test:ci": "jest --runInBand",
34
+ "test:coverage": "jest --coverage ",
35
+ "test:dev": "npm run test -- --watch",
36
+ "test:dev:coverage": "npm run test:coverage -- --watch",
32
37
  "lint": "eslint .",
33
38
  "format": "prettier -w .",
34
39
  "start:test": "env-cmd -f env/.env.development node scripts/dev.js"
35
40
  },
36
41
  "dependencies": {
37
42
  "@atlaskit/tree": "^8.2.0",
38
- "@babel/core": "7.14.2",
39
- "@babel/preset-env": "^7.14.5",
40
43
  "@babel/preset-react": "^7.14.5",
41
44
  "@pmmmwh/react-refresh-webpack-plugin": "0.5.0-rc.0",
42
45
  "@styled-system/prop-types": "5.1.2",
43
46
  "@styled-system/theme-get": "^5.1.2",
44
47
  "@svgr/webpack": "^5.5.0",
48
+ "@testing-library/jest-dom": "^5.16.4",
49
+ "@testing-library/react": "^13.0.0",
50
+ "@testing-library/user-event": "^14.0.4",
45
51
  "@types/compress.js": "^1.1.0",
46
52
  "@types/draft-js": "^0.10.44",
47
- "@types/jest": "24.0.19",
48
53
  "@types/lodash.isequal": "^4.5.5",
49
54
  "@types/markdown-draft-js": "^2.2.2",
50
55
  "@types/node": "12.11.1",
@@ -55,7 +60,7 @@
55
60
  "@types/react-redux": "^7.1.23",
56
61
  "@types/react-router-dom": "5.3.3",
57
62
  "@types/react-select": "^3.0.8",
58
- "@types/react-test-renderer": "16.9.1",
63
+ "@types/react-test-renderer": "17.0.1",
59
64
  "@types/react-textarea-autosize": "^4.3.5",
60
65
  "@types/styled-components": "^5.1.25",
61
66
  "@types/uuid": "^8.3.1",
@@ -65,9 +70,9 @@
65
70
  "add": "^2.0.6",
66
71
  "axios": "0.19.0",
67
72
  "babel-eslint": "10.0.3",
68
- "babel-jest": "^26.6.0",
69
73
  "babel-loader": "8.2.2",
70
74
  "babel-plugin-named-asset-import": "^0.3.7",
75
+ "babel-plugin-require-context-hook": "^1.0.0",
71
76
  "babel-plugin-root-import": "^6.4.1",
72
77
  "babel-plugin-styled-components": "^1.13.2",
73
78
  "babel-preset-react-app": "^10.0.0",
@@ -92,10 +97,12 @@
92
97
  "identity-obj-proxy": "3.0.0",
93
98
  "ignore-loader": "^0.1.2",
94
99
  "is-wsl": "^1.1.0",
95
- "jest": "24.9.0",
100
+ "jest-environment-jsdom": "^27.5.1",
96
101
  "jest-environment-jsdom-fourteen": "0.1.0",
97
102
  "jest-resolve": "24.9.0",
98
103
  "jest-watch-typeahead": "0.4.0",
104
+ "jsdom": "^19.0.0",
105
+ "jsdom-global": "^3.0.2",
99
106
  "lodash.isequal": "4.5.0",
100
107
  "markdown-draft-js": "^2.2.1",
101
108
  "mini-css-extract-plugin": "0.11.3",
@@ -148,6 +155,11 @@
148
155
  "yarn": "^1.22.11"
149
156
  },
150
157
  "devDependencies": {
158
+ "@babel/core": "^7.17.7",
159
+ "@babel/preset-env": "^7.16.11",
160
+ "@babel/preset-typescript": "^7.16.7",
161
+ "@types/jest": "^27.4.1",
162
+ "babel-jest": "^27.5.1",
151
163
  "eslint": "^6.1.0",
152
164
  "eslint-config-prettier": "^8.3.0",
153
165
  "eslint-config-react-app": "^5.0.2",
@@ -158,8 +170,11 @@
158
170
  "eslint-plugin-prettier": "^3.4.0",
159
171
  "eslint-plugin-react": "7.14.3",
160
172
  "eslint-plugin-react-hooks": "^4.2.0",
173
+ "jest": "^27.5.1",
174
+ "jest-styled-components": "^7.0.8",
161
175
  "prettier": "^2.3.0",
162
- "react-test-render": "1.1.2"
176
+ "react-test-render": "1.1.2",
177
+ "ts-jest": "^27.1.4"
163
178
  },
164
179
  "resolutions": {
165
180
  "react-error-overlay": "6.0.9"
@@ -168,7 +183,14 @@
168
183
  "presets": [
169
184
  "react-app",
170
185
  "@babel/preset-react"
171
- ]
186
+ ],
187
+ "env": {
188
+ "test": {
189
+ "plugins": [
190
+ "require-context-hook"
191
+ ]
192
+ }
193
+ }
172
194
  },
173
195
  "browserslist": {
174
196
  "production": [
@@ -191,54 +213,6 @@
191
213
  "tsconfig.json",
192
214
  "tsconfig.paths.json"
193
215
  ],
194
- "jest": {
195
- "roots": [
196
- "<rootDir>/src"
197
- ],
198
- "collectCoverageFrom": [
199
- "src/**/*.{js,jsx,ts,tsx}",
200
- "!src/**/*.d.ts"
201
- ],
202
- "setupFiles": [
203
- "react-app-polyfill/jsdom"
204
- ],
205
- "setupFilesAfterEnv": [],
206
- "testMatch": [
207
- "<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}",
208
- "<rootDir>/src/**/*.{spec,test}.{js,jsx,ts,tsx}"
209
- ],
210
- "testEnvironment": "jest-environment-jsdom-fourteen",
211
- "transform": {
212
- "^.+\\.(js|jsx|ts|tsx)$": "<rootDir>/node_modules/babel-jest",
213
- "^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
214
- "^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
215
- },
216
- "transformIgnorePatterns": [
217
- "[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$",
218
- "^.+\\.module\\.(css|sass|scss)$"
219
- ],
220
- "modulePaths": [],
221
- "moduleNameMapper": {
222
- "^react-native$": "react-native-web",
223
- "^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy"
224
- },
225
- "moduleFileExtensions": [
226
- "web.js",
227
- "js",
228
- "web.ts",
229
- "ts",
230
- "web.tsx",
231
- "tsx",
232
- "json",
233
- "web.jsx",
234
- "jsx",
235
- "node"
236
- ],
237
- "watchPlugins": [
238
- "jest-watch-typeahead/filename",
239
- "jest-watch-typeahead/testname"
240
- ]
241
- },
242
216
  "peerDependencies": {
243
217
  "react": "*",
244
218
  "react-dom": "*"
@@ -246,5 +220,5 @@
246
220
  "publishConfig": {
247
221
  "access": "public"
248
222
  },
249
- "gitHead": "af01aecc628fe1ec952cc63f21e8f576c090b053"
223
+ "gitHead": "5db7cf23a29ddbaefa77db1dd1be23a1035d16d3"
250
224
  }
package/scripts/build.js CHANGED
@@ -47,6 +47,8 @@ const config = configFactory("production");
47
47
  // browserslist defaults.
48
48
  const { checkBrowsers } = require("react-dev-utils/browsersHelper");
49
49
  const pkgDir = require("pkg-dir");
50
+ const { prepareAssetsFolders } = require("../config/paths");
51
+
50
52
  checkBrowsers(paths.appPath, isInteractive)
51
53
  .then(() => {
52
54
  // First, read the current file sizes in build directory.
@@ -58,7 +60,7 @@ checkBrowsers(paths.appPath, isInteractive)
58
60
  // if you're in it, you don't end up in Trash
59
61
  fs.emptyDirSync(paths.appBuild);
60
62
  // Merge with the public folder
61
- copyPublicFolder();
63
+ copyStaticAssets();
62
64
  // Start the webpack build
63
65
  return build(previousFileSizes);
64
66
  })
@@ -159,8 +161,13 @@ function build(previousFileSizes) {
159
161
  });
160
162
  }
161
163
 
164
+ function copyStaticAssets() {
165
+ prepareAssetsFolders();
166
+ copyPublicFolder();
167
+ }
168
+
162
169
  function copyPublicFolder() {
163
- fs.copySync(paths.appPublic, paths.appBuild, {
170
+ fs.copySync(paths.appStaticAssetsCache, paths.appBuild, {
164
171
  dereference: true,
165
172
  filter: (file) => file !== paths.appHtml,
166
173
  });
@@ -0,0 +1,14 @@
1
+ const initialState = {
2
+ scriptCode: "",
3
+ siteScriptCodeExists: false,
4
+ dimensions: [{ name: "", values: "" }],
5
+ groups: [{ templates: "", name: "", dimensions: "" }],
6
+ };
7
+
8
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
9
+ export default (state = initialState, action: { type: unknown }) => {
10
+ switch (action.type) {
11
+ default:
12
+ return state;
13
+ }
14
+ };
@@ -0,0 +1,30 @@
1
+ import { PageEditorActionsCreators } from "../../containers/PageEditor/interfaces";
2
+
3
+ const initialState = {
4
+ editorContent: {},
5
+ template: "BasicTemplate",
6
+ breadcrumb: [],
7
+ schema: {},
8
+ selectedContent: {},
9
+ tab: "content",
10
+ selectedEditorID: 0,
11
+ currentPageID: null,
12
+ currentPageStatus: null,
13
+ currentPageName: "",
14
+ currentPageLanguages: [],
15
+ isNewTranslation: false,
16
+ templateConfig: {},
17
+ selectedParent: null,
18
+ errors: [],
19
+ validated: false,
20
+ sitePageID: null,
21
+ userEditing: null,
22
+ };
23
+
24
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
25
+ export default (state = initialState, action: { type: PageEditorActionsCreators }) => {
26
+ switch (action.type) {
27
+ default:
28
+ return state;
29
+ }
30
+ };
package/src/api/sites.tsx CHANGED
@@ -84,6 +84,11 @@ const SERVICES: { [key: string]: IServiceConfig } = {
84
84
  endpoint: ["/site/", "/pages/global/imports/bulk"],
85
85
  method: "POST",
86
86
  },
87
+ REMOVE_USERS_BULK: {
88
+ ...template,
89
+ endpoint: ["/site/", "/restrict"],
90
+ method: "PUT",
91
+ },
87
92
  REMOVE_PAGE: {
88
93
  ...template,
89
94
  endpoint: ["/site/", "/pages/global/imports/"],
@@ -119,8 +124,10 @@ const getStructuredSitePages = async (params: IGetSitePagesParams, structuredDat
119
124
 
120
125
  SERVICES.GET_SITE_STRUCTURED_PAGES.dynamicUrl = `${host}${prefix}${siteID}${suffix}${structuredData}${filters}deleted=${deleted}&page=${page}&itemsPerPage=${itemsPerPage}`;
121
126
 
122
- if (query && query.trim() !== "") SERVICES.GET_SITE_STRUCTURED_PAGES.dynamicUrl = SERVICES.GET_SITE_STRUCTURED_PAGES.dynamicUrl + `&query=${query}`;
123
- if (format) SERVICES.GET_SITE_STRUCTURED_PAGES.dynamicUrl = SERVICES.GET_SITE_STRUCTURED_PAGES.dynamicUrl + `&format=${format}`;
127
+ if (query && query.trim() !== "")
128
+ SERVICES.GET_SITE_STRUCTURED_PAGES.dynamicUrl = SERVICES.GET_SITE_STRUCTURED_PAGES.dynamicUrl + `&query=${query}`;
129
+ if (format)
130
+ SERVICES.GET_SITE_STRUCTURED_PAGES.dynamicUrl = SERVICES.GET_SITE_STRUCTURED_PAGES.dynamicUrl + `&format=${format}`;
124
131
 
125
132
  return sendRequest(SERVICES.GET_SITE_STRUCTURED_PAGES);
126
133
  };
@@ -136,13 +143,16 @@ const getSitePages = async (params: IGetSitePagesParams, filterQuery?: string):
136
143
  const filters = filterQuery ? `${filterQuery}&` : "?";
137
144
 
138
145
  SERVICES.GET_SITE_PAGES.dynamicUrl = `${host}${prefix}${siteID}${suffix}${filters}deleted=${deleted}&page=${page}&itemsPerPage=${itemsPerPage}`;
139
- if (query && query.trim() !== "") SERVICES.GET_SITE_PAGES.dynamicUrl = SERVICES.GET_SITE_PAGES.dynamicUrl + `&query=${query}`;
140
- if (filterStructuredData) SERVICES.GET_SITE_PAGES.dynamicUrl = SERVICES.GET_SITE_PAGES.dynamicUrl + `&filterStructuredData=${filterStructuredData}`;
146
+ if (query && query.trim() !== "")
147
+ SERVICES.GET_SITE_PAGES.dynamicUrl = SERVICES.GET_SITE_PAGES.dynamicUrl + `&query=${query}`;
148
+ if (filterStructuredData)
149
+ SERVICES.GET_SITE_PAGES.dynamicUrl =
150
+ SERVICES.GET_SITE_PAGES.dynamicUrl + `&filterStructuredData=${filterStructuredData}`;
141
151
  if (format) SERVICES.GET_SITE_PAGES.dynamicUrl = SERVICES.GET_SITE_PAGES.dynamicUrl + `&format=${format}`;
142
152
 
143
153
  const dataHeader = {
144
- ...(lang && { lang })
145
- }
154
+ ...(lang && { lang }),
155
+ };
146
156
 
147
157
  return sendRequest(SERVICES.GET_SITE_PAGES, null, dataHeader);
148
158
  };
@@ -208,6 +218,17 @@ const removePage = async (siteId: number, pageId: number): Promise<AxiosResponse
208
218
  return sendRequest(SERVICES.REMOVE_PAGE);
209
219
  };
210
220
 
221
+ const removeUsersBulk = async (siteId: number, users: number[]): Promise<AxiosResponse> => {
222
+ const {
223
+ host,
224
+ endpoint: [prefix, suffix],
225
+ } = SERVICES.REMOVE_USERS_BULK;
226
+
227
+ SERVICES.REMOVE_USERS_BULK.dynamicUrl = `${host}${prefix}${siteId}${suffix}`;
228
+
229
+ return sendRequest(SERVICES.REMOVE_USERS_BULK, { users });
230
+ };
231
+
211
232
  const removePageBulk = async (siteID: number, ids: number[]): Promise<AxiosResponse> => {
212
233
  const {
213
234
  host,
@@ -317,4 +338,5 @@ export default {
317
338
  importPageBulk,
318
339
  removePage,
319
340
  removePageBulk,
341
+ removeUsersBulk,
320
342
  };
@@ -108,7 +108,7 @@ const getDataContents = (params: IGetStructuredDataParams, siteID?: number | nul
108
108
 
109
109
  const url = siteID ? `${host}/site/${siteID}${endpoint}` : `${host}${endpoint}`;
110
110
 
111
- SERVICES.GET_DATA_CONTENTS.dynamicUrl = `${url}${dataID}?page=${page}&itemsPerPage=${itemsPerPage}&pagination=${pagination}&deleted=${deleted}&includeDraft=${include_draft}`;
111
+ SERVICES.GET_DATA_CONTENTS.dynamicUrl = `${url}${dataID}?page=${page}&itemsPerPage=${itemsPerPage}&pagination=${pagination}&deleted=${deleted}&includeDraft=${include_draft}&relatedFields=true`;
112
112
  if (query && query.trim() !== "") SERVICES.GET_DATA_CONTENTS.dynamicUrl += `&query=${query}`;
113
113
  if (filterQuery) SERVICES.GET_DATA_CONTENTS.dynamicUrl += filterQuery;
114
114