slice-machine-ui 2.17.3-alpha.jp-field-type.1 → 2.17.3-alpha.jp-logout.3
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/IuHy5xX4O7OS7pw5BhQtD/_buildManifest.js +1 -0
- package/out/_next/static/chunks/{248-6f20227ad4764216.js → 248-ce52121d4f52fee1.js} +1 -1
- package/out/_next/static/chunks/{34-6c3125e6f01c62c7.js → 34-7d7a907d79f9279b.js} +1 -1
- package/out/_next/static/chunks/{489-a42bd4eeb1350d97.js → 489-70cd522d13c732e7.js} +1 -1
- package/out/_next/static/chunks/50-586dc7ab5e584e76.js +1 -0
- package/out/_next/static/chunks/630-ee074347f93761a9.js +1 -0
- package/out/_next/static/chunks/{647-7b9b5aa9468f9e4b.js → 647-740ad5d8c2da5010.js} +1 -1
- package/out/_next/static/chunks/7c1bce44.7757952f8fa3a45d.js +28 -0
- package/out/_next/static/chunks/{907-a42dc5698d5dc000.js → 907-ec265d505f89358d.js} +1 -1
- package/out/_next/static/chunks/pages/{_app-f0fb73e024f8f44f.js → _app-655a32ee37d0a72e.js} +220 -222
- package/out/_next/static/chunks/pages/{changelog-98836c22c6a40c5d.js → changelog-64a61af8248660c4.js} +1 -1
- package/out/_next/static/chunks/pages/{changes-2bd69f3877d60b26.js → changes-1eee1278e11e37fe.js} +1 -1
- package/out/_next/static/chunks/pages/custom-types/{[customTypeId]-4024560ca59ad2be.js → [customTypeId]-7102c23f96cd1768.js} +1 -1
- package/out/_next/static/chunks/pages/{labs-ad7f36c6f544c1a8.js → labs-044341a257fe1f55.js} +1 -1
- package/out/_next/static/chunks/pages/page-types/{[pageTypeId]-0d2416da0958eb40.js → [pageTypeId]-d4bc920a5efffa0a.js} +1 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/{simulator-0ecd552897e61e29.js → simulator-760b1b0acfc25361.js} +1 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/{[variation]-8b6e7854cb3466d4.js → [variation]-63a0b554bb376d8b.js} +1 -1
- package/out/_next/static/chunks/pages/{slices-fe1bb16ff3020762.js → slices-7d9503c44b707717.js} +1 -1
- package/out/_next/static/chunks/{webpack-b3522fdebabf510a.js → webpack-9ab76e21d6198b49.js} +1 -1
- package/out/_next/static/css/303dad78be1eb854.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 +6 -6
- package/src/apiClient.ts +1 -1
- package/src/domain/fields.ts +17 -49
- package/src/features/auth/LogoutButton.tsx +32 -0
- package/src/features/environments/useActiveEnvironment.ts +9 -1
- package/src/features/environments/useEnvironments.ts +8 -1
- package/src/legacy/components/ItemHeader/index.tsx +3 -6
- package/src/legacy/components/ListItem/Header.tsx +12 -19
- package/src/legacy/components/ListItem/index.tsx +0 -1
- package/src/legacy/components/LoginModal/index.tsx +8 -2
- package/src/legacy/components/Navigation/SideNavEnvironmentSelector/SideNavEnvironmentSelector.tsx +3 -0
- package/src/legacy/lib/builders/common/EditModal/index.jsx +10 -4
- package/src/legacy/lib/models/common/widgets/Group/createGroupWidget.ts +1 -2
- package/src/legacy/lib/models/common/widgets/Widget.ts +1 -2
- package/src/modules/auth.ts +3 -0
- package/src/modules/availableCustomTypes/index.ts +12 -1
- package/src/modules/slices/index.ts +10 -1
- package/src/modules/useSliceMachineActions.ts +4 -1
- package/src/modules/userContext/index.ts +8 -0
- package/out/_next/static/chunks/33641354.3864aefb6106ae71.js +0 -28
- package/out/_next/static/chunks/44-a2056f993381ad0f.js +0 -1
- package/out/_next/static/chunks/630-4816078c5c8305e8.js +0 -1
- package/out/_next/static/css/cc9b10286400c2b9.css +0 -1
- package/out/_next/static/krHWnQqEiEZ6ik3PpEjL8/_buildManifest.js +0 -1
- /package/out/_next/static/{krHWnQqEiEZ6ik3PpEjL8 → IuHy5xX4O7OS7pw5BhQtD}/_ssgManifest.js +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "slice-machine-ui",
|
|
3
|
-
"version": "2.17.3-alpha.jp-
|
|
3
|
+
"version": "2.17.3-alpha.jp-logout.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "A visual builder for your Slice Models with all the tools you need to generate data models and mock CMS content locally.",
|
|
6
6
|
"repository": {
|
|
@@ -35,16 +35,16 @@
|
|
|
35
35
|
"start-slicemachine": "./bin/start-slicemachine.cjs"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@slicemachine/manager": "0.25.2-alpha.jp-
|
|
39
|
-
"start-slicemachine": "0.12.60-alpha.jp-
|
|
38
|
+
"@slicemachine/manager": "0.25.2-alpha.jp-logout.5",
|
|
39
|
+
"start-slicemachine": "0.12.60-alpha.jp-logout.5"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@emotion/react": "11.11.1",
|
|
43
43
|
"@extractus/oembed-extractor": "3.1.8",
|
|
44
44
|
"@prismicio/client": "7.17.0",
|
|
45
|
-
"@prismicio/editor-fields": "0.4.
|
|
46
|
-
"@prismicio/editor-support": "0.4.
|
|
47
|
-
"@prismicio/editor-ui": "0.4.
|
|
45
|
+
"@prismicio/editor-fields": "0.4.85",
|
|
46
|
+
"@prismicio/editor-support": "0.4.85",
|
|
47
|
+
"@prismicio/editor-ui": "0.4.85",
|
|
48
48
|
"@prismicio/mock": "0.7.1",
|
|
49
49
|
"@prismicio/mocks": "2.14.0",
|
|
50
50
|
"@prismicio/simulator": "0.1.4",
|
package/src/apiClient.ts
CHANGED
|
@@ -163,7 +163,7 @@ export const pushChanges: SliceMachineManagerClient["prismicRepository"]["pushCh
|
|
|
163
163
|
|
|
164
164
|
/** Auth Routes * */
|
|
165
165
|
|
|
166
|
-
export const
|
|
166
|
+
export const logout = async (): Promise<void> => {
|
|
167
167
|
return await managerClient.user.logout();
|
|
168
168
|
};
|
|
169
169
|
|
package/src/domain/fields.ts
CHANGED
|
@@ -34,44 +34,12 @@ export interface GroupField extends BaseField {
|
|
|
34
34
|
|
|
35
35
|
export type Field = NestableField | UIDField | GroupField;
|
|
36
36
|
|
|
37
|
-
export type CustomFieldType =
|
|
38
|
-
| FieldType
|
|
39
|
-
| "LinkToMedia"
|
|
40
|
-
| "ContentRelationship"
|
|
41
|
-
| "NestedGroup";
|
|
42
|
-
|
|
43
|
-
export const fieldLabels: Record<CustomFieldType, string> = {
|
|
44
|
-
Text: "Text",
|
|
45
|
-
StructuredText: "Rich Text",
|
|
46
|
-
Boolean: "Boolean",
|
|
47
|
-
Number: "Number",
|
|
48
|
-
Select: "Select",
|
|
49
|
-
Link: "Link",
|
|
50
|
-
LinkToMedia: "Link To Media",
|
|
51
|
-
UID: "UID",
|
|
52
|
-
Image: "Image",
|
|
53
|
-
Group: "Repeatable Group",
|
|
54
|
-
NestedGroup: "Nested Group",
|
|
55
|
-
Color: "Color",
|
|
56
|
-
Date: "Date",
|
|
57
|
-
Table: "Table",
|
|
58
|
-
Timestamp: "Timestamp",
|
|
59
|
-
Embed: "Embed",
|
|
60
|
-
GeoPoint: "Geopoint",
|
|
61
|
-
ContentRelationship: "Content Relationship",
|
|
62
|
-
IntegrationFields: "Integration Fields",
|
|
63
|
-
Range: "Range",
|
|
64
|
-
Separator: "Separator",
|
|
65
|
-
Slices: "Slices",
|
|
66
|
-
Choice: "Choice",
|
|
67
|
-
};
|
|
68
|
-
|
|
69
37
|
/**
|
|
70
38
|
* Nestable fields
|
|
71
39
|
*/
|
|
72
40
|
|
|
73
41
|
export const booleanField: NestableField = {
|
|
74
|
-
name:
|
|
42
|
+
name: "Boolean",
|
|
75
43
|
description: "A true or false toggle.",
|
|
76
44
|
icon: "toggleOff",
|
|
77
45
|
thumbnail:
|
|
@@ -80,7 +48,7 @@ export const booleanField: NestableField = {
|
|
|
80
48
|
};
|
|
81
49
|
|
|
82
50
|
export const colorField: NestableField = {
|
|
83
|
-
name:
|
|
51
|
+
name: "Color",
|
|
84
52
|
description: "A color in hex format.",
|
|
85
53
|
icon: "colorLens",
|
|
86
54
|
thumbnail:
|
|
@@ -89,7 +57,7 @@ export const colorField: NestableField = {
|
|
|
89
57
|
};
|
|
90
58
|
|
|
91
59
|
export const dateField: NestableField = {
|
|
92
|
-
name:
|
|
60
|
+
name: "Date",
|
|
93
61
|
description: "A date without time.",
|
|
94
62
|
icon: "dateRange",
|
|
95
63
|
thumbnail:
|
|
@@ -98,7 +66,7 @@ export const dateField: NestableField = {
|
|
|
98
66
|
};
|
|
99
67
|
|
|
100
68
|
export const embedField: NestableField = {
|
|
101
|
-
name:
|
|
69
|
+
name: "Embed",
|
|
102
70
|
description: "A video, song, or oEmbed link.",
|
|
103
71
|
icon: "code",
|
|
104
72
|
thumbnail:
|
|
@@ -107,7 +75,7 @@ export const embedField: NestableField = {
|
|
|
107
75
|
};
|
|
108
76
|
|
|
109
77
|
export const geoPointField: NestableField = {
|
|
110
|
-
name:
|
|
78
|
+
name: "Geopoint",
|
|
111
79
|
description: "A geographical coordinate.",
|
|
112
80
|
icon: "place",
|
|
113
81
|
thumbnail:
|
|
@@ -116,7 +84,7 @@ export const geoPointField: NestableField = {
|
|
|
116
84
|
};
|
|
117
85
|
|
|
118
86
|
export const imageField: NestableField = {
|
|
119
|
-
name:
|
|
87
|
+
name: "Image",
|
|
120
88
|
description: "A responsive image.",
|
|
121
89
|
icon: "image",
|
|
122
90
|
thumbnail:
|
|
@@ -125,7 +93,7 @@ export const imageField: NestableField = {
|
|
|
125
93
|
};
|
|
126
94
|
|
|
127
95
|
export const LinkField: NestableField = {
|
|
128
|
-
name:
|
|
96
|
+
name: "Link",
|
|
129
97
|
description: "A link to a website, asset, or document.",
|
|
130
98
|
icon: "link",
|
|
131
99
|
thumbnail:
|
|
@@ -134,7 +102,7 @@ export const LinkField: NestableField = {
|
|
|
134
102
|
};
|
|
135
103
|
|
|
136
104
|
export const contentRelationshipField: NestableField = {
|
|
137
|
-
name:
|
|
105
|
+
name: "Content Relationship",
|
|
138
106
|
description: "A reference to a Prismic document.",
|
|
139
107
|
icon: "settingsEthernet",
|
|
140
108
|
thumbnail:
|
|
@@ -144,7 +112,7 @@ export const contentRelationshipField: NestableField = {
|
|
|
144
112
|
};
|
|
145
113
|
|
|
146
114
|
export const LinkToMediaField: NestableField = {
|
|
147
|
-
name:
|
|
115
|
+
name: "Link To Media",
|
|
148
116
|
description: "A link to a media asset.",
|
|
149
117
|
icon: "attachFile",
|
|
150
118
|
thumbnail:
|
|
@@ -154,7 +122,7 @@ export const LinkToMediaField: NestableField = {
|
|
|
154
122
|
};
|
|
155
123
|
|
|
156
124
|
export const numberField: NestableField = {
|
|
157
|
-
name:
|
|
125
|
+
name: "Number",
|
|
158
126
|
description: "An integer or float.",
|
|
159
127
|
icon: "pin",
|
|
160
128
|
thumbnail:
|
|
@@ -163,7 +131,7 @@ export const numberField: NestableField = {
|
|
|
163
131
|
};
|
|
164
132
|
|
|
165
133
|
export const richTextField: NestableField = {
|
|
166
|
-
name:
|
|
134
|
+
name: "Rich Text",
|
|
167
135
|
description: "Text with formatting options.",
|
|
168
136
|
icon: "textFields",
|
|
169
137
|
thumbnail:
|
|
@@ -172,7 +140,7 @@ export const richTextField: NestableField = {
|
|
|
172
140
|
};
|
|
173
141
|
|
|
174
142
|
export const selectField: NestableField = {
|
|
175
|
-
name:
|
|
143
|
+
name: "Select",
|
|
176
144
|
description: "A dropdown of options.",
|
|
177
145
|
icon: "arrowDropDownCircle",
|
|
178
146
|
thumbnail:
|
|
@@ -181,7 +149,7 @@ export const selectField: NestableField = {
|
|
|
181
149
|
};
|
|
182
150
|
|
|
183
151
|
export const tableField: NestableField = {
|
|
184
|
-
name:
|
|
152
|
+
name: "Table",
|
|
185
153
|
description: "A structured table.",
|
|
186
154
|
icon: "table",
|
|
187
155
|
thumbnail:
|
|
@@ -190,7 +158,7 @@ export const tableField: NestableField = {
|
|
|
190
158
|
};
|
|
191
159
|
|
|
192
160
|
export const textField: NestableField = {
|
|
193
|
-
name:
|
|
161
|
+
name: "Text",
|
|
194
162
|
description: "A text string without formatting.",
|
|
195
163
|
icon: "title",
|
|
196
164
|
thumbnail:
|
|
@@ -199,7 +167,7 @@ export const textField: NestableField = {
|
|
|
199
167
|
};
|
|
200
168
|
|
|
201
169
|
export const timestampField: NestableField = {
|
|
202
|
-
name:
|
|
170
|
+
name: "Timestamp",
|
|
203
171
|
description: "A date and time.",
|
|
204
172
|
icon: "schedule",
|
|
205
173
|
thumbnail:
|
|
@@ -230,7 +198,7 @@ export const nestableFields: NestableField[] = [
|
|
|
230
198
|
*/
|
|
231
199
|
|
|
232
200
|
export const UIDField: UIDField = {
|
|
233
|
-
name:
|
|
201
|
+
name: "UID",
|
|
234
202
|
description: "Unique Identifier",
|
|
235
203
|
icon: "tag",
|
|
236
204
|
thumbnail:
|
|
@@ -243,7 +211,7 @@ export const UIDField: UIDField = {
|
|
|
243
211
|
*/
|
|
244
212
|
|
|
245
213
|
export const groupField: GroupField = {
|
|
246
|
-
name:
|
|
214
|
+
name: "Repeatable Group",
|
|
247
215
|
description: "A set of fields that editors can repeat.",
|
|
248
216
|
icon: "createNewFolder",
|
|
249
217
|
thumbnail:
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { IconButton, Tooltip } from "@prismicio/editor-ui";
|
|
2
|
+
import { toast } from "react-toastify";
|
|
3
|
+
|
|
4
|
+
import { logout as managerLogout } from "@/apiClient";
|
|
5
|
+
import { invalidateActiveEnvironmentData } from "@/features/environments/useActiveEnvironment";
|
|
6
|
+
import { invalidateEnvironmentsData } from "@/features/environments/useEnvironments";
|
|
7
|
+
import useSliceMachineActions from "@/modules/useSliceMachineActions";
|
|
8
|
+
|
|
9
|
+
export function LogoutButton() {
|
|
10
|
+
const { logout: storeLogout } = useSliceMachineActions();
|
|
11
|
+
|
|
12
|
+
async function onClick() {
|
|
13
|
+
await managerLogout();
|
|
14
|
+
storeLogout();
|
|
15
|
+
|
|
16
|
+
// refresh queries to update the UI
|
|
17
|
+
invalidateEnvironmentsData();
|
|
18
|
+
invalidateActiveEnvironmentData();
|
|
19
|
+
|
|
20
|
+
toast.success("Logged out");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<Tooltip content="Log out" side="right">
|
|
25
|
+
<IconButton
|
|
26
|
+
icon="logout"
|
|
27
|
+
onClick={() => void onClick()}
|
|
28
|
+
hiddenLabel="Log out"
|
|
29
|
+
/>
|
|
30
|
+
</Tooltip>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Fetcher,
|
|
3
|
+
invalidateFetcherData,
|
|
4
|
+
useRequest,
|
|
5
|
+
} from "@prismicio/editor-support/Suspense";
|
|
2
6
|
|
|
3
7
|
import { getActiveEnvironment } from "./actions/getActiveEnvironment";
|
|
4
8
|
|
|
9
|
+
export function invalidateActiveEnvironmentData() {
|
|
10
|
+
invalidateFetcherData(getActiveEnvironment as Fetcher<undefined[], unknown>);
|
|
11
|
+
}
|
|
12
|
+
|
|
5
13
|
export function useActiveEnvironment() {
|
|
6
14
|
return useRequest(getActiveEnvironment, []);
|
|
7
15
|
}
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
invalidateFetcherData,
|
|
3
|
+
useRequest,
|
|
4
|
+
} from "@prismicio/editor-support/Suspense";
|
|
2
5
|
|
|
3
6
|
import { getEnvironments } from "./actions/getEnvironments";
|
|
4
7
|
|
|
8
|
+
export function invalidateEnvironmentsData() {
|
|
9
|
+
invalidateFetcherData(getEnvironments);
|
|
10
|
+
}
|
|
11
|
+
|
|
5
12
|
export function useEnvironments() {
|
|
6
13
|
return useRequest(getEnvironments, []);
|
|
7
14
|
}
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import { FieldType } from "@prismicio/types-internal/lib/customtypes";
|
|
2
1
|
import React from "react";
|
|
3
2
|
import type { Theme } from "theme-ui";
|
|
4
3
|
import { Flex, Text } from "theme-ui";
|
|
5
4
|
|
|
6
|
-
import { fieldLabels } from "@/domain/fields";
|
|
7
|
-
|
|
8
5
|
const ItemHeader: React.FC<{
|
|
9
|
-
|
|
6
|
+
text: React.ReactNode;
|
|
10
7
|
sliceFieldName: React.ReactNode;
|
|
11
8
|
theme: Theme;
|
|
12
9
|
WidgetIcon: React.ElementType;
|
|
13
|
-
}> = ({
|
|
10
|
+
}> = ({ text, sliceFieldName, theme, WidgetIcon }) => (
|
|
14
11
|
<Flex sx={{ alignItems: "center" }}>
|
|
15
12
|
<WidgetIcon
|
|
16
13
|
size={28}
|
|
@@ -33,7 +30,7 @@ const ItemHeader: React.FC<{
|
|
|
33
30
|
fontSize: "15px",
|
|
34
31
|
}}
|
|
35
32
|
>
|
|
36
|
-
{
|
|
33
|
+
{text}
|
|
37
34
|
</Text>
|
|
38
35
|
<Text
|
|
39
36
|
as="p"
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { Box, Tooltip } from "@prismicio/editor-ui";
|
|
2
1
|
import * as CSS from "csstype";
|
|
3
2
|
import { IconType } from "react-icons";
|
|
4
3
|
import { Flex, Text, Theme } from "theme-ui";
|
|
5
4
|
|
|
6
|
-
import { CustomFieldType, fieldLabels } from "@/domain/fields";
|
|
7
5
|
import { TextWithTooltip } from "@/legacy/components/Tooltip/TextWithTooltip";
|
|
8
6
|
|
|
9
7
|
interface ItemHeaderProps {
|
|
@@ -11,7 +9,6 @@ interface ItemHeaderProps {
|
|
|
11
9
|
sliceFieldName: string | undefined;
|
|
12
10
|
theme: Theme;
|
|
13
11
|
WidgetIcon: IconType;
|
|
14
|
-
type: CustomFieldType;
|
|
15
12
|
}
|
|
16
13
|
|
|
17
14
|
const ItemHeader: React.FC<ItemHeaderProps> = ({
|
|
@@ -19,24 +16,20 @@ const ItemHeader: React.FC<ItemHeaderProps> = ({
|
|
|
19
16
|
sliceFieldName,
|
|
20
17
|
theme,
|
|
21
18
|
WidgetIcon,
|
|
22
|
-
type,
|
|
23
19
|
}) => (
|
|
24
20
|
<Flex sx={{ alignItems: "center", position: "relative" }}>
|
|
25
|
-
<
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
/>
|
|
38
|
-
</Box>
|
|
39
|
-
</Tooltip>
|
|
21
|
+
<WidgetIcon
|
|
22
|
+
size={28}
|
|
23
|
+
style={{
|
|
24
|
+
color: theme.colors?.primary as CSS.Property.Color,
|
|
25
|
+
marginRight: "8px",
|
|
26
|
+
borderRadius: "4px",
|
|
27
|
+
padding: "4px",
|
|
28
|
+
border: "2px solid",
|
|
29
|
+
borderColor: theme.colors?.primary as CSS.Property.Color,
|
|
30
|
+
flexShrink: 0,
|
|
31
|
+
}}
|
|
32
|
+
/>
|
|
40
33
|
<TextWithTooltip
|
|
41
34
|
text={text}
|
|
42
35
|
as="p"
|
|
@@ -110,7 +110,6 @@ function ListItem<F extends TabField, S extends AnyObjectSchema>({
|
|
|
110
110
|
theme={theme}
|
|
111
111
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/strict-boolean-expressions, @typescript-eslint/prefer-nullish-coalescing
|
|
112
112
|
text={config?.label || key}
|
|
113
|
-
type={widget.CUSTOM_NAME ?? widget.TYPE_NAME}
|
|
114
113
|
sliceFieldName={
|
|
115
114
|
renderFieldAccessor && renderFieldAccessor(key)
|
|
116
115
|
}
|
|
@@ -13,8 +13,10 @@ import {
|
|
|
13
13
|
Text,
|
|
14
14
|
} from "theme-ui";
|
|
15
15
|
|
|
16
|
-
import { checkAuthStatus, getState,
|
|
16
|
+
import { checkAuthStatus, getState, logout } from "@/apiClient";
|
|
17
17
|
import { getActiveEnvironment } from "@/features/environments/actions/getActiveEnvironment";
|
|
18
|
+
import { invalidateActiveEnvironmentData } from "@/features/environments/useActiveEnvironment";
|
|
19
|
+
import { invalidateEnvironmentsData } from "@/features/environments/useEnvironments";
|
|
18
20
|
import { useAutoSync } from "@/features/sync/AutoSyncProvider";
|
|
19
21
|
import { getUnSyncedChanges } from "@/features/sync/getUnSyncChanges";
|
|
20
22
|
import SliceMachineModal from "@/legacy/components/SliceMachineModal";
|
|
@@ -64,7 +66,7 @@ const LoginModal: React.FunctionComponent = () => {
|
|
|
64
66
|
|
|
65
67
|
try {
|
|
66
68
|
startLoadingLogin();
|
|
67
|
-
await
|
|
69
|
+
await logout();
|
|
68
70
|
window.open(loginRedirectUrl, "_blank");
|
|
69
71
|
await startPolling<CheckAuthStatusResponse, ValidAuthStatus>(
|
|
70
72
|
checkAuthStatus,
|
|
@@ -76,6 +78,10 @@ const LoginModal: React.FunctionComponent = () => {
|
|
|
76
78
|
60,
|
|
77
79
|
);
|
|
78
80
|
|
|
81
|
+
// refresh queries to update the UI
|
|
82
|
+
invalidateEnvironmentsData();
|
|
83
|
+
invalidateActiveEnvironmentData();
|
|
84
|
+
|
|
79
85
|
toast.success("Logged in");
|
|
80
86
|
stopLoadingLogin();
|
|
81
87
|
closeModals();
|
package/src/legacy/components/Navigation/SideNavEnvironmentSelector/SideNavEnvironmentSelector.tsx
CHANGED
|
@@ -18,6 +18,7 @@ import type { Environment } from "@slicemachine/manager/client";
|
|
|
18
18
|
import { clsx } from "clsx";
|
|
19
19
|
import type { FC, ReactNode } from "react";
|
|
20
20
|
|
|
21
|
+
import { LogoutButton } from "@/features/auth/LogoutButton";
|
|
21
22
|
import { LoginIcon } from "@/icons/LoginIcon";
|
|
22
23
|
import { LogoIcon } from "@/icons/LogoIcon";
|
|
23
24
|
|
|
@@ -138,6 +139,8 @@ export const SideNavEnvironmentSelector: FC<SideNavEnvironmentSelectorProps> = (
|
|
|
138
139
|
}
|
|
139
140
|
/>
|
|
140
141
|
) : undefined}
|
|
142
|
+
|
|
143
|
+
{variant === "default" && <LogoutButton />}
|
|
141
144
|
</Box>
|
|
142
145
|
</>
|
|
143
146
|
)}
|
|
@@ -60,8 +60,6 @@ const EditModal = ({ close, data, fields, onSave, zoneType }) => {
|
|
|
60
60
|
FormFields,
|
|
61
61
|
Form: CustomForm,
|
|
62
62
|
schema: widgetSchema,
|
|
63
|
-
CUSTOM_NAME: widgetCustomName,
|
|
64
|
-
TYPE_NAME: widgetTypeName,
|
|
65
63
|
} = maybeWidget;
|
|
66
64
|
|
|
67
65
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
@@ -165,7 +163,15 @@ const EditModal = ({ close, data, fields, onSave, zoneType }) => {
|
|
|
165
163
|
>
|
|
166
164
|
{(props) => {
|
|
167
165
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-assignment
|
|
168
|
-
const {
|
|
166
|
+
const {
|
|
167
|
+
values: {
|
|
168
|
+
id,
|
|
169
|
+
config: { label },
|
|
170
|
+
},
|
|
171
|
+
isValid,
|
|
172
|
+
isSubmitting,
|
|
173
|
+
initialValues,
|
|
174
|
+
} = props;
|
|
169
175
|
|
|
170
176
|
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
171
177
|
const fieldModelTabContent = CustomForm ? (
|
|
@@ -220,7 +226,7 @@ const EditModal = ({ close, data, fields, onSave, zoneType }) => {
|
|
|
220
226
|
<ItemHeader
|
|
221
227
|
theme={theme}
|
|
222
228
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/strict-boolean-expressions
|
|
223
|
-
|
|
229
|
+
text={label || id}
|
|
224
230
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
225
231
|
WidgetIcon={WidgetIcon}
|
|
226
232
|
/>
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { MdOutlineCreateNewFolder } from "react-icons/md";
|
|
2
2
|
import * as yup from "yup";
|
|
3
3
|
|
|
4
|
-
import { CustomFieldType } from "@/domain/fields";
|
|
5
4
|
import { TabField } from "@/legacy/lib/models/common/CustomType";
|
|
6
5
|
import {
|
|
7
6
|
type GroupSM,
|
|
@@ -34,7 +33,7 @@ type CreateGroupWidgetArgsBase<T extends TabField> = {
|
|
|
34
33
|
schemaTypeRegex: RegExp;
|
|
35
34
|
customListItem: (props: GroupListItemProps<T>) => JSX.Element;
|
|
36
35
|
hintItemName: string;
|
|
37
|
-
customName?:
|
|
36
|
+
customName?: string;
|
|
38
37
|
};
|
|
39
38
|
type CreateTopGroupWidgetArgs = CreateGroupWidgetArgsBase<GroupSM>;
|
|
40
39
|
type CreateNestedGroupWidgetArgs = CreateGroupWidgetArgsBase<NestedGroupSM> & {
|
|
@@ -2,7 +2,6 @@ import { FieldType } from "@prismicio/types-internal/lib/customtypes";
|
|
|
2
2
|
import { IconType } from "react-icons";
|
|
3
3
|
import { AnyObjectSchema } from "yup";
|
|
4
4
|
|
|
5
|
-
import { CustomFieldType } from "@/domain/fields";
|
|
6
5
|
import { TabField } from "@/legacy/lib/models/common/CustomType";
|
|
7
6
|
import { GroupSM, NestedGroupSM } from "@/legacy/lib/models/common/Group";
|
|
8
7
|
import { LocalOnlyCustomType } from "@/legacy/lib/models/common/ModelData";
|
|
@@ -16,7 +15,7 @@ interface WidgetBase<F extends TabField, S extends AnyObjectSchema> {
|
|
|
16
15
|
schema: S;
|
|
17
16
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
18
17
|
FormFields: {};
|
|
19
|
-
CUSTOM_NAME?:
|
|
18
|
+
CUSTOM_NAME?: string;
|
|
20
19
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
20
|
CustomListItem?: (props: any) => React.ReactElement;
|
|
22
21
|
// eslint-disable-next-line @typescript-eslint/ban-types, @typescript-eslint/no-explicit-any
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
normalizeFrontendCustomTypes,
|
|
15
15
|
} from "@/legacy/lib/models/common/normalizers/customType";
|
|
16
16
|
import { filterSliceFromCustomType } from "@/legacy/lib/utils/shared/customTypes";
|
|
17
|
+
import { logout } from "@/modules/auth";
|
|
17
18
|
import { refreshStateCreator } from "@/modules/environment";
|
|
18
19
|
import { SliceMachineStoreType } from "@/redux/type";
|
|
19
20
|
|
|
@@ -49,7 +50,8 @@ type CustomTypesActions =
|
|
|
49
50
|
| ActionType<typeof customTypeRenameSuccess>
|
|
50
51
|
| ActionType<typeof customTypeSaveSuccess>
|
|
51
52
|
| ActionType<typeof customTypeDeleteSuccess>
|
|
52
|
-
| ActionType<typeof sliceDeleteSuccess
|
|
53
|
+
| ActionType<typeof sliceDeleteSuccess>
|
|
54
|
+
| ActionType<typeof logout>;
|
|
53
55
|
|
|
54
56
|
// Selectors
|
|
55
57
|
export const selectAllCustomTypes = (
|
|
@@ -188,6 +190,15 @@ export const availableCustomTypesReducer: Reducer<
|
|
|
188
190
|
return customTypesUpdated;
|
|
189
191
|
}
|
|
190
192
|
|
|
193
|
+
case getType(logout): {
|
|
194
|
+
return Object.fromEntries(
|
|
195
|
+
Object.entries(state).flatMap(([customTypeId, customType]) => {
|
|
196
|
+
if (!hasLocal(customType)) return [];
|
|
197
|
+
return [[customTypeId, { local: customType.local }]];
|
|
198
|
+
}),
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
|
|
191
202
|
default:
|
|
192
203
|
return state;
|
|
193
204
|
}
|
|
@@ -10,6 +10,7 @@ import { LibraryUI } from "@/legacy/lib/models/common/LibraryUI";
|
|
|
10
10
|
import { LocalOrRemoteSlice } from "@/legacy/lib/models/common/ModelData";
|
|
11
11
|
import { normalizeFrontendSlices } from "@/legacy/lib/models/common/normalizers/slices";
|
|
12
12
|
import { SliceSM } from "@/legacy/lib/models/common/Slice";
|
|
13
|
+
import { logout } from "@/modules/auth";
|
|
13
14
|
import { refreshStateCreator } from "@/modules/environment";
|
|
14
15
|
import { SliceMachineStoreType } from "@/redux/type";
|
|
15
16
|
|
|
@@ -49,7 +50,8 @@ type SlicesActions =
|
|
|
49
50
|
| ActionType<typeof sliceDeleteSuccess>
|
|
50
51
|
| ActionType<typeof sliceUpdateSuccess>
|
|
51
52
|
| ActionType<typeof sliceGenerateCustomScreenshotSuccess>
|
|
52
|
-
| ActionType<typeof sliceUpdateMockSuccess
|
|
53
|
+
| ActionType<typeof sliceUpdateMockSuccess>
|
|
54
|
+
| ActionType<typeof logout>;
|
|
53
55
|
|
|
54
56
|
// Selectors
|
|
55
57
|
export const getLibraries = (
|
|
@@ -193,6 +195,13 @@ export const slicesReducer: Reducer<SlicesStoreType | null, SlicesActions> = (
|
|
|
193
195
|
};
|
|
194
196
|
}
|
|
195
197
|
|
|
198
|
+
case getType(logout): {
|
|
199
|
+
return {
|
|
200
|
+
...state,
|
|
201
|
+
remoteSlices: [],
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
|
|
196
205
|
default:
|
|
197
206
|
return state;
|
|
198
207
|
}
|
|
@@ -10,6 +10,7 @@ import { CustomTypes } from "@/legacy/lib/models/common/CustomType";
|
|
|
10
10
|
import { LibraryUI } from "@/legacy/lib/models/common/LibraryUI";
|
|
11
11
|
import { SliceSM } from "@/legacy/lib/models/common/Slice";
|
|
12
12
|
import ServerState from "@/legacy/lib/models/server/ServerState";
|
|
13
|
+
import { logout as logoutAction } from "@/modules/auth";
|
|
13
14
|
|
|
14
15
|
import {
|
|
15
16
|
customTypeCreateSuccess,
|
|
@@ -148,12 +149,13 @@ const useSliceMachineActions = () => {
|
|
|
148
149
|
);
|
|
149
150
|
const updateSliceMockSuccess = (args: SaveSliceMockRequest) =>
|
|
150
151
|
dispatch(sliceUpdateMockSuccess(args));
|
|
151
|
-
|
|
152
152
|
/**
|
|
153
153
|
* Changes module
|
|
154
154
|
*/
|
|
155
155
|
const pushChangesSuccess = () => dispatch(changesPushSuccess());
|
|
156
156
|
|
|
157
|
+
const logout = () => dispatch(logoutAction());
|
|
158
|
+
|
|
157
159
|
return {
|
|
158
160
|
refreshState,
|
|
159
161
|
openScreenshotsModal,
|
|
@@ -175,6 +177,7 @@ const useSliceMachineActions = () => {
|
|
|
175
177
|
pushChangesSuccess,
|
|
176
178
|
createCustomTypeSuccess,
|
|
177
179
|
updateSliceMockSuccess,
|
|
180
|
+
logout,
|
|
178
181
|
};
|
|
179
182
|
};
|
|
180
183
|
|
|
@@ -2,6 +2,7 @@ import { Reducer } from "redux";
|
|
|
2
2
|
import { ActionType, createAction, getType } from "typesafe-actions";
|
|
3
3
|
|
|
4
4
|
import ErrorWithStatus from "@/legacy/lib/models/common/ErrorWithStatus";
|
|
5
|
+
import { logout } from "@/modules/auth";
|
|
5
6
|
import { AuthStatus, UserContextStoreType } from "@/modules/userContext/types";
|
|
6
7
|
import { SliceMachineStoreType } from "@/redux/type";
|
|
7
8
|
|
|
@@ -34,6 +35,7 @@ type userContextActions = ActionType<
|
|
|
34
35
|
| typeof hasSeenChangesToolTipCreator
|
|
35
36
|
| typeof refreshStateCreator
|
|
36
37
|
| typeof changesPushSuccess
|
|
38
|
+
| typeof logout
|
|
37
39
|
>;
|
|
38
40
|
|
|
39
41
|
// Selectors
|
|
@@ -79,6 +81,12 @@ export const userContextReducer: Reducer<
|
|
|
79
81
|
lastSyncChange: Date.now(),
|
|
80
82
|
};
|
|
81
83
|
}
|
|
84
|
+
case getType(logout): {
|
|
85
|
+
return {
|
|
86
|
+
...initialState,
|
|
87
|
+
authStatus: AuthStatus.UNAUTHORIZED,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
82
90
|
|
|
83
91
|
default:
|
|
84
92
|
return state;
|