slice-machine-ui 1.23.2-beta.9 → 1.24.0
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 +3 -0
- package/components/DeleteVariationModal/index.tsx +1 -0
- package/components/Forms/CreateCustomTypeModal/CreateCustomTypeModal.tsx +4 -0
- package/components/Forms/CreateSliceModal/CreateSliceModal.tsx +3 -1
- package/components/Forms/RenameCustomTypeModal/RenameCustomTypeModal.tsx +6 -1
- package/components/Forms/RenameSliceModal/RenameSliceModal.tsx +3 -0
- 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/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/{labs-ee206005948f8e87.js → labs-2adfb5127f9c4081.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-52c3e1f9d14160b8.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/eNujlD43QIdmra7ggcNtK/_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 +10 -8
- package/pages/_app.tsx +34 -32
- package/pages/changes.tsx +27 -41
- package/pages/settings.tsx +1 -0
- package/postcss.config.js +10 -0
- 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/features/autoSave/AutoSaveStatusIndicator.tsx +4 -4
- package/src/features/customTypes/customTypesBuilder/CustomTypeProvider.tsx +11 -10
- package/src/features/customTypes/customTypesBuilder/CustomTypesBuilderPage.tsx +3 -3
- 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/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/test/__testutils__/index.tsx +8 -5
- package/test/src/modules/__fixtures__/serverState.ts +1 -2
- package/components/Navigation/ChangesListItem.tsx +0 -74
- package/components/Navigation/ChangesRightElement.tsx +0 -33
- package/out/_next/static/chunks/18539003-5cc559566b738915.js +0 -97
- package/out/_next/static/chunks/25-01f422cea8066349.js +0 -1
- package/out/_next/static/chunks/318-387e3f23d717c53d.js +0 -1
- package/out/_next/static/chunks/376-7e784d6069e01654.js +0 -8
- package/out/_next/static/chunks/727-358d7fae68a880b3.js +0 -1
- package/out/_next/static/chunks/799-9928a9413d9f0730.js +0 -1
- package/out/_next/static/chunks/904-1ff7519adece2b55.js +0 -1
- package/out/_next/static/chunks/pages/_app-9448839a9d20924d.js +0 -432
- package/out/_next/static/chunks/pages/changes-92c84f6cac0285fd.js +0 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-fecb771f91e70853.js +0 -1
- package/out/_next/static/chunks/pages/slices-b0b58192a87df822.js +0 -1
- package/out/_next/static/css/200244e3e0463c39.css +0 -1
- package/out/_next/static/sysU54bHKiGDh8pmVpi41/_buildManifest.js +0 -1
- package/src/features/autoSave/useAutoSave.tsx +0 -177
- 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/LoginModal.test.tsx +0 -67
- package/test/src/hooks/useModelStatus.test.ts +0 -115
- /package/out/_next/static/{sysU54bHKiGDh8pmVpi41 → eNujlD43QIdmra7ggcNtK}/_ssgManifest.js +0 -0
- /package/src/features/{changes → sync}/actions/pushChanges.ts +0 -0
- /package/src/features/{changes → sync}/actions/trackPushChangesSuccess.ts +0 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useCallback,
|
|
3
|
+
useState,
|
|
4
|
+
useEffect,
|
|
5
|
+
SetStateAction,
|
|
6
|
+
Dispatch,
|
|
7
|
+
useMemo,
|
|
8
|
+
} from "react";
|
|
9
|
+
import { uniqueId } from "lodash";
|
|
10
|
+
import { toast } from "react-toastify";
|
|
11
|
+
import { Box, Button, Text } from "@prismicio/editor-ui";
|
|
12
|
+
|
|
13
|
+
export type ActionQueueStatus = "pending" | "done" | "failed";
|
|
14
|
+
|
|
15
|
+
type UseActionQueueArgs = {
|
|
16
|
+
actionQueueStatusDelay?: number;
|
|
17
|
+
errorMessage: string;
|
|
18
|
+
retryDelay?: number;
|
|
19
|
+
retryMessage?: string;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
type UseActionQueueReturnType = {
|
|
23
|
+
actionQueueStatus: ActionQueueStatus;
|
|
24
|
+
setNextAction: (nextAction: NextAction) => void;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
type ActionQueueStack = {
|
|
28
|
+
pendingAction: NextAction | undefined;
|
|
29
|
+
nextAction: NextAction | undefined;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
type NextAction = () => Promise<unknown>;
|
|
33
|
+
|
|
34
|
+
export const useActionQueue = (
|
|
35
|
+
args: UseActionQueueArgs,
|
|
36
|
+
): UseActionQueueReturnType => {
|
|
37
|
+
const {
|
|
38
|
+
actionQueueStatusDelay = 300,
|
|
39
|
+
errorMessage,
|
|
40
|
+
retryDelay = 1000,
|
|
41
|
+
retryMessage = "Retry",
|
|
42
|
+
} = args;
|
|
43
|
+
|
|
44
|
+
const [actionQueueStack, setActionQueueStack] = useState<ActionQueueStack>({
|
|
45
|
+
pendingAction: undefined,
|
|
46
|
+
nextAction: undefined,
|
|
47
|
+
});
|
|
48
|
+
const [actionQueueStatusActual, setActionQueueStatusActual] =
|
|
49
|
+
useState<ActionQueueStatus>("done");
|
|
50
|
+
const [actionQueueStatusDelayed, setActionQueueStatusDelayed] =
|
|
51
|
+
useState<ActionQueueStatus>(actionQueueStatusActual);
|
|
52
|
+
|
|
53
|
+
const setNextAction = useCallback((nextAction: NextAction) => {
|
|
54
|
+
setActionQueueStack((prevState) => ({
|
|
55
|
+
...prevState,
|
|
56
|
+
nextAction,
|
|
57
|
+
}));
|
|
58
|
+
}, []);
|
|
59
|
+
|
|
60
|
+
const executeAction = useCallback(
|
|
61
|
+
async (nextAction?: NextAction) => {
|
|
62
|
+
if (nextAction) {
|
|
63
|
+
setActionQueueStatusActual("pending");
|
|
64
|
+
|
|
65
|
+
try {
|
|
66
|
+
await nextAction();
|
|
67
|
+
|
|
68
|
+
setActionQueueStatusActual("done");
|
|
69
|
+
} catch (error) {
|
|
70
|
+
setActionQueueStatusActual("failed");
|
|
71
|
+
console.error(errorMessage, error);
|
|
72
|
+
|
|
73
|
+
toastError({
|
|
74
|
+
errorMessage,
|
|
75
|
+
retryDelay,
|
|
76
|
+
retryMessage,
|
|
77
|
+
setActionQueueStatusActual,
|
|
78
|
+
setActionQueueStack,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
[errorMessage, retryDelay, retryMessage],
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
if (actionQueueStatusActual === "done" && actionQueueStack.nextAction) {
|
|
88
|
+
void executeAction(actionQueueStack.nextAction);
|
|
89
|
+
|
|
90
|
+
setActionQueueStack({
|
|
91
|
+
pendingAction: actionQueueStack.nextAction,
|
|
92
|
+
nextAction: undefined,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}, [actionQueueStatusActual, actionQueueStack, executeAction]);
|
|
96
|
+
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
if (actionQueueStatusActual === "pending") {
|
|
99
|
+
setActionQueueStatusDelayed("pending");
|
|
100
|
+
} else {
|
|
101
|
+
const delayedTimeout = setTimeout(() => {
|
|
102
|
+
setActionQueueStatusDelayed(actionQueueStatusActual);
|
|
103
|
+
}, actionQueueStatusDelay);
|
|
104
|
+
|
|
105
|
+
return () => {
|
|
106
|
+
clearTimeout(delayedTimeout);
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return;
|
|
111
|
+
}, [actionQueueStatusActual, actionQueueStatusDelay]);
|
|
112
|
+
|
|
113
|
+
return useMemo(
|
|
114
|
+
() => ({
|
|
115
|
+
actionQueueStatus: actionQueueStatusDelayed,
|
|
116
|
+
setNextAction,
|
|
117
|
+
}),
|
|
118
|
+
[actionQueueStatusDelayed, setNextAction],
|
|
119
|
+
);
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
type ToastErrorArgs = {
|
|
123
|
+
errorMessage: string;
|
|
124
|
+
retryDelay: number;
|
|
125
|
+
retryMessage: string;
|
|
126
|
+
setActionQueueStatusActual: Dispatch<SetStateAction<ActionQueueStatus>>;
|
|
127
|
+
setActionQueueStack: Dispatch<SetStateAction<ActionQueueStack>>;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
function toastError(args: ToastErrorArgs) {
|
|
131
|
+
const {
|
|
132
|
+
errorMessage,
|
|
133
|
+
retryDelay,
|
|
134
|
+
retryMessage,
|
|
135
|
+
setActionQueueStatusActual,
|
|
136
|
+
setActionQueueStack,
|
|
137
|
+
} = args;
|
|
138
|
+
const toastId = uniqueId();
|
|
139
|
+
|
|
140
|
+
toast.error(
|
|
141
|
+
() => (
|
|
142
|
+
<Box gap={8} alignItems="center">
|
|
143
|
+
<Text color="grey1" variant="small">
|
|
144
|
+
{errorMessage}
|
|
145
|
+
</Text>
|
|
146
|
+
<Button
|
|
147
|
+
size="small"
|
|
148
|
+
color="grey"
|
|
149
|
+
onClick={() => {
|
|
150
|
+
toast.dismiss(toastId);
|
|
151
|
+
|
|
152
|
+
// Ensure saving is directly propagated before waiting for the retry
|
|
153
|
+
setActionQueueStatusActual("pending");
|
|
154
|
+
|
|
155
|
+
setTimeout(() => {
|
|
156
|
+
// By setting the status to done, the effect will be triggered
|
|
157
|
+
// with the latest action to process.
|
|
158
|
+
setActionQueueStatusActual("done");
|
|
159
|
+
setActionQueueStack((prevState) => ({
|
|
160
|
+
nextAction: prevState.nextAction ?? prevState.pendingAction,
|
|
161
|
+
pendingAction: undefined,
|
|
162
|
+
}));
|
|
163
|
+
}, retryDelay);
|
|
164
|
+
}}
|
|
165
|
+
>
|
|
166
|
+
{retryMessage}
|
|
167
|
+
</Button>
|
|
168
|
+
</Box>
|
|
169
|
+
),
|
|
170
|
+
{
|
|
171
|
+
autoClose: false,
|
|
172
|
+
closeOnClick: false,
|
|
173
|
+
draggable: false,
|
|
174
|
+
toastId,
|
|
175
|
+
},
|
|
176
|
+
);
|
|
177
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useSelector } from "react-redux";
|
|
2
|
+
|
|
3
|
+
import { getAuthStatus } from "@src/modules/environment";
|
|
4
|
+
import { SliceMachineStoreType } from "@src/redux/type";
|
|
5
|
+
|
|
6
|
+
export function useAuthStatus() {
|
|
7
|
+
const { authStatus } = useSelector((store: SliceMachineStoreType) => ({
|
|
8
|
+
authStatus: getAuthStatus(store),
|
|
9
|
+
}));
|
|
10
|
+
|
|
11
|
+
return authStatus;
|
|
12
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useRequest } from "@prismicio/editor-support/Suspense";
|
|
2
|
+
|
|
3
|
+
import { managerClient } from "@src/managerClient";
|
|
4
|
+
|
|
5
|
+
type User = { isLoggedIn: boolean };
|
|
6
|
+
|
|
7
|
+
export function useUser(): User {
|
|
8
|
+
return useRequest(getUser, []);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async function getUser(): Promise<User> {
|
|
12
|
+
const isLoggedIn = await managerClient.user.checkIsLoggedIn();
|
|
13
|
+
return { isLoggedIn };
|
|
14
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { FC, SVGProps } from "react";
|
|
2
|
+
|
|
3
|
+
export const SettingsIcon: FC<SVGProps<SVGSVGElement>> = (props) => (
|
|
4
|
+
<svg
|
|
5
|
+
width="32"
|
|
6
|
+
height="32"
|
|
7
|
+
viewBox="0 0 32 32"
|
|
8
|
+
fill="none"
|
|
9
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
10
|
+
{...props}
|
|
11
|
+
>
|
|
12
|
+
<path
|
|
13
|
+
fillRule="evenodd"
|
|
14
|
+
clipRule="evenodd"
|
|
15
|
+
d="M16 12C16 13.1046 15.1046 14 14 14C12.8954 14 12 13.1046 12 12C12 10.8954 12.8954 10 14 10C15.1046 10 16 10.8954 16 12ZM14 9C15.4865 9 16.7205 10.0811 16.9585 11.5H23.5C23.7761 11.5 24 11.7239 24 12C24 12.2761 23.7761 12.5 23.5 12.5H16.9585C16.7205 13.9189 15.4865 15 14 15C12.5135 15 11.2795 13.9189 11.0415 12.5H8.5C8.22386 12.5 8 12.2761 8 12C8 11.7239 8.22386 11.5 8.5 11.5H11.0415C11.2795 10.0811 12.5135 9 14 9ZM21 20C21 21.1046 20.1046 22 19 22C17.8954 22 17 21.1046 17 20C17 18.8954 17.8954 18 19 18C20.1046 18 21 18.8954 21 20ZM16.0415 20.5C16.2795 21.9189 17.5135 23 19 23C20.4865 23 21.7205 21.9189 21.9585 20.5H23.5C23.7761 20.5 24 20.2761 24 20C24 19.7239 23.7761 19.5 23.5 19.5H21.9585C21.7205 18.0811 20.4865 17 19 17C17.5135 17 16.2795 18.0811 16.0415 19.5H8.5C8.22386 19.5 8 19.7239 8 20C8 20.2761 8.22386 20.5 8.5 20.5H16.0415Z"
|
|
16
|
+
fill="currentColor"
|
|
17
|
+
/>
|
|
18
|
+
</svg>
|
|
19
|
+
);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { FC, SVGProps } from "react";
|
|
2
|
+
|
|
3
|
+
export const SyncFailed: FC<SVGProps<SVGSVGElement>> = (props) => (
|
|
4
|
+
<svg
|
|
5
|
+
width="20"
|
|
6
|
+
height="20"
|
|
7
|
+
viewBox="0 0 20 20"
|
|
8
|
+
fill="none"
|
|
9
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
10
|
+
{...props}
|
|
11
|
+
>
|
|
12
|
+
<g clipPath="url(#clip0_11119_1080440)">
|
|
13
|
+
<path
|
|
14
|
+
d="M4.43868 8.23554L5.06668 7.9405L5.01013 7.24895C5.00343 7.16706 5 7.08404 5 7C5 5.34315 6.34315 4 8 4C9.20763 4 10.2507 4.71358 10.7266 5.7464L11.1628 6.69299L12.0905 6.21805C12.3622 6.07893 12.6704 6 13 6C14.1046 6 15 6.89543 15 8C15 8.03818 14.9989 8.07605 14.9969 8.1136L14.9552 8.86338L15.6636 9.11245C16.4434 9.38659 17 10.1296 17 11C17 12.1046 16.1046 13 15 13V14C16.6569 14 18 12.6569 18 11C18 9.69203 17.163 8.57956 15.9953 8.16905C15.9984 8.1131 16 8.05673 16 8C16 6.34315 14.6569 5 13 5C12.5961 5 12.2108 5.07982 11.8591 5.22454C11.7827 5.25599 11.7079 5.29049 11.6348 5.32791C11.5887 5.22784 11.5386 5.13 11.4847 5.03459C10.7981 3.81994 9.4948 3 8 3C5.79086 3 4 4.79086 4 7C4 7.11127 4.00454 7.22148 4.01346 7.33046C2.82373 7.88942 2 9.09851 2 10.5C2 12.2632 3.30385 13.7219 5 13.9646V12.95C3.85888 12.7184 3 11.7095 3 10.5C3 9.50045 3.58659 8.63588 4.43868 8.23554Z"
|
|
15
|
+
fill="#6F6E77"
|
|
16
|
+
/>
|
|
17
|
+
<path
|
|
18
|
+
fillRule="evenodd"
|
|
19
|
+
clipRule="evenodd"
|
|
20
|
+
d="M7.32913 10.1715C7.13387 10.3667 7.13387 10.6833 7.32913 10.8786L9.45048 12.9999L7.32906 15.1213C7.1338 15.3166 7.1338 15.6332 7.32906 15.8285C7.52432 16.0237 7.8409 16.0237 8.03616 15.8285L10.1576 13.707L12.2789 15.8283C12.4741 16.0236 12.7907 16.0236 12.986 15.8283C13.1812 15.6331 13.1812 15.3165 12.986 15.1212L10.8647 12.9999L12.9859 10.8787C13.1812 10.6834 13.1812 10.3669 12.9859 10.1716C12.7906 9.97634 12.4741 9.97634 12.2788 10.1716L10.1576 12.2928L8.03624 10.1715C7.84098 9.97621 7.5244 9.97621 7.32913 10.1715Z"
|
|
21
|
+
fill="#6F6E77"
|
|
22
|
+
/>
|
|
23
|
+
</g>
|
|
24
|
+
<defs>
|
|
25
|
+
<clipPath id="clip0_11119_1080440">
|
|
26
|
+
<rect width="20" height="20" fill="white" />
|
|
27
|
+
</clipPath>
|
|
28
|
+
</defs>
|
|
29
|
+
</svg>
|
|
30
|
+
);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { FC, SVGProps } from "react";
|
|
2
|
+
|
|
3
|
+
export const Synced: FC<SVGProps<SVGSVGElement>> = (props) => (
|
|
4
|
+
<svg
|
|
5
|
+
width="20"
|
|
6
|
+
height="20"
|
|
7
|
+
viewBox="0 0 20 20"
|
|
8
|
+
fill="none"
|
|
9
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
10
|
+
{...props}
|
|
11
|
+
>
|
|
12
|
+
<path
|
|
13
|
+
d="M15.5 6L8 15.5L4.5 11"
|
|
14
|
+
stroke="#6F6E77"
|
|
15
|
+
strokeLinecap="round"
|
|
16
|
+
strokeLinejoin="round"
|
|
17
|
+
/>
|
|
18
|
+
</svg>
|
|
19
|
+
);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { FC, SVGProps } from "react";
|
|
2
|
+
|
|
3
|
+
export const Syncing: FC<SVGProps<SVGSVGElement>> = (props) => (
|
|
4
|
+
<svg
|
|
5
|
+
width="20"
|
|
6
|
+
height="20"
|
|
7
|
+
viewBox="0 0 20 20"
|
|
8
|
+
fill="none"
|
|
9
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
10
|
+
{...props}
|
|
11
|
+
>
|
|
12
|
+
<path
|
|
13
|
+
d="M4.43868 8.23554L5.06668 7.9405L5.01013 7.24895C5.00343 7.16706 5 7.08404 5 7C5 5.34315 6.34315 4 8 4C9.20763 4 10.2507 4.71358 10.7266 5.7464L11.1628 6.69299L12.0905 6.21805C12.3622 6.07893 12.6704 6 13 6C14.1046 6 15 6.89543 15 8C15 8.03818 14.9989 8.07605 14.9969 8.1136L14.9552 8.86338L15.6636 9.11245C16.4434 9.38659 17 10.1296 17 11C17 12.1046 16.1046 13 15 13V14C16.6569 14 18 12.6569 18 11C18 9.69203 17.163 8.57956 15.9953 8.16905C15.9984 8.1131 16 8.05673 16 8C16 6.34315 14.6569 5 13 5C12.5961 5 12.2108 5.07982 11.8591 5.22454C11.7827 5.25599 11.7079 5.29049 11.6348 5.32791C11.5887 5.22784 11.5386 5.13 11.4847 5.03459C10.7981 3.81994 9.4948 3 8 3C5.79086 3 4 4.79086 4 7C4 7.11127 4.00454 7.22148 4.01346 7.33046C2.82373 7.88942 2 9.09851 2 10.5C2 12.2632 3.30385 13.7219 5 13.9646V12.95C3.85888 12.7184 3 11.7095 3 10.5C3 9.50045 3.58659 8.63588 4.43868 8.23554Z"
|
|
14
|
+
fill="#6F6E77"
|
|
15
|
+
/>
|
|
16
|
+
<path
|
|
17
|
+
fillRule="evenodd"
|
|
18
|
+
clipRule="evenodd"
|
|
19
|
+
d="M10 9.79289L13.3536 13.1464L12.6464 13.8536L10.5 11.7071V17.5H9.5V11.7071L7.35355 13.8536L6.64645 13.1464L10 9.79289Z"
|
|
20
|
+
fill="#6F6E77"
|
|
21
|
+
/>
|
|
22
|
+
</svg>
|
|
23
|
+
);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { render as rtlRender, RenderOptions } from "@testing-library/react";
|
|
2
2
|
import userEvent from "@testing-library/user-event";
|
|
3
3
|
import { Store, AnyAction } from "redux";
|
|
4
|
+
import { ErrorBoundary } from "@prismicio/editor-ui";
|
|
4
5
|
|
|
5
6
|
import { Provider } from "react-redux";
|
|
6
7
|
import type { SliceMachineStoreType } from "../../src/redux/type";
|
|
@@ -41,11 +42,13 @@ function render(
|
|
|
41
42
|
children: any;
|
|
42
43
|
}) {
|
|
43
44
|
return (
|
|
44
|
-
<
|
|
45
|
-
<
|
|
46
|
-
<
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
<ErrorBoundary>
|
|
46
|
+
<ThemeUIThemeProvider theme={theme}>
|
|
47
|
+
<BaseStyles>
|
|
48
|
+
<Provider store={store}>{children}</Provider>
|
|
49
|
+
</BaseStyles>
|
|
50
|
+
</ThemeUIThemeProvider>
|
|
51
|
+
</ErrorBoundary>
|
|
49
52
|
);
|
|
50
53
|
}
|
|
51
54
|
return {
|
|
@@ -36,8 +36,7 @@ export const dummyServerState: Pick<
|
|
|
36
36
|
"https://0yyeb2g040.execute-api.us-east-1.amazonaws.com/prod/",
|
|
37
37
|
PrismicOembed: "https://oembed.prismic.io",
|
|
38
38
|
PrismicUnsplash: "https://unsplash.prismic.io",
|
|
39
|
-
SliceMachineV1:
|
|
40
|
-
"https://21vvgrh0s6.execute-api.us-east-1.amazonaws.com/v1/",
|
|
39
|
+
SliceMachineV1: "https://sm-api.prismic.io/v1/",
|
|
41
40
|
},
|
|
42
41
|
shortId: "shortId",
|
|
43
42
|
supportsSliceSimulator: true,
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { type FC } from "react";
|
|
2
|
-
import Link from "next/link";
|
|
3
|
-
import { useRouter } from "next/router";
|
|
4
|
-
|
|
5
|
-
import { SideNavLink, SideNavListItem } from "@src/components/SideNav";
|
|
6
|
-
import { RadarIcon } from "@src/icons/RadarIcon";
|
|
7
|
-
import {
|
|
8
|
-
HoverCard,
|
|
9
|
-
HoverCardCloseButton,
|
|
10
|
-
HoverCardDescription,
|
|
11
|
-
HoverCardMedia,
|
|
12
|
-
HoverCardTitle,
|
|
13
|
-
} from "@src/components/HoverCard";
|
|
14
|
-
import useSliceMachineActions from "@src/modules/useSliceMachineActions";
|
|
15
|
-
|
|
16
|
-
import { ChangesRightElement } from "./ChangesRightElement";
|
|
17
|
-
|
|
18
|
-
export const ChangesListItem: FC = () => {
|
|
19
|
-
const { setSeenChangesToolTip } = useSliceMachineActions();
|
|
20
|
-
const open = useOpenChangesHoverCard();
|
|
21
|
-
const router = useRouter();
|
|
22
|
-
|
|
23
|
-
const onClose = () => {
|
|
24
|
-
setSeenChangesToolTip();
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
<HoverCard
|
|
29
|
-
open={open}
|
|
30
|
-
openDelay={3000}
|
|
31
|
-
onClose={onClose}
|
|
32
|
-
side="right"
|
|
33
|
-
sideOffset={24}
|
|
34
|
-
collisionPadding={280}
|
|
35
|
-
trigger={
|
|
36
|
-
<SideNavListItem>
|
|
37
|
-
<SideNavLink
|
|
38
|
-
title="Changes"
|
|
39
|
-
href="/changes"
|
|
40
|
-
active={router.asPath.startsWith("/changes")}
|
|
41
|
-
component={Link}
|
|
42
|
-
Icon={RadarIcon}
|
|
43
|
-
RightElement={<ChangesRightElement />}
|
|
44
|
-
/>
|
|
45
|
-
</SideNavListItem>
|
|
46
|
-
}
|
|
47
|
-
>
|
|
48
|
-
<HoverCardTitle>Push your changes</HoverCardTitle>
|
|
49
|
-
<HoverCardMedia component="image" src="/push.png" />
|
|
50
|
-
<HoverCardDescription>
|
|
51
|
-
When you click Save, your changes are saved locally. Then, you can push
|
|
52
|
-
your models to Prismic from the Changes page.
|
|
53
|
-
</HoverCardDescription>
|
|
54
|
-
<HoverCardCloseButton>Got it</HoverCardCloseButton>
|
|
55
|
-
</HoverCard>
|
|
56
|
-
);
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
// TODO(DT-1925): Reactivate this feature
|
|
60
|
-
const useOpenChangesHoverCard = () => {
|
|
61
|
-
// const { hasSeenChangesToolTip, hasSeenSimulatorToolTip } = useSelector(
|
|
62
|
-
// (store: SliceMachineStoreType) => ({
|
|
63
|
-
// hasSeenChangesToolTip: userHasSeenChangesToolTip(store),
|
|
64
|
-
// hasSeenSimulatorToolTip: userHasSeenSimulatorToolTip(store),
|
|
65
|
-
// }),
|
|
66
|
-
// );
|
|
67
|
-
|
|
68
|
-
// return (
|
|
69
|
-
// !hasSeenChangesToolTip &&
|
|
70
|
-
// hasSeenSimulatorToolTip
|
|
71
|
-
// );
|
|
72
|
-
|
|
73
|
-
return false;
|
|
74
|
-
};
|
|
@@ -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
|
-
};
|