slice-machine-ui 2.16.2-beta.1 → 2.16.2-beta.11

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 (78) hide show
  1. package/out/404.html +1 -1
  2. package/out/_next/static/BxXLQmEwuMSmBB0OCTl9m/_buildManifest.js +1 -0
  3. package/out/_next/static/chunks/157-54b8336d20b41933.js +3 -0
  4. package/out/_next/static/chunks/{183-85de38d65a85dc2c.js → 183-4ea255b867ff171b.js} +1 -1
  5. package/out/_next/static/chunks/248-03446cd9e9f13730.js +1 -0
  6. package/out/_next/static/chunks/268-6a9214b97195af9c.js +1 -0
  7. package/out/_next/static/chunks/33641354.3864aefb6106ae71.js +28 -0
  8. package/out/_next/static/chunks/34-e684c5fd75cc9dd0.js +1 -0
  9. package/out/_next/static/chunks/397-e6c340070a3bcb41.js +1 -0
  10. package/out/_next/static/chunks/630-a9927675acae2970.js +1 -0
  11. package/out/_next/static/chunks/647-7b9b5aa9468f9e4b.js +1 -0
  12. package/out/_next/static/chunks/882-53d88aa0b7e3ffeb.js +1 -0
  13. package/out/_next/static/chunks/{main-1c0e53194ff2e726.js → main-c46f4dcf6e3174bd.js} +1 -1
  14. package/out/_next/static/chunks/pages/_app-274bca1ad521803c.js +708 -0
  15. package/out/_next/static/chunks/pages/changelog-063c5e11dfc8fd55.js +1 -0
  16. package/out/_next/static/chunks/pages/changes-564336edb0ed18b0.js +1 -0
  17. package/out/_next/static/chunks/pages/custom-types/{[customTypeId]-61a3846ae1654f54.js → [customTypeId]-a408f5a660e096a6.js} +1 -1
  18. package/out/_next/static/chunks/pages/{custom-types-093f2e2213561492.js → custom-types-5acd56959b60346f.js} +1 -1
  19. package/out/_next/static/chunks/pages/{index-0e27ae9805b59004.js → index-0d8cb369de720a35.js} +1 -1
  20. package/out/_next/static/chunks/pages/labs-9630bfb1005be02b.js +1 -0
  21. package/out/_next/static/chunks/pages/page-types/{[pageTypeId]-91a4eb622fa3cb7c.js → [pageTypeId]-f5e851ebe35049a8.js} +1 -1
  22. package/out/_next/static/chunks/pages/settings-01f4aeb9112a1f87.js +1 -0
  23. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/simulator-5008e29008aa04f4.js +1 -0
  24. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-94c9cad9da2c3089.js +1 -0
  25. package/out/_next/static/chunks/pages/slices-4a60cd5f2c71327e.js +1 -0
  26. package/out/_next/static/chunks/webpack-b3522fdebabf510a.js +1 -0
  27. package/out/_next/static/css/cc9b10286400c2b9.css +1 -0
  28. package/out/changelog.html +1 -1
  29. package/out/changes.html +1 -1
  30. package/out/custom-types/[customTypeId].html +1 -1
  31. package/out/custom-types.html +1 -1
  32. package/out/index.html +1 -1
  33. package/out/labs.html +1 -1
  34. package/out/page-types/[pageTypeId].html +1 -1
  35. package/out/settings.html +1 -1
  36. package/out/slices/[lib]/[sliceName]/[variation]/simulator.html +1 -1
  37. package/out/slices/[lib]/[sliceName]/[variation].html +1 -1
  38. package/out/slices.html +1 -1
  39. package/package.json +9 -9
  40. package/src/apiClient.ts +8 -6
  41. package/src/features/builder/fields/ContentRelationshipFieldPicker.tsx +1233 -0
  42. package/src/features/customTypes/customTypesTable/CustomTypesTable.tsx +2 -4
  43. package/src/features/customTypes/customTypesTable/{useCustomTypes.ts → useCustomTypesAutoRevalidation.tsx} +1 -34
  44. package/src/features/customTypes/useCustomTypes.ts +48 -0
  45. package/src/legacy/components/App/index.tsx +0 -2
  46. package/src/legacy/lib/models/common/widgets/ContentRelationship/Form.tsx +35 -77
  47. package/src/legacy/lib/models/common/widgets/ContentRelationship/index.ts +44 -14
  48. package/src/legacy/lib/models/common/widgets/Link/index.ts +1 -1
  49. package/src/modules/loading/types.ts +0 -1
  50. package/src/modules/useSliceMachineActions.ts +0 -23
  51. package/src/modules/userContext/index.ts +1 -33
  52. package/src/modules/userContext/types.ts +0 -13
  53. package/src/styles/modal.css +0 -22
  54. package/src/utils/isValidObject.ts +32 -0
  55. package/test/src/modules/userContext.test.ts +1 -50
  56. package/out/_next/static/9BX45OSSCQeaYmYslFbMt/_buildManifest.js +0 -1
  57. package/out/_next/static/chunks/157-fca2f00f6df07660.js +0 -5
  58. package/out/_next/static/chunks/268-6d5fc7642a1b87c8.js +0 -1
  59. package/out/_next/static/chunks/34-2911c905c8a6e9d9.js +0 -1
  60. package/out/_next/static/chunks/630-93339694ef30b82d.js +0 -1
  61. package/out/_next/static/chunks/867-8164160c810122c6.js +0 -1
  62. package/out/_next/static/chunks/882-28837678beff7e51.js +0 -1
  63. package/out/_next/static/chunks/895-8c214ba470a4e23c.js +0 -1
  64. package/out/_next/static/chunks/pages/_app-4f1854df4dfc747d.js +0 -657
  65. package/out/_next/static/chunks/pages/changelog-80a618708f44f25f.js +0 -1
  66. package/out/_next/static/chunks/pages/changes-d40c17939854b984.js +0 -1
  67. package/out/_next/static/chunks/pages/labs-c6df252ea5d8fb6f.js +0 -1
  68. package/out/_next/static/chunks/pages/settings-0da3553b3a0acc99.js +0 -1
  69. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/simulator-063fa88ba75f483e.js +0 -1
  70. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-c71823bf02dc292d.js +0 -1
  71. package/out/_next/static/chunks/pages/slices-7e816c2b32cc6f19.js +0 -1
  72. package/out/_next/static/chunks/webpack-2f903acb0cccbf9e.js +0 -1
  73. package/out/_next/static/css/f0e6d8449ce2bb46.css +0 -1
  74. package/src/legacy/components/ReviewModal/ReviewForm.tsx +0 -169
  75. package/src/legacy/components/ReviewModal/ReviewFormSelect.tsx +0 -35
  76. package/src/legacy/components/ReviewModal/ReviewModal.tsx +0 -56
  77. package/src/legacy/components/ReviewModal/index.ts +0 -1
  78. /package/out/_next/static/{9BX45OSSCQeaYmYslFbMt → BxXLQmEwuMSmBB0OCTl9m}/_ssgManifest.js +0 -0
@@ -29,10 +29,8 @@ import { SingleIcon } from "@/icons/SingleIcon";
29
29
 
30
30
  import { CUSTOM_TYPES_CONFIG } from "../customTypesConfig";
31
31
  import { EditDropdown } from "../EditDropdown";
32
- import {
33
- useCustomTypes,
34
- useCustomTypesAutoRevalidation,
35
- } from "./useCustomTypes";
32
+ import { useCustomTypes } from "../useCustomTypes";
33
+ import { useCustomTypesAutoRevalidation } from "./useCustomTypesAutoRevalidation";
36
34
 
37
35
  type CustomTypesTableProps = {
38
36
  format: CustomTypeFormat;
@@ -1,46 +1,13 @@
1
- import { updateData, useRequest } from "@prismicio/editor-support/Suspense";
2
1
  import type { CustomType } from "@prismicio/types-internal/lib/customtypes";
3
2
  import type { CustomTypeFormat } from "@slicemachine/manager";
4
- import { useCallback, useEffect } from "react";
3
+ import { useEffect } from "react";
5
4
  import { useSelector } from "react-redux";
6
5
 
7
6
  import { CustomTypes } from "@/legacy/lib/models/common/CustomType";
8
7
  import { hasLocal } from "@/legacy/lib/models/common/ModelData";
9
- import { managerClient } from "@/managerClient";
10
8
  import { selectAllCustomTypes } from "@/modules/availableCustomTypes";
11
9
  import type { SliceMachineStoreType } from "@/redux/type";
12
10
 
13
- type UseCustomTypesReturnType = {
14
- customTypes: CustomType[];
15
- updateCustomTypes: (customTypes: CustomType[]) => void;
16
- };
17
-
18
- export function useCustomTypes(
19
- format: CustomTypeFormat,
20
- ): UseCustomTypesReturnType {
21
- const updateCustomTypes = useCallback(
22
- (data: CustomType[]) => updateData(getCustomTypes, [format], data),
23
- [format],
24
- );
25
-
26
- return {
27
- customTypes: useRequest(getCustomTypes, [format]),
28
- updateCustomTypes,
29
- };
30
- }
31
-
32
- async function getCustomTypes(format: CustomTypeFormat): Promise<CustomType[]> {
33
- const { errors, models } = await managerClient.customTypes.readAllCustomTypes(
34
- { format },
35
- );
36
-
37
- if (errors.length > 0) {
38
- throw errors;
39
- }
40
-
41
- return models.map(({ model }) => model);
42
- }
43
-
44
11
  /**
45
12
  * TODO: DT-1363 - Update the way to have new data without Redux by revalidating
46
13
  * Suspense
@@ -0,0 +1,48 @@
1
+ import {
2
+ revalidateData,
3
+ updateData,
4
+ useRequest,
5
+ } from "@prismicio/editor-support/Suspense";
6
+ import type { CustomType } from "@prismicio/types-internal/lib/customtypes";
7
+ import type { CustomTypeFormat } from "@slicemachine/manager";
8
+ import { useCallback } from "react";
9
+
10
+ import { managerClient } from "@/managerClient";
11
+
12
+ type UseCustomTypesReturnType = {
13
+ customTypes: CustomType[];
14
+ updateCustomTypes: (customTypes: CustomType[]) => void;
15
+ };
16
+
17
+ export function useCustomTypes(
18
+ format?: CustomTypeFormat,
19
+ ): UseCustomTypesReturnType {
20
+ const updateCustomTypes = useCallback(
21
+ (data: CustomType[]) => updateData(getCustomTypes, [format], data),
22
+ [format],
23
+ );
24
+
25
+ return {
26
+ customTypes: useRequest(getCustomTypes, [format]),
27
+ updateCustomTypes,
28
+ };
29
+ }
30
+
31
+ export async function getCustomTypes(
32
+ format?: CustomTypeFormat,
33
+ ): Promise<CustomType[]> {
34
+ const { errors, models } = await managerClient.customTypes.readAllCustomTypes(
35
+ format ? { format } : undefined,
36
+ );
37
+
38
+ if (errors.length > 0) {
39
+ throw errors;
40
+ }
41
+
42
+ return models.map(({ model }) => model);
43
+ }
44
+
45
+ export function revalidateGetCustomTypes(format?: CustomTypeFormat) {
46
+ void revalidateData(getCustomTypes, []);
47
+ void revalidateData(getCustomTypes, [format]);
48
+ }
@@ -7,7 +7,6 @@ import useSMTracker from "@/hooks/useSMTracker";
7
7
  import { AppLayout, AppLayoutContent } from "@/legacy/components/AppLayout";
8
8
  import LoginModal from "@/legacy/components/LoginModal";
9
9
  import { MissingLibraries } from "@/legacy/components/MissingLibraries";
10
- import { ReviewModal } from "@/legacy/components/ReviewModal";
11
10
  import { getLibraries } from "@/modules/slices";
12
11
  import { SliceMachineStoreType } from "@/redux/type";
13
12
 
@@ -37,7 +36,6 @@ const SliceMachineApp: FC<Props> = ({ children }) => {
37
36
  </AppLayout>
38
37
  )}
39
38
  <LoginModal />
40
- <ReviewModal />
41
39
  </>
42
40
  );
43
41
  };
@@ -1,105 +1,63 @@
1
+ import { LinkConfig } from "@prismicio/types-internal/lib/customtypes";
1
2
  import { FormikProps } from "formik";
2
- import { useSelector } from "react-redux";
3
- import Select from "react-select";
4
- import { Box, Label } from "theme-ui";
3
+ import { Box } from "theme-ui";
5
4
  import * as yup from "yup";
6
5
 
6
+ import { ContentRelationshipFieldPicker } from "@/features/builder/fields/ContentRelationshipFieldPicker";
7
7
  import { Col, Flex as FlexGrid } from "@/legacy/components/Flex";
8
8
  import WidgetFormField from "@/legacy/lib/builders/common/EditModal/Field";
9
9
  import { createFieldNameFromKey } from "@/legacy/lib/forms";
10
10
  import { DefaultFields } from "@/legacy/lib/forms/defaults";
11
- import { selectAllCustomTypes } from "@/modules/availableCustomTypes";
12
-
13
- import { hasLocal } from "../../ModelData";
14
11
 
15
12
  const FormFields = {
16
13
  label: DefaultFields.label,
17
14
  id: DefaultFields.id,
18
15
  customtypes: {
19
- validate: () => yup.array().of(yup.string()),
16
+ validate: () => yup.array(),
20
17
  },
21
18
  };
22
19
 
23
20
  type FormProps = {
24
- config: { label: string; select: string; customtypes?: string[] };
21
+ config: {
22
+ label: string;
23
+ select: string;
24
+ customtypes?: LinkConfig["customtypes"];
25
+ };
25
26
  id: string;
26
- // type: string; // TODO: this exists in the yup schema but this doesn't seem to be validated by formik
27
+ // TODO: this exists in the yup schema but this doesn't seem to be validated by formik
27
28
  };
28
29
 
29
30
  const WidgetForm = ({
30
31
  initialValues,
31
- values: formValues,
32
- fields,
32
+ values,
33
33
  setFieldValue,
34
+ fields,
34
35
  }: FormikProps<FormProps> & { fields: Record<string, unknown> }) => {
35
- const customTypes = useSelector(selectAllCustomTypes).filter(hasLocal);
36
-
37
- const options = customTypes.map((ct) => ({
38
- value: ct.local.id,
39
- label: ct.local.label,
40
- }));
41
-
42
- const selectValues = formValues.config.customtypes
43
- ? formValues.config.customtypes.map((id) => {
44
- const ct = customTypes.find(
45
- (frontendCustomType) => frontendCustomType.local.id === id,
46
- );
47
- return { value: ct?.local.id, label: ct?.local.label };
48
- })
49
- : null;
50
-
51
36
  return (
52
- <FlexGrid>
53
- {Object.entries(FormFields)
54
- .filter((e) => e[0] !== "customtypes")
55
- .map(([key, field]) => (
56
- <Col key={key}>
57
- <WidgetFormField
58
- fieldName={createFieldNameFromKey(key)}
59
- formField={field}
60
- fields={fields}
61
- initialValues={initialValues}
62
- />
63
- </Col>
64
- ))}
65
- <Col>
66
- <Box
67
- sx={{
68
- mt: 2,
69
- alignItems: "center",
37
+ <>
38
+ <FlexGrid>
39
+ {Object.entries(FormFields)
40
+ .filter((e) => e[0] !== "customtypes")
41
+ .map(([key, field]) => (
42
+ <Col key={key}>
43
+ <WidgetFormField
44
+ fieldName={createFieldNameFromKey(key)}
45
+ formField={field}
46
+ fields={fields}
47
+ initialValues={initialValues}
48
+ />
49
+ </Col>
50
+ ))}
51
+ </FlexGrid>
52
+ <Box mt={20}>
53
+ <ContentRelationshipFieldPicker
54
+ value={values.config.customtypes}
55
+ onChange={(fields) => {
56
+ void setFieldValue("config.customtypes", fields);
70
57
  }}
71
- >
72
- <Label htmlFor="origin" mb="1">
73
- Types
74
- </Label>
75
- <Select
76
- isMulti
77
- name="origin"
78
- options={options}
79
- onChange={(v) => {
80
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
81
- if (v) {
82
- void setFieldValue(
83
- "config.customtypes",
84
- v.map(({ value }) => value),
85
- );
86
- }
87
- }}
88
- value={selectValues}
89
- theme={(theme) => {
90
- return {
91
- ...theme,
92
- colors: {
93
- ...theme.colors,
94
- text: "text",
95
- primary: "background",
96
- },
97
- };
98
- }}
99
- />
100
- </Box>
101
- </Col>
102
- </FlexGrid>
58
+ />
59
+ </Box>
60
+ </>
103
61
  );
104
62
  };
105
63
 
@@ -7,17 +7,44 @@ import { Widget } from "../Widget";
7
7
  import Form, { FormFields } from "./Form";
8
8
 
9
9
  /**
10
+ * Legacy:
11
+ * {
12
+ * "type": "Link",
13
+ * "config": {
14
+ * "select": "document",
15
+ * "label": "relationship"
16
+ * "customtypes": [
17
+ * "page"
18
+ * ],
19
+ * }
20
+ * }
21
+ *
22
+ * Current format (field picking):
10
23
  * {
11
- "type": "Link",
12
- "config": {
13
- "select": "document",
14
- "customtypes": [
15
- "page"
16
- ],
17
- "label": "relationship"
18
- }
19
- }
20
- */
24
+ * "type": "Link",
25
+ * "config": {
26
+ * "select": "document",
27
+ * "label": "relationship"
28
+ * "customtypes": [
29
+ * {
30
+ * "id": "page",
31
+ * "fields": [
32
+ * "category",
33
+ * {
34
+ * "id": "countryRelation",
35
+ * "customtypes": [
36
+ * {
37
+ * "id": "country",
38
+ * "fields": ["name"]
39
+ * }
40
+ * ]
41
+ * }
42
+ * ]
43
+ * }
44
+ * ],
45
+ * }
46
+ * }
47
+ */
21
48
 
22
49
  const Meta = {
23
50
  icon: MdSettingsEthernet,
@@ -30,7 +57,7 @@ const contentRelationShipConfigSchema = linkConfigSchema.shape({
30
57
  .string()
31
58
  .required()
32
59
  .matches(/^document$/, { excludeEmptyString: true }),
33
- customtypes: yup.array(yup.string()).strict().optional(),
60
+ customtypes: yup.array().optional(),
34
61
  });
35
62
 
36
63
  const schema = yup.object().shape({
@@ -65,9 +92,12 @@ export const ContentRelationshipWidget: Widget<Link, typeof schema> = {
65
92
  return {
66
93
  ...initialValues,
67
94
  customtypes: initialValues.customtypes.filter((ct) =>
68
- customTypes.find(
69
- (frontendCustomType) => frontendCustomType.local.id === ct,
70
- ),
95
+ customTypes.find((frontendCustomType) => {
96
+ if (typeof ct === "string") {
97
+ return frontendCustomType.local.id === ct;
98
+ }
99
+ return frontendCustomType.local.id === ct.id;
100
+ }),
71
101
  ),
72
102
  };
73
103
  },
@@ -72,7 +72,7 @@ export const linkConfigSchema = yup
72
72
  .optional()
73
73
  .oneOf(["media", "document", "web", null])
74
74
  .nullable(),
75
- customtypes: yup.array(yup.string()).strict().optional(),
75
+ customtypes: yup.array().strict().optional(),
76
76
  masks: yup.array(yup.string()).optional(),
77
77
  tags: yup.array(yup.string()).optional(),
78
78
  allowTargetBlank: yup.boolean().strict().optional(),
@@ -2,5 +2,4 @@ export type LoadingStoreType = Record<LoadingKeysEnum, boolean>;
2
2
 
3
3
  export enum LoadingKeysEnum {
4
4
  LOGIN = "LOGIN",
5
- REVIEW = "REVIEW",
6
5
  }
@@ -34,10 +34,7 @@ import {
34
34
  changesPushSuccess,
35
35
  hasSeenChangesToolTipCreator,
36
36
  hasSeenSimulatorToolTipCreator,
37
- sendAReviewCreator,
38
- skipReviewCreator,
39
37
  } from "./userContext";
40
- import { UserReviewType } from "./userContext/types";
41
38
 
42
39
  const useSliceMachineActions = () => {
43
40
  const dispatch = useDispatch();
@@ -54,28 +51,12 @@ const useSliceMachineActions = () => {
54
51
  dispatch(modalOpenCreator({ modalKey: ModalKeysEnum.SCREENSHOT_PREVIEW }));
55
52
 
56
53
  // Loading module
57
- const startLoadingReview = () =>
58
- dispatch(startLoadingActionCreator({ loadingKey: LoadingKeysEnum.REVIEW }));
59
- const stopLoadingReview = () =>
60
- dispatch(stopLoadingActionCreator({ loadingKey: LoadingKeysEnum.REVIEW }));
61
54
  const startLoadingLogin = () =>
62
55
  dispatch(startLoadingActionCreator({ loadingKey: LoadingKeysEnum.LOGIN }));
63
56
  const stopLoadingLogin = () =>
64
57
  dispatch(stopLoadingActionCreator({ loadingKey: LoadingKeysEnum.LOGIN }));
65
58
 
66
59
  // UserContext module
67
- const skipReview = (reviewType: UserReviewType) =>
68
- dispatch(
69
- skipReviewCreator({
70
- reviewType,
71
- }),
72
- );
73
- const sendAReview = (reviewType: UserReviewType) =>
74
- dispatch(
75
- sendAReviewCreator({
76
- reviewType,
77
- }),
78
- );
79
60
  const setSeenSimulatorToolTip = () =>
80
61
  dispatch(hasSeenSimulatorToolTipCreator());
81
62
  const setSeenChangesToolTip = () => dispatch(hasSeenChangesToolTipCreator());
@@ -179,8 +160,6 @@ const useSliceMachineActions = () => {
179
160
  openLoginModal,
180
161
  startLoadingLogin,
181
162
  stopLoadingLogin,
182
- stopLoadingReview,
183
- startLoadingReview,
184
163
  deleteCustomTypeSuccess,
185
164
  renameCustomTypeSuccess,
186
165
  saveCustomTypeSuccess,
@@ -189,8 +168,6 @@ const useSliceMachineActions = () => {
189
168
  createSliceSuccess,
190
169
  renameSliceSuccess,
191
170
  deleteSliceSuccess,
192
- sendAReview,
193
- skipReview,
194
171
  setSeenSimulatorToolTip,
195
172
  setSeenChangesToolTip,
196
173
  openScreenshotPreviewModal,
@@ -2,12 +2,7 @@ import { Reducer } from "redux";
2
2
  import { ActionType, createAction, getType } from "typesafe-actions";
3
3
 
4
4
  import ErrorWithStatus from "@/legacy/lib/models/common/ErrorWithStatus";
5
- import {
6
- AuthStatus,
7
- UserContextStoreType,
8
- UserReviewState,
9
- UserReviewType,
10
- } from "@/modules/userContext/types";
5
+ import { AuthStatus, UserContextStoreType } from "@/modules/userContext/types";
11
6
  import { SliceMachineStoreType } from "@/redux/type";
12
7
 
13
8
  import { refreshStateCreator } from "../environment";
@@ -15,9 +10,6 @@ import { refreshStateCreator } from "../environment";
15
10
  // NOTE: Be careful every key written in this store is persisted in the localstorage
16
11
 
17
12
  const initialState: UserContextStoreType = {
18
- userReview: {
19
- onboarding: false,
20
- },
21
13
  hasSeenSimulatorToolTip: false,
22
14
  hasSeenChangesToolTip: false,
23
15
  authStatus: AuthStatus.UNKNOWN,
@@ -25,14 +17,6 @@ const initialState: UserContextStoreType = {
25
17
  };
26
18
 
27
19
  // Actions Creators
28
- export const sendAReviewCreator = createAction("USER_CONTEXT/SEND_REVIEW")<{
29
- reviewType: UserReviewType;
30
- }>();
31
-
32
- export const skipReviewCreator = createAction("USER_CONTEXT/SKIP_REVIEW")<{
33
- reviewType: UserReviewType;
34
- }>();
35
-
36
20
  export const hasSeenSimulatorToolTipCreator = createAction(
37
21
  "USER_CONTEXT/VIEW_SIMULATOR_TOOL_TIP",
38
22
  )();
@@ -46,8 +30,6 @@ export const changesPushSuccess = createAction(
46
30
  )();
47
31
 
48
32
  type userContextActions = ActionType<
49
- | typeof sendAReviewCreator
50
- | typeof skipReviewCreator
51
33
  | typeof hasSeenSimulatorToolTipCreator
52
34
  | typeof hasSeenChangesToolTipCreator
53
35
  | typeof refreshStateCreator
@@ -55,11 +37,6 @@ type userContextActions = ActionType<
55
37
  >;
56
38
 
57
39
  // Selectors
58
- export const getUserReview = (state: SliceMachineStoreType): UserReviewState =>
59
- state.userContext.userReview ?? {
60
- onboarding: state.userContext.hasSendAReview ?? false,
61
- };
62
-
63
40
  export const userHasSeenSimulatorToolTip = (
64
41
  state: SliceMachineStoreType,
65
42
  ): boolean => state.userContext.hasSeenSimulatorToolTip || false;
@@ -78,15 +55,6 @@ export const userContextReducer: Reducer<
78
55
  userContextActions
79
56
  > = (state = initialState, action) => {
80
57
  switch (action.type) {
81
- case getType(sendAReviewCreator):
82
- case getType(skipReviewCreator):
83
- return {
84
- ...state,
85
- userReview: {
86
- ...state.userReview,
87
- [action.payload.reviewType]: true,
88
- },
89
- };
90
58
  case getType(hasSeenSimulatorToolTipCreator): {
91
59
  return {
92
60
  ...state,
@@ -6,21 +6,8 @@ export enum AuthStatus {
6
6
  }
7
7
 
8
8
  export type UserContextStoreType = {
9
- userReview: UserReviewState;
10
9
  hasSeenSimulatorToolTip: boolean;
11
10
  hasSeenChangesToolTip: boolean;
12
11
  authStatus: AuthStatus;
13
12
  lastSyncChange: number | null;
14
- } & LegacyUserContextStoreType;
15
-
16
- export type UserReviewState = {
17
- onboarding: boolean;
18
- };
19
-
20
- export type UserReviewType = keyof UserReviewState;
21
-
22
- // Allow to handle old property that users can have
23
- // in their local storage
24
- type LegacyUserContextStoreType = {
25
- hasSendAReview?: boolean;
26
13
  };
@@ -13,25 +13,3 @@
13
13
  .react-datepicker-wrapper {
14
14
  width: 100%;
15
15
  }
16
-
17
- /* Review modal animation */
18
- .ReactModal__Overlay {
19
- z-index: 1;
20
- }
21
- .ReviewModal .ReactModal__Overlay {
22
- opacity: 0;
23
- transform: translateX(100px);
24
- transition: all 500ms ease-in-out;
25
- bottom: 16px;
26
- right: 16px;
27
- }
28
-
29
- .ReviewModal .ReactModal__Overlay--after-open {
30
- opacity: 1;
31
- transform: translateX(0px);
32
- }
33
-
34
- .ReviewModal .ReactModal__Overlay--before-close {
35
- opacity: 0;
36
- transform: translateX(100px);
37
- }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Ensure that the value is an record/object with string keys and existing
3
+ * properties. Accepts empty objects and objects created with
4
+ * `Object.create(null)`.
5
+ */
6
+ export function isValidObject(
7
+ value: unknown,
8
+ ): value is Record<string, unknown> {
9
+ if (typeof value !== "object" || value === null) return false;
10
+
11
+ if (Array.isArray(value)) return false;
12
+
13
+ if (
14
+ value instanceof Date ||
15
+ value instanceof RegExp ||
16
+ value instanceof Error
17
+ ) {
18
+ return false;
19
+ }
20
+
21
+ // Check if all keys are strings and all values are valid
22
+ for (const key in value) {
23
+ if (
24
+ typeof key !== "string" ||
25
+ !Object.prototype.hasOwnProperty.call(value, key)
26
+ ) {
27
+ return false;
28
+ }
29
+ }
30
+
31
+ return true;
32
+ }
@@ -1,11 +1,6 @@
1
1
  import { describe, expect, it } from "vitest";
2
2
 
3
- import {
4
- sendAReviewCreator,
5
- skipReviewCreator,
6
- userContextReducer,
7
- } from "@/modules/userContext";
8
- import { UserContextStoreType } from "@/modules/userContext/types";
3
+ import { userContextReducer } from "@/modules/userContext";
9
4
 
10
5
  describe("[UserContext module]", () => {
11
6
  describe("[Reducer]", () => {
@@ -18,49 +13,5 @@ describe("[UserContext module]", () => {
18
13
  // @ts-expect-error TS(2345) FIXME: Argument of type '{}' is not assignable to paramet... Remove this comment to see the full error message
19
14
  expect(userContextReducer({}, { type: "NO.MATCH" })).toEqual({});
20
15
  });
21
-
22
- it("should update user review onboarding to true when given USER_CONTEXT/SEND_REVIEW action", () => {
23
- // @ts-expect-error TS(2739) FIXME: Type '{ hasSendAReview: false;... Remove this comment to see the full error message
24
- const initialState: UserContextStoreType = {
25
- userReview: {
26
- onboarding: false,
27
- },
28
- };
29
-
30
- const action = sendAReviewCreator({
31
- reviewType: "onboarding",
32
- });
33
-
34
- const expectedState: UserContextStoreType = {
35
- ...initialState,
36
- userReview: {
37
- onboarding: true,
38
- },
39
- };
40
-
41
- expect(userContextReducer(initialState, action)).toEqual(expectedState);
42
- });
43
-
44
- it("should update user review onboarding to true when given USER_CONTEXT/SKIP_REVIEW action", () => {
45
- // @ts-expect-error TS(2739) FIXME: Type '{ hasSendAReview: false;... Remove this comment to see the full error message
46
- const initialState: UserContextStoreType = {
47
- userReview: {
48
- onboarding: false,
49
- },
50
- };
51
-
52
- const action = skipReviewCreator({
53
- reviewType: "onboarding",
54
- });
55
-
56
- const expectedState: UserContextStoreType = {
57
- ...initialState,
58
- userReview: {
59
- onboarding: true,
60
- },
61
- };
62
-
63
- expect(userContextReducer(initialState, action)).toEqual(expectedState);
64
- });
65
16
  });
66
17
  });
@@ -1 +0,0 @@
1
- self.__BUILD_MANIFEST=function(s,c,a,e,t,i,d,n,b,u,f,h,l,k,p,j,g,o,r){return{__rewrites:{afterFiles:[],beforeFiles:[],fallback:[]},"/":[a,p,j,"static/chunks/pages/index-0e27ae9805b59004.js"],"/_error":["static/chunks/pages/_error-fedd2c6ebd3d27b9.js"],"/changelog":[s,e,"static/chunks/870-a72b74312773efea.js","static/chunks/pages/changelog-80a618708f44f25f.js"],"/changes":[s,t,"static/chunks/8eec4907-b712959d9f984b68.js","static/chunks/918-fa4f2563cb5fd014.js",c,d,"static/css/d98ebc475f8423a3.css","static/chunks/pages/changes-d40c17939854b984.js"],"/custom-types":[a,p,j,"static/chunks/pages/custom-types-093f2e2213561492.js"],"/custom-types/[customTypeId]":[s,n,b,u,f,e,i,h,g,c,a,l,k,o,r,"static/chunks/pages/custom-types/[customTypeId]-61a3846ae1654f54.js"],"/labs":["static/chunks/pages/labs-c6df252ea5d8fb6f.js"],"/page-types/[pageTypeId]":[s,n,b,u,f,e,i,h,g,c,a,l,k,o,r,"static/chunks/pages/page-types/[pageTypeId]-91a4eb622fa3cb7c.js"],"/settings":["static/css/e5f781f20e24a5ea.css","static/chunks/pages/settings-0da3553b3a0acc99.js"],"/slices":[s,t,i,c,d,k,"static/css/efa5152b7c0f35c0.css","static/chunks/pages/slices-7e816c2b32cc6f19.js"],"/slices/[lib]/[sliceName]/[variation]":[s,t,n,b,u,f,e,i,h,c,l,d,"static/css/cdee5b195444f185.css","static/chunks/pages/slices/[lib]/[sliceName]/[variation]-c71823bf02dc292d.js"],"/slices/[lib]/[sliceName]/[variation]/simulator":[t,"static/chunks/72585f70-28b4d7d5384b3703.js","static/chunks/157-fca2f00f6df07660.js","static/chunks/pages/slices/[lib]/[sliceName]/[variation]/simulator-063fa88ba75f483e.js"],sortedPages:["/","/_app","/_error","/changelog","/changes","/custom-types","/custom-types/[customTypeId]","/labs","/page-types/[pageTypeId]","/settings","/slices","/slices/[lib]/[sliceName]/[variation]","/slices/[lib]/[sliceName]/[variation]/simulator"]}}("static/chunks/59b4e022-ef680789f7cc9b11.js","static/chunks/34-2911c905c8a6e9d9.js","static/chunks/867-8164160c810122c6.js","static/chunks/183-85de38d65a85dc2c.js","static/chunks/c8eae200-966ce352f7b5d2b9.js","static/chunks/44-a2056f993381ad0f.js","static/chunks/658-8231c0b729e0124a.js","static/chunks/f36c6662-1f3a854183168b10.js","static/chunks/4c744e84-480e426e4b1cfef3.js","static/chunks/065a3ddb-9a38ca0d60f0bf2f.js","static/chunks/1cc2734a-09fb3b997ad1eb70.js","static/chunks/349-7118116b93278f73.js","static/chunks/630-93339694ef30b82d.js","static/chunks/268-6d5fc7642a1b87c8.js","static/chunks/895-8c214ba470a4e23c.js","static/css/4e475d945cf8a890.css","static/chunks/385-b949173dfa03dd3e.js","static/chunks/882-28837678beff7e51.js","static/css/56f2a6684a524374.css"),self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();