slice-machine-ui 1.20.1-dev-environments.2 → 1.20.1-dev-next-release.3

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.
Files changed (90) hide show
  1. package/components/AppLayout/index.tsx +10 -34
  2. package/components/Navigation/index.tsx +15 -32
  3. package/components/ReviewModal/ReviewForm.tsx +2 -2
  4. package/components/ReviewModal/ReviewModal.tsx +7 -0
  5. package/out/404.html +1 -1
  6. package/out/_next/static/BIxidu02_xbgjO9EV7tg4/_buildManifest.js +1 -0
  7. package/out/_next/static/chunks/{18539003-371d86ea83e7293b.js → 18539003-5d8b6a04053638af.js} +2 -2
  8. package/out/_next/static/chunks/{482-39cef3a713901788.js → 482-30c0f114c7213fa3.js} +1 -1
  9. package/out/_next/static/chunks/{125-f0e2eb84ee39757a.js → 505-fa47e200ac3a012d.js} +1 -1
  10. package/out/_next/static/chunks/{550-e72c08c598051224.js → 550-abf97d3008006056.js} +1 -1
  11. package/out/_next/static/chunks/{80-821a0b5d4ad61185.js → 80-72d903b2a0bd5dc3.js} +1 -1
  12. package/out/_next/static/chunks/840-8cec2bbd104111f2.js +1 -0
  13. package/out/_next/static/chunks/904-cb627b6d7b8068f9.js +1 -0
  14. package/out/_next/static/chunks/958-8f814daf5896ff97.js +1 -0
  15. package/out/_next/static/chunks/pages/{_app-61dfd5e4a504dad6.js → _app-2d01c2c528624eaf.js} +44 -44
  16. package/out/_next/static/chunks/pages/{changelog-4b8369d91d82b28b.js → changelog-fa36b9995c26e1d7.js} +1 -1
  17. package/out/_next/static/chunks/pages/changes-494c71511b2e8989.js +1 -0
  18. package/out/_next/static/chunks/pages/index-d8e3a2c0d712904f.js +1 -0
  19. package/out/_next/static/chunks/pages/labs-ebce03a4e7a95a4e.js +1 -0
  20. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/{simulator-79a62d775e64898c.js → simulator-7b17cb59d0db03b5.js} +1 -1
  21. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/{[variation]-724893d27ffa426c.js → [variation]-763cc8c12e977b4a.js} +1 -1
  22. package/out/_next/static/chunks/pages/slices-22db04643850c1d8.js +1 -0
  23. package/out/_next/static/css/31841735992dea23.css +1 -0
  24. package/out/_next/static/css/58a89606d9ca9093.css +1 -0
  25. package/out/_next/static/css/5d18ccf403d4649a.css +1 -0
  26. package/out/_next/static/css/{51597cd1f01c4889.css → 78250665d395ea50.css} +1 -1
  27. package/out/_next/static/css/{16b41648cd1de03b.css → b0be58d878c0fac3.css} +1 -1
  28. package/out/_next/static/css/e48f99beffa085f5.css +1 -0
  29. package/out/changelog.html +1 -1
  30. package/out/changes.html +1 -1
  31. package/out/custom-types/[customTypeId].html +1 -1
  32. package/out/custom-types.html +1 -1
  33. package/out/index.html +1 -1
  34. package/out/labs.html +1 -1
  35. package/out/page-types/[pageTypeId].html +1 -1
  36. package/out/slices/[lib]/[sliceName]/[variation]/simulator.html +1 -1
  37. package/out/slices/[lib]/[sliceName]/[variation].html +1 -1
  38. package/out/slices.html +1 -1
  39. package/package.json +7 -7
  40. package/pages/_app.tsx +39 -35
  41. package/pages/slices.tsx +0 -1
  42. package/src/components/Counter/Counter.css.ts +26 -0
  43. package/src/components/Counter/Counter.stories.tsx +17 -0
  44. package/src/components/Counter/Counter.tsx +16 -0
  45. package/src/components/Counter/index.ts +1 -0
  46. package/src/components/PageLayout/PageLayout.css.ts +3 -8
  47. package/src/components/PageLayout/PageLayout.stories.tsx +1 -10
  48. package/src/components/PageLayout/PageLayout.tsx +2 -7
  49. package/src/components/SideNav/SideNav.css.ts +10 -3
  50. package/src/components/SideNav/SideNav.stories.tsx +2 -29
  51. package/src/components/SideNav/SideNav.tsx +1 -5
  52. package/src/components/SideNav/index.ts +0 -1
  53. package/src/features/customTypes/__tests__/CustomTypeBuilderPage.test.tsx +3 -4
  54. package/src/features/inAppGuide/InAppGuideContext.tsx +47 -0
  55. package/src/features/inAppGuide/InAppGuideDialog.tsx +97 -0
  56. package/src/features/inAppGuide/inAppGuideContent.tsx +65 -0
  57. package/src/hooks/usePersistedState.ts +34 -0
  58. package/src/hooks/useRepositoryInformation.ts +24 -0
  59. package/src/icons/FlowerBackgroundIcon.tsx +17 -0
  60. package/src/icons/HelpIcon.tsx +19 -0
  61. package/test/pages/slices.test.tsx +8 -4
  62. package/test/src/modules/__fixtures__/serverState.ts +0 -2
  63. package/components/Navigation/Environment.tsx +0 -47
  64. package/components/Navigation/index.css.ts +0 -6
  65. package/out/_next/static/chunks/840-5b485c737b24324b.js +0 -1
  66. package/out/_next/static/chunks/904-6204ab2ad8798857.js +0 -1
  67. package/out/_next/static/chunks/958-c90d60818f1c468a.js +0 -1
  68. package/out/_next/static/chunks/pages/changes-db6e8c6be5ae076e.js +0 -1
  69. package/out/_next/static/chunks/pages/index-941b44c74dd339e4.js +0 -1
  70. package/out/_next/static/chunks/pages/labs-2922105ab714d32a.js +0 -1
  71. package/out/_next/static/chunks/pages/slices-93b7af2624c85b8e.js +0 -1
  72. package/out/_next/static/css/009bd7f5ac85fc6a.css +0 -1
  73. package/out/_next/static/css/3e88bd24e38f18d0.css +0 -1
  74. package/out/_next/static/css/6e4843007ff41825.css +0 -1
  75. package/out/_next/static/css/867d8d7ab4a75762.css +0 -1
  76. package/out/_next/static/eEMbH0pyO9pWG3REga3T2/_buildManifest.js +0 -1
  77. package/src/components/Divider/Divider.css.ts +0 -31
  78. package/src/components/Divider/Divider.stories.tsx +0 -27
  79. package/src/components/Divider/Divider.tsx +0 -25
  80. package/src/components/Divider/index.ts +0 -1
  81. package/src/components/SideNav/SideNavEnvironmentSelector.css.ts +0 -69
  82. package/src/components/SideNav/SideNavEnvironmentSelector.tsx +0 -163
  83. package/src/features/environments/actions/getActiveEnvironmentDomain.ts +0 -11
  84. package/src/features/environments/actions/getEnvironments.ts +0 -12
  85. package/src/features/environments/actions/setEnvironment.ts +0 -18
  86. package/src/features/environments/useActiveEnvironment.ts +0 -38
  87. package/src/features/environments/useEnvironments.ts +0 -7
  88. package/src/features/legacyState/actions/getLegacySliceMachineState.ts +0 -53
  89. package/src/features/legacyState/useLegacySliceMachineState.ts +0 -7
  90. /package/out/_next/static/{eEMbH0pyO9pWG3REga3T2 → BIxidu02_xbgjO9EV7tg4}/_ssgManifest.js +0 -0
@@ -6,21 +6,12 @@ import {
6
6
  PageLayoutHeader,
7
7
  PageLayoutPane,
8
8
  } from "./PageLayout";
9
- import { borderTop } from "./PageLayout.css";
10
9
 
11
10
  type Story = StoryObj<typeof meta>;
12
11
 
13
12
  const meta = {
14
13
  component: PageLayout,
15
- argTypes: {
16
- children: {
17
- control: { disable: true },
18
- },
19
- activeEnvironmentKind: {
20
- control: { type: "select" },
21
- options: Object.keys(borderTop),
22
- },
23
- },
14
+ argTypes: { children: { control: { disable: true } } },
24
15
  parameters: {
25
16
  docs: { story: { height: 256, inline: false } },
26
17
  layout: "fullscreen",
@@ -2,18 +2,13 @@ import type { FC, PropsWithChildren } from "react";
2
2
 
3
3
  import * as styles from "./PageLayout.css";
4
4
 
5
- type PageLayoutProps = PropsWithChildren<{
6
- activeEnvironmentKind?: "prod" | "stage" | "dev";
7
- }>;
8
-
9
- export const PageLayout: FC<PageLayoutProps> = ({
10
- activeEnvironmentKind = "prod",
5
+ export const PageLayout: FC<PropsWithChildren> = ({
11
6
  children,
12
7
  ...otherProps
13
8
  }) => (
14
9
  <div {...otherProps} className={styles.root}>
15
10
  {children}
16
- <div className={styles.borderTop[activeEnvironmentKind]} />
11
+ <div className={styles.borderTop} />
17
12
  </div>
18
13
  );
19
14
 
@@ -101,6 +101,7 @@ export const repositoryLinkIcon = style([
101
101
  borderWidth: 1,
102
102
  cursor: "pointer",
103
103
  height: 32,
104
+ marginRight: 8,
104
105
  width: 32,
105
106
  color: colors.grey12,
106
107
  backgroundColor: {
@@ -162,9 +163,15 @@ export const listTitle = style([
162
163
  },
163
164
  ]);
164
165
 
165
- export const separator = sprinkles({
166
- marginTop: 8,
167
- });
166
+ export const dashedLine = style([
167
+ blockWithDisplayRevert,
168
+ sprinkles({
169
+ borderColor: colors.grey6,
170
+ borderTopStyle: "dashed",
171
+ borderWidth: 1,
172
+ marginTop: 8,
173
+ }),
174
+ ]);
168
175
 
169
176
  export const link = style([
170
177
  block,
@@ -5,6 +5,7 @@ import { LightningIcon } from "@src/icons/Lightning";
5
5
 
6
6
  import {
7
7
  SideNav,
8
+ SideNavLogo,
8
9
  SideNavList,
9
10
  SideNavListItem,
10
11
  SideNavLink,
@@ -14,7 +15,6 @@ import {
14
15
  SideNavRepository,
15
16
  RightElement,
16
17
  } from "./SideNav";
17
- import { SideNavEnvironmentSelector } from "./SideNavEnvironmentSelector";
18
18
 
19
19
  type Story = StoryObj<typeof meta>;
20
20
 
@@ -33,34 +33,7 @@ export const Default = {
33
33
  args: {
34
34
  children: (
35
35
  <>
36
- <SideNavEnvironmentSelector
37
- environments={[
38
- {
39
- name: "Production",
40
- domain: "example-prismic-repo",
41
- kind: "prod",
42
- users: [{ id: "id" }],
43
- },
44
- {
45
- name: "Staging",
46
- domain: "example-prismic-repo-staging",
47
- kind: "stage",
48
- users: [{ id: "id" }],
49
- },
50
- {
51
- name: "Development",
52
- domain: "example-prismic-repo-development",
53
- kind: "dev",
54
- users: [{ id: "id" }],
55
- },
56
- ]}
57
- activeEnvironment={{
58
- name: "Production",
59
- domain: "example-prismic-repo",
60
- kind: "prod",
61
- users: [{ id: "id" }],
62
- }}
63
- />
36
+ <SideNavLogo />
64
37
 
65
38
  <SideNavRepository
66
39
  repositoryName="really long repository name"
@@ -16,8 +16,6 @@ import type { UrlObject } from "node:url";
16
16
  import LogoIcon from "@src/icons/LogoIcon";
17
17
  import OpenIcon from "@src/icons/OpenIcon";
18
18
 
19
- import { Divider } from "../Divider";
20
-
21
19
  import * as styles from "./SideNav.css";
22
20
 
23
21
  type SideNavProps = PropsWithChildren<{ style?: CSSProperties }>;
@@ -92,9 +90,7 @@ export const SideNavListTitle: FC<PropsWithChildren> = (props) => (
92
90
  <h3 {...props} className={styles.listTitle} />
93
91
  );
94
92
 
95
- export const SideNavSeparator = () => (
96
- <Divider color="grey6" className={styles.separator} />
97
- );
93
+ export const SideNavSeparator = () => <hr className={styles.dashedLine} />;
98
94
 
99
95
  export type SideNavLinkProps = {
100
96
  title: string;
@@ -1,2 +1 @@
1
1
  export * from "./SideNav";
2
- export { SideNavEnvironmentSelector } from "./SideNavEnvironmentSelector";
@@ -178,10 +178,9 @@ async function renderCustomTypesBuilderPage({
178
178
  const renderResults = render(<CustomTypesBuilderPage />, customTypeMockStore);
179
179
 
180
180
  const folder = customType.format === "page" ? "Page types" : "Custom types";
181
- const breadcrumb = await screen.findByTestId(
182
- `breadcrumb-${folder}-${customType.label as string}`,
183
- );
184
- expect(breadcrumb).toBeVisible();
181
+ expect(
182
+ screen.getByTestId(`breadcrumb-${folder}-${customType.label as string}`),
183
+ ).toBeVisible();
185
184
 
186
185
  return renderResults;
187
186
  }
@@ -0,0 +1,47 @@
1
+ import {
2
+ Dispatch,
3
+ FC,
4
+ PropsWithChildren,
5
+ SetStateAction,
6
+ createContext,
7
+ useContext,
8
+ useMemo,
9
+ } from "react";
10
+
11
+ import { usePersistedState } from "@src/hooks/usePersistedState";
12
+
13
+ type InAppGuideContextValue = {
14
+ isInAppGuideOpen: boolean;
15
+ setIsInAppGuideOpen: Dispatch<SetStateAction<boolean>>;
16
+ };
17
+
18
+ export const InAppGuideContext = createContext<
19
+ InAppGuideContextValue | undefined
20
+ >(undefined);
21
+
22
+ export const InAppGuideProvider: FC<PropsWithChildren> = (props) => {
23
+ const { children } = props;
24
+ const [isInAppGuideOpen, setIsInAppGuideOpen] = usePersistedState(
25
+ "isInAppGuideOpen",
26
+ true,
27
+ );
28
+
29
+ const memoizedValue = useMemo(
30
+ () => ({ isInAppGuideOpen, setIsInAppGuideOpen }),
31
+ [isInAppGuideOpen, setIsInAppGuideOpen],
32
+ );
33
+
34
+ return (
35
+ <InAppGuideContext.Provider value={memoizedValue}>
36
+ {children}
37
+ </InAppGuideContext.Provider>
38
+ );
39
+ };
40
+
41
+ export const useInAppGuide = () => {
42
+ const context = useContext(InAppGuideContext);
43
+ if (context === undefined) {
44
+ throw new Error("useInAppGuide must be used within an InAppGuideProvider");
45
+ }
46
+ return context;
47
+ };
@@ -0,0 +1,97 @@
1
+ import { FC } from "react";
2
+ import {
3
+ Box,
4
+ Dialog,
5
+ DialogContent,
6
+ DialogHeader,
7
+ IconButton,
8
+ ScrollArea,
9
+ Separator,
10
+ Text,
11
+ Video,
12
+ } from "@prismicio/editor-ui";
13
+
14
+ import { Counter } from "@src/components/Counter";
15
+ import { HelpIcon } from "@src/icons/HelpIcon";
16
+ import { useIsEmptyProject } from "@src/hooks/useIsEmptyProject";
17
+
18
+ import { useInAppGuideContent } from "./inAppGuideContent";
19
+ import { useInAppGuide } from "./InAppGuideContext";
20
+
21
+ export const InAppGuideDialog: FC = () => {
22
+ const isEmptyProject = useIsEmptyProject();
23
+ const { isInAppGuideOpen, setIsInAppGuideOpen } = useInAppGuide();
24
+ const inAppGuideContent = useInAppGuideContent();
25
+
26
+ const trigger =
27
+ isEmptyProject === false ? (
28
+ <Box position="fixed" right={16} bottom={16}>
29
+ <IconButton
30
+ color="purple"
31
+ icon={<HelpIcon />}
32
+ onClick={() => {
33
+ setIsInAppGuideOpen(!isInAppGuideOpen);
34
+ }}
35
+ radius="full"
36
+ variant="solid"
37
+ />
38
+ </Box>
39
+ ) : undefined;
40
+
41
+ return (
42
+ <Dialog
43
+ trigger={trigger}
44
+ modal={false}
45
+ open={isInAppGuideOpen && isEmptyProject === false}
46
+ onOpenChange={(open) => {
47
+ setIsInAppGuideOpen(open);
48
+ }}
49
+ position="bottomRight"
50
+ size={{
51
+ width: 360,
52
+ height: 456,
53
+ }}
54
+ >
55
+ <DialogHeader title={inAppGuideContent.title} />
56
+ <DialogContent>
57
+ <ScrollArea>
58
+ <Box flexDirection="column" padding={{ inline: 16, block: 8 }}>
59
+ <Text>{inAppGuideContent.description}</Text>
60
+ </Box>
61
+
62
+ <Box>
63
+ <Separator />
64
+ </Box>
65
+
66
+ {inAppGuideContent.steps.map((content, index) => (
67
+ <Box key={index} flexDirection="column">
68
+ <Box flexDirection="column" padding={16} gap={8}>
69
+ <Box alignItems="center" gap={8}>
70
+ <Counter>{index + 1}</Counter>
71
+ <Text component="h3" variant="bold">
72
+ {content.title}
73
+ </Text>
74
+ </Box>
75
+ <Video
76
+ src={content.videoUrl}
77
+ sizing="contain"
78
+ autoPlay
79
+ controls
80
+ loop
81
+ />
82
+ <Text>{content.description}</Text>
83
+ </Box>
84
+
85
+ <Separator />
86
+ </Box>
87
+ ))}
88
+
89
+ <Box flexDirection="column" padding={16} gap={4}>
90
+ <Text variant="bold">{inAppGuideContent.successTitle}</Text>
91
+ <Text>{inAppGuideContent.successDescription}</Text>
92
+ </Box>
93
+ </ScrollArea>
94
+ </DialogContent>
95
+ </Dialog>
96
+ );
97
+ };
@@ -0,0 +1,65 @@
1
+ import { TextLink, Text } from "@prismicio/editor-ui";
2
+
3
+ import { useRepositoryInformation } from "@src/hooks/useRepositoryInformation";
4
+
5
+ export function useInAppGuideContent() {
6
+ const { repositoryUrl } = useRepositoryInformation();
7
+
8
+ return {
9
+ title: "Build a page in 5 minutes",
10
+ description:
11
+ "Great, now that you have a page type, let's make it a live page!",
12
+ steps: [
13
+ {
14
+ title: "Add slices to your page type",
15
+ videoUrl:
16
+ "https://res.cloudinary.com/dmtf1daqp/video/upload/v1700213517/IN-APP-GUIDE-SM/ADD_SLICE.mp4",
17
+ description: "Use slice templates and add them to your page type.",
18
+ },
19
+ {
20
+ title: "Code your page",
21
+ videoUrl:
22
+ "https://res.cloudinary.com/dmtf1daqp/video/upload/v1700213517/IN-APP-GUIDE-SM/CODE_SNIP.mp4",
23
+ description:
24
+ "If you don't already have a page component, copy-paste the page snippets provided in your page type to create one.",
25
+ },
26
+ {
27
+ title: "Push to your Page Builder",
28
+ videoUrl:
29
+ "https://res.cloudinary.com/dmtf1daqp/video/upload/v1700213517/IN-APP-GUIDE-SM/PUSH.mp4",
30
+ description:
31
+ "You have just created some models, but you can't use them yet. First, you must push them to the Page Builder. The Page Builder is where you create content. Go head — push your models.",
32
+ },
33
+ {
34
+ title: "Create content",
35
+ videoUrl:
36
+ "https://res.cloudinary.com/dmtf1daqp/video/upload/v1700213517/IN-APP-GUIDE-SM/WRITE.mp4",
37
+ description: (
38
+ <>
39
+ Open your{" "}
40
+ <TextLink href={repositoryUrl} underline>
41
+ Page Builder
42
+ </TextLink>
43
+ , create a page, add slices, save, and publish. Then, come back
44
+ here.
45
+ </>
46
+ ),
47
+ },
48
+ {
49
+ title: "Render your page",
50
+ videoUrl:
51
+ "https://res.cloudinary.com/dmtf1daqp/video/upload/v1700213517/IN-APP-GUIDE-SM/PREVIEW.mp4",
52
+ description: (
53
+ <>
54
+ To render the page, run your project in your terminal and visit the
55
+ page on localhost (e.g.{" "}
56
+ <Text component="code">localhost:3000/example-page</Text>).
57
+ </>
58
+ ),
59
+ },
60
+ ],
61
+ successTitle: "Next",
62
+ successDescription:
63
+ "Create more slices and then go back to the Page Builder to build out your website.",
64
+ };
65
+ }
@@ -0,0 +1,34 @@
1
+ import { Dispatch, SetStateAction, useEffect, useState } from "react";
2
+
3
+ type PersistedState<T> = [T, Dispatch<SetStateAction<T>>];
4
+
5
+ const SLICE_MACHINE_STORAGE_PREFIX = "slice-machine";
6
+
7
+ export function usePersistedState<T>(
8
+ key: string,
9
+ defaultValue: T,
10
+ ): PersistedState<T> {
11
+ const computedKey = `${SLICE_MACHINE_STORAGE_PREFIX}_${key}`;
12
+
13
+ const [value, setValue] = useState<T>(() => {
14
+ try {
15
+ const value = localStorage.getItem(computedKey);
16
+
17
+ return value !== null ? (JSON.parse(value) as T) : defaultValue;
18
+ } catch (error) {
19
+ console.warn(`Error reading localStorage key “${computedKey}”:`, error);
20
+
21
+ return defaultValue;
22
+ }
23
+ });
24
+
25
+ useEffect(() => {
26
+ try {
27
+ localStorage.setItem(computedKey, JSON.stringify(value));
28
+ } catch (error) {
29
+ console.warn(`Error setting localStorage key “${computedKey}”:`, error);
30
+ }
31
+ }, [computedKey, value]);
32
+
33
+ return [value, setValue];
34
+ }
@@ -0,0 +1,24 @@
1
+ import { useSelector } from "react-redux";
2
+
3
+ import { SliceMachineStoreType } from "@src/redux/type";
4
+ import { getApiEndpoint, getRepoName } from "@src/modules/environment";
5
+
6
+ // TODO: This hook should be extracted to a new manager endpoint
7
+ export function useRepositoryInformation() {
8
+ const { repositoryName, apiEndpoint } = useSelector(
9
+ (store: SliceMachineStoreType) => ({
10
+ repositoryName: getRepoName(store),
11
+ apiEndpoint: getApiEndpoint(store),
12
+ }),
13
+ );
14
+ const repositoryDomain = new URL(apiEndpoint).hostname.replace(".cdn", "");
15
+ const repositoryUrl = apiEndpoint
16
+ .replace(".cdn.", ".")
17
+ .replace("/api/v2", "");
18
+
19
+ return {
20
+ repositoryName,
21
+ repositoryDomain,
22
+ repositoryUrl,
23
+ };
24
+ }
@@ -0,0 +1,17 @@
1
+ import { FC } from "react";
2
+
3
+ export const FlowerBackgroundIcon: FC = (props) => (
4
+ <svg
5
+ width="16"
6
+ height="16"
7
+ viewBox="0 0 16 16"
8
+ fill="none"
9
+ xmlns="http://www.w3.org/2000/svg"
10
+ {...props}
11
+ >
12
+ <path
13
+ d="M16 8C15.9847 7.44998 15.8169 6.91443 15.5147 6.45381C15.2133 5.99404 14.7893 5.62622 14.2903 5.39293C14.4802 4.87612 14.5202 4.31673 14.4095 3.77778C14.298 3.23797 14.0375 2.74074 13.6586 2.34142C13.2584 1.96254 12.762 1.70285 12.2222 1.59046C11.6833 1.47978 11.1239 1.5198 10.6071 1.70966C10.3746 1.20988 10.0077 0.785015 9.54704 0.48361C9.08642 0.182205 8.55087 0.0136228 8 0C7.44998 0.0144742 6.91613 0.181354 6.45636 0.48361C5.99659 0.785866 5.63133 1.21073 5.4006 1.70966C4.88293 1.5198 4.32184 1.47808 3.78118 1.59046C3.24053 1.70115 2.74244 1.96169 2.34227 2.34142C1.96339 2.74159 1.70456 3.23968 1.59472 3.77863C1.48404 4.31758 1.52661 4.87697 1.71733 5.39293C1.21754 5.62622 0.791826 5.99319 0.488719 6.45296C0.185611 6.91273 0.0161771 7.44913 0 8C0.0170285 8.55087 0.185611 9.08642 0.488719 9.54704C0.791826 10.0068 1.21754 10.3746 1.71733 10.6071C1.52661 11.123 1.48404 11.6824 1.59472 12.2214C1.70541 12.7612 1.96339 13.2584 2.34142 13.6586C2.74159 14.0358 3.23882 14.2946 3.77778 14.4061C4.31673 14.5185 4.87612 14.4777 5.39293 14.2903C5.62622 14.7893 5.99319 15.2133 6.45381 15.5155C6.91358 15.8169 7.44998 15.9847 8 16C8.55087 15.9864 9.08642 15.8186 9.54704 15.5172C10.0077 15.2158 10.3746 14.7901 10.6071 14.2912C11.1213 14.4947 11.685 14.5432 12.2273 14.4308C12.7688 14.3184 13.2661 14.0502 13.6577 13.6586C14.0494 13.2669 14.3184 12.7697 14.4308 12.2273C14.5432 11.685 14.4947 11.1213 14.2903 10.6071C14.7893 10.3738 15.2133 10.0068 15.5155 9.54619C15.8169 9.08642 15.9847 8.55002 16 8Z"
14
+ fill="#6E56CF"
15
+ />
16
+ </svg>
17
+ );
@@ -0,0 +1,19 @@
1
+ import type { FC, SVGProps } from "react";
2
+
3
+ export const HelpIcon: FC<SVGProps<SVGSVGElement>> = (props) => (
4
+ <svg
5
+ width="24"
6
+ height="24"
7
+ viewBox="0 0 24 24"
8
+ fill="none"
9
+ xmlns="http://www.w3.org/2000/svg"
10
+ {...props}
11
+ >
12
+ <path
13
+ fillRule="evenodd"
14
+ clipRule="evenodd"
15
+ d="M12.5 18.9824C15.9675 18.7377 18.7377 15.9675 18.9824 12.5H15.9691C15.7434 14.3094 14.3094 15.7434 12.5 15.9691V18.9824ZM15.9691 11.5H18.9824C18.7377 8.03251 15.9675 5.2623 12.5 5.01758V8.03095C14.3094 8.25657 15.7434 9.69064 15.9691 11.5ZM11.5 18.9824V15.9691C9.69064 15.7434 8.25657 14.3094 8.03095 12.5H5.01758C5.2623 15.9675 8.03251 18.7377 11.5 18.9824ZM5.01758 11.5H8.03095C8.25657 9.69064 9.69064 8.25657 11.5 8.03095V5.01758C8.03251 5.2623 5.2623 8.03251 5.01758 11.5ZM9 12C9 13.6569 10.3431 15 12 15C13.6569 15 15 13.6569 15 12C15 10.3431 13.6569 9 12 9C10.3431 9 9 10.3431 9 12ZM20 12C20 16.4183 16.4183 20 12 20C7.58172 20 4 16.4183 4 12C4 7.58172 7.58172 4 12 4C16.4183 4 20 7.58172 20 12Z"
16
+ fill="#EDEDEF"
17
+ />
18
+ </svg>
19
+ );
@@ -167,14 +167,18 @@ describe("slices", () => {
167
167
  },
168
168
  });
169
169
 
170
- const createOneButton = await screen.findByTestId("create-slice");
170
+ const createOneButton = document.querySelector('[data-cy="create-slice"]');
171
171
  await act(async () => {
172
- fireEvent.click(createOneButton);
172
+ if (createOneButton) {
173
+ fireEvent.click(createOneButton);
174
+ }
173
175
  });
174
176
 
175
- const nameInput = await screen.findByPlaceholderText(/slice api id/i);
177
+ const nameInput = document.querySelector('[data-cy="slice-name-input"]');
176
178
  await act(async () => {
177
- fireEvent.change(nameInput, { target: { value: "FooBar" } });
179
+ if (nameInput) {
180
+ fireEvent.change(nameInput, { target: { value: "FooBar" } });
181
+ }
178
182
  });
179
183
 
180
184
  const createSliceModal = screen.getByLabelText("Create a new slice");
@@ -36,8 +36,6 @@ export const dummyServerState: Pick<
36
36
  "https://0yyeb2g040.execute-api.us-east-1.amazonaws.com/prod/",
37
37
  PrismicOembed: "https://oembed.prismic.io",
38
38
  PrismicUnsplash: "https://unsplash.prismic.io",
39
- SliceMachineV1:
40
- "https://21vvgrh0s6.execute-api.us-east-1.amazonaws.com/v1/",
41
39
  },
42
40
  shortId: "shortId",
43
41
  supportsSliceSimulator: true,
@@ -1,47 +0,0 @@
1
- import {
2
- Environment as EnvironmentType,
3
- isUnauthenticatedError,
4
- isUnauthorizedError,
5
- } from "@slicemachine/manager/client";
6
-
7
- import { useEnvironments } from "@src/features/environments/useEnvironments";
8
- import { setEnvironment } from "@src/features/environments/actions/setEnvironment";
9
- import { useActiveEnvironment } from "@src/features/environments/useActiveEnvironment";
10
- import { getLegacySliceMachineState } from "@src/features/legacyState/actions/getLegacySliceMachineState";
11
- import useSliceMachineActions from "@src/modules/useSliceMachineActions";
12
-
13
- import { SideNavEnvironmentSelector } from "@src/components/SideNav";
14
-
15
- export function Environment() {
16
- const { environments, error: useEnvironmentsError } = useEnvironments();
17
- const { activeEnvironment } = useActiveEnvironment();
18
- const { refreshState, openLoginModal } = useSliceMachineActions();
19
-
20
- async function onSelect(environment: EnvironmentType) {
21
- await setEnvironment(environment);
22
-
23
- const legacySliceMachineState = await getLegacySliceMachineState();
24
-
25
- refreshState(legacySliceMachineState);
26
- }
27
-
28
- if (
29
- isUnauthenticatedError(useEnvironmentsError) ||
30
- isUnauthorizedError(useEnvironmentsError)
31
- ) {
32
- return (
33
- <SideNavEnvironmentSelector
34
- variant="unauthorized"
35
- onLogInClick={() => openLoginModal()}
36
- />
37
- );
38
- }
39
-
40
- return (
41
- <SideNavEnvironmentSelector
42
- environments={environments}
43
- activeEnvironment={activeEnvironment}
44
- onSelect={onSelect}
45
- />
46
- );
47
- }
@@ -1,6 +0,0 @@
1
- import { sprinkles } from "@prismicio/editor-ui";
2
-
3
- export const environmentDivider = sprinkles({
4
- marginTop: 16,
5
- marginBottom: 32,
6
- });
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[840],{80131:function(e,n,t){"use strict";t.d(n,{M:function(){return w}});var r=t(62230),s=t(85244),a=t(52322),l=t(2784),c=t(75289),i=t(56580),d=t(68780),o=t(70041),u=t(17064),h=t(63397),x=t(78656),C=t(98240),f=function(e){var n=e.selected,t=(0,C.Z)(e,["selected"]);return(0,a.jsx)(c.kC,(0,r.Z)({sx:{p:"24px",mb:3,alignItems:"top",cursor:"pointer",borderRadius:"6px",backgroundColor:"grayLight",boxShadow:n?function(e){var n;return"0 0 0 2px ".concat(String(null===(n=e.colors)||void 0===n?void 0:n.primary))}:"none","&:hover":{boxShadow:function(e){var n;return"0 0 0 2px ".concat(String(null===(n=e.colors)||void 0===n?void 0:n.primary))}}}},t))},p=function(e){var n=e.format,t=(0,u.Z)((0,h.U$)("repeatable"),3),r=t[0],s=t[2],l=x.$[n];return(0,a.jsxs)(c.xu,{mb:2,children:[(0,a.jsxs)(f,{selected:r.value,onClick:function(){return s.setValue(!0)},children:[(0,a.jsx)(c.Y8,{checked:r.value,onChange:function(){},"data-cy":"repeatable-type-radio-btn"}),(0,a.jsxs)(c.xu,{sx:{marginLeft:2},children:["Reusable type",(0,a.jsx)(c.xu,{as:"p",sx:{fontSize:"12px",color:"textClear",mt:1},children:l.hintRepeatable})]})]}),(0,a.jsxs)(f,{selected:!r.value,onClick:function(){return s.setValue(!1)},children:[(0,a.jsx)(c.Y8,{checked:!r.value,onChange:function(){},"data-cy":"single-type-radio-btn"}),(0,a.jsxs)(c.xu,{sx:{marginLeft:2},children:["Single type",(0,a.jsx)(c.xu,{as:"p",sx:{fontSize:"12px",color:"textClear",mt:1},children:l.hintSingle})]})]})]})},m=t(90374),j=t(49471),g=t(77174),v=t(24340),_=t(32665),y=t(3098),b=t(82770),T=t(38876),L=t(75329),w=function(e){var n=e.format,t=e.origin,u=void 0===t?"table":t,h=(0,m.Z)(),C=h.createCustomType,f=h.closeModals,w=(0,i.v9)(function(e){return{customTypeIds:(0,j.W6)(e),customTypeLabels:(0,j.YS)(e),isCreateCustomTypeModalOpen:(0,g.gP)(e,v.q.CREATE_CUSTOM_TYPE),isCreatingCustomType:(0,_.hg)(e,y.z.CREATE_CUSTOM_TYPE)}}),S=w.customTypeIds,k=w.isCreateCustomTypeModalOpen,Z=w.isCreatingCustomType,H=w.customTypeLabels,M=x.$[n],N=(0,l.useState)(!0),E=N[0],I=N[1],R=function(e){var t=e.id,r=e.label,s=e.repeatable,a=r||t;b.Xe.track({event:"custom-type:created",id:t,name:a,format:n,type:s?"repeatable":"single",origin:u}),C(t,a,s,n),f(),I(!0)},V=function(e,n,t){t(E?(0,s.Z)((0,r.Z)({},n),{label:e.target.value,id:(0,T.lV)(e.target.value)}):(0,s.Z)((0,r.Z)({},n),{label:e.target.value}))},z=function(e,n){n("id",e.target.value),I(!1)};return(0,a.jsx)(d.Z,{dataCy:"create-ct-modal",isOpen:k,widthInPx:"530px",formId:"create-custom-type",buttonLabel:"Create",close:function(){f(),I(!0)},onSubmit:R,isLoading:Z,initialValues:{repeatable:!0,id:"",label:""},validate:function(e){var n=e.id,t=e.label,r={};return t&&t.length||(r.label="Cannot be empty."),!r.label&&H.includes(t)&&(r.label="".concat(M.name({start:!0,plural:!1})," name is already taken.")),n&&n.length||(r.id="ID cannot be empty."),r.id||!n||L.xo.exec(n)||(r.id="Invalid id: No special characters allowed."),!r.id&&n&&S.map(function(e){return e.toLowerCase()}).includes(n)&&(r.id='ID "'.concat(n,'" exists already.')),Object.keys(r).length>0?r:void 0},content:{title:"Create a new ".concat(M.name({start:!1,plural:!1}))},children:function(e){var t=e.errors,r=e.setValues,s=e.setFieldValue,l=e.values,i=e.touched;return(0,a.jsxs)(c.xu,{children:[(0,a.jsx)(p,{format:n}),(0,a.jsx)(o.W,{name:"label",label:"".concat(M.name({start:!0,plural:!1})," Name"),dataCy:"ct-name-input",placeholder:"A display name for the ".concat(M.name({start:!1,plural:!1})),error:i.label?t.label:void 0,onChange:function(e){return V(e,l,r)}}),(0,a.jsx)(o.W,{name:"id",dataCy:"ct-id-input",label:"".concat(M.name({start:!0,plural:!1})," ID"),placeholder:M.inputPlaceholder,error:i.id?t.id:void 0,onChange:function(e){return z(e,s)}})]})}})}},840:function(e,n,t){"use strict";t.d(n,{F:function(){return D}});var r=t(52322),s=t(2784),a=t(22715),l=t(97729),c=t.n(l),i=t(56580),d=t(5327),o=t(90374),u=t(32665),h=t(3098),x=t(80131),C=t(78656),f=t(5632),p=t(67557),m=t(50002),j=t(6277);t(80207);var g=function(e){var n=e.children;return(0,r.jsx)("div",{className:"_1ecs97de7i _1ecs97de7n _1ecs97d39c _1ecs97d3gp _1ecs97de99 _1ecs97deal _1ecs97deaz _1ecs97de89",children:(0,r.jsx)("table",{className:"gdfsm51 _1ecs97de7i _1ecs97de7n _1ecs97dec6 _1ecs97ded9",children:n})})},v=(0,s.createContext)("body");function _(){return(0,s.useContext)(v)}var y=function(e){var n=e.children;return(0,r.jsx)(v.Provider,{value:"head",children:(0,r.jsx)("thead",{className:"gdfsm52 _1ecs97de7i _1ecs97de7n _1ecs97d18 _1ecs97d8l",children:n})})},b=function(e){var n=e.children;return(0,r.jsx)(v.Provider,{value:"body",children:(0,r.jsx)("tbody",{className:"gdfsm53 _1ecs97de7i _1ecs97de7n",children:n})})},T=function(e){var n,t=e.children,s=e.onClick,a=_();return(0,r.jsx)("tr",{className:(0,j.W)("_1ecs97de7i _1ecs97de7n _1ecs97deff",(n={},(0,p.Z)(n,"_1ecs97decf",!!s),(0,p.Z)(n,"_1ecs97dm _1ecs97d7z _1ecs97d3c _1ecs97dap _1ecs97d2w _1ecs97da9 _1ecs97defi _1ecs97der0 _1ecs97de8v _1ecs97der3","body"===a),n)),onClick:function(e){var n,t=e.target;if(s&&e.currentTarget.contains(t)){var r=(0,m.JY)(t);(null===(n=null==r?void 0:r.contains(e.currentTarget))||void 0===n||n)&&s(e)}},children:t})},L=function(e){var n=e.children,t=_();return(0,r.jsx)("head"===t?"th":"td",{className:"gdfsm55 _1ecs97de7i _1ecs97de7n _1ecs97d39c _1ecs97d3gp _1ecs97deaz _1ecs97de7j _1ecs97d9nq _1ecs97d9v3 _1ecs97decj _1ecs97depd",children:(0,r.jsx)("div",{className:"gdfsm56 _1ecs97de7i _1ecs97de7k",children:n})})},w=function(){return(0,r.jsxs)("svg",{width:"32",height:"32",viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,r.jsx)("path",{d:"M8 28H24C25.1046 28 26 27.1046 26 26V9L21 4H8C6.89543 4 6 4.89543 6 6V26C6 27.1046 6.89543 28 8 28Z",fill:"#6E56CF"}),(0,r.jsx)("path",{d:"M23 9H26L21 4V7C21 8.10457 21.8954 9 23 9Z",fill:"#9E8CFC"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M16.0912 12C13.2794 12 11 14.2794 11 17.0912C11 19.903 13.2794 22.1824 16.0912 22.1824C17.9763 22.1824 19.6215 21.1577 20.501 19.6372C20.6563 19.3688 20.7878 19.0849 20.8926 18.7883C20.9846 18.5279 20.8482 18.2422 20.5878 18.1502C20.3275 18.0582 20.0418 18.1947 19.9498 18.455C19.8657 18.693 19.7601 18.9209 19.6354 19.1365C18.9273 20.3606 17.6049 21.1824 16.0912 21.1824C13.8317 21.1824 12 19.3507 12 17.0912C12 14.8317 13.8317 13 16.0912 13C17.4478 13 18.6507 13.66 19.3955 14.6782H17.6216C17.3455 14.6782 17.1216 14.9021 17.1216 15.1782C17.1216 15.4544 17.3455 15.6782 17.6216 15.6782H20.2998C20.576 15.6782 20.7998 15.4544 20.7998 15.1782V12.5C20.7998 12.2239 20.576 12 20.2998 12C20.0237 12 19.7998 12.2239 19.7998 12.5V13.6032C18.8717 12.6167 17.5536 12 16.0912 12Z",fill:"white"})]})},S=function(){return(0,r.jsxs)("svg",{width:"32",height:"32",viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,r.jsx)("path",{d:"M8 28H24C25.1046 28 26 27.1046 26 26V9L21 4H8C6.89543 4 6 4.89543 6 6V26C6 27.1046 6.89543 28 8 28Z",fill:"#6E56CF"}),(0,r.jsx)("path",{d:"M23 9H26L21 4V7C21 8.10457 21.8954 9 23 9Z",fill:"#9E8CFC"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M14.0869 14.6818L14.6627 12.3787C14.7183 12.1561 14.9183 12 15.1477 12C15.473 12 15.7117 12.3057 15.6328 12.6213L15.1177 14.6818H17.7232L18.299 12.3787C18.3547 12.1561 18.5547 12 18.7841 12C19.1094 12 19.3481 12.3057 19.2692 12.6213L18.754 14.6818H21C21.2761 14.6818 21.5 14.9057 21.5 15.1818C21.5 15.458 21.2761 15.6818 21 15.6818H18.504L17.8449 18.3182H20C20.2761 18.3182 20.5 18.542 20.5 18.8182C20.5 19.0943 20.2761 19.3182 20 19.3182H17.5949L17.0192 21.6213C16.9635 21.8439 16.7635 22 16.5341 22C16.2088 22 15.9701 21.6943 16.049 21.3787L16.5642 19.3182H13.9586L13.3828 21.6213C13.3272 21.8439 13.1272 22 12.8977 22C12.5724 22 12.3338 21.6943 12.4127 21.3787L12.9278 19.3182H11C10.7239 19.3182 10.5 19.0943 10.5 18.8182C10.5 18.542 10.7239 18.3182 11 18.3182H13.1778L13.8369 15.6818H12C11.7239 15.6818 11.5 15.458 11.5 15.1818C11.5 14.9057 11.7239 14.6818 12 14.6818H14.0869ZM16.8142 18.3182L17.4732 15.6818H14.8677L14.2086 18.3182H16.8142Z",fill:"white"})]})},k=t(67445),Z=t(22710),H=t(99267),M=t(17329),N=t(40147),E=t(49471),I=t(7819),R=t(75708);function V(e){return z.apply(this,arguments)}function z(){return(z=(0,Z.Z)(function(e){var n,t,r;return(0,H.__generator)(this,function(s){switch(s.label){case 0:return[4,N.j.customTypes.readAllCustomTypes({format:e})];case 1:if(t=(n=s.sent()).errors,r=n.models,t.length>0)throw t;return[2,r.map(function(e){return e.model})]}})})).apply(this,arguments)}var P=t(2754),O=t(62607),A=function(e){var n,t,l,c,d,u,h=e.format,x=e.isCreatingCustomType,p=(0,o.Z)().openCreateCustomTypeModal,m=(0,f.useRouter)(),j=(t=(0,s.useCallback)(function(e){return(0,M.VA)(V,[h],e)},[h]),{customTypes:(0,M.QT)(V,[h]),updateCustomTypes:t}),v=j.customTypes,_=j.updateCustomTypes,Z=v.sort(function(e,n){return e.id.localeCompare(n.id)}),H=k.cd[h],N=C.$[h];return(u=(0,i.v9)(function(e){return{storeCustomTypes:(0,E.Ch)(e).filter(I.TG)}}).storeCustomTypes,(0,s.useEffect)(function(){var e=u.filter(function(e){return e.local.format===h});(e.length!==v.length||e.some(function(e){var n=v.find(function(n){return n.id===e.local.id});return!n||JSON.stringify(R.Dc.fromSM(e.local))!==JSON.stringify(n)}))&&_(e.map(function(e){var n=e.local;return R.Dc.fromSM(n)}))},[h,_,v,u]),0===Z.length)?(0,r.jsxs)(P.R$,{style:{alignSelf:"center",marginTop:a.TV.size[72]},children:[(0,r.jsx)(P.u2,{children:(0,r.jsx)(a.Ee,{src:H.blankSlateImage,sizing:"cover"})}),(0,r.jsxs)(P.T9,{children:[(0,r.jsx)(P._T,{children:N.name({start:!0,plural:!0})}),(0,r.jsx)(P.nf,{children:N.blankSlateDescription}),(0,r.jsx)(P.Qj,{children:(0,r.jsx)(a.zx,{onClick:p,loading:x,children:"Create"})})]})]}):(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)(g,{children:[(0,r.jsx)(y,{children:(0,r.jsxs)(T,{children:[(0,r.jsx)(L,{children:(0,r.jsx)(a.I5,{name:"notes",size:"medium"})}),(0,r.jsx)(L,{children:"Label"}),(0,r.jsx)(L,{children:"API ID"}),(0,r.jsx)(L,{children:"Limit"}),(0,r.jsx)(L,{})]})}),(0,r.jsx)(b,{children:Z.map(function(e){var n=e.repeatable,t=e.label,s=e.id;return(0,r.jsxs)(T,{onClick:function(){m.push(k.cd[h].getBuilderPagePathname(s))},children:[(0,r.jsx)(L,{children:n?(0,r.jsx)(w,{}):(0,r.jsx)(S,{})}),(0,r.jsx)(L,{children:t}),(0,r.jsx)(L,{children:s}),(0,r.jsx)(L,{children:n?"Reusable":"Single"}),(0,r.jsx)(L,{children:(0,r.jsx)(O._,{isChangesLocal:!1,format:h,customType:e})})]},s)})})]})})},D=function(e){var n=e.format,t=C.$[n],l=(0,o.Z)().openCreateCustomTypeModal,f=(0,i.v9)(function(e){return{isCreatingCustomType:(0,u.hg)(e,h.z.CREATE_CUSTOM_TYPE)}}).isCreatingCustomType;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(c(),{children:(0,r.jsxs)("title",{children:[t.name({start:!0,plural:!0})," - Slice Machine"]})}),(0,r.jsx)(a.SV,{renderError:function(){return(0,r.jsx)(d.LN,{children:(0,r.jsx)(d.RN,{children:(0,r.jsx)(a.xu,{alignItems:"center",justifyContent:"center",children:(0,r.jsx)(a.Iq,{title:"Request failed",description:"An error occurred while fetching your ".concat(t.name({start:!1,plural:!0}),".")})})})})},children:(0,r.jsx)(s.Suspense,{fallback:(0,r.jsxs)(d.LN,{children:[(0,r.jsxs)(d.wd,{children:[(0,r.jsx)(d.Cx,{folder:t.name({start:!0,plural:!0})}),(0,r.jsx)(d.K2,{children:(0,r.jsx)(a.zx,{disabled:!0,startIcon:"add",children:"Create"})})]}),(0,r.jsx)(d.RN,{children:(0,r.jsx)(a._3,{})})]}),children:(0,r.jsxs)(d.LN,{children:[(0,r.jsxs)(d.wd,{children:[(0,r.jsx)(d.Cx,{folder:t.name({start:!0,plural:!0})}),(0,r.jsx)(d.K2,{children:(0,r.jsx)(a.zx,{"data-cy":"create-ct",loading:f,onClick:l,startIcon:"add",children:"Create"})})]}),(0,r.jsx)(d.RN,{children:(0,r.jsxs)(a.xu,{flexDirection:"column",children:[(0,r.jsx)(A,{format:n,isCreatingCustomType:f}),(0,r.jsx)(x.M,{format:n})]})})]})})})]})}},80207:function(){}}]);