slice-machine-ui 1.23.2-beta.3 → 1.23.2-beta.4
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/Forms/CreateCustomTypeModal/CreateCustomTypeModal.tsx +61 -38
- package/components/Forms/RenameCustomTypeModal/RenameCustomTypeModal.tsx +2 -2
- package/components/Navigation/ChangesListItem.tsx +14 -32
- package/out/404.html +1 -1
- package/out/_next/static/{RRBm5bm2F__Ws0vsvXhN6 → GqPZYfMQrQUPwvgI_rvdq}/_buildManifest.js +1 -1
- package/out/_next/static/chunks/{183-aab7066c73ebde44.js → 183-4feb6bb3eddbc768.js} +1 -1
- package/out/_next/static/chunks/{318-2112803ca34b2f49.js → 318-34a2dea7cfd4661d.js} +1 -1
- package/out/_next/static/chunks/727-c5028806448c4387.js +1 -0
- package/out/_next/static/chunks/731-341869976a48a09a.js +1 -0
- package/out/_next/static/chunks/{904-9a4c1264727ae89a.js → 904-833eed675f19ab60.js} +1 -1
- package/out/_next/static/chunks/pages/{_app-9f3513533bb2dfb8.js → _app-4a63c0e108026c4d.js} +2 -2
- package/out/_next/static/chunks/pages/{changes-2a976f9efeb719aa.js → changes-92c84f6cac0285fd.js} +1 -1
- package/out/_next/static/chunks/pages/index-ca194b18d0e3930d.js +1 -0
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-2d3d84de925b289e.js +1 -0
- package/out/changelog.html +1 -1
- package/out/changes.html +1 -1
- package/out/custom-types/[customTypeId].html +1 -1
- package/out/custom-types.html +1 -1
- package/out/index.html +1 -1
- package/out/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 +3 -3
- package/src/domain/__tests__/customType.test.ts +179 -0
- package/src/domain/customType.ts +110 -2
- package/src/features/customTypes/PageTypeOnboarding.tsx +21 -26
- package/src/features/customTypes/actions/convertCustomToPageType.ts +14 -10
- package/src/features/customTypes/actions/createCustomType.ts +69 -0
- package/src/features/customTypes/actions/deleteCustomType.ts +13 -3
- package/src/features/customTypes/actions/renameCustomType.ts +10 -4
- package/src/features/customTypes/customTypesBuilder/CustomTypesBuilderPage.tsx +3 -1
- package/src/features/customTypes/customTypesTable/CustomTypesTable.tsx +8 -8
- package/src/features/customTypes/customTypesTable/CustomTypesTablePage.tsx +18 -17
- package/src/modules/availableCustomTypes/index.ts +26 -132
- package/src/modules/loading/types.ts +0 -3
- package/src/modules/modal/types.ts +0 -1
- package/src/modules/useSliceMachineActions.ts +72 -78
- package/src/modules/userContext/index.ts +3 -3
- package/src/redux/saga.ts +0 -2
- package/test/src/modules/availableCustomTypes/index.test.ts +4 -156
- package/out/_next/static/chunks/727-3a3bc32518778317.js +0 -1
- package/out/_next/static/chunks/731-501990ebe6a71b32.js +0 -1
- package/out/_next/static/chunks/pages/index-64cfb8b0948ba8ef.js +0 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-b2a9d773ce5d7739.js +0 -1
- package/src/features/customTypes/__tests__/createCustomType.test.ts +0 -159
- package/src/features/customTypes/customTypesTable/createCustomType.ts +0 -107
- package/test/components/CreateCustomTypeModal.test.tsx +0 -73
- /package/out/_next/static/{RRBm5bm2F__Ws0vsvXhN6 → GqPZYfMQrQUPwvgI_rvdq}/_ssgManifest.js +0 -0
|
@@ -2,25 +2,28 @@ import { SetStateAction, useState } from "react";
|
|
|
2
2
|
import { Box } from "theme-ui";
|
|
3
3
|
import { FormikErrors } from "formik";
|
|
4
4
|
import { useSelector } from "react-redux";
|
|
5
|
+
import { useRouter } from "next/router";
|
|
5
6
|
|
|
6
7
|
import ModalFormCard from "@components/ModalFormCard";
|
|
7
|
-
import { InputBox } from "../components/InputBox";
|
|
8
|
-
import { SelectRepeatable } from "../components/SelectRepeatable";
|
|
9
8
|
import useSliceMachineActions from "@src/modules/useSliceMachineActions";
|
|
10
9
|
import { SliceMachineStoreType } from "@src/redux/type";
|
|
11
10
|
import {
|
|
12
11
|
selectAllCustomTypeIds,
|
|
13
12
|
selectAllCustomTypeLabels,
|
|
14
13
|
} from "@src/modules/availableCustomTypes";
|
|
15
|
-
import { isModalOpen } from "@src/modules/modal";
|
|
16
|
-
import { ModalKeysEnum } from "@src/modules/modal/types";
|
|
17
|
-
import { isLoading } from "@src/modules/loading";
|
|
18
|
-
import { LoadingKeysEnum } from "@src/modules/loading/types";
|
|
19
|
-
import { telemetry } from "@src/apiClient";
|
|
20
14
|
import { slugify } from "@lib/utils/str";
|
|
21
15
|
import { API_ID_REGEX } from "@lib/consts";
|
|
22
16
|
import type { CustomTypeFormat } from "@slicemachine/manager";
|
|
23
17
|
import { CUSTOM_TYPES_MESSAGES } from "@src/features/customTypes/customTypesMessages";
|
|
18
|
+
import {
|
|
19
|
+
CustomTypeOrigin,
|
|
20
|
+
createCustomType,
|
|
21
|
+
} from "@src/features/customTypes/actions/createCustomType";
|
|
22
|
+
import { CUSTOM_TYPES_CONFIG } from "@src/features/customTypes/customTypesConfig";
|
|
23
|
+
import { getFormat } from "@src/domain/customType";
|
|
24
|
+
|
|
25
|
+
import { InputBox } from "../components/InputBox";
|
|
26
|
+
import { SelectRepeatable } from "../components/SelectRepeatable";
|
|
24
27
|
|
|
25
28
|
interface FormValues {
|
|
26
29
|
id: string;
|
|
@@ -30,46 +33,64 @@ interface FormValues {
|
|
|
30
33
|
|
|
31
34
|
type CreateCustomTypeModalProps = {
|
|
32
35
|
format: CustomTypeFormat;
|
|
33
|
-
|
|
36
|
+
isCreating: boolean;
|
|
37
|
+
isOpen: boolean;
|
|
38
|
+
origin?: CustomTypeOrigin;
|
|
39
|
+
onCreateChange: (isCreating: boolean) => void;
|
|
40
|
+
onOpenChange: (isOpen: boolean) => void;
|
|
34
41
|
};
|
|
35
42
|
|
|
36
43
|
export const CreateCustomTypeModal: React.FC<CreateCustomTypeModalProps> = ({
|
|
37
44
|
format,
|
|
45
|
+
isCreating,
|
|
46
|
+
isOpen,
|
|
38
47
|
origin = "table",
|
|
48
|
+
onCreateChange,
|
|
49
|
+
onOpenChange,
|
|
39
50
|
}) => {
|
|
40
|
-
const {
|
|
41
|
-
|
|
42
|
-
const {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
customTypeIds: selectAllCustomTypeIds(store),
|
|
49
|
-
customTypeLabels: selectAllCustomTypeLabels(store),
|
|
50
|
-
isCreateCustomTypeModalOpen: isModalOpen(
|
|
51
|
-
store,
|
|
52
|
-
ModalKeysEnum.CREATE_CUSTOM_TYPE,
|
|
53
|
-
),
|
|
54
|
-
isCreatingCustomType: isLoading(store, LoadingKeysEnum.CREATE_CUSTOM_TYPE),
|
|
55
|
-
}));
|
|
51
|
+
const { createCustomTypeSuccess } = useSliceMachineActions();
|
|
52
|
+
|
|
53
|
+
const { customTypeIds, customTypeLabels } = useSelector(
|
|
54
|
+
(store: SliceMachineStoreType) => ({
|
|
55
|
+
customTypeIds: selectAllCustomTypeIds(store),
|
|
56
|
+
customTypeLabels: selectAllCustomTypeLabels(store),
|
|
57
|
+
}),
|
|
58
|
+
);
|
|
56
59
|
const customTypesMessages = CUSTOM_TYPES_MESSAGES[format];
|
|
57
60
|
const [isIdFieldPristine, setIsIdFieldPristine] = useState(true);
|
|
61
|
+
const router = useRouter();
|
|
58
62
|
|
|
59
|
-
const
|
|
60
|
-
|
|
63
|
+
const onSubmit = async ({ id, label, repeatable }: FormValues) => {
|
|
64
|
+
onCreateChange(true);
|
|
61
65
|
|
|
62
|
-
|
|
63
|
-
event: "custom-type:created",
|
|
64
|
-
id,
|
|
65
|
-
name,
|
|
66
|
+
await createCustomType({
|
|
66
67
|
format,
|
|
67
|
-
|
|
68
|
+
id,
|
|
69
|
+
label,
|
|
68
70
|
origin,
|
|
71
|
+
repeatable,
|
|
72
|
+
onSuccess: async (newCustomType) => {
|
|
73
|
+
createCustomTypeSuccess(newCustomType);
|
|
74
|
+
|
|
75
|
+
const format = getFormat(newCustomType);
|
|
76
|
+
const customTypesConfig = CUSTOM_TYPES_CONFIG[format];
|
|
77
|
+
|
|
78
|
+
setIsIdFieldPristine(true);
|
|
79
|
+
|
|
80
|
+
await router.push({
|
|
81
|
+
pathname: customTypesConfig.getBuilderPagePathname(id),
|
|
82
|
+
query:
|
|
83
|
+
newCustomType.format === "page"
|
|
84
|
+
? {
|
|
85
|
+
newPageType: true,
|
|
86
|
+
}
|
|
87
|
+
: undefined,
|
|
88
|
+
});
|
|
89
|
+
},
|
|
69
90
|
});
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
91
|
+
|
|
92
|
+
onCreateChange(false);
|
|
93
|
+
onOpenChange(false);
|
|
73
94
|
};
|
|
74
95
|
|
|
75
96
|
const handleLabelChange = (
|
|
@@ -106,16 +127,18 @@ export const CreateCustomTypeModal: React.FC<CreateCustomTypeModalProps> = ({
|
|
|
106
127
|
return (
|
|
107
128
|
<ModalFormCard
|
|
108
129
|
dataCy="create-ct-modal"
|
|
109
|
-
isOpen={
|
|
130
|
+
isOpen={isOpen}
|
|
110
131
|
widthInPx="530px"
|
|
111
132
|
formId="create-custom-type"
|
|
112
133
|
buttonLabel={"Create"}
|
|
113
134
|
close={() => {
|
|
114
|
-
|
|
135
|
+
onOpenChange(false);
|
|
115
136
|
setIsIdFieldPristine(true);
|
|
116
137
|
}}
|
|
117
|
-
onSubmit={
|
|
118
|
-
|
|
138
|
+
onSubmit={(values) => {
|
|
139
|
+
void onSubmit(values);
|
|
140
|
+
}}
|
|
141
|
+
isLoading={isCreating}
|
|
119
142
|
initialValues={{
|
|
120
143
|
repeatable: true,
|
|
121
144
|
id: "",
|
|
@@ -31,7 +31,7 @@ export const RenameCustomTypeModal: React.FC<RenameCustomTypeModalProps> = ({
|
|
|
31
31
|
}) => {
|
|
32
32
|
const customTypeName = customType?.label ?? "";
|
|
33
33
|
const customTypeId = customType?.id ?? "";
|
|
34
|
-
const {
|
|
34
|
+
const { renameCustomTypeSuccess } = useSliceMachineActions();
|
|
35
35
|
|
|
36
36
|
const [isRenaming, setIsRenaming] = useState(false);
|
|
37
37
|
|
|
@@ -46,7 +46,7 @@ export const RenameCustomTypeModal: React.FC<RenameCustomTypeModalProps> = ({
|
|
|
46
46
|
await renameCustomType({
|
|
47
47
|
model: customType,
|
|
48
48
|
newLabel: values.customTypeName,
|
|
49
|
-
onSuccess:
|
|
49
|
+
onSuccess: renameCustomTypeSuccess,
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
setIsRenaming(false);
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import { type FC
|
|
1
|
+
import { type FC } from "react";
|
|
2
2
|
import Link from "next/link";
|
|
3
3
|
import { useRouter } from "next/router";
|
|
4
|
-
import { SliceMachineStoreType } from "@src/redux/type";
|
|
5
|
-
import { useSelector } from "react-redux";
|
|
6
4
|
|
|
7
5
|
import { SideNavLink, SideNavListItem } from "@src/components/SideNav";
|
|
8
6
|
import { RadarIcon } from "@src/icons/RadarIcon";
|
|
9
|
-
import { isLoading } from "@src/modules/loading";
|
|
10
|
-
import { LoadingKeysEnum } from "@src/modules/loading/types";
|
|
11
7
|
import {
|
|
12
8
|
HoverCard,
|
|
13
9
|
HoverCardCloseButton,
|
|
@@ -15,11 +11,8 @@ import {
|
|
|
15
11
|
HoverCardMedia,
|
|
16
12
|
HoverCardTitle,
|
|
17
13
|
} from "@src/components/HoverCard";
|
|
18
|
-
import {
|
|
19
|
-
userHasSeenChangesToolTip,
|
|
20
|
-
userHasSeenSimulatorToolTip,
|
|
21
|
-
} from "@src/modules/userContext";
|
|
22
14
|
import useSliceMachineActions from "@src/modules/useSliceMachineActions";
|
|
15
|
+
|
|
23
16
|
import { ChangesRightElement } from "./ChangesRightElement";
|
|
24
17
|
|
|
25
18
|
export const ChangesListItem: FC = () => {
|
|
@@ -63,30 +56,19 @@ export const ChangesListItem: FC = () => {
|
|
|
63
56
|
);
|
|
64
57
|
};
|
|
65
58
|
|
|
59
|
+
// TODO(DT-1925): Reactivate this feature
|
|
66
60
|
const useOpenChangesHoverCard = () => {
|
|
67
|
-
const {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
hasSeenChangesToolTip: userHasSeenChangesToolTip(store),
|
|
74
|
-
hasSeenSimulatorToolTip: userHasSeenSimulatorToolTip(store),
|
|
75
|
-
isSavingCustomType: isLoading(store, LoadingKeysEnum.SAVE_CUSTOM_TYPE),
|
|
76
|
-
isSavingSlice: isLoading(store, LoadingKeysEnum.SAVE_SLICE),
|
|
77
|
-
}));
|
|
78
|
-
|
|
79
|
-
const isSaving = isSavingCustomType || isSavingSlice;
|
|
80
|
-
const [prevIsSaving, setPrevIsSaving] = useState(isSaving);
|
|
61
|
+
// const { hasSeenChangesToolTip, hasSeenSimulatorToolTip } = useSelector(
|
|
62
|
+
// (store: SliceMachineStoreType) => ({
|
|
63
|
+
// hasSeenChangesToolTip: userHasSeenChangesToolTip(store),
|
|
64
|
+
// hasSeenSimulatorToolTip: userHasSeenSimulatorToolTip(store),
|
|
65
|
+
// }),
|
|
66
|
+
// );
|
|
81
67
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
68
|
+
// return (
|
|
69
|
+
// !hasSeenChangesToolTip &&
|
|
70
|
+
// hasSeenSimulatorToolTip
|
|
71
|
+
// );
|
|
85
72
|
|
|
86
|
-
return
|
|
87
|
-
!hasSeenChangesToolTip &&
|
|
88
|
-
hasSeenSimulatorToolTip &&
|
|
89
|
-
!isSaving &&
|
|
90
|
-
prevIsSaving
|
|
91
|
-
);
|
|
73
|
+
return false;
|
|
92
74
|
};
|
package/out/404.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/css/200244e3e0463c39.css" as="style"/><link rel="stylesheet" href="/_next/static/css/200244e3e0463c39.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"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/css/200244e3e0463c39.css" as="style"/><link rel="stylesheet" href="/_next/static/css/200244e3e0463c39.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-4a63c0e108026c4d.js" defer=""></script><script src="/_next/static/chunks/pages/_error-69b4f498bafdd188.js" defer=""></script><script src="/_next/static/GqPZYfMQrQUPwvgI_rvdq/_buildManifest.js" defer=""></script><script src="/_next/static/GqPZYfMQrQUPwvgI_rvdq/_ssgManifest.js" defer=""></script></head><body><div id="__next"></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":404}},"page":"/_error","query":{},"buildId":"GqPZYfMQrQUPwvgI_rvdq","runtimeConfig":{"sentryEnvironment":"beta"},"nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
self.__BUILD_MANIFEST=function(s,c,a,e,t,i,f,b,n,u,d,h,l,k,j,p,g,o,r){return{__rewrites:{beforeFiles:[],afterFiles:[],fallback:[]},"/":[a,j,p,"static/chunks/pages/index-
|
|
1
|
+
self.__BUILD_MANIFEST=function(s,c,a,e,t,i,f,b,n,u,d,h,l,k,j,p,g,o,r){return{__rewrites:{beforeFiles:[],afterFiles:[],fallback:[]},"/":[a,j,p,"static/chunks/pages/index-ca194b18d0e3930d.js"],"/_error":["static/chunks/pages/_error-69b4f498bafdd188.js"],"/changelog":[s,e,"static/chunks/870-0c7a8a9622de78b7.js","static/chunks/pages/changelog-afd18276fe018b24.js"],"/changes":[s,t,"static/chunks/8eec4907-b712959d9f984b68.js",i,"static/chunks/918-5bb55fb464e34768.js",c,b,"static/css/37153180c3b0dd66.css","static/chunks/pages/changes-92c84f6cac0285fd.js"],"/custom-types":[a,j,p,"static/chunks/pages/custom-types-94b8f8dbf7727412.js"],"/custom-types/[customTypeId]":[s,n,u,d,h,e,f,i,l,g,c,a,k,o,r,"static/chunks/pages/custom-types/[customTypeId]-3f862ad6111a1fc0.js"],"/labs":["static/chunks/pages/labs-ee206005948f8e87.js"],"/page-types/[pageTypeId]":[s,n,u,d,h,e,f,i,l,g,c,a,k,o,r,"static/chunks/pages/page-types/[pageTypeId]-d1ffca11c42f2603.js"],"/slices":[s,t,f,c,b,"static/css/f8eb526e10bc2441.css","static/chunks/pages/slices-e9c70c082ca3e3f9.js"],"/slices/[lib]/[sliceName]/[variation]":[s,t,n,u,d,h,e,f,i,l,c,k,b,"static/css/b22c0750c14cc089.css","static/chunks/pages/slices/[lib]/[sliceName]/[variation]-2d3d84de925b289e.js"],"/slices/[lib]/[sliceName]/[variation]/simulator":[t,"static/chunks/72585f70-28b4d7d5384b3703.js","static/chunks/18539003-5cc559566b738915.js","static/chunks/376-7e784d6069e01654.js","static/chunks/pages/slices/[lib]/[sliceName]/[variation]/simulator-897ca93c114a1435.js"],sortedPages:["/","/_app","/_error","/changelog","/changes","/custom-types","/custom-types/[customTypeId]","/labs","/page-types/[pageTypeId]","/slices","/slices/[lib]/[sliceName]/[variation]","/slices/[lib]/[sliceName]/[variation]/simulator"]}}("static/chunks/59b4e022-7a3b5554b806349f.js","static/chunks/25-37d6fa7f064be04b.js","static/chunks/731-341869976a48a09a.js","static/chunks/183-4feb6bb3eddbc768.js","static/chunks/c8eae200-966ce352f7b5d2b9.js","static/chunks/543-f8766685f7f451e2.js","static/chunks/50-cfc2514205b86001.js","static/chunks/286-ed90373e9a469944.js","static/chunks/f36c6662-03bb5e9d9aa0b0aa.js","static/chunks/4c744e84-e3161d754618373f.js","static/chunks/065a3ddb-9a38ca0d60f0bf2f.js","static/chunks/1cc2734a-2c5b6c0367fcde86.js","static/chunks/696-b12edad30a3617e5.js","static/chunks/318-34a2dea7cfd4661d.js","static/chunks/727-c5028806448c4387.js","static/css/be1f49e49a5aa7eb.css","static/chunks/474-5a072e6fac61f703.js","static/chunks/904-833eed675f19ab60.js","static/css/72465cc1225f28a2.css"),self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();
|