slice-machine-ui 1.23.1-beta.2 → 1.23.1-beta.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/CustomTypeTable/changesPage.tsx +1 -0
- package/components/DeleteDocumentsDrawer/HardDeleteDocumentsDrawer.tsx +11 -23
- package/components/DeleteDocumentsDrawer/SoftDeleteDocumentsDrawer.tsx +11 -23
- package/components/DeleteDocumentsDrawer/index.tsx +0 -1
- package/components/SliceMachineDrawer/index.tsx +4 -6
- package/out/404.html +1 -1
- package/out/_next/static/{8aiH3LjdI_Vj38RRmPnNx → N2MQkjqkeMvE9gtxiUiFA}/_buildManifest.js +1 -1
- package/out/_next/static/chunks/25-37d6fa7f064be04b.js +1 -0
- package/out/_next/static/chunks/{727-15cf3f2fea9a37e5.js → 727-2016e98f80ea6a62.js} +1 -1
- package/out/_next/static/chunks/{904-ccd8ca3368ce29fc.js → 904-4c4d0a2183ae9a27.js} +1 -1
- package/out/_next/static/chunks/pages/{_app-46cdcb7304fa805f.js → _app-6fc45ce12a6c566a.js} +2 -2
- package/out/_next/static/chunks/pages/{changelog-68d115a14f1423d7.js → changelog-afd18276fe018b24.js} +1 -1
- package/out/_next/static/chunks/pages/changes-898f58035cfafe03.js +1 -0
- package/out/_next/static/chunks/pages/{labs-526bb7d60a1b90f4.js → labs-ee206005948f8e87.js} +1 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/{[variation]-73dd999915509965.js → [variation]-b2a9d773ce5d7739.js} +1 -1
- package/out/_next/static/chunks/pages/{slices-7b09cb5130c63bb3.js → slices-e9c70c082ca3e3f9.js} +1 -1
- 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/changes.tsx +67 -28
- package/src/components/FieldSet/FieldSet.module.css +92 -0
- package/src/components/FieldSet/FieldSet.module.css.d.ts +18 -0
- package/src/components/FieldSet/FieldSet.stories.tsx +208 -0
- package/src/components/FieldSet/FieldSet.tsx +72 -0
- package/src/components/FieldSet/index.ts +9 -0
- package/src/features/changes/actions/pushChanges.ts +66 -0
- package/src/{modules/pushChangesSaga → features/changes/actions}/trackPushChangesSuccess.ts +16 -12
- package/src/icons/BitbucketIcon.tsx +19 -0
- package/src/icons/GitHubIcon.tsx +17 -0
- package/src/icons/GitLabIcon.tsx +19 -0
- package/src/modules/loading/types.ts +0 -1
- package/src/modules/modal/types.ts +0 -3
- package/src/modules/useSliceMachineActions.ts +3 -18
- package/src/modules/userContext/index.ts +6 -3
- package/src/redux/reducer.ts +0 -2
- package/src/redux/saga.ts +0 -2
- package/src/redux/type.ts +0 -2
- package/components/DeleteDocumentsDrawer/ReferencesErrorDrawer.tsx +0 -92
- package/lib/models/common/TransactionalPush.ts +0 -10
- package/out/_next/static/chunks/25-8fedd33ad9b6de5b.js +0 -1
- package/out/_next/static/chunks/pages/changes-6a24f50da1a00688.js +0 -1
- package/src/modules/pushChangesSaga/index.ts +0 -191
- package/test/src/modules/pushChangesSaga.test.ts +0 -261
- /package/out/_next/static/{8aiH3LjdI_Vj38RRmPnNx → N2MQkjqkeMvE9gtxiUiFA}/_ssgManifest.js +0 -0
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
ChangedCustomType,
|
|
3
|
+
ChangedSlice,
|
|
4
|
+
ModelStatus,
|
|
5
|
+
} from "@lib/models/common/ModelStatus";
|
|
2
6
|
import { telemetry } from "@src/apiClient";
|
|
3
7
|
import { countMissingScreenshots } from "@src/domain/slice";
|
|
4
|
-
import { ModelStatus } from "@lib/models/common/ModelStatus";
|
|
5
8
|
|
|
6
|
-
type
|
|
9
|
+
type TrackPushChangesSuccessArgs = {
|
|
10
|
+
changedSlices: ReadonlyArray<ChangedSlice>;
|
|
11
|
+
changedCustomTypes: ReadonlyArray<ChangedCustomType>;
|
|
12
|
+
hasDeletedDocuments: boolean;
|
|
13
|
+
startTime: number;
|
|
14
|
+
};
|
|
7
15
|
|
|
8
|
-
export function trackPushChangesSuccess(
|
|
9
|
-
const {
|
|
10
|
-
|
|
11
|
-
confirmDeleteDocuments,
|
|
12
|
-
changedCustomTypes,
|
|
13
|
-
changedSlices,
|
|
14
|
-
} = params;
|
|
16
|
+
export function trackPushChangesSuccess(args: TrackPushChangesSuccessArgs) {
|
|
17
|
+
const { startTime, hasDeletedDocuments, changedCustomTypes, changedSlices } =
|
|
18
|
+
args;
|
|
15
19
|
|
|
16
20
|
const customTypesStats = changedCustomTypes.reduce<{
|
|
17
21
|
customTypesCreated: number;
|
|
@@ -80,14 +84,14 @@ export function trackPushChangesSuccess(params: trackingParameters) {
|
|
|
80
84
|
);
|
|
81
85
|
const duration = Date.now() - startTime;
|
|
82
86
|
|
|
83
|
-
|
|
87
|
+
void telemetry.track({
|
|
84
88
|
event: "changes:pushed",
|
|
85
89
|
...customTypesStats,
|
|
86
90
|
...slicesStats,
|
|
87
91
|
total: total,
|
|
88
92
|
missingScreenshots,
|
|
89
93
|
duration: duration,
|
|
90
|
-
hasDeletedDocuments
|
|
94
|
+
hasDeletedDocuments,
|
|
91
95
|
_includeEnvironmentKind: true,
|
|
92
96
|
});
|
|
93
97
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { FC, SVGProps } from "react";
|
|
2
|
+
|
|
3
|
+
export const BitbucketIcon: FC<SVGProps<SVGSVGElement>> = (props) => (
|
|
4
|
+
<svg
|
|
5
|
+
width="24"
|
|
6
|
+
height="24"
|
|
7
|
+
viewBox="0 0 24 24"
|
|
8
|
+
fill="none"
|
|
9
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
10
|
+
{...props}
|
|
11
|
+
>
|
|
12
|
+
<path
|
|
13
|
+
fillRule="evenodd"
|
|
14
|
+
clipRule="evenodd"
|
|
15
|
+
d="M4.77596 5.47599C4.84147 5.44648 4.91265 5.43167 4.9845 5.4326L19.3525 5.43506C19.4243 5.43413 19.4955 5.44894 19.561 5.47845C19.6265 5.50796 19.6848 5.55146 19.7317 5.60588C19.7786 5.6603 19.8131 5.72433 19.8326 5.79348C19.8521 5.86262 19.8563 5.93521 19.8448 6.00614L19.1802 10.0751H9.71803L10.5722 14.6018H11.1162L11.1162 14.6018H13.7846L14.56 10.0751H19.1803L17.7575 18.8357C17.7387 18.9522 17.6786 19.058 17.5882 19.1339C17.4979 19.2098 17.3832 19.2507 17.2652 19.2492H7.23692C7.2134 19.249 7.19001 19.2476 7.16682 19.2449C7.03392 19.2298 6.90803 19.175 6.80603 19.0868C6.68704 18.9851 6.60772 18.8448 6.58203 18.6904L4.49219 6.00367C4.48069 5.93275 4.48485 5.86016 4.50438 5.79102C4.52392 5.72187 4.55835 5.65784 4.60527 5.60342C4.65218 5.54899 4.71044 5.5055 4.77596 5.47599Z"
|
|
16
|
+
fill="currentColor"
|
|
17
|
+
/>
|
|
18
|
+
</svg>
|
|
19
|
+
);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { FC, SVGProps } from "react";
|
|
2
|
+
|
|
3
|
+
export const GitHubIcon: FC<SVGProps<SVGSVGElement>> = (props) => (
|
|
4
|
+
<svg
|
|
5
|
+
width="24"
|
|
6
|
+
height="24"
|
|
7
|
+
viewBox="0 0 24 24"
|
|
8
|
+
fill="none"
|
|
9
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
10
|
+
{...props}
|
|
11
|
+
>
|
|
12
|
+
<path
|
|
13
|
+
d="M12 4C7.57486 4 4 7.57486 4 12C4 15.5246 6.30057 18.5257 9.47429 19.6C9.87429 19.6754 10.0251 19.4251 10.0251 19.2251V17.8754C7.8 18.3497 7.32457 16.8 7.32457 16.8C6.94971 15.8743 6.42514 15.6251 6.42514 15.6251C5.70057 15.1246 6.47543 15.1497 6.47543 15.1497C7.27543 15.2 7.69943 15.9749 7.69943 15.9749C8.42514 17.2 9.57486 16.8503 10.0251 16.6491C10.1006 16.1246 10.2994 15.7749 10.5246 15.5749C8.74971 15.3749 6.87543 14.6754 6.87543 11.6251C6.87543 10.7497 7.17486 10.0503 7.69943 9.47543C7.62514 9.27543 7.34971 8.45029 7.77486 7.34971C7.77486 7.34971 8.44914 7.12457 9.97486 8.17486C10.6266 7.99627 11.2991 7.90405 11.9749 7.90057C12.6491 7.90057 13.3497 8 13.9749 8.17486C15.5006 7.14971 16.1749 7.34971 16.1749 7.34971C16.6 8.45029 16.3246 9.27543 16.2503 9.47543C16.776 10.024 17.0754 10.7497 17.0754 11.624C17.0754 14.6994 15.2 15.3749 13.4251 15.5749C13.6994 15.8251 13.9749 16.2994 13.9749 17.0491V19.2503C13.9749 19.4754 14.1246 19.7246 14.5246 19.6251C17.7006 18.5246 20 15.5246 20 12C20 7.57486 16.4251 4 12 4Z"
|
|
14
|
+
fill="currentColor"
|
|
15
|
+
/>
|
|
16
|
+
</svg>
|
|
17
|
+
);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { FC, SVGProps } from "react";
|
|
2
|
+
|
|
3
|
+
export const GitLabIcon: FC<SVGProps<SVGSVGElement>> = (props) => (
|
|
4
|
+
<svg
|
|
5
|
+
width="24"
|
|
6
|
+
height="24"
|
|
7
|
+
viewBox="0 0 24 24"
|
|
8
|
+
fill="none"
|
|
9
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
10
|
+
{...props}
|
|
11
|
+
>
|
|
12
|
+
<path
|
|
13
|
+
fillRule="evenodd"
|
|
14
|
+
clipRule="evenodd"
|
|
15
|
+
d="M14.7881 10.5954L16.5431 5.20756C16.6328 4.93081 17.0594 4.93081 17.1492 5.20756L18.9076 10.5954H14.7881ZM6.6192 5.20756L4.86353 10.5954H8.97968L7.22468 5.20756C7.1349 4.93081 6.70898 4.93081 6.6192 5.20756ZM4.0299 13.2981L4.86352 10.5954H4.86353H8.979H14.7881H18.9076L19.7392 13.2981C19.7796 13.4207 19.7802 13.553 19.7408 13.676C19.7014 13.799 19.624 13.9063 19.5198 13.9826L11.893 19.5257L11.8879 19.5319L11.8923 19.5378L11.8865 19.5336L11.8835 19.5371L11.8852 19.5326L4.24927 13.9826C4.0299 13.8246 3.95092 13.5458 4.0299 13.2981Z"
|
|
16
|
+
fill="currentColor"
|
|
17
|
+
/>
|
|
18
|
+
</svg>
|
|
19
|
+
);
|
|
@@ -10,7 +10,6 @@ export enum LoadingKeysEnum {
|
|
|
10
10
|
RENAME_SLICE = "RENAME_SLICE",
|
|
11
11
|
GENERATE_SLICE_CUSTOM_SCREENSHOT = "GENERATE_SLICE_CUSTOM_SCREENSHOT",
|
|
12
12
|
SAVE_SLICE = "SAVE_SLICE",
|
|
13
|
-
CHANGES_PUSH = "CHANGES_PUSH",
|
|
14
13
|
DELETE_SLICE = "DELETE_SLICE",
|
|
15
14
|
SIMULATOR_SAVE_MOCK = "SIMULATOR_SAVE_MOCK",
|
|
16
15
|
CHANGELOG = "CHANGELOG",
|
|
@@ -5,9 +5,6 @@ export enum ModalKeysEnum {
|
|
|
5
5
|
SCREENSHOT_PREVIEW = "SCREENSHOT_PREVIEW",
|
|
6
6
|
SCREENSHOTS = "SCREENSHOTS",
|
|
7
7
|
DELETE_SLICE = "DELETE_SLICE",
|
|
8
|
-
SOFT_DELETE_DOCUMENTS_DRAWER = "SOFT_DELETE_DOCUMENTS_DRAWER",
|
|
9
|
-
HARD_DELETE_DOCUMENTS_DRAWER = "HARD_DELETE_DOCUMENTS_DRAWER",
|
|
10
|
-
REFERENCES_MISSING_DRAWER = "REFERENCES_MISSING_DRAWER",
|
|
11
8
|
SIMULATOR_SETUP = "SIMULATOR_SETUP",
|
|
12
9
|
}
|
|
13
10
|
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
hasSeenTutorialsToolTipCreator,
|
|
11
11
|
hasSeenSimulatorToolTipCreator,
|
|
12
12
|
hasSeenChangesToolTipCreator,
|
|
13
|
+
changesPushSuccessCreator,
|
|
13
14
|
} from "./userContext";
|
|
14
15
|
import { getChangelogCreator, refreshStateCreator } from "./environment";
|
|
15
16
|
import {
|
|
@@ -35,7 +36,6 @@ import { GenericToastTypes, openToasterCreator } from "./toaster";
|
|
|
35
36
|
import { CustomTypes } from "@lib/models/common/CustomType";
|
|
36
37
|
import { CustomType } from "@prismicio/types-internal/lib/customtypes";
|
|
37
38
|
import { ComponentUI, ScreenshotUI } from "../../lib/models/common/ComponentUI";
|
|
38
|
-
import { ChangesPushSagaPayload, changesPushCreator } from "./pushChangesSaga";
|
|
39
39
|
import { saveSliceMockCreator } from "./simulator";
|
|
40
40
|
import { SaveSliceMockRequest } from "@src/apiClient";
|
|
41
41
|
import { CustomTypeFormat } from "@slicemachine/manager";
|
|
@@ -70,18 +70,6 @@ const useSliceMachineActions = () => {
|
|
|
70
70
|
dispatch(modalOpenCreator({ modalKey: ModalKeysEnum.SCREENSHOT_PREVIEW }));
|
|
71
71
|
const openDeleteSliceModal = () =>
|
|
72
72
|
dispatch(modalOpenCreator({ modalKey: ModalKeysEnum.DELETE_SLICE }));
|
|
73
|
-
const openDeleteDocumentsDrawer = () =>
|
|
74
|
-
dispatch(
|
|
75
|
-
modalOpenCreator({
|
|
76
|
-
modalKey: ModalKeysEnum.SOFT_DELETE_DOCUMENTS_DRAWER,
|
|
77
|
-
}),
|
|
78
|
-
);
|
|
79
|
-
const openDeleteDocumentsDrawerOverLimit = () =>
|
|
80
|
-
dispatch(
|
|
81
|
-
modalOpenCreator({
|
|
82
|
-
modalKey: ModalKeysEnum.HARD_DELETE_DOCUMENTS_DRAWER,
|
|
83
|
-
}),
|
|
84
|
-
);
|
|
85
73
|
const openSimulatorSetupModal = () =>
|
|
86
74
|
dispatch(modalOpenCreator({ modalKey: ModalKeysEnum.SIMULATOR_SETUP }));
|
|
87
75
|
|
|
@@ -203,8 +191,7 @@ const useSliceMachineActions = () => {
|
|
|
203
191
|
}),
|
|
204
192
|
);
|
|
205
193
|
|
|
206
|
-
const
|
|
207
|
-
dispatch(changesPushCreator.request(payload));
|
|
194
|
+
const pushChangesSuccess = () => dispatch(changesPushSuccessCreator());
|
|
208
195
|
|
|
209
196
|
// Toaster store
|
|
210
197
|
const openToaster = (
|
|
@@ -238,8 +225,6 @@ const useSliceMachineActions = () => {
|
|
|
238
225
|
checkSimulatorSetup,
|
|
239
226
|
connectToSimulatorFailure,
|
|
240
227
|
connectToSimulatorSuccess,
|
|
241
|
-
openDeleteDocumentsDrawer,
|
|
242
|
-
openDeleteDocumentsDrawerOverLimit,
|
|
243
228
|
connectToSimulatorIframe,
|
|
244
229
|
refreshState,
|
|
245
230
|
openScreenshotsModal,
|
|
@@ -270,9 +255,9 @@ const useSliceMachineActions = () => {
|
|
|
270
255
|
openRenameSliceModal,
|
|
271
256
|
closeModals,
|
|
272
257
|
openToaster,
|
|
273
|
-
pushChanges,
|
|
274
258
|
saveSliceMock,
|
|
275
259
|
getChangelog,
|
|
260
|
+
pushChangesSuccess,
|
|
276
261
|
};
|
|
277
262
|
};
|
|
278
263
|
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
} from "@src/modules/userContext/types";
|
|
10
10
|
import { refreshStateCreator } from "../environment";
|
|
11
11
|
import ErrorWithStatus from "@lib/models/common/ErrorWithStatus";
|
|
12
|
-
import { changesPushCreator } from "../pushChangesSaga";
|
|
13
12
|
|
|
14
13
|
// NOTE: Be careful every key written in this store is persisted in the localstorage
|
|
15
14
|
|
|
@@ -54,6 +53,10 @@ export const hasSeenChangesToolTipCreator = createAction(
|
|
|
54
53
|
"USER_CONTEXT/VIEW_CHANGES_TOOL_TIP",
|
|
55
54
|
)();
|
|
56
55
|
|
|
56
|
+
export const changesPushSuccessCreator = createAction(
|
|
57
|
+
"USER_CONTEXT/CHANGES_PUSH_SUCCESS",
|
|
58
|
+
)();
|
|
59
|
+
|
|
57
60
|
type userContextActions = ActionType<
|
|
58
61
|
| typeof sendAReviewCreator
|
|
59
62
|
| typeof skipReviewCreator
|
|
@@ -62,7 +65,7 @@ type userContextActions = ActionType<
|
|
|
62
65
|
| typeof hasSeenSimulatorToolTipCreator
|
|
63
66
|
| typeof hasSeenChangesToolTipCreator
|
|
64
67
|
| typeof refreshStateCreator
|
|
65
|
-
| typeof
|
|
68
|
+
| typeof changesPushSuccessCreator
|
|
66
69
|
>;
|
|
67
70
|
|
|
68
71
|
// Selectors
|
|
@@ -137,7 +140,7 @@ export const userContextReducer: Reducer<
|
|
|
137
140
|
authStatus: getAuthStatus(action.payload.clientError),
|
|
138
141
|
};
|
|
139
142
|
}
|
|
140
|
-
case getType(
|
|
143
|
+
case getType(changesPushSuccessCreator): {
|
|
141
144
|
return {
|
|
142
145
|
...state,
|
|
143
146
|
lastSyncChange: Date.now(),
|
package/src/redux/reducer.ts
CHANGED
|
@@ -12,7 +12,6 @@ import { simulatorReducer } from "@src/modules/simulator";
|
|
|
12
12
|
import { availableCustomTypesReducer } from "@src/modules/availableCustomTypes";
|
|
13
13
|
import { slicesReducer } from "@src/modules/slices";
|
|
14
14
|
import { routerReducer } from "connected-next-router";
|
|
15
|
-
import { pushChangesReducer } from "@src/modules/pushChangesSaga";
|
|
16
15
|
|
|
17
16
|
/** Creates the main reducer */
|
|
18
17
|
const createReducer = (): Reducer =>
|
|
@@ -25,7 +24,6 @@ const createReducer = (): Reducer =>
|
|
|
25
24
|
availableCustomTypes: availableCustomTypesReducer,
|
|
26
25
|
slices: slicesReducer,
|
|
27
26
|
router: routerReducer,
|
|
28
|
-
pushChanges: pushChangesReducer,
|
|
29
27
|
});
|
|
30
28
|
|
|
31
29
|
export default createReducer;
|
package/src/redux/saga.ts
CHANGED
|
@@ -4,7 +4,6 @@ import { watchSimulatorSagas } from "@src/modules/simulator";
|
|
|
4
4
|
import { watchAvailableCustomTypesSagas } from "@src/modules/availableCustomTypes";
|
|
5
5
|
import { watchSliceSagas } from "@src/modules/slices";
|
|
6
6
|
import { watchToasterSagas } from "@src/modules/toaster";
|
|
7
|
-
import { watchChangesPushSagas } from "@src/modules/pushChangesSaga";
|
|
8
7
|
import { watchChangelogSagas } from "@src/modules/environment";
|
|
9
8
|
|
|
10
9
|
// Single entry point to start all Sagas at once
|
|
@@ -13,6 +12,5 @@ export default function* rootSaga() {
|
|
|
13
12
|
yield fork(watchAvailableCustomTypesSagas);
|
|
14
13
|
yield fork(watchSliceSagas);
|
|
15
14
|
yield fork(watchToasterSagas);
|
|
16
|
-
yield fork(watchChangesPushSagas);
|
|
17
15
|
yield fork(watchChangelogSagas);
|
|
18
16
|
}
|
package/src/redux/type.ts
CHANGED
|
@@ -6,7 +6,6 @@ import { SimulatorStoreType } from "@src/modules/simulator/types";
|
|
|
6
6
|
import { AvailableCustomTypesStoreType } from "@src/modules/availableCustomTypes/types";
|
|
7
7
|
import { SlicesStoreType } from "@src/modules/slices/types";
|
|
8
8
|
import { RouterState } from "connected-next-router/types";
|
|
9
|
-
import { PushChangesStoreType } from "@src/modules/pushChangesSaga";
|
|
10
9
|
|
|
11
10
|
export type SliceMachineStoreType = {
|
|
12
11
|
modal: ModalStoreType;
|
|
@@ -17,5 +16,4 @@ export type SliceMachineStoreType = {
|
|
|
17
16
|
availableCustomTypes: AvailableCustomTypesStoreType;
|
|
18
17
|
slices: SlicesStoreType;
|
|
19
18
|
router: RouterState;
|
|
20
|
-
pushChanges: PushChangesStoreType;
|
|
21
19
|
};
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Text } from "theme-ui";
|
|
3
|
-
import useSliceMachineActions from "@src/modules/useSliceMachineActions";
|
|
4
|
-
import { Button } from "@components/Button";
|
|
5
|
-
import { useSelector } from "react-redux";
|
|
6
|
-
import { SliceMachineStoreType } from "@src/redux/type";
|
|
7
|
-
import { ModalKeysEnum } from "@src/modules/modal/types";
|
|
8
|
-
import { isModalOpen } from "@src/modules/modal";
|
|
9
|
-
import { getModelId, hasLocal } from "@lib/models/common/ModelData";
|
|
10
|
-
import { CustomTypesReferencesCard } from "./AssociatedDocumentsCard";
|
|
11
|
-
import { ToasterType } from "@src/modules/toaster";
|
|
12
|
-
import { selectAllCustomTypes } from "@src/modules/availableCustomTypes";
|
|
13
|
-
import { SliceMachineDrawerUI } from "@components/SliceMachineDrawer";
|
|
14
|
-
|
|
15
|
-
export const ReferencesErrorDrawer: React.FunctionComponent<{
|
|
16
|
-
pushChanges: (confirmDeleteDocuments: boolean) => void;
|
|
17
|
-
}> = ({ pushChanges }) => {
|
|
18
|
-
const { isOpen, modalData, localCustomTypes } = useSelector(
|
|
19
|
-
(store: SliceMachineStoreType) => ({
|
|
20
|
-
isOpen: isModalOpen(store, ModalKeysEnum.REFERENCES_MISSING_DRAWER),
|
|
21
|
-
localCustomTypes: selectAllCustomTypes(store).filter(hasLocal),
|
|
22
|
-
modalData: store.pushChanges,
|
|
23
|
-
}),
|
|
24
|
-
);
|
|
25
|
-
const { closeModals, openToaster } = useSliceMachineActions();
|
|
26
|
-
|
|
27
|
-
if (!isOpen) return null;
|
|
28
|
-
|
|
29
|
-
if (modalData?.details === undefined) {
|
|
30
|
-
openToaster("No change data", ToasterType.ERROR);
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const hasMoreThanOne = modalData?.details.customTypes.length > 1;
|
|
35
|
-
|
|
36
|
-
const associatedDocumentsCards = modalData.details.customTypes.map(
|
|
37
|
-
(customTypeDetail) => {
|
|
38
|
-
const customType = localCustomTypes.find(
|
|
39
|
-
(customType) => getModelId(customType) === customTypeDetail.id,
|
|
40
|
-
);
|
|
41
|
-
if (customType === undefined) return null;
|
|
42
|
-
|
|
43
|
-
return (
|
|
44
|
-
<CustomTypesReferencesCard
|
|
45
|
-
format={customType.local.format}
|
|
46
|
-
id={customType.local.id}
|
|
47
|
-
name={customType.local.label ?? customType.local.id}
|
|
48
|
-
/>
|
|
49
|
-
);
|
|
50
|
-
},
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
return (
|
|
54
|
-
<SliceMachineDrawerUI
|
|
55
|
-
isOpen={isOpen}
|
|
56
|
-
title={"Missing Slices"}
|
|
57
|
-
footer={
|
|
58
|
-
<>
|
|
59
|
-
<Button
|
|
60
|
-
label="Try again"
|
|
61
|
-
variant="primary"
|
|
62
|
-
onClick={() => {
|
|
63
|
-
closeModals();
|
|
64
|
-
pushChanges(false);
|
|
65
|
-
}}
|
|
66
|
-
sx={{
|
|
67
|
-
fontWeight: "bold",
|
|
68
|
-
color: "white",
|
|
69
|
-
borderRadius: 6,
|
|
70
|
-
width: "100%",
|
|
71
|
-
}}
|
|
72
|
-
/>
|
|
73
|
-
</>
|
|
74
|
-
}
|
|
75
|
-
explanations={
|
|
76
|
-
<>
|
|
77
|
-
<Text sx={{ fontWeight: "bold", mb: 1, lineHeight: "24px" }}>
|
|
78
|
-
You have{hasMoreThanOne ? "" : " a"} type
|
|
79
|
-
{hasMoreThanOne ? "s" : ""} that reference{" "}
|
|
80
|
-
{hasMoreThanOne ? "" : "s"} one or more missing Slices
|
|
81
|
-
</Text>
|
|
82
|
-
<Text sx={{ mb: 24 }}>
|
|
83
|
-
Before pushing, remove references to any missing Slices by opening{" "}
|
|
84
|
-
the affected type{hasMoreThanOne ? "s" : ""} and clicking the{" "}
|
|
85
|
-
<b>Save</b> button.
|
|
86
|
-
</Text>
|
|
87
|
-
{associatedDocumentsCards}
|
|
88
|
-
</>
|
|
89
|
-
}
|
|
90
|
-
/>
|
|
91
|
-
);
|
|
92
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[25],{54132:function(e,n,t){"use strict";t.d(n,{Z:function(){return a}});var o=t(62230),r=t(85244),i=t(98240),c=t(52322);t(2784);var d=t(75289),s=function(e){var n=e.bg,t=e.background,r=e.sx,i=e.withRadius,s=e.radius,a=e.children;return(0,c.jsx)(d.xu,{sx:(0,o.Z)({p:4,bg:n||t},i?{borderBottomLeftRadius:s,borderBottomRightRadius:s}:null,r),children:a})},a=function(e){var n=e.Header,t=void 0===n?null:n,a=e.SubHeader,l=void 0===a?null:a,u=e.Body,h=void 0===u?null:u,v=e.Footer,m=void 0===v?null:v,f=e.borderFooter,b=e.radius,_=void 0===b?"6px":b,p=e.bodySx,x=e.footerSx,g=e.sx,C=e.bg,j=e.background,Z=e.children,k=(0,i.Z)(e,["Header","SubHeader","Body","Footer","borderFooter","radius","bodySx","footerSx","sx","bg","background","children"]);return(0,c.jsxs)(d.Zb,(0,r.Z)((0,o.Z)({sx:(0,o.Z)({border:function(e){var n;return"1px solid ".concat(String(null===(n=e.colors)||void 0===n?void 0:n.borders))},borderRadius:_},void 0===g?null:g)},k),{children:[t?(0,c.jsx)(t,{radius:_}):null,l?(0,c.jsx)(l,{radius:_}):null,(0,c.jsxs)(s,{bg:C,background:j,sx:void 0===p?{}:p,withRadius:!m,children:[h?(0,c.jsx)(h,{}):null,Z||null]}),m?(0,c.jsx)(s,{bg:C,background:j,sx:(0,o.Z)({},void 0!==f&&f?{borderTop:function(e){var n=e.colors;return"1px solid ".concat(String(null==n?void 0:n.borders))}}:null,void 0===x?{}:x),radius:_,withRadius:!0,children:"object"==typeof m?m:(0,c.jsx)(m,{})}):null]}))}},75329:function(e,n,t){"use strict";t.d(n,{Sn:function(){return d},lS:function(){return o},nG:function(){return r},pq:function(){return s},rd:function(){return c},xo:function(){return i}});var o=["components"],r=["png","jpg","jpeg"],i=/^[A-Za-z0-9]+(?:_[A-Za-z0-9]+)*$/,c="placeholders/What_are_Slices_mrvome",d="SM_HELP_VIDEOS/mock_data",s="slice-machine-simulator"},24804:function(e,n,t){"use strict";t.d(n,{Zb:function(){return b},T$:function(){return p},eW:function(){return x},ZB:function(){return _},Lm:function(){return g}});var o=t(67557),r=t(62230),i=t(85244),c=t(98240),d=t(52322),s=t(50002),a=t(22715),l=t(6277),u=t(2784);t(71457);var h={solid:"_1ecs97d3c _1ecs97dap _1ecs97d4pk _1ecs97d4wx",outlined:"_1ecs97d2i _1ecs97d9v _1ecs97dw _1ecs97d89 _1ecs97d2w _1ecs97da9 _1ecs97d4oq _1ecs97d4w3 _1ecs97d4oc _1ecs97d4vp"},v={div:"_1ecs97dez0 _1ecs97dez3 _1ecs97dezd",img:"kedahr9 _1ecs97df77 _1ecs97dezn"},m={small:"kedahr2",medium:"kedahr3"},f={solid:"kedahr4 _1ecs97d1u _1ecs97d97 _1ecs97d4pe _1ecs97d4wr",outlined:"kedahr5 _1ecs97d18 _1ecs97d8l _1ecs97d4o6 _1ecs97d4vj"},b=function(e){var n,t=e.checked,a=e.size,v=e.variant,b=void 0===v?"solid":v,_=(e.interactive,e.disabled,e.onClick,e.href,e.component),p=void 0===_?"a":_,x=(e.replace,(0,c.Z)(e,["checked","size","variant","interactive","disabled","onClick","href","component","replace"])),g=(0,i.Z)((0,r.Z)({},x),{className:(0,l.W)("_1ecs97dez0 _1ecs97dez2 _1ecs97dezb _1ecs97d3fg _1ecs97d3mt _1ecs97df0r _1ecs97df23 _1ecs97df2h _1ecs97dez1 _1ecs97dezr _1ecs97dezv",m[void 0===a?"medium":a],f[b],(n={},(0,o.Z)(n,"kedahr6",e.interactive),(0,o.Z)(n,h[b],e.interactive),n)),"data-state":!0===(void 0!==t&&t)?"checked":void 0});return!0===e.interactive&&void 0===e.href?(0,d.jsx)("div",(0,i.Z)((0,r.Z)({},g),{"data-disabled":!0===e.disabled?"":void 0,onClick:function(n){if(!0!==e.disabled&&void 0!==e.onClick){var t=n.target;(0,s.JY)(t)===n.currentTarget&&e.onClick(n)}},tabIndex:!0===e.disabled?void 0:0})):!0===e.interactive?(0,u.createElement)(p,(0,r.Z)((0,i.Z)((0,r.Z)({},g),{href:e.href,onClick:function(e){var n=e.target;(0,s.JY)(n)!==e.currentTarget&&e.preventDefault()}}),"a"===p?{}:{replace:e.replace})):(0,d.jsx)("div",(0,r.Z)({},g))},_=function(e){var n=e.className,t=e.component,o=void 0===t?"img":t,s=e.overlay,a=(0,c.Z)(e,["className","component","overlay"]);return(0,d.jsxs)("div",{className:"kedahr7 _1ecs97dez0 _1ecs97dez2 _1ecs97dezb _1ecs97deze _1ecs97dezd _1ecs97df7d _1ecs97dezv",children:[(0,u.createElement)(o,(0,i.Z)((0,r.Z)({},a),{className:(0,l.W)(v[o],n)})),Boolean(s)?(0,d.jsx)("div",{className:"kedahra _1ecs97dez0 _1ecs97dez3 _1ecs97df9d _1ecs97dezt _1ecs97df0i",children:s}):void 0]})},p=function(e){return(0,d.jsx)("div",(0,i.Z)((0,r.Z)({},e),{className:"kedahrc kedahrb _1ecs97dez0 _1ecs97dez2 _1ecs97dez8 _1ecs97dez1 _1ecs97dezc _1ecs97df71 _1ecs97dezi"}))},x=function(e){var n=e.action,t=e.subtitle,o=e.title,s=(0,c.Z)(e,["action","subtitle","title"]);return(0,d.jsxs)("div",(0,i.Z)((0,r.Z)({},s),{className:"kedahrd kedahrb _1ecs97dez0 _1ecs97dez2 _1ecs97dez8 _1ecs97dez1 _1ecs97dezc _1ecs97df92 _1ecs97df73",children:[(0,d.jsxs)("div",{className:"kedahre _1ecs97dez0 _1ecs97dez2 _1ecs97dezb _1ecs97deze _1ecs97dezd _1ecs97df51",children:[(0,d.jsx)(a.xv,{component:"span",noWrap:!0,variant:"bold",children:o}),(0,d.jsx)(a.xv,{color:"grey11",component:"span",noWrap:!0,variant:"small",children:t})]}),n]}))},g=function(e){var n=e.children,t=(0,c.Z)(e,["children"]);return(0,d.jsx)("div",(0,i.Z)((0,r.Z)({},t),{className:"kedahrf _1ecs97dez0 _1ecs97dez2 _1ecs97dezb _1ecs97df6v _1ecs97dfb5 _1ecs97dezh _1ecs97dfhi _1ecs97dezt",children:(0,d.jsx)(a.xv,{align:"center",color:"inherit",component:"span",noWrap:!0,variant:"smallBold",children:n})}))}},34728:function(e,n,t){"use strict";t.d(n,{O:function(){return d}});var o=t(52322),r=t(22715),i=t(32681),c=t(79096),d=function(e){var n=function(e){var n=s[e.modelType];switch(e.modelStatus){case i.G.New:return{badgeColor:"green",badgeTitle:"New",tooltipContent:"This ".concat(n," exists only locally. Upon sync, it will be pushed to your remote repository.")};case i.G.Modified:return{badgeColor:"amber",badgeTitle:"Modified",tooltipContent:"This ".concat(n," has been modified locally. Upon sync, changes will be pushed to your remote repository.")};case i.G.Synced:return{badgeColor:"purple",badgeTitle:"Synced",tooltipContent:"This ".concat(n," is in sync with the remote repository.")};case i.G.Deleted:return{badgeColor:"tomato",badgeTitle:"Deleted",tooltipContent:"This ".concat(n," has been deleted locally.")};case i.G.Unknown:if(!e.isOnline)return{badgeColor:"grey",badgeTitle:"Unknown",tooltipContent:"Data from the remote repository could not be fetched (no internet connection)."};if(e.authStatus===c.t.UNAUTHORIZED)return{badgeColor:"grey",badgeTitle:"Unknown",tooltipContent:"Data from the remote repository could not be fetched (not connected to Prismic)."};if(e.authStatus===c.t.FORBIDDEN)return{badgeColor:"grey",badgeTitle:"Unknown",tooltipContent:"Data from the remote repository could not be fetched (you don't have access to the repository)."};default:return{badgeColor:"grey",badgeTitle:"Unknown",tooltipContent:"Data from the remote repository could not be fetched (unknown error)."}}}(e),t=n.badgeColor,d=n.badgeTitle,a=n.tooltipContent;return(0,o.jsx)(r.u,{content:a,side:"bottom",children:(0,o.jsx)(r.Ct,{color:t,title:d})})},s={CustomType:"type",Slice:"slice"}},71749:function(e,n,t){"use strict";t.d(n,{b:function(){return _}});var o=t(62230),r=t(85244),i=t(52322),c=t(22715),d=t(39097),s=t.n(d),a=t(67557),l=t(17064),u={build:function(e){var n;return(0,r.Z)((0,o.Z)({},e),{screenshots:(n=e.screenshots)?Object.entries(n).reduce(function(e,n){var t,i=(0,l.Z)(n,2),c=i[0],d=i[1];return d.hash?(0,r.Z)((0,o.Z)({},e),(0,a.Z)({},c,(0,o.Z)({},d,{hash:d.hash}))):e},{}):{}})},variation:function(e,n){if(e.model.variations.length)return n?e.model.variations.find(function(e){return e.id===n}):e.model.variations[0]}},h=t(24804),v=t(5479),m=t(34728),f=t(49451),b=function(e){return(0,i.jsx)("svg",(0,r.Z)((0,o.Z)({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:(0,i.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 5.5C4 4.67157 4.67157 4 5.5 4H18.5C19.3284 4 20 4.67157 20 5.5V12.4413C20 12.4512 19.9997 12.461 19.9991 12.4707C20.0072 12.6083 19.9586 12.7485 19.8536 12.8536C19.6583 13.0488 19.3417 13.0488 19.1464 12.8536L16.3536 10.0607C16.1583 9.8654 15.8417 9.8654 15.6464 10.0607L11.8536 13.8536C11.6583 14.0488 11.3417 14.0488 11.1464 13.8536L9.35355 12.0607C9.15829 11.8654 8.84171 11.8654 8.64645 12.0607L5 15.7071V18.5C5 18.7761 5.22386 19 5.5 19H12.5C12.7761 19 13 19.2239 13 19.5C13 19.7761 12.7761 20 12.5 20H5.5C4.67157 20 4 19.3284 4 18.5V15.5003V15.4997V5.5ZM11.5 12.7929L14.9393 9.35355C15.5251 8.76777 16.4749 8.76777 17.0607 9.35355L19 11.2929V5.5C19 5.22386 18.7761 5 18.5 5H5.5C5.22386 5 5 5.22386 5 5.5V14.2929L7.93934 11.3536C8.52513 10.7678 9.47487 10.7678 10.0607 11.3536L11.5 12.7929ZM16.5 13C16.7761 13 17 13.2239 17 13.5V16H19.5C19.7761 16 20 16.2239 20 16.5C20 16.7761 19.7761 17 19.5 17H17V19.5C17 19.7761 16.7761 20 16.5 20C16.2239 20 16 19.7761 16 19.5V17H13.5C13.2239 17 13 16.7761 13 16.5C13 16.2239 13.2239 16 13.5 16H16V13.5C16 13.2239 16.2239 13 16.5 13Z",fill:"currentColor"})}))},_=function(e){var n,t=e.action,d=e.isComingSoon,a=void 0!==d&&d,l=e.isDeleted,_=e.onUpdateScreenshot,g=e.selected,C=void 0!==g&&g,j=e.slice,Z=e.variant,k=e.variationId,y=u.variation(j,k);if(!y)return null;var z=(0,v.d7)(j,y),S=a||void 0!==l&&l,w=!S&&!!_,T="outlined"===Z,N=void 0!==k;return n="selection"===e.mode?{disabled:S,interactive:!0,onClick:function(){e.onSelectedChange(!C)}}:S?{interactive:!1}:{component:s(),href:f.Y.getBuilderPagePathname({libraryName:j.href,sliceName:j.model.name,variationId:y.id}),interactive:!0,replace:e.replace},(0,i.jsxs)(h.Zb,(0,r.Z)((0,o.Z)({"aria-label":"".concat(j.model.name," ").concat(y.name," slice card"),checked:C,"data-cy":"shared-slice-card","data-testid":"shared-slice-card"},n,"outlined"===Z?{size:"small",variant:"outlined"}:{}),{children:[void 0!==z?(0,i.jsx)(h.ZB,{alt:"Preview image",overlay:w&&!T?(0,i.jsx)(c.xu,{alignItems:"center",justifyContent:"center",children:(0,i.jsx)(p,{onClick:_})}):void 0,src:z}):(0,i.jsx)(h.ZB,{component:"div",children:(0,i.jsxs)(c.xu,{alignItems:"center",flexDirection:"column",gap:8,justifyContent:"center",children:[(0,i.jsx)(c.xv,{color:"grey11",component:"span",children:"No screenshot available"}),w&&!T?(0,i.jsx)(p,{onClick:_}):void 0]})}),(0,i.jsx)(h.eW,{action:"checkbox"===t.type&&"selection"===e.mode?(0,i.jsx)("div",{onClick:function(e){return e.stopPropagation()},children:(0,i.jsx)(c.XZ,{checked:C,disabled:S,onCheckedChange:e.onSelectedChange})}):"menu"===t.type?(0,i.jsxs)(c.h_,{modal:!0,children:[(0,i.jsx)(c.$F,{disabled:S,children:(0,i.jsx)(c.hU,{hiddenLabel:"Slice actions",icon:"moreVert"})}),(0,i.jsxs)(c.AW,{align:"end","data-cy":"slice-action-icon-dropdown",children:[w&&T?(0,i.jsx)(c.Xi,{onSelect:_,startIcon:(0,i.jsx)(b,{}),children:"Update screenshot"}):void 0,(0,i.jsx)(c.Xi,{onSelect:t.onRename,startIcon:(0,i.jsx)(c.I5,{name:"edit"}),children:"Rename"}),!0===t.removeDisabled&&N?(0,i.jsx)(c.u,{content:"The slice needs to have at least one variation.",side:"bottom",stableMount:!0,children:(0,i.jsx)(x,{disabled:!0,onSelect:t.onRemove})}):(0,i.jsx)(x,{disabled:!0===t.removeDisabled,onSelect:t.onRemove})]})]}):"remove"===t.type?(0,i.jsx)(c.hU,{icon:"close",onClick:function(){return!S&&t.onRemove()},hiddenLabel:"Remove slice"}):"status"===t.type?(0,i.jsx)(m.O,{authStatus:t.authStatus,isOnline:t.isOnline,modelStatus:t.modelStatus,modelType:"Slice"}):void 0,subtitle:(0,i.jsxs)(i.Fragment,{children:[N?y.id:"".concat(j.model.variations.length," variation").concat(j.model.variations.length>1?"s":""),a?(0,i.jsxs)(c.xv,{color:"purple11",component:"span",variant:"small",children:[" ","• (coming soon)"]}):void 0]}),title:N?y.name:j.model.name}),w&&!N&&(0,v.cx)(j)>0?(0,i.jsx)(h.Lm,{children:"Missing screenshot"}):void 0]}))},p=function(e){return(0,i.jsx)(c.zx,{onClick:e.onClick,renderStartIcon:function(){return(0,i.jsx)(b,{color:c.TV.color.greyLight11})},color:"grey",children:"Update screenshot"})},x=function(e){return(0,i.jsx)(c.Xi,(0,r.Z)((0,o.Z)({},e),{color:"tomato",startIcon:(0,i.jsx)(c.I5,{name:"delete"}),children:"Delete"}))}},49451:function(e,n,t){"use strict";t.d(n,{Y:function(){return o}});var o={getBuilderPagePathname:function(e){return"/slices/".concat(e.libraryName.replaceAll("/","--"),"/").concat(e.sliceName,"/").concat(e.variationId)}}},71457:function(){}}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[849],{21985:function(e,n,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/changes",function(){return t(4920)}])},56577:function(e,n,t){"use strict";t.d(n,{z:function(){return u}});var s=t(62230),i=t(85244),r=t(98240),a=t(52322),o=t(2784),c=t(75289),l=function(e,n){return e?"".concat(e,"-").concat(n):""},d=function(e){switch(e){case"white":case"secondaryMedium":case"secondarySmall":case"secondary":return"#1A1523";default:return"grey01"}},u=(0,o.forwardRef)(function(e,n){var t=e.label,o=e.Icon,u=e.type,h=e.form,x=e.isLoading,m=void 0!==x&&x,f=e.disabled,p=e.onClick,g=e.sx,j=e.iconSize,v=void 0===j?16:j,y=e.iconFill,b=e.variant,_=void 0===b?"primary":b,C=(0,r.Z)(e,["label","Icon","type","form","isLoading","disabled","onClick","sx","iconSize","iconFill","variant"]);return(0,a.jsx)(c.zx,(0,i.Z)((0,s.Z)({ref:n,sx:(0,s.Z)((0,i.Z)((0,s.Z)({},void 0===g?{}:g),{display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"}),m?{cursor:"wait !important"}:{}),type:u,form:h,disabled:void 0!==f&&f||m,onClick:m?void 0:p,variant:_},C),{children:m?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(c.$j,{size:v,color:d(_),"data-cy":l(C["data-cy"],"spinner")}),o&&t]}):(0,a.jsxs)(a.Fragment,{children:[o&&(0,a.jsx)(o,{size:v,fill:y,"data-cy":l(C["data-cy"],"icon")}),t]})}))})},59469:function(e,n,t){"use strict";var s=t(62230),i=t(52322),r=t(75289);n.Z=function(e){var n=e.elems,t=e.renderElem,a=e.defineElementKey,o=e.gridTemplateMinPx,c=e.gridGap,l=e.sx;return(0,i.jsx)(r.xu,{as:"section",sx:(0,s.Z)({display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(".concat(void 0===o?"320px":o,", 1fr))"),gridGap:void 0===c?"16px":c,pt:2},l),children:n.map(function(e,n){return e?(0,i.jsx)("span",{children:t(e,n)},"".concat(a(e),"-").concat(n+1)):null})})}},4920:function(e,n,t){"use strict";t.r(n),t.d(n,{default:function(){return ed}});var s=t(52322),i=t(22715),r=t(2784),a=t(97729),o=t.n(a),c=t(65077),l=t(56580),d=t(22337),u=t(75289),h=t(951),x=function(e){var n=e.children;return(0,s.jsx)(u.kC,{sx:{alignItems:"center",justifyContent:"space-between",mt:"8px",bg:"grey02",borderRadius:4,padding:"12px 16px"},children:n})},m=t(39097),f=t.n(m),p=t(7819),g=t(34728),j=t(67445),v=function(e){var n=e.ct,t=e.status,i=e.authStatus,r=e.isOnline;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(u.xu,{as:"td",style:{width:"40%"},children:(0,s.jsx)(u.xv,{sx:{fontWeight:500},children:n.label})}),(0,s.jsx)(u.xu,{as:"td",style:{width:"40%"},children:n.id}),(0,s.jsx)(u.xu,{as:"td",style:{width:"20%"},children:(0,s.jsx)(g.O,{authStatus:i,isOnline:r,modelStatus:t,modelType:"CustomType"})})]})},y=function(e){var n=e.customTypes,t=e.modelsStatuses,i=e.authStatus,r=e.isOnline;return(0,s.jsxs)(u.xu,{as:"table","data-legacy-component":!0,children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{className:"transparent small",children:[(0,s.jsx)(u.xu,{as:"th",sx:{width:"40%",fontWeight:600},children:"Name"}),(0,s.jsx)(u.xu,{as:"th",sx:{width:"40%",fontWeight:600},children:"API ID"}),(0,s.jsx)(u.xu,{as:"th",sx:{width:"20%",fontWeight:600},children:"Status"})]})}),(0,s.jsx)("tbody",{children:n.map(function(e){return(0,p.TG)(e)?(0,s.jsx)(f(),{passHref:!0,href:j.cd[e.local.format].getBuilderPagePathname(e.local.id),legacyBehavior:!0,children:(0,s.jsx)("tr",{tabIndex:0,"data-cy":"custom-type-".concat(e.local.id),children:(0,s.jsx)(v,{ct:e.local,status:t.customTypes[e.local.id],authStatus:i,isOnline:r,modelsStatuses:t},e.local.id)})},e.local.id):(0,s.jsx)("tr",{tabIndex:0,className:"disabled","data-cy":"custom-type-".concat(e.remote.id),children:(0,s.jsx)(v,{ct:e.remote,status:t.customTypes[e.remote.id],authStatus:i,isOnline:r,modelsStatuses:t},e.remote.id)})})})]})},b=t(59469),_=t(15836),C=t(5479),S=t(47731),D=t(32681),T=t(71749),k=function(e){var n=e.unSyncedCustomTypes,t=e.unSyncedSlices,i=e.modelsStatuses,r=e.authStatus,a=e.isOnline,o=(0,S.H)(),c=o.modalPayload,l=o.onOpenModal,d=c.sliceFilterFn,m=c.defaultVariationSelector,f=t.filter(function(e){return i.slices[e.model.id]!==D.G.Deleted});return(0,s.jsxs)(s.Fragment,{children:[n.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(x,{children:(0,s.jsxs)(u.xu,{children:[(0,s.jsx)(u.xv,{variant:"heading",children:"Types"}),(0,s.jsx)(u.xv,{variant:"grey",sx:{ml:"8px"},children:n.length})]})}),(0,s.jsx)(y,{customTypes:n,modelsStatuses:i,authStatus:r,isOnline:a})]}),t.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(u.xu,{sx:{mb:"8px"},children:(0,s.jsxs)(x,{children:[(0,s.jsxs)(u.xu,{children:[(0,s.jsx)(u.xv,{variant:"heading",children:"Slices"}),(0,s.jsx)(u.xv,{variant:"grey",sx:{ml:"8px"},children:t.length})]}),(0,s.jsxs)(u.xu,{children:[t.some(function(e){return(0,C.cx)(e)>0&&i.slices[e.model.id]!==D.G.Deleted})&&(0,s.jsxs)(u.xv,{sx:{mr:3,color:"warning02",fontSize:"12px",lineHeight:"16px",fontWeight:600},children:[(0,s.jsx)(h.sQg,{size:16,style:{marginRight:"4px",position:"relative",top:"3px"}}),"Missing Screenshots"]}),(0,s.jsxs)(u.zx,{variant:"darkSmall",onClick:function(){return l({sliceFilterFn:function(e){return e}})},children:[(0,s.jsx)(h.hOO,{style:{color:"#FFF",fontSize:"15px",position:"relative",top:"3px",marginRight:"4px"}})," ","Update all screenshots"]})]})]})}),(0,s.jsx)(b.Z,{gridGap:"32px 16px",elems:t,gridTemplateMinPx:"305px",defineElementKey:function(e){return e.model.name},renderElem:function(e){var n=i.slices[e.model.id];return(0,s.jsx)(T.b,{action:{type:"status",authStatus:r,isOnline:a,modelStatus:n},isDeleted:n===D.G.Deleted,mode:"navigation",onUpdateScreenshot:function(){l({sliceFilterFn:function(n){return n.filter(function(n){return n.model.id===e.model.id})}})},slice:e,variant:"solid"})}}),(0,s.jsx)(_.Z,{slices:d(f),defaultVariationSelector:m})]})]})},z=t(91914),O=function(){return(0,s.jsx)(u.kC,{sx:{justifyContent:"center",alignItems:"center",flex:1},children:(0,s.jsxs)(u.kC,{sx:{flexDirection:"column",alignItems:"center",transform:"translateY(-50%)"},children:[(0,s.jsx)(z.wQ1,{size:48}),(0,s.jsx)(u.xv,{sx:{fontWeight:600,fontSize:"24px",lineHeight:"32px",mb:"8px",mt:"2px",textAlign:"center"},children:"No internet connection"}),(0,s.jsx)(u.xv,{sx:{fontSize:"13px",lineHeight:"24px",textAlign:"center"},children:"You need a stable internet connection to review and push changes"})]})})},w=t(90374),Z=t(79096),R=function(e){var n=e.authStatus,t=(0,w.Z)().openLoginModal;return(0,s.jsxs)(i.xu,{flexDirection:"column",height:"100%",alignItems:"center",justifyContent:"center",gap:8,children:[n===Z.t.FORBIDDEN?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.xv,{variant:"h3",align:"center",children:"It seems like you are logged out"}),(0,s.jsx)(i.xv,{align:"center",children:"Log in to connect to your repository."})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.xv,{variant:"h3",align:"center",children:"It seems like you don't have access to this repository"}),(0,s.jsx)(i.xv,{align:"center",children:"Check that the repository name is correct, then contact your repository administrator."})]}),(0,s.jsxs)(i.xv,{align:"center",children:["If that doesn't work, it's possible that Slice Machine is having trouble accessing Prismic's servers."," ",(0,s.jsx)(i.hh,{href:"https://community.prismic.io/",children:"Contact our support team"}),"."]}),n===Z.t.FORBIDDEN&&(0,s.jsx)(i.zx,{onClick:function(){return t()},children:"Log in to Prismic"})]})},E=t(5632),N=t.n(E),F=t(2754),I=t(34543),M=t(62230),P=t(85244),H=t(98240),W=t(6277);t(25977);var A={primary:"_1ecs97dbc8 _1ecs97dbjl _1ecs97dbc2 _1ecs97dbjf _1ecs97dbca _1ecs97dbjn",secondary:"_1ecs97daji _1ecs97dah3 _1ecs97dajc _1ecs97dagx _1ecs97dajk _1ecs97dah5"},B={normal:"ovkapw1",smallBold:"ovkapw2",inherit:"ovkapw3 _1ecs97df47"},G=function(e){var n=e.children,t=e.color,a=e.endIcon,o=e.href,c=e.textVariant,l=void 0===c?"smallBold":c,d=(0,H.Z)(e,["children","color","endIcon","href","textVariant"]);return(0,s.jsxs)("a",(0,P.Z)((0,M.Z)({href:o,target:"_blank",rel:"noreferrer"},d),{className:(0,W.Z)("ovkapw0 _1ecs97dez0 _1ecs97df41 _1ecs97dez2 _1ecs97dez8",A[void 0===t?"primary":t]),children:[(0,s.jsx)(i.xv,{component:"span",color:"inherit",variant:l,children:n}),(0,r.isValidElement)(a)?(0,r.cloneElement)(a,{className:(0,W.Z)(a.props.className,"_1ecs97dfhw",B[l])}):null]}))},L=t(39092),U=function(){var e,n=(e=(0,l.v9)(function(e){return{repoName:(0,L.MY)(e)}}).repoName,"https://".concat(e,".prismic.io/documents/working"));return(0,s.jsxs)(F.R$,{style:{alignSelf:"center",marginTop:i.TV.size[72]},children:[(0,s.jsx)(F.u2,{children:(0,s.jsx)(i.Ee,{src:"/blank-slate-changes-uptodate.png",sizing:"cover"})}),(0,s.jsxs)(F.T9,{children:[(0,s.jsx)(F._T,{children:"Everything up-to-date"}),(0,s.jsx)(F.nf,{children:"You have no changes staged. Your changes appear here after you have saved them, while they're waiting to be pushed to the Page Builder. Ready to get going?"}),(0,s.jsxs)(F.Qj,{children:[(0,s.jsx)(i.zx,{onClick:function(){N().push("/")},children:"Create a page type"}),(0,s.jsx)(G,{endIcon:(0,s.jsx)(I.AlO,{}),textVariant:"normal",href:n,children:"Create content"})]})]})]})},V=t(67764),Y=t(32665),X=t(3098),q=t(56577),Q=t(24340),$=t(77174),J=t(49471),K=t(40432),ee=t(78656),en=function(e){var n=e.ctName,t=e.numberOfDocuments,i=e.link,r=e.isOverLimit;return(0,s.jsxs)(u.Zb,{sx:{mb:12},variant:"drawerCard","data-cy":"AssociatedDocumentsCard-".concat(n),children:[(0,s.jsxs)(u.kC,{sx:{flexDirection:"column"},children:[(0,s.jsx)(u.xv,{children:n}),(0,s.jsxs)(u.xv,{sx:{color:"textClear",fontSize:"12px",lineHeight:"16px"},children:[t," documents"]})]}),(0,s.jsx)(u.rU,{href:i,target:"_blank",variant:"cardSmall",sx:{color:void 0!==r&&r?"danger":"purple08"},children:"View documents"})]})},et=function(e){var n=e.format,t=e.id,i=e.name;return(0,s.jsxs)(u.Zb,{sx:{mb:12},variant:"drawerCard","data-cy":"CustomTypesReferencesCard-".concat(i),children:[(0,s.jsxs)(u.kC,{sx:{flexDirection:"column"},children:[(0,s.jsx)(u.xv,{children:i}),(0,s.jsx)(u.xv,{sx:{color:"textClear",fontSize:"12px",lineHeight:"16px"},children:"Missing Slices"})]}),(0,s.jsxs)(u.rU,{href:j.cd[n].getBuilderPagePathname(t),target:"_blank",variant:"cardSmall",children:["View ",ee.$[n].name({start:!1,plural:!1})]},t)]})},es=t(79797),ei=t(54132),er=function(e){var n=e.isOpen,t=e.title,i=e.footer,r=e.explanations,a=(0,w.Z)().closeModals;return(0,s.jsx)(es.Z,{placement:"right",open:n,level:null,onClose:a,width:496,children:(0,s.jsx)(ei.Z,{radius:"0px",bodySx:{bg:"white",padding:24,flex:1,display:"flex",flexDirection:"column",overflow:"scroll"},footerSx:{p:0},sx:{flexDirection:"column",display:"flex",height:"100%",border:"none"},borderFooter:!0,Header:function(){return(0,s.jsxs)(u.kC,{sx:{p:"16px",alignItems:"center",justifyContent:"space-between",borderBottom:function(e){var n;return"1px solid ".concat(String(null===(n=e.colors)||void 0===n?void 0:n.borders))}},children:[(0,s.jsx)(u.kC,{sx:{alignItems:"center"},children:(0,s.jsx)(u.X6,{sx:{fontSize:"14px",fontWeight:"bold",ml:1},children:t})}),(0,s.jsx)(u.x8,{type:"button",onClick:function(){return a()}})]})},Footer:function(){return(0,s.jsx)(u.kC,{sx:{flexDirection:"column",justifyContent:"center",alignItems:"center",paddingRight:16,borderTop:function(e){var n;return"1px solid ".concat(String(null===(n=e.colors)||void 0===n?void 0:n.darkBorders))},backgroundColor:"white",padding:20},children:i})},children:r})})},ea=function(e){var n=e.onToggle,t=e.isConfirmed,i=e.sx;return(0,s.jsxs)(u.kC,{sx:(0,M.Z)({borderRadius:6,flexDirection:"column",backgroundColor:"grey03",padding:12,width:"100%"},i),children:[(0,s.jsx)(u.xv,{sx:{fontWeight:"bold",mb:2},children:"Are you sure to proceed?"}),(0,s.jsxs)(u.__,{sx:{mt:"4px",py:1},variant:"large",children:[(0,s.jsx)(u.XZ,{defaultChecked:t,onChange:n,variant:"forms.checkbox.dark"}),"Delete these Documents"]})]})},eo=function(e){var n=e.pushChanges,t=(0,r.useState)(!1),i=t[0],a=t[1],o=(0,l.v9)(function(e){return{isDeleteDocumentsDrawerOpen:(0,$.gP)(e,Q.q.SOFT_DELETE_DOCUMENTS_DRAWER),remoteOnlyCustomTypes:(0,J.Ch)(e).filter(p.yp),modalData:e.pushChanges}}),c=o.isDeleteDocumentsDrawerOpen,d=o.remoteOnlyCustomTypes,h=o.modalData,x=(0,w.Z)(),m=x.closeModals,f=x.openToaster;if(!c)return null;if((null==h?void 0:h.type)!=="SOFT")return f("No change data",K.Jf.ERROR),null;var g=h.details.customTypes.map(function(e){var n,t=d.find(function(n){return(0,p.n5)(n)===e.id});return void 0===t?null:(0,s.jsx)(en,{isOverLimit:!0,ctName:null!==(n=t.remote.label)&&void 0!==n?n:t.remote.id,link:e.url,numberOfDocuments:e.numberOfDocuments},e.id)});return(0,s.jsx)(er,{isOpen:c,title:"Confirm deletion",footer:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ea,{onToggle:function(){a(!i)},isConfirmed:i,sx:{mb:10}}),(0,s.jsx)(q.z,{label:"Push changes",variant:"primary",onClick:function(){m(),n(i)},disabled:!i,sx:{fontWeight:"bold",color:"white",borderRadius:6,width:"100%"}})]}),explanations:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(u.xv,{sx:{fontWeight:"bold",mb:1,lineHeight:"24px"},children:"This action will also delete Documents."}),(0,s.jsxs)(u.xv,{sx:{mb:24},children:[h.details.customTypes.length>1?"These types have":"This type has"," ","associated Documents, which will also be deleted. This might create broken links in your repository."]}),g]})})},ec=function(e){var n=e.pushChanges,t=(0,l.v9)(function(e){return{isDeleteDocumentsDrawerOpen:(0,$.gP)(e,Q.q.HARD_DELETE_DOCUMENTS_DRAWER),remoteOnlyCustomTypes:(0,J.Ch)(e).filter(p.yp),modalData:e.pushChanges}}),i=t.isDeleteDocumentsDrawerOpen,r=t.remoteOnlyCustomTypes,a=t.modalData,o=(0,w.Z)(),c=o.closeModals,d=o.openToaster;if(!i)return null;if((null==a?void 0:a.type)!=="HARD")return d("No change data",K.Jf.ERROR),null;var h=a.details.customTypes.map(function(e){var n,t=r.find(function(n){return(0,p.n5)(n)===e.id});return void 0===t?null:(0,s.jsx)(en,{isOverLimit:!0,ctName:null!==(n=t.remote.label)&&void 0!==n?n:t.remote.id,link:e.url,numberOfDocuments:e.numberOfDocuments},e.id)});return(0,s.jsx)(er,{isOpen:i,title:"Manual action required",footer:(0,s.jsx)(q.z,{label:"Try again",variant:"primary",onClick:function(){c(),n(!1)},sx:{fontWeight:"bold",color:"white",borderRadius:6,width:"100%"}}),explanations:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(u.xv,{sx:{fontWeight:"bold",mb:1,lineHeight:"24px"},children:["Your type",a.details.customTypes.length>1&&"s"," cannot be deleted."]}),(0,s.jsxs)(u.xv,{sx:{mb:24},children:[a.details.customTypes.length>1?"These types have":"This type has"," ","too many associated Documents. Archive and delete these Documents manually and then try deleting the types again."]}),h]})})},el=function(e){var n=e.pushChanges,t=(0,l.v9)(function(e){return{isOpen:(0,$.gP)(e,Q.q.REFERENCES_MISSING_DRAWER),localCustomTypes:(0,J.Ch)(e).filter(p.TG),modalData:e.pushChanges}}),i=t.isOpen,r=t.modalData,a=t.localCustomTypes,o=(0,w.Z)(),c=o.closeModals,d=o.openToaster;if(!i)return null;if((null==r?void 0:r.details)===void 0)return d("No change data",K.Jf.ERROR),null;var h=(null==r?void 0:r.details.customTypes.length)>1,x=r.details.customTypes.map(function(e){var n,t=a.find(function(n){return(0,p.n5)(n)===e.id});return void 0===t?null:(0,s.jsx)(et,{format:t.local.format,id:t.local.id,name:null!==(n=t.local.label)&&void 0!==n?n:t.local.id})});return(0,s.jsx)(er,{isOpen:i,title:"Missing Slices",footer:(0,s.jsx)(s.Fragment,{children:(0,s.jsx)(q.z,{label:"Try again",variant:"primary",onClick:function(){c(),n(!1)},sx:{fontWeight:"bold",color:"white",borderRadius:6,width:"100%"}})}),explanations:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(u.xv,{sx:{fontWeight:"bold",mb:1,lineHeight:"24px"},children:["You have",h?"":" a"," type",h?"s":""," that reference"," ",h?"":"s"," one or more missing Slices"]}),(0,s.jsxs)(u.xv,{sx:{mb:24},children:["Before pushing, remove references to any missing Slices by opening"," ","the affected type",h?"s":""," and clicking the"," ",(0,s.jsx)("b",{children:"Save"})," button."]}),x]})})},ed=function(){var e=(0,V.X)(),n=e.unSyncedSlices,t=e.unSyncedCustomTypes,a=e.modelsStatuses,u=e.authStatus,h=e.isOnline,x=(0,r.useMemo)(function(){var e;return{changedSlices:n.map(function(e){return{slice:e,status:a.slices[e.model.id]}}).filter(function(e){return V.O.includes(e.status)}),changedCustomTypes:t.map(function(e){return(0,p.TG)(e)?e.local:e.remote}).map(function(e){return{customType:e,status:a.customTypes[e.id]}}).filter(function(e){return V.O.includes(e.status)})}},[n,t,a]),m=x.changedSlices,f=x.changedCustomTypes,g=(0,w.Z)(),j=g.pushChanges,v=g.closeModals,y=(0,l.v9)(function(e){return{isSyncing:(0,Y.hg)(e,X.z.CHANGES_PUSH)}}).isSyncing;(0,r.useEffect)(function(){return function(){v()}},[]);var b=n.length+t.length,_=function(e){return j({confirmDeleteDocuments:e,changedSlices:m,changedCustomTypes:f})},C=(0,r.useMemo)(function(){return h?u===Z.t.UNAUTHORIZED||u===Z.t.FORBIDDEN?(0,s.jsx)(R,{authStatus:u}):0===b?(0,s.jsx)(U,{}):(0,s.jsx)(k,{unSyncedSlices:n,unSyncedCustomTypes:t,modelsStatuses:a,authStatus:u,isOnline:h}):(0,s.jsx)(O,{})},[h,u,b,n,t,a,]);return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o(),{children:(0,s.jsx)("title",{children:"Changes - Slice Machine"})}),(0,s.jsxs)(d.LN,{children:[(0,s.jsxs)(d.wd,{children:[(0,s.jsx)(d.Cx,{folder:"Changes"}),(0,s.jsx)(d.K2,{children:(0,s.jsx)(i.zx,{onClick:function(){return _(!1)},loading:y,disabled:0===b||!h||u===Z.t.UNAUTHORIZED||u===Z.t.FORBIDDEN||y,"data-cy":"push-changes",children:"Push Changes"})})]}),(0,s.jsx)(d.RN,{children:(0,s.jsxs)(c.xR,{sx:{display:"flex",flexDirection:"column"},children:[C,(0,s.jsx)(eo,{pushChanges:_}),(0,s.jsx)(ec,{pushChanges:_}),(0,s.jsx)(el,{pushChanges:_})]})})]})]})}},2754:function(e,n,t){"use strict";t.d(n,{R$:function(){return d},Qj:function(){return f},T9:function(){return h},nf:function(){return m},u2:function(){return u},_T:function(){return x}});var s=t(67557),i=t(62230),r=t(85244),a=t(98240),o=t(52322),c=t(6277),l=t(22715);t(69143);var d=function(e){var n=e.backgroundImage,t=e.style,l=(0,a.Z)(e,["backgroundImage","style"]),d=void 0!==n;return(0,o.jsx)("article",(0,r.Z)((0,i.Z)({},l),{className:(0,c.Z)("_18bjhbz0 _1ecs97dez0 _1ecs97dez1 _1ecs97dez2 _1ecs97dezb _1ecs97dfiv _1ecs97dfix _1ecs97dfiz _1ecs97d3fg _1ecs97d3mt _1ecs97df0r _1ecs97df23 _1ecs97df2h _1ecs97dezp",(0,s.Z)({},"_18bjhbz1 _1ecs97dezx _1ecs97df4v",d)),style:(0,i.Z)({backgroundImage:d?"url(".concat(n,")"):void 0},t)}))},u=function(e){return(0,o.jsx)("div",(0,r.Z)((0,i.Z)({},e),{className:"_1ecs97dez0 _1ecs97dez1 _1ecs97dez2 _1ecs97dezb _1ecs97d6r8 _1ecs97d6yl _1ecs97df29 _1ecs97df2l _1ecs97dezp"}))},h=function(e){return(0,o.jsx)("div",(0,r.Z)((0,i.Z)({},e),{className:"_18bjhbz3 _1ecs97dez0 _1ecs97dez1 _1ecs97dez2 _1ecs97dezb _1ecs97dffv"}))},x=function(e){return(0,o.jsx)(l.xv,(0,r.Z)((0,i.Z)({},e),{className:"_18bjhbz4"}))},m=function(e){return(0,o.jsx)(l.xv,(0,r.Z)((0,i.Z)({},e),{className:"_18bjhbz5",color:"grey11"}))},f=function(e){return(0,o.jsx)("div",(0,r.Z)((0,i.Z)({},e),{className:"_18bjhbz6 _1ecs97dez0 _1ecs97dez8 _1ecs97dez1 _1ecs97dez2 _1ecs97df95 _1ecs97dfdl",color:"grey"}))}},69143:function(){},25977:function(){}},function(e){e.O(0,[898,789,123,543,918,25,286,774,888,179],function(){return e(e.s=21985)}),_N_E=e.O()}]);
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
import { getState, pushChanges, telemetry } from "../../apiClient";
|
|
2
|
-
import {
|
|
3
|
-
call,
|
|
4
|
-
fork,
|
|
5
|
-
put,
|
|
6
|
-
SagaReturnType,
|
|
7
|
-
takeLatest,
|
|
8
|
-
} from "redux-saga/effects";
|
|
9
|
-
import {
|
|
10
|
-
ActionType,
|
|
11
|
-
createAsyncAction,
|
|
12
|
-
getType,
|
|
13
|
-
Reducer,
|
|
14
|
-
} from "typesafe-actions";
|
|
15
|
-
import { withLoader } from "../loading";
|
|
16
|
-
import { openToasterCreator, ToasterType } from "../toaster";
|
|
17
|
-
import { modalOpenCreator } from "../modal";
|
|
18
|
-
import { ModalKeysEnum } from "../modal/types";
|
|
19
|
-
import { LoadingKeysEnum } from "../loading/types";
|
|
20
|
-
import { refreshStateCreator } from "../environment";
|
|
21
|
-
import {
|
|
22
|
-
InvalidCustomTypeResponse,
|
|
23
|
-
PushChangesPayload,
|
|
24
|
-
} from "@lib/models/common/TransactionalPush";
|
|
25
|
-
import { trackPushChangesSuccess } from "./trackPushChangesSuccess";
|
|
26
|
-
import {
|
|
27
|
-
isUnauthenticatedError,
|
|
28
|
-
isUnauthorizedError,
|
|
29
|
-
SliceMachineManagerClient,
|
|
30
|
-
} from "@slicemachine/manager/client";
|
|
31
|
-
import {
|
|
32
|
-
ChangedCustomType,
|
|
33
|
-
ChangedSlice,
|
|
34
|
-
} from "@lib/models/common/ModelStatus";
|
|
35
|
-
|
|
36
|
-
export type ChangesPushSagaPayload = PushChangesPayload & {
|
|
37
|
-
changedSlices: ReadonlyArray<ChangedSlice>;
|
|
38
|
-
changedCustomTypes: ReadonlyArray<ChangedCustomType>;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
type Limit = NonNullable<
|
|
42
|
-
Awaited<
|
|
43
|
-
ReturnType<SliceMachineManagerClient["prismicRepository"]["pushChanges"]>
|
|
44
|
-
>
|
|
45
|
-
>;
|
|
46
|
-
|
|
47
|
-
export const changesPushCreator = createAsyncAction(
|
|
48
|
-
"PUSH_CHANGES.REQUEST",
|
|
49
|
-
"PUSH_CHANGES.RESPONSE",
|
|
50
|
-
"PUSH_CHANGES.FAILURE",
|
|
51
|
-
)<ChangesPushSagaPayload, undefined, Limit | InvalidCustomTypeResponse>();
|
|
52
|
-
|
|
53
|
-
export const sortDocumentLimits = (limit: Readonly<Limit>) => ({
|
|
54
|
-
...limit,
|
|
55
|
-
details: {
|
|
56
|
-
...limit.details,
|
|
57
|
-
customTypes: [...limit.details.customTypes].sort(
|
|
58
|
-
(doc1, doc2) => doc2.numberOfDocuments - doc1.numberOfDocuments,
|
|
59
|
-
),
|
|
60
|
-
},
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
const MODAL_KEY_MAP = {
|
|
64
|
-
["INVALID_CUSTOM_TYPES"]: ModalKeysEnum.REFERENCES_MISSING_DRAWER,
|
|
65
|
-
["SOFT"]: ModalKeysEnum.SOFT_DELETE_DOCUMENTS_DRAWER,
|
|
66
|
-
["HARD"]: ModalKeysEnum.HARD_DELETE_DOCUMENTS_DRAWER,
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
export function* changesPushSaga({
|
|
70
|
-
payload,
|
|
71
|
-
}: ReturnType<typeof changesPushCreator.request>): Generator {
|
|
72
|
-
const startTime = Date.now();
|
|
73
|
-
const { changedSlices, changedCustomTypes } = payload;
|
|
74
|
-
|
|
75
|
-
const sliceChanges = changedSlices.map((sliceChange) => ({
|
|
76
|
-
id: sliceChange.slice.model.id,
|
|
77
|
-
type: "Slice" as const,
|
|
78
|
-
libraryID: sliceChange.slice.from,
|
|
79
|
-
status: sliceChange.status,
|
|
80
|
-
}));
|
|
81
|
-
const customTypeChanges = changedCustomTypes.map((customTypeChange) => ({
|
|
82
|
-
id: customTypeChange.customType.id,
|
|
83
|
-
type: "CustomType" as const,
|
|
84
|
-
status: customTypeChange.status,
|
|
85
|
-
}));
|
|
86
|
-
|
|
87
|
-
// Creating a new payload with the correct format
|
|
88
|
-
const pushPayload = {
|
|
89
|
-
confirmDeleteDocuments: payload.confirmDeleteDocuments,
|
|
90
|
-
changes: [...sliceChanges, ...customTypeChanges],
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
try {
|
|
94
|
-
const response = (yield call(pushChanges, pushPayload)) as SagaReturnType<
|
|
95
|
-
typeof pushChanges
|
|
96
|
-
>;
|
|
97
|
-
|
|
98
|
-
if (response) {
|
|
99
|
-
// sending failure event
|
|
100
|
-
yield put(changesPushCreator.failure(sortDocumentLimits(response)));
|
|
101
|
-
// Tracking when a limit has been reached
|
|
102
|
-
void telemetry.track({
|
|
103
|
-
event: "changes:limit-reach",
|
|
104
|
-
limitType: response.type,
|
|
105
|
-
});
|
|
106
|
-
// Open the corresponding drawer
|
|
107
|
-
yield put(
|
|
108
|
-
modalOpenCreator({
|
|
109
|
-
modalKey: MODAL_KEY_MAP[response.type],
|
|
110
|
-
}),
|
|
111
|
-
);
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const serverState = (yield call(getState)) as SagaReturnType<
|
|
116
|
-
typeof getState
|
|
117
|
-
>;
|
|
118
|
-
yield put(
|
|
119
|
-
refreshStateCreator({
|
|
120
|
-
env: serverState.env,
|
|
121
|
-
remoteCustomTypes: serverState.remoteCustomTypes,
|
|
122
|
-
localCustomTypes: serverState.customTypes,
|
|
123
|
-
libraries: serverState.libraries,
|
|
124
|
-
remoteSlices: serverState.remoteSlices,
|
|
125
|
-
clientError: serverState.clientError,
|
|
126
|
-
}),
|
|
127
|
-
);
|
|
128
|
-
|
|
129
|
-
// Tracking the success of the push
|
|
130
|
-
void trackPushChangesSuccess({ ...payload, startTime });
|
|
131
|
-
|
|
132
|
-
// Send global success event
|
|
133
|
-
yield put(changesPushCreator.success());
|
|
134
|
-
|
|
135
|
-
// Display success toaster
|
|
136
|
-
yield put(
|
|
137
|
-
openToasterCreator({
|
|
138
|
-
content: "All slices and types have been pushed",
|
|
139
|
-
type: ToasterType.SUCCESS,
|
|
140
|
-
}),
|
|
141
|
-
);
|
|
142
|
-
} catch (error) {
|
|
143
|
-
if (isUnauthenticatedError(error) || isUnauthorizedError(error)) {
|
|
144
|
-
yield put(modalOpenCreator({ modalKey: ModalKeysEnum.LOGIN }));
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
// TODO: handle auth errors
|
|
148
|
-
yield put(
|
|
149
|
-
openToasterCreator({
|
|
150
|
-
content:
|
|
151
|
-
"Something went wrong when pushing your changes. Check your terminal logs.",
|
|
152
|
-
type: ToasterType.ERROR,
|
|
153
|
-
}),
|
|
154
|
-
);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function* watchChangesPush() {
|
|
159
|
-
yield takeLatest(
|
|
160
|
-
getType(changesPushCreator.request),
|
|
161
|
-
withLoader(changesPushSaga, LoadingKeysEnum.CHANGES_PUSH),
|
|
162
|
-
);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// Saga Exports
|
|
166
|
-
export function* watchChangesPushSagas() {
|
|
167
|
-
yield fork(watchChangesPush);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// Reducer
|
|
171
|
-
export type PushChangesStoreType = Readonly<
|
|
172
|
-
Limit | InvalidCustomTypeResponse | null
|
|
173
|
-
>;
|
|
174
|
-
type PushChangesActions = ActionType<typeof changesPushCreator>;
|
|
175
|
-
|
|
176
|
-
export const pushChangesReducer: Reducer<
|
|
177
|
-
PushChangesStoreType,
|
|
178
|
-
PushChangesActions
|
|
179
|
-
> = (state = null, action) => {
|
|
180
|
-
switch (action.type) {
|
|
181
|
-
case getType(changesPushCreator.request):
|
|
182
|
-
case getType(changesPushCreator.success):
|
|
183
|
-
return null;
|
|
184
|
-
|
|
185
|
-
case getType(changesPushCreator.failure): {
|
|
186
|
-
return action.payload;
|
|
187
|
-
}
|
|
188
|
-
default:
|
|
189
|
-
return state;
|
|
190
|
-
}
|
|
191
|
-
};
|