slice-machine-ui 1.20.1-dev-environments.1 → 1.20.1-dev-next-release.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/components/AppLayout/index.tsx +10 -34
- package/components/Navigation/index.tsx +2 -15
- package/out/404.html +1 -1
- package/out/_next/static/chunks/840-884e41a48b92e5d3.js +1 -0
- package/out/_next/static/chunks/904-69cc3c4be2bff626.js +1 -0
- package/out/_next/static/chunks/pages/{_app-f3478f5725df30c0.js → _app-990b6afa681c1060.js} +7 -7
- package/out/_next/static/chunks/pages/{changelog-4b8369d91d82b28b.js → changelog-fa36b9995c26e1d7.js} +1 -1
- package/out/_next/static/chunks/pages/changes-e388be4457a43c3a.js +1 -0
- package/out/_next/static/chunks/pages/labs-ebce03a4e7a95a4e.js +1 -0
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/{[variation]-724893d27ffa426c.js → [variation]-481c9b569db5ca0e.js} +1 -1
- package/out/_next/static/chunks/pages/slices-22db04643850c1d8.js +1 -0
- package/out/_next/static/css/{009bd7f5ac85fc6a.css → 412af4286eb0b283.css} +1 -1
- package/out/_next/static/mHdomNE5ByJ1GIQgA7J-S/_buildManifest.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 +4 -4
- package/pages/_app.tsx +4 -7
- package/pages/slices.tsx +0 -1
- package/src/components/PageLayout/PageLayout.css.ts +3 -8
- package/src/components/PageLayout/PageLayout.stories.tsx +1 -10
- package/src/components/PageLayout/PageLayout.tsx +2 -7
- package/src/components/SideNav/SideNav.css.ts +10 -3
- package/src/components/SideNav/SideNav.stories.tsx +2 -29
- package/src/components/SideNav/SideNav.tsx +1 -5
- package/src/components/SideNav/index.ts +0 -1
- package/src/features/customTypes/__tests__/CustomTypeBuilderPage.test.tsx +3 -4
- package/test/pages/slices.test.tsx +8 -4
- package/test/src/modules/__fixtures__/serverState.ts +0 -2
- package/components/Navigation/Environment.tsx +0 -47
- package/components/Navigation/index.css.ts +0 -6
- package/out/_next/static/VuNOMEY9KNCIOIr_WyriJ/_buildManifest.js +0 -1
- package/out/_next/static/chunks/840-5b485c737b24324b.js +0 -1
- package/out/_next/static/chunks/904-6204ab2ad8798857.js +0 -1
- package/out/_next/static/chunks/pages/changes-db6e8c6be5ae076e.js +0 -1
- package/out/_next/static/chunks/pages/labs-2922105ab714d32a.js +0 -1
- package/out/_next/static/chunks/pages/slices-93b7af2624c85b8e.js +0 -1
- package/src/components/Divider/Divider.css.ts +0 -31
- package/src/components/Divider/Divider.stories.tsx +0 -27
- package/src/components/Divider/Divider.tsx +0 -25
- package/src/components/Divider/index.ts +0 -1
- package/src/components/SideNav/SideNavEnvironmentSelector.css.ts +0 -69
- package/src/components/SideNav/SideNavEnvironmentSelector.tsx +0 -163
- package/src/features/environments/actions/getActiveEnvironmentDomain.ts +0 -11
- package/src/features/environments/actions/getEnvironments.ts +0 -12
- package/src/features/environments/actions/setEnvironment.ts +0 -18
- package/src/features/environments/useActiveEnvironment.ts +0 -38
- package/src/features/environments/useEnvironments.ts +0 -7
- package/src/features/legacyState/actions/getLegacySliceMachineState.ts +0 -53
- package/src/features/legacyState/useLegacySliceMachineState.ts +0 -7
- /package/out/_next/static/{VuNOMEY9KNCIOIr_WyriJ → mHdomNE5ByJ1GIQgA7J-S}/_ssgManifest.js +0 -0
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Box,
|
|
3
|
-
DropdownMenu,
|
|
4
|
-
DropdownMenuContent,
|
|
5
|
-
DropdownMenuItem,
|
|
6
|
-
DropdownMenuLabel,
|
|
7
|
-
DropdownMenuTrigger,
|
|
8
|
-
Icon,
|
|
9
|
-
IconButton,
|
|
10
|
-
Text,
|
|
11
|
-
} from "@prismicio/editor-ui";
|
|
12
|
-
import { Environment } from "@slicemachine/manager/client";
|
|
13
|
-
import type { FC } from "react";
|
|
14
|
-
import clsx from "clsx";
|
|
15
|
-
|
|
16
|
-
import LogoIcon from "@src/icons/LogoIcon";
|
|
17
|
-
|
|
18
|
-
import * as styles from "./SideNavEnvironmentSelector.css";
|
|
19
|
-
|
|
20
|
-
type SideNavEnvironmentSelectorProps = {
|
|
21
|
-
variant?: "default" | "unauthorized";
|
|
22
|
-
environments?: Environment[];
|
|
23
|
-
activeEnvironment?: Environment;
|
|
24
|
-
onSelect?: (environment: Environment) => void | Promise<void>;
|
|
25
|
-
onLogInClick?: () => void;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export const SideNavEnvironmentSelector: FC<SideNavEnvironmentSelectorProps> = (
|
|
29
|
-
props,
|
|
30
|
-
) => {
|
|
31
|
-
const {
|
|
32
|
-
variant = "default",
|
|
33
|
-
environments = [],
|
|
34
|
-
activeEnvironment,
|
|
35
|
-
onSelect,
|
|
36
|
-
onLogInClick,
|
|
37
|
-
} = props;
|
|
38
|
-
|
|
39
|
-
const isProductionEnvironmentActive = activeEnvironment?.kind === "prod";
|
|
40
|
-
|
|
41
|
-
return (
|
|
42
|
-
<Box alignItems="center" gap={16}>
|
|
43
|
-
<Box position="relative">
|
|
44
|
-
<LogoIcon className={styles.logo} />
|
|
45
|
-
{activeEnvironment !== undefined && (
|
|
46
|
-
<EnvironmentDot
|
|
47
|
-
kind={activeEnvironment.kind}
|
|
48
|
-
className={styles.activeEnvironmentDot}
|
|
49
|
-
/>
|
|
50
|
-
)}
|
|
51
|
-
</Box>
|
|
52
|
-
<Box flexGrow={1} flexDirection="column" overflow="hidden">
|
|
53
|
-
<Text component="span" variant="small" color="grey11">
|
|
54
|
-
Environment
|
|
55
|
-
</Text>
|
|
56
|
-
{variant === "unauthorized" ? (
|
|
57
|
-
<Text component="span" className={styles.actionRequiredLabel}>
|
|
58
|
-
Login required
|
|
59
|
-
</Text>
|
|
60
|
-
) : activeEnvironment === undefined ? (
|
|
61
|
-
<Text component="span" className={styles.actionRequiredLabel}>
|
|
62
|
-
Select environment
|
|
63
|
-
</Text>
|
|
64
|
-
) : (
|
|
65
|
-
<Text component="span" className={styles.activeEnvironmentName}>
|
|
66
|
-
{isProductionEnvironmentActive
|
|
67
|
-
? "Production"
|
|
68
|
-
: activeEnvironment?.name}
|
|
69
|
-
</Text>
|
|
70
|
-
)}
|
|
71
|
-
</Box>
|
|
72
|
-
<Box flexShrink={0}>
|
|
73
|
-
{variant === "unauthorized" ? (
|
|
74
|
-
<IconButton icon="arrowForward" onClick={onLogInClick} />
|
|
75
|
-
) : !activeEnvironment || environments.length > 1 ? (
|
|
76
|
-
<EnvironmentDropdownMenu
|
|
77
|
-
environments={environments}
|
|
78
|
-
activeEnvironment={activeEnvironment}
|
|
79
|
-
onSelect={onSelect}
|
|
80
|
-
/>
|
|
81
|
-
) : null}
|
|
82
|
-
</Box>
|
|
83
|
-
</Box>
|
|
84
|
-
);
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
type EnvironmentDropdownMenuProps = Pick<
|
|
88
|
-
SideNavEnvironmentSelectorProps,
|
|
89
|
-
"environments" | "activeEnvironment" | "onSelect"
|
|
90
|
-
>;
|
|
91
|
-
|
|
92
|
-
const EnvironmentDropdownMenu: FC<EnvironmentDropdownMenuProps> = (props) => {
|
|
93
|
-
const { environments = [], activeEnvironment, onSelect } = props;
|
|
94
|
-
|
|
95
|
-
return (
|
|
96
|
-
<DropdownMenu modal>
|
|
97
|
-
<DropdownMenuTrigger>
|
|
98
|
-
<IconButton icon="unfoldMore" />
|
|
99
|
-
</DropdownMenuTrigger>
|
|
100
|
-
<DropdownMenuContent align="end" minWidth={256}>
|
|
101
|
-
<DropdownMenuLabel>Regular Environments</DropdownMenuLabel>
|
|
102
|
-
{environments.map((environment) =>
|
|
103
|
-
environment.kind !== "dev" ? (
|
|
104
|
-
<EnvironmentDropdownMenuItem
|
|
105
|
-
key={environment.domain}
|
|
106
|
-
environment={environment}
|
|
107
|
-
onSelect={onSelect}
|
|
108
|
-
isActive={environment.domain === activeEnvironment?.domain}
|
|
109
|
-
/>
|
|
110
|
-
) : (
|
|
111
|
-
<>
|
|
112
|
-
<DropdownMenuLabel>Personal Environment</DropdownMenuLabel>
|
|
113
|
-
<EnvironmentDropdownMenuItem
|
|
114
|
-
key={environment.domain}
|
|
115
|
-
environment={environment}
|
|
116
|
-
onSelect={onSelect}
|
|
117
|
-
isActive={environment.domain === activeEnvironment?.domain}
|
|
118
|
-
/>
|
|
119
|
-
</>
|
|
120
|
-
),
|
|
121
|
-
)}
|
|
122
|
-
</DropdownMenuContent>
|
|
123
|
-
</DropdownMenu>
|
|
124
|
-
);
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
type EnvironmentDropdownMenuItemProps = {
|
|
128
|
-
environment: Environment;
|
|
129
|
-
isActive?: boolean;
|
|
130
|
-
} & Pick<SideNavEnvironmentSelectorProps, "onSelect">;
|
|
131
|
-
|
|
132
|
-
const EnvironmentDropdownMenuItem: FC<EnvironmentDropdownMenuItemProps> = (
|
|
133
|
-
props,
|
|
134
|
-
) => {
|
|
135
|
-
const { environment, onSelect, isActive } = props;
|
|
136
|
-
const isProductionEnvironment = environment.kind === "prod";
|
|
137
|
-
|
|
138
|
-
return (
|
|
139
|
-
<DropdownMenuItem
|
|
140
|
-
startIcon={
|
|
141
|
-
<EnvironmentDot
|
|
142
|
-
kind={environment.kind}
|
|
143
|
-
className={styles.menuItemEnvironmentDot}
|
|
144
|
-
/>
|
|
145
|
-
}
|
|
146
|
-
endIcon={Boolean(isActive) ? <Icon name="check" /> : undefined}
|
|
147
|
-
onSelect={() => void onSelect?.(environment)}
|
|
148
|
-
>
|
|
149
|
-
{isProductionEnvironment ? "Production" : environment.name}
|
|
150
|
-
</DropdownMenuItem>
|
|
151
|
-
);
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
type EnvironmentDotProps = {
|
|
155
|
-
kind: Environment["kind"];
|
|
156
|
-
className?: string;
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
const EnvironmentDot: FC<EnvironmentDotProps> = (props) => {
|
|
160
|
-
const { kind, className } = props;
|
|
161
|
-
|
|
162
|
-
return <div className={clsx(styles.environmentDot[kind], className)} />;
|
|
163
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { managerClient } from "@src/managerClient";
|
|
2
|
-
|
|
3
|
-
export async function getActiveEnvironmentDomain() {
|
|
4
|
-
try {
|
|
5
|
-
const { environment } = await managerClient.project.readEnvironment();
|
|
6
|
-
|
|
7
|
-
return { activeEnvironmentDomain: environment };
|
|
8
|
-
} catch (error) {
|
|
9
|
-
return { error };
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { managerClient } from "@src/managerClient";
|
|
2
|
-
|
|
3
|
-
export async function getEnvironments() {
|
|
4
|
-
try {
|
|
5
|
-
const environments =
|
|
6
|
-
await managerClient.prismicRepository.fetchEnvironments();
|
|
7
|
-
|
|
8
|
-
return { environments };
|
|
9
|
-
} catch (error) {
|
|
10
|
-
return { error };
|
|
11
|
-
}
|
|
12
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { revalidateData } from "@prismicio/editor-support/Suspense";
|
|
2
|
-
import { Environment } from "@slicemachine/manager/client";
|
|
3
|
-
|
|
4
|
-
import { getLegacySliceMachineState } from "@src/features/legacyState/actions/getLegacySliceMachineState";
|
|
5
|
-
import { managerClient } from "@src/managerClient";
|
|
6
|
-
|
|
7
|
-
import { getActiveEnvironmentDomain } from "./getActiveEnvironmentDomain";
|
|
8
|
-
|
|
9
|
-
export async function setEnvironment(
|
|
10
|
-
environment: Pick<Environment, "domain">,
|
|
11
|
-
): Promise<void> {
|
|
12
|
-
await managerClient.project.updateEnvironment({
|
|
13
|
-
environment: environment.domain,
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
revalidateData(getActiveEnvironmentDomain, []);
|
|
17
|
-
revalidateData(getLegacySliceMachineState, []);
|
|
18
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { useRequest } from "@prismicio/editor-support/Suspense";
|
|
2
|
-
|
|
3
|
-
import { getActiveEnvironmentDomain } from "./actions/getActiveEnvironmentDomain";
|
|
4
|
-
import { useEnvironments } from "./useEnvironments";
|
|
5
|
-
|
|
6
|
-
export function useActiveEnvironment() {
|
|
7
|
-
const { environments, error: useEnvironmentsError } = useEnvironments();
|
|
8
|
-
const { activeEnvironmentDomain, error: getActiveEnvironmentError } =
|
|
9
|
-
useRequest(getActiveEnvironmentDomain, []);
|
|
10
|
-
|
|
11
|
-
if (useEnvironmentsError !== undefined) {
|
|
12
|
-
return { error: useEnvironmentsError };
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
if (getActiveEnvironmentError !== undefined) {
|
|
16
|
-
return { error: getActiveEnvironmentError };
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const activeEnvironment = environments?.find((environment) => {
|
|
20
|
-
if (activeEnvironmentDomain === undefined) {
|
|
21
|
-
return environment.kind === "prod";
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return environment.domain === activeEnvironmentDomain;
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
if (!activeEnvironment) {
|
|
28
|
-
return {
|
|
29
|
-
error: new Error(
|
|
30
|
-
`The active environment (${
|
|
31
|
-
activeEnvironmentDomain ?? "Production"
|
|
32
|
-
}) does not match one of the repository's environments.`,
|
|
33
|
-
),
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return { activeEnvironment };
|
|
38
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import ServerState from "@models/server/ServerState";
|
|
2
|
-
import { Slices } from "@lib/models/common/Slice";
|
|
3
|
-
import { CustomTypes } from "@lib/models/common/CustomType";
|
|
4
|
-
import { managerClient } from "@src/managerClient";
|
|
5
|
-
|
|
6
|
-
export async function getLegacySliceMachineState() {
|
|
7
|
-
const rawState = await managerClient.getState();
|
|
8
|
-
|
|
9
|
-
// `rawState` from the client contains non-SM-specific models. We need to
|
|
10
|
-
// transform the data to something SM recognizes.
|
|
11
|
-
const state: ServerState = {
|
|
12
|
-
...rawState,
|
|
13
|
-
libraries: rawState.libraries.map((library) => {
|
|
14
|
-
return {
|
|
15
|
-
...library,
|
|
16
|
-
components: library.components.map((component) => {
|
|
17
|
-
return {
|
|
18
|
-
...component,
|
|
19
|
-
model: Slices.toSM(component.model),
|
|
20
|
-
|
|
21
|
-
// Replace screnshot Blobs with URLs.
|
|
22
|
-
screenshots: Object.fromEntries(
|
|
23
|
-
Object.entries(component.screenshots).map(
|
|
24
|
-
([variationID, screenshot]) => {
|
|
25
|
-
return [
|
|
26
|
-
variationID,
|
|
27
|
-
{
|
|
28
|
-
...screenshot,
|
|
29
|
-
url: URL.createObjectURL(screenshot.data),
|
|
30
|
-
},
|
|
31
|
-
];
|
|
32
|
-
},
|
|
33
|
-
),
|
|
34
|
-
),
|
|
35
|
-
};
|
|
36
|
-
}),
|
|
37
|
-
};
|
|
38
|
-
}),
|
|
39
|
-
customTypes: rawState.customTypes.map((customTypeModel) => {
|
|
40
|
-
return CustomTypes.toSM(customTypeModel);
|
|
41
|
-
}),
|
|
42
|
-
remoteCustomTypes: rawState.remoteCustomTypes.map(
|
|
43
|
-
(remoteCustomTypeModel) => {
|
|
44
|
-
return CustomTypes.toSM(remoteCustomTypeModel);
|
|
45
|
-
},
|
|
46
|
-
),
|
|
47
|
-
remoteSlices: rawState.remoteSlices.map((remoteSliceModel) => {
|
|
48
|
-
return Slices.toSM(remoteSliceModel);
|
|
49
|
-
}),
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
return state;
|
|
53
|
-
}
|
|
File without changes
|