slice-machine-ui 1.23.2-alpha.bmo-add-github-settings-page.5 → 1.23.2-alpha.bmo-add-github-settings-page.7

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 (74) hide show
  1. package/components/DeleteSliceModal/index.tsx +34 -24
  2. package/components/Forms/CreateCustomTypeModal/CreateCustomTypeModal.tsx +61 -38
  3. package/components/Forms/RenameCustomTypeModal/RenameCustomTypeModal.tsx +2 -2
  4. package/components/Forms/RenameSliceModal/RenameSliceModal.tsx +33 -21
  5. package/components/Navigation/ChangesListItem.tsx +14 -32
  6. package/lib/models/common/widgets/StructuredText/index.ts +1 -1
  7. package/out/404.html +1 -1
  8. package/out/_next/static/{eWuPXMHFhmgmq_6O409zA → T-um-aWXK8w7MVWXz2AL0}/_buildManifest.js +1 -1
  9. package/out/_next/static/chunks/25-01f422cea8066349.js +1 -0
  10. package/out/_next/static/chunks/{318-bd030cc1725e23b5.js → 318-99b5914b60bf1d17.js} +1 -1
  11. package/out/_next/static/chunks/727-f8fefdd3e50cab2a.js +1 -0
  12. package/out/_next/static/chunks/799-b467582de0a7254f.js +1 -0
  13. package/out/_next/static/chunks/904-4653b7a849f4db94.js +1 -0
  14. package/out/_next/static/chunks/pages/{_app-0556263ae30802aa.js → _app-8d17c36db86b1fa1.js} +26 -26
  15. package/out/_next/static/chunks/pages/{changes-8de69920dfb5a48f.js → changes-ac7d64fc8ec82b39.js} +1 -1
  16. package/out/_next/static/chunks/pages/custom-types/{[customTypeId]-3f862ad6111a1fc0.js → [customTypeId]-97ab3b90b85d645d.js} +1 -1
  17. package/out/_next/static/chunks/pages/{custom-types-94b8f8dbf7727412.js → custom-types-3c8e721ec6802127.js} +1 -1
  18. package/out/_next/static/chunks/pages/index-cf93d16e9c63b6db.js +1 -0
  19. package/out/_next/static/chunks/pages/page-types/{[pageTypeId]-d1ffca11c42f2603.js → [pageTypeId]-84a22c5e480d3fa9.js} +1 -1
  20. package/out/_next/static/chunks/pages/{settings-0961cf5b601e4baf.js → settings-197a424739e72b83.js} +1 -1
  21. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/{simulator-b12346e58ac9abea.js → simulator-c498e9c80cae8cce.js} +1 -1
  22. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-8038454f751ad0b9.js +1 -0
  23. package/out/_next/static/chunks/pages/slices-4522d604117d8c66.js +1 -0
  24. package/out/changelog.html +1 -1
  25. package/out/changes.html +1 -1
  26. package/out/custom-types/[customTypeId].html +1 -1
  27. package/out/custom-types.html +1 -1
  28. package/out/index.html +1 -1
  29. package/out/labs.html +1 -1
  30. package/out/page-types/[pageTypeId].html +1 -1
  31. package/out/settings.html +1 -1
  32. package/out/slices/[lib]/[sliceName]/[variation]/simulator.html +1 -1
  33. package/out/slices/[lib]/[sliceName]/[variation].html +1 -1
  34. package/out/slices.html +1 -1
  35. package/package.json +3 -3
  36. package/pages/slices.tsx +20 -8
  37. package/src/apiClient.ts +1 -22
  38. package/src/domain/__tests__/customType.test.ts +179 -0
  39. package/src/domain/customType.ts +110 -2
  40. package/src/domain/slice.ts +38 -0
  41. package/src/features/customTypes/PageTypeOnboarding.tsx +21 -26
  42. package/src/features/customTypes/actions/convertCustomToPageType.ts +14 -10
  43. package/src/features/customTypes/actions/createCustomType.ts +69 -0
  44. package/src/features/customTypes/actions/deleteCustomType.ts +13 -3
  45. package/src/features/customTypes/actions/renameCustomType.ts +10 -4
  46. package/src/features/customTypes/customTypesBuilder/CustomTypesBuilderPage.tsx +3 -1
  47. package/src/features/customTypes/customTypesTable/CustomTypesTable.tsx +8 -8
  48. package/src/features/customTypes/customTypesTable/CustomTypesTablePage.tsx +18 -17
  49. package/src/features/settings/git/ConnectGitRepository.tsx +10 -7
  50. package/src/features/slices/actions/createSlice.ts +5 -29
  51. package/src/features/slices/actions/deleteSlice.ts +33 -0
  52. package/src/features/slices/actions/renameSlice.ts +37 -0
  53. package/src/hooks/useUser.ts +14 -0
  54. package/src/modules/availableCustomTypes/index.ts +29 -135
  55. package/src/modules/loading/types.ts +0 -5
  56. package/src/modules/modal/types.ts +0 -3
  57. package/src/modules/slices/index.ts +27 -193
  58. package/src/modules/slices/selector.ts +0 -14
  59. package/src/modules/useSliceMachineActions.ts +70 -89
  60. package/src/modules/userContext/index.ts +3 -3
  61. package/src/redux/saga.ts +0 -4
  62. package/test/src/modules/availableCustomTypes/index.test.ts +2 -243
  63. package/test/src/modules/slices.test.ts +1 -267
  64. package/out/_next/static/chunks/25-37d6fa7f064be04b.js +0 -1
  65. package/out/_next/static/chunks/727-2235967a881f9035.js +0 -1
  66. package/out/_next/static/chunks/731-a9b66ccdc3fae2c2.js +0 -1
  67. package/out/_next/static/chunks/904-6d6937d53ea2761e.js +0 -1
  68. package/out/_next/static/chunks/pages/index-64cfb8b0948ba8ef.js +0 -1
  69. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-62b55bae7f1b3793.js +0 -1
  70. package/out/_next/static/chunks/pages/slices-81e382c3374273df.js +0 -1
  71. package/src/features/customTypes/__tests__/createCustomType.test.ts +0 -159
  72. package/src/features/customTypes/customTypesTable/createCustomType.ts +0 -107
  73. package/test/components/CreateCustomTypeModal.test.tsx +0 -73
  74. /package/out/_next/static/{eWuPXMHFhmgmq_6O409zA → T-um-aWXK8w7MVWXz2AL0}/_ssgManifest.js +0 -0
@@ -1,28 +1,15 @@
1
1
  import { Reducer } from "redux";
2
2
  import { AvailableCustomTypesStoreType } from "./types";
3
- import {
4
- ActionType,
5
- createAction,
6
- createAsyncAction,
7
- getType,
8
- } from "typesafe-actions";
3
+ import { ActionType, createAction, getType } from "typesafe-actions";
9
4
  import { SliceMachineStoreType } from "@src/redux/type";
10
5
  import { refreshStateCreator } from "@src/modules/environment";
11
- import { call, fork, put, takeLatest } from "redux-saga/effects";
12
- import { withLoader } from "@src/modules/loading";
13
- import { LoadingKeysEnum } from "@src/modules/loading/types";
14
- import { updateCustomType } from "@src/apiClient";
15
- import { modalCloseCreator } from "@src/modules/modal";
16
- import { push } from "connected-next-router";
17
- import { createCustomType } from "@src/features/customTypes/customTypesTable/createCustomType";
18
- import { openToasterCreator, ToasterType } from "@src/modules/toaster";
19
6
  import { CustomTypeSM } from "@lib/models/common/CustomType";
20
7
  import {
21
8
  normalizeFrontendCustomType,
22
9
  normalizeFrontendCustomTypes,
23
10
  } from "@lib/models/common/normalizers/customType";
24
11
  import { omit } from "lodash";
25
- import { deleteSliceCreator } from "../slices";
12
+ import { sliceDeleteSuccess } from "../slices";
26
13
  import { filterSliceFromCustomType } from "@lib/utils/shared/customTypes";
27
14
  import {
28
15
  LocalOrRemoteCustomType,
@@ -30,63 +17,37 @@ import {
30
17
  hasLocal,
31
18
  hasLocalAndRemote,
32
19
  } from "@lib/models/common/ModelData";
33
- import { CustomTypeFormat } from "@slicemachine/manager";
34
- import { CUSTOM_TYPES_CONFIG } from "@src/features/customTypes/customTypesConfig";
35
- import { CUSTOM_TYPES_MESSAGES } from "@src/features/customTypes/customTypesMessages";
36
- import { CustomTypes } from "@lib/models/common/CustomType";
37
- import { ToastMessageWithPath } from "@components/ToasterContainer";
38
-
39
- export const saveCustomTypeCreator = createAsyncAction(
40
- "CUSTOM_TYPE/SAVE.REQUEST",
41
- "CUSTOM_TYPE/SAVE.RESPONSE",
42
- "CUSTOM_TYPE/SAVE.FAILURE",
43
- )<undefined, { customType: CustomTypeSM }>();
44
20
 
45
21
  // Action Creators
46
- export const createCustomTypeCreator = createAsyncAction(
47
- "CUSTOM_TYPES/CREATE.REQUEST",
48
- "CUSTOM_TYPES/CREATE.RESPONSE",
49
- "CUSTOM_TYPES/CREATE.FAILURE",
50
- )<
51
- {
52
- id: string;
53
- label: string;
54
- repeatable: boolean;
55
- format: CustomTypeFormat;
56
- },
57
- {
58
- newCustomType: CustomTypeSM;
59
- }
60
- >();
22
+ export const customTypeSaveSuccess = createAction("CUSTOM_TYPE/SAVE_SUCCESS")<{
23
+ newCustomType: CustomTypeSM;
24
+ }>();
61
25
 
62
- export const renameAvailableCustomType = createAction(
63
- "CUSTOM_TYPES/RENAME_CUSTOM_TYPE",
26
+ export const customTypeCreateSuccess = createAction(
27
+ "CUSTOM_TYPES/CREATE_SUCCESS",
28
+ )<{
29
+ newCustomType: CustomTypeSM;
30
+ }>();
31
+
32
+ export const customTypeRenameSuccess = createAction(
33
+ "CUSTOM_TYPES/RENAME_SUCCESS",
64
34
  )<{
65
35
  renamedCustomType: CustomTypeSM;
66
36
  }>();
67
37
 
68
- export const deleteCustomTypeCreator = createAsyncAction(
69
- "CUSTOM_TYPES/DELETE.REQUEST",
70
- "CUSTOM_TYPES/DELETE.RESPONSE",
71
- "CUSTOM_TYPES/DELETE.FAILURE",
72
- )<
73
- {
74
- customTypeId: string;
75
- customTypeName: string;
76
- format: CustomTypeFormat;
77
- },
78
- {
79
- customTypeId: string;
80
- }
81
- >();
38
+ export const customTypeDeleteSuccess = createAction(
39
+ "CUSTOM_TYPES/DELETE_SUCCESS",
40
+ )<{
41
+ customTypeId: string;
42
+ }>();
82
43
 
83
44
  type CustomTypesActions =
84
45
  | ActionType<typeof refreshStateCreator>
85
- | ActionType<typeof createCustomTypeCreator>
86
- | ActionType<typeof renameAvailableCustomType>
87
- | ActionType<typeof saveCustomTypeCreator>
88
- | ActionType<typeof deleteCustomTypeCreator>
89
- | ActionType<typeof deleteSliceCreator.success>;
46
+ | ActionType<typeof customTypeCreateSuccess>
47
+ | ActionType<typeof customTypeRenameSuccess>
48
+ | ActionType<typeof customTypeSaveSuccess>
49
+ | ActionType<typeof customTypeDeleteSuccess>
50
+ | ActionType<typeof sliceDeleteSuccess>;
90
51
 
91
52
  // Selectors
92
53
  export const selectAllCustomTypes = (
@@ -134,7 +95,7 @@ export const availableCustomTypesReducer: Reducer<
134
95
  ...normalizedNewCustomType,
135
96
  };
136
97
  }
137
- case getType(createCustomTypeCreator.success): {
98
+ case getType(customTypeCreateSuccess): {
138
99
  const normalizedNewCustomType = normalizeFrontendCustomType(
139
100
  action.payload.newCustomType,
140
101
  );
@@ -145,8 +106,8 @@ export const availableCustomTypesReducer: Reducer<
145
106
  };
146
107
  }
147
108
 
148
- case getType(saveCustomTypeCreator.success): {
149
- const localCustomType = action.payload.customType;
109
+ case getType(customTypeSaveSuccess): {
110
+ const localCustomType = action.payload.newCustomType;
150
111
 
151
112
  return {
152
113
  ...state,
@@ -157,7 +118,7 @@ export const availableCustomTypesReducer: Reducer<
157
118
  };
158
119
  }
159
120
 
160
- case getType(renameAvailableCustomType): {
121
+ case getType(customTypeRenameSuccess): {
161
122
  const id = action.payload.renamedCustomType.id;
162
123
  const customType = state[id];
163
124
 
@@ -172,7 +133,7 @@ export const availableCustomTypesReducer: Reducer<
172
133
  };
173
134
  }
174
135
 
175
- case getType(deleteCustomTypeCreator.success): {
136
+ case getType(customTypeDeleteSuccess): {
176
137
  const customType = state[action.payload.customTypeId];
177
138
 
178
139
  if (hasLocalAndRemote(customType)) {
@@ -191,7 +152,7 @@ export const availableCustomTypesReducer: Reducer<
191
152
  return state;
192
153
  }
193
154
 
194
- case getType(deleteSliceCreator.success): {
155
+ case getType(sliceDeleteSuccess): {
195
156
  const sliceId = action.payload.sliceId;
196
157
 
197
158
  const customTypesUpdated: AvailableCustomTypesStoreType = Object.entries(
@@ -229,70 +190,3 @@ export const availableCustomTypesReducer: Reducer<
229
190
  return state;
230
191
  }
231
192
  };
232
-
233
- export function* createCustomTypeSaga({
234
- payload,
235
- }: ReturnType<typeof createCustomTypeCreator.request>) {
236
- const customTypesConfig = CUSTOM_TYPES_CONFIG[payload.format];
237
- const customTypesMessages = CUSTOM_TYPES_MESSAGES[payload.format];
238
-
239
- try {
240
- const newCustomType = CustomTypes.toSM(
241
- createCustomType(
242
- payload.id,
243
- payload.label,
244
- payload.repeatable,
245
- payload.format,
246
- ),
247
- );
248
- yield call(updateCustomType, CustomTypes.fromSM(newCustomType));
249
- yield put(createCustomTypeCreator.success({ newCustomType }));
250
- yield put(modalCloseCreator());
251
- yield put(
252
- push({
253
- pathname: customTypesConfig.getBuilderPagePathname(payload.id),
254
- query:
255
- newCustomType.format === "page"
256
- ? {
257
- newPageType: true,
258
- }
259
- : undefined,
260
- }),
261
- );
262
- yield put(
263
- openToasterCreator({
264
- content: ToastMessageWithPath({
265
- message: `${customTypesMessages.name({
266
- start: true,
267
- plural: false,
268
- })} saved successfully at `,
269
- path: `./customtypes/${newCustomType.id}/index.json`,
270
- }),
271
- type: ToasterType.SUCCESS,
272
- }),
273
- );
274
- } catch (e) {
275
- yield put(
276
- openToasterCreator({
277
- content: `Internal Error: ${customTypesMessages.name({
278
- start: true,
279
- plural: false,
280
- })} not saved`,
281
- type: ToasterType.ERROR,
282
- }),
283
- );
284
- }
285
- }
286
-
287
- // Saga watchers
288
- function* handleCustomTypeRequests() {
289
- yield takeLatest(
290
- getType(createCustomTypeCreator.request),
291
- withLoader(createCustomTypeSaga, LoadingKeysEnum.CREATE_CUSTOM_TYPE),
292
- );
293
- }
294
-
295
- // Saga Exports
296
- export function* watchAvailableCustomTypesSagas() {
297
- yield fork(handleCustomTypeRequests);
298
- }
@@ -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 { withLoader } from "@src/modules/loading";
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 createSlice = createAction("SLICES/CREATE_SLICE")<{
15
+ export const sliceCreateSuccess = createAction("SLICES/CREATE_SUCCESS")<{
35
16
  libraries: Readonly<LibraryUI[]>;
36
17
  }>();
37
18
 
38
- export const renameSliceCreator = createAsyncAction(
39
- "SLICES/RENAME.REQUEST",
40
- "SLICES/RENAME.RESPONSE",
41
- "SLICES/RENAME.FAILURE",
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 deleteSliceCreator = createAsyncAction(
55
- "SLICES/DELETE.REQUEST",
56
- "SLICES/DELETE.RESPONSE",
57
- "SLICES/DELETE.FAILURE",
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 updateSliceCreator = createAsyncAction(
72
- "SLICE/UPDATE.REQUEST",
73
- "SLICE/UPDATE.RESPONSE",
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 generateSliceCustomScreenshotCreator = createAsyncAction(
86
- "SLICE/GENERATE_CUSTOM_SCREENSHOT.REQUEST",
87
- "SLICE/GENERATE_CUSTOM_SCREENSHOT.RESPONSE",
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 createSlice>
105
- | ActionType<typeof renameSliceCreator>
106
- | ActionType<typeof deleteSliceCreator>
107
- | ActionType<typeof updateSliceCreator>
108
- | ActionType<typeof generateSliceCustomScreenshotCreator>
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(createSlice):
84
+ case getType(sliceCreateSuccess):
147
85
  return {
148
86
  ...state,
149
87
  libraries: action.payload.libraries,
150
88
  };
151
- case getType(renameSliceCreator.success): {
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(updateSliceCreator.success): {
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(generateSliceCustomScreenshotCreator.success): {
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(deleteSliceCreator.success): {
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,