slice-machine-ui 1.19.3-dev-next-release.1 → 1.19.3-dev-rename-and-delete-variations.2
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/DeleteVariationModal/index.tsx +84 -0
- package/components/Forms/RenameVariationModal/RenameVariationModal.css.ts +7 -0
- package/components/Forms/RenameVariationModal/RenameVariationModal.tsx +118 -0
- package/components/Forms/RenameVariationModal/index.ts +1 -0
- package/lib/builders/SliceBuilder/Sidebar/{VariationModal.tsx → AddVariationModal.tsx} +3 -3
- package/lib/builders/SliceBuilder/Sidebar/index.tsx +82 -37
- package/lib/builders/SliceBuilder/index.tsx +31 -27
- package/out/404.html +1 -1
- package/out/_next/static/chunks/904-69cc3c4be2bff626.js +1 -0
- package/out/_next/static/chunks/958-9a56a0b83f7dc035.js +1 -0
- package/out/_next/static/chunks/pages/{_app-2d090d3ea4b0e31a.js → _app-5a91622066c7f465.js} +2 -2
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-6a529b68fb092f4c.js +1 -0
- package/out/_next/static/{aZP9hfVnQfVO9cRmJSs18 → hVQ3Yc7gBdqefYnTLZuOw}/_buildManifest.js +1 -1
- 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 +4 -4
- package/src/apiClient.ts +32 -4
- package/src/features/slices/convertLegacySlice/ConvertLegacySliceAsNewSliceDialog.tsx +3 -4
- package/src/features/slices/sliceBuilder/actions/deleteVariation.ts +86 -0
- package/src/features/slices/sliceBuilder/actions/renameVariation.ts +77 -0
- package/src/features/slices/sliceCards/SharedSliceCard.tsx +44 -17
- package/src/modules/environment/index.ts +2 -2
- package/src/modules/screenshots/sagas.ts +3 -6
- package/src/modules/selectedSlice/actions.ts +7 -2
- package/src/modules/selectedSlice/reducer.ts +6 -1
- package/src/modules/selectedSlice/sagas.ts +10 -18
- package/src/modules/slices/index.ts +23 -1
- package/src/modules/toaster/utils.tsx +6 -12
- package/src/modules/useSliceMachineActions.ts +9 -3
- package/test/src/modules/selectedSlice/sagas.test.ts +14 -12
- package/test/src/modules/toaster/utils.test.ts +3 -34
- package/out/_next/static/chunks/904-55ff54caf14254dc.js +0 -1
- package/out/_next/static/chunks/958-be627006594efb21.js +0 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-2282320bb9091898.js +0 -1
- /package/out/_next/static/{aZP9hfVnQfVO9cRmJSs18 → hVQ3Yc7gBdqefYnTLZuOw}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Box,
|
|
3
|
+
Dialog,
|
|
4
|
+
DialogActions,
|
|
5
|
+
DialogContent,
|
|
6
|
+
DialogHeader,
|
|
7
|
+
Text,
|
|
8
|
+
} from "@prismicio/editor-ui";
|
|
9
|
+
import { useRouter } from "next/router";
|
|
10
|
+
import type { Dispatch, FC, PropsWithChildren, SetStateAction } from "react";
|
|
11
|
+
|
|
12
|
+
import type { SliceBuilderState } from "@builders/SliceBuilder";
|
|
13
|
+
import type { ComponentUI } from "@lib/models/common/ComponentUI";
|
|
14
|
+
import type { VariationSM } from "@lib/models/common/Slice";
|
|
15
|
+
import { deleteVariation } from "@src/features/slices/sliceBuilder/actions/deleteVariation";
|
|
16
|
+
import useSliceMachineActions from "@src/modules/useSliceMachineActions";
|
|
17
|
+
|
|
18
|
+
type DeleteVariationModalProps = {
|
|
19
|
+
isOpen: boolean;
|
|
20
|
+
onClose: () => void;
|
|
21
|
+
slice: ComponentUI;
|
|
22
|
+
variation: VariationSM;
|
|
23
|
+
sliceBuilderState: SliceBuilderState;
|
|
24
|
+
setSliceBuilderState: Dispatch<SetStateAction<SliceBuilderState>>;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const DeleteVariationModal: FC<DeleteVariationModalProps> = ({
|
|
28
|
+
isOpen,
|
|
29
|
+
onClose,
|
|
30
|
+
slice,
|
|
31
|
+
variation,
|
|
32
|
+
sliceBuilderState,
|
|
33
|
+
setSliceBuilderState,
|
|
34
|
+
}) => {
|
|
35
|
+
const router = useRouter();
|
|
36
|
+
const { updateAndSaveSlice } = useSliceMachineActions();
|
|
37
|
+
return (
|
|
38
|
+
<Dialog
|
|
39
|
+
open={isOpen}
|
|
40
|
+
onOpenChange={(open) => !open && onClose()}
|
|
41
|
+
size={{ width: 448, height: "auto" }}
|
|
42
|
+
>
|
|
43
|
+
<DialogHeader icon="delete" title="Delete variation" />
|
|
44
|
+
<DialogContent>
|
|
45
|
+
<Box flexDirection="column">
|
|
46
|
+
<Box flexDirection="column" gap={8} padding={16}>
|
|
47
|
+
<Text color="grey11">
|
|
48
|
+
This action will remove the variation from the slice model and
|
|
49
|
+
delete associated files. When you push your changes, the variation
|
|
50
|
+
will disappear from your repository. This update will{" "}
|
|
51
|
+
<Bold>not</Bold> affect your documents until you <Bold>edit</Bold>{" "}
|
|
52
|
+
them manually.
|
|
53
|
+
</Text>
|
|
54
|
+
</Box>
|
|
55
|
+
<DialogActions
|
|
56
|
+
ok={{
|
|
57
|
+
text: "Delete",
|
|
58
|
+
onClick: () => {
|
|
59
|
+
void (async () => {
|
|
60
|
+
try {
|
|
61
|
+
await deleteVariation({
|
|
62
|
+
component: slice,
|
|
63
|
+
router,
|
|
64
|
+
setSliceBuilderState,
|
|
65
|
+
updateAndSaveSlice,
|
|
66
|
+
variation,
|
|
67
|
+
});
|
|
68
|
+
} catch {}
|
|
69
|
+
onClose();
|
|
70
|
+
})();
|
|
71
|
+
},
|
|
72
|
+
loading: sliceBuilderState.loading,
|
|
73
|
+
}}
|
|
74
|
+
cancel={{ text: "Cancel" }}
|
|
75
|
+
/>
|
|
76
|
+
</Box>
|
|
77
|
+
</DialogContent>
|
|
78
|
+
</Dialog>
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const Bold: FC<PropsWithChildren> = (props) => (
|
|
83
|
+
<Text {...props} color="inherit" component="span" variant="bold" />
|
|
84
|
+
);
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Box,
|
|
3
|
+
Dialog,
|
|
4
|
+
DialogActions,
|
|
5
|
+
DialogContent,
|
|
6
|
+
DialogHeader,
|
|
7
|
+
FormInput,
|
|
8
|
+
Text,
|
|
9
|
+
} from "@prismicio/editor-ui";
|
|
10
|
+
import { Formik } from "formik";
|
|
11
|
+
import type { Dispatch, FC, SetStateAction } from "react";
|
|
12
|
+
|
|
13
|
+
import type { SliceBuilderState } from "@builders/SliceBuilder";
|
|
14
|
+
import type { ComponentUI } from "@lib/models/common/ComponentUI";
|
|
15
|
+
import type { VariationSM } from "@lib/models/common/Slice";
|
|
16
|
+
import { renameVariation } from "@src/features/slices/sliceBuilder/actions/renameVariation";
|
|
17
|
+
import useSliceMachineActions from "@src/modules/useSliceMachineActions";
|
|
18
|
+
|
|
19
|
+
import * as styles from "./RenameVariationModal.css";
|
|
20
|
+
|
|
21
|
+
type RenameVariationModalProps = {
|
|
22
|
+
isOpen: boolean;
|
|
23
|
+
onClose: () => void;
|
|
24
|
+
slice: ComponentUI;
|
|
25
|
+
variation: VariationSM;
|
|
26
|
+
sliceBuilderState: SliceBuilderState;
|
|
27
|
+
setSliceBuilderState: Dispatch<SetStateAction<SliceBuilderState>>;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const RenameVariationModal: FC<RenameVariationModalProps> = ({
|
|
31
|
+
isOpen,
|
|
32
|
+
onClose,
|
|
33
|
+
slice,
|
|
34
|
+
variation,
|
|
35
|
+
sliceBuilderState,
|
|
36
|
+
setSliceBuilderState,
|
|
37
|
+
}) => {
|
|
38
|
+
const { updateAndSaveSlice } = useSliceMachineActions();
|
|
39
|
+
return (
|
|
40
|
+
<>
|
|
41
|
+
<Dialog
|
|
42
|
+
open={isOpen}
|
|
43
|
+
onOpenChange={(open) => !open && onClose()}
|
|
44
|
+
size={{ width: 448, height: "auto" }}
|
|
45
|
+
>
|
|
46
|
+
<DialogHeader icon="edit" title="Rename variation" />
|
|
47
|
+
<DialogContent>
|
|
48
|
+
<Formik
|
|
49
|
+
validateOnChange
|
|
50
|
+
validateOnMount
|
|
51
|
+
initialValues={{ variationName: variation.name }}
|
|
52
|
+
validate={(values) => {
|
|
53
|
+
if (values.variationName.length === 0) {
|
|
54
|
+
return { variationName: "Cannot be empty" };
|
|
55
|
+
}
|
|
56
|
+
}}
|
|
57
|
+
onSubmit={async (values) => {
|
|
58
|
+
try {
|
|
59
|
+
await renameVariation({
|
|
60
|
+
component: slice,
|
|
61
|
+
setSliceBuilderState,
|
|
62
|
+
updateAndSaveSlice,
|
|
63
|
+
variation,
|
|
64
|
+
variationName: values.variationName.trim(),
|
|
65
|
+
});
|
|
66
|
+
} catch {}
|
|
67
|
+
onClose();
|
|
68
|
+
}}
|
|
69
|
+
>
|
|
70
|
+
{(formik) => (
|
|
71
|
+
<form>
|
|
72
|
+
<Box flexDirection="column">
|
|
73
|
+
<Box flexDirection="column" gap={8} padding={16}>
|
|
74
|
+
<Text variant="normal" color="grey11">
|
|
75
|
+
This action will rename the variation in the slice model.
|
|
76
|
+
When you push your changes, the variation will be renamed
|
|
77
|
+
in your repository.
|
|
78
|
+
</Text>
|
|
79
|
+
<Box flexDirection="column" gap={4}>
|
|
80
|
+
<label className={styles.label}>
|
|
81
|
+
<Text variant="bold">Variation name*</Text>
|
|
82
|
+
{typeof formik.errors.variationName === "string" ? (
|
|
83
|
+
<Text variant="small" color="tomato10">
|
|
84
|
+
{formik.errors.variationName}
|
|
85
|
+
</Text>
|
|
86
|
+
) : null}
|
|
87
|
+
</label>
|
|
88
|
+
<FormInput
|
|
89
|
+
placeholder="Variation name"
|
|
90
|
+
error={typeof formik.errors.variationName === "string"}
|
|
91
|
+
value={formik.values.variationName}
|
|
92
|
+
onValueChange={(value) =>
|
|
93
|
+
void formik.setFieldValue(
|
|
94
|
+
"variationName",
|
|
95
|
+
value.slice(0, 30),
|
|
96
|
+
)
|
|
97
|
+
}
|
|
98
|
+
/>
|
|
99
|
+
</Box>
|
|
100
|
+
</Box>
|
|
101
|
+
<DialogActions
|
|
102
|
+
ok={{
|
|
103
|
+
text: "Rename",
|
|
104
|
+
onClick: () => void formik.submitForm(),
|
|
105
|
+
loading: sliceBuilderState.loading,
|
|
106
|
+
disabled: !formik.isValid,
|
|
107
|
+
}}
|
|
108
|
+
cancel={{ text: "Cancel" }}
|
|
109
|
+
/>
|
|
110
|
+
</Box>
|
|
111
|
+
</form>
|
|
112
|
+
)}
|
|
113
|
+
</Formik>
|
|
114
|
+
</DialogContent>
|
|
115
|
+
</Dialog>
|
|
116
|
+
</>
|
|
117
|
+
);
|
|
118
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { RenameVariationModal } from "./RenameVariationModal";
|
|
@@ -15,7 +15,7 @@ const Error = ({ msg }: { msg?: string }) => (
|
|
|
15
15
|
{msg || "Error!"}
|
|
16
16
|
</Text>
|
|
17
17
|
);
|
|
18
|
-
const
|
|
18
|
+
const AddVariationModal: React.FunctionComponent<{
|
|
19
19
|
isOpen: boolean;
|
|
20
20
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
21
|
onClose: () => any;
|
|
@@ -51,7 +51,7 @@ const VariationModal: React.FunctionComponent<{
|
|
|
51
51
|
const originError = !(
|
|
52
52
|
origin.value.length && variations.find((v) => v.id === origin.value)
|
|
53
53
|
)
|
|
54
|
-
? { id: "
|
|
54
|
+
? { id: "You must select an existing variation!" }
|
|
55
55
|
: null;
|
|
56
56
|
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
57
57
|
const invalidIdError = id &&
|
|
@@ -236,4 +236,4 @@ const VariationModal: React.FunctionComponent<{
|
|
|
236
236
|
);
|
|
237
237
|
};
|
|
238
238
|
|
|
239
|
-
export default
|
|
239
|
+
export default AddVariationModal;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { Box, Button } from "@prismicio/editor-ui";
|
|
2
2
|
import { useRouter } from "next/router";
|
|
3
|
-
import { type FC, useState } from "react";
|
|
3
|
+
import { type Dispatch, type FC, type SetStateAction, useState } from "react";
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import AddVariationModal from "@builders/SliceBuilder/Sidebar/AddVariationModal";
|
|
6
|
+
import type { SliceBuilderState } from "@builders/SliceBuilder";
|
|
7
|
+
import { DeleteVariationModal } from "@components/DeleteVariationModal";
|
|
8
|
+
import { RenameVariationModal } from "@components/Forms/RenameVariationModal";
|
|
6
9
|
import ScreenshotChangesModal from "@components/ScreenshotChangesModal";
|
|
7
10
|
import type { ComponentUI } from "@lib/models/common/ComponentUI";
|
|
8
11
|
import type { VariationSM } from "@lib/models/common/Slice";
|
|
@@ -15,27 +18,43 @@ import useSliceMachineActions from "@src/modules/useSliceMachineActions";
|
|
|
15
18
|
type SidebarProps = {
|
|
16
19
|
slice: ComponentUI;
|
|
17
20
|
variation: VariationSM;
|
|
18
|
-
|
|
21
|
+
sliceBuilderState: SliceBuilderState;
|
|
22
|
+
setSliceBuilderState: Dispatch<SetStateAction<SliceBuilderState>>;
|
|
19
23
|
};
|
|
20
24
|
|
|
25
|
+
type DialogState =
|
|
26
|
+
| { type: "ADD_VARIATION" }
|
|
27
|
+
| { type: "RENAME_VARIATION"; variation: VariationSM }
|
|
28
|
+
| { type: "DELETE_VARIATION"; variation: VariationSM }
|
|
29
|
+
| undefined;
|
|
30
|
+
|
|
21
31
|
export const Sidebar: FC<SidebarProps> = (props) => {
|
|
22
|
-
const { slice, variation,
|
|
32
|
+
const { slice, variation, sliceBuilderState, setSliceBuilderState } = props;
|
|
23
33
|
|
|
24
|
-
const
|
|
34
|
+
const [dialog, setDialog] = useState<DialogState>();
|
|
25
35
|
|
|
26
36
|
const screenshotChangesModal = useScreenshotChangesModal();
|
|
27
37
|
const { sliceFilterFn, defaultVariationSelector } =
|
|
28
38
|
screenshotChangesModal.modalPayload;
|
|
29
39
|
|
|
30
|
-
const
|
|
31
|
-
const
|
|
40
|
+
const { copyVariationSlice, updateSlice } = useSliceMachineActions();
|
|
41
|
+
const router = useRouter();
|
|
32
42
|
|
|
33
43
|
return (
|
|
34
44
|
<>
|
|
35
45
|
<Box flexDirection="column" gap={16}>
|
|
36
46
|
{slice.model.variations.map((v) => (
|
|
37
47
|
<SharedSliceCard
|
|
38
|
-
action={{
|
|
48
|
+
action={{
|
|
49
|
+
type: "menu",
|
|
50
|
+
onRename: () => {
|
|
51
|
+
setDialog({ type: "RENAME_VARIATION", variation: v });
|
|
52
|
+
},
|
|
53
|
+
onRemove: () => {
|
|
54
|
+
setDialog({ type: "DELETE_VARIATION", variation: v });
|
|
55
|
+
},
|
|
56
|
+
removeDisabled: slice.model.variations.length <= 1,
|
|
57
|
+
}}
|
|
39
58
|
key={v.id}
|
|
40
59
|
mode="navigation"
|
|
41
60
|
onUpdateScreenshot={() => {
|
|
@@ -56,7 +75,7 @@ export const Sidebar: FC<SidebarProps> = (props) => {
|
|
|
56
75
|
))}
|
|
57
76
|
<Button
|
|
58
77
|
onClick={() => {
|
|
59
|
-
|
|
78
|
+
setDialog({ type: "ADD_VARIATION" });
|
|
60
79
|
}}
|
|
61
80
|
startIcon="add"
|
|
62
81
|
sx={{ bottom: 72, marginInline: 24, position: "sticky" }}
|
|
@@ -69,36 +88,62 @@ export const Sidebar: FC<SidebarProps> = (props) => {
|
|
|
69
88
|
slices={sliceFilterFn([slice])}
|
|
70
89
|
defaultVariationSelector={defaultVariationSelector}
|
|
71
90
|
/>
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
91
|
+
{dialog?.type === "RENAME_VARIATION" ? (
|
|
92
|
+
<RenameVariationModal
|
|
93
|
+
isOpen
|
|
94
|
+
onClose={() => {
|
|
95
|
+
setDialog(undefined);
|
|
96
|
+
}}
|
|
97
|
+
slice={slice}
|
|
98
|
+
variation={dialog.variation}
|
|
99
|
+
sliceBuilderState={sliceBuilderState}
|
|
100
|
+
setSliceBuilderState={setSliceBuilderState}
|
|
101
|
+
/>
|
|
102
|
+
) : undefined}
|
|
103
|
+
{dialog?.type === "DELETE_VARIATION" ? (
|
|
104
|
+
<DeleteVariationModal
|
|
105
|
+
isOpen
|
|
106
|
+
onClose={() => {
|
|
107
|
+
setDialog(undefined);
|
|
108
|
+
}}
|
|
109
|
+
slice={slice}
|
|
110
|
+
variation={dialog.variation}
|
|
111
|
+
sliceBuilderState={sliceBuilderState}
|
|
112
|
+
setSliceBuilderState={setSliceBuilderState}
|
|
113
|
+
/>
|
|
114
|
+
) : undefined}
|
|
115
|
+
{dialog?.type === "ADD_VARIATION" ? (
|
|
116
|
+
<AddVariationModal
|
|
117
|
+
initialVariation={variation}
|
|
118
|
+
isOpen
|
|
119
|
+
onClose={() => {
|
|
120
|
+
setDialog(undefined);
|
|
121
|
+
}}
|
|
122
|
+
onSubmit={(id, name, copiedVariation) => {
|
|
123
|
+
copyVariationSlice(id, name, copiedVariation);
|
|
80
124
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
125
|
+
// We have to immediately save the new variation to prevent an
|
|
126
|
+
// infinite loop related to screenshots handling.
|
|
127
|
+
const newVariation = Variation.copyValue(copiedVariation, id, name);
|
|
128
|
+
const newSlice = {
|
|
129
|
+
...slice,
|
|
130
|
+
model: {
|
|
131
|
+
...slice.model,
|
|
132
|
+
variations: [...slice.model.variations, newVariation],
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
updateSlice(newSlice, setSliceBuilderState);
|
|
92
136
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
137
|
+
const url = SLICES_CONFIG.getBuilderPagePathname({
|
|
138
|
+
libraryName: newSlice.href,
|
|
139
|
+
sliceName: newSlice.model.name,
|
|
140
|
+
variationId: newVariation.id,
|
|
141
|
+
});
|
|
142
|
+
void router.replace(url);
|
|
143
|
+
}}
|
|
144
|
+
variations={slice.model.variations}
|
|
145
|
+
/>
|
|
146
|
+
) : undefined}
|
|
102
147
|
</>
|
|
103
148
|
);
|
|
104
149
|
};
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import { Box, Button } from "@prismicio/editor-ui";
|
|
2
|
-
import
|
|
2
|
+
import {
|
|
3
|
+
type Dispatch,
|
|
4
|
+
type FC,
|
|
5
|
+
type SetStateAction,
|
|
6
|
+
useEffect,
|
|
7
|
+
useState,
|
|
8
|
+
} from "react";
|
|
3
9
|
|
|
4
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
type ToastPayload,
|
|
12
|
+
handleRemoteResponse,
|
|
13
|
+
} from "@src/modules/toaster/utils";
|
|
5
14
|
|
|
6
15
|
import FieldZones from "./FieldZones";
|
|
7
16
|
import { Sidebar } from "./Sidebar";
|
|
@@ -27,10 +36,7 @@ import { selectIsSimulatorAvailableForFramework } from "@src/modules/environment
|
|
|
27
36
|
import { isSelectedSliceTouched } from "@src/modules/selectedSlice/selectors";
|
|
28
37
|
import { ComponentWithSliceProps } from "@src/layouts/WithSlice";
|
|
29
38
|
|
|
30
|
-
export type SliceBuilderState = {
|
|
31
|
-
loading: boolean;
|
|
32
|
-
done: boolean;
|
|
33
|
-
};
|
|
39
|
+
export type SliceBuilderState = ToastPayload & { loading: boolean };
|
|
34
40
|
|
|
35
41
|
export const initialState: SliceBuilderState = {
|
|
36
42
|
loading: false,
|
|
@@ -38,63 +44,60 @@ export const initialState: SliceBuilderState = {
|
|
|
38
44
|
};
|
|
39
45
|
|
|
40
46
|
const SliceBuilder: ComponentWithSliceProps = ({ slice, variation }) => {
|
|
41
|
-
const { openToaster
|
|
47
|
+
const { openToaster } = useSliceMachineActions();
|
|
42
48
|
const isTouched = useSelector((store: SliceMachineStoreType) =>
|
|
43
49
|
isSelectedSliceTouched(store, slice.from, slice.model.id),
|
|
44
50
|
);
|
|
45
51
|
|
|
46
52
|
// We need to move this state to somewhere global to update the UI if any action from anywhere save or update to the filesystem I'd guess
|
|
47
|
-
const [
|
|
53
|
+
const [state, setState] = useState<SliceBuilderState>(initialState);
|
|
48
54
|
|
|
49
55
|
useEffect(() => {
|
|
50
56
|
if (isTouched) {
|
|
51
|
-
|
|
57
|
+
setState(initialState);
|
|
52
58
|
}
|
|
53
59
|
}, [isTouched]);
|
|
54
60
|
|
|
55
61
|
// activate/deactivate Success message
|
|
56
62
|
useEffect(() => {
|
|
57
|
-
if (
|
|
58
|
-
|
|
59
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
60
|
-
handleRemoteResponse(openToaster)(data);
|
|
63
|
+
if (state.done) {
|
|
64
|
+
handleRemoteResponse(openToaster)(state);
|
|
61
65
|
}
|
|
62
66
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
63
|
-
}, [
|
|
67
|
+
}, [state]);
|
|
64
68
|
|
|
65
69
|
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
66
70
|
if (!variation) return <AppLayout />;
|
|
67
71
|
else
|
|
68
72
|
return (
|
|
69
73
|
<SliceBuilderForVariation
|
|
70
|
-
|
|
71
|
-
updateSlice(slice, setData);
|
|
72
|
-
}}
|
|
74
|
+
setState={setState}
|
|
73
75
|
slice={slice}
|
|
74
76
|
variation={variation}
|
|
75
77
|
isTouched={isTouched}
|
|
76
|
-
|
|
78
|
+
state={state}
|
|
77
79
|
/>
|
|
78
80
|
);
|
|
79
81
|
};
|
|
80
82
|
|
|
81
83
|
type SliceBuilderForVariationProps = {
|
|
82
|
-
|
|
84
|
+
setState: Dispatch<SetStateAction<SliceBuilderState>>;
|
|
83
85
|
slice: ComponentUI;
|
|
84
86
|
variation: VariationSM;
|
|
85
87
|
isTouched: boolean;
|
|
86
|
-
|
|
88
|
+
state: SliceBuilderState;
|
|
87
89
|
};
|
|
88
|
-
const SliceBuilderForVariation:
|
|
89
|
-
|
|
90
|
+
const SliceBuilderForVariation: FC<SliceBuilderForVariationProps> = ({
|
|
91
|
+
setState,
|
|
90
92
|
slice,
|
|
91
93
|
variation,
|
|
92
94
|
isTouched,
|
|
93
|
-
|
|
95
|
+
state,
|
|
94
96
|
}) => {
|
|
95
97
|
const isSimulatorAvailableForFramework = useSelector(
|
|
96
98
|
selectIsSimulatorAvailableForFramework,
|
|
97
99
|
);
|
|
100
|
+
const { updateSlice } = useSliceMachineActions();
|
|
98
101
|
|
|
99
102
|
return (
|
|
100
103
|
<AppLayout>
|
|
@@ -107,10 +110,10 @@ const SliceBuilderForVariation: React.FC<SliceBuilderForVariationProps> = ({
|
|
|
107
110
|
isTouched={!!isTouched}
|
|
108
111
|
/>
|
|
109
112
|
<Button
|
|
110
|
-
loading={
|
|
111
|
-
disabled={!isTouched ||
|
|
113
|
+
loading={state.loading}
|
|
114
|
+
disabled={!isTouched || state.loading}
|
|
112
115
|
onClick={() => {
|
|
113
|
-
updateSlice(slice);
|
|
116
|
+
updateSlice(slice, setState);
|
|
114
117
|
}}
|
|
115
118
|
data-cy="builder-save-button"
|
|
116
119
|
>
|
|
@@ -128,7 +131,8 @@ const SliceBuilderForVariation: React.FC<SliceBuilderForVariationProps> = ({
|
|
|
128
131
|
<Sidebar
|
|
129
132
|
slice={slice}
|
|
130
133
|
variation={variation}
|
|
131
|
-
|
|
134
|
+
sliceBuilderState={state}
|
|
135
|
+
setSliceBuilderState={setState}
|
|
132
136
|
/>
|
|
133
137
|
<FieldZones variation={variation} />
|
|
134
138
|
</Box>
|
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/412af4286eb0b283.css" as="style"/><link rel="stylesheet" href="/_next/static/css/412af4286eb0b283.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/412af4286eb0b283.css" as="style"/><link rel="stylesheet" href="/_next/static/css/412af4286eb0b283.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-5a91622066c7f465.js" defer=""></script><script src="/_next/static/chunks/pages/_error-69b4f498bafdd188.js" defer=""></script><script src="/_next/static/hVQ3Yc7gBdqefYnTLZuOw/_buildManifest.js" defer=""></script><script src="/_next/static/hVQ3Yc7gBdqefYnTLZuOw/_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":"hVQ3Yc7gBdqefYnTLZuOw","runtimeConfig":{"sentryEnvironment":"alpha"},"nextExport":true,"isFallback":false,"gip":true,"appGip":true,"scriptLoader":[]}</script></body></html>
|