slice-machine-ui 1.23.2-beta.1 → 1.23.2-beta.10

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 (122) hide show
  1. package/.depcheckrc +3 -0
  2. package/components/DeleteSliceModal/index.tsx +34 -24
  3. package/components/DeleteVariationModal/index.tsx +1 -0
  4. package/components/Forms/CreateCustomTypeModal/CreateCustomTypeModal.tsx +61 -38
  5. package/components/Forms/RenameCustomTypeModal/RenameCustomTypeModal.tsx +2 -2
  6. package/components/Forms/RenameSliceModal/RenameSliceModal.tsx +33 -21
  7. package/components/Forms/RenameVariationModal/RenameVariationModal.tsx +0 -1
  8. package/components/ModalFormCard/index.tsx +0 -1
  9. package/components/Navigation/ChangesListItem.tsx +14 -32
  10. package/components/Navigation/index.tsx +29 -12
  11. package/components/ReviewModal/ReviewForm.tsx +0 -1
  12. package/lib/builders/common/EditModal/Form.jsx +0 -1
  13. package/lib/builders/common/Zone/Card/components/NewField.tsx +0 -1
  14. package/lib/models/common/widgets/StructuredText/index.ts +1 -1
  15. package/out/404.html +1 -1
  16. package/out/_next/static/Dz7wwTNVdXvoAjySXz7mE/_buildManifest.js +1 -0
  17. package/out/_next/static/chunks/18539003-5f78714a35fde4a1.js +97 -0
  18. package/out/_next/static/chunks/25-01f422cea8066349.js +1 -0
  19. package/out/_next/static/chunks/318-99b5914b60bf1d17.js +1 -0
  20. package/out/_next/static/chunks/727-f8fefdd3e50cab2a.js +1 -0
  21. package/out/_next/static/chunks/777-8c5507e3b119b5dc.js +8 -0
  22. package/out/_next/static/chunks/799-b616401fe0dafdeb.js +1 -0
  23. package/out/_next/static/chunks/904-4653b7a849f4db94.js +1 -0
  24. package/out/_next/static/chunks/pages/_app-5ec41fc53c1f6405.js +434 -0
  25. package/out/_next/static/chunks/pages/{changelog-afd18276fe018b24.js → changelog-02cd80dad6f40878.js} +1 -1
  26. package/out/_next/static/chunks/pages/changes-8e9da8fbb809aad3.js +1 -0
  27. package/out/_next/static/chunks/pages/custom-types/{[customTypeId]-3f862ad6111a1fc0.js → [customTypeId]-97ab3b90b85d645d.js} +1 -1
  28. package/out/_next/static/chunks/pages/{custom-types-94b8f8dbf7727412.js → custom-types-3c8e721ec6802127.js} +1 -1
  29. package/out/_next/static/chunks/pages/index-cf93d16e9c63b6db.js +1 -0
  30. package/out/_next/static/chunks/pages/{labs-ee206005948f8e87.js → labs-39b50541a4c370bf.js} +1 -1
  31. package/out/_next/static/chunks/pages/page-types/{[pageTypeId]-d1ffca11c42f2603.js → [pageTypeId]-84a22c5e480d3fa9.js} +1 -1
  32. package/out/_next/static/chunks/pages/settings-879686e3a8759dc3.js +1 -0
  33. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/{simulator-897ca93c114a1435.js → simulator-c498e9c80cae8cce.js} +1 -1
  34. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-9b893c62b2f2fe4a.js +1 -0
  35. package/out/_next/static/chunks/pages/slices-4522d604117d8c66.js +1 -0
  36. package/out/_next/static/css/3c26dbbbd8f4be12.css +1 -0
  37. package/out/_next/static/css/{37153180c3b0dd66.css → 838fd8bb5a7c32b0.css} +1 -1
  38. package/out/_next/static/css/ca32882a5d2d8d88.css +1 -0
  39. package/out/changelog.html +1 -1
  40. package/out/changes.html +1 -1
  41. package/out/custom-types/[customTypeId].html +1 -1
  42. package/out/custom-types.html +1 -1
  43. package/out/index.html +1 -1
  44. package/out/labs.html +1 -1
  45. package/out/page-types/[pageTypeId].html +1 -1
  46. package/out/settings.html +1 -0
  47. package/out/slices/[lib]/[sliceName]/[variation]/simulator.html +1 -1
  48. package/out/slices/[lib]/[sliceName]/[variation].html +1 -1
  49. package/out/slices.html +1 -1
  50. package/package.json +9 -6
  51. package/pages/settings.tsx +1 -0
  52. package/pages/slices.tsx +20 -8
  53. package/postcss.config.js +10 -0
  54. package/src/apiClient.ts +1 -22
  55. package/src/components/FieldSet/FieldSet.stories.tsx +20 -11
  56. package/src/components/RelativeTime/RelativeTime.stories.tsx +25 -0
  57. package/src/components/RelativeTime/RelativeTime.tsx +40 -0
  58. package/src/components/RelativeTime/index.ts +1 -0
  59. package/src/domain/__tests__/customType.test.ts +205 -19
  60. package/src/domain/customType.ts +132 -7
  61. package/src/domain/slice.ts +38 -0
  62. package/src/features/customTypes/PageTypeOnboarding.tsx +21 -26
  63. package/src/features/customTypes/actions/convertCustomToPageType.ts +14 -10
  64. package/src/features/customTypes/actions/createCustomType.ts +69 -0
  65. package/src/features/customTypes/actions/deleteCustomType.ts +13 -3
  66. package/src/features/customTypes/actions/renameCustomType.ts +10 -4
  67. package/src/features/customTypes/customTypesBuilder/CustomTypesBuilderPage.tsx +3 -1
  68. package/src/features/customTypes/customTypesTable/CustomTypesTable.tsx +8 -8
  69. package/src/features/customTypes/customTypesTable/CustomTypesTablePage.tsx +18 -17
  70. package/src/features/environments/actions/setEnvironment.ts +2 -2
  71. package/src/features/settings/SettingsPage.tsx +47 -0
  72. package/src/features/settings/git/ConnectGitRepository.tsx +126 -0
  73. package/src/features/settings/git/ConnectGitRepositoryBlankSlate.tsx +33 -0
  74. package/src/features/settings/git/GitOwnerSelect.tsx +71 -0
  75. package/src/features/settings/git/GitProvider.ts +40 -0
  76. package/src/features/settings/git/GitProviderConnectButtons.tsx +63 -0
  77. package/src/features/settings/git/GitRepositoriesList.tsx +76 -0
  78. package/src/features/settings/git/GitRepositoriesSearch.tsx +69 -0
  79. package/src/features/settings/git/GitRepositoryConnectDialog.tsx +85 -0
  80. package/src/features/settings/git/GitRepositoryDisconnectDialog.tsx +60 -0
  81. package/src/features/settings/git/useGitIntegrationExperiment.ts +8 -0
  82. package/src/features/settings/git/useGitOwners.ts +12 -0
  83. package/src/features/settings/git/useGitRepos.ts +24 -0
  84. package/src/features/settings/git/useLinkedGitRepos.ts +41 -0
  85. package/src/features/settings/git/useWriteAPIToken.ts +23 -0
  86. package/src/features/slices/actions/createSlice.ts +5 -29
  87. package/src/features/slices/actions/deleteSlice.ts +33 -0
  88. package/src/features/slices/actions/renameSlice.ts +37 -0
  89. package/src/features/slices/convertLegacySlice/ConvertLegacySliceAsNewSliceDialog.tsx +0 -1
  90. package/src/features/slices/convertLegacySlice/ConvertLegacySliceAsNewVariationDialog.tsx +0 -1
  91. package/src/features/slices/convertLegacySlice/ConvertLegacySliceMergeWithIdenticalDialog.tsx +0 -1
  92. package/src/hooks/useUser.ts +14 -0
  93. package/src/icons/SettingsIcon.tsx +19 -0
  94. package/src/modules/availableCustomTypes/index.ts +29 -135
  95. package/src/modules/loading/types.ts +0 -5
  96. package/src/modules/modal/types.ts +0 -3
  97. package/src/modules/slices/index.ts +27 -193
  98. package/src/modules/slices/selector.ts +0 -14
  99. package/src/modules/useSliceMachineActions.ts +70 -89
  100. package/src/modules/userContext/index.ts +3 -3
  101. package/src/redux/saga.ts +0 -4
  102. package/test/src/modules/__fixtures__/serverState.ts +1 -2
  103. package/test/src/modules/availableCustomTypes/index.test.ts +2 -243
  104. package/test/src/modules/slices.test.ts +1 -267
  105. package/out/_next/static/chunks/18539003-5cc559566b738915.js +0 -97
  106. package/out/_next/static/chunks/25-37d6fa7f064be04b.js +0 -1
  107. package/out/_next/static/chunks/318-ce7e74f18f2d5b22.js +0 -1
  108. package/out/_next/static/chunks/376-7e784d6069e01654.js +0 -8
  109. package/out/_next/static/chunks/727-3a3bc32518778317.js +0 -1
  110. package/out/_next/static/chunks/731-501990ebe6a71b32.js +0 -1
  111. package/out/_next/static/chunks/904-9a4c1264727ae89a.js +0 -1
  112. package/out/_next/static/chunks/pages/_app-cd9d4c76a4abc11a.js +0 -432
  113. package/out/_next/static/chunks/pages/changes-2a976f9efeb719aa.js +0 -1
  114. package/out/_next/static/chunks/pages/index-64cfb8b0948ba8ef.js +0 -1
  115. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-b2a9d773ce5d7739.js +0 -1
  116. package/out/_next/static/chunks/pages/slices-e9c70c082ca3e3f9.js +0 -1
  117. package/out/_next/static/css/200244e3e0463c39.css +0 -1
  118. package/out/_next/static/m6psnC5u1xT7Y6osWHKjp/_buildManifest.js +0 -1
  119. package/src/features/customTypes/__tests__/createCustomType.test.ts +0 -159
  120. package/src/features/customTypes/customTypesTable/createCustomType.ts +0 -107
  121. package/test/components/CreateCustomTypeModal.test.tsx +0 -73
  122. /package/out/_next/static/{m6psnC5u1xT7Y6osWHKjp → Dz7wwTNVdXvoAjySXz7mE}/_ssgManifest.js +0 -0
@@ -1,21 +1,8 @@
1
1
  // @vitest-environment jsdom
2
2
 
3
3
  import { describe, expect, it } from "vitest";
4
- import {
5
- slicesReducer,
6
- deleteSliceCreator,
7
- // getFrontendSlices,
8
- deleteSliceSaga,
9
- } from "@src/modules/slices";
10
- import { testSaga } from "redux-saga-test-plan";
11
-
12
- import { deleteSlice } from "@src/apiClient";
13
- import { modalCloseCreator } from "@src/modules/modal";
4
+ import { slicesReducer } from "@src/modules/slices";
14
5
  import { SlicesStoreType } from "@src/modules/slices/types";
15
- import { openToasterCreator, ToasterType } from "@src/modules/toaster";
16
- import { LibraryUI } from "@lib/models/common/LibraryUI";
17
- // import { generateComponentUI, generateLibraryUI, generateSliceSM } from "./__fixtures__/sliceUtilsFactory";
18
- // import { SliceMachineStoreType } from "@src/redux/type";
19
6
 
20
7
  const dummySlicesState: SlicesStoreType = {
21
8
  libraries: [],
@@ -35,258 +22,5 @@ describe("[Slices module]", () => {
35
22
  dummySlicesState,
36
23
  );
37
24
  });
38
-
39
- it("should update the slice state given SLICES/DELETE.SUCCESS action", () => {
40
- const sliceIdToDelete = "id";
41
- const sliceNameToDelete = "slice-name";
42
- const libName = "libName";
43
-
44
- const originalState = { ...dummySlicesState };
45
-
46
- originalState["libraries"] = [
47
- {
48
- name: libName,
49
- isLocal: true,
50
- components: [
51
- { model: { id: sliceIdToDelete } },
52
- { model: { id: "second-slice" } },
53
- ],
54
- },
55
- ] as unknown as LibraryUI[];
56
-
57
- const action = deleteSliceCreator.success({
58
- sliceId: sliceIdToDelete,
59
- libName,
60
- sliceName: sliceNameToDelete,
61
- });
62
-
63
- const result = slicesReducer(originalState, action);
64
-
65
- const expectState = { ...originalState };
66
- expectState["libraries"] = [
67
- {
68
- name: libName,
69
- isLocal: true,
70
- components: [{ model: { id: "second-slice" } }],
71
- },
72
- ] as unknown as LibraryUI[];
73
-
74
- expect(result).toEqual(expectState);
75
- });
76
25
  });
77
-
78
- // describe("[renameSliceSaga]", () => {
79
- // it("should call the api and dispatch the good actions", () => {
80
- // const actionPayload = {
81
- // sliceId: "MySlice",
82
- // libName: "MyLib/Components",
83
- // newSliceName: "MyNewSlice",
84
- // };
85
- // const saga = testSaga(
86
- // renameSliceSaga,
87
- // renameSliceCreator.request(actionPayload)
88
- // );
89
-
90
- // saga
91
- // .next()
92
- // .call(
93
- // renameSlice,
94
- // actionPayload.sliceId,
95
- // actionPayload.newSliceName,
96
- // actionPayload.libName
97
- // );
98
- // saga.next().put(
99
- // renameSliceCreator.success({
100
- // libName: actionPayload.libName,
101
- // sliceId: actionPayload.sliceId,
102
- // newSliceName: actionPayload.newSliceName,
103
- // })
104
- // );
105
- // saga.next().put(modalCloseCreator());
106
- // saga.next().put(
107
- // openToasterCreator({
108
- // content: "Slice name updated",
109
- // type: ToasterType.SUCCESS,
110
- // })
111
- // );
112
- // saga.next().isDone();
113
- // });
114
- // });
115
-
116
- describe("[deleteSliceSaga]", () => {
117
- it("should call the api and dispatch the good actions on success", () => {
118
- const actionPayload = {
119
- sliceId: "id",
120
- sliceName: "name",
121
- libName: "lib",
122
- };
123
- const saga = testSaga(
124
- deleteSliceSaga,
125
- deleteSliceCreator.request(actionPayload),
126
- );
127
-
128
- saga
129
- .next()
130
- .call(deleteSlice, actionPayload.sliceId, actionPayload.libName);
131
- saga.next({ errors: [] }).put(deleteSliceCreator.success(actionPayload));
132
- saga.next().put(
133
- openToasterCreator({
134
- content: `Successfully deleted Slice “${actionPayload.sliceName}”`,
135
- type: ToasterType.SUCCESS,
136
- }),
137
- );
138
-
139
- saga.next().put(modalCloseCreator());
140
- saga.next().isDone();
141
- });
142
- it("should call the api and dispatch the good actions on unknown failure", () => {
143
- const actionPayload = {
144
- sliceId: "id",
145
- sliceName: "name",
146
- libName: "lib",
147
- };
148
- const saga = testSaga(
149
- deleteSliceSaga,
150
- deleteSliceCreator.request(actionPayload),
151
- );
152
-
153
- saga
154
- .next()
155
- .call(deleteSlice, actionPayload.sliceId, actionPayload.libName);
156
- saga.throw(new Error()).put(
157
- openToasterCreator({
158
- content: "An unexpected error happened while deleting your slice.",
159
- type: ToasterType.ERROR,
160
- }),
161
- );
162
-
163
- saga.next().put(modalCloseCreator());
164
- saga.next().isDone();
165
- });
166
- });
167
-
168
- // describe("[Selectors]", () => {
169
- // describe.only("getLocallyDeletedSlices", () => {
170
- // it("works as expected", () => {
171
- // const l1 = generateLibraryUI({
172
- // components: [
173
- // generateComponentUI({
174
- // model: generateSliceSM({ id: "1" }),
175
- // }),
176
- // generateComponentUI({
177
- // model: generateSliceSM({ id: "2" }),
178
- // }),
179
- // generateComponentUI({
180
- // model: generateSliceSM({ id: "3" }),
181
- // }),
182
- // ],
183
- // });
184
- // const l2 = generateLibraryUI({
185
- // components: [
186
- // generateComponentUI({
187
- // model: generateSliceSM({ id: "4" }),
188
- // }),
189
- // generateComponentUI({
190
- // model: generateSliceSM({ id: "5" }),
191
- // }),
192
- // ],
193
- // });
194
-
195
- // const remoteSlices = [
196
- // generateSliceSM({ id: "1" }),
197
- // generateSliceSM({ id: "3" }),
198
- // generateSliceSM({ id: "4" }),
199
- // generateSliceSM({ id: "6" }),
200
- // ];
201
-
202
- // const frontendSlices = getFrontendSlices({
203
- // slices: { libraries: [l1, l2], remoteSlices },
204
- // } as unknown as SliceMachineStoreType);
205
-
206
- // // it combines slices from all the local libraries
207
- // // it combines local and remote only libraries
208
- // // it maps the correct remote slice if found
209
- // expect(frontendSlices.length).toEqual(6);
210
- // expect(frontendSlices.map((s) => s.local?.id)).toEqual([
211
- // "1",
212
- // "2",
213
- // "3",
214
- // "4",
215
- // "5",
216
- // undefined,
217
- // ]);
218
- // expect(frontendSlices.map((s) => s.remote?.id)).toEqual([
219
- // "1",
220
- // undefined,
221
- // "3",
222
- // "4",
223
- // undefined,
224
- // "6",
225
- // ]);
226
- // });
227
- // });
228
- // });
229
26
  });
230
-
231
- // describe("[utils]", () => {
232
- // const PREV_NAME = "SliceName";
233
- // const NEW_NAME = "SliceRenamed";
234
- // it("test renameScreenshots", () => {
235
- // const initialPaths: Record<string, ScreenshotUI> = {
236
- // "default-variation": createScreenshotUI(PREV_NAME, "default-variation"),
237
- // "other-variation": createScreenshotUI(PREV_NAME, "other-variation"),
238
- // };
239
- // const expectedRenamedPaths: Record<string, ScreenshotUI> = {
240
- // "default-variation": createScreenshotUI(NEW_NAME, "default-variation"),
241
- // "other-variation": createScreenshotUI(NEW_NAME, "other-variation"),
242
- // };
243
- // expect(renameScreenshots(initialPaths, PREV_NAME, NEW_NAME)).toEqual(
244
- // expectedRenamedPaths
245
- // );
246
- // });
247
-
248
- // it("test renameScreenshotUrls", () => {
249
- // const initialUrls: Screenshots = {
250
- // "default-variation": {
251
- // hash: "xxx",
252
- // path: `../../e2e-projects/next/.slicemachine/assets/slices/ecommerce/${PREV_NAME}/default-variation/preview.png`,
253
- // url: `http://localhost:9999/api/__preview?q=..%2F..%2Fe2e-projects%2Fnext%2F.slicemachine%2Fassets%2Fslices%2Fecommerce%2F${PREV_NAME}%2Fdefault-slice%2Fpreview.png&uniq=0.39230892472268586`,
254
- // },
255
- // "other-variation": {
256
- // hash: "xxx",
257
- // path: `../../e2e-projects/next/.slicemachine/assets/slices/ecommerce/${PREV_NAME}/other-variation/preview.png`,
258
- // url: `http://localhost:9999/api/__preview?q=..%2F..%2Fe2e-projects%2Fnext%2F.slicemachine%2Fassets%2Fslices%2Fecommerce%2F${PREV_NAME}%2Fdefault-slice%2Fpreview.png&uniq=0.39230892472268586`,
259
- // },
260
- // };
261
- // const expectedRenamedUrls: Screenshots = {
262
- // "default-variation": {
263
- // hash: "xxx",
264
- // path: `../../e2e-projects/next/.slicemachine/assets/slices/ecommerce/${NEW_NAME}/default-variation/preview.png`,
265
- // url: `http://localhost:9999/api/__preview?q=..%2F..%2Fe2e-projects%2Fnext%2F.slicemachine%2Fassets%2Fslices%2Fecommerce%2F${NEW_NAME}%2Fdefault-slice%2Fpreview.png&uniq=0.39230892472268586`,
266
- // },
267
- // "other-variation": {
268
- // hash: "xxx",
269
- // path: `../../e2e-projects/next/.slicemachine/assets/slices/ecommerce/${NEW_NAME}/other-variation/preview.png`,
270
- // url: `http://localhost:9999/api/__preview?q=..%2F..%2Fe2e-projects%2Fnext%2F.slicemachine%2Fassets%2Fslices%2Fecommerce%2F${NEW_NAME}%2Fdefault-slice%2Fpreview.png&uniq=0.39230892472268586`,
271
- // },
272
- // };
273
- // expect(renameScreenshots(initialUrls, PREV_NAME, NEW_NAME)).toEqual(
274
- // expectedRenamedUrls
275
- // );
276
- // });
277
- // it("test renameModel", () => {
278
- // const initialModel: SliceSM = {
279
- // id: "slice_id",
280
- // name: PREV_NAME,
281
- // type: "SharedSlice",
282
- // variations: [],
283
- // };
284
- // const expectedModel: SliceSM = {
285
- // id: "slice_id",
286
- // name: NEW_NAME,
287
- // type: "SharedSlice",
288
- // variations: [],
289
- // };
290
- // expect(renameModel(initialModel, NEW_NAME)).toEqual(expectedModel);
291
- // });
292
- // });