slice-machine-ui 1.11.1-dev-slices-templates-feature.3 → 1.11.1-dev-next-release.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/ModalFormCard/index.tsx +93 -102
- package/lib/builders/CustomTypeBuilder/SliceZone/UpdateSliceZoneModal.tsx +3 -2
- package/lib/builders/CustomTypeBuilder/SliceZone/UpdateSliceZoneModalList.tsx +6 -36
- package/lib/builders/CustomTypeBuilder/SliceZone/index.tsx +12 -99
- package/lib/builders/CustomTypeBuilder/TabZone/index.tsx +39 -50
- package/lib/builders/common/Zone/components/EmptyState/index.tsx +14 -13
- package/lib/builders/common/Zone/index.jsx +33 -22
- package/out/404.html +1 -1
- package/out/[lib]/[sliceName]/[variation]/screenshot.html +1 -1
- package/out/[lib]/[sliceName]/[variation]/simulator.html +1 -1
- package/out/[lib]/[sliceName]/[variation].html +1 -1
- package/out/_next/static/chunks/119-626b7b48e4535694.js +1 -0
- package/out/_next/static/chunks/18539003-b0b0df3d19f7d641.js +101 -0
- package/out/_next/static/chunks/377-c283ea91a489e394.js +1 -0
- package/out/_next/static/chunks/{482-5ae2d1fd2572cb1f.js → 482-ad5ef8eecedd8b52.js} +1 -1
- package/out/_next/static/chunks/{573-c4f805b20b6710f3.js → 573-aaae870d20e5f86c.js} +1 -1
- package/out/_next/static/chunks/677-d8555c165c261511.js +1 -0
- package/out/_next/static/chunks/{791-091202c1718b4ac3.js → 740-d0642219804fa9f0.js} +2 -2
- package/out/_next/static/chunks/799-4787c871f6119407.js +1 -0
- package/out/_next/static/chunks/pages/[lib]/[sliceName]/[variation]/{simulator-e51d1161076d4797.js → simulator-2c6033d99c3672e0.js} +1 -1
- package/out/_next/static/chunks/pages/[lib]/[sliceName]/{[variation]-4b4fed1e884838ad.js → [variation]-bd1822e54ac8836c.js} +1 -1
- package/out/_next/static/chunks/pages/{_app-ad2ca67a0f9eb7a1.js → _app-1025224bb77de20a.js} +98 -98
- package/out/_next/static/chunks/pages/{changelog-c08cc37b54d73a60.js → changelog-dda7774c702c6b47.js} +1 -1
- package/out/_next/static/chunks/pages/{changes-3b7c6b9b312b5e2f.js → changes-26dab4f4657a54e4.js} +1 -1
- package/out/_next/static/chunks/pages/custom-types/{[customTypeId]-207b0c837912e5a9.js → [customTypeId]-a69df1ad7fd8b927.js} +1 -1
- package/out/_next/static/chunks/pages/page-types/{[pageTypeId]-a6a8ebd9f4b3b608.js → [pageTypeId]-5e4e26de800fccff.js} +1 -1
- package/out/_next/static/chunks/pages/slices-d1c96629e458440c.js +1 -0
- package/out/_next/static/css/{a978ac70ea31c6d7.css → 6639e1548a7d3442.css} +1 -1
- package/out/_next/static/css/{bbe0f7491bdca3fc.css → 6c430d5aaa4ef12a.css} +1 -1
- package/out/_next/static/css/74653a9f89a68929.css +1 -0
- package/out/_next/static/css/{f7381722c36382c6.css → d4b59834999106a5.css} +1 -1
- package/out/_next/static/yIYfb0XzER_WZfVN-JElL/_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/page-types/[pageTypeId].html +1 -1
- package/out/slices.html +1 -1
- package/package.json +7 -7
- package/src/components/List/List.css.ts +2 -0
- package/src/components/List/List.tsx +7 -3
- package/src/features/customTypes/customTypesBuilder/SliceZoneBlankSlate.tsx +5 -17
- package/src/features/customTypes/customTypesMessages.ts +2 -2
- package/test/pages/custom-types.test.tsx +20 -38
- package/lib/builders/CustomTypeBuilder/SliceZone/SlicesTemplatesModal.tsx +0 -88
- package/lib/builders/CustomTypeBuilder/SliceZone/sliceTemplatesComingSoon.ts +0 -122
- package/out/_next/static/chunks/18539003-b49b17dc02a89c7b.js +0 -101
- package/out/_next/static/chunks/377-04a57b21fc2cae35.js +0 -1
- package/out/_next/static/chunks/777-2489ebe4bf5d384c.js +0 -1
- package/out/_next/static/chunks/799-48a1855b96a3623f.js +0 -1
- package/out/_next/static/chunks/962-6beea758652e94f7.js +0 -1
- package/out/_next/static/chunks/pages/slices-24d2714462334469.js +0 -1
- package/out/_next/static/css/de841cf04740a2ad.css +0 -1
- package/out/_next/static/dK1SmUj7YkNEkbU_Prnmf/_buildManifest.js +0 -1
- package/out/alternateGrid.png +0 -0
- package/out/customerLogos.png +0 -0
- package/out/hero.png +0 -0
- package/out/videoHighlight.png +0 -0
- package/public/alternateGrid.png +0 -0
- package/public/customerLogos.png +0 -0
- package/public/hero.png +0 -0
- package/public/videoHighlight.png +0 -0
- package/src/features/slicesTemplates/actions/createSlicesTemplates.ts +0 -41
- package/src/features/slicesTemplates/useSlicesTemplates.ts +0 -37
- /package/out/_next/static/{dK1SmUj7YkNEkbU_Prnmf → yIYfb0XzER_WZfVN-JElL}/_ssgManifest.js +0 -0
|
@@ -6,9 +6,8 @@ import {
|
|
|
6
6
|
FormikErrors,
|
|
7
7
|
FormikTouched,
|
|
8
8
|
FormikValues,
|
|
9
|
-
FormikProps,
|
|
10
9
|
} from "formik";
|
|
11
|
-
import { SetStateAction } from "react";
|
|
10
|
+
import { ReactNode, SetStateAction } from "react";
|
|
12
11
|
import { Flex, Heading, Close, Button as ThemeButton } from "theme-ui";
|
|
13
12
|
|
|
14
13
|
import { Button } from "@components/Button";
|
|
@@ -45,9 +44,7 @@ type ModalCardProps<T extends FormikValues> = {
|
|
|
45
44
|
omitFooter?: boolean;
|
|
46
45
|
isLoading?: boolean;
|
|
47
46
|
dataCy?: string;
|
|
48
|
-
actionMessage?:
|
|
49
|
-
| ((props: FormikProps<T>) => React.ReactNode)
|
|
50
|
-
| React.ReactNode;
|
|
47
|
+
actionMessage?: ReactNode;
|
|
51
48
|
};
|
|
52
49
|
|
|
53
50
|
function ModalCard<Values extends FormikValues>({
|
|
@@ -91,108 +88,102 @@ function ModalCard<Values extends FormikValues>({
|
|
|
91
88
|
onSubmit(values);
|
|
92
89
|
}}
|
|
93
90
|
>
|
|
94
|
-
{(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
91
|
+
{({
|
|
92
|
+
isValid,
|
|
93
|
+
isSubmitting,
|
|
94
|
+
values,
|
|
95
|
+
errors,
|
|
96
|
+
touched,
|
|
97
|
+
setFieldValue,
|
|
98
|
+
setValues,
|
|
99
|
+
}) => (
|
|
100
|
+
<Form
|
|
101
|
+
id={formId}
|
|
102
|
+
{...(dataCy != null ? { "data-cy": dataCy } : null)}
|
|
103
|
+
>
|
|
104
|
+
<Card
|
|
105
|
+
borderFooter
|
|
106
|
+
footerSx={{
|
|
107
|
+
p: 3,
|
|
108
|
+
position: "sticky",
|
|
109
|
+
bottom: 0,
|
|
110
|
+
background: "gray",
|
|
111
|
+
}}
|
|
112
|
+
bodySx={{ px: 4, py: 4 }}
|
|
113
|
+
sx={{ border: "none" }}
|
|
114
|
+
{...cardProps}
|
|
115
|
+
Header={({ radius }: { radius: string | number }) => (
|
|
116
|
+
<Flex
|
|
117
|
+
sx={{
|
|
118
|
+
position: "sticky",
|
|
119
|
+
top: 0,
|
|
120
|
+
zIndex: 1,
|
|
121
|
+
p: "16px",
|
|
122
|
+
pl: 4,
|
|
123
|
+
bg: "headSection",
|
|
124
|
+
alignItems: "center",
|
|
125
|
+
justifyContent: "space-between",
|
|
126
|
+
borderTopLeftRadius: radius,
|
|
127
|
+
borderTopRightRadius: radius,
|
|
128
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
129
|
+
borderBottom: (t) => `1px solid ${t.colors?.borders}`,
|
|
130
|
+
}}
|
|
131
|
+
>
|
|
132
|
+
<Heading sx={{ fontSize: "20px" }}>{title}</Heading>
|
|
133
|
+
<Close type="button" onClick={close} />
|
|
134
|
+
</Flex>
|
|
135
|
+
)}
|
|
136
|
+
Footer={
|
|
137
|
+
!omitFooter ? (
|
|
122
138
|
<Flex
|
|
123
139
|
sx={{
|
|
124
|
-
|
|
125
|
-
top: 0,
|
|
126
|
-
zIndex: 1,
|
|
127
|
-
p: "16px",
|
|
128
|
-
pl: 4,
|
|
129
|
-
bg: "headSection",
|
|
130
|
-
alignItems: "center",
|
|
131
|
-
justifyContent: "space-between",
|
|
132
|
-
borderTopLeftRadius: radius,
|
|
133
|
-
borderTopRightRadius: radius,
|
|
134
|
-
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
135
|
-
borderBottom: (t) => `1px solid ${t.colors?.borders}`,
|
|
140
|
+
alignItems: "space-between",
|
|
136
141
|
}}
|
|
137
142
|
>
|
|
138
|
-
<
|
|
139
|
-
|
|
140
|
-
</Flex>
|
|
141
|
-
)}
|
|
142
|
-
Footer={
|
|
143
|
-
!omitFooter ? (
|
|
144
|
-
<Flex
|
|
145
|
-
sx={{
|
|
146
|
-
alignItems: "space-between",
|
|
147
|
-
}}
|
|
148
|
-
>
|
|
149
|
-
<Flex sx={{ fontSize: "14px", alignItems: "center" }}>
|
|
150
|
-
{typeof actionMessage === "function"
|
|
151
|
-
? actionMessage(formikProps)
|
|
152
|
-
: actionMessage}
|
|
153
|
-
</Flex>
|
|
154
|
-
<Flex sx={{ ml: "auto" }}>
|
|
155
|
-
<ThemeButton
|
|
156
|
-
mr={2}
|
|
157
|
-
type="button"
|
|
158
|
-
onClick={close}
|
|
159
|
-
variant="secondary"
|
|
160
|
-
disabled={isSubmitting || isLoading}
|
|
161
|
-
>
|
|
162
|
-
Cancel
|
|
163
|
-
</ThemeButton>
|
|
164
|
-
<Button
|
|
165
|
-
label={buttonLabel}
|
|
166
|
-
form={formId}
|
|
167
|
-
type="submit"
|
|
168
|
-
disabled={!isValid || isSubmitting || isLoading}
|
|
169
|
-
isLoading={isSubmitting || isLoading}
|
|
170
|
-
sx={{
|
|
171
|
-
fontWeight: "400",
|
|
172
|
-
paddingBlock: "8px",
|
|
173
|
-
paddingInline: "16px",
|
|
174
|
-
fontSize: "14px",
|
|
175
|
-
borderRadius: "4px",
|
|
176
|
-
}}
|
|
177
|
-
/>
|
|
178
|
-
</Flex>
|
|
143
|
+
<Flex sx={{ fontSize: "14px", alignItems: "center" }}>
|
|
144
|
+
{actionMessage}
|
|
179
145
|
</Flex>
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
146
|
+
<Flex sx={{ ml: "auto" }}>
|
|
147
|
+
<ThemeButton
|
|
148
|
+
mr={2}
|
|
149
|
+
type="button"
|
|
150
|
+
onClick={close}
|
|
151
|
+
variant="secondary"
|
|
152
|
+
disabled={isSubmitting || isLoading}
|
|
153
|
+
>
|
|
154
|
+
Cancel
|
|
155
|
+
</ThemeButton>
|
|
156
|
+
<Button
|
|
157
|
+
label={buttonLabel}
|
|
158
|
+
form={formId}
|
|
159
|
+
type="submit"
|
|
160
|
+
disabled={!isValid || isSubmitting || isLoading}
|
|
161
|
+
isLoading={isSubmitting || isLoading}
|
|
162
|
+
sx={{
|
|
163
|
+
fontWeight: "400",
|
|
164
|
+
paddingBlock: "8px",
|
|
165
|
+
paddingInline: "16px",
|
|
166
|
+
fontSize: "14px",
|
|
167
|
+
borderRadius: "4px",
|
|
168
|
+
}}
|
|
169
|
+
/>
|
|
170
|
+
</Flex>
|
|
171
|
+
</Flex>
|
|
172
|
+
) : null
|
|
173
|
+
}
|
|
174
|
+
>
|
|
175
|
+
{children({
|
|
176
|
+
isValid,
|
|
177
|
+
isSubmitting,
|
|
178
|
+
values,
|
|
179
|
+
errors,
|
|
180
|
+
touched,
|
|
181
|
+
setFieldValue,
|
|
182
|
+
setValues,
|
|
183
|
+
})}
|
|
184
|
+
</Card>
|
|
185
|
+
</Form>
|
|
186
|
+
)}
|
|
196
187
|
</Formik>
|
|
197
188
|
</SliceMachineModal>
|
|
198
189
|
);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { ComponentUI } from "@lib/models/common/ComponentUI";
|
|
2
1
|
import ModalFormCard from "../../../../components/ModalFormCard";
|
|
2
|
+
|
|
3
3
|
import UpdateSliceZoneModalList from "./UpdateSliceZoneModalList";
|
|
4
|
+
import { ComponentUI } from "@lib/models/common/ComponentUI";
|
|
4
5
|
|
|
5
6
|
interface UpdateSliceModalProps {
|
|
6
7
|
isOpen: boolean;
|
|
@@ -37,7 +38,7 @@ const UpdateSliceZoneModal: React.FC<UpdateSliceModalProps> = ({
|
|
|
37
38
|
sliceKeys: slicesInSliceZone.map((slice) => slice.model.id),
|
|
38
39
|
}}
|
|
39
40
|
content={{
|
|
40
|
-
title: "Update
|
|
41
|
+
title: "Update Slices",
|
|
41
42
|
}}
|
|
42
43
|
dataCy="update-slices-modal"
|
|
43
44
|
>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FieldArray } from "formik";
|
|
2
|
-
import { Checkbox, Box
|
|
2
|
+
import { Checkbox, Box } from "theme-ui";
|
|
3
3
|
|
|
4
4
|
import { SharedSlice } from "@lib/models/ui/Slice";
|
|
5
5
|
|
|
@@ -10,8 +10,7 @@ import { ComponentUI } from "@lib/models/common/ComponentUI";
|
|
|
10
10
|
const UpdateSliceZoneModalList: React.FC<{
|
|
11
11
|
availableSlices: ReadonlyArray<ComponentUI>;
|
|
12
12
|
values: SliceZoneFormValues;
|
|
13
|
-
|
|
14
|
-
}> = ({ availableSlices, values, placeholderSlices }) => (
|
|
13
|
+
}> = ({ availableSlices, values }) => (
|
|
15
14
|
<FieldArray
|
|
16
15
|
name="sliceKeys"
|
|
17
16
|
render={(arrayHelpers) => (
|
|
@@ -20,10 +19,6 @@ const UpdateSliceZoneModalList: React.FC<{
|
|
|
20
19
|
elems={availableSlices}
|
|
21
20
|
defineElementKey={(slice: ComponentUI) => slice.model.name}
|
|
22
21
|
renderElem={(slice: ComponentUI) => {
|
|
23
|
-
const isPlaceholderSlice = placeholderSlices?.find(
|
|
24
|
-
(s) => s.model.id === slice.model.id
|
|
25
|
-
);
|
|
26
|
-
|
|
27
22
|
return SharedSlice.render({
|
|
28
23
|
slice: slice,
|
|
29
24
|
Wrapper: ({ slice, children, sx }) => {
|
|
@@ -31,10 +26,6 @@ const UpdateSliceZoneModalList: React.FC<{
|
|
|
31
26
|
<Box
|
|
32
27
|
data-testid="slicezone-modal-item"
|
|
33
28
|
onClick={() => {
|
|
34
|
-
if (isPlaceholderSlice) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
29
|
const isInSliceZone = values.sliceKeys.includes(
|
|
39
30
|
slice.model.id
|
|
40
31
|
);
|
|
@@ -46,37 +37,16 @@ const UpdateSliceZoneModalList: React.FC<{
|
|
|
46
37
|
arrayHelpers.push(slice.model.id);
|
|
47
38
|
}}
|
|
48
39
|
key={`${slice.from}-${slice.model.name}`}
|
|
49
|
-
sx={
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
...sx,
|
|
54
|
-
}
|
|
55
|
-
: {
|
|
56
|
-
opacity: 0.5,
|
|
57
|
-
...sx,
|
|
58
|
-
}
|
|
59
|
-
}
|
|
40
|
+
sx={{
|
|
41
|
+
cursor: "pointer",
|
|
42
|
+
...sx,
|
|
43
|
+
}}
|
|
60
44
|
>
|
|
61
45
|
{children}
|
|
62
46
|
</Box>
|
|
63
47
|
);
|
|
64
48
|
},
|
|
65
49
|
StatusOrCustom: ({ slice }: { slice: ComponentUI }) => {
|
|
66
|
-
if (isPlaceholderSlice) {
|
|
67
|
-
return (
|
|
68
|
-
<Text
|
|
69
|
-
sx={{
|
|
70
|
-
fontSize: 12,
|
|
71
|
-
color: "purpleStrong",
|
|
72
|
-
fontWeight: "bold",
|
|
73
|
-
}}
|
|
74
|
-
>
|
|
75
|
-
Coming soon
|
|
76
|
-
</Text>
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
50
|
const isInSliceZone = values.sliceKeys.includes(slice.model.id);
|
|
81
51
|
|
|
82
52
|
return (
|
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Button,
|
|
3
|
-
Box,
|
|
4
|
-
Switch,
|
|
5
|
-
DropdownMenu,
|
|
6
|
-
DropdownMenuTrigger,
|
|
7
|
-
DropdownMenuContent,
|
|
8
|
-
DropdownMenuItem,
|
|
9
|
-
Icon,
|
|
10
|
-
} from "@prismicio/editor-ui";
|
|
1
|
+
import { Button, Box, Switch } from "@prismicio/editor-ui";
|
|
11
2
|
import { useEffect, useMemo, useState } from "react";
|
|
12
3
|
import { useSelector } from "react-redux";
|
|
13
4
|
import { BaseStyles } from "theme-ui";
|
|
@@ -24,22 +15,16 @@ import type { SlicesSM } from "@lib/models/common/Slices";
|
|
|
24
15
|
import { List, ListHeader } from "@src/components/List";
|
|
25
16
|
import { SliceZoneBlankSlate } from "@src/features/customTypes/customTypesBuilder/SliceZoneBlankSlate";
|
|
26
17
|
import { useModelStatus } from "@src/hooks/useModelStatus";
|
|
27
|
-
import { telemetry } from "@src/apiClient";
|
|
28
18
|
import {
|
|
29
19
|
getFrontendSlices,
|
|
30
20
|
getLibraries,
|
|
31
21
|
getRemoteSlices,
|
|
32
22
|
} from "@src/modules/slices";
|
|
33
23
|
import type { SliceMachineStoreType } from "@src/redux/type";
|
|
34
|
-
import { useSlicesTemplates } from "@src/features/slicesTemplates/useSlicesTemplates";
|
|
35
|
-
import { createSlicesTemplates } from "@src/features/slicesTemplates/actions/createSlicesTemplates";
|
|
36
24
|
|
|
37
25
|
import { DeleteSliceZoneModal } from "./DeleteSliceZoneModal";
|
|
38
26
|
import { SlicesList } from "./List";
|
|
39
27
|
import UpdateSliceZoneModal from "./UpdateSliceZoneModal";
|
|
40
|
-
import { SlicesTemplatesModal } from "./SlicesTemplatesModal";
|
|
41
|
-
import { getState } from "@src/apiClient";
|
|
42
|
-
import useSliceMachineActions from "@src/modules/useSliceMachineActions";
|
|
43
28
|
|
|
44
29
|
const mapAvailableAndSharedSlices = (
|
|
45
30
|
sliceZone: SlicesSM,
|
|
@@ -115,11 +100,7 @@ const SliceZone: React.FC<SliceZoneProps> = ({
|
|
|
115
100
|
sliceZone,
|
|
116
101
|
tabId,
|
|
117
102
|
}) => {
|
|
118
|
-
const
|
|
119
|
-
const [isSlicesTemplatesModalOpen, setIsSlicesTemplatesModalOpen] =
|
|
120
|
-
useState(false);
|
|
121
|
-
const [isUpdateSliceZoneModalOpen, setIsUpdateSliceZoneModalOpen] =
|
|
122
|
-
useState(false);
|
|
103
|
+
const [formIsOpen, setFormIsOpen] = useState(false);
|
|
123
104
|
const [isCreateSliceModalOpen, setIsCreateSliceModalOpen] = useState(false);
|
|
124
105
|
const { remoteSlices, libraries, slices } = useSelector(
|
|
125
106
|
(store: SliceMachineStoreType) => ({
|
|
@@ -128,7 +109,6 @@ const SliceZone: React.FC<SliceZoneProps> = ({
|
|
|
128
109
|
slices: getFrontendSlices(store),
|
|
129
110
|
})
|
|
130
111
|
);
|
|
131
|
-
const { createSliceSuccess } = useSliceMachineActions();
|
|
132
112
|
const localLibraries: readonly LibraryUI[] = libraries.filter(
|
|
133
113
|
(library) => library.isLocal
|
|
134
114
|
);
|
|
@@ -162,69 +142,33 @@ const SliceZone: React.FC<SliceZoneProps> = ({
|
|
|
162
142
|
.map((e) => (e.payload as NonSharedSliceInSliceZone).key);
|
|
163
143
|
|
|
164
144
|
const onAddNewSlice = () => {
|
|
165
|
-
|
|
145
|
+
setFormIsOpen(true);
|
|
166
146
|
};
|
|
167
147
|
|
|
168
148
|
const onCreateNewSlice = () => {
|
|
169
149
|
setIsCreateSliceModalOpen(true);
|
|
170
150
|
};
|
|
171
151
|
|
|
172
|
-
const openSlicesTemplatesModal = () => {
|
|
173
|
-
setIsSlicesTemplatesModalOpen(true);
|
|
174
|
-
|
|
175
|
-
void telemetry.track({
|
|
176
|
-
event: "custom-type:open-add-from-templates",
|
|
177
|
-
customTypeId: customType.id,
|
|
178
|
-
customTypeFormat: customType.format,
|
|
179
|
-
});
|
|
180
|
-
};
|
|
181
|
-
|
|
182
152
|
return (
|
|
183
153
|
<Box flexDirection="column">
|
|
184
154
|
<List>
|
|
185
155
|
<ListHeader
|
|
186
156
|
actions={
|
|
187
|
-
sliceZone
|
|
188
|
-
|
|
189
|
-
<
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
Add
|
|
193
|
-
</Button>
|
|
194
|
-
</DropdownMenuTrigger>
|
|
195
|
-
|
|
196
|
-
<DropdownMenuContent align="end">
|
|
197
|
-
<DropdownMenuItem
|
|
198
|
-
startIcon={<Icon name="add" />}
|
|
199
|
-
onSelect={onCreateNewSlice}
|
|
200
|
-
>
|
|
201
|
-
Blank slice
|
|
202
|
-
</DropdownMenuItem>
|
|
203
|
-
|
|
204
|
-
{availableSlicesTemplates.length > 0 ? (
|
|
205
|
-
<DropdownMenuItem
|
|
206
|
-
onSelect={() => {
|
|
207
|
-
openSlicesTemplatesModal();
|
|
208
|
-
}}
|
|
209
|
-
startIcon={<Icon name="contentCopy" />}
|
|
210
|
-
>
|
|
211
|
-
Slice template
|
|
212
|
-
</DropdownMenuItem>
|
|
213
|
-
) : undefined}
|
|
214
|
-
</DropdownMenuContent>
|
|
215
|
-
</DropdownMenu>
|
|
216
|
-
|
|
157
|
+
sliceZone ? (
|
|
158
|
+
<>
|
|
159
|
+
<Button onClick={onCreateNewSlice} startIcon="add">
|
|
160
|
+
New slice
|
|
161
|
+
</Button>
|
|
217
162
|
{availableSlices.length > 0 ? (
|
|
218
163
|
<Button
|
|
219
164
|
data-cy="update-slices"
|
|
220
165
|
onClick={onAddNewSlice}
|
|
221
166
|
startIcon="edit"
|
|
222
|
-
variant="secondary"
|
|
223
167
|
>
|
|
224
|
-
Update
|
|
168
|
+
Update Slices
|
|
225
169
|
</Button>
|
|
226
170
|
) : undefined}
|
|
227
|
-
|
|
171
|
+
</>
|
|
228
172
|
) : undefined
|
|
229
173
|
}
|
|
230
174
|
toggle={
|
|
@@ -260,14 +204,12 @@ const SliceZone: React.FC<SliceZoneProps> = ({
|
|
|
260
204
|
<SliceZoneBlankSlate
|
|
261
205
|
onAddNewSlice={onAddNewSlice}
|
|
262
206
|
onCreateNewSlice={onCreateNewSlice}
|
|
263
|
-
openSlicesTemplatesModal={openSlicesTemplatesModal}
|
|
264
207
|
projectHasAvailableSlices={availableSlices.length > 0}
|
|
265
|
-
isSlicesTemplatesSupported={availableSlicesTemplates.length > 0}
|
|
266
208
|
/>
|
|
267
209
|
)
|
|
268
210
|
) : undefined}
|
|
269
211
|
<UpdateSliceZoneModal
|
|
270
|
-
isOpen={
|
|
212
|
+
isOpen={formIsOpen}
|
|
271
213
|
formId={`tab-slicezone-form-${tabId}`}
|
|
272
214
|
availableSlices={availableSlices}
|
|
273
215
|
slicesInSliceZone={sharedSlicesInSliceZone}
|
|
@@ -275,36 +217,7 @@ const SliceZone: React.FC<SliceZoneProps> = ({
|
|
|
275
217
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
276
218
|
onSelectSharedSlices(sliceKeys, nonSharedSlicesKeysInSliceZone)
|
|
277
219
|
}
|
|
278
|
-
close={() =>
|
|
279
|
-
/>
|
|
280
|
-
<SlicesTemplatesModal
|
|
281
|
-
isOpen={isSlicesTemplatesModalOpen}
|
|
282
|
-
formId={`tab-slicezone-form-${tabId}`}
|
|
283
|
-
availableSlicesTemplates={availableSlicesTemplates}
|
|
284
|
-
onSubmit={({ sliceKeys }) =>
|
|
285
|
-
void createSlicesTemplates({
|
|
286
|
-
templateIDs: sliceKeys,
|
|
287
|
-
localLibrariesNames: localLibraries.map((library) => library.name),
|
|
288
|
-
onSuccess: async (slicesIds: string[]) => {
|
|
289
|
-
// TODO(DT-1453): Remove the need of the global getState
|
|
290
|
-
const serverState = await getState();
|
|
291
|
-
|
|
292
|
-
// Update Redux store
|
|
293
|
-
createSliceSuccess(serverState.libraries);
|
|
294
|
-
|
|
295
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
296
|
-
onSelectSharedSlices(
|
|
297
|
-
slicesIds.concat(
|
|
298
|
-
sharedSlicesInSliceZone.map((s) => s.model.id)
|
|
299
|
-
),
|
|
300
|
-
nonSharedSlicesKeysInSliceZone
|
|
301
|
-
);
|
|
302
|
-
|
|
303
|
-
setIsSlicesTemplatesModalOpen(false);
|
|
304
|
-
},
|
|
305
|
-
})
|
|
306
|
-
}
|
|
307
|
-
close={() => setIsSlicesTemplatesModalOpen(false)}
|
|
220
|
+
close={() => setFormIsOpen(false)}
|
|
308
221
|
/>
|
|
309
222
|
<DeleteSliceZoneModal
|
|
310
223
|
isDeleteSliceZoneModalOpen={isDeleteSliceZoneModalOpen}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Box
|
|
2
|
-
import { FC
|
|
1
|
+
import { Box } from "@prismicio/editor-ui";
|
|
2
|
+
import type { FC } from "react";
|
|
3
3
|
import type { DropResult } from "react-beautiful-dnd";
|
|
4
4
|
import { useSelector } from "react-redux";
|
|
5
5
|
import type { AnyObjectSchema } from "yup";
|
|
@@ -139,54 +139,43 @@ const TabZone: FC<TabZoneProps> = ({
|
|
|
139
139
|
|
|
140
140
|
return (
|
|
141
141
|
<Box backgroundColor="grey2" flexDirection="column" gap={8}>
|
|
142
|
-
<
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
180
|
-
tabId={tabId}
|
|
181
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
182
|
-
sliceZone={sliceZone}
|
|
183
|
-
onRemoveSharedSlice={onRemoveSharedSlice}
|
|
184
|
-
onCreateSliceZone={onCreateSliceZone}
|
|
185
|
-
onDeleteSliceZone={onDeleteSliceZone}
|
|
186
|
-
onSelectSharedSlices={onSelectSharedSlices}
|
|
187
|
-
/>
|
|
188
|
-
</Suspense>
|
|
189
|
-
</ErrorBoundary>
|
|
142
|
+
<Zone
|
|
143
|
+
zoneType="customType"
|
|
144
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
145
|
+
tabId={tabId}
|
|
146
|
+
title="Static Zone"
|
|
147
|
+
dataTip={""}
|
|
148
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
149
|
+
fields={fields}
|
|
150
|
+
// @ts-expect-error propsType and typescript are incompatible on this type, we can remove the error when migrating the Zone component
|
|
151
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
152
|
+
poolOfFieldsToCheck={poolOfFields}
|
|
153
|
+
showHints={true}
|
|
154
|
+
EditModal={EditModal}
|
|
155
|
+
widgetsArray={ctBuilderArray}
|
|
156
|
+
onDeleteItem={onDeleteItem}
|
|
157
|
+
onSave={onSave}
|
|
158
|
+
onSaveNewField={onSaveNewField}
|
|
159
|
+
onDragEnd={onDragEnd}
|
|
160
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
|
|
161
|
+
renderHintBase={({ item }) => `data${transformKeyAccessor(item.key)}`}
|
|
162
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-argument
|
|
163
|
+
renderFieldAccessor={(key) => `data${transformKeyAccessor(key)}`}
|
|
164
|
+
dataCy="ct-static-zone"
|
|
165
|
+
isRepeatableCustomType={customType.repeatable}
|
|
166
|
+
/>
|
|
167
|
+
|
|
168
|
+
<SliceZone
|
|
169
|
+
customType={customType}
|
|
170
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
171
|
+
tabId={tabId}
|
|
172
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
173
|
+
sliceZone={sliceZone}
|
|
174
|
+
onRemoveSharedSlice={onRemoveSharedSlice}
|
|
175
|
+
onCreateSliceZone={onCreateSliceZone}
|
|
176
|
+
onDeleteSliceZone={onDeleteSliceZone}
|
|
177
|
+
onSelectSharedSlices={onSelectSharedSlices}
|
|
178
|
+
/>
|
|
190
179
|
</Box>
|
|
191
180
|
);
|
|
192
181
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Box, Text, Heading } from "theme-ui";
|
|
2
|
-
import {
|
|
1
|
+
import { Box, Button, Text, Heading } from "theme-ui";
|
|
2
|
+
import { FaPlus } from "react-icons/fa";
|
|
3
3
|
|
|
4
4
|
const ZoneEmptyState = ({
|
|
5
5
|
onEnterSelectMode,
|
|
@@ -16,17 +16,18 @@ const ZoneEmptyState = ({
|
|
|
16
16
|
Add a field to your {zoneName} Zone
|
|
17
17
|
</Text>
|
|
18
18
|
</Box>
|
|
19
|
-
<
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
19
|
+
<Button
|
|
20
|
+
mt={3}
|
|
21
|
+
variant="buttons.darkSmall"
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
23
|
+
onClick={() => onEnterSelectMode()}
|
|
24
|
+
data-cy={`add-${zoneName}-field`}
|
|
25
|
+
>
|
|
26
|
+
<FaPlus
|
|
27
|
+
style={{ marginRight: "8px", position: "relative", top: "2px" }}
|
|
28
|
+
/>{" "}
|
|
29
|
+
Add a new field
|
|
30
|
+
</Button>
|
|
30
31
|
</Box>
|
|
31
32
|
);
|
|
32
33
|
|