slice-machine-ui 1.22.2 → 1.22.3-alpha.chore-introduce-css-modules.1
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/.depcheckrc +4 -1
- package/.eslintignore +1 -0
- package/components/DeleteVariationModal/index.tsx +12 -11
- package/components/Forms/CreateSliceModal/CreateSliceModal.tsx +2 -5
- package/components/Forms/RenameCustomTypeModal/RenameCustomTypeModal.tsx +9 -5
- package/components/Forms/RenameVariationModal/RenameVariationModal.tsx +12 -11
- package/components/ItemHeader/index.tsx +1 -0
- package/components/ListItem/index.tsx +5 -2
- package/components/ScreenshotChangesModal/VariationDropZone.tsx +31 -9
- package/components/ScreenshotChangesModal/index.tsx +3 -0
- package/components/ScreenshotChangesModal/useCustomScreenshot.tsx +5 -5
- package/components/Simulator/index.tsx +9 -3
- package/lib/builders/CustomTypeBuilder/SliceZone/SlicesTemplatesModal.tsx +2 -2
- package/lib/builders/CustomTypeBuilder/SliceZone/UpdateSliceZoneModal.tsx +2 -2
- package/lib/builders/CustomTypeBuilder/SliceZone/index.tsx +12 -20
- package/lib/builders/CustomTypeBuilder/TabModal/update.tsx +3 -1
- package/lib/builders/CustomTypeBuilder/TabZone/index.tsx +119 -52
- package/lib/builders/CustomTypeBuilder/index.tsx +39 -42
- package/lib/builders/SliceBuilder/FieldZones/index.tsx +81 -56
- package/lib/builders/SliceBuilder/Sidebar/AddVariationModal.tsx +24 -16
- package/lib/builders/SliceBuilder/Sidebar/index.tsx +44 -46
- package/lib/builders/SliceBuilder/SimulatorButton/index.tsx +4 -28
- package/lib/builders/SliceBuilder/index.tsx +10 -96
- package/lib/builders/common/Zone/Card/components/Hints/CodeBlock.tsx +5 -1
- package/lib/builders/common/Zone/Card/components/NewField.tsx +16 -15
- package/lib/builders/common/Zone/Card/index.jsx +2 -0
- package/lib/builders/common/Zone/index.jsx +3 -1
- package/lib/models/common/ComponentUI.ts +0 -14
- package/lib/models/common/CustomType/sliceZone.ts +0 -29
- package/lib/models/common/CustomType/tab.ts +10 -142
- package/lib/models/common/widgets/Group/ListItem/index.jsx +61 -23
- package/out/404.html +1 -1
- package/out/_next/static/QLcban0JdGEoFu6NgapR9/_buildManifest.js +1 -0
- package/out/_next/static/chunks/065a3ddb-9a38ca0d60f0bf2f.js +1 -0
- package/out/_next/static/chunks/183-4feb6bb3eddbc768.js +1 -0
- package/out/_next/static/chunks/18539003-7b2711e6c51d6fac.js +97 -0
- package/out/_next/static/chunks/1cc2734a-2c5b6c0367fcde86.js +1 -0
- package/out/_next/static/chunks/25-8fedd33ad9b6de5b.js +1 -0
- package/out/_next/static/chunks/286-ed90373e9a469944.js +1 -0
- package/out/_next/static/chunks/318-541db69860d31138.js +1 -0
- package/out/_next/static/chunks/{505-3f1cf09a086dcba8.js → 376-0ed5822f8afcaa7c.js} +3 -3
- package/out/_next/static/chunks/4c744e84-e3161d754618373f.js +1 -0
- package/out/_next/static/chunks/50-cfc2514205b86001.js +1 -0
- package/out/_next/static/chunks/543-f8766685f7f451e2.js +1 -0
- package/out/_next/static/chunks/59b4e022-7a3b5554b806349f.js +1 -0
- package/out/_next/static/chunks/696-b12edad30a3617e5.js +31 -0
- package/out/_next/static/chunks/727-15cf3f2fea9a37e5.js +1 -0
- package/out/_next/static/chunks/731-501990ebe6a71b32.js +1 -0
- package/out/_next/static/chunks/904-ccd8ca3368ce29fc.js +1 -0
- package/out/_next/static/chunks/{918-38d08f1e885b222d.js → 918-5bb55fb464e34768.js} +1 -1
- package/out/_next/static/chunks/f36c6662-03bb5e9d9aa0b0aa.js +1 -0
- package/out/_next/static/chunks/pages/_app-3bb7f58b43c87166.js +430 -0
- package/out/_next/static/chunks/pages/changelog-68d115a14f1423d7.js +1 -0
- package/out/_next/static/chunks/pages/{changes-52c9d917808d1461.js → changes-1cf9e7888029f113.js} +1 -1
- package/out/_next/static/chunks/pages/custom-types/{[customTypeId]-3a37eb3373bb8823.js → [customTypeId]-3f862ad6111a1fc0.js} +1 -1
- package/out/_next/static/chunks/pages/{custom-types-2f5664d9492b13fb.js → custom-types-94b8f8dbf7727412.js} +1 -1
- package/out/_next/static/chunks/pages/{index-d8e3a2c0d712904f.js → index-64cfb8b0948ba8ef.js} +1 -1
- package/out/_next/static/chunks/pages/page-types/{[pageTypeId]-733f3890c0466a05.js → [pageTypeId]-d1ffca11c42f2603.js} +1 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/simulator-897ca93c114a1435.js +1 -0
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-73dd999915509965.js +1 -0
- package/out/_next/static/chunks/pages/slices-7b09cb5130c63bb3.js +1 -0
- package/out/_next/static/css/37153180c3b0dd66.css +1 -0
- package/out/_next/static/css/538ecf581b0e7c11.css +1 -0
- package/out/_next/static/css/{5da5d3cd7a87c3cf.css → 72465cc1225f28a2.css} +1 -1
- package/out/_next/static/css/{77abb01eee0e43a7.css → b22c0750c14cc089.css} +1 -1
- package/out/_next/static/css/f8eb526e10bc2441.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 +21 -11
- package/pages/slices/[lib]/[sliceName]/[variation]/index.tsx +25 -11
- package/pages/slices/[lib]/[sliceName]/[variation]/simulator.tsx +12 -9
- package/src/apiClient.ts +7 -6
- package/src/components/CodeBlock/CodeBlock.tsx +1 -0
- package/src/components/Kbd/Kbd.module.css +10 -0
- package/src/components/Kbd/Kbd.module.css.d.ts +5 -0
- package/src/components/Kbd/Kbd.tsx +1 -1
- package/src/components/Window/Window.tsx +7 -1
- package/src/domain/__tests__/customType.test.ts +785 -0
- package/src/domain/customType.ts +519 -6
- package/src/domain/slice.ts +166 -1
- package/src/features/autoSave/AutoSaveStatusIndicator.tsx +43 -0
- package/src/features/autoSave/useAutoSave.tsx +177 -0
- package/src/features/customTypes/EditDropdown.tsx +3 -0
- package/src/features/customTypes/actions/convertCustomToPageType.ts +2 -4
- package/src/features/customTypes/customTypesBuilder/CustomTypeProvider.tsx +90 -0
- package/src/features/customTypes/customTypesBuilder/CustomTypesBuilderPage.tsx +46 -79
- package/src/features/customTypes/customTypesMessages.ts +4 -0
- package/src/features/slices/actions/addSlicesToSliceZone.ts +2 -7
- package/src/features/slices/actions/uploadSliceScreenshot.ts +45 -0
- package/src/features/slices/convertLegacySlice/ConvertLegacySliceAsNewVariationDialog.tsx +5 -5
- package/src/features/slices/convertLegacySlice/ConvertLegacySliceButton.tsx +4 -10
- package/src/features/slices/sliceBuilder/SliceBuilderProvider.tsx +110 -0
- package/src/features/slices/sliceBuilder/actions/deleteVariation.ts +8 -24
- package/src/features/slices/sliceBuilder/actions/renameVariation.ts +8 -24
- package/src/features/slices/sliceCards/SharedSliceCard.tsx +1 -0
- package/src/hooks/useCurrentSlice.tsx +4 -16
- package/src/hooks/useScreenshotChangesModal.ts +1 -0
- package/src/hooks/useServerState.ts +1 -58
- package/src/modules/availableCustomTypes/index.ts +8 -3
- package/src/modules/simulator/index.ts +0 -2
- package/src/modules/slices/index.ts +32 -25
- package/src/modules/slices/selector.ts +30 -0
- package/src/modules/useSliceMachineActions.ts +20 -270
- package/src/redux/reducer.ts +0 -4
- package/src/redux/saga.ts +0 -6
- package/src/redux/type.ts +0 -4
- package/stylelint.config.js +17 -0
- package/test/src/modules/availableCustomTypes/index.test.ts +8 -10
- package/test/src/modules/simulator.test.ts +0 -2
- package/lib/models/common/CustomType/group.ts +0 -80
- package/lib/models/common/Variation.ts +0 -100
- package/out/_next/static/3vLhj_JZ10e4rwC2sTZNQ/_buildManifest.js +0 -1
- package/out/_next/static/chunks/18539003-4460ccbfe3109578.js +0 -97
- package/out/_next/static/chunks/482-49264466566eac99.js +0 -1
- package/out/_next/static/chunks/550-c80fd46fb64d1eef.js +0 -1
- package/out/_next/static/chunks/80-7b8a97d0122ff74a.js +0 -1
- package/out/_next/static/chunks/840-163f8a1040e6820d.js +0 -1
- package/out/_next/static/chunks/904-fe1af089657fb0cc.js +0 -1
- package/out/_next/static/chunks/958-3d829456f4f5632c.js +0 -1
- package/out/_next/static/chunks/pages/_app-f88a66f6532a8e87.js +0 -458
- package/out/_next/static/chunks/pages/changelog-4d0f2f1222e403fe.js +0 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/simulator-7b17cb59d0db03b5.js +0 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-ef11594ce026b650.js +0 -1
- package/out/_next/static/chunks/pages/slices-884a936a9a062a65.js +0 -1
- package/out/_next/static/css/1bbf650dfd37ce69.css +0 -1
- package/out/_next/static/css/7d650bca12dc4061.css +0 -1
- package/out/_next/static/css/cb33580e45d01b59.css +0 -1
- package/postcss.config.js +0 -2
- package/src/components/Kbd/Kbd.css.ts +0 -16
- package/src/domain/__tests__/CustomTypeModel.test.ts +0 -247
- package/src/layouts/WithSlice.tsx +0 -26
- package/src/modules/screenshots/actions.ts +0 -21
- package/src/modules/screenshots/sagas.ts +0 -70
- package/src/modules/selectedCustomType/actions.ts +0 -147
- package/src/modules/selectedCustomType/index.ts +0 -11
- package/src/modules/selectedCustomType/reducer.ts +0 -287
- package/src/modules/selectedCustomType/sagas.ts +0 -72
- package/src/modules/selectedCustomType/selectors.ts +0 -33
- package/src/modules/selectedCustomType/stateHelpers.ts +0 -42
- package/src/modules/selectedCustomType/types.ts +0 -9
- package/src/modules/selectedSlice/actions.ts +0 -106
- package/src/modules/selectedSlice/reducer.ts +0 -175
- package/src/modules/selectedSlice/sagas.ts +0 -72
- package/src/modules/selectedSlice/selectors.ts +0 -55
- package/src/modules/selectedSlice/types.ts +0 -3
- package/src/modules/toaster/utils.tsx +0 -23
- package/test/lib/models/common/CustomType/sliceZone.test.ts +0 -49
- package/test/pages/custom-types.test.tsx +0 -625
- package/test/src/modules/selectedCustomType/__fixtures__/model.json +0 -119
- package/test/src/modules/selectedCustomType/reducer.test.ts +0 -322
- package/test/src/modules/selectedCustomType/sagas.test.ts +0 -89
- package/test/src/modules/selectedCustomType/selectors.test.ts +0 -54
- package/test/src/modules/selectedSlice/__fixtures__/mocks.json +0 -171
- package/test/src/modules/selectedSlice/__fixtures__/model.json +0 -35
- package/test/src/modules/selectedSlice/__testutils__/getRefreshStateCreatorPayloadData.ts +0 -72
- package/test/src/modules/selectedSlice/__testutils__/getSelectedSliceDummyData.ts +0 -30
- package/test/src/modules/selectedSlice/reducer.test.ts +0 -170
- package/test/src/modules/selectedSlice/sagas.test.ts +0 -82
- package/test/src/modules/toaster/utils.test.ts +0 -50
- /package/out/_next/static/{3vLhj_JZ10e4rwC2sTZNQ → QLcban0JdGEoFu6NgapR9}/_ssgManifest.js +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
._1nkpwww0{border-radius:3px}.kedahr2{height:240px}.kedahr3{height:320px}.kedahr6:focus-visible{box-shadow:0 0 0 4px rgba(123,101,220,.1)}.kedahr6[data-disabled]{opacity:var(--_7j49md3z)}.kedahr6:not([data-disabled]){cursor:var(--_7j49md3n)}.kedahr7{order:0}.kedahr4>.kedahr7{padding:calc(var(--_7j49md55) - var(--_7j49mdh))}.kedahr5>.kedahr7{background-color:var(--_7j49md1a);margin-inline:calc(var(--_7j49md53) - var(--_7j49mdh));margin-top:calc(var(--_7j49md53) - var(--_7j49mdh));padding:var(--_7j49md53)}.kedahr9:not([src]){visibility:hidden}.kedahra:before{content:"";background-color:var(--_7j49md1j);inset:var(--_7j49md4v);opacity:var(--_7j49md3x);position:absolute}.kedahr6:focus-visible .kedahra,.kedahr6:not([data-disabled]) .kedahr7:hover>.kedahra{visibility:visible}.kedahr6:not([data-disabled]) .kedahra:has(:focus-visible){visibility:visible}.kedahr4>.kedahrb{background-color:var(--_7j49md18)}.kedahr4>.kedahrb:not(:first-child){border-top-color:var(--_7j49md1d);border-top-style:inherit;border-top-width:inherit}.kedahrc{order:1}.kedahr4>.kedahrc{padding-left:calc(var(--_7j49md52) - var(--_7j49mdh));padding-right:calc(var(--_7j49md50) - var(--_7j49mdh))}.kedahr5>.kedahrc{padding-inline:calc(var(--_7j49md53) - var(--_7j49mdh))}.kedahrd{order:2}.kedahr4>.kedahrd{padding-inline:calc(var(--_7j49md52) - var(--_7j49mdh))}.kedahr5>.kedahrd{padding-inline:calc(var(--_7j49md53) - var(--_7j49mdh))}.kedahre{margin-bottom:calc((1.5rem - 1rem) / 2)}.kedahrf{background-color:#ebe7fe;color:#5746af}._18bjhbz0{max-width:498px;min-height:400px;background-color:var(--_7j49md18)}._18bjhbz1{background-size:cover;background-color:transparent;border-radius:var(--_7j49md3);border-style:var(--_7j49mdd);height:100%;max-width:100%}._18bjhbz1 ._18bjhbz3{padding:64px}._18bjhbz4{font-size:18px;font-weight:600;line-height:32px}._18bjhbz5{font-weight:400;line-height:24px}._18bjhbz1 ._18bjhbz5{max-width:464px;align-self:center}._18bjhbz1 ._18bjhbz6{justify-content:center}.ovkapw0:focus-visible{outline:none;text-decoration-line:underline}.ovkapw1{font-size:1.2rem;width:18px;height:18px}.ovkapw2{font-size:1rem;width:16px;height:16px}.ovkapw3{font-size:inherit;width:inherit;height:inherit}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
._1nkpwww0{border-radius:3px}.kedahr2{height:240px}.kedahr3{height:320px}.kedahr6:focus-visible{box-shadow:0 0 0 4px rgba(123,101,220,.1)}.kedahr6[data-disabled]{opacity:var(--_7j49md3z)}.kedahr6:not([data-disabled]){cursor:var(--_7j49md3n)}.kedahr7{order:0}.kedahr4>.kedahr7{padding:calc(var(--_7j49md55) - var(--_7j49mdh))}.kedahr5>.kedahr7{background-color:var(--_7j49md1a);margin-inline:calc(var(--_7j49md53) - var(--_7j49mdh));margin-top:calc(var(--_7j49md53) - var(--_7j49mdh));padding:var(--_7j49md53)}.kedahr9:not([src]){visibility:hidden}.kedahra:before{content:"";background-color:var(--_7j49md1j);inset:var(--_7j49md4v);opacity:var(--_7j49md3x);position:absolute}.kedahr6:focus-visible .kedahra,.kedahr6:not([data-disabled]) .kedahr7:hover>.kedahra{visibility:visible}.kedahr6:not([data-disabled]) .kedahra:has(:focus-visible){visibility:visible}.kedahr4>.kedahrb{background-color:var(--_7j49md18)}.kedahr4>.kedahrb:not(:first-child){border-top-color:var(--_7j49md1d);border-top-style:inherit;border-top-width:inherit}.kedahrc{order:1}.kedahr4>.kedahrc{padding-left:calc(var(--_7j49md52) - var(--_7j49mdh));padding-right:calc(var(--_7j49md50) - var(--_7j49mdh))}.kedahr5>.kedahrc{padding-inline:calc(var(--_7j49md53) - var(--_7j49mdh))}.kedahrd{order:2}.kedahr4>.kedahrd{padding-inline:calc(var(--_7j49md52) - var(--_7j49mdh))}.kedahr5>.kedahrd{padding-inline:calc(var(--_7j49md53) - var(--_7j49mdh))}.kedahre{margin-bottom:calc((1.5rem - 1rem) / 2)}.kedahrf{background-color:#ebe7fe;color:#5746af}
|
package/postcss.config.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { style } from "@vanilla-extract/css";
|
|
2
|
-
import { colors, sprinkles } from "@prismicio/editor-ui";
|
|
3
|
-
|
|
4
|
-
export const root = style([
|
|
5
|
-
sprinkles({
|
|
6
|
-
paddingInline: 4,
|
|
7
|
-
color: colors.grey11,
|
|
8
|
-
backgroundColor: colors.grey2,
|
|
9
|
-
borderColor: colors.grey6,
|
|
10
|
-
borderStyle: "solid",
|
|
11
|
-
borderWidth: 1,
|
|
12
|
-
}),
|
|
13
|
-
{
|
|
14
|
-
borderRadius: "3px",
|
|
15
|
-
},
|
|
16
|
-
]);
|
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
import { describe, expect } from "vitest";
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
CustomType,
|
|
5
|
-
DynamicSection,
|
|
6
|
-
} from "@prismicio/types-internal/lib/customtypes";
|
|
7
|
-
|
|
8
|
-
import * as CustomTypeModel from "../customType";
|
|
9
|
-
|
|
10
|
-
describe("CustomTypeModel test suite", () => {
|
|
11
|
-
const mainSection: DynamicSection = {
|
|
12
|
-
uid: {
|
|
13
|
-
config: {
|
|
14
|
-
label: "MainSectionField",
|
|
15
|
-
},
|
|
16
|
-
type: "UID",
|
|
17
|
-
},
|
|
18
|
-
slices: {
|
|
19
|
-
type: "Slices",
|
|
20
|
-
fieldset: "Slice Zone",
|
|
21
|
-
config: {
|
|
22
|
-
choices: {
|
|
23
|
-
hero_banner: {
|
|
24
|
-
type: "SharedSlice",
|
|
25
|
-
},
|
|
26
|
-
promo_section_image_tiles: {
|
|
27
|
-
type: "SharedSlice",
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
const anotherSection: DynamicSection = {
|
|
34
|
-
uid: {
|
|
35
|
-
config: {
|
|
36
|
-
label: "AnotherSectionField",
|
|
37
|
-
},
|
|
38
|
-
type: "UID",
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
const mockCustomType: CustomType = {
|
|
42
|
-
format: "custom",
|
|
43
|
-
id: "id",
|
|
44
|
-
json: {
|
|
45
|
-
mainSection,
|
|
46
|
-
anotherSection,
|
|
47
|
-
},
|
|
48
|
-
label: "lama",
|
|
49
|
-
repeatable: true,
|
|
50
|
-
status: true,
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
it("getSectionEntries should return the sections entries", () => {
|
|
54
|
-
expect(CustomTypeModel.getSectionEntries(mockCustomType)).toEqual([
|
|
55
|
-
["mainSection", mainSection],
|
|
56
|
-
["anotherSection", anotherSection],
|
|
57
|
-
]);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it("getSectionEntries should return an empty array if there are no sections", () => {
|
|
61
|
-
expect(
|
|
62
|
-
CustomTypeModel.getSectionEntries({
|
|
63
|
-
...mockCustomType,
|
|
64
|
-
json: {},
|
|
65
|
-
}),
|
|
66
|
-
).toEqual([]);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it("getMainSectionEntry should return the first section even if not named Main", () => {
|
|
70
|
-
expect(CustomTypeModel.getMainSectionEntry(mockCustomType)).toEqual([
|
|
71
|
-
"mainSection",
|
|
72
|
-
mainSection,
|
|
73
|
-
]);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it("getMainSectionEntry should return undefined if there is are sections", () => {
|
|
77
|
-
expect(
|
|
78
|
-
CustomTypeModel.getMainSectionEntry({
|
|
79
|
-
...mockCustomType,
|
|
80
|
-
json: {},
|
|
81
|
-
}),
|
|
82
|
-
).toEqual(undefined);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it("getSection should return the section matching the key", () => {
|
|
86
|
-
expect(
|
|
87
|
-
CustomTypeModel.getSection(mockCustomType, "anotherSection"),
|
|
88
|
-
).toEqual(anotherSection);
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it("getSection should return undefined if there are no sections", () => {
|
|
92
|
-
expect(
|
|
93
|
-
CustomTypeModel.getSection(
|
|
94
|
-
{
|
|
95
|
-
...mockCustomType,
|
|
96
|
-
json: {},
|
|
97
|
-
},
|
|
98
|
-
"mainSection",
|
|
99
|
-
),
|
|
100
|
-
).toEqual(undefined);
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it("getSectionSliceZoneConfig should return the config of the given section", () => {
|
|
104
|
-
expect(
|
|
105
|
-
CustomTypeModel.getSectionSliceZoneConfig(mockCustomType, "mainSection"),
|
|
106
|
-
).toEqual({
|
|
107
|
-
choices: {
|
|
108
|
-
hero_banner: {
|
|
109
|
-
type: "SharedSlice",
|
|
110
|
-
},
|
|
111
|
-
promo_section_image_tiles: {
|
|
112
|
-
type: "SharedSlice",
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
it("getSectionSliceZoneConfig should return undefined if there are no sections", () => {
|
|
119
|
-
expect(
|
|
120
|
-
CustomTypeModel.getSectionSliceZoneConfig(
|
|
121
|
-
{
|
|
122
|
-
...mockCustomType,
|
|
123
|
-
json: {},
|
|
124
|
-
},
|
|
125
|
-
"mainSection",
|
|
126
|
-
),
|
|
127
|
-
).toEqual(undefined);
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
it("findNextSectionSliceZoneKey should return 'slices'", () => {
|
|
131
|
-
expect(
|
|
132
|
-
CustomTypeModel.findNextSectionSliceZoneKey(
|
|
133
|
-
{
|
|
134
|
-
...mockCustomType,
|
|
135
|
-
json: {
|
|
136
|
-
anotherSection: {},
|
|
137
|
-
},
|
|
138
|
-
},
|
|
139
|
-
"anotherSection",
|
|
140
|
-
),
|
|
141
|
-
).toEqual("slices");
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
it("findNextSectionSliceZoneKey should return 'slices1'", () => {
|
|
145
|
-
expect(
|
|
146
|
-
CustomTypeModel.findNextSectionSliceZoneKey(
|
|
147
|
-
mockCustomType,
|
|
148
|
-
"anotherSection",
|
|
149
|
-
),
|
|
150
|
-
).toEqual("slices1");
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
it("findNextSectionSliceZoneKey should return 'slices2'", () => {
|
|
154
|
-
expect(
|
|
155
|
-
CustomTypeModel.findNextSectionSliceZoneKey(
|
|
156
|
-
{
|
|
157
|
-
...mockCustomType,
|
|
158
|
-
json: {
|
|
159
|
-
mainSection,
|
|
160
|
-
SecondSection: {
|
|
161
|
-
slices1: {
|
|
162
|
-
type: "Slices",
|
|
163
|
-
},
|
|
164
|
-
},
|
|
165
|
-
anotherSection,
|
|
166
|
-
},
|
|
167
|
-
},
|
|
168
|
-
"anotherSection",
|
|
169
|
-
),
|
|
170
|
-
).toEqual("slices2");
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
it("findNextSectionSliceZoneKey should return 'slices3'", () => {
|
|
174
|
-
expect(
|
|
175
|
-
CustomTypeModel.findNextSectionSliceZoneKey(
|
|
176
|
-
{
|
|
177
|
-
...mockCustomType,
|
|
178
|
-
json: {
|
|
179
|
-
mainSection,
|
|
180
|
-
SecondSection: {
|
|
181
|
-
slices2: {
|
|
182
|
-
type: "Slices",
|
|
183
|
-
},
|
|
184
|
-
},
|
|
185
|
-
anotherSection,
|
|
186
|
-
},
|
|
187
|
-
},
|
|
188
|
-
"anotherSection",
|
|
189
|
-
),
|
|
190
|
-
).toEqual("slices3");
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
it("createSectionSliceZone should return the given custom type with a slice zone for given section", () => {
|
|
194
|
-
expect(
|
|
195
|
-
CustomTypeModel.createSectionSliceZone(mockCustomType, "anotherSection"),
|
|
196
|
-
).toEqual({
|
|
197
|
-
...mockCustomType,
|
|
198
|
-
json: {
|
|
199
|
-
...mockCustomType.json,
|
|
200
|
-
anotherSection: {
|
|
201
|
-
...mockCustomType.json.anotherSection,
|
|
202
|
-
slices1: {
|
|
203
|
-
type: "Slices",
|
|
204
|
-
fieldset: "Slice Zone",
|
|
205
|
-
},
|
|
206
|
-
},
|
|
207
|
-
},
|
|
208
|
-
});
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
it("createSectionSliceZone should return the same custom type if slice zone already exist for given section", () => {
|
|
212
|
-
expect(
|
|
213
|
-
CustomTypeModel.createSectionSliceZone(mockCustomType, "mainSection"),
|
|
214
|
-
).toEqual(mockCustomType);
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
it("convertToPageType should convert the given custom type", () => {
|
|
218
|
-
expect(CustomTypeModel.convertToPageType(mockCustomType)).toEqual({
|
|
219
|
-
...mockCustomType,
|
|
220
|
-
format: "page",
|
|
221
|
-
});
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
it("convertToPageType should convert the given custom type with a slice zone for Main section when it doesn't exist", () => {
|
|
225
|
-
expect(
|
|
226
|
-
CustomTypeModel.convertToPageType({
|
|
227
|
-
...mockCustomType,
|
|
228
|
-
json: {
|
|
229
|
-
mainSection: {},
|
|
230
|
-
anotherSection,
|
|
231
|
-
},
|
|
232
|
-
}),
|
|
233
|
-
).toEqual({
|
|
234
|
-
...mockCustomType,
|
|
235
|
-
json: {
|
|
236
|
-
mainSection: {
|
|
237
|
-
slices: {
|
|
238
|
-
type: "Slices",
|
|
239
|
-
fieldset: "Slice Zone",
|
|
240
|
-
},
|
|
241
|
-
},
|
|
242
|
-
anotherSection,
|
|
243
|
-
},
|
|
244
|
-
format: "page",
|
|
245
|
-
});
|
|
246
|
-
});
|
|
247
|
-
});
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode } from "react";
|
|
2
|
-
import { ComponentUI } from "@lib/models/common/ComponentUI";
|
|
3
|
-
import { VariationSM } from "@lib/models/common/Slice";
|
|
4
|
-
import useCurrentSlice from "@src/hooks/useCurrentSlice";
|
|
5
|
-
import { AppProps } from "next/app";
|
|
6
|
-
|
|
7
|
-
import { replace } from "connected-next-router";
|
|
8
|
-
|
|
9
|
-
export type ComponentWithSliceProps = React.FC<{
|
|
10
|
-
slice: ComponentUI;
|
|
11
|
-
variation: VariationSM;
|
|
12
|
-
}>;
|
|
13
|
-
|
|
14
|
-
export const createComponentWithSlice = (C: ComponentWithSliceProps) => {
|
|
15
|
-
const Wrapper: React.FC<{ pageProps?: AppProps }> & {
|
|
16
|
-
CustomLayout?: React.FC<{ children: ReactNode }>;
|
|
17
|
-
} = ({ pageProps }) => {
|
|
18
|
-
const { slice, variation } = useCurrentSlice();
|
|
19
|
-
if (!slice || !variation) {
|
|
20
|
-
void replace("/");
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
return <C slice={slice} variation={variation} {...pageProps} />;
|
|
24
|
-
};
|
|
25
|
-
return Wrapper;
|
|
26
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { ActionType, createAsyncAction } from "typesafe-actions";
|
|
2
|
-
import type { ScreenshotGenerationMethod } from "@lib/models/common/Screenshots";
|
|
3
|
-
import { ComponentUI, ScreenshotUI } from "@lib/models/common/ComponentUI";
|
|
4
|
-
|
|
5
|
-
export type SelectedSliceActions = ActionType<
|
|
6
|
-
typeof generateSliceCustomScreenshotCreator
|
|
7
|
-
>;
|
|
8
|
-
|
|
9
|
-
export const generateSliceCustomScreenshotCreator = createAsyncAction(
|
|
10
|
-
"SLICE/GENERATE_CUSTOM_SCREENSHOT.REQUEST",
|
|
11
|
-
"SLICE/GENERATE_CUSTOM_SCREENSHOT.RESPONSE",
|
|
12
|
-
"SLICE/GENERATE_CUSTOM_SCREENSHOT.FAILURE",
|
|
13
|
-
)<
|
|
14
|
-
{
|
|
15
|
-
variationId: string;
|
|
16
|
-
component: ComponentUI;
|
|
17
|
-
file: Blob;
|
|
18
|
-
method: ScreenshotGenerationMethod;
|
|
19
|
-
},
|
|
20
|
-
{ variationId: string; screenshot: ScreenshotUI; component: ComponentUI }
|
|
21
|
-
>();
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
call,
|
|
3
|
-
fork,
|
|
4
|
-
takeLatest,
|
|
5
|
-
put,
|
|
6
|
-
SagaReturnType,
|
|
7
|
-
} from "redux-saga/effects";
|
|
8
|
-
import { getType } from "typesafe-actions";
|
|
9
|
-
import { withLoader } from "../loading";
|
|
10
|
-
import { LoadingKeysEnum } from "../loading/types";
|
|
11
|
-
import { generateSliceCustomScreenshotCreator } from "./actions";
|
|
12
|
-
import { generateSliceCustomScreenshot, telemetry } from "@src/apiClient";
|
|
13
|
-
import { openToasterCreator, ToasterType } from "@src/modules/toaster";
|
|
14
|
-
|
|
15
|
-
export function* generateSliceCustomScreenshotSaga({
|
|
16
|
-
payload,
|
|
17
|
-
}: ReturnType<typeof generateSliceCustomScreenshotCreator.request>) {
|
|
18
|
-
const { variationId, component, file, method } = payload;
|
|
19
|
-
try {
|
|
20
|
-
const form = new FormData();
|
|
21
|
-
form.append("file", file);
|
|
22
|
-
form.append("libraryName", component.from);
|
|
23
|
-
form.append("sliceName", component.model.name);
|
|
24
|
-
form.append("variationId", variationId);
|
|
25
|
-
const response = (yield call(generateSliceCustomScreenshot, {
|
|
26
|
-
libraryName: component.from,
|
|
27
|
-
sliceId: component.model.id,
|
|
28
|
-
variationId,
|
|
29
|
-
file,
|
|
30
|
-
})) as SagaReturnType<typeof generateSliceCustomScreenshot>;
|
|
31
|
-
|
|
32
|
-
if (!response?.url) {
|
|
33
|
-
throw Error("No screenshot saved");
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
void telemetry.track({ event: "screenshot-taken", type: "custom", method });
|
|
37
|
-
|
|
38
|
-
yield put(
|
|
39
|
-
generateSliceCustomScreenshotCreator.success({
|
|
40
|
-
variationId,
|
|
41
|
-
screenshot: {
|
|
42
|
-
url: response.url,
|
|
43
|
-
},
|
|
44
|
-
component,
|
|
45
|
-
}),
|
|
46
|
-
);
|
|
47
|
-
} catch (e) {
|
|
48
|
-
yield put(
|
|
49
|
-
openToasterCreator({
|
|
50
|
-
content: "Internal Error: Custom screenshot not saved",
|
|
51
|
-
type: ToasterType.ERROR,
|
|
52
|
-
}),
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function* watchGenerateSliceCustomScreenshot() {
|
|
58
|
-
yield takeLatest(
|
|
59
|
-
getType(generateSliceCustomScreenshotCreator.request),
|
|
60
|
-
withLoader(
|
|
61
|
-
generateSliceCustomScreenshotSaga,
|
|
62
|
-
LoadingKeysEnum.GENERATE_SLICE_CUSTOM_SCREENSHOT,
|
|
63
|
-
),
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// Saga Exports
|
|
68
|
-
export function* screenshotsSagas() {
|
|
69
|
-
yield fork(watchGenerateSliceCustomScreenshot);
|
|
70
|
-
}
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import { ActionType, createAction, createAsyncAction } from "typesafe-actions";
|
|
2
|
-
import { NestableWidget } from "@prismicio/types-internal/lib/customtypes";
|
|
3
|
-
import { CustomTypeSM, TabField } from "@lib/models/common/CustomType";
|
|
4
|
-
|
|
5
|
-
export type SelectedCustomTypeActions =
|
|
6
|
-
| ActionType<typeof initCustomTypeStoreCreator>
|
|
7
|
-
| ActionType<typeof cleanupCustomTypeStoreCreator>
|
|
8
|
-
| ActionType<typeof saveCustomTypeCreator>
|
|
9
|
-
| ActionType<typeof createTabCreator>
|
|
10
|
-
| ActionType<typeof updateTabCreator>
|
|
11
|
-
| ActionType<typeof deleteTabCreator>
|
|
12
|
-
| ActionType<typeof addFieldCreator>
|
|
13
|
-
| ActionType<typeof deleteFieldCreator>
|
|
14
|
-
| ActionType<typeof replaceFieldCreator>
|
|
15
|
-
| ActionType<typeof reorderFieldCreator>
|
|
16
|
-
| ActionType<typeof createSliceZoneCreator>
|
|
17
|
-
| ActionType<typeof deleteSliceZoneCreator>
|
|
18
|
-
| ActionType<typeof addFieldIntoGroupCreator>
|
|
19
|
-
| ActionType<typeof replaceFieldIntoGroupCreator>
|
|
20
|
-
| ActionType<typeof reorderFieldIntoGroupCreator>
|
|
21
|
-
| ActionType<typeof deleteFieldIntoGroupCreator>
|
|
22
|
-
| ActionType<typeof deleteSharedSliceCreator>
|
|
23
|
-
| ActionType<typeof renameSelectedCustomTypeLabel>;
|
|
24
|
-
|
|
25
|
-
export const initCustomTypeStoreCreator = createAction("CUSTOM_TYPE/INIT")<{
|
|
26
|
-
model: CustomTypeSM;
|
|
27
|
-
remoteModel: CustomTypeSM | undefined;
|
|
28
|
-
}>();
|
|
29
|
-
|
|
30
|
-
export const cleanupCustomTypeStoreCreator = createAction(
|
|
31
|
-
"CUSTOM_TYPE/CLEANUP",
|
|
32
|
-
)();
|
|
33
|
-
|
|
34
|
-
// Async actions
|
|
35
|
-
export const saveCustomTypeCreator = createAsyncAction(
|
|
36
|
-
"CUSTOM_TYPE/SAVE.REQUEST",
|
|
37
|
-
"CUSTOM_TYPE/SAVE.RESPONSE",
|
|
38
|
-
"CUSTOM_TYPE/SAVE.FAILURE",
|
|
39
|
-
)<undefined, { customType: CustomTypeSM }>();
|
|
40
|
-
|
|
41
|
-
// Tab actions
|
|
42
|
-
export const createTabCreator = createAction("CUSTOM_TYPE/CREATE_TAB")<{
|
|
43
|
-
tabId: string;
|
|
44
|
-
}>();
|
|
45
|
-
|
|
46
|
-
export const updateTabCreator = createAction("CUSTOM_TYPE/UPDATE_TAB")<{
|
|
47
|
-
tabId: string;
|
|
48
|
-
newTabId: string;
|
|
49
|
-
}>();
|
|
50
|
-
|
|
51
|
-
export const deleteTabCreator = createAction("CUSTOM_TYPE/DELETE_TAB")<{
|
|
52
|
-
tabId: string;
|
|
53
|
-
}>();
|
|
54
|
-
|
|
55
|
-
// Field actions
|
|
56
|
-
export const addFieldCreator = createAction("CUSTOM_TYPE/ADD_FIELD")<{
|
|
57
|
-
tabId: string;
|
|
58
|
-
fieldId: string;
|
|
59
|
-
field: TabField;
|
|
60
|
-
}>();
|
|
61
|
-
|
|
62
|
-
export const deleteFieldCreator = createAction("CUSTOM_TYPE/DELETE_FIELD")<{
|
|
63
|
-
tabId: string;
|
|
64
|
-
fieldId: string;
|
|
65
|
-
}>();
|
|
66
|
-
|
|
67
|
-
export const replaceFieldCreator = createAction("CUSTOM_TYPE/REPLACE_FIELD")<{
|
|
68
|
-
tabId: string;
|
|
69
|
-
previousFieldId: string;
|
|
70
|
-
newFieldId: string;
|
|
71
|
-
value: TabField;
|
|
72
|
-
}>();
|
|
73
|
-
|
|
74
|
-
export const reorderFieldCreator = createAction("CUSTOM_TYPE/REORDER_FIELD")<{
|
|
75
|
-
tabId: string;
|
|
76
|
-
start: number;
|
|
77
|
-
end: number;
|
|
78
|
-
}>();
|
|
79
|
-
|
|
80
|
-
// Slice zone actions
|
|
81
|
-
export const createSliceZoneCreator = createAction(
|
|
82
|
-
"CUSTOM_TYPE/CREATE_SLICE_ZONE",
|
|
83
|
-
)<{
|
|
84
|
-
tabId: string;
|
|
85
|
-
}>();
|
|
86
|
-
|
|
87
|
-
export const deleteSliceZoneCreator = createAction(
|
|
88
|
-
"CUSTOM_TYPE/DELETE_SLICE_ZONE",
|
|
89
|
-
)<{
|
|
90
|
-
tabId: string;
|
|
91
|
-
}>();
|
|
92
|
-
|
|
93
|
-
export type ReplaceSharedSliceCreatorPayload = {
|
|
94
|
-
tabId: string;
|
|
95
|
-
sliceKeys: string[];
|
|
96
|
-
preserve: string[];
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
export const deleteSharedSliceCreator = createAction(
|
|
100
|
-
"CUSTOM_TYPE/DELETE_SHARED_SLICE",
|
|
101
|
-
)<{
|
|
102
|
-
tabId: string;
|
|
103
|
-
sliceId: string;
|
|
104
|
-
}>();
|
|
105
|
-
|
|
106
|
-
export const renameSelectedCustomTypeLabel = createAction(
|
|
107
|
-
"CUSTOM_TYPE/RENAME_CUSTOM_TYPE",
|
|
108
|
-
)<{
|
|
109
|
-
newLabel: string;
|
|
110
|
-
}>();
|
|
111
|
-
|
|
112
|
-
// Group actions (can be grouped into the field actions probably)
|
|
113
|
-
export const addFieldIntoGroupCreator = createAction(
|
|
114
|
-
"CUSTOM_TYPE/GROUP/ADD_FIELD",
|
|
115
|
-
)<{
|
|
116
|
-
tabId: string;
|
|
117
|
-
groupId: string;
|
|
118
|
-
fieldId: string;
|
|
119
|
-
field: NestableWidget;
|
|
120
|
-
}>();
|
|
121
|
-
|
|
122
|
-
export const replaceFieldIntoGroupCreator = createAction(
|
|
123
|
-
"CUSTOM_TYPE/GROUP/REPLACE_FIELD",
|
|
124
|
-
)<{
|
|
125
|
-
tabId: string;
|
|
126
|
-
groupId: string;
|
|
127
|
-
previousFieldId: string;
|
|
128
|
-
newFieldId: string;
|
|
129
|
-
value: NestableWidget;
|
|
130
|
-
}>();
|
|
131
|
-
|
|
132
|
-
export const reorderFieldIntoGroupCreator = createAction(
|
|
133
|
-
"CUSTOM_TYPE/GROUP/REORDER_FIELD",
|
|
134
|
-
)<{
|
|
135
|
-
tabId: string;
|
|
136
|
-
groupId: string;
|
|
137
|
-
start: number;
|
|
138
|
-
end: number;
|
|
139
|
-
}>();
|
|
140
|
-
|
|
141
|
-
export const deleteFieldIntoGroupCreator = createAction(
|
|
142
|
-
"CUSTOM_TYPE/GROUP/DELETE_FIELD",
|
|
143
|
-
)<{
|
|
144
|
-
tabId: string;
|
|
145
|
-
groupId: string;
|
|
146
|
-
fieldId: string;
|
|
147
|
-
}>();
|