slice-machine-ui 1.16.1-dev-labs.4 → 1.16.1-dev-labs.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/builders/CustomTypeBuilder/SliceZone/List.tsx +2 -2
- package/out/404.html +1 -1
- package/out/_next/static/{y1lfqDJZlHDBVNsbiXjqQ → 9nGf8S8lP3rV-FGSNOY7i}/_buildManifest.js +1 -1
- package/out/_next/static/chunks/{933-fdaafbc600eded59.js → 933-69751ad062b29f00.js} +1 -1
- package/out/_next/static/chunks/pages/{_app-a082eaa025bcd3d5.js → _app-fc3c460c09526cd2.js} +1 -1
- package/out/_next/static/chunks/pages/labs-cf2bece58d3805d5.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]/screenshot.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/features/labs/labsList/LabsList.tsx +35 -50
- package/src/features/labs/labsList/useLab.tsx +26 -7
- package/src/features/slices/sliceCards/NonSharedSliceViewCard.tsx +3 -3
- package/src/hooks/useSliceMachineConfig.ts +12 -6
- package/out/_next/static/chunks/pages/labs-ae812d322acc765b.js +0 -1
- /package/out/_next/static/{y1lfqDJZlHDBVNsbiXjqQ → 9nGf8S8lP3rV-FGSNOY7i}/_ssgManifest.js +0 -0
package/out/slices.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/66b3836ab88b0c5c.css" as="style"/><link rel="stylesheet" href="/_next/static/css/66b3836ab88b0c5c.css" data-n-g=""/><link rel="preload" href="/_next/static/css/22d69420bda374a7.css" as="style"/><link rel="stylesheet" href="/_next/static/css/22d69420bda374a7.css" data-n-p=""/><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/66b3836ab88b0c5c.css" as="style"/><link rel="stylesheet" href="/_next/static/css/66b3836ab88b0c5c.css" data-n-g=""/><link rel="preload" href="/_next/static/css/22d69420bda374a7.css" as="style"/><link rel="stylesheet" href="/_next/static/css/22d69420bda374a7.css" data-n-p=""/><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-fc3c460c09526cd2.js" defer=""></script><script src="/_next/static/chunks/c8eae200-966ce352f7b5d2b9.js" defer=""></script><script src="/_next/static/chunks/590-ab38d53732035bf0.js" defer=""></script><script src="/_next/static/chunks/573-8678a91b09707f5d.js" defer=""></script><script src="/_next/static/chunks/pages/slices-b686960d7d228e36.js" defer=""></script><script src="/_next/static/9nGf8S8lP3rV-FGSNOY7i/_buildManifest.js" defer=""></script><script src="/_next/static/9nGf8S8lP3rV-FGSNOY7i/_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":{}},"page":"/slices","query":{},"buildId":"9nGf8S8lP3rV-FGSNOY7i","runtimeConfig":{"sentryEnvironment":"alpha"},"nextExport":true,"isFallback":false,"appGip":true,"scriptLoader":[]}</script></body></html>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "slice-machine-ui",
|
|
3
|
-
"version": "1.16.1-dev-labs.
|
|
3
|
+
"version": "1.16.1-dev-labs.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "A visual builder for your Slice Models with all the tools you need to generate data models and mock CMS content locally.",
|
|
6
6
|
"repository": {
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"start-slicemachine": "./bin/start-slicemachine.cjs"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@slicemachine/manager": "^0.13.1-dev-labs.
|
|
35
|
-
"start-slicemachine": "^0.11.10-dev-labs.
|
|
34
|
+
"@slicemachine/manager": "^0.13.1-dev-labs.5",
|
|
35
|
+
"start-slicemachine": "^0.11.10-dev-labs.5"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@emotion/react": "11.11.1",
|
|
@@ -130,5 +130,5 @@
|
|
|
130
130
|
"vitest": "0.32.0",
|
|
131
131
|
"yup": "0.32.11"
|
|
132
132
|
},
|
|
133
|
-
"gitHead": "
|
|
133
|
+
"gitHead": "dc1a14e27de86bea0f78e66e2bc53f29e624c741"
|
|
134
134
|
}
|
|
@@ -1,57 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { FC } from "react";
|
|
2
2
|
import { Box, Text } from "@prismicio/editor-ui";
|
|
3
3
|
|
|
4
|
-
import type { SliceMachineConfig } from "@slicemachine/manager";
|
|
5
|
-
|
|
6
4
|
import useSliceMachineActions from "@src/modules/useSliceMachineActions";
|
|
7
5
|
import { ToasterType } from "@src/modules/toaster";
|
|
8
|
-
import {
|
|
9
|
-
useSliceMachineConfig,
|
|
10
|
-
writeSliceMachineConfig,
|
|
11
|
-
} from "@src/hooks/useSliceMachineConfig";
|
|
12
6
|
|
|
13
7
|
import { LabsListItem } from "./LabsListItem";
|
|
14
|
-
import { useLab } from "./useLab";
|
|
8
|
+
import { type UseLabArgs, type UseLabReturnType, useLab } from "./useLab";
|
|
15
9
|
|
|
16
10
|
export const LabsList: FC = () => {
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
key: keyof Required<SliceMachineConfig>["labs"],
|
|
22
|
-
name: string,
|
|
23
|
-
enabled: boolean
|
|
24
|
-
) => {
|
|
25
|
-
const updatedConfig = { ...config, labs: { ...config.labs } };
|
|
26
|
-
|
|
27
|
-
if (enabled) {
|
|
28
|
-
updatedConfig.labs[key] = enabled;
|
|
29
|
-
} else if (key in updatedConfig.labs) {
|
|
30
|
-
delete updatedConfig.labs[key];
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (Object.keys(updatedConfig.labs).length === 0) {
|
|
34
|
-
delete (updatedConfig as SliceMachineConfig).labs;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
try {
|
|
38
|
-
await writeSliceMachineConfig(updatedConfig);
|
|
39
|
-
|
|
40
|
-
openToaster(
|
|
41
|
-
enabled ? `Labs: enabled ${name}` : `Labs: disabled ${name}`,
|
|
42
|
-
ToasterType.SUCCESS
|
|
43
|
-
);
|
|
44
|
-
} catch (error) {
|
|
45
|
-
console.error(error);
|
|
46
|
-
|
|
47
|
-
openToaster(
|
|
48
|
-
enabled
|
|
49
|
-
? `Labs: failed to enable ${name}`
|
|
50
|
-
: `Labs: failed to disable ${name}`,
|
|
51
|
-
ToasterType.ERROR
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
};
|
|
11
|
+
const [legacySliceUpgraderLab, setLegacySliceUpgraderLab] = useLabWithToast(
|
|
12
|
+
"legacySliceUpgrader",
|
|
13
|
+
"Legacy Slice Upgrader"
|
|
14
|
+
);
|
|
55
15
|
|
|
56
16
|
return (
|
|
57
17
|
<Box flexDirection="column" gap={32}>
|
|
@@ -68,10 +28,8 @@ export const LabsList: FC = () => {
|
|
|
68
28
|
<Box flexDirection="column" gap={16}>
|
|
69
29
|
<LabsListItem
|
|
70
30
|
title="Legacy Slice Upgrader"
|
|
71
|
-
enabled={
|
|
72
|
-
onToggle={(enabled) =>
|
|
73
|
-
void setLab("legacySliceUpgrader", "Legacy Slice Upgrader", enabled)
|
|
74
|
-
}
|
|
31
|
+
enabled={legacySliceUpgraderLab.enabled}
|
|
32
|
+
onToggle={(enabled) => void setLegacySliceUpgraderLab(enabled)}
|
|
75
33
|
>
|
|
76
34
|
The Legacy Slice Upgrader allows you to convert old slices (legacy and
|
|
77
35
|
composite slices) to slices managed by Slice Machine (shared slices).
|
|
@@ -83,3 +41,30 @@ export const LabsList: FC = () => {
|
|
|
83
41
|
</Box>
|
|
84
42
|
);
|
|
85
43
|
};
|
|
44
|
+
|
|
45
|
+
function useLabWithToast(key: UseLabArgs, name: string): UseLabReturnType {
|
|
46
|
+
const { openToaster } = useSliceMachineActions();
|
|
47
|
+
const [lab, setLab] = useLab(key);
|
|
48
|
+
|
|
49
|
+
const setLabWithToast = async (enabled: boolean) => {
|
|
50
|
+
try {
|
|
51
|
+
await setLab(enabled);
|
|
52
|
+
|
|
53
|
+
openToaster(
|
|
54
|
+
enabled ? `Labs: enabled ${name}` : `Labs: disabled ${name}`,
|
|
55
|
+
ToasterType.SUCCESS
|
|
56
|
+
);
|
|
57
|
+
} catch (error) {
|
|
58
|
+
console.error(error);
|
|
59
|
+
|
|
60
|
+
openToaster(
|
|
61
|
+
enabled
|
|
62
|
+
? `Labs: failed to enable ${name}`
|
|
63
|
+
: `Labs: failed to disable ${name}`,
|
|
64
|
+
ToasterType.ERROR
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
return [lab, setLabWithToast];
|
|
70
|
+
}
|
|
@@ -2,12 +2,31 @@ import type { SliceMachineConfig } from "@slicemachine/manager";
|
|
|
2
2
|
|
|
3
3
|
import { useSliceMachineConfig } from "@src/hooks/useSliceMachineConfig";
|
|
4
4
|
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
export type UseLabArgs = keyof Required<SliceMachineConfig>["labs"];
|
|
6
|
+
|
|
7
|
+
export type UseLabReturnType = [
|
|
8
|
+
lab: { enabled: boolean },
|
|
9
|
+
setLab: (enabled: boolean) => Promise<void>
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
export function useLab(key: UseLabArgs): UseLabReturnType {
|
|
13
|
+
const [config, setConfig] = useSliceMachineConfig();
|
|
14
|
+
|
|
15
|
+
const setLab = async (enabled: boolean) => {
|
|
16
|
+
const updatedConfig = { ...config, labs: { ...config.labs } };
|
|
17
|
+
|
|
18
|
+
if (enabled) {
|
|
19
|
+
updatedConfig.labs[key] = enabled;
|
|
20
|
+
} else if (key in updatedConfig.labs) {
|
|
21
|
+
delete updatedConfig.labs[key];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (Object.keys(updatedConfig.labs).length === 0) {
|
|
25
|
+
delete (updatedConfig as SliceMachineConfig).labs;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
await setConfig(updatedConfig);
|
|
29
|
+
};
|
|
10
30
|
|
|
11
|
-
|
|
12
|
-
return useSliceMachineConfig().labs ?? {};
|
|
31
|
+
return [{ enabled: config?.labs?.[key] ?? false }, setLab];
|
|
13
32
|
}
|
|
@@ -21,9 +21,9 @@ export const NonSharedSliceViewCard: FC<NonSharedSliceViewCardProps> = ({
|
|
|
21
21
|
slice,
|
|
22
22
|
path,
|
|
23
23
|
}) => {
|
|
24
|
-
const
|
|
24
|
+
const [legacySliceUpgraderLab] = useLab("legacySliceUpgrader");
|
|
25
25
|
|
|
26
|
-
const tooltipContent =
|
|
26
|
+
const tooltipContent = legacySliceUpgraderLab.enabled
|
|
27
27
|
? "This Slice was created with the Legacy Builder. It needs to be converted first to be used within Slice Machine."
|
|
28
28
|
: "This Slice was created with the Legacy Builder, and is incompatible with Slice Machine. You cannot edit, push, or delete it in Slice Machine. In order to proceed, manually remove the Slice from your type model. Then create a new Slice with the same fields using Slice Machine.";
|
|
29
29
|
|
|
@@ -40,7 +40,7 @@ export const NonSharedSliceViewCard: FC<NonSharedSliceViewCardProps> = ({
|
|
|
40
40
|
<Tooltip content={tooltipContent} side="bottom">
|
|
41
41
|
<Badge color="purple" title="Legacy Slice" />
|
|
42
42
|
</Tooltip>
|
|
43
|
-
{
|
|
43
|
+
{legacySliceUpgraderLab.enabled ? (
|
|
44
44
|
<ConvertLegacySliceButton slice={slice} path={path} />
|
|
45
45
|
) : null}
|
|
46
46
|
</CardActions>
|
|
@@ -3,14 +3,20 @@ import type { SliceMachineConfig } from "@slicemachine/manager";
|
|
|
3
3
|
|
|
4
4
|
import { managerClient } from "@src/managerClient";
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
type UseSliceMachineConfigReturnType = [
|
|
7
|
+
config: SliceMachineConfig,
|
|
8
|
+
setConfig: (config: SliceMachineConfig) => Promise<void>
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
export function useSliceMachineConfig(): UseSliceMachineConfigReturnType {
|
|
12
|
+
const config = useRequest(readSliceMachineConfig, []);
|
|
9
13
|
|
|
10
|
-
|
|
11
|
-
|
|
14
|
+
const setConfig = async (config: SliceMachineConfig) => {
|
|
15
|
+
await managerClient.project.writeSliceMachineConfig({ config });
|
|
16
|
+
updateData(readSliceMachineConfig, [], config);
|
|
17
|
+
};
|
|
12
18
|
|
|
13
|
-
|
|
19
|
+
return [config, setConfig];
|
|
14
20
|
}
|
|
15
21
|
|
|
16
22
|
async function readSliceMachineConfig(): Promise<SliceMachineConfig> {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[274],{41535:function(e,n,r){(window.__NEXT_P=window.__NEXT_P||[]).push(["/labs",function(){return r(8951)}])},8951:function(e,n,r){"use strict";r.r(n),r.d(n,{default:function(){return y}});var t=r(52322),i=r(2784),c=r(71651),s=r(97729),a=r.n(s),l=r(25251),o=r(22710),u=r(62230),d=r(85244),h=r(99267),f=r(90374),x=r(57282),g=r(19334),b=function(e){var n=e.title,r=e.enabled,i=e.onToggle,s=e.children;return(0,t.jsx)(c.Zb,{variant:"outlined",style:{padding:0},children:(0,t.jsxs)(c.xu,{gap:8,padding:16,children:[(0,t.jsx)(c.xu,{padding:{top:6},children:(0,t.jsx)(c.I5,{name:"viewDay",size:"medium",color:"grey11"})}),(0,t.jsxs)(c.xu,{flexDirection:"column",flexGrow:1,children:[(0,t.jsx)(c.xv,{variant:"h3",children:n}),(0,t.jsx)(c.xv,{variant:"normal",children:s})]}),(0,t.jsx)(c.xu,{width:128,justifyContent:"end",children:(0,t.jsx)(c.rs,{size:"medium",checked:r,onCheckedChange:function(e){return i(e)}})})]})})},j=r(63269),p=function(){var e,n=(0,g.f)(),r=(0,f.Z)().openToaster,i=(e=(0,o.Z)(function(e,t,i){var c,s;return(0,h.__generator)(this,function(a){switch(a.label){case 0:c=(0,d.Z)((0,u.Z)({},n),{labs:(0,u.Z)({},n.labs)}),i?c.labs[e]=i:e in c.labs&&delete c.labs[e],0===Object.keys(c.labs).length&&delete c.labs,a.label=1;case 1:return a.trys.push([1,3,,4]),[4,(0,g.O)(c)];case 2:return a.sent(),r(i?"Labs: enabled ".concat(t):"Labs: disabled ".concat(t),x.Jf.SUCCESS),[3,4];case 3:return s=a.sent(),console.error(s),r(i?"Labs: failed to enable ".concat(t):"Labs: failed to disable ".concat(t),x.Jf.ERROR),[3,4];case 4:return[2]}})}),function(n,r,t){return e.apply(this,arguments)});return(0,t.jsxs)(c.xu,{flexDirection:"column",gap:32,children:[(0,t.jsxs)("header",{children:[(0,t.jsx)(c.xv,{variant:"normal",children:"Slice Machine Labs gives you early access to new features before they're available to everyone."}),(0,t.jsx)(c.xv,{variant:"normal",children:"Experimental features are works-in-progress and unstable, so you may find some bugs along the way."})]}),(0,t.jsx)(c.xu,{flexDirection:"column",gap:16,children:(0,t.jsx)(b,{title:"Legacy Slice Upgrader",enabled:(0,j.E)("legacySliceUpgrader").enabled,onToggle:function(e){i("legacySliceUpgrader","Legacy Slice Upgrader",e)},children:"The Legacy Slice Upgrader allows you to convert old slices (legacy and composite slices) to slices managed by Slice Machine (shared slices). This feature is experimental, we strongly encourage you testing it through a Prismic environment first or you'll be at risk of losing past content."})})]})},y=function(){return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(a(),{children:(0,t.jsx)("title",{children:"Labs - Slice Machine"})}),(0,t.jsx)(c.SV,{renderError:function(){return(0,t.jsx)(v,{children:(0,t.jsx)(c.xu,{alignItems:"center",justifyContent:"center",children:(0,t.jsx)(c.Iq,{title:"Request failed",description:"An error occurred while fetching your labs configuration."})})})},children:(0,t.jsx)(i.Suspense,{fallback:(0,t.jsx)(v,{withHeader:!0,children:(0,t.jsx)(c._3,{})}),children:(0,t.jsx)(v,{withHeader:!0,children:(0,t.jsx)(p,{})})})})]})},v=function(e){var n=e.children,r=e.withHeader;return(0,t.jsxs)(l.LN,{children:[void 0!==r&&r?(0,t.jsx)(l.wd,{children:(0,t.jsx)(l.Cx,{folder:"Labs"})}):null,(0,t.jsx)(l.RN,{children:n})]})}},63269:function(e,n,r){"use strict";r.d(n,{E:function(){return i}});var t=r(19334);function i(e){var n,r;return{enabled:null!==(n=(null!==(r=(0,t.f)().labs)&&void 0!==r?r:{})[e])&&void 0!==n&&n}}},19334:function(e,n,r){"use strict";r.d(n,{O:function(){return l},f:function(){return a}});var t=r(22710),i=r(99267),c=r(17329),s=r(40147);function a(){return(0,c.QT)(u,[])}function l(e){return o.apply(this,arguments)}function o(){return(o=(0,t.Z)(function(e){return(0,i.__generator)(this,function(n){switch(n.label){case 0:return[4,s.j.project.writeSliceMachineConfig({config:e})];case 1:return n.sent(),(0,c.VA)(u,[],e),[2]}})})).apply(this,arguments)}function u(){return d.apply(this,arguments)}function d(){return(d=(0,t.Z)(function(){return(0,i.__generator)(this,function(e){return[2,s.j.project.getSliceMachineConfig()]})})).apply(this,arguments)}}},function(e){e.O(0,[774,888,179],function(){return e(e.s=41535)}),_N_E=e.O()}]);
|
|
File without changes
|