slice-machine-ui 1.23.2-beta.1 → 1.23.2-beta.11
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/.depcheckrc +3 -0
- package/components/ChangesEmptyState/OfflinePage.tsx +1 -1
- package/components/ChangesItems/ChangesItems.tsx +6 -2
- package/components/CustomTypeTable/changesPage.tsx +12 -7
- package/components/DeleteSliceModal/index.tsx +37 -24
- package/components/DeleteVariationModal/index.tsx +1 -0
- package/components/Forms/CreateCustomTypeModal/CreateCustomTypeModal.tsx +65 -38
- package/components/Forms/CreateSliceModal/CreateSliceModal.tsx +3 -1
- package/components/Forms/RenameCustomTypeModal/RenameCustomTypeModal.tsx +7 -2
- package/components/Forms/RenameSliceModal/RenameSliceModal.tsx +36 -21
- package/components/Forms/RenameVariationModal/RenameVariationModal.tsx +0 -1
- package/components/LoginModal/index.tsx +40 -2
- package/components/ModalFormCard/index.tsx +0 -1
- package/components/Navigation/ChangesItem.tsx +117 -0
- package/components/Navigation/Environment.tsx +51 -4
- package/components/Navigation/index.css.ts +1 -2
- package/components/Navigation/index.test.tsx +5 -85
- package/components/Navigation/index.tsx +32 -20
- package/components/ReviewModal/ReviewForm.tsx +0 -1
- package/lib/builders/SliceBuilder/index.tsx +3 -3
- package/lib/builders/common/EditModal/Form.jsx +0 -1
- package/lib/builders/common/Zone/Card/components/NewField.tsx +0 -1
- package/lib/models/common/ModelStatus/index.ts +25 -0
- package/lib/models/common/widgets/StructuredText/index.ts +1 -1
- package/out/404.html +1 -1
- package/out/_next/static/chunks/18539003-5f78714a35fde4a1.js +97 -0
- package/out/_next/static/chunks/25-3aa4d4b24167d340.js +1 -0
- package/out/_next/static/chunks/318-19dbcae10cdb6408.js +1 -0
- package/out/_next/static/chunks/727-de03055e40815a3a.js +1 -0
- package/out/_next/static/chunks/777-8c5507e3b119b5dc.js +8 -0
- package/out/_next/static/chunks/799-0af1215eb2b3c17e.js +1 -0
- package/out/_next/static/chunks/904-40686b0426716111.js +1 -0
- package/out/_next/static/chunks/pages/_app-bca191df4ac7078e.js +434 -0
- package/out/_next/static/chunks/pages/{changelog-afd18276fe018b24.js → changelog-cb1df3a70b20f1b8.js} +1 -1
- package/out/_next/static/chunks/pages/changes-ccfd715c2bdc4f83.js +1 -0
- 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/{labs-ee206005948f8e87.js → labs-2adfb5127f9c4081.js} +1 -1
- package/out/_next/static/chunks/pages/page-types/{[pageTypeId]-d1ffca11c42f2603.js → [pageTypeId]-84a22c5e480d3fa9.js} +1 -1
- package/out/_next/static/chunks/pages/settings-94bcd7422e8b237d.js +1 -0
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/{simulator-897ca93c114a1435.js → simulator-aaf65fbec8f5839c.js} +1 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-90bb2ea76d2abf42.js +1 -0
- package/out/_next/static/chunks/pages/slices-e0ce615c38e8338d.js +1 -0
- package/out/_next/static/css/39e089aad1742a3a.css +1 -0
- package/out/_next/static/css/{37153180c3b0dd66.css → 838fd8bb5a7c32b0.css} +1 -1
- package/out/_next/static/css/ca32882a5d2d8d88.css +1 -0
- package/out/_next/static/dS_xZnzzna6Y6uwcTgf90/_buildManifest.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/settings.html +1 -0
- 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 +9 -6
- package/pages/_app.tsx +34 -32
- package/pages/changes.tsx +27 -41
- package/pages/settings.tsx +1 -0
- package/pages/slices.tsx +20 -8
- package/postcss.config.js +10 -0
- package/src/apiClient.ts +1 -22
- package/src/components/FieldSet/FieldSet.stories.tsx +20 -11
- package/src/components/RelativeTime/RelativeTime.stories.tsx +25 -0
- package/src/components/RelativeTime/RelativeTime.tsx +40 -0
- package/src/components/RelativeTime/index.ts +1 -0
- package/src/components/SideNav/SideNav.css.ts +1 -1
- package/src/components/SideNav/SideNav.tsx +9 -5
- package/src/components/SideNav/SideNavEnvironmentSelector.tsx +31 -11
- package/src/domain/__tests__/customType.test.ts +205 -19
- package/src/domain/customType.ts +132 -7
- package/src/domain/slice.ts +38 -0
- package/src/features/autoSave/AutoSaveStatusIndicator.tsx +4 -4
- 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/CustomTypeProvider.tsx +11 -10
- package/src/features/customTypes/customTypesBuilder/CustomTypesBuilderPage.tsx +5 -3
- package/src/features/customTypes/customTypesTable/CustomTypesTable.tsx +8 -8
- package/src/features/customTypes/customTypesTable/CustomTypesTablePage.tsx +18 -17
- package/src/features/environments/actions/setEnvironment.ts +4 -4
- package/src/features/settings/SettingsPage.tsx +47 -0
- package/src/features/settings/git/ConnectGitRepository.tsx +126 -0
- package/src/features/settings/git/ConnectGitRepositoryBlankSlate.tsx +33 -0
- package/src/features/settings/git/GitOwnerSelect.tsx +71 -0
- package/src/features/settings/git/GitProvider.ts +40 -0
- package/src/features/settings/git/GitProviderConnectButtons.tsx +63 -0
- package/src/features/settings/git/GitRepositoriesList.tsx +76 -0
- package/src/features/settings/git/GitRepositoriesSearch.tsx +69 -0
- package/src/features/settings/git/GitRepositoryConnectDialog.tsx +85 -0
- package/src/features/settings/git/GitRepositoryDisconnectDialog.tsx +60 -0
- package/src/features/settings/git/useGitIntegrationExperiment.ts +8 -0
- package/src/features/settings/git/useGitOwners.ts +12 -0
- package/src/features/settings/git/useGitRepos.ts +24 -0
- package/src/features/settings/git/useLinkedGitRepos.ts +41 -0
- package/src/features/settings/git/useWriteAPIToken.ts +23 -0
- 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/features/slices/convertLegacySlice/ConvertLegacySliceAsNewSliceDialog.tsx +0 -1
- package/src/features/slices/convertLegacySlice/ConvertLegacySliceAsNewVariationDialog.tsx +0 -1
- package/src/features/slices/convertLegacySlice/ConvertLegacySliceMergeWithIdenticalDialog.tsx +0 -1
- package/src/features/slices/sliceBuilder/SliceBuilderProvider.tsx +12 -10
- package/src/features/sync/AutoSyncProvider.tsx +252 -0
- package/src/features/sync/components/AutoSyncStatusIndicator.module.css +17 -0
- package/src/features/sync/components/AutoSyncStatusIndicator.module.css.d.ts +5 -0
- package/src/features/sync/components/AutoSyncStatusIndicator.tsx +58 -0
- package/src/features/sync/fetchUnSyncChanges.ts +40 -0
- package/src/features/sync/getUnSyncChanges.ts +144 -0
- package/src/features/sync/useUnSyncChanges.ts +32 -0
- package/src/hooks/useActionQueue.tsx +177 -0
- package/src/hooks/useAuthStatus.ts +12 -0
- package/src/hooks/useUser.ts +14 -0
- package/src/icons/SettingsIcon.tsx +19 -0
- package/src/icons/SyncFailed.tsx +30 -0
- package/src/icons/Synced.tsx +19 -0
- package/src/icons/Syncing.tsx +23 -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/__testutils__/index.tsx +8 -5
- package/test/src/modules/__fixtures__/serverState.ts +1 -2
- package/test/src/modules/availableCustomTypes/index.test.ts +2 -243
- package/test/src/modules/slices.test.ts +1 -267
- package/components/Navigation/ChangesListItem.tsx +0 -92
- package/components/Navigation/ChangesRightElement.tsx +0 -33
- package/out/_next/static/chunks/18539003-5cc559566b738915.js +0 -97
- package/out/_next/static/chunks/25-37d6fa7f064be04b.js +0 -1
- package/out/_next/static/chunks/318-ce7e74f18f2d5b22.js +0 -1
- package/out/_next/static/chunks/376-7e784d6069e01654.js +0 -8
- 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/_app-cd9d4c76a4abc11a.js +0 -432
- package/out/_next/static/chunks/pages/changes-2a976f9efeb719aa.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/out/_next/static/css/200244e3e0463c39.css +0 -1
- package/out/_next/static/m6psnC5u1xT7Y6osWHKjp/_buildManifest.js +0 -1
- package/src/features/autoSave/useAutoSave.tsx +0 -177
- package/src/features/customTypes/__tests__/createCustomType.test.ts +0 -159
- package/src/features/customTypes/customTypesTable/createCustomType.ts +0 -107
- package/src/features/legacyState/actions/getLegacySliceMachineState.ts +0 -53
- package/src/features/legacyState/useLegacySliceMachineState.ts +0 -7
- package/src/hooks/useModelStatus.ts +0 -78
- package/src/hooks/useUnSyncChanges.ts +0 -88
- package/test/components/CreateCustomTypeModal.test.tsx +0 -73
- package/test/components/LoginModal.test.tsx +0 -67
- package/test/src/hooks/useModelStatus.test.ts +0 -115
- /package/out/_next/static/{m6psnC5u1xT7Y6osWHKjp → dS_xZnzzna6Y6uwcTgf90}/_ssgManifest.js +0 -0
- /package/src/features/{changes → sync}/actions/pushChanges.ts +0 -0
- /package/src/features/{changes → sync}/actions/trackPushChangesSuccess.ts +0 -0
|
@@ -1,21 +1,8 @@
|
|
|
1
1
|
// @vitest-environment jsdom
|
|
2
2
|
|
|
3
3
|
import { describe, expect, it } from "vitest";
|
|
4
|
-
import {
|
|
5
|
-
slicesReducer,
|
|
6
|
-
deleteSliceCreator,
|
|
7
|
-
// getFrontendSlices,
|
|
8
|
-
deleteSliceSaga,
|
|
9
|
-
} from "@src/modules/slices";
|
|
10
|
-
import { testSaga } from "redux-saga-test-plan";
|
|
11
|
-
|
|
12
|
-
import { deleteSlice } from "@src/apiClient";
|
|
13
|
-
import { modalCloseCreator } from "@src/modules/modal";
|
|
4
|
+
import { slicesReducer } from "@src/modules/slices";
|
|
14
5
|
import { SlicesStoreType } from "@src/modules/slices/types";
|
|
15
|
-
import { openToasterCreator, ToasterType } from "@src/modules/toaster";
|
|
16
|
-
import { LibraryUI } from "@lib/models/common/LibraryUI";
|
|
17
|
-
// import { generateComponentUI, generateLibraryUI, generateSliceSM } from "./__fixtures__/sliceUtilsFactory";
|
|
18
|
-
// import { SliceMachineStoreType } from "@src/redux/type";
|
|
19
6
|
|
|
20
7
|
const dummySlicesState: SlicesStoreType = {
|
|
21
8
|
libraries: [],
|
|
@@ -35,258 +22,5 @@ describe("[Slices module]", () => {
|
|
|
35
22
|
dummySlicesState,
|
|
36
23
|
);
|
|
37
24
|
});
|
|
38
|
-
|
|
39
|
-
it("should update the slice state given SLICES/DELETE.SUCCESS action", () => {
|
|
40
|
-
const sliceIdToDelete = "id";
|
|
41
|
-
const sliceNameToDelete = "slice-name";
|
|
42
|
-
const libName = "libName";
|
|
43
|
-
|
|
44
|
-
const originalState = { ...dummySlicesState };
|
|
45
|
-
|
|
46
|
-
originalState["libraries"] = [
|
|
47
|
-
{
|
|
48
|
-
name: libName,
|
|
49
|
-
isLocal: true,
|
|
50
|
-
components: [
|
|
51
|
-
{ model: { id: sliceIdToDelete } },
|
|
52
|
-
{ model: { id: "second-slice" } },
|
|
53
|
-
],
|
|
54
|
-
},
|
|
55
|
-
] as unknown as LibraryUI[];
|
|
56
|
-
|
|
57
|
-
const action = deleteSliceCreator.success({
|
|
58
|
-
sliceId: sliceIdToDelete,
|
|
59
|
-
libName,
|
|
60
|
-
sliceName: sliceNameToDelete,
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
const result = slicesReducer(originalState, action);
|
|
64
|
-
|
|
65
|
-
const expectState = { ...originalState };
|
|
66
|
-
expectState["libraries"] = [
|
|
67
|
-
{
|
|
68
|
-
name: libName,
|
|
69
|
-
isLocal: true,
|
|
70
|
-
components: [{ model: { id: "second-slice" } }],
|
|
71
|
-
},
|
|
72
|
-
] as unknown as LibraryUI[];
|
|
73
|
-
|
|
74
|
-
expect(result).toEqual(expectState);
|
|
75
|
-
});
|
|
76
25
|
});
|
|
77
|
-
|
|
78
|
-
// describe("[renameSliceSaga]", () => {
|
|
79
|
-
// it("should call the api and dispatch the good actions", () => {
|
|
80
|
-
// const actionPayload = {
|
|
81
|
-
// sliceId: "MySlice",
|
|
82
|
-
// libName: "MyLib/Components",
|
|
83
|
-
// newSliceName: "MyNewSlice",
|
|
84
|
-
// };
|
|
85
|
-
// const saga = testSaga(
|
|
86
|
-
// renameSliceSaga,
|
|
87
|
-
// renameSliceCreator.request(actionPayload)
|
|
88
|
-
// );
|
|
89
|
-
|
|
90
|
-
// saga
|
|
91
|
-
// .next()
|
|
92
|
-
// .call(
|
|
93
|
-
// renameSlice,
|
|
94
|
-
// actionPayload.sliceId,
|
|
95
|
-
// actionPayload.newSliceName,
|
|
96
|
-
// actionPayload.libName
|
|
97
|
-
// );
|
|
98
|
-
// saga.next().put(
|
|
99
|
-
// renameSliceCreator.success({
|
|
100
|
-
// libName: actionPayload.libName,
|
|
101
|
-
// sliceId: actionPayload.sliceId,
|
|
102
|
-
// newSliceName: actionPayload.newSliceName,
|
|
103
|
-
// })
|
|
104
|
-
// );
|
|
105
|
-
// saga.next().put(modalCloseCreator());
|
|
106
|
-
// saga.next().put(
|
|
107
|
-
// openToasterCreator({
|
|
108
|
-
// content: "Slice name updated",
|
|
109
|
-
// type: ToasterType.SUCCESS,
|
|
110
|
-
// })
|
|
111
|
-
// );
|
|
112
|
-
// saga.next().isDone();
|
|
113
|
-
// });
|
|
114
|
-
// });
|
|
115
|
-
|
|
116
|
-
describe("[deleteSliceSaga]", () => {
|
|
117
|
-
it("should call the api and dispatch the good actions on success", () => {
|
|
118
|
-
const actionPayload = {
|
|
119
|
-
sliceId: "id",
|
|
120
|
-
sliceName: "name",
|
|
121
|
-
libName: "lib",
|
|
122
|
-
};
|
|
123
|
-
const saga = testSaga(
|
|
124
|
-
deleteSliceSaga,
|
|
125
|
-
deleteSliceCreator.request(actionPayload),
|
|
126
|
-
);
|
|
127
|
-
|
|
128
|
-
saga
|
|
129
|
-
.next()
|
|
130
|
-
.call(deleteSlice, actionPayload.sliceId, actionPayload.libName);
|
|
131
|
-
saga.next({ errors: [] }).put(deleteSliceCreator.success(actionPayload));
|
|
132
|
-
saga.next().put(
|
|
133
|
-
openToasterCreator({
|
|
134
|
-
content: `Successfully deleted Slice “${actionPayload.sliceName}”`,
|
|
135
|
-
type: ToasterType.SUCCESS,
|
|
136
|
-
}),
|
|
137
|
-
);
|
|
138
|
-
|
|
139
|
-
saga.next().put(modalCloseCreator());
|
|
140
|
-
saga.next().isDone();
|
|
141
|
-
});
|
|
142
|
-
it("should call the api and dispatch the good actions on unknown failure", () => {
|
|
143
|
-
const actionPayload = {
|
|
144
|
-
sliceId: "id",
|
|
145
|
-
sliceName: "name",
|
|
146
|
-
libName: "lib",
|
|
147
|
-
};
|
|
148
|
-
const saga = testSaga(
|
|
149
|
-
deleteSliceSaga,
|
|
150
|
-
deleteSliceCreator.request(actionPayload),
|
|
151
|
-
);
|
|
152
|
-
|
|
153
|
-
saga
|
|
154
|
-
.next()
|
|
155
|
-
.call(deleteSlice, actionPayload.sliceId, actionPayload.libName);
|
|
156
|
-
saga.throw(new Error()).put(
|
|
157
|
-
openToasterCreator({
|
|
158
|
-
content: "An unexpected error happened while deleting your slice.",
|
|
159
|
-
type: ToasterType.ERROR,
|
|
160
|
-
}),
|
|
161
|
-
);
|
|
162
|
-
|
|
163
|
-
saga.next().put(modalCloseCreator());
|
|
164
|
-
saga.next().isDone();
|
|
165
|
-
});
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
// describe("[Selectors]", () => {
|
|
169
|
-
// describe.only("getLocallyDeletedSlices", () => {
|
|
170
|
-
// it("works as expected", () => {
|
|
171
|
-
// const l1 = generateLibraryUI({
|
|
172
|
-
// components: [
|
|
173
|
-
// generateComponentUI({
|
|
174
|
-
// model: generateSliceSM({ id: "1" }),
|
|
175
|
-
// }),
|
|
176
|
-
// generateComponentUI({
|
|
177
|
-
// model: generateSliceSM({ id: "2" }),
|
|
178
|
-
// }),
|
|
179
|
-
// generateComponentUI({
|
|
180
|
-
// model: generateSliceSM({ id: "3" }),
|
|
181
|
-
// }),
|
|
182
|
-
// ],
|
|
183
|
-
// });
|
|
184
|
-
// const l2 = generateLibraryUI({
|
|
185
|
-
// components: [
|
|
186
|
-
// generateComponentUI({
|
|
187
|
-
// model: generateSliceSM({ id: "4" }),
|
|
188
|
-
// }),
|
|
189
|
-
// generateComponentUI({
|
|
190
|
-
// model: generateSliceSM({ id: "5" }),
|
|
191
|
-
// }),
|
|
192
|
-
// ],
|
|
193
|
-
// });
|
|
194
|
-
|
|
195
|
-
// const remoteSlices = [
|
|
196
|
-
// generateSliceSM({ id: "1" }),
|
|
197
|
-
// generateSliceSM({ id: "3" }),
|
|
198
|
-
// generateSliceSM({ id: "4" }),
|
|
199
|
-
// generateSliceSM({ id: "6" }),
|
|
200
|
-
// ];
|
|
201
|
-
|
|
202
|
-
// const frontendSlices = getFrontendSlices({
|
|
203
|
-
// slices: { libraries: [l1, l2], remoteSlices },
|
|
204
|
-
// } as unknown as SliceMachineStoreType);
|
|
205
|
-
|
|
206
|
-
// // it combines slices from all the local libraries
|
|
207
|
-
// // it combines local and remote only libraries
|
|
208
|
-
// // it maps the correct remote slice if found
|
|
209
|
-
// expect(frontendSlices.length).toEqual(6);
|
|
210
|
-
// expect(frontendSlices.map((s) => s.local?.id)).toEqual([
|
|
211
|
-
// "1",
|
|
212
|
-
// "2",
|
|
213
|
-
// "3",
|
|
214
|
-
// "4",
|
|
215
|
-
// "5",
|
|
216
|
-
// undefined,
|
|
217
|
-
// ]);
|
|
218
|
-
// expect(frontendSlices.map((s) => s.remote?.id)).toEqual([
|
|
219
|
-
// "1",
|
|
220
|
-
// undefined,
|
|
221
|
-
// "3",
|
|
222
|
-
// "4",
|
|
223
|
-
// undefined,
|
|
224
|
-
// "6",
|
|
225
|
-
// ]);
|
|
226
|
-
// });
|
|
227
|
-
// });
|
|
228
|
-
// });
|
|
229
26
|
});
|
|
230
|
-
|
|
231
|
-
// describe("[utils]", () => {
|
|
232
|
-
// const PREV_NAME = "SliceName";
|
|
233
|
-
// const NEW_NAME = "SliceRenamed";
|
|
234
|
-
// it("test renameScreenshots", () => {
|
|
235
|
-
// const initialPaths: Record<string, ScreenshotUI> = {
|
|
236
|
-
// "default-variation": createScreenshotUI(PREV_NAME, "default-variation"),
|
|
237
|
-
// "other-variation": createScreenshotUI(PREV_NAME, "other-variation"),
|
|
238
|
-
// };
|
|
239
|
-
// const expectedRenamedPaths: Record<string, ScreenshotUI> = {
|
|
240
|
-
// "default-variation": createScreenshotUI(NEW_NAME, "default-variation"),
|
|
241
|
-
// "other-variation": createScreenshotUI(NEW_NAME, "other-variation"),
|
|
242
|
-
// };
|
|
243
|
-
// expect(renameScreenshots(initialPaths, PREV_NAME, NEW_NAME)).toEqual(
|
|
244
|
-
// expectedRenamedPaths
|
|
245
|
-
// );
|
|
246
|
-
// });
|
|
247
|
-
|
|
248
|
-
// it("test renameScreenshotUrls", () => {
|
|
249
|
-
// const initialUrls: Screenshots = {
|
|
250
|
-
// "default-variation": {
|
|
251
|
-
// hash: "xxx",
|
|
252
|
-
// path: `../../e2e-projects/next/.slicemachine/assets/slices/ecommerce/${PREV_NAME}/default-variation/preview.png`,
|
|
253
|
-
// url: `http://localhost:9999/api/__preview?q=..%2F..%2Fe2e-projects%2Fnext%2F.slicemachine%2Fassets%2Fslices%2Fecommerce%2F${PREV_NAME}%2Fdefault-slice%2Fpreview.png&uniq=0.39230892472268586`,
|
|
254
|
-
// },
|
|
255
|
-
// "other-variation": {
|
|
256
|
-
// hash: "xxx",
|
|
257
|
-
// path: `../../e2e-projects/next/.slicemachine/assets/slices/ecommerce/${PREV_NAME}/other-variation/preview.png`,
|
|
258
|
-
// url: `http://localhost:9999/api/__preview?q=..%2F..%2Fe2e-projects%2Fnext%2F.slicemachine%2Fassets%2Fslices%2Fecommerce%2F${PREV_NAME}%2Fdefault-slice%2Fpreview.png&uniq=0.39230892472268586`,
|
|
259
|
-
// },
|
|
260
|
-
// };
|
|
261
|
-
// const expectedRenamedUrls: Screenshots = {
|
|
262
|
-
// "default-variation": {
|
|
263
|
-
// hash: "xxx",
|
|
264
|
-
// path: `../../e2e-projects/next/.slicemachine/assets/slices/ecommerce/${NEW_NAME}/default-variation/preview.png`,
|
|
265
|
-
// url: `http://localhost:9999/api/__preview?q=..%2F..%2Fe2e-projects%2Fnext%2F.slicemachine%2Fassets%2Fslices%2Fecommerce%2F${NEW_NAME}%2Fdefault-slice%2Fpreview.png&uniq=0.39230892472268586`,
|
|
266
|
-
// },
|
|
267
|
-
// "other-variation": {
|
|
268
|
-
// hash: "xxx",
|
|
269
|
-
// path: `../../e2e-projects/next/.slicemachine/assets/slices/ecommerce/${NEW_NAME}/other-variation/preview.png`,
|
|
270
|
-
// url: `http://localhost:9999/api/__preview?q=..%2F..%2Fe2e-projects%2Fnext%2F.slicemachine%2Fassets%2Fslices%2Fecommerce%2F${NEW_NAME}%2Fdefault-slice%2Fpreview.png&uniq=0.39230892472268586`,
|
|
271
|
-
// },
|
|
272
|
-
// };
|
|
273
|
-
// expect(renameScreenshots(initialUrls, PREV_NAME, NEW_NAME)).toEqual(
|
|
274
|
-
// expectedRenamedUrls
|
|
275
|
-
// );
|
|
276
|
-
// });
|
|
277
|
-
// it("test renameModel", () => {
|
|
278
|
-
// const initialModel: SliceSM = {
|
|
279
|
-
// id: "slice_id",
|
|
280
|
-
// name: PREV_NAME,
|
|
281
|
-
// type: "SharedSlice",
|
|
282
|
-
// variations: [],
|
|
283
|
-
// };
|
|
284
|
-
// const expectedModel: SliceSM = {
|
|
285
|
-
// id: "slice_id",
|
|
286
|
-
// name: NEW_NAME,
|
|
287
|
-
// type: "SharedSlice",
|
|
288
|
-
// variations: [],
|
|
289
|
-
// };
|
|
290
|
-
// expect(renameModel(initialModel, NEW_NAME)).toEqual(expectedModel);
|
|
291
|
-
// });
|
|
292
|
-
// });
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { type FC, useState } from "react";
|
|
2
|
-
import Link from "next/link";
|
|
3
|
-
import { useRouter } from "next/router";
|
|
4
|
-
import { SliceMachineStoreType } from "@src/redux/type";
|
|
5
|
-
import { useSelector } from "react-redux";
|
|
6
|
-
|
|
7
|
-
import { SideNavLink, SideNavListItem } from "@src/components/SideNav";
|
|
8
|
-
import { RadarIcon } from "@src/icons/RadarIcon";
|
|
9
|
-
import { isLoading } from "@src/modules/loading";
|
|
10
|
-
import { LoadingKeysEnum } from "@src/modules/loading/types";
|
|
11
|
-
import {
|
|
12
|
-
HoverCard,
|
|
13
|
-
HoverCardCloseButton,
|
|
14
|
-
HoverCardDescription,
|
|
15
|
-
HoverCardMedia,
|
|
16
|
-
HoverCardTitle,
|
|
17
|
-
} from "@src/components/HoverCard";
|
|
18
|
-
import {
|
|
19
|
-
userHasSeenChangesToolTip,
|
|
20
|
-
userHasSeenSimulatorToolTip,
|
|
21
|
-
} from "@src/modules/userContext";
|
|
22
|
-
import useSliceMachineActions from "@src/modules/useSliceMachineActions";
|
|
23
|
-
import { ChangesRightElement } from "./ChangesRightElement";
|
|
24
|
-
|
|
25
|
-
export const ChangesListItem: FC = () => {
|
|
26
|
-
const { setSeenChangesToolTip } = useSliceMachineActions();
|
|
27
|
-
const open = useOpenChangesHoverCard();
|
|
28
|
-
const router = useRouter();
|
|
29
|
-
|
|
30
|
-
const onClose = () => {
|
|
31
|
-
setSeenChangesToolTip();
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
return (
|
|
35
|
-
<HoverCard
|
|
36
|
-
open={open}
|
|
37
|
-
openDelay={3000}
|
|
38
|
-
onClose={onClose}
|
|
39
|
-
side="right"
|
|
40
|
-
sideOffset={24}
|
|
41
|
-
collisionPadding={280}
|
|
42
|
-
trigger={
|
|
43
|
-
<SideNavListItem>
|
|
44
|
-
<SideNavLink
|
|
45
|
-
title="Changes"
|
|
46
|
-
href="/changes"
|
|
47
|
-
active={router.asPath.startsWith("/changes")}
|
|
48
|
-
component={Link}
|
|
49
|
-
Icon={RadarIcon}
|
|
50
|
-
RightElement={<ChangesRightElement />}
|
|
51
|
-
/>
|
|
52
|
-
</SideNavListItem>
|
|
53
|
-
}
|
|
54
|
-
>
|
|
55
|
-
<HoverCardTitle>Push your changes</HoverCardTitle>
|
|
56
|
-
<HoverCardMedia component="image" src="/push.png" />
|
|
57
|
-
<HoverCardDescription>
|
|
58
|
-
When you click Save, your changes are saved locally. Then, you can push
|
|
59
|
-
your models to Prismic from the Changes page.
|
|
60
|
-
</HoverCardDescription>
|
|
61
|
-
<HoverCardCloseButton>Got it</HoverCardCloseButton>
|
|
62
|
-
</HoverCard>
|
|
63
|
-
);
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const useOpenChangesHoverCard = () => {
|
|
67
|
-
const {
|
|
68
|
-
hasSeenChangesToolTip,
|
|
69
|
-
hasSeenSimulatorToolTip,
|
|
70
|
-
isSavingCustomType,
|
|
71
|
-
isSavingSlice,
|
|
72
|
-
} = useSelector((store: SliceMachineStoreType) => ({
|
|
73
|
-
hasSeenChangesToolTip: userHasSeenChangesToolTip(store),
|
|
74
|
-
hasSeenSimulatorToolTip: userHasSeenSimulatorToolTip(store),
|
|
75
|
-
isSavingCustomType: isLoading(store, LoadingKeysEnum.SAVE_CUSTOM_TYPE),
|
|
76
|
-
isSavingSlice: isLoading(store, LoadingKeysEnum.SAVE_SLICE),
|
|
77
|
-
}));
|
|
78
|
-
|
|
79
|
-
const isSaving = isSavingCustomType || isSavingSlice;
|
|
80
|
-
const [prevIsSaving, setPrevIsSaving] = useState(isSaving);
|
|
81
|
-
|
|
82
|
-
if (!prevIsSaving && isSaving) {
|
|
83
|
-
setPrevIsSaving(isSaving);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return (
|
|
87
|
-
!hasSeenChangesToolTip &&
|
|
88
|
-
hasSeenSimulatorToolTip &&
|
|
89
|
-
!isSaving &&
|
|
90
|
-
prevIsSaving
|
|
91
|
-
);
|
|
92
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { FC } from "react";
|
|
2
|
-
|
|
3
|
-
import { useUnSyncChanges } from "@src/hooks/useUnSyncChanges";
|
|
4
|
-
import { RightElement } from "@src/components/SideNav/SideNav";
|
|
5
|
-
import { AuthStatus } from "@src/modules/userContext/types";
|
|
6
|
-
import { useNetwork } from "@src/hooks/useNetwork";
|
|
7
|
-
|
|
8
|
-
export const ChangesRightElement: FC = () => {
|
|
9
|
-
const isOnline = useNetwork();
|
|
10
|
-
const { unSyncedSlices, unSyncedCustomTypes, authStatus } =
|
|
11
|
-
useUnSyncChanges();
|
|
12
|
-
const numberOfChanges = unSyncedSlices.length + unSyncedCustomTypes.length;
|
|
13
|
-
|
|
14
|
-
if (
|
|
15
|
-
!isOnline ||
|
|
16
|
-
authStatus === AuthStatus.UNAUTHORIZED ||
|
|
17
|
-
authStatus === AuthStatus.FORBIDDEN
|
|
18
|
-
) {
|
|
19
|
-
return <RightElement>Logged out</RightElement>;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (numberOfChanges === 0) {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const formattedNumberOfChanges = numberOfChanges > 9 ? "+9" : numberOfChanges;
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<RightElement type="pill" data-cy="changes-number">
|
|
30
|
-
{formattedNumberOfChanges}
|
|
31
|
-
</RightElement>
|
|
32
|
-
);
|
|
33
|
-
};
|