slice-machine-ui 1.23.2-beta.3 → 1.23.2-beta.5
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/DeleteSliceModal/index.tsx +34 -24
- package/components/Forms/CreateCustomTypeModal/CreateCustomTypeModal.tsx +61 -38
- package/components/Forms/RenameCustomTypeModal/RenameCustomTypeModal.tsx +2 -2
- package/components/Forms/RenameSliceModal/RenameSliceModal.tsx +33 -21
- package/components/Navigation/ChangesListItem.tsx +14 -32
- package/out/404.html +1 -1
- package/out/_next/static/W3x14bv5_NtxtSjAB0JUM/_buildManifest.js +1 -0
- package/out/_next/static/chunks/{183-aab7066c73ebde44.js → 183-4feb6bb3eddbc768.js} +1 -1
- package/out/_next/static/chunks/25-01f422cea8066349.js +1 -0
- package/out/_next/static/chunks/{318-2112803ca34b2f49.js → 318-34a2dea7cfd4661d.js} +1 -1
- package/out/_next/static/chunks/727-358d7fae68a880b3.js +1 -0
- package/out/_next/static/chunks/799-d95a93e965557aeb.js +1 -0
- package/out/_next/static/chunks/904-1ff7519adece2b55.js +1 -0
- package/out/_next/static/chunks/pages/{_app-9f3513533bb2dfb8.js → _app-a2fa2db79a1e9a1e.js} +37 -37
- package/out/_next/static/chunks/pages/{changes-2a976f9efeb719aa.js → changes-92c84f6cac0285fd.js} +1 -1
- package/out/_next/static/chunks/pages/custom-types/{[customTypeId]-3f862ad6111a1fc0.js → [customTypeId]-97ab3b90b85d645d.js} +1 -1
- package/out/_next/static/chunks/pages/{custom-types-94b8f8dbf7727412.js → custom-types-3c8e721ec6802127.js} +1 -1
- package/out/_next/static/chunks/pages/index-cf93d16e9c63b6db.js +1 -0
- package/out/_next/static/chunks/pages/page-types/{[pageTypeId]-d1ffca11c42f2603.js → [pageTypeId]-84a22c5e480d3fa9.js} +1 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/{simulator-897ca93c114a1435.js → simulator-52c3e1f9d14160b8.js} +1 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-608d206d10a719e3.js +1 -0
- package/out/_next/static/chunks/pages/slices-b0b58192a87df822.js +1 -0
- 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]/simulator.html +1 -1
- package/out/slices/[lib]/[sliceName]/[variation].html +1 -1
- package/out/slices.html +1 -1
- package/package.json +3 -3
- package/pages/slices.tsx +20 -8
- package/src/apiClient.ts +1 -22
- package/src/domain/__tests__/customType.test.ts +179 -0
- package/src/domain/customType.ts +110 -2
- package/src/domain/slice.ts +38 -0
- package/src/features/customTypes/PageTypeOnboarding.tsx +21 -26
- package/src/features/customTypes/actions/convertCustomToPageType.ts +14 -10
- package/src/features/customTypes/actions/createCustomType.ts +69 -0
- package/src/features/customTypes/actions/deleteCustomType.ts +13 -3
- package/src/features/customTypes/actions/renameCustomType.ts +10 -4
- package/src/features/customTypes/customTypesBuilder/CustomTypesBuilderPage.tsx +3 -1
- package/src/features/customTypes/customTypesTable/CustomTypesTable.tsx +8 -8
- package/src/features/customTypes/customTypesTable/CustomTypesTablePage.tsx +18 -17
- package/src/features/slices/actions/createSlice.ts +5 -29
- package/src/features/slices/actions/deleteSlice.ts +33 -0
- package/src/features/slices/actions/renameSlice.ts +37 -0
- package/src/modules/availableCustomTypes/index.ts +29 -135
- package/src/modules/loading/types.ts +0 -5
- package/src/modules/modal/types.ts +0 -3
- package/src/modules/slices/index.ts +27 -193
- package/src/modules/slices/selector.ts +0 -14
- package/src/modules/useSliceMachineActions.ts +70 -89
- package/src/modules/userContext/index.ts +3 -3
- package/src/redux/saga.ts +0 -4
- package/test/src/modules/availableCustomTypes/index.test.ts +2 -243
- package/test/src/modules/slices.test.ts +1 -267
- package/out/_next/static/RRBm5bm2F__Ws0vsvXhN6/_buildManifest.js +0 -1
- package/out/_next/static/chunks/25-37d6fa7f064be04b.js +0 -1
- package/out/_next/static/chunks/727-3a3bc32518778317.js +0 -1
- package/out/_next/static/chunks/731-501990ebe6a71b32.js +0 -1
- package/out/_next/static/chunks/904-9a4c1264727ae89a.js +0 -1
- package/out/_next/static/chunks/pages/index-64cfb8b0948ba8ef.js +0 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-b2a9d773ce5d7739.js +0 -1
- package/out/_next/static/chunks/pages/slices-e9c70c082ca3e3f9.js +0 -1
- package/src/features/customTypes/__tests__/createCustomType.test.ts +0 -159
- package/src/features/customTypes/customTypesTable/createCustomType.ts +0 -107
- package/test/components/CreateCustomTypeModal.test.tsx +0 -73
- /package/out/_next/static/{RRBm5bm2F__Ws0vsvXhN6 → W3x14bv5_NtxtSjAB0JUM}/_ssgManifest.js +0 -0
|
@@ -5,12 +5,7 @@ export enum LoadingKeysEnum {
|
|
|
5
5
|
REVIEW = "REVIEW",
|
|
6
6
|
CHECK_SIMULATOR = "CHECK_SIMULATOR",
|
|
7
7
|
CHECK_SIMULATOR_IFRAME = "CHECK_SIMULATOR_IFRAME",
|
|
8
|
-
CREATE_CUSTOM_TYPE = "CREATE_CUSTOM_TYPE",
|
|
9
|
-
SAVE_CUSTOM_TYPE = "SAVE_CUSTOM_TYPE",
|
|
10
|
-
RENAME_SLICE = "RENAME_SLICE",
|
|
11
8
|
GENERATE_SLICE_CUSTOM_SCREENSHOT = "GENERATE_SLICE_CUSTOM_SCREENSHOT",
|
|
12
|
-
SAVE_SLICE = "SAVE_SLICE",
|
|
13
|
-
DELETE_SLICE = "DELETE_SLICE",
|
|
14
9
|
SIMULATOR_SAVE_MOCK = "SIMULATOR_SAVE_MOCK",
|
|
15
10
|
CHANGELOG = "CHANGELOG",
|
|
16
11
|
}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
export enum ModalKeysEnum {
|
|
2
2
|
LOGIN = "LOGIN",
|
|
3
|
-
CREATE_CUSTOM_TYPE = "CREATE_CUSTOM_TYPE",
|
|
4
|
-
RENAME_SLICE = "RENAME_SLICE",
|
|
5
3
|
SCREENSHOT_PREVIEW = "SCREENSHOT_PREVIEW",
|
|
6
4
|
SCREENSHOTS = "SCREENSHOTS",
|
|
7
|
-
DELETE_SLICE = "DELETE_SLICE",
|
|
8
5
|
SIMULATOR_SETUP = "SIMULATOR_SETUP",
|
|
9
6
|
}
|
|
10
7
|
|
|
@@ -1,111 +1,49 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ActionType,
|
|
3
|
-
createAction,
|
|
4
|
-
createAsyncAction,
|
|
5
|
-
getType,
|
|
6
|
-
} from "typesafe-actions";
|
|
7
|
-
import {
|
|
8
|
-
call,
|
|
9
|
-
fork,
|
|
10
|
-
put,
|
|
11
|
-
SagaReturnType,
|
|
12
|
-
select,
|
|
13
|
-
takeLatest,
|
|
14
|
-
} from "redux-saga/effects";
|
|
1
|
+
import { ActionType, createAction, getType } from "typesafe-actions";
|
|
15
2
|
import { Reducer } from "redux";
|
|
16
3
|
|
|
17
4
|
import { LocalOrRemoteSlice } from "@lib/models/common/ModelData";
|
|
18
5
|
import { normalizeFrontendSlices } from "@lib/models/common/normalizers/slices";
|
|
19
6
|
import { SliceSM } from "@lib/models/common/Slice";
|
|
20
7
|
import { LibraryUI } from "@models/common/LibraryUI";
|
|
21
|
-
import {
|
|
22
|
-
import { LoadingKeysEnum } from "@src/modules/loading/types";
|
|
23
|
-
import { deleteSlice, renameSlice, SaveSliceMockRequest } from "@src/apiClient";
|
|
24
|
-
import { modalCloseCreator } from "@src/modules/modal";
|
|
8
|
+
import { SaveSliceMockRequest } from "@src/apiClient";
|
|
25
9
|
import { refreshStateCreator } from "@src/modules/environment";
|
|
26
10
|
import { SliceMachineStoreType } from "@src/redux/type";
|
|
27
|
-
import { openToasterCreator, ToasterType } from "@src/modules/toaster";
|
|
28
11
|
import { SlicesStoreType } from "./types";
|
|
29
12
|
import { ComponentUI, ScreenshotUI } from "@lib/models/common/ComponentUI";
|
|
30
|
-
import { selectSliceById } from "./selector";
|
|
31
|
-
import { ScreenshotGenerationMethod } from "@lib/models/common/Screenshots";
|
|
32
13
|
|
|
33
14
|
// Action Creators
|
|
34
|
-
export const
|
|
15
|
+
export const sliceCreateSuccess = createAction("SLICES/CREATE_SUCCESS")<{
|
|
35
16
|
libraries: Readonly<LibraryUI[]>;
|
|
36
17
|
}>();
|
|
37
18
|
|
|
38
|
-
export const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
)<
|
|
43
|
-
{
|
|
44
|
-
libName: string;
|
|
45
|
-
sliceId: string;
|
|
46
|
-
newSliceName: string;
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
libName: string;
|
|
50
|
-
renamedSlice: SliceSM;
|
|
51
|
-
}
|
|
52
|
-
>();
|
|
19
|
+
export const sliceRenameSuccess = createAction("SLICES/RENAME_SUCCESS")<{
|
|
20
|
+
libName: string;
|
|
21
|
+
renamedSlice: SliceSM;
|
|
22
|
+
}>();
|
|
53
23
|
|
|
54
|
-
export const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
)<
|
|
59
|
-
{
|
|
60
|
-
sliceId: string;
|
|
61
|
-
sliceName: string;
|
|
62
|
-
libName: string;
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
sliceId: string;
|
|
66
|
-
sliceName: string;
|
|
67
|
-
libName: string;
|
|
68
|
-
}
|
|
69
|
-
>();
|
|
24
|
+
export const sliceDeleteSuccess = createAction("SLICES/DELETE_SUCCESS")<{
|
|
25
|
+
sliceId: string;
|
|
26
|
+
libName: string;
|
|
27
|
+
}>();
|
|
70
28
|
|
|
71
|
-
export const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
"SLICE/UPDATE.FAILURE",
|
|
75
|
-
)<
|
|
76
|
-
{
|
|
77
|
-
component: ComponentUI;
|
|
78
|
-
setSliceBuilderState: () => void;
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
component: ComponentUI;
|
|
82
|
-
}
|
|
83
|
-
>();
|
|
29
|
+
export const sliceUpdateSuccess = createAction("SLICE/UPDATE_SUCCESS")<{
|
|
30
|
+
component: ComponentUI;
|
|
31
|
+
}>();
|
|
84
32
|
|
|
85
|
-
export const
|
|
86
|
-
"SLICE/
|
|
87
|
-
|
|
88
|
-
"SLICE/GENERATE_CUSTOM_SCREENSHOT.FAILURE",
|
|
89
|
-
)<
|
|
90
|
-
{
|
|
91
|
-
variationId: string;
|
|
92
|
-
component: ComponentUI;
|
|
93
|
-
file: Blob;
|
|
94
|
-
method: ScreenshotGenerationMethod;
|
|
95
|
-
},
|
|
96
|
-
{ variationId: string; screenshot: ScreenshotUI; component: ComponentUI }
|
|
97
|
-
>();
|
|
33
|
+
export const sliceGenerateCustomScreenshotSuccess = createAction(
|
|
34
|
+
"SLICE/GENERATE_CUSTOM_SCREENSHOT_SUCCESS",
|
|
35
|
+
)<{ variationId: string; screenshot: ScreenshotUI; component: ComponentUI }>();
|
|
98
36
|
|
|
99
37
|
export const updateSliceMock =
|
|
100
38
|
createAction("SLICE/UPDATE_MOCK")<SaveSliceMockRequest>();
|
|
101
39
|
|
|
102
40
|
type SlicesActions =
|
|
103
41
|
| ActionType<typeof refreshStateCreator>
|
|
104
|
-
| ActionType<typeof
|
|
105
|
-
| ActionType<typeof
|
|
106
|
-
| ActionType<typeof
|
|
107
|
-
| ActionType<typeof
|
|
108
|
-
| ActionType<typeof
|
|
42
|
+
| ActionType<typeof sliceCreateSuccess>
|
|
43
|
+
| ActionType<typeof sliceRenameSuccess>
|
|
44
|
+
| ActionType<typeof sliceDeleteSuccess>
|
|
45
|
+
| ActionType<typeof sliceUpdateSuccess>
|
|
46
|
+
| ActionType<typeof sliceGenerateCustomScreenshotSuccess>
|
|
109
47
|
| ActionType<typeof updateSliceMock>;
|
|
110
48
|
|
|
111
49
|
// Selectors
|
|
@@ -143,12 +81,12 @@ export const slicesReducer: Reducer<SlicesStoreType | null, SlicesActions> = (
|
|
|
143
81
|
libraries: action.payload.libraries,
|
|
144
82
|
remoteSlices: action.payload.remoteSlices,
|
|
145
83
|
};
|
|
146
|
-
case getType(
|
|
84
|
+
case getType(sliceCreateSuccess):
|
|
147
85
|
return {
|
|
148
86
|
...state,
|
|
149
87
|
libraries: action.payload.libraries,
|
|
150
88
|
};
|
|
151
|
-
case getType(
|
|
89
|
+
case getType(sliceRenameSuccess): {
|
|
152
90
|
const { libName, renamedSlice } = action.payload;
|
|
153
91
|
const newLibs = state.libraries.map((library) => {
|
|
154
92
|
if (library.name !== libName) return library;
|
|
@@ -169,7 +107,7 @@ export const slicesReducer: Reducer<SlicesStoreType | null, SlicesActions> = (
|
|
|
169
107
|
libraries: newLibs,
|
|
170
108
|
};
|
|
171
109
|
}
|
|
172
|
-
case getType(
|
|
110
|
+
case getType(sliceUpdateSuccess): {
|
|
173
111
|
const newComponentUI = action.payload.component;
|
|
174
112
|
|
|
175
113
|
const newLibraries = state.libraries.map((library) => {
|
|
@@ -186,7 +124,7 @@ export const slicesReducer: Reducer<SlicesStoreType | null, SlicesActions> = (
|
|
|
186
124
|
|
|
187
125
|
return { ...state, libraries: newLibraries };
|
|
188
126
|
}
|
|
189
|
-
case getType(
|
|
127
|
+
case getType(sliceGenerateCustomScreenshotSuccess): {
|
|
190
128
|
const { component, screenshot, variationId } = action.payload;
|
|
191
129
|
|
|
192
130
|
const newLibraries = state.libraries.map((library) => {
|
|
@@ -209,7 +147,7 @@ export const slicesReducer: Reducer<SlicesStoreType | null, SlicesActions> = (
|
|
|
209
147
|
|
|
210
148
|
return { ...state, libraries: newLibraries };
|
|
211
149
|
}
|
|
212
|
-
case getType(
|
|
150
|
+
case getType(sliceDeleteSuccess): {
|
|
213
151
|
const { libName, sliceId } = action.payload;
|
|
214
152
|
const newLibs = state.libraries.map((library) => {
|
|
215
153
|
if (library.name !== libName) return library;
|
|
@@ -254,107 +192,3 @@ export const slicesReducer: Reducer<SlicesStoreType | null, SlicesActions> = (
|
|
|
254
192
|
return state;
|
|
255
193
|
}
|
|
256
194
|
};
|
|
257
|
-
|
|
258
|
-
// Sagas
|
|
259
|
-
|
|
260
|
-
export function* renameSliceSaga({
|
|
261
|
-
payload,
|
|
262
|
-
}: ReturnType<typeof renameSliceCreator.request>) {
|
|
263
|
-
const { libName, sliceId, newSliceName } = payload;
|
|
264
|
-
try {
|
|
265
|
-
const slice = (yield select((store: SliceMachineStoreType) =>
|
|
266
|
-
selectSliceById(store, libName, sliceId),
|
|
267
|
-
)) as ReturnType<typeof selectSliceById>;
|
|
268
|
-
if (!slice) {
|
|
269
|
-
throw new Error(
|
|
270
|
-
`Slice "${payload.sliceId} in the "${payload.libName}" library not found.`,
|
|
271
|
-
);
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
const renamedSlice = renameSliceModel({
|
|
275
|
-
slice: slice.model,
|
|
276
|
-
newName: newSliceName,
|
|
277
|
-
});
|
|
278
|
-
|
|
279
|
-
yield call(renameSlice, renamedSlice, libName);
|
|
280
|
-
yield put(renameSliceCreator.success({ libName, renamedSlice }));
|
|
281
|
-
|
|
282
|
-
yield put(modalCloseCreator());
|
|
283
|
-
yield put(
|
|
284
|
-
openToasterCreator({
|
|
285
|
-
content: "Slice name updated",
|
|
286
|
-
type: ToasterType.SUCCESS,
|
|
287
|
-
}),
|
|
288
|
-
);
|
|
289
|
-
} catch (e) {
|
|
290
|
-
yield put(
|
|
291
|
-
openToasterCreator({
|
|
292
|
-
content: "Internal Error: Slice name not saved",
|
|
293
|
-
type: ToasterType.ERROR,
|
|
294
|
-
}),
|
|
295
|
-
);
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
function* watchRenameSlice() {
|
|
300
|
-
yield takeLatest(
|
|
301
|
-
getType(renameSliceCreator.request),
|
|
302
|
-
withLoader(renameSliceSaga, LoadingKeysEnum.RENAME_SLICE),
|
|
303
|
-
);
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
export function* deleteSliceSaga({
|
|
307
|
-
payload,
|
|
308
|
-
}: ReturnType<typeof deleteSliceCreator.request>) {
|
|
309
|
-
const { libName, sliceId, sliceName } = payload;
|
|
310
|
-
try {
|
|
311
|
-
const result = (yield call(
|
|
312
|
-
deleteSlice,
|
|
313
|
-
sliceId,
|
|
314
|
-
libName,
|
|
315
|
-
)) as SagaReturnType<typeof deleteSlice>;
|
|
316
|
-
if (result.errors.length > 0) {
|
|
317
|
-
throw result.errors;
|
|
318
|
-
}
|
|
319
|
-
yield put(deleteSliceCreator.success(payload));
|
|
320
|
-
yield put(
|
|
321
|
-
openToasterCreator({
|
|
322
|
-
content: `Successfully deleted Slice “${sliceName}”`,
|
|
323
|
-
type: ToasterType.SUCCESS,
|
|
324
|
-
}),
|
|
325
|
-
);
|
|
326
|
-
} catch (e) {
|
|
327
|
-
yield put(
|
|
328
|
-
openToasterCreator({
|
|
329
|
-
content: "An unexpected error happened while deleting your slice.",
|
|
330
|
-
type: ToasterType.ERROR,
|
|
331
|
-
}),
|
|
332
|
-
);
|
|
333
|
-
}
|
|
334
|
-
yield put(modalCloseCreator());
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
function* watchDeleteSlice() {
|
|
338
|
-
yield takeLatest(
|
|
339
|
-
getType(deleteSliceCreator.request),
|
|
340
|
-
withLoader(deleteSliceSaga, LoadingKeysEnum.DELETE_SLICE),
|
|
341
|
-
);
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
// Saga Exports
|
|
345
|
-
export function* watchSliceSagas() {
|
|
346
|
-
yield fork(watchRenameSlice);
|
|
347
|
-
yield fork(watchDeleteSlice);
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
type RenameSliceModelArgs = {
|
|
351
|
-
slice: SliceSM;
|
|
352
|
-
newName: string;
|
|
353
|
-
};
|
|
354
|
-
|
|
355
|
-
export function renameSliceModel(args: RenameSliceModelArgs): SliceSM {
|
|
356
|
-
return {
|
|
357
|
-
...args.slice,
|
|
358
|
-
name: args.newName,
|
|
359
|
-
};
|
|
360
|
-
}
|
|
@@ -2,20 +2,6 @@ import { SliceMachineStoreType } from "@src/redux/type";
|
|
|
2
2
|
|
|
3
3
|
import { getLibraries } from "./index";
|
|
4
4
|
|
|
5
|
-
export const selectSliceById = (
|
|
6
|
-
store: SliceMachineStoreType,
|
|
7
|
-
libraryName: string,
|
|
8
|
-
sliceId: string,
|
|
9
|
-
) => {
|
|
10
|
-
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
11
|
-
const libraries = getLibraries(store) || [];
|
|
12
|
-
|
|
13
|
-
const library = libraries.find((library) => library.name === libraryName);
|
|
14
|
-
const slice = library?.components.find((c) => c.model.id === sliceId);
|
|
15
|
-
|
|
16
|
-
return slice;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
5
|
export const selectCurrentSlice = (
|
|
20
6
|
store: SliceMachineStoreType,
|
|
21
7
|
lib: string,
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
hasSeenTutorialsToolTipCreator,
|
|
11
11
|
hasSeenSimulatorToolTipCreator,
|
|
12
12
|
hasSeenChangesToolTipCreator,
|
|
13
|
-
|
|
13
|
+
changesPushSuccess,
|
|
14
14
|
} from "./userContext";
|
|
15
15
|
import { getChangelogCreator, refreshStateCreator } from "./environment";
|
|
16
16
|
import {
|
|
@@ -19,17 +19,17 @@ import {
|
|
|
19
19
|
} from "./simulator";
|
|
20
20
|
import ServerState from "@models/server/ServerState";
|
|
21
21
|
import {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
customTypeCreateSuccess,
|
|
23
|
+
customTypeDeleteSuccess,
|
|
24
|
+
customTypeRenameSuccess,
|
|
25
|
+
customTypeSaveSuccess,
|
|
26
26
|
} from "./availableCustomTypes";
|
|
27
27
|
import {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
sliceCreateSuccess,
|
|
29
|
+
sliceDeleteSuccess,
|
|
30
|
+
sliceGenerateCustomScreenshotSuccess,
|
|
31
|
+
sliceUpdateSuccess,
|
|
32
|
+
sliceRenameSuccess,
|
|
33
33
|
} from "./slices";
|
|
34
34
|
import { UserContextStoreType, UserReviewType } from "./userContext/types";
|
|
35
35
|
import { GenericToastTypes, openToasterCreator } from "./toaster";
|
|
@@ -38,8 +38,8 @@ import { CustomType } from "@prismicio/types-internal/lib/customtypes";
|
|
|
38
38
|
import { ComponentUI, ScreenshotUI } from "../../lib/models/common/ComponentUI";
|
|
39
39
|
import { saveSliceMockCreator } from "./simulator";
|
|
40
40
|
import { SaveSliceMockRequest } from "@src/apiClient";
|
|
41
|
-
import { CustomTypeFormat } from "@slicemachine/manager";
|
|
42
41
|
import { LibraryUI } from "@lib/models/common/LibraryUI";
|
|
42
|
+
import { SliceSM } from "@lib/models/common/Slice";
|
|
43
43
|
|
|
44
44
|
const useSliceMachineActions = () => {
|
|
45
45
|
const dispatch = useDispatch();
|
|
@@ -62,14 +62,8 @@ const useSliceMachineActions = () => {
|
|
|
62
62
|
dispatch(modalOpenCreator({ modalKey: ModalKeysEnum.LOGIN }));
|
|
63
63
|
const openScreenshotsModal = () =>
|
|
64
64
|
dispatch(modalOpenCreator({ modalKey: ModalKeysEnum.SCREENSHOTS }));
|
|
65
|
-
const openRenameSliceModal = () =>
|
|
66
|
-
dispatch(modalOpenCreator({ modalKey: ModalKeysEnum.RENAME_SLICE }));
|
|
67
|
-
const openCreateCustomTypeModal = () =>
|
|
68
|
-
dispatch(modalOpenCreator({ modalKey: ModalKeysEnum.CREATE_CUSTOM_TYPE }));
|
|
69
65
|
const openScreenshotPreviewModal = () =>
|
|
70
66
|
dispatch(modalOpenCreator({ modalKey: ModalKeysEnum.SCREENSHOT_PREVIEW }));
|
|
71
|
-
const openDeleteSliceModal = () =>
|
|
72
|
-
dispatch(modalOpenCreator({ modalKey: ModalKeysEnum.DELETE_SLICE }));
|
|
73
67
|
const openSimulatorSetupModal = () =>
|
|
74
68
|
dispatch(modalOpenCreator({ modalKey: ModalKeysEnum.SIMULATOR_SETUP }));
|
|
75
69
|
|
|
@@ -104,122 +98,112 @@ const useSliceMachineActions = () => {
|
|
|
104
98
|
dispatch(hasSeenTutorialsToolTipCreator());
|
|
105
99
|
const setSeenChangesToolTip = () => dispatch(hasSeenChangesToolTipCreator());
|
|
106
100
|
|
|
107
|
-
//
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
101
|
+
// Toaster store
|
|
102
|
+
const openToaster = (
|
|
103
|
+
content: string | React.ReactNode,
|
|
104
|
+
type: GenericToastTypes,
|
|
105
|
+
) => dispatch(openToasterCreator({ content, type }));
|
|
106
|
+
|
|
107
|
+
// Simulator
|
|
108
|
+
const saveSliceMock = (payload: SaveSliceMockRequest) =>
|
|
109
|
+
dispatch(saveSliceMockCreator.request(payload));
|
|
110
|
+
|
|
111
|
+
// State Action (used by multiple stores)
|
|
112
|
+
const refreshState = (serverState: ServerState) => {
|
|
114
113
|
dispatch(
|
|
115
|
-
|
|
114
|
+
refreshStateCreator({
|
|
115
|
+
env: serverState.env,
|
|
116
|
+
remoteCustomTypes: serverState.remoteCustomTypes,
|
|
117
|
+
localCustomTypes: serverState.customTypes,
|
|
118
|
+
libraries: serverState.libraries,
|
|
119
|
+
remoteSlices: serverState.remoteSlices,
|
|
120
|
+
clientError: serverState.clientError,
|
|
121
|
+
}),
|
|
116
122
|
);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const getChangelog = () => {
|
|
126
|
+
dispatch(getChangelogCreator.request());
|
|
127
|
+
};
|
|
117
128
|
|
|
118
129
|
/**
|
|
119
130
|
* Success actions = sync store state from external actions. If its name
|
|
120
131
|
* contains "Creator", it means it is still used in a saga and that `.request`
|
|
121
132
|
* and `.failure` need to be preserved
|
|
122
133
|
*/
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Custom Type module
|
|
137
|
+
*/
|
|
138
|
+
const createCustomTypeSuccess = (newCustomType: CustomType) =>
|
|
139
|
+
dispatch(
|
|
140
|
+
customTypeCreateSuccess({
|
|
141
|
+
newCustomType: CustomTypes.toSM(newCustomType),
|
|
142
|
+
}),
|
|
143
|
+
);
|
|
123
144
|
const saveCustomTypeSuccess = (customType: CustomType) =>
|
|
124
145
|
dispatch(
|
|
125
|
-
|
|
126
|
-
|
|
146
|
+
customTypeSaveSuccess({
|
|
147
|
+
newCustomType: CustomTypes.toSM(customType),
|
|
127
148
|
}),
|
|
128
149
|
);
|
|
129
|
-
|
|
130
150
|
const deleteCustomTypeSuccess = (id: string) =>
|
|
131
151
|
dispatch(
|
|
132
|
-
|
|
152
|
+
customTypeDeleteSuccess({
|
|
133
153
|
customTypeId: id,
|
|
134
154
|
}),
|
|
135
155
|
);
|
|
136
|
-
|
|
137
|
-
const renameAvailableCustomTypeSuccess = (customType: CustomType) =>
|
|
156
|
+
const renameCustomTypeSuccess = (customType: CustomType) =>
|
|
138
157
|
dispatch(
|
|
139
|
-
|
|
158
|
+
customTypeRenameSuccess({
|
|
140
159
|
renamedCustomType: CustomTypes.toSM(customType),
|
|
141
160
|
}),
|
|
142
161
|
);
|
|
143
162
|
|
|
144
|
-
/**
|
|
145
|
-
|
|
146
|
-
|
|
163
|
+
/**
|
|
164
|
+
* Slice module
|
|
165
|
+
*/
|
|
147
166
|
const saveSliceSuccess = (component: ComponentUI) => {
|
|
148
167
|
dispatch(
|
|
149
|
-
|
|
168
|
+
sliceUpdateSuccess({
|
|
150
169
|
component,
|
|
151
170
|
}),
|
|
152
171
|
);
|
|
153
172
|
};
|
|
154
|
-
|
|
155
173
|
const saveSliceCustomScreenshotSuccess = (
|
|
156
174
|
variationId: string,
|
|
157
175
|
screenshot: ScreenshotUI,
|
|
158
176
|
component: ComponentUI,
|
|
159
177
|
) => {
|
|
160
178
|
dispatch(
|
|
161
|
-
|
|
179
|
+
sliceGenerateCustomScreenshotSuccess({
|
|
162
180
|
variationId,
|
|
163
181
|
screenshot,
|
|
164
182
|
component,
|
|
165
183
|
}),
|
|
166
184
|
);
|
|
167
185
|
};
|
|
168
|
-
|
|
169
186
|
const createSliceSuccess = (libraries: readonly LibraryUI[]) =>
|
|
170
|
-
dispatch(
|
|
171
|
-
|
|
172
|
-
const renameSlice = (
|
|
173
|
-
libName: string,
|
|
174
|
-
sliceId: string,
|
|
175
|
-
newSliceName: string,
|
|
176
|
-
) =>
|
|
187
|
+
dispatch(sliceCreateSuccess({ libraries }));
|
|
188
|
+
const deleteSliceSuccess = (sliceId: string, libName: string) =>
|
|
177
189
|
dispatch(
|
|
178
|
-
|
|
190
|
+
sliceDeleteSuccess({
|
|
179
191
|
sliceId,
|
|
180
|
-
newSliceName,
|
|
181
192
|
libName,
|
|
182
193
|
}),
|
|
183
194
|
);
|
|
184
|
-
|
|
185
|
-
const deleteSlice = (sliceId: string, sliceName: string, libName: string) =>
|
|
195
|
+
const renameSliceSuccess = (libName: string, renamedSlice: SliceSM) =>
|
|
186
196
|
dispatch(
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
sliceName,
|
|
197
|
+
sliceRenameSuccess({
|
|
198
|
+
renamedSlice,
|
|
190
199
|
libName,
|
|
191
200
|
}),
|
|
192
201
|
);
|
|
193
202
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
const
|
|
198
|
-
content: string | React.ReactNode,
|
|
199
|
-
type: GenericToastTypes,
|
|
200
|
-
) => dispatch(openToasterCreator({ content, type }));
|
|
201
|
-
|
|
202
|
-
// Simulator
|
|
203
|
-
const saveSliceMock = (payload: SaveSliceMockRequest) =>
|
|
204
|
-
dispatch(saveSliceMockCreator.request(payload));
|
|
205
|
-
|
|
206
|
-
// State Action (used by multiple stores)
|
|
207
|
-
const refreshState = (serverState: ServerState) => {
|
|
208
|
-
dispatch(
|
|
209
|
-
refreshStateCreator({
|
|
210
|
-
env: serverState.env,
|
|
211
|
-
remoteCustomTypes: serverState.remoteCustomTypes,
|
|
212
|
-
localCustomTypes: serverState.customTypes,
|
|
213
|
-
libraries: serverState.libraries,
|
|
214
|
-
remoteSlices: serverState.remoteSlices,
|
|
215
|
-
clientError: serverState.clientError,
|
|
216
|
-
}),
|
|
217
|
-
);
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
const getChangelog = () => {
|
|
221
|
-
dispatch(getChangelogCreator.request());
|
|
222
|
-
};
|
|
203
|
+
/**
|
|
204
|
+
* Changes module
|
|
205
|
+
*/
|
|
206
|
+
const pushChangesSuccess = () => dispatch(changesPushSuccess());
|
|
223
207
|
|
|
224
208
|
return {
|
|
225
209
|
checkSimulatorSetup,
|
|
@@ -233,31 +217,28 @@ const useSliceMachineActions = () => {
|
|
|
233
217
|
stopLoadingLogin,
|
|
234
218
|
stopLoadingReview,
|
|
235
219
|
startLoadingReview,
|
|
236
|
-
createCustomType,
|
|
237
220
|
deleteCustomTypeSuccess,
|
|
238
|
-
|
|
221
|
+
renameCustomTypeSuccess,
|
|
239
222
|
saveCustomTypeSuccess,
|
|
240
223
|
saveSliceSuccess,
|
|
241
224
|
saveSliceCustomScreenshotSuccess,
|
|
242
225
|
createSliceSuccess,
|
|
243
|
-
|
|
244
|
-
|
|
226
|
+
renameSliceSuccess,
|
|
227
|
+
deleteSliceSuccess,
|
|
245
228
|
sendAReview,
|
|
246
229
|
skipReview,
|
|
247
230
|
setUpdatesViewed,
|
|
248
231
|
setSeenTutorialsToolTip,
|
|
249
232
|
setSeenSimulatorToolTip,
|
|
250
233
|
setSeenChangesToolTip,
|
|
251
|
-
openCreateCustomTypeModal,
|
|
252
234
|
openScreenshotPreviewModal,
|
|
253
|
-
openDeleteSliceModal,
|
|
254
235
|
openSimulatorSetupModal,
|
|
255
|
-
openRenameSliceModal,
|
|
256
236
|
closeModals,
|
|
257
237
|
openToaster,
|
|
258
238
|
saveSliceMock,
|
|
259
239
|
getChangelog,
|
|
260
240
|
pushChangesSuccess,
|
|
241
|
+
createCustomTypeSuccess,
|
|
261
242
|
};
|
|
262
243
|
};
|
|
263
244
|
|
|
@@ -53,7 +53,7 @@ export const hasSeenChangesToolTipCreator = createAction(
|
|
|
53
53
|
"USER_CONTEXT/VIEW_CHANGES_TOOL_TIP",
|
|
54
54
|
)();
|
|
55
55
|
|
|
56
|
-
export const
|
|
56
|
+
export const changesPushSuccess = createAction(
|
|
57
57
|
"USER_CONTEXT/CHANGES_PUSH_SUCCESS",
|
|
58
58
|
)();
|
|
59
59
|
|
|
@@ -65,7 +65,7 @@ type userContextActions = ActionType<
|
|
|
65
65
|
| typeof hasSeenSimulatorToolTipCreator
|
|
66
66
|
| typeof hasSeenChangesToolTipCreator
|
|
67
67
|
| typeof refreshStateCreator
|
|
68
|
-
| typeof
|
|
68
|
+
| typeof changesPushSuccess
|
|
69
69
|
>;
|
|
70
70
|
|
|
71
71
|
// Selectors
|
|
@@ -140,7 +140,7 @@ export const userContextReducer: Reducer<
|
|
|
140
140
|
authStatus: getAuthStatus(action.payload.clientError),
|
|
141
141
|
};
|
|
142
142
|
}
|
|
143
|
-
case getType(
|
|
143
|
+
case getType(changesPushSuccess): {
|
|
144
144
|
return {
|
|
145
145
|
...state,
|
|
146
146
|
lastSyncChange: Date.now(),
|
package/src/redux/saga.ts
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import { fork } from "redux-saga/effects";
|
|
2
2
|
|
|
3
3
|
import { watchSimulatorSagas } from "@src/modules/simulator";
|
|
4
|
-
import { watchAvailableCustomTypesSagas } from "@src/modules/availableCustomTypes";
|
|
5
|
-
import { watchSliceSagas } from "@src/modules/slices";
|
|
6
4
|
import { watchToasterSagas } from "@src/modules/toaster";
|
|
7
5
|
import { watchChangelogSagas } from "@src/modules/environment";
|
|
8
6
|
|
|
9
7
|
// Single entry point to start all Sagas at once
|
|
10
8
|
export default function* rootSaga() {
|
|
11
9
|
yield fork(watchSimulatorSagas);
|
|
12
|
-
yield fork(watchAvailableCustomTypesSagas);
|
|
13
|
-
yield fork(watchSliceSagas);
|
|
14
10
|
yield fork(watchToasterSagas);
|
|
15
11
|
yield fork(watchChangelogSagas);
|
|
16
12
|
}
|