slice-machine-ui 1.18.1-dev-next-release.2 → 1.18.1-dev-next-release.4
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/components/Button/index.tsx +2 -2
- package/components/Changelog/index.tsx +1 -1
- package/components/Changelog/versionDetails/UpdateCommandBox.tsx +1 -1
- package/components/ChangesItems/ChangesItems.tsx +2 -2
- package/components/CustomTypeTable/changesPage.tsx +1 -1
- package/components/DeleteDocumentsDrawer/HardDeleteDocumentsDrawer.tsx +3 -3
- package/components/DeleteDocumentsDrawer/ReferencesErrorDrawer.tsx +3 -3
- package/components/DeleteDocumentsDrawer/SoftDeleteDocumentsDrawer.tsx +3 -3
- package/components/DeleteSliceModal/index.tsx +1 -1
- package/components/FormFields/CheckboxControl.jsx +1 -1
- package/components/Forms/CreateCustomTypeModal/CreateCustomTypeModal.tsx +5 -5
- package/components/Forms/CreateSliceModal/CreateSliceModal.tsx +1 -1
- package/components/Forms/RenameSliceModal/RenameSliceModal.tsx +1 -1
- package/components/Forms/formsValidator.ts +2 -2
- package/components/Grid/index.tsx +1 -1
- package/components/Li/index.tsx +2 -2
- package/components/ListItem/index.tsx +2 -2
- package/components/ListItem/utils.js +1 -1
- package/components/LoginModal/index.tsx +2 -2
- package/components/ModalFormCard/index.tsx +2 -2
- package/components/Navigation/VideoItem.tsx +2 -2
- package/components/Navigation/index.test.tsx +8 -8
- package/components/Navigation/index.tsx +2 -2
- package/components/ReviewModal/ReviewForm.tsx +1 -1
- package/components/ReviewModal/ReviewModal.tsx +4 -4
- package/components/ScreenshotChangesModal/VariationDropZone.tsx +6 -6
- package/components/ScreenshotChangesModal/index.tsx +3 -3
- package/components/ScreenshotPreviewModal/index.tsx +2 -2
- package/components/Simulator/components/Header/index.tsx +1 -1
- package/components/Simulator/components/IframeRenderer/index.tsx +2 -2
- package/components/Simulator/components/SetupModal/index.tsx +1 -1
- package/components/Simulator/components/Toolbar/index.tsx +2 -2
- package/components/Simulator/index.tsx +5 -5
- package/components/Tooltip/TextWithTooltip.tsx +1 -1
- package/lib/builders/CustomTypeBuilder/SliceZone/List.tsx +2 -2
- package/lib/builders/CustomTypeBuilder/SliceZone/SlicesTemplatesModal.tsx +4 -4
- package/lib/builders/CustomTypeBuilder/SliceZone/UpdateSliceZoneModal.tsx +1 -1
- package/lib/builders/CustomTypeBuilder/SliceZone/index.tsx +12 -12
- package/lib/builders/CustomTypeBuilder/TabZone/index.tsx +1 -1
- package/lib/builders/CustomTypeBuilder/index.tsx +1 -1
- package/lib/builders/SliceBuilder/FieldZones/index.tsx +4 -4
- package/lib/builders/SliceBuilder/Header/SimulatorButton/index.tsx +1 -1
- package/lib/builders/SliceBuilder/Header/VariationsPopover/index.tsx +1 -1
- package/lib/builders/SliceBuilder/Header/index.tsx +2 -2
- package/lib/builders/SliceBuilder/index.tsx +2 -2
- package/lib/builders/common/EditModal/Form.jsx +1 -1
- package/lib/builders/common/EditModal/index.jsx +3 -3
- package/lib/builders/common/Zone/Card/components/NewField.tsx +7 -7
- package/lib/builders/common/Zone/index.jsx +2 -2
- package/lib/builders/utils/index.ts +1 -1
- package/lib/forms/defaults.ts +3 -3
- package/lib/forms/fields.ts +3 -3
- package/lib/forms/index.ts +3 -3
- package/lib/models/common/ComponentUI.ts +3 -3
- package/lib/models/common/CustomType/group.ts +2 -2
- package/lib/models/common/CustomType/index.ts +4 -4
- package/lib/models/common/CustomType/tab.ts +7 -7
- package/lib/models/common/ErrorWithStatus.ts +4 -1
- package/lib/models/common/Fields.ts +1 -1
- package/lib/models/common/Group.ts +5 -5
- package/lib/models/common/Library.ts +1 -1
- package/lib/models/common/Manifest.ts +4 -4
- package/lib/models/common/ModelData.ts +6 -6
- package/lib/models/common/ModelStatus/compareCustomTypeModels.ts +1 -1
- package/lib/models/common/ModelStatus/compareSliceModels.ts +4 -4
- package/lib/models/common/ModelStatus/index.ts +5 -5
- package/lib/models/common/Screenshots.ts +1 -1
- package/lib/models/common/Slice.ts +7 -7
- package/lib/models/common/Slices.ts +5 -5
- package/lib/models/common/UserProfile.ts +1 -1
- package/lib/models/common/Variation.ts +6 -6
- package/lib/models/common/normalizers/customType.ts +3 -3
- package/lib/models/common/normalizers/slices.ts +2 -2
- package/lib/models/common/widgets/Boolean/index.ts +2 -2
- package/lib/models/common/widgets/ContentRelationship/Form.tsx +2 -2
- package/lib/models/common/widgets/ContentRelationship/index.ts +2 -2
- package/lib/models/common/widgets/Group/ListItem/index.jsx +3 -3
- package/lib/models/common/widgets/Image/Form.tsx +3 -3
- package/lib/models/common/widgets/StructuredText/Form.tsx +2 -2
- package/lib/models/common/widgets/StructuredText/index.ts +2 -2
- package/lib/utils/index.ts +1 -1
- package/lib/utils/poll.ts +3 -3
- package/lib/utils/shared/customTypes.ts +1 -1
- package/next.config.mjs +3 -3
- package/out/404.html +1 -1
- package/out/_next/static/{4_g3bWryyxcdGzgi4MHr- → HGF5llOreY_Hv9IuGfW25}/_buildManifest.js +1 -1
- package/out/_next/static/chunks/125-e3857af2068bbedf.js +11 -0
- package/out/_next/static/chunks/pages/{_app-b2f6093b3f1e9f24.js → _app-925e9450acf20963.js} +12 -12
- package/out/changelog.html +1 -1
- package/out/changes.html +1 -1
- package/out/custom-types/[customTypeId].html +1 -1
- package/out/custom-types.html +1 -1
- package/out/index.html +1 -1
- package/out/labs.html +1 -1
- package/out/page-types/[pageTypeId].html +1 -1
- package/out/slices/[lib]/[sliceName]/[variation]/screenshot.html +1 -1
- package/out/slices/[lib]/[sliceName]/[variation]/simulator.html +1 -1
- package/out/slices/[lib]/[sliceName]/[variation].html +1 -1
- package/out/slices.html +1 -1
- package/package.json +5 -5
- package/pages/_app.tsx +1 -1
- package/pages/api/embed.js +1 -1
- package/pages/slices.tsx +4 -4
- package/src/apiClient.ts +11 -11
- package/src/components/BaseHoverCard/BaseHoverCard.test.tsx +1 -1
- package/src/components/HoverCard/HoverCard.tsx +1 -1
- package/src/components/SideNav/SideNav.tsx +2 -2
- package/src/components/Table/Table.test.tsx +1 -1
- package/src/components/TextLink/TextLink.tsx +1 -1
- package/src/domain/__tests__/CustomTypeModel.test.ts +19 -19
- package/src/domain/customType.ts +10 -10
- package/src/domain/slice.ts +5 -5
- package/src/features/changes/StatusBadge.tsx +1 -1
- package/src/features/customTypes/EditDropdown.tsx +1 -1
- package/src/features/customTypes/PageTypeOnboarding.tsx +2 -2
- package/src/features/customTypes/__tests__/CustomTypeBuilderPage.test.tsx +7 -7
- package/src/features/customTypes/__tests__/CustomTypesTablePage.test.tsx +24 -22
- package/src/features/customTypes/actions/convertCustomToPageType.ts +3 -3
- package/src/features/customTypes/actions/deleteCustomType.ts +1 -1
- package/src/features/customTypes/actions/renameCustomType.ts +1 -1
- package/src/features/customTypes/customTypesBuilder/CustomTypesBuilderPage.tsx +3 -3
- package/src/features/customTypes/customTypesConfig.ts +3 -3
- package/src/features/customTypes/customTypesTable/CustomTypesTable.tsx +2 -2
- package/src/features/customTypes/customTypesTable/CustomTypesTablePage.tsx +3 -3
- package/src/features/customTypes/customTypesTable/createCustomType.ts +2 -2
- package/src/features/customTypes/customTypesTable/useCustomTypes.ts +7 -7
- package/src/features/labs/labsList/LabsList.tsx +3 -3
- package/src/features/labs/labsList/useLab.tsx +1 -1
- package/src/features/slices/actions/addSlicesToSliceZone.ts +1 -1
- package/src/features/slices/convertLegacySlice/ConvertLegacySliceAsNewSliceDialog.tsx +2 -2
- package/src/features/slices/convertLegacySlice/ConvertLegacySliceAsNewVariationDialog.tsx +5 -5
- package/src/features/slices/convertLegacySlice/ConvertLegacySliceButton.tsx +11 -11
- package/src/features/slicesTemplates/useSlicesTemplates.ts +1 -1
- package/src/hooks/useCurrentSlice.tsx +2 -2
- package/src/hooks/useElementSize.ts +1 -1
- package/src/hooks/useModelStatus.ts +13 -10
- package/src/hooks/useRouteChange.tsx +1 -1
- package/src/hooks/useSMTracker.ts +2 -2
- package/src/hooks/useSliceMachineConfig.ts +1 -1
- package/src/hooks/useThrottle.ts +10 -7
- package/src/hooks/useUnSyncChanges.ts +5 -5
- package/src/hooks/useWindowDimensions.ts +1 -1
- package/src/modules/availableCustomTypes/index.ts +19 -19
- package/src/modules/environment/index.ts +6 -6
- package/src/modules/loading/index.ts +3 -3
- package/src/modules/modal/index.ts +2 -2
- package/src/modules/pushChangesSaga/index.ts +7 -7
- package/src/modules/pushChangesSaga/trackPushChangesSuccess.ts +3 -3
- package/src/modules/screenshots/actions.ts +2 -2
- package/src/modules/screenshots/sagas.ts +9 -9
- package/src/modules/selectedCustomType/actions.ts +10 -10
- package/src/modules/selectedCustomType/reducer.ts +26 -26
- package/src/modules/selectedCustomType/sagas.ts +5 -5
- package/src/modules/selectedCustomType/selectors.ts +4 -4
- package/src/modules/selectedCustomType/stateHelpers.ts +1 -1
- package/src/modules/selectedSlice/actions.ts +4 -4
- package/src/modules/selectedSlice/reducer.ts +7 -7
- package/src/modules/selectedSlice/sagas.ts +4 -4
- package/src/modules/selectedSlice/selectors.ts +5 -5
- package/src/modules/simulator/index.ts +20 -17
- package/src/modules/slices/index.ts +18 -18
- package/src/modules/toaster/index.tsx +3 -3
- package/src/modules/toaster/utils.tsx +1 -1
- package/src/modules/useSliceMachineActions.ts +43 -41
- package/src/modules/userContext/index.ts +9 -9
- package/src/redux/store.ts +2 -2
- package/src/theme.ts +1 -1
- package/src/utils/editor.ts +1 -1
- package/src/utils/fieldNameCreator.ts +2 -2
- package/test/__setup__.ts +18 -7
- package/test/__testutils__/createPrismicAuthLoginResponse.ts +1 -1
- package/test/__testutils__/createTestPlugin.ts +1 -1
- package/test/__testutils__/createTestProject.ts +3 -3
- package/test/__testutils__/index.tsx +1 -1
- package/test/__testutils__/mockAWSACLAPI.ts +9 -9
- package/test/__testutils__/mockCustomTypesAPI.ts +16 -16
- package/test/__testutils__/mockPrismicAuthAPI.ts +3 -3
- package/test/__testutils__/mockPrismicUserAPI.ts +4 -4
- package/test/__testutils__/readMSWFormData.ts +3 -3
- package/test/components/CreateCustomTypeModal.test.tsx +1 -1
- package/test/components/LoginModal.test.tsx +2 -2
- package/test/lib/builders/EditModal.test.tsx +5 -5
- package/test/lib/builders/buildersUtils.test.ts +13 -13
- package/test/lib/models/common/CustomType/sliceZone.test.ts +2 -2
- package/test/lib/models/common/ModelStatus.test.ts +1 -1
- package/test/lib/models/common/widgets/index.test.ts +6 -6
- package/test/lib/utils/shared/customTypes.test.ts +1 -1
- package/test/pages/custom-types.test.tsx +7 -7
- package/test/pages/simulator.test.tsx +5 -5
- package/test/pages/slices.test.tsx +4 -4
- package/test/src/hooks/useModelStatus.test.ts +2 -3
- package/test/src/modules/__fixtures__/sliceUtilsFactory.ts +2 -2
- package/test/src/modules/availableCustomTypes/index.test.ts +20 -18
- package/test/src/modules/environment.test.ts +2 -2
- package/test/src/modules/loading.test.ts +1 -1
- package/test/src/modules/modal.test.ts +1 -1
- package/test/src/modules/pushChangesSaga.test.ts +10 -10
- package/test/src/modules/screenshots/sagas.test.ts +5 -5
- package/test/src/modules/selectedCustomType/reducer.test.ts +25 -25
- package/test/src/modules/selectedCustomType/sagas.test.ts +3 -3
- package/test/src/modules/selectedSlice/__testutils__/getRefreshStateCreatorPayloadData.ts +1 -1
- package/test/src/modules/selectedSlice/reducer.test.ts +12 -12
- package/test/src/modules/selectedSlice/sagas.test.ts +6 -6
- package/test/src/modules/simulator.test.ts +10 -10
- package/test/src/modules/slices.test.ts +5 -5
- package/test/src/modules/toaster/utils.test.ts +3 -3
- package/test/src/normalizers/customType.test.ts +5 -5
- package/test/src/utils/fieldNameCreator.test.ts +1 -1
- package/out/_next/static/chunks/125-84464edfe25651eb.js +0 -19
- /package/out/_next/static/{4_g3bWryyxcdGzgi4MHr- → HGF5llOreY_Hv9IuGfW25}/_ssgManifest.js +0 -0
|
@@ -42,18 +42,18 @@ describe.each(formats)(
|
|
|
42
42
|
.closest("tr") as HTMLElement;
|
|
43
43
|
expect(within(row).getByText(customTypeMock.id)).toBeVisible();
|
|
44
44
|
expect(
|
|
45
|
-
within(row).getByText(customTypeMock.label as string)
|
|
45
|
+
within(row).getByText(customTypeMock.label as string),
|
|
46
46
|
).toBeVisible();
|
|
47
47
|
expect(
|
|
48
48
|
within(row).getByText(
|
|
49
|
-
customTypeMock.repeatable ? "Reusable" : "Single"
|
|
50
|
-
)
|
|
49
|
+
customTypeMock.repeatable ? "Reusable" : "Single",
|
|
50
|
+
),
|
|
51
51
|
).toBeVisible();
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
// Check that there is the correct number of custom types displayed
|
|
55
55
|
expect(screen.getAllByText(/MyID/)).toHaveLength(
|
|
56
|
-
customTypesMockByFormat[format].length
|
|
56
|
+
customTypesMockByFormat[format].length,
|
|
57
57
|
);
|
|
58
58
|
});
|
|
59
59
|
|
|
@@ -65,7 +65,7 @@ describe.each(formats)(
|
|
|
65
65
|
|
|
66
66
|
// Ensure the modal is visible
|
|
67
67
|
expect(
|
|
68
|
-
await screen.findByText(`Create a new ${format} type`)
|
|
68
|
+
await screen.findByText(`Create a new ${format} type`),
|
|
69
69
|
).toBeVisible();
|
|
70
70
|
|
|
71
71
|
// Scope the test to the modal
|
|
@@ -75,10 +75,10 @@ describe.each(formats)(
|
|
|
75
75
|
|
|
76
76
|
// Get form inputs
|
|
77
77
|
const idInput = within(form).getByPlaceholderText(
|
|
78
|
-
CUSTOM_TYPES_MESSAGES[format].inputPlaceholder
|
|
78
|
+
CUSTOM_TYPES_MESSAGES[format].inputPlaceholder,
|
|
79
79
|
);
|
|
80
80
|
const nameInput = within(form).getByPlaceholderText(
|
|
81
|
-
`A display name for the ${format} type
|
|
81
|
+
`A display name for the ${format} type`,
|
|
82
82
|
);
|
|
83
83
|
|
|
84
84
|
// Fill the form
|
|
@@ -95,7 +95,7 @@ describe.each(formats)(
|
|
|
95
95
|
// Check that the redirection has been done
|
|
96
96
|
if (format === "page") {
|
|
97
97
|
expect(mockRouter.asPath).toEqual(
|
|
98
|
-
`/${format}-types/${newCustomType}?newPageType=true
|
|
98
|
+
`/${format}-types/${newCustomType}?newPageType=true`,
|
|
99
99
|
);
|
|
100
100
|
} else {
|
|
101
101
|
expect(mockRouter.asPath).toEqual(`/${format}-types/${newCustomType}`);
|
|
@@ -125,7 +125,7 @@ describe.each(formats)(
|
|
|
125
125
|
// Check that the custom type is not visible
|
|
126
126
|
await waitFor(() => {
|
|
127
127
|
expect(
|
|
128
|
-
screen.queryByText(customTypesMockByFormat[format][0].id)
|
|
128
|
+
screen.queryByText(customTypesMockByFormat[format][0].id),
|
|
129
129
|
).not.toBeInTheDocument();
|
|
130
130
|
});
|
|
131
131
|
});
|
|
@@ -155,7 +155,7 @@ describe.each(formats)(
|
|
|
155
155
|
// Get form input
|
|
156
156
|
const renamedCustomType = `My renamed ${format} type`;
|
|
157
157
|
const nameInput = within(form).getByPlaceholderText(
|
|
158
|
-
`A display name for the ${format} type
|
|
158
|
+
`A display name for the ${format} type`,
|
|
159
159
|
);
|
|
160
160
|
|
|
161
161
|
// Clear the name and type a new one
|
|
@@ -168,7 +168,9 @@ describe.each(formats)(
|
|
|
168
168
|
// Check that the old custom type label is not visible anymore
|
|
169
169
|
await waitFor(() => {
|
|
170
170
|
expect(
|
|
171
|
-
screen.queryByText(
|
|
171
|
+
screen.queryByText(
|
|
172
|
+
customTypesMockByFormat[format][0].label as string,
|
|
173
|
+
),
|
|
172
174
|
).not.toBeInTheDocument();
|
|
173
175
|
});
|
|
174
176
|
|
|
@@ -184,10 +186,10 @@ describe.each(formats)(
|
|
|
184
186
|
|
|
185
187
|
// Check that the redirection has been done
|
|
186
188
|
expect(mockRouter.asPath).toEqual(
|
|
187
|
-
`/${format}-types/${customTypesMockByFormat[format][0].id}
|
|
189
|
+
`/${format}-types/${customTypesMockByFormat[format][0].id}`,
|
|
188
190
|
);
|
|
189
191
|
});
|
|
190
|
-
}
|
|
192
|
+
},
|
|
191
193
|
);
|
|
192
194
|
|
|
193
195
|
describe("CustomTypesTablePage > Custom type", () => {
|
|
@@ -212,21 +214,21 @@ describe("CustomTypesTablePage > Custom type", () => {
|
|
|
212
214
|
// Check that the custom type is not visible anymore
|
|
213
215
|
await waitFor(() => {
|
|
214
216
|
expect(
|
|
215
|
-
screen.queryByText(customTypesMockByFormat[format][0].label as string)
|
|
217
|
+
screen.queryByText(customTypesMockByFormat[format][0].label as string),
|
|
216
218
|
).not.toBeInTheDocument();
|
|
217
219
|
});
|
|
218
220
|
|
|
219
221
|
// Check that the converted custom type is visible on the page type table now
|
|
220
222
|
rerender(<CustomTypesTablePage format="page" />);
|
|
221
223
|
expect(
|
|
222
|
-
screen.getByText(customTypesMockByFormat[format][0].id)
|
|
224
|
+
screen.getByText(customTypesMockByFormat[format][0].id),
|
|
223
225
|
).toBeVisible();
|
|
224
226
|
});
|
|
225
227
|
});
|
|
226
228
|
|
|
227
229
|
function createCustomTypesMock(
|
|
228
230
|
format: CustomTypeFormat,
|
|
229
|
-
count: number
|
|
231
|
+
count: number,
|
|
230
232
|
): CustomType[] {
|
|
231
233
|
return Array.from(Array(count), (_, index) => ({
|
|
232
234
|
id: `MyID${format}${index}`,
|
|
@@ -275,7 +277,7 @@ async function renderCustomTypesTablePage({
|
|
|
275
277
|
});
|
|
276
278
|
hook("custom-type:read", (args: CustomTypeReadHookData) => {
|
|
277
279
|
const model = customTypesMock.find(
|
|
278
|
-
(customTypeMock) => customTypeMock.id === args.id
|
|
280
|
+
(customTypeMock) => customTypeMock.id === args.id,
|
|
279
281
|
);
|
|
280
282
|
|
|
281
283
|
if (model) {
|
|
@@ -304,7 +306,7 @@ async function renderCustomTypesTablePage({
|
|
|
304
306
|
createSliceMachineManagerMSWHandler({
|
|
305
307
|
url: "http://localhost:3000/_manager",
|
|
306
308
|
sliceMachineManager: manager,
|
|
307
|
-
})
|
|
309
|
+
}),
|
|
308
310
|
);
|
|
309
311
|
|
|
310
312
|
const customTypeMockStore = {
|
|
@@ -315,14 +317,14 @@ async function renderCustomTypesTablePage({
|
|
|
315
317
|
...obj,
|
|
316
318
|
[item.id]: { local: CustomTypes.toSM(item) },
|
|
317
319
|
}),
|
|
318
|
-
{}
|
|
320
|
+
{},
|
|
319
321
|
),
|
|
320
322
|
...customTypesMockByFormat.page.reduce(
|
|
321
323
|
(obj, item) => ({
|
|
322
324
|
...obj,
|
|
323
325
|
[item.id]: { local: CustomTypes.toSM(item) },
|
|
324
326
|
}),
|
|
325
|
-
{}
|
|
327
|
+
{},
|
|
326
328
|
),
|
|
327
329
|
},
|
|
328
330
|
environment: {
|
|
@@ -335,12 +337,12 @@ async function renderCustomTypesTablePage({
|
|
|
335
337
|
const renderResults = render(
|
|
336
338
|
<CustomTypesTablePage format={format} />,
|
|
337
339
|
// @ts-expect-error TS2345: Argument of type '{ preloadedState: { availableCustomTypes: {}; environment: { manifest: { apiEndpoint: string; }; }; slices: { libraries: never[]; remoteSlices: never[]; }; }; }' is not assignable to parameter of type 'Partial<{ preloadedState: Partial<SliceMachineStoreType>; store: Store<SliceMachineStoreType, AnyAction>; } & RenderOptions<...>>'.
|
|
338
|
-
customTypeMockStore
|
|
340
|
+
customTypeMockStore,
|
|
339
341
|
);
|
|
340
342
|
|
|
341
343
|
// Ensure table finished loading
|
|
342
344
|
expect(
|
|
343
|
-
await screen.findByText(customTypesMockByFormat[format][0].id)
|
|
345
|
+
await screen.findByText(customTypesMockByFormat[format][0].id),
|
|
344
346
|
).toBeVisible();
|
|
345
347
|
|
|
346
348
|
return renderResults;
|
|
@@ -9,7 +9,7 @@ import { CUSTOM_TYPES_MESSAGES } from "../customTypesMessages";
|
|
|
9
9
|
|
|
10
10
|
export async function convertCustomToPageType(
|
|
11
11
|
customType: CustomType,
|
|
12
|
-
saveCustomType: (customType: CustomType) => void
|
|
12
|
+
saveCustomType: (customType: CustomType) => void,
|
|
13
13
|
) {
|
|
14
14
|
const customTypesMessages =
|
|
15
15
|
CUSTOM_TYPES_MESSAGES[customType.format as CustomTypeFormat];
|
|
@@ -27,14 +27,14 @@ export async function convertCustomToPageType(
|
|
|
27
27
|
`${customTypesMessages.name({
|
|
28
28
|
start: true,
|
|
29
29
|
plural: false,
|
|
30
|
-
})} converted to page type
|
|
30
|
+
})} converted to page type`,
|
|
31
31
|
);
|
|
32
32
|
} catch (e) {
|
|
33
33
|
toast.error(
|
|
34
34
|
`Internal Error: ${customTypesMessages.name({
|
|
35
35
|
start: true,
|
|
36
36
|
plural: false,
|
|
37
|
-
})} not converted to page type
|
|
37
|
+
})} not converted to page type`,
|
|
38
38
|
);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
@@ -37,9 +37,9 @@ export const CustomTypesBuilderPage: FC = () => {
|
|
|
37
37
|
(store: SliceMachineStoreType) => ({
|
|
38
38
|
selectedCustomType: selectCustomTypeById(
|
|
39
39
|
store,
|
|
40
|
-
readBuilderPageDynamicSegment(router.query) as string
|
|
40
|
+
readBuilderPageDynamicSegment(router.query) as string,
|
|
41
41
|
),
|
|
42
|
-
})
|
|
42
|
+
}),
|
|
43
43
|
);
|
|
44
44
|
|
|
45
45
|
const { cleanupCustomTypeStore } = useSliceMachineActions();
|
|
@@ -94,7 +94,7 @@ const CustomTypesBuilderPageWithProvider: React.FC<
|
|
|
94
94
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
95
95
|
[
|
|
96
96
|
/* leave this empty to prevent local updates to disappear */
|
|
97
|
-
]
|
|
97
|
+
],
|
|
98
98
|
);
|
|
99
99
|
|
|
100
100
|
const { currentCustomType, hasPendingModifications, isSavingCustomType } =
|
|
@@ -28,15 +28,15 @@ export const CUSTOM_TYPES_CONFIG = {
|
|
|
28
28
|
|
|
29
29
|
export function matchesBuilderPagePathname(
|
|
30
30
|
pathname: string,
|
|
31
|
-
customTypeId: string
|
|
31
|
+
customTypeId: string,
|
|
32
32
|
): boolean {
|
|
33
33
|
return Object.values(CUSTOM_TYPES_CONFIG).some(({ getBuilderPagePathname }) =>
|
|
34
|
-
pathname.startsWith(getBuilderPagePathname(customTypeId))
|
|
34
|
+
pathname.startsWith(getBuilderPagePathname(customTypeId)),
|
|
35
35
|
);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
export function readBuilderPageDynamicSegment(
|
|
39
|
-
query: NextRouter["query"]
|
|
39
|
+
query: NextRouter["query"],
|
|
40
40
|
): string | undefined {
|
|
41
41
|
const customTypesConfigValues = Object.values(CUSTOM_TYPES_CONFIG);
|
|
42
42
|
for (const { builderPageDynamicSegment } of customTypesConfigValues) {
|
|
@@ -46,7 +46,7 @@ export const CustomTypesTable: FC<CustomTypesTableProps> = ({
|
|
|
46
46
|
const sortedCustomTypes = customTypes.sort(
|
|
47
47
|
(customType1: CustomType, customType2: CustomType) => {
|
|
48
48
|
return customType1.id.localeCompare(customType2.id);
|
|
49
|
-
}
|
|
49
|
+
},
|
|
50
50
|
);
|
|
51
51
|
const customTypesConfig = CUSTOM_TYPES_CONFIG[format];
|
|
52
52
|
const customTypesMessages = CUSTOM_TYPES_MESSAGES[format];
|
|
@@ -102,7 +102,7 @@ export const CustomTypesTable: FC<CustomTypesTableProps> = ({
|
|
|
102
102
|
key={id}
|
|
103
103
|
onClick={() => {
|
|
104
104
|
void router.push(
|
|
105
|
-
CUSTOM_TYPES_CONFIG[format].getBuilderPagePathname(id)
|
|
105
|
+
CUSTOM_TYPES_CONFIG[format].getBuilderPagePathname(id),
|
|
106
106
|
);
|
|
107
107
|
}}
|
|
108
108
|
>
|
|
@@ -38,9 +38,9 @@ export const CustomTypesTablePage: FC<CustomTypesTablePageProps> = ({
|
|
|
38
38
|
(store: SliceMachineStoreType) => ({
|
|
39
39
|
isCreatingCustomType: isLoading(
|
|
40
40
|
store,
|
|
41
|
-
LoadingKeysEnum.CREATE_CUSTOM_TYPE
|
|
41
|
+
LoadingKeysEnum.CREATE_CUSTOM_TYPE,
|
|
42
42
|
),
|
|
43
|
-
})
|
|
43
|
+
}),
|
|
44
44
|
);
|
|
45
45
|
|
|
46
46
|
return (
|
|
@@ -59,7 +59,7 @@ export const CustomTypesTablePage: FC<CustomTypesTablePageProps> = ({
|
|
|
59
59
|
<DefaultErrorMessage
|
|
60
60
|
title="Request failed"
|
|
61
61
|
description={`An error occurred while fetching your ${customTypesMessages.name(
|
|
62
|
-
{ start: false, plural: true }
|
|
62
|
+
{ start: false, plural: true },
|
|
63
63
|
)}.`}
|
|
64
64
|
/>
|
|
65
65
|
</Box>
|
|
@@ -5,7 +5,7 @@ export function createCustomType(
|
|
|
5
5
|
id: string,
|
|
6
6
|
label: string,
|
|
7
7
|
repeatable: boolean,
|
|
8
|
-
format: CustomTypeFormat
|
|
8
|
+
format: CustomTypeFormat,
|
|
9
9
|
): CustomType {
|
|
10
10
|
const mainTab = makeMainTab(repeatable, format);
|
|
11
11
|
|
|
@@ -21,7 +21,7 @@ export function createCustomType(
|
|
|
21
21
|
|
|
22
22
|
function makeMainTab(
|
|
23
23
|
repeatable: boolean,
|
|
24
|
-
format: CustomTypeFormat
|
|
24
|
+
format: CustomTypeFormat,
|
|
25
25
|
): CustomType["json"] {
|
|
26
26
|
if (repeatable === false && format === "page") {
|
|
27
27
|
return { ...DEFAULT_MAIN_WITH_SLICE_ZONE, ...DEFAULT_SEO_TAB };
|
|
@@ -16,11 +16,11 @@ type UseCustomTypesReturnType = {
|
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
export function useCustomTypes(
|
|
19
|
-
format: CustomTypeFormat
|
|
19
|
+
format: CustomTypeFormat,
|
|
20
20
|
): UseCustomTypesReturnType {
|
|
21
21
|
const updateCustomTypes = useCallback(
|
|
22
22
|
(data: CustomType[]) => updateData(getCustomTypes, [format], data),
|
|
23
|
-
[format]
|
|
23
|
+
[format],
|
|
24
24
|
);
|
|
25
25
|
|
|
26
26
|
return {
|
|
@@ -31,7 +31,7 @@ export function useCustomTypes(
|
|
|
31
31
|
|
|
32
32
|
async function getCustomTypes(format: CustomTypeFormat): Promise<CustomType[]> {
|
|
33
33
|
const { errors, models } = await managerClient.customTypes.readAllCustomTypes(
|
|
34
|
-
{ format }
|
|
34
|
+
{ format },
|
|
35
35
|
);
|
|
36
36
|
|
|
37
37
|
if (errors.length > 0) {
|
|
@@ -48,7 +48,7 @@ async function getCustomTypes(format: CustomTypeFormat): Promise<CustomType[]> {
|
|
|
48
48
|
export function useCustomTypesAutoRevalidation(
|
|
49
49
|
customTypes: CustomType[],
|
|
50
50
|
format: CustomTypeFormat,
|
|
51
|
-
updateCustomTypes: (data: CustomType[]) => void
|
|
51
|
+
updateCustomTypes: (data: CustomType[]) => void,
|
|
52
52
|
): void {
|
|
53
53
|
const { storeCustomTypes } = useSelector((store: SliceMachineStoreType) => ({
|
|
54
54
|
storeCustomTypes: selectAllCustomTypes(store).filter(hasLocal),
|
|
@@ -56,7 +56,7 @@ export function useCustomTypesAutoRevalidation(
|
|
|
56
56
|
|
|
57
57
|
useEffect(() => {
|
|
58
58
|
const storeCustomTypesFiltered = storeCustomTypes.filter(
|
|
59
|
-
({ local }) => local.format === format
|
|
59
|
+
({ local }) => local.format === format,
|
|
60
60
|
);
|
|
61
61
|
|
|
62
62
|
if (
|
|
@@ -66,7 +66,7 @@ export function useCustomTypesAutoRevalidation(
|
|
|
66
66
|
// the one from suspense because it could not be the same after some
|
|
67
67
|
// modifications (rename, add/remove field, new tab, etc.)
|
|
68
68
|
const currentCustomType = customTypes.find(
|
|
69
|
-
(ct2: CustomType) => ct2.id === ct.local.id
|
|
69
|
+
(ct2: CustomType) => ct2.id === ct.local.id,
|
|
70
70
|
);
|
|
71
71
|
|
|
72
72
|
return (
|
|
@@ -77,7 +77,7 @@ export function useCustomTypesAutoRevalidation(
|
|
|
77
77
|
})
|
|
78
78
|
) {
|
|
79
79
|
const newCustomTypes: CustomType[] = storeCustomTypesFiltered.map(
|
|
80
|
-
({ local }) => CustomTypes.fromSM(local)
|
|
80
|
+
({ local }) => CustomTypes.fromSM(local),
|
|
81
81
|
);
|
|
82
82
|
|
|
83
83
|
updateCustomTypes(newCustomTypes);
|
|
@@ -10,7 +10,7 @@ import { type UseLabArgs, type UseLabReturnType, useLab } from "./useLab";
|
|
|
10
10
|
export const LabsList: FC = () => {
|
|
11
11
|
const [legacySliceUpgraderLab, setLegacySliceUpgraderLab] = useLabWithToast(
|
|
12
12
|
"legacySliceUpgrader",
|
|
13
|
-
"Legacy Slice Upgrader"
|
|
13
|
+
"Legacy Slice Upgrader",
|
|
14
14
|
);
|
|
15
15
|
|
|
16
16
|
return (
|
|
@@ -53,7 +53,7 @@ function useLabWithToast(key: UseLabArgs, name: string): UseLabReturnType {
|
|
|
53
53
|
|
|
54
54
|
openToaster(
|
|
55
55
|
enabled ? `Labs: enabled ${name}` : `Labs: disabled ${name}`,
|
|
56
|
-
ToasterType.SUCCESS
|
|
56
|
+
ToasterType.SUCCESS,
|
|
57
57
|
);
|
|
58
58
|
} catch (error) {
|
|
59
59
|
console.error(error);
|
|
@@ -62,7 +62,7 @@ function useLabWithToast(key: UseLabArgs, name: string): UseLabReturnType {
|
|
|
62
62
|
enabled
|
|
63
63
|
? `Labs: failed to enable ${name}`
|
|
64
64
|
: `Labs: failed to disable ${name}`,
|
|
65
|
-
ToasterType.ERROR
|
|
65
|
+
ToasterType.ERROR,
|
|
66
66
|
);
|
|
67
67
|
}
|
|
68
68
|
};
|
|
@@ -6,7 +6,7 @@ export type UseLabArgs = keyof Required<SliceMachineConfig>["labs"];
|
|
|
6
6
|
|
|
7
7
|
export type UseLabReturnType = [
|
|
8
8
|
lab: { enabled: boolean },
|
|
9
|
-
setLab: (enabled: boolean) => Promise<void
|
|
9
|
+
setLab: (enabled: boolean) => Promise<void>,
|
|
10
10
|
];
|
|
11
11
|
|
|
12
12
|
export function useLab(key: UseLabArgs): UseLabReturnType {
|
|
@@ -86,14 +86,14 @@ export const ConvertLegacySliceAsNewSliceDialog: FC<DialogProps> = ({
|
|
|
86
86
|
</label>
|
|
87
87
|
<FormInput
|
|
88
88
|
placeholder={`Pascalised Slice API ID (e.g. ${pascalize(
|
|
89
|
-
slice.key
|
|
89
|
+
slice.key,
|
|
90
90
|
)})`}
|
|
91
91
|
error={typeof formik.errors.sliceName === "string"}
|
|
92
92
|
value={formik.values.sliceName}
|
|
93
93
|
onValueChange={(value) =>
|
|
94
94
|
void formik.setFieldValue(
|
|
95
95
|
"sliceName",
|
|
96
|
-
value.slice(0, 30)
|
|
96
|
+
value.slice(0, 30),
|
|
97
97
|
)
|
|
98
98
|
}
|
|
99
99
|
data-cy="slice-name-input"
|
|
@@ -137,7 +137,7 @@ export const ConvertLegacySliceAsNewVariationDialog: FC<DialogProps> = ({
|
|
|
137
137
|
|
|
138
138
|
if (inferIDFromName) {
|
|
139
139
|
values.variationID = Variation.generateId(
|
|
140
|
-
values.variationName
|
|
140
|
+
values.variationName,
|
|
141
141
|
);
|
|
142
142
|
}
|
|
143
143
|
|
|
@@ -163,7 +163,7 @@ export const ConvertLegacySliceAsNewVariationDialog: FC<DialogProps> = ({
|
|
|
163
163
|
setInferIDFromName(false);
|
|
164
164
|
void formik.setFieldValue(
|
|
165
165
|
"variationID",
|
|
166
|
-
Variation.generateId(value.slice(0, 30))
|
|
166
|
+
Variation.generateId(value.slice(0, 30)),
|
|
167
167
|
);
|
|
168
168
|
}}
|
|
169
169
|
data-cy="variation-id-input"
|
|
@@ -191,7 +191,7 @@ export const ConvertLegacySliceAsNewVariationDialog: FC<DialogProps> = ({
|
|
|
191
191
|
|
|
192
192
|
const validateAsNewVariationValues = (
|
|
193
193
|
values: FormValues,
|
|
194
|
-
libraries: readonly LibraryUI[]
|
|
194
|
+
libraries: readonly LibraryUI[],
|
|
195
195
|
): Partial<Record<keyof FormValues, string>> => {
|
|
196
196
|
const errors: Partial<Record<keyof FormValues, string>> = {};
|
|
197
197
|
|
|
@@ -199,7 +199,7 @@ const validateAsNewVariationValues = (
|
|
|
199
199
|
errors.libraryID = "Cannot be empty.";
|
|
200
200
|
}
|
|
201
201
|
const library = libraries.find(
|
|
202
|
-
(library) => library.path === values.libraryID
|
|
202
|
+
(library) => library.path === values.libraryID,
|
|
203
203
|
);
|
|
204
204
|
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
205
205
|
if (!errors.libraryID && !library) {
|
|
@@ -210,7 +210,7 @@ const validateAsNewVariationValues = (
|
|
|
210
210
|
errors.sliceID = "Cannot be empty.";
|
|
211
211
|
}
|
|
212
212
|
const slice = library?.components.find(
|
|
213
|
-
(component) => component.model.id === values.sliceID
|
|
213
|
+
(component) => component.model.id === values.sliceID,
|
|
214
214
|
);
|
|
215
215
|
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
216
216
|
if (!errors.sliceID && !slice) {
|
|
@@ -49,7 +49,7 @@ export const ConvertLegacySliceButton: FC<ConvertLegacySliceButtonProps> = ({
|
|
|
49
49
|
const { libraries: allLibraries } = useSelector(
|
|
50
50
|
(store: SliceMachineStoreType) => ({
|
|
51
51
|
libraries: getLibraries(store),
|
|
52
|
-
})
|
|
52
|
+
}),
|
|
53
53
|
);
|
|
54
54
|
|
|
55
55
|
const sliceName =
|
|
@@ -63,11 +63,11 @@ export const ConvertLegacySliceButton: FC<ConvertLegacySliceButtonProps> = ({
|
|
|
63
63
|
const identicalSlices = useIdenticalSlices(
|
|
64
64
|
slice,
|
|
65
65
|
sliceName,
|
|
66
|
-
localSharedSlices
|
|
66
|
+
localSharedSlices,
|
|
67
67
|
);
|
|
68
68
|
|
|
69
69
|
const convertLegacySliceAndTrack = async (
|
|
70
|
-
args: ConvertLegacySliceAndTrackArgs
|
|
70
|
+
args: ConvertLegacySliceAndTrackArgs,
|
|
71
71
|
) => {
|
|
72
72
|
if (!dialog) {
|
|
73
73
|
return;
|
|
@@ -103,7 +103,7 @@ export const ConvertLegacySliceButton: FC<ConvertLegacySliceButtonProps> = ({
|
|
|
103
103
|
|
|
104
104
|
openToaster(
|
|
105
105
|
`Could not convert slice \`${sliceName}\``,
|
|
106
|
-
ToasterType.ERROR
|
|
106
|
+
ToasterType.ERROR,
|
|
107
107
|
);
|
|
108
108
|
|
|
109
109
|
throw errors;
|
|
@@ -117,12 +117,12 @@ export const ConvertLegacySliceButton: FC<ConvertLegacySliceButtonProps> = ({
|
|
|
117
117
|
if (customTypeReadErrors.length || !customType) {
|
|
118
118
|
console.error(
|
|
119
119
|
`Could not refresh custom type view \`${path.customTypeID}\``,
|
|
120
|
-
customTypeReadErrors
|
|
120
|
+
customTypeReadErrors,
|
|
121
121
|
);
|
|
122
122
|
|
|
123
123
|
openToaster(
|
|
124
124
|
`Could not refresh custom type view \`${path.customTypeID}\``,
|
|
125
|
-
ToasterType.ERROR
|
|
125
|
+
ToasterType.ERROR,
|
|
126
126
|
);
|
|
127
127
|
|
|
128
128
|
return;
|
|
@@ -139,14 +139,14 @@ export const ConvertLegacySliceButton: FC<ConvertLegacySliceButtonProps> = ({
|
|
|
139
139
|
case "as_new_slice":
|
|
140
140
|
openToaster(
|
|
141
141
|
`${sliceName} has been upgraded to a new slice ${args.libraryID} > ${args.sliceID}`,
|
|
142
|
-
ToasterType.SUCCESS
|
|
142
|
+
ToasterType.SUCCESS,
|
|
143
143
|
);
|
|
144
144
|
break;
|
|
145
145
|
|
|
146
146
|
case "as_new_variation":
|
|
147
147
|
openToaster(
|
|
148
148
|
`${sliceName} has been converted as a variation of ${args.libraryID} > ${args.sliceID}`,
|
|
149
|
-
ToasterType.SUCCESS
|
|
149
|
+
ToasterType.SUCCESS,
|
|
150
150
|
);
|
|
151
151
|
break;
|
|
152
152
|
|
|
@@ -154,7 +154,7 @@ export const ConvertLegacySliceButton: FC<ConvertLegacySliceButtonProps> = ({
|
|
|
154
154
|
default:
|
|
155
155
|
openToaster(
|
|
156
156
|
`${sliceName} has been merged with ${args.libraryID} > ${args.sliceID}`,
|
|
157
|
-
ToasterType.SUCCESS
|
|
157
|
+
ToasterType.SUCCESS,
|
|
158
158
|
);
|
|
159
159
|
break;
|
|
160
160
|
}
|
|
@@ -235,7 +235,7 @@ export const ConvertLegacySliceButton: FC<ConvertLegacySliceButtonProps> = ({
|
|
|
235
235
|
const useIdenticalSlices = (
|
|
236
236
|
slice: NonSharedSliceInSliceZone,
|
|
237
237
|
sliceName: string,
|
|
238
|
-
localSharedSlices: ComponentUI[]
|
|
238
|
+
localSharedSlices: ComponentUI[],
|
|
239
239
|
) => {
|
|
240
240
|
return useMemo<IdenticalSlice[]>(() => {
|
|
241
241
|
const results: IdenticalSlice[] = [];
|
|
@@ -246,7 +246,7 @@ const useIdenticalSlices = (
|
|
|
246
246
|
for (const variation of sharedSlice.model.variations) {
|
|
247
247
|
const variationFields = getFieldMappingFingerprint(
|
|
248
248
|
variation,
|
|
249
|
-
sharedSlice.model.name
|
|
249
|
+
sharedSlice.model.name,
|
|
250
250
|
);
|
|
251
251
|
|
|
252
252
|
if (
|
|
@@ -18,7 +18,7 @@ const useCurrentSlice = (): UseCurrentSliceRet => {
|
|
|
18
18
|
slice: selectCurrentSlice(
|
|
19
19
|
store,
|
|
20
20
|
router.query.lib as string,
|
|
21
|
-
router.query.sliceName as string
|
|
21
|
+
router.query.sliceName as string,
|
|
22
22
|
),
|
|
23
23
|
}));
|
|
24
24
|
|
|
@@ -35,7 +35,7 @@ const useCurrentSlice = (): UseCurrentSliceRet => {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
const variation = slice.model.variations.find(
|
|
38
|
-
(variation) => variation.id === router.query.variation
|
|
38
|
+
(variation) => variation.id === router.query.variation,
|
|
39
39
|
);
|
|
40
40
|
|
|
41
41
|
if (!variation) {
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
|
|
8
8
|
export function useElementSize<E extends Element>(
|
|
9
9
|
callback: (size: ResizeObserverSize, element: E) => void,
|
|
10
|
-
deps: DependencyList
|
|
10
|
+
deps: DependencyList,
|
|
11
11
|
): RefCallback<E> {
|
|
12
12
|
const resizeObserverRef = useRef<ResizeObserver>();
|
|
13
13
|
return useCallback((element: E | null) => {
|
|
@@ -26,24 +26,27 @@ export interface ModelStatusInformation {
|
|
|
26
26
|
|
|
27
27
|
function computeStatuses(
|
|
28
28
|
models: LocalOrRemoteCustomType[],
|
|
29
|
-
userHasAccessToModels: boolean
|
|
29
|
+
userHasAccessToModels: boolean,
|
|
30
30
|
): { [sliceId: string]: ModelStatus };
|
|
31
31
|
function computeStatuses(
|
|
32
32
|
models: LocalOrRemoteSlice[],
|
|
33
|
-
userHasAccessToModels: boolean
|
|
33
|
+
userHasAccessToModels: boolean,
|
|
34
34
|
): { [sliceId: string]: ModelStatus };
|
|
35
35
|
function computeStatuses(
|
|
36
36
|
models: LocalOrRemoteModel[],
|
|
37
|
-
userHasAccessToModels: boolean
|
|
37
|
+
userHasAccessToModels: boolean,
|
|
38
38
|
) {
|
|
39
|
-
return models.reduce<{ [id: string]: ModelStatus }>(
|
|
40
|
-
|
|
39
|
+
return models.reduce<{ [id: string]: ModelStatus }>(
|
|
40
|
+
(acc, model) => {
|
|
41
|
+
const { status } = computeModelStatus(model, userHasAccessToModels);
|
|
41
42
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
return {
|
|
44
|
+
...acc,
|
|
45
|
+
[hasLocal(model) ? model.local.id : model.remote.id]: status,
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
{} as { [sliceId: string]: ModelStatus },
|
|
49
|
+
);
|
|
47
50
|
}
|
|
48
51
|
|
|
49
52
|
export const useModelStatus = ({
|
|
@@ -36,7 +36,7 @@ export function useRouteChange(): RouteChange {
|
|
|
36
36
|
const routeChange = useContext(RouteChangeContext);
|
|
37
37
|
if (routeChange === undefined)
|
|
38
38
|
throw new Error(
|
|
39
|
-
"useRouteChange must be used within a RouteChangeProvider."
|
|
39
|
+
"useRouteChange must be used within a RouteChangeProvider.",
|
|
40
40
|
);
|
|
41
41
|
return routeChange;
|
|
42
42
|
}
|