slice-machine-ui 1.14.0 → 1.14.1-dev-upgrade-legacy.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/components/ChangesItems/ChangesItems.tsx +1 -1
- package/components/Forms/ConvertLegacySliceModal/ConvertLegacySliceModal.css.ts +97 -0
- package/components/Forms/ConvertLegacySliceModal/ConvertLegacySliceModal.tsx +260 -0
- package/components/Forms/ConvertLegacySliceModal/FormAsNewSlice.tsx +165 -0
- package/components/Forms/ConvertLegacySliceModal/FormAsNewVariation.tsx +263 -0
- package/components/Forms/ConvertLegacySliceModal/FormMergeWithIdentical.tsx +120 -0
- package/components/Forms/ConvertLegacySliceModal/index.tsx +1 -0
- package/components/Forms/ConvertLegacySliceModal/types.ts +47 -0
- package/lib/builders/CustomTypeBuilder/SliceZone/List.tsx +12 -4
- package/lib/builders/CustomTypeBuilder/SliceZone/UpdateSliceZoneModalList.tsx +1 -1
- package/lib/builders/CustomTypeBuilder/SliceZone/index.tsx +8 -0
- package/lib/models/ui/Slice/index.tsx +52 -26
- 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/HJothAZ-ufia3zK-uZgiR/_buildManifest.js +1 -0
- package/out/_next/static/chunks/4-910f159726a3f684.js +1 -0
- package/out/_next/static/chunks/400-c4f177099af55f63.js +1 -0
- package/out/_next/static/chunks/799-00944cdde5b22566.js +1 -0
- package/out/_next/static/chunks/80-dce703180b269337.js +1 -0
- package/out/_next/static/chunks/934-1d2b243f3faee287.js +1 -0
- package/out/_next/static/chunks/{740-d0642219804fa9f0.js → 969-bcfa23e8fd4773e7.js} +1 -1
- package/out/_next/static/chunks/970-d63bac52b8b2439a.js +1 -0
- package/out/_next/static/chunks/pages/[lib]/[sliceName]/[variation]-fc545d9beb1bb757.js +1 -0
- package/out/_next/static/chunks/pages/{_app-250ad97f7f362ab4.js → _app-cdcc9574e096e708.js} +8 -8
- package/out/_next/static/chunks/pages/changes-07beedca8a24be6f.js +1 -0
- package/out/_next/static/chunks/pages/custom-types/{[customTypeId]-f8e48a51edbb5e1c.js → [customTypeId]-67a1bd3229bc7b7c.js} +1 -1
- package/out/_next/static/chunks/pages/{custom-types-abb8c8c92880120e.js → custom-types-9284cf805b076b09.js} +1 -1
- package/out/_next/static/chunks/pages/{index-f382c8090bd21628.js → index-162379cd9d1baab9.js} +1 -1
- package/out/_next/static/chunks/pages/page-types/{[pageTypeId]-ddc8d057c3e251d1.js → [pageTypeId]-84d90c359c16cc7d.js} +1 -1
- package/out/_next/static/chunks/pages/slices-1f8e5627b061633b.js +1 -0
- package/out/_next/static/css/{2d1eda18406a9ff4.css → 4d6fac6cebf3eff3.css} +1 -1
- package/out/_next/static/css/dfac2b323a77a5d0.css +1 -0
- package/out/_next/static/css/e2c7f4cf38a226ef.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/page-types/[pageTypeId].html +1 -1
- package/out/slices.html +1 -1
- package/package.json +6 -6
- package/pages/slices.tsx +1 -1
- package/out/_next/static/98p2ftWwipTg4xas9uSc6/_buildManifest.js +0 -1
- package/out/_next/static/chunks/482-a4c1c3721ca38516.js +0 -1
- package/out/_next/static/chunks/573-aaae870d20e5f86c.js +0 -1
- package/out/_next/static/chunks/799-5ea3393033a9f617.js +0 -1
- package/out/_next/static/chunks/906-9224feb63b5e36f3.js +0 -1
- package/out/_next/static/chunks/97-f6188ebe22eb21da.js +0 -1
- package/out/_next/static/chunks/970-6fb969573ccdf018.js +0 -1
- package/out/_next/static/chunks/pages/[lib]/[sliceName]/[variation]-9fff494255e34c39.js +0 -1
- package/out/_next/static/chunks/pages/changes-6a039e823313b41c.js +0 -1
- package/out/_next/static/chunks/pages/slices-24d2714462334469.js +0 -1
- package/out/_next/static/css/6b6c11ed1fffd3e0.css +0 -1
- package/out/_next/static/css/e855bef88bb5345b.css +0 -1
- /package/out/_next/static/{98p2ftWwipTg4xas9uSc6 → HJothAZ-ufia3zK-uZgiR}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import Select from "react-select";
|
|
3
|
+
import { Field, Input, Label } from "theme-ui";
|
|
4
|
+
import { Formik } from "formik";
|
|
5
|
+
import {
|
|
6
|
+
Dialog,
|
|
7
|
+
DialogActions,
|
|
8
|
+
DialogContent,
|
|
9
|
+
DialogHeader,
|
|
10
|
+
ScrollArea,
|
|
11
|
+
Text,
|
|
12
|
+
tokens,
|
|
13
|
+
} from "@prismicio/editor-ui";
|
|
14
|
+
|
|
15
|
+
import { Variation } from "@models/common/Variation";
|
|
16
|
+
import { LibraryUI } from "@models/common/LibraryUI";
|
|
17
|
+
|
|
18
|
+
import * as styles from "./ConvertLegacySliceModal.css";
|
|
19
|
+
import { FormProps } from "./types";
|
|
20
|
+
|
|
21
|
+
type FormValues = {
|
|
22
|
+
libraryID: string;
|
|
23
|
+
sliceID: string;
|
|
24
|
+
variationID: string;
|
|
25
|
+
variationName: string;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const validateAsNewVariationValues = (
|
|
29
|
+
values: FormValues,
|
|
30
|
+
libraries: readonly LibraryUI[]
|
|
31
|
+
): Partial<Record<keyof FormValues, string>> => {
|
|
32
|
+
const errors: Partial<Record<keyof FormValues, string>> = {};
|
|
33
|
+
|
|
34
|
+
if (!values.libraryID) {
|
|
35
|
+
errors.libraryID = "Cannot be empty.";
|
|
36
|
+
}
|
|
37
|
+
const library = libraries.find(
|
|
38
|
+
(library) => library.path === values.libraryID
|
|
39
|
+
);
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
41
|
+
if (!errors.variationID && !library) {
|
|
42
|
+
errors.variationID = "Does not exists.";
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (!values.sliceID) {
|
|
46
|
+
errors.libraryID = "Cannot be empty.";
|
|
47
|
+
}
|
|
48
|
+
const slice = library?.components.find(
|
|
49
|
+
(component) => component.model.id === values.sliceID
|
|
50
|
+
);
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
52
|
+
if (!errors.sliceID && !slice) {
|
|
53
|
+
errors.sliceID = "Does not exists.";
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (!values.variationName) {
|
|
57
|
+
errors.libraryID = "Cannot be empty.";
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (!values.variationID) {
|
|
61
|
+
errors.libraryID = "Cannot be empty.";
|
|
62
|
+
} else {
|
|
63
|
+
const variationIDs =
|
|
64
|
+
slice?.model.variations.map((variation) => variation.id) ?? [];
|
|
65
|
+
|
|
66
|
+
if (variationIDs.includes(values.variationID)) {
|
|
67
|
+
errors.variationID = "Slice variation ID is already taken.";
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return errors;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export const FormAsNewVariation: React.FC<FormProps> = ({
|
|
75
|
+
isOpen,
|
|
76
|
+
close,
|
|
77
|
+
onSubmit,
|
|
78
|
+
isLoading,
|
|
79
|
+
slice,
|
|
80
|
+
sliceName,
|
|
81
|
+
libraries,
|
|
82
|
+
localSharedSlices,
|
|
83
|
+
}) => {
|
|
84
|
+
const [inferIDFromName, setInferIDFromName] = useState(true);
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<Dialog
|
|
88
|
+
open={isOpen}
|
|
89
|
+
onOpenChange={(open) => !open && close()}
|
|
90
|
+
size="small"
|
|
91
|
+
>
|
|
92
|
+
<DialogHeader title="Convert to new slice" />
|
|
93
|
+
<DialogContent>
|
|
94
|
+
<Formik
|
|
95
|
+
validateOnChange
|
|
96
|
+
initialValues={{
|
|
97
|
+
libraryID: localSharedSlices[0]?.from,
|
|
98
|
+
sliceID: localSharedSlices[0]?.model.id,
|
|
99
|
+
variationID: Variation.generateId(slice.key),
|
|
100
|
+
variationName: sliceName,
|
|
101
|
+
}}
|
|
102
|
+
validate={(values) => {
|
|
103
|
+
return validateAsNewVariationValues(values, libraries);
|
|
104
|
+
}}
|
|
105
|
+
onSubmit={(values) => {
|
|
106
|
+
onSubmit(values);
|
|
107
|
+
}}
|
|
108
|
+
>
|
|
109
|
+
{(formik) => {
|
|
110
|
+
return (
|
|
111
|
+
<form
|
|
112
|
+
id="convert-legacy-slice-modal-as-new-variation"
|
|
113
|
+
data-cy="convert-legacy-slice-modal-as-new-variation"
|
|
114
|
+
className={styles.layout.small}
|
|
115
|
+
>
|
|
116
|
+
<ScrollArea
|
|
117
|
+
style={{
|
|
118
|
+
height: "100%",
|
|
119
|
+
display: "flex",
|
|
120
|
+
gap: tokens.space[12],
|
|
121
|
+
paddingInline: tokens.space[24],
|
|
122
|
+
paddingBlock: tokens.space[16],
|
|
123
|
+
}}
|
|
124
|
+
>
|
|
125
|
+
<div className={styles.layout.small}>
|
|
126
|
+
<div>
|
|
127
|
+
<Label htmlFor="slice" sx={{ mb: 2 }}>
|
|
128
|
+
Target Slice
|
|
129
|
+
</Label>
|
|
130
|
+
<Select
|
|
131
|
+
name="slice"
|
|
132
|
+
options={localSharedSlices.map((slice) => ({
|
|
133
|
+
value: `${slice.from}::${slice.model.id}`,
|
|
134
|
+
label: `${slice.from} > ${slice.model.name} (${slice.model.id})`,
|
|
135
|
+
}))}
|
|
136
|
+
onChange={(option) => {
|
|
137
|
+
if (option) {
|
|
138
|
+
const [libraryID, sliceID] =
|
|
139
|
+
option.value.split("::");
|
|
140
|
+
void formik.setFieldValue("libraryID", libraryID);
|
|
141
|
+
void formik.setFieldValue("sliceID", sliceID);
|
|
142
|
+
}
|
|
143
|
+
}}
|
|
144
|
+
defaultValue={{
|
|
145
|
+
value: `${formik.values.libraryID}::${formik.values.sliceID}`,
|
|
146
|
+
label: `${formik.values.libraryID} > ${localSharedSlices[0]?.model.name} (${formik.values.sliceID})`,
|
|
147
|
+
}}
|
|
148
|
+
styles={{
|
|
149
|
+
option: (provided) => ({
|
|
150
|
+
...provided,
|
|
151
|
+
// Color of item text (Dark/Shade-01)
|
|
152
|
+
color: "#161618",
|
|
153
|
+
}),
|
|
154
|
+
}}
|
|
155
|
+
theme={(theme) => {
|
|
156
|
+
return {
|
|
157
|
+
...theme,
|
|
158
|
+
colors: {
|
|
159
|
+
...theme.colors,
|
|
160
|
+
// Background of selected item (Gray/Shade-05)
|
|
161
|
+
primary: "#E9E8EA",
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
}}
|
|
165
|
+
menuPortalTarget={document.body}
|
|
166
|
+
/>
|
|
167
|
+
</div>
|
|
168
|
+
<div>
|
|
169
|
+
<Label
|
|
170
|
+
htmlFor="variationName"
|
|
171
|
+
sx={{
|
|
172
|
+
mb: 2,
|
|
173
|
+
display: "inline-flex",
|
|
174
|
+
alignItems: "center",
|
|
175
|
+
gap: 2,
|
|
176
|
+
}}
|
|
177
|
+
>
|
|
178
|
+
Variation Name
|
|
179
|
+
{typeof formik.errors.variationName === "string" ? (
|
|
180
|
+
<Text variant="small" color="tomato10">
|
|
181
|
+
{formik.errors.variationName}
|
|
182
|
+
</Text>
|
|
183
|
+
) : null}
|
|
184
|
+
</Label>
|
|
185
|
+
<Field
|
|
186
|
+
autoComplete="off"
|
|
187
|
+
id="variationName"
|
|
188
|
+
name="variationName"
|
|
189
|
+
type="text"
|
|
190
|
+
placeholder={sliceName}
|
|
191
|
+
as={Input}
|
|
192
|
+
maxLength={30}
|
|
193
|
+
value={formik.values.variationName}
|
|
194
|
+
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
|
195
|
+
void formik.setFieldValue(
|
|
196
|
+
"variationName",
|
|
197
|
+
e.currentTarget.value
|
|
198
|
+
);
|
|
199
|
+
if (inferIDFromName) {
|
|
200
|
+
void formik.setFieldValue(
|
|
201
|
+
"variationID",
|
|
202
|
+
Variation.generateId(e.currentTarget.value)
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
}}
|
|
206
|
+
data-cy="slice-name-input"
|
|
207
|
+
/>
|
|
208
|
+
</div>
|
|
209
|
+
<div>
|
|
210
|
+
<Label
|
|
211
|
+
htmlFor="variationID"
|
|
212
|
+
sx={{
|
|
213
|
+
mb: 2,
|
|
214
|
+
display: "inline-flex",
|
|
215
|
+
alignItems: "center",
|
|
216
|
+
gap: 2,
|
|
217
|
+
}}
|
|
218
|
+
>
|
|
219
|
+
Variation ID
|
|
220
|
+
{typeof formik.errors.variationID === "string" ? (
|
|
221
|
+
<Text variant="small" color="tomato10">
|
|
222
|
+
{formik.errors.variationID}
|
|
223
|
+
</Text>
|
|
224
|
+
) : null}
|
|
225
|
+
</Label>
|
|
226
|
+
<Field
|
|
227
|
+
autoComplete="off"
|
|
228
|
+
id="variationID"
|
|
229
|
+
name="variationID"
|
|
230
|
+
type="text"
|
|
231
|
+
placeholder={Variation.generateId(slice.key)}
|
|
232
|
+
as={Input}
|
|
233
|
+
maxLength={30}
|
|
234
|
+
value={formik.values.variationID}
|
|
235
|
+
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
|
236
|
+
setInferIDFromName(false);
|
|
237
|
+
void formik.setFieldValue(
|
|
238
|
+
"variationID",
|
|
239
|
+
Variation.generateId(e.currentTarget.value)
|
|
240
|
+
);
|
|
241
|
+
}}
|
|
242
|
+
data-cy="slice-name-input"
|
|
243
|
+
/>
|
|
244
|
+
</div>
|
|
245
|
+
</div>
|
|
246
|
+
</ScrollArea>
|
|
247
|
+
<DialogActions
|
|
248
|
+
ok={{
|
|
249
|
+
text: "Convert",
|
|
250
|
+
onClick: () => void formik.submitForm(),
|
|
251
|
+
loading: isLoading,
|
|
252
|
+
disabled: !formik.isValid,
|
|
253
|
+
}}
|
|
254
|
+
cancel={{ text: "Cancel" }}
|
|
255
|
+
/>
|
|
256
|
+
</form>
|
|
257
|
+
);
|
|
258
|
+
}}
|
|
259
|
+
</Formik>
|
|
260
|
+
</DialogContent>
|
|
261
|
+
</Dialog>
|
|
262
|
+
);
|
|
263
|
+
};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import Select from "react-select";
|
|
2
|
+
import { Label } from "theme-ui";
|
|
3
|
+
import { Formik } from "formik";
|
|
4
|
+
import {
|
|
5
|
+
Dialog,
|
|
6
|
+
DialogActions,
|
|
7
|
+
DialogContent,
|
|
8
|
+
DialogHeader,
|
|
9
|
+
ScrollArea,
|
|
10
|
+
tokens,
|
|
11
|
+
} from "@prismicio/editor-ui";
|
|
12
|
+
|
|
13
|
+
import * as styles from "./ConvertLegacySliceModal.css";
|
|
14
|
+
import { FormProps } from "./types";
|
|
15
|
+
|
|
16
|
+
export const FormMergeWithIdentical: React.FC<FormProps> = ({
|
|
17
|
+
isOpen,
|
|
18
|
+
close,
|
|
19
|
+
onSubmit,
|
|
20
|
+
isLoading,
|
|
21
|
+
identicalSlices,
|
|
22
|
+
}) => {
|
|
23
|
+
return (
|
|
24
|
+
<Dialog
|
|
25
|
+
open={isOpen}
|
|
26
|
+
onOpenChange={(open) => !open && close()}
|
|
27
|
+
size="small"
|
|
28
|
+
>
|
|
29
|
+
<DialogHeader title="Convert to new slice" />
|
|
30
|
+
<DialogContent>
|
|
31
|
+
<Formik
|
|
32
|
+
validateOnChange
|
|
33
|
+
initialValues={{
|
|
34
|
+
path: identicalSlices[0]?.path ?? "",
|
|
35
|
+
}}
|
|
36
|
+
validate={(values) => {
|
|
37
|
+
if (!values.path) {
|
|
38
|
+
return { path: "Cannot be empty." };
|
|
39
|
+
}
|
|
40
|
+
}}
|
|
41
|
+
onSubmit={(values) => {
|
|
42
|
+
const [libraryID, sliceID, variationID] = values.path.split("::");
|
|
43
|
+
onSubmit({ libraryID, sliceID, variationID });
|
|
44
|
+
}}
|
|
45
|
+
>
|
|
46
|
+
{(formik) => {
|
|
47
|
+
return (
|
|
48
|
+
<form
|
|
49
|
+
id="convert-legacy-slice-modal-merge-with-identical"
|
|
50
|
+
data-cy="convert-legacy-slice-modal-merge-with-identical"
|
|
51
|
+
className={styles.layout.small}
|
|
52
|
+
>
|
|
53
|
+
<ScrollArea
|
|
54
|
+
style={{
|
|
55
|
+
height: "100%",
|
|
56
|
+
display: "flex",
|
|
57
|
+
gap: tokens.space[12],
|
|
58
|
+
paddingInline: tokens.space[24],
|
|
59
|
+
paddingBlock: tokens.space[16],
|
|
60
|
+
}}
|
|
61
|
+
>
|
|
62
|
+
<div className={styles.layout.small}>
|
|
63
|
+
<div>
|
|
64
|
+
<Label htmlFor="path" sx={{ mb: 2 }}>
|
|
65
|
+
Merge with
|
|
66
|
+
</Label>
|
|
67
|
+
<Select
|
|
68
|
+
name="path"
|
|
69
|
+
options={identicalSlices.map((v) => ({
|
|
70
|
+
value: v.path,
|
|
71
|
+
label: v.path.split("::").join(" > "),
|
|
72
|
+
}))}
|
|
73
|
+
onChange={(option) =>
|
|
74
|
+
option
|
|
75
|
+
? void formik.setFieldValue("path", option.value)
|
|
76
|
+
: null
|
|
77
|
+
}
|
|
78
|
+
defaultValue={{
|
|
79
|
+
value: formik.values.path,
|
|
80
|
+
label: formik.values.path.split("::").join(" > "),
|
|
81
|
+
}}
|
|
82
|
+
styles={{
|
|
83
|
+
option: (provided) => ({
|
|
84
|
+
...provided,
|
|
85
|
+
// Color of item text (Dark/Shade-01)
|
|
86
|
+
color: "#161618",
|
|
87
|
+
}),
|
|
88
|
+
}}
|
|
89
|
+
theme={(theme) => {
|
|
90
|
+
return {
|
|
91
|
+
...theme,
|
|
92
|
+
colors: {
|
|
93
|
+
...theme.colors,
|
|
94
|
+
// Background of selected item (Gray/Shade-05)
|
|
95
|
+
primary: "#E9E8EA",
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
}}
|
|
99
|
+
menuPortalTarget={document.body}
|
|
100
|
+
/>
|
|
101
|
+
</div>
|
|
102
|
+
</div>
|
|
103
|
+
</ScrollArea>
|
|
104
|
+
<DialogActions
|
|
105
|
+
ok={{
|
|
106
|
+
text: "Convert",
|
|
107
|
+
onClick: () => void formik.submitForm(),
|
|
108
|
+
loading: isLoading,
|
|
109
|
+
disabled: !formik.isValid,
|
|
110
|
+
}}
|
|
111
|
+
cancel={{ text: "Cancel" }}
|
|
112
|
+
/>
|
|
113
|
+
</form>
|
|
114
|
+
);
|
|
115
|
+
}}
|
|
116
|
+
</Formik>
|
|
117
|
+
</DialogContent>
|
|
118
|
+
</Dialog>
|
|
119
|
+
);
|
|
120
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ConvertLegacySliceModal } from "./ConvertLegacySliceModal";
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { CompositeSlice } from "@prismicio/types-internal/lib/customtypes";
|
|
2
|
+
|
|
3
|
+
import { LibraryUI } from "@models/common/LibraryUI";
|
|
4
|
+
import { ComponentUI } from "@models/common/ComponentUI";
|
|
5
|
+
import { SliceZoneSlice } from "@models/common/CustomType/sliceZone";
|
|
6
|
+
|
|
7
|
+
export type ConvertLegacySliceModalProps = {
|
|
8
|
+
slice: { key: string; value: CompositeSlice };
|
|
9
|
+
slices: readonly SliceZoneSlice[];
|
|
10
|
+
path: {
|
|
11
|
+
customTypeID: string;
|
|
12
|
+
tabID: string;
|
|
13
|
+
sliceZoneID: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type ConvertLegacySliceAndTrackArgs = {
|
|
18
|
+
libraryID: string;
|
|
19
|
+
sliceID: string;
|
|
20
|
+
variationID?: string;
|
|
21
|
+
variationName?: string;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const types = [
|
|
25
|
+
"as_new_slice",
|
|
26
|
+
"as_new_variation",
|
|
27
|
+
"merge_with_identical",
|
|
28
|
+
] as const;
|
|
29
|
+
export type Type = (typeof types)[number];
|
|
30
|
+
|
|
31
|
+
export type IdenticalSlice = {
|
|
32
|
+
libraryID: string;
|
|
33
|
+
sliceID: string;
|
|
34
|
+
variationID: string;
|
|
35
|
+
path: string;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type FormProps = {
|
|
39
|
+
isOpen: boolean;
|
|
40
|
+
close: () => void;
|
|
41
|
+
onSubmit: (args: ConvertLegacySliceAndTrackArgs) => void;
|
|
42
|
+
isLoading: boolean;
|
|
43
|
+
sliceName: string;
|
|
44
|
+
libraries: readonly LibraryUI[];
|
|
45
|
+
localSharedSlices: ComponentUI[];
|
|
46
|
+
identicalSlices: IdenticalSlice[];
|
|
47
|
+
} & Pick<ConvertLegacySliceModalProps, "path" | "slice">;
|
|
@@ -16,12 +16,18 @@ import { CUSTOM_TYPES_MESSAGES } from "@src/features/customTypes/customTypesMess
|
|
|
16
16
|
interface SlicesListProps {
|
|
17
17
|
format: CustomTypeFormat;
|
|
18
18
|
slices: ReadonlyArray<SliceZoneSlice>;
|
|
19
|
+
path: {
|
|
20
|
+
customTypeID: string;
|
|
21
|
+
tabID: string;
|
|
22
|
+
sliceZoneID: string;
|
|
23
|
+
};
|
|
19
24
|
onRemoveSharedSlice: (sliceId: string) => void;
|
|
20
25
|
}
|
|
21
26
|
|
|
22
27
|
export const SlicesList: React.FC<SlicesListProps> = ({
|
|
23
28
|
slices,
|
|
24
29
|
format,
|
|
30
|
+
path,
|
|
25
31
|
onRemoveSharedSlice,
|
|
26
32
|
}) => {
|
|
27
33
|
const hasLegacySlices = slices.some((slice) => slice.type !== "SharedSlice");
|
|
@@ -45,19 +51,21 @@ export const SlicesList: React.FC<SlicesListProps> = ({
|
|
|
45
51
|
<Grid
|
|
46
52
|
elems={slices}
|
|
47
53
|
defineElementKey={(slice: SliceZoneSlice) => {
|
|
48
|
-
if (slice.type
|
|
54
|
+
if (slice.type !== "SharedSlice") {
|
|
49
55
|
// NonsharedSlice
|
|
50
56
|
return (slice.payload as NonSharedSliceInSliceZone).key;
|
|
51
57
|
}
|
|
52
58
|
return (slice.payload as ComponentUI).model.name;
|
|
53
59
|
}}
|
|
54
60
|
renderElem={(slice: SliceZoneSlice) => {
|
|
55
|
-
if (slice.type
|
|
56
|
-
return NonSharedSlice.
|
|
61
|
+
if (slice.type !== "SharedSlice") {
|
|
62
|
+
return NonSharedSlice.Render({
|
|
57
63
|
slice: slice.payload as NonSharedSliceInSliceZone,
|
|
64
|
+
slices,
|
|
65
|
+
path,
|
|
58
66
|
});
|
|
59
67
|
}
|
|
60
|
-
return SharedSlice.
|
|
68
|
+
return SharedSlice.Render({
|
|
61
69
|
slice: slice.payload as ComponentUI,
|
|
62
70
|
StatusOrCustom: () => (
|
|
63
71
|
// Prevent the Grid to redirect to the slice builder page
|
|
@@ -161,6 +161,13 @@ const SliceZone: React.FC<SliceZoneProps> = ({
|
|
|
161
161
|
.filter((e) => e.type === "Slice")
|
|
162
162
|
.map((e) => (e.payload as NonSharedSliceInSliceZone).key);
|
|
163
163
|
|
|
164
|
+
const path = useMemo(() => {
|
|
165
|
+
return {
|
|
166
|
+
customTypeID: customType.id,
|
|
167
|
+
tabID: tabId,
|
|
168
|
+
sliceZoneID: sliceZone?.key as string,
|
|
169
|
+
};
|
|
170
|
+
}, [customType, tabId, sliceZone]);
|
|
164
171
|
const availableSlicesToAdd = availableSlices.filter(
|
|
165
172
|
(slice) =>
|
|
166
173
|
!sharedSlicesInSliceZone.some(
|
|
@@ -267,6 +274,7 @@ const SliceZone: React.FC<SliceZoneProps> = ({
|
|
|
267
274
|
<SlicesList
|
|
268
275
|
slices={slicesInSliceZone}
|
|
269
276
|
format={customType.format}
|
|
277
|
+
path={path}
|
|
270
278
|
onRemoveSharedSlice={onRemoveSharedSlice}
|
|
271
279
|
/>
|
|
272
280
|
</BaseStyles>
|
|
@@ -21,6 +21,12 @@ import { Button } from "@components/Button";
|
|
|
21
21
|
import { KebabMenuDropdown } from "@components/KebabMenuDropdown";
|
|
22
22
|
import ReactTooltip from "react-tooltip";
|
|
23
23
|
import style from "./LegacySliceTooltip.module.css";
|
|
24
|
+
import { ConvertLegacySliceModal } from "@components/Forms/ConvertLegacySliceModal";
|
|
25
|
+
import {
|
|
26
|
+
NonSharedSliceInSliceZone,
|
|
27
|
+
SliceZoneSlice,
|
|
28
|
+
} from "@lib/models/common/CustomType/sliceZone";
|
|
29
|
+
import { CompositeSlice } from "@prismicio/types-internal/lib/customtypes";
|
|
24
30
|
|
|
25
31
|
const defaultSx = (sx: ThemeUIStyleObject = {}): ThemeUICSSObject => ({
|
|
26
32
|
bg: "white",
|
|
@@ -210,7 +216,7 @@ const isDeleted = (statusOrCustom: StatusOrCustom): boolean =>
|
|
|
210
216
|
"status" in statusOrCustom && statusOrCustom.status === ModelStatus.Deleted;
|
|
211
217
|
|
|
212
218
|
export const SharedSlice = {
|
|
213
|
-
|
|
219
|
+
Render({
|
|
214
220
|
showActions,
|
|
215
221
|
slice,
|
|
216
222
|
Wrapper,
|
|
@@ -311,13 +317,20 @@ export const SharedSlice = {
|
|
|
311
317
|
};
|
|
312
318
|
|
|
313
319
|
export const NonSharedSlice = {
|
|
314
|
-
|
|
320
|
+
Render({
|
|
315
321
|
slice,
|
|
322
|
+
slices,
|
|
316
323
|
sx,
|
|
324
|
+
path,
|
|
317
325
|
}: {
|
|
318
|
-
|
|
319
|
-
|
|
326
|
+
slice: NonSharedSliceInSliceZone;
|
|
327
|
+
slices: readonly SliceZoneSlice[];
|
|
320
328
|
sx?: ThemeUIStyleObject;
|
|
329
|
+
path: {
|
|
330
|
+
customTypeID: string;
|
|
331
|
+
tabID: string;
|
|
332
|
+
sliceZoneID: string;
|
|
333
|
+
};
|
|
321
334
|
}) {
|
|
322
335
|
const Wrapper = WrapperByType[WrapperType.nonClickable];
|
|
323
336
|
|
|
@@ -374,11 +387,9 @@ export const NonSharedSlice = {
|
|
|
374
387
|
lineHeight: "16px",
|
|
375
388
|
}}
|
|
376
389
|
>
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
the Slice from your type model. Then create a new Slice with the
|
|
381
|
-
same fields using Slice Machine.
|
|
390
|
+
{slice.value.type === "Slice"
|
|
391
|
+
? "This Slice was created with the Legacy Builder. It needs to be converted first to be used within Slice Machine."
|
|
392
|
+
: "This Slice was created with the Legacy Builder and cannot be yet converted to be used within Slice Machine."}
|
|
382
393
|
</Text>
|
|
383
394
|
</ReactTooltip>
|
|
384
395
|
</ReactTooltipPortal>
|
|
@@ -392,30 +403,45 @@ export const NonSharedSlice = {
|
|
|
392
403
|
/>
|
|
393
404
|
<Flex
|
|
394
405
|
p={3}
|
|
395
|
-
sx={{
|
|
396
|
-
flexDirection: "column",
|
|
397
|
-
}}
|
|
406
|
+
sx={{ justifyContent: "space-between", alignItems: "center" }}
|
|
398
407
|
>
|
|
399
|
-
<TextWithTooltip
|
|
400
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/strict-boolean-expressions
|
|
401
|
-
text={slice?.value?.fieldset || slice.key}
|
|
402
|
-
as="h6"
|
|
403
|
-
sx={{
|
|
404
|
-
fontWeight: "600 !important",
|
|
405
|
-
maxWidth: "80%",
|
|
406
|
-
lineHeight: "24px !important",
|
|
407
|
-
color: "grey10",
|
|
408
|
-
}}
|
|
409
|
-
/>
|
|
410
408
|
<Flex
|
|
411
409
|
sx={{
|
|
412
|
-
height: "28px",
|
|
413
|
-
justifyContent: "center",
|
|
414
410
|
flexDirection: "column",
|
|
411
|
+
flex: "1 1 auto",
|
|
415
412
|
}}
|
|
416
413
|
>
|
|
417
|
-
<
|
|
414
|
+
<TextWithTooltip
|
|
415
|
+
text={
|
|
416
|
+
slice.value.type === "Slice"
|
|
417
|
+
? slice?.value?.fieldset ?? slice.key
|
|
418
|
+
: slice.key
|
|
419
|
+
}
|
|
420
|
+
as="h6"
|
|
421
|
+
sx={{
|
|
422
|
+
fontWeight: "600 !important",
|
|
423
|
+
maxWidth: "80%",
|
|
424
|
+
lineHeight: "24px !important",
|
|
425
|
+
color: "grey10",
|
|
426
|
+
}}
|
|
427
|
+
/>
|
|
428
|
+
<Flex
|
|
429
|
+
sx={{
|
|
430
|
+
height: "28px",
|
|
431
|
+
justifyContent: "center",
|
|
432
|
+
flexDirection: "column",
|
|
433
|
+
}}
|
|
434
|
+
>
|
|
435
|
+
<SliceVariations numberOfVariations={1} />
|
|
436
|
+
</Flex>
|
|
418
437
|
</Flex>
|
|
438
|
+
{slice.value.type === "Slice" ? (
|
|
439
|
+
<ConvertLegacySliceModal
|
|
440
|
+
slice={slice as { key: string; value: CompositeSlice }}
|
|
441
|
+
slices={slices}
|
|
442
|
+
path={path}
|
|
443
|
+
/>
|
|
444
|
+
) : null}
|
|
419
445
|
</Flex>
|
|
420
446
|
</Themecard>
|
|
421
447
|
</Wrapper>
|
package/out/404.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><title>Slice Machine</title><meta name="next-head-count" content="3"/><link rel="preload" href="/_next/static/css/fe2a2a1cbf3b4092.css" as="style"/><link rel="stylesheet" href="/_next/static/css/fe2a2a1cbf3b4092.css" data-n-g=""/><noscript data-n-css=""></noscript><script defer="" nomodule="" src="/_next/static/chunks/polyfills-c67a75d1b6f99dc8.js"></script><script src="/_next/static/chunks/webpack-2f903acb0cccbf9e.js" defer=""></script><script src="/_next/static/chunks/framework-cdccea7a52cc6e81.js" defer=""></script><script src="/_next/static/chunks/main-5e6780279ca21cb9.js" defer=""></script><script src="/_next/static/chunks/pages/_app-
|
|
1
|
+
<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><title>Slice Machine</title><meta name="next-head-count" content="3"/><link rel="preload" href="/_next/static/css/fe2a2a1cbf3b4092.css" as="style"/><link rel="stylesheet" href="/_next/static/css/fe2a2a1cbf3b4092.css" data-n-g=""/><noscript data-n-css=""></noscript><script defer="" nomodule="" src="/_next/static/chunks/polyfills-c67a75d1b6f99dc8.js"></script><script src="/_next/static/chunks/webpack-2f903acb0cccbf9e.js" defer=""></script><script src="/_next/static/chunks/framework-cdccea7a52cc6e81.js" defer=""></script><script src="/_next/static/chunks/main-5e6780279ca21cb9.js" defer=""></script><script src="/_next/static/chunks/pages/_app-cdcc9574e096e708.js" defer=""></script><script src="/_next/static/chunks/pages/_error-69b4f498bafdd188.js" defer=""></script><script src="/_next/static/HJothAZ-ufia3zK-uZgiR/_buildManifest.js" defer=""></script><script src="/_next/static/HJothAZ-ufia3zK-uZgiR/_ssgManifest.js" defer=""></script></head><body><div id="__next"><style data-emotion="css-global 413pep">html{--theme-ui-colors-text:#25252D;--theme-ui-colors-textClear:#6F6E77;--theme-ui-colors-grayLight:#E8E8ED;--theme-ui-colors-hoverBackground:#f2f2f2;--theme-ui-colors-background:#FFF;--theme-ui-colors-backgroundClear:#FFF;--theme-ui-colors-primary:#5D40F7;--theme-ui-colors-purpleLight:#F6F1FC;--theme-ui-colors-purpleLight01:#6548FF1A;--theme-ui-colors-purple12:#F1EEFE;--theme-ui-colors-purpleStrong:#5842C3;--theme-ui-colors-whiteButtonText:#1A1523;--theme-ui-colors-codeBlockBackground:#32275F;--theme-ui-colors-failedConnectText:#86848D;--theme-ui-colors-changesWarning-background:#FFECC7;--theme-ui-colors-changesWarning-color:#5C0C17;--theme-ui-colors-greyIcon:#6F6E77;--theme-ui-colors-greyIconDisabled:#C9D0D8;--theme-ui-colors-missingScreenshotBanner-color:#5C0C17;--theme-ui-colors-missingScreenshotBanner-bg:#FFECC7;--theme-ui-colors-badge-new-bg:#DBEDDB;--theme-ui-colors-badge-new-color:#05644D;--theme-ui-colors-badge-modified-bg:#FFECC7;--theme-ui-colors-badge-modified-color:#5C0C17;--theme-ui-colors-badge-synced-bg:purple12;--theme-ui-colors-badge-synced-color:#5842C3;--theme-ui-colors-badge-deleted-bg:rgba(203, 36, 49, 0.1);--theme-ui-colors-badge-unknown-bg:#F3F5F7;--theme-ui-colors-badge-unknown-color:#9AA4AF;--theme-ui-colors-codeBlockBorder:#545454;--theme-ui-colors-secondary:#F9FAFB;--theme-ui-colors-danger:#CB2431;--theme-ui-colors-highlight:hsl(10, 40%, 90%);--theme-ui-colors-purple:#5B3DF5;--theme-ui-colors-purple08:#5842C3;--theme-ui-colors-muted:#F9F9FB;--theme-ui-colors-icons:#8091A5;--theme-ui-colors-gray:#F8F9FA;--theme-ui-colors-grey01:#F3F5F7;--theme-ui-colors-grey02:#E6E6EA;--theme-ui-colors-grey03:#F4F2F4;--theme-ui-colors-grey04:#9AA4AF;--theme-ui-colors-grey05:#667587;--theme-ui-colors-grey07:#F9F8F9;--theme-ui-colors-grey10:#86848D;--theme-ui-colors-grey12:#1A1523;--theme-ui-colors-greyTransparent:rgba(37, 37, 45, 0.4);--theme-ui-colors-borders:#E4E2E4;--theme-ui-colors-bordersFocused:#6E56CF;--theme-ui-colors-deep:#0E2150;--theme-ui-colors-deep1:#A0ADE7;--theme-ui-colors-lightGreen:#EBF8F1;--theme-ui-colors-lightOrange:#FDF4EC;--theme-ui-colors-darkOrange:#C17C10;--theme-ui-colors-error:#E55737;--theme-ui-colors-success:#3AB97A;--theme-ui-colors-headSection:#fff;--theme-ui-colors-warning:#E67E22;--theme-ui-colors-warning02:#ED811C;--theme-ui-colors-sidebar:#F1F1F4;--theme-ui-colors-link:#6E56CF;--theme-ui-colors-choggleBox:#5163BA;--theme-ui-colors-darkBorder:#DCDBDD;--theme-ui-colors-code-border:#DFE1E5;--theme-ui-colors-code-blue:#3B41BD;--theme-ui-colors-code-gray:#667587;--theme-ui-colors-code-orange:#EA6D46;--theme-ui-colors-code-green:#3AB97A;color:var(--theme-ui-colors-text);background-color:var(--theme-ui-colors-background);}html.theme-ui-light,.theme-ui-light html{--theme-ui-colors-text:#25252D;--theme-ui-colors-textClear:#6F6E77;--theme-ui-colors-grayLight:#E8E8ED;--theme-ui-colors-hoverBackground:#f2f2f2;--theme-ui-colors-background:#FFF;--theme-ui-colors-backgroundClear:#FFF;--theme-ui-colors-primary:#5D40F7;--theme-ui-colors-purpleLight:#F6F1FC;--theme-ui-colors-purpleLight01:#6548FF1A;--theme-ui-colors-purple12:#F1EEFE;--theme-ui-colors-purpleStrong:#5842C3;--theme-ui-colors-whiteButtonText:#1A1523;--theme-ui-colors-codeBlockBackground:#32275F;--theme-ui-colors-failedConnectText:#86848D;--theme-ui-colors-changesWarning-background:#FFECC7;--theme-ui-colors-changesWarning-color:#5C0C17;--theme-ui-colors-greyIcon:#6F6E77;--theme-ui-colors-greyIconDisabled:#C9D0D8;--theme-ui-colors-missingScreenshotBanner-color:#5C0C17;--theme-ui-colors-missingScreenshotBanner-bg:#FFECC7;--theme-ui-colors-badge-new-bg:#DBEDDB;--theme-ui-colors-badge-new-color:#05644D;--theme-ui-colors-badge-modified-bg:#FFECC7;--theme-ui-colors-badge-modified-color:#5C0C17;--theme-ui-colors-badge-synced-bg:purple12;--theme-ui-colors-badge-synced-color:#5842C3;--theme-ui-colors-badge-deleted-bg:rgba(203, 36, 49, 0.1);--theme-ui-colors-badge-unknown-bg:#F3F5F7;--theme-ui-colors-badge-unknown-color:#9AA4AF;--theme-ui-colors-codeBlockBorder:#545454;--theme-ui-colors-secondary:#F9FAFB;--theme-ui-colors-danger:#CB2431;--theme-ui-colors-highlight:hsl(10, 40%, 90%);--theme-ui-colors-purple:#5B3DF5;--theme-ui-colors-purple08:#5842C3;--theme-ui-colors-muted:#F9F9FB;--theme-ui-colors-icons:#8091A5;--theme-ui-colors-gray:#F8F9FA;--theme-ui-colors-grey01:#F3F5F7;--theme-ui-colors-grey02:#E6E6EA;--theme-ui-colors-grey03:#F4F2F4;--theme-ui-colors-grey04:#9AA4AF;--theme-ui-colors-grey05:#667587;--theme-ui-colors-grey07:#F9F8F9;--theme-ui-colors-grey10:#86848D;--theme-ui-colors-grey12:#1A1523;--theme-ui-colors-greyTransparent:rgba(37, 37, 45, 0.4);--theme-ui-colors-borders:#E4E2E4;--theme-ui-colors-bordersFocused:#6E56CF;--theme-ui-colors-deep:#0E2150;--theme-ui-colors-deep1:#A0ADE7;--theme-ui-colors-lightGreen:#EBF8F1;--theme-ui-colors-lightOrange:#FDF4EC;--theme-ui-colors-darkOrange:#C17C10;--theme-ui-colors-error:#E55737;--theme-ui-colors-success:#3AB97A;--theme-ui-colors-headSection:#fff;--theme-ui-colors-warning:#E67E22;--theme-ui-colors-warning02:#ED811C;--theme-ui-colors-sidebar:#F1F1F4;--theme-ui-colors-link:#6E56CF;--theme-ui-colors-choggleBox:#5163BA;--theme-ui-colors-darkBorder:#DCDBDD;--theme-ui-colors-code-border:#DFE1E5;--theme-ui-colors-code-blue:#3B41BD;--theme-ui-colors-code-gray:#667587;--theme-ui-colors-code-orange:#EA6D46;--theme-ui-colors-code-green:#3AB97A;}html.theme-ui-dark,.theme-ui-dark html{--theme-ui-colors-text:#fff;--theme-ui-colors-textClear:#6E707B;--theme-ui-colors-hoverBackground:#202020;--theme-ui-colors-grey02:#E6E6EA;--theme-ui-colors-background:#202022;--theme-ui-colors-backgroundClear:#28282C;--theme-ui-colors-primary:#4E54D7;--theme-ui-colors-secondary:#28282C;--theme-ui-colors-icons:#5D5D71;--theme-ui-colors-gray:#1D1D1F;--theme-ui-colors-borders:#3A3A46;--theme-ui-colors-deep:#28282C;--theme-ui-colors-headSection:#28282C;--theme-ui-colors-warning:#E67E22;--theme-ui-colors-sidebar:#28282C;--theme-ui-colors-code-border:#5D5D6F;--theme-ui-colors-code-blue:#3B41BD;--theme-ui-colors-code-gray:#667587;--theme-ui-colors-code-orange:#EA6D46;--theme-ui-colors-code-green:#3AB97A;--theme-ui-colors-link:#A9A9C6;--theme-ui-colors-choggleBox:#fff;}</style><style data-emotion="css-global h19pgh">*{box-sizing:border-box;}html{font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",sans-serif;line-height:1.5;font-weight:400;}body{margin:0;}</style><style data-emotion="css yvak7d">.css-yvak7d{box-sizing:border-box;margin:0;min-width:0;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;height:calc(100vh - 57px);width:100vw;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;-webkit-justify-content:center;justify-content:center;}</style><div class="css-yvak7d"><style data-emotion="css uqm8ih">.css-uqm8ih{box-sizing:border-box;margin:0;min-width:0;color:var(--theme-ui-colors-primary);overflow:visible;}</style><svg stroke-width="4" viewBox="0 0 32 32" width="48" height="48" fill="none" stroke="currentColor" role="img" id="spinner" class="css-uqm8ih"><title>Loading</title><circle stroke-width="4" r="12" cx="16" cy="16" fill="none" opacity="0.125"></circle><circle stroke-width="4" r="12" cx="16" cy="16" fill="none" stroke-dasharray="20 110"><animateTransform attributeName="transform" attributeType="XML" type="rotate" from="0 16 16" to="360 16 16" dur="750ms" repeatCount="indefinite"></animateTransform></circle></svg></div></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":404}},"page":"/_error","query":{},"buildId":"HJothAZ-ufia3zK-uZgiR","runtimeConfig":{"sentryEnvironment":"alpha"},"nextExport":true,"isFallback":false,"gip":true,"appGip":true,"scriptLoader":[]}</script></body></html>
|