slice-machine-ui 2.18.1-beta.6 → 2.18.1-beta.8
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/out/404.html +1 -1
- package/out/_next/static/U9WVTg1pSTJVt94SbRE5Y/_buildManifest.js +1 -0
- package/out/_next/static/chunks/{248-43faecb386a16518.js → 248-a9c33f7fbe2da2f1.js} +1 -1
- package/out/_next/static/chunks/256-07f768a2b19b0a0e.js +4 -0
- package/out/_next/static/chunks/34-50c64778da33cff6.js +1 -0
- package/out/_next/static/chunks/344-fdb3008f4bb3b0c1.js +1 -0
- package/out/_next/static/chunks/429-aab52070cad2884b.js +3 -0
- package/out/_next/static/chunks/484-3e011e79c41f0342.js +1 -0
- package/out/_next/static/chunks/{489-234ed5471aa694b3.js → 489-a046ae0fa4f74435.js} +1 -1
- package/out/_next/static/chunks/500-d3989390f5e8da53.js +1 -0
- package/out/_next/static/chunks/52d4c156-89c6ec6efca0a0bb.js +1 -0
- package/out/_next/static/chunks/{630-bb6e3db525588f16.js → 630-eae75e90b30f201a.js} +1 -1
- package/out/_next/static/chunks/pages/{_app-174a369b49b73427.js → _app-1b4541325b4a29ab.js} +105 -105
- package/out/_next/static/chunks/pages/{changelog-ba55ed247c20dc21.js → changelog-3901f2fc937d9648.js} +1 -1
- package/out/_next/static/chunks/pages/changes-c58a60af39167147.js +1 -0
- package/out/_next/static/chunks/pages/custom-types/{[customTypeId]-816acb31b652239b.js → [customTypeId]-af9376721beb489e.js} +1 -1
- package/out/_next/static/chunks/pages/{labs-78ac01d97ab02cd7.js → labs-dd04033db23a58f3.js} +1 -1
- package/out/_next/static/chunks/pages/page-types/{[pageTypeId]-669d5479e81b638b.js → [pageTypeId]-a24665e91b882169.js} +1 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/{simulator-b127d948a17968d3.js → simulator-f237aaa755dc9a99.js} +1 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-c8c3e7ffb898261c.js +1 -0
- package/out/_next/static/chunks/pages/slices-0aaae79dcc7b8c55.js +1 -0
- package/out/_next/static/css/{303dad78be1eb854.css → bc89f2cd4e4781f5.css} +1 -1
- package/out/_next/static/css/e8e03c0d4003d1eb.css +1 -0
- package/out/changelog.html +1 -1
- package/out/changes.html +1 -1
- package/out/custom-types/[customTypeId].html +1 -1
- package/out/custom-types.html +1 -1
- package/out/index.html +1 -1
- package/out/labs.html +1 -1
- package/out/page-types/[pageTypeId].html +1 -1
- package/out/slices/[lib]/[sliceName]/[variation]/simulator.html +1 -1
- package/out/slices/[lib]/[sliceName]/[variation].html +1 -1
- package/out/slices.html +1 -1
- package/package.json +3 -3
- package/src/features/auth/LogoutButton.tsx +42 -36
- package/src/features/builder/fields/contentRelationship/ContentRelationshipFieldPicker.tsx +3 -3
- package/src/features/changes/StatusBadge.tsx +1 -9
- package/src/features/customTypes/customTypesBuilder/PageSnippetDialog/PageSnippetDialog.tsx +3 -3
- package/src/features/customTypes/customTypesTable/CustomTypesTablePage.tsx +3 -3
- package/src/features/environments/actions/useSetEnvironment.ts +22 -0
- package/src/features/environments/useActiveEnvironment.ts +17 -9
- package/src/features/environments/useEnvironments.ts +11 -8
- package/src/features/errorBoundaries/AppStateErrorBoundary.tsx +108 -0
- package/src/{ErrorBoundary.tsx → features/errorBoundaries/DefaultErrorBoundary.tsx} +2 -2
- package/src/features/errorBoundaries/index.ts +2 -0
- package/src/features/labs/labsList/LabsPage.tsx +3 -3
- package/src/features/navigation/Navigation.tsx +7 -8
- package/src/features/slices/sliceBuilder/FloatingBackButton.tsx +3 -3
- package/src/features/sync/AutoSyncProvider.tsx +2 -2
- package/src/features/sync/getUnSyncChanges.ts +1 -3
- package/src/legacy/components/AppLayout/index.tsx +10 -85
- package/src/legacy/components/ChangesEmptyState/UnauthenticatedView.tsx +31 -0
- package/src/legacy/components/ChangesEmptyState/index.ts +1 -1
- package/src/legacy/components/ChangesItems/ChangesItems.tsx +3 -3
- package/src/legacy/components/LoginModal/index.tsx +14 -6
- package/src/legacy/components/Navigation/ChangesItem.tsx +44 -100
- package/src/legacy/components/Navigation/Environment.tsx +2 -7
- package/src/legacy/components/Navigation/SideNavEnvironmentSelector/SideNavEnvironmentSelector.tsx +3 -8
- package/src/legacy/components/Simulator/index.tsx +3 -3
- package/src/legacy/lib/builders/CustomTypeBuilder/TabZone/index.tsx +3 -3
- package/src/modules/userContext/index.ts +5 -5
- package/src/modules/userContext/types.ts +2 -3
- package/src/pages/_app.tsx +93 -95
- package/src/pages/changes.tsx +4 -5
- package/src/queryClient.tsx +24 -0
- package/test/__testutils__/index.tsx +13 -10
- package/out/_next/static/AMILL72qfLjZDeK2IRMSB/_buildManifest.js +0 -1
- package/out/_next/static/chunks/157-54b8336d20b41933.js +0 -3
- package/out/_next/static/chunks/34-8d9d9b2944824750.js +0 -1
- package/out/_next/static/chunks/349-7118116b93278f73.js +0 -4
- package/out/_next/static/chunks/50-586dc7ab5e584e76.js +0 -1
- package/out/_next/static/chunks/pages/changes-4c23263cdc8e59c6.js +0 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-11802744e89707f7.js +0 -1
- package/out/_next/static/chunks/pages/slices-f6552e2fbc491c4d.js +0 -1
- package/out/_next/static/css/cdee5b195444f185.css +0 -1
- package/src/features/environments/actions/setEnvironment.ts +0 -18
- package/src/legacy/components/ChangesEmptyState/AuthErrorPage.tsx +0 -44
- /package/out/_next/static/{AMILL72qfLjZDeK2IRMSB → U9WVTg1pSTJVt94SbRE5Y}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BlankSlate,
|
|
3
|
+
BlankSlateDescription,
|
|
4
|
+
BlankSlateIcon,
|
|
5
|
+
BlankSlateTitle,
|
|
6
|
+
Box,
|
|
7
|
+
ErrorBoundary as EditorUiErrorBoundary,
|
|
8
|
+
Text,
|
|
9
|
+
} from "@prismicio/editor-ui";
|
|
10
|
+
import {
|
|
11
|
+
isInvalidActiveEnvironmentError,
|
|
12
|
+
isUnauthorizedError,
|
|
13
|
+
} from "@slicemachine/manager/client";
|
|
14
|
+
import Link from "next/link";
|
|
15
|
+
import { PropsWithChildren } from "react";
|
|
16
|
+
|
|
17
|
+
import { ReloadLogoutButton } from "@/features/auth/LogoutButton";
|
|
18
|
+
|
|
19
|
+
export function AppStateErrorBoundary(props: PropsWithChildren) {
|
|
20
|
+
return (
|
|
21
|
+
<EditorUiErrorBoundary
|
|
22
|
+
renderError={(error) => {
|
|
23
|
+
return (
|
|
24
|
+
<Box
|
|
25
|
+
position="absolute"
|
|
26
|
+
top={64}
|
|
27
|
+
width="100%"
|
|
28
|
+
justifyContent="center"
|
|
29
|
+
flexDirection="column"
|
|
30
|
+
>
|
|
31
|
+
<BlankSlate>
|
|
32
|
+
<BlankSlateIcon
|
|
33
|
+
lineColor="tomato11"
|
|
34
|
+
backgroundColor="tomato3"
|
|
35
|
+
name="alert"
|
|
36
|
+
/>
|
|
37
|
+
<BlankSlateTitle>Failed to load Slice Machine</BlankSlateTitle>
|
|
38
|
+
<RenderErrorDescription error={error} />
|
|
39
|
+
</BlankSlate>
|
|
40
|
+
</Box>
|
|
41
|
+
);
|
|
42
|
+
}}
|
|
43
|
+
>
|
|
44
|
+
{props.children}
|
|
45
|
+
</EditorUiErrorBoundary>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function RenderErrorDescription(args: { error: unknown }) {
|
|
50
|
+
const { error } = args;
|
|
51
|
+
|
|
52
|
+
if (isUnauthorizedError(error)) {
|
|
53
|
+
return (
|
|
54
|
+
<CommonErrorBox>
|
|
55
|
+
<Box flexDirection="column" gap={8} alignItems="center">
|
|
56
|
+
<Text variant="h3" align="center">
|
|
57
|
+
You don't have access to this repository.
|
|
58
|
+
</Text>
|
|
59
|
+
<Text align="center">
|
|
60
|
+
Check that the repository name is correct, then contact your
|
|
61
|
+
repository administrator.
|
|
62
|
+
</Text>
|
|
63
|
+
</Box>
|
|
64
|
+
<ReloadLogoutButton sx={{ alignSelf: "center" }} />
|
|
65
|
+
</CommonErrorBox>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (isInvalidActiveEnvironmentError(error)) {
|
|
70
|
+
return (
|
|
71
|
+
<CommonErrorBox>
|
|
72
|
+
<Box flexDirection="column" gap={8} alignItems="center">
|
|
73
|
+
<Text variant="h3" align="center">
|
|
74
|
+
Your current environment is invalid.
|
|
75
|
+
</Text>
|
|
76
|
+
<Text align="center">
|
|
77
|
+
Check with your repository administrator that you have permissions
|
|
78
|
+
and correctly configured your environment for the current
|
|
79
|
+
repository. For more details, consult the{" "}
|
|
80
|
+
<Link href="https://prismic.io/docs/environments" target="_blank">
|
|
81
|
+
documentation
|
|
82
|
+
</Link>
|
|
83
|
+
.
|
|
84
|
+
</Text>
|
|
85
|
+
</Box>
|
|
86
|
+
<ReloadLogoutButton sx={{ alignSelf: "center" }} />
|
|
87
|
+
</CommonErrorBox>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return <BlankSlateDescription>{JSON.stringify(error)}</BlankSlateDescription>;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function CommonErrorBox(args: { children: React.ReactNode }) {
|
|
95
|
+
const { children } = args;
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<Box
|
|
99
|
+
flexDirection="column"
|
|
100
|
+
alignItems="center"
|
|
101
|
+
gap={16}
|
|
102
|
+
margin={{ top: 8 }}
|
|
103
|
+
maxWidth={768}
|
|
104
|
+
>
|
|
105
|
+
{children}
|
|
106
|
+
</Box>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
@@ -12,13 +12,13 @@ import {
|
|
|
12
12
|
|
|
13
13
|
import { useAuthStatus } from "@/hooks/useAuthStatus";
|
|
14
14
|
|
|
15
|
-
type
|
|
15
|
+
type DefaultErrorBoundaryProps = Pick<
|
|
16
16
|
// TODO(DT-1979): Export the `ErrorBoundaryProps` type from `@prismicio/editor-ui`.
|
|
17
17
|
ComponentPropsWithoutRef<typeof EditorUiErrorBoundary>,
|
|
18
18
|
"children" | "renderError"
|
|
19
19
|
>;
|
|
20
20
|
|
|
21
|
-
export const
|
|
21
|
+
export const DefaultErrorBoundary: FC<DefaultErrorBoundaryProps> = (props) => {
|
|
22
22
|
const errorRef = useRef<unknown>();
|
|
23
23
|
const authStatus = useAuthStatus();
|
|
24
24
|
return (
|
|
@@ -3,7 +3,7 @@ import Head from "next/head";
|
|
|
3
3
|
import { type FC, ReactNode, Suspense } from "react";
|
|
4
4
|
|
|
5
5
|
import { BreadcrumbItem } from "@/components/Breadcrumb";
|
|
6
|
-
import {
|
|
6
|
+
import { DefaultErrorBoundary } from "@/features/errorBoundaries";
|
|
7
7
|
import {
|
|
8
8
|
AppLayout,
|
|
9
9
|
AppLayoutBreadcrumb,
|
|
@@ -19,7 +19,7 @@ export const LabsPage: FC = () => {
|
|
|
19
19
|
<Head>
|
|
20
20
|
<title>Labs - Slice Machine</title>
|
|
21
21
|
</Head>
|
|
22
|
-
<
|
|
22
|
+
<DefaultErrorBoundary
|
|
23
23
|
renderError={() => (
|
|
24
24
|
<LabsPageLayout>
|
|
25
25
|
<Box alignItems="center" justifyContent="center">
|
|
@@ -42,7 +42,7 @@ export const LabsPage: FC = () => {
|
|
|
42
42
|
<LabsList />
|
|
43
43
|
</LabsPageLayout>
|
|
44
44
|
</Suspense>
|
|
45
|
-
</
|
|
45
|
+
</DefaultErrorBoundary>
|
|
46
46
|
</>
|
|
47
47
|
);
|
|
48
48
|
};
|
|
@@ -9,9 +9,9 @@ import { useRouter } from "next/router";
|
|
|
9
9
|
import { Suspense } from "react";
|
|
10
10
|
|
|
11
11
|
import { telemetry } from "@/apiClient";
|
|
12
|
-
import { ErrorBoundary } from "@/ErrorBoundary";
|
|
13
12
|
import { CUSTOM_TYPES_CONFIG } from "@/features/customTypes/customTypesConfig";
|
|
14
13
|
import { CUSTOM_TYPES_MESSAGES } from "@/features/customTypes/customTypesMessages";
|
|
14
|
+
import { DefaultErrorBoundary } from "@/features/errorBoundaries";
|
|
15
15
|
import { RepositoryInfo } from "@/features/navigation/RepositoryInfo";
|
|
16
16
|
import { OnboardingGuide } from "@/features/onboarding";
|
|
17
17
|
import { useAdapterName } from "@/hooks/useAdapterName";
|
|
@@ -86,21 +86,20 @@ export function Navigation() {
|
|
|
86
86
|
/>
|
|
87
87
|
</ActionList>
|
|
88
88
|
|
|
89
|
-
<
|
|
89
|
+
<DefaultErrorBoundary>
|
|
90
90
|
<Suspense>
|
|
91
91
|
<UpdateInfo />
|
|
92
92
|
</Suspense>
|
|
93
|
-
</
|
|
93
|
+
</DefaultErrorBoundary>
|
|
94
94
|
</Box>
|
|
95
95
|
|
|
96
96
|
<Box flexDirection="column">
|
|
97
97
|
<ActionList variant="compact">
|
|
98
|
-
<
|
|
98
|
+
<DefaultErrorBoundary>
|
|
99
99
|
<Suspense>
|
|
100
100
|
<OnboardingGuide />
|
|
101
101
|
</Suspense>
|
|
102
|
-
</
|
|
103
|
-
|
|
102
|
+
</DefaultErrorBoundary>
|
|
104
103
|
<NavigationItem
|
|
105
104
|
title="Documentation"
|
|
106
105
|
href={documentationLink}
|
|
@@ -136,11 +135,11 @@ export function Navigation() {
|
|
|
136
135
|
Icon={LightningIcon}
|
|
137
136
|
active={router.asPath.startsWith("/changelog")}
|
|
138
137
|
RightElement={
|
|
139
|
-
<
|
|
138
|
+
<DefaultErrorBoundary>
|
|
140
139
|
<Suspense fallback={<Skeleton height={16} />}>
|
|
141
140
|
<SliceMachineVersion />
|
|
142
141
|
</Suspense>
|
|
143
|
-
</
|
|
142
|
+
</DefaultErrorBoundary>
|
|
144
143
|
}
|
|
145
144
|
/>
|
|
146
145
|
</ActionList>
|
|
@@ -2,13 +2,13 @@ import { Box, Button, ButtonGroup } from "@prismicio/editor-ui";
|
|
|
2
2
|
import { useRouter } from "next/router";
|
|
3
3
|
import { type FC, Suspense, useState } from "react";
|
|
4
4
|
|
|
5
|
-
import { ErrorBoundary } from "@/ErrorBoundary";
|
|
6
5
|
import { useCustomType } from "@/features/customTypes/customTypesBuilder/useCustomType";
|
|
7
6
|
import {
|
|
8
7
|
CUSTOM_TYPES_CONFIG,
|
|
9
8
|
matchesBuilderPagePathname,
|
|
10
9
|
readBuilderPageDynamicSegment,
|
|
11
10
|
} from "@/features/customTypes/customTypesConfig";
|
|
11
|
+
import { DefaultErrorBoundary } from "@/features/errorBoundaries";
|
|
12
12
|
import { type Route, useRouteChange } from "@/hooks/useRouteChange";
|
|
13
13
|
import { CloseIcon } from "@/icons/CloseIcon";
|
|
14
14
|
import { UndoIcon } from "@/icons/UndoIcon";
|
|
@@ -17,7 +17,7 @@ export const FloatingBackButton: FC = () => {
|
|
|
17
17
|
const { source } = useRouteChange();
|
|
18
18
|
const sourceCustomTypeId = getSourceCustomTypeId(source);
|
|
19
19
|
return sourceCustomTypeId !== undefined ? (
|
|
20
|
-
<
|
|
20
|
+
<DefaultErrorBoundary>
|
|
21
21
|
<Suspense>
|
|
22
22
|
<Box
|
|
23
23
|
bottom={32}
|
|
@@ -29,7 +29,7 @@ export const FloatingBackButton: FC = () => {
|
|
|
29
29
|
<BackButton sourceCustomTypeId={sourceCustomTypeId} />
|
|
30
30
|
</Box>
|
|
31
31
|
</Suspense>
|
|
32
|
-
</
|
|
32
|
+
</DefaultErrorBoundary>
|
|
33
33
|
) : null;
|
|
34
34
|
};
|
|
35
35
|
|
|
@@ -83,7 +83,7 @@ export const AutoSyncProvider: FC<PropsWithChildren> = (props) => {
|
|
|
83
83
|
|
|
84
84
|
// We default to a full user logged in with internet access if not provider.
|
|
85
85
|
// This is useful when we want to sync changes right after the user logs in.
|
|
86
|
-
loggedIn = isOnline && authStatus === AuthStatus.
|
|
86
|
+
loggedIn = isOnline && authStatus === AuthStatus.AUTHENTICATED,
|
|
87
87
|
} = args;
|
|
88
88
|
|
|
89
89
|
if (!loggedIn || environment?.kind !== "dev") {
|
|
@@ -240,7 +240,7 @@ function getAutoSyncStatus(args: GetAutoSyncStatusArgs): AutoSyncStatus {
|
|
|
240
240
|
return "offline";
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
-
if (authStatus !== AuthStatus.
|
|
243
|
+
if (authStatus !== AuthStatus.AUTHENTICATED) {
|
|
244
244
|
return "not-logged-in";
|
|
245
245
|
}
|
|
246
246
|
|
|
@@ -149,9 +149,7 @@ export const getModelStatus = (args: GetModelStatusArgs): ModelsStatuses => {
|
|
|
149
149
|
const { slices, customTypes, isOnline, authStatus } = args;
|
|
150
150
|
|
|
151
151
|
const userHasAccessToModels =
|
|
152
|
-
isOnline &&
|
|
153
|
-
authStatus != AuthStatus.FORBIDDEN &&
|
|
154
|
-
authStatus != AuthStatus.UNAUTHORIZED;
|
|
152
|
+
isOnline && authStatus === AuthStatus.AUTHENTICATED;
|
|
155
153
|
|
|
156
154
|
const modelsStatuses = {
|
|
157
155
|
slices: computeStatuses(slices, userHasAccessToModels),
|
|
@@ -1,16 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BlankSlate,
|
|
3
|
-
BlankSlateDescription,
|
|
4
|
-
BlankSlateIcon,
|
|
5
|
-
BlankSlateTitle,
|
|
6
|
-
Box,
|
|
7
|
-
Button,
|
|
8
|
-
ButtonGroup,
|
|
9
|
-
Text,
|
|
10
|
-
} from "@prismicio/editor-ui";
|
|
11
|
-
import { isUnauthorizedError } from "@slicemachine/manager/client";
|
|
1
|
+
import { Box, Button, ButtonGroup } from "@prismicio/editor-ui";
|
|
12
2
|
import { useRouter } from "next/router";
|
|
13
|
-
import { FC, PropsWithChildren, Suspense
|
|
3
|
+
import { FC, PropsWithChildren, Suspense } from "react";
|
|
14
4
|
|
|
15
5
|
import { Breadcrumb } from "@/components/Breadcrumb";
|
|
16
6
|
import {
|
|
@@ -19,8 +9,6 @@ import {
|
|
|
19
9
|
PageLayoutHeader,
|
|
20
10
|
PageLayoutPane,
|
|
21
11
|
} from "@/components/PageLayout";
|
|
22
|
-
import { ErrorBoundary } from "@/ErrorBoundary";
|
|
23
|
-
import { LogoutButton } from "@/features/auth/LogoutButton";
|
|
24
12
|
import { useActiveEnvironment } from "@/features/environments/useActiveEnvironment";
|
|
25
13
|
import { Navigation } from "@/features/navigation/Navigation";
|
|
26
14
|
|
|
@@ -29,80 +17,17 @@ export const AppLayout: FC<PropsWithChildren> = ({
|
|
|
29
17
|
...otherProps
|
|
30
18
|
}) => {
|
|
31
19
|
return (
|
|
32
|
-
<
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
<
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
flexDirection="column"
|
|
41
|
-
>
|
|
42
|
-
<BlankSlate>
|
|
43
|
-
<BlankSlateIcon
|
|
44
|
-
lineColor="tomato11"
|
|
45
|
-
backgroundColor="tomato3"
|
|
46
|
-
name="alert"
|
|
47
|
-
/>
|
|
48
|
-
<BlankSlateTitle>Failed to load Slice Machine</BlankSlateTitle>
|
|
49
|
-
<BlankSlateDescription>
|
|
50
|
-
<RenderError error={error} />
|
|
51
|
-
</BlankSlateDescription>
|
|
52
|
-
</BlankSlate>
|
|
53
|
-
</Box>
|
|
54
|
-
);
|
|
55
|
-
}}
|
|
56
|
-
>
|
|
57
|
-
<Suspense>
|
|
58
|
-
<PageLayoutWithActiveEnvironment {...otherProps}>
|
|
59
|
-
<PageLayoutPane>
|
|
60
|
-
<Navigation />
|
|
61
|
-
</PageLayoutPane>
|
|
62
|
-
{children}
|
|
63
|
-
</PageLayoutWithActiveEnvironment>
|
|
64
|
-
</Suspense>
|
|
65
|
-
</ErrorBoundary>
|
|
20
|
+
<Suspense>
|
|
21
|
+
<PageLayoutWithActiveEnvironment {...otherProps}>
|
|
22
|
+
<PageLayoutPane>
|
|
23
|
+
<Navigation />
|
|
24
|
+
</PageLayoutPane>
|
|
25
|
+
{children}
|
|
26
|
+
</PageLayoutWithActiveEnvironment>
|
|
27
|
+
</Suspense>
|
|
66
28
|
);
|
|
67
29
|
};
|
|
68
30
|
|
|
69
|
-
function RenderError(args: { error: unknown }) {
|
|
70
|
-
const { error } = args;
|
|
71
|
-
|
|
72
|
-
if (isUnauthorizedError(error)) {
|
|
73
|
-
return <UnauthorizedErrorView />;
|
|
74
|
-
}
|
|
75
|
-
return <>{JSON.stringify(error)}</>;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function UnauthorizedErrorView() {
|
|
79
|
-
const [isLoggingOut, setIsLoggingOut] = useState(false);
|
|
80
|
-
|
|
81
|
-
return (
|
|
82
|
-
<Box flexDirection="column" gap={16} margin={{ top: 8 }}>
|
|
83
|
-
<Box flexDirection="column" gap={8} alignItems="center">
|
|
84
|
-
<Text variant="h3" align="center">
|
|
85
|
-
It seems like you don't have access to this repository
|
|
86
|
-
</Text>
|
|
87
|
-
<Text align="center">
|
|
88
|
-
Check that the repository name is correct, then contact your
|
|
89
|
-
repository administrator.
|
|
90
|
-
</Text>
|
|
91
|
-
</Box>
|
|
92
|
-
<LogoutButton
|
|
93
|
-
isLoading={isLoggingOut}
|
|
94
|
-
onLogoutSuccess={() => {
|
|
95
|
-
setIsLoggingOut(true);
|
|
96
|
-
window.location.reload();
|
|
97
|
-
}}
|
|
98
|
-
sx={{ alignSelf: "center" }}
|
|
99
|
-
>
|
|
100
|
-
Log out
|
|
101
|
-
</LogoutButton>
|
|
102
|
-
</Box>
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
31
|
const environmentTopBorderColorMap = {
|
|
107
32
|
prod: "purple",
|
|
108
33
|
stage: "indigo",
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Box, Button, Text } from "@prismicio/editor-ui";
|
|
2
|
+
|
|
3
|
+
import useSliceMachineActions from "@/modules/useSliceMachineActions";
|
|
4
|
+
|
|
5
|
+
export const UnauthenticatedView = () => {
|
|
6
|
+
const { openLoginModal } = useSliceMachineActions();
|
|
7
|
+
|
|
8
|
+
return (
|
|
9
|
+
<Box
|
|
10
|
+
flexDirection="column"
|
|
11
|
+
height="100%"
|
|
12
|
+
alignItems="center"
|
|
13
|
+
justifyContent="center"
|
|
14
|
+
gap={8}
|
|
15
|
+
>
|
|
16
|
+
<Text variant="h3" align="center">
|
|
17
|
+
It seems like you are logged out
|
|
18
|
+
</Text>
|
|
19
|
+
<Text align="center">Log in to connect to your repository.</Text>
|
|
20
|
+
<Text align="center">
|
|
21
|
+
If that doesn't work, it's possible that Slice Machine is having trouble
|
|
22
|
+
accessing Prismic's servers.{" "}
|
|
23
|
+
<Text href="https://community.prismic.io/">
|
|
24
|
+
Contact our support team
|
|
25
|
+
</Text>
|
|
26
|
+
.
|
|
27
|
+
</Text>
|
|
28
|
+
<Button onClick={() => openLoginModal()}>Log in to Prismic</Button>
|
|
29
|
+
</Box>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
@@ -3,7 +3,7 @@ import React, { Suspense } from "react";
|
|
|
3
3
|
import { AiOutlineExclamationCircle } from "react-icons/ai";
|
|
4
4
|
|
|
5
5
|
import { countMissingScreenshots } from "@/domain/slice";
|
|
6
|
-
import {
|
|
6
|
+
import { DefaultErrorBoundary } from "@/features/errorBoundaries";
|
|
7
7
|
import { SharedSliceCard } from "@/features/slices/sliceCards/SharedSliceCard";
|
|
8
8
|
import { ModelsStatuses } from "@/features/sync/getUnSyncChanges";
|
|
9
9
|
import { useScreenshotChangesModal } from "@/hooks/useScreenshotChangesModal";
|
|
@@ -146,11 +146,11 @@ export const ChangesItems: React.FC<ChangesItemsProps> = ({
|
|
|
146
146
|
)}
|
|
147
147
|
</Box>
|
|
148
148
|
|
|
149
|
-
<
|
|
149
|
+
<DefaultErrorBoundary>
|
|
150
150
|
<Suspense>
|
|
151
151
|
<DevCollaborationExperiment />
|
|
152
152
|
</Suspense>
|
|
153
|
-
</
|
|
153
|
+
</DefaultErrorBoundary>
|
|
154
154
|
</Box>
|
|
155
155
|
</>
|
|
156
156
|
);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useQueryClient } from "@tanstack/react-query";
|
|
1
2
|
import React from "react";
|
|
2
3
|
import Modal from "react-modal";
|
|
3
4
|
import { useSelector } from "react-redux";
|
|
@@ -15,8 +16,8 @@ import {
|
|
|
15
16
|
|
|
16
17
|
import { checkAuthStatus, clearAuth, getState } from "@/apiClient";
|
|
17
18
|
import { getActiveEnvironment } from "@/features/environments/actions/getActiveEnvironment";
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
19
|
+
import { GetActiveEnvironmentQueryKey } from "@/features/environments/useActiveEnvironment";
|
|
20
|
+
import { GetEnvironmentsQueryKey } from "@/features/environments/useEnvironments";
|
|
20
21
|
import { useAutoSync } from "@/features/sync/AutoSyncProvider";
|
|
21
22
|
import { getUnSyncedChanges } from "@/features/sync/getUnSyncChanges";
|
|
22
23
|
import SliceMachineModal from "@/legacy/components/SliceMachineModal";
|
|
@@ -54,6 +55,7 @@ const LoginModal: React.FunctionComponent = () => {
|
|
|
54
55
|
const { syncChanges } = useAutoSync();
|
|
55
56
|
const { closeModals, startLoadingLogin, stopLoadingLogin, refreshState } =
|
|
56
57
|
useSliceMachineActions();
|
|
58
|
+
const queryClient = useQueryClient();
|
|
57
59
|
|
|
58
60
|
const prismicBase = preferWroomBase(env.manifest.apiEndpoint);
|
|
59
61
|
const loginRedirectUrl = `${
|
|
@@ -79,8 +81,14 @@ const LoginModal: React.FunctionComponent = () => {
|
|
|
79
81
|
);
|
|
80
82
|
|
|
81
83
|
// refresh queries to update the UI
|
|
82
|
-
|
|
83
|
-
|
|
84
|
+
await Promise.all([
|
|
85
|
+
queryClient.invalidateQueries({
|
|
86
|
+
queryKey: GetEnvironmentsQueryKey,
|
|
87
|
+
}),
|
|
88
|
+
queryClient.invalidateQueries({
|
|
89
|
+
queryKey: GetActiveEnvironmentQueryKey,
|
|
90
|
+
}),
|
|
91
|
+
]);
|
|
84
92
|
|
|
85
93
|
toast.success("Logged in");
|
|
86
94
|
stopLoadingLogin();
|
|
@@ -100,7 +108,7 @@ const LoginModal: React.FunctionComponent = () => {
|
|
|
100
108
|
),
|
|
101
109
|
);
|
|
102
110
|
const { changedCustomTypes, changedSlices } = getUnSyncedChanges({
|
|
103
|
-
authStatus: AuthStatus.
|
|
111
|
+
authStatus: AuthStatus.AUTHENTICATED,
|
|
104
112
|
customTypes,
|
|
105
113
|
isOnline: true,
|
|
106
114
|
libraries: serverState.libraries,
|
|
@@ -127,7 +135,7 @@ const LoginModal: React.FunctionComponent = () => {
|
|
|
127
135
|
|
|
128
136
|
return (
|
|
129
137
|
<SliceMachineModal
|
|
130
|
-
isOpen={isOpen}
|
|
138
|
+
isOpen={isLoginLoading || isOpen}
|
|
131
139
|
shouldCloseOnOverlayClick
|
|
132
140
|
onRequestClose={closeModals}
|
|
133
141
|
contentLabel={"login_modal"}
|