slice-machine-ui 1.24.1-beta.5 → 1.24.1-beta.7
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/App/index.tsx +0 -2
- package/components/Changelog/index.tsx +29 -40
- package/components/Changelog/navigation/index.tsx +27 -23
- package/components/Changelog/versionDetails/{ReleaseNoteDetails.tsx → ReleaseNotesDetails.tsx} +5 -5
- package/components/Changelog/versionDetails/UpdateCommandBox.tsx +15 -11
- package/components/Changelog/versionDetails/VersionKindLabel.tsx +3 -2
- package/components/Changelog/versionDetails/index.tsx +17 -16
- package/components/Navigation/RunningVersion.tsx +14 -0
- package/components/Navigation/UpdateBox.tsx +16 -0
- package/components/Navigation/index.test.tsx +10 -35
- package/components/Navigation/index.tsx +14 -29
- package/components/ScreenshotChangesModal/VariationDropZone.tsx +18 -19
- package/lib/models/common/Environment.ts +0 -2
- package/out/404.html +1 -1
- package/out/_next/static/{CX_VpC44wSUExDDmSr6ZF → 1pfD8kf3T_M14h3yL2oNi}/_buildManifest.js +1 -1
- package/out/_next/static/chunks/286-877cd7b96660f95f.js +1 -0
- package/out/_next/static/chunks/{727-c6c0c0d8c72c2676.js → 727-ffb4c69fbb971ed7.js} +1 -1
- package/out/_next/static/chunks/{904-c09e8a519129a3d8.js → 904-d9089efa6d974e3e.js} +1 -1
- package/out/_next/static/chunks/pages/{_app-2d7dea178f8d87cc.js → _app-dc8dc7dc0c053ac9.js} +24 -24
- package/out/_next/static/chunks/pages/changelog-57289ca6bc99702b.js +1 -0
- package/out/_next/static/chunks/pages/{changes-0623b15f5e49d3b0.js → changes-ea6064c1db5ab5e1.js} +1 -1
- package/out/_next/static/chunks/pages/{labs-773e5e6044d04247.js → labs-85d5c752dd5148b6.js} +1 -1
- package/out/_next/static/chunks/pages/{settings-934f8c6734b9c427.js → settings-5182a8e6bdb92822.js} +1 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/{[variation]-4cd51835ba731872.js → [variation]-89c911fd39271b5d.js} +1 -1
- package/out/_next/static/chunks/pages/{slices-e0ce615c38e8338d.js → slices-5dc0c55c386e047a.js} +1 -1
- 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/settings.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/apiClient.ts +0 -50
- package/src/features/changelog/useSliceMachineLatestNonBreakingVersion.ts +14 -0
- package/src/features/changelog/useSliceMachineReleaseNotes.ts +16 -0
- package/src/features/changelog/useSliceMachineVersions.ts +15 -0
- package/src/features/customTypes/customTypesBuilder/PageSnippetDialog/PageSnippetDialog.tsx +4 -6
- package/src/features/documentation/MarkdownRenderer/index.tsx +4 -6
- package/src/hooks/useAdapterName.ts +4 -5
- package/src/hooks/useMarketingContent.ts +0 -3
- package/src/hooks/useSliceMachineRunningVersion.ts +14 -0
- package/src/hooks/useUpdateAvailable.ts +17 -0
- package/src/modules/environment/index.ts +2 -71
- package/src/modules/loading/types.ts +0 -2
- package/src/modules/useSliceMachineActions.ts +2 -11
- package/src/modules/userContext/index.ts +0 -19
- package/src/modules/userContext/types.ts +0 -4
- package/src/redux/saga.ts +0 -2
- package/test/src/modules/__fixtures__/serverState.ts +0 -13
- package/test/src/modules/environment.test.ts +0 -57
- package/test/src/modules/userContext.test.ts +0 -31
- package/lib/models/common/versions.ts +0 -39
- package/out/_next/static/chunks/286-ed90373e9a469944.js +0 -1
- package/out/_next/static/chunks/pages/changelog-cb1df3a70b20f1b8.js +0 -1
- package/src/hooks/useChangelog.ts +0 -12
- package/test/pages/simulator.test.tsx +0 -332
- /package/out/_next/static/{CX_VpC44wSUExDDmSr6ZF → 1pfD8kf3T_M14h3yL2oNi}/_ssgManifest.js +0 -0
package/components/App/index.tsx
CHANGED
|
@@ -10,7 +10,6 @@ import useServerState from "@src/hooks/useServerState";
|
|
|
10
10
|
import { SliceMachineStoreType } from "@src/redux/type";
|
|
11
11
|
import { getLibraries } from "@src/modules/slices";
|
|
12
12
|
import useSMTracker from "@src/hooks/useSMTracker";
|
|
13
|
-
import { useChangelog } from "@src/hooks/useChangelog";
|
|
14
13
|
|
|
15
14
|
type Props = Readonly<{
|
|
16
15
|
children?: ReactNode;
|
|
@@ -23,7 +22,6 @@ const SliceMachineApp: FC<Props> = ({ children }) => {
|
|
|
23
22
|
|
|
24
23
|
useSMTracker();
|
|
25
24
|
useServerState();
|
|
26
|
-
useChangelog();
|
|
27
25
|
|
|
28
26
|
return (
|
|
29
27
|
<>
|
|
@@ -1,65 +1,54 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BaseStyles
|
|
1
|
+
import { Suspense, useEffect, useState } from "react";
|
|
2
|
+
import { BaseStyles } from "theme-ui";
|
|
3
3
|
import { useSelector } from "react-redux";
|
|
4
|
+
import { ErrorBoundary, ProgressCircle } from "@prismicio/editor-ui";
|
|
5
|
+
|
|
6
|
+
import { Version } from "@slicemachine/manager";
|
|
7
|
+
import { AppLayout, AppLayoutContent } from "@components/AppLayout";
|
|
8
|
+
import { useSliceMachineVersions } from "@src/features/changelog/useSliceMachineVersions";
|
|
4
9
|
import { SliceMachineStoreType } from "@src/redux/type";
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
import { PackageVersion } from "@models/common/versions";
|
|
10
|
+
import { getPackageManager } from "@src/modules/environment";
|
|
11
|
+
|
|
8
12
|
import { Navigation } from "./navigation";
|
|
9
13
|
import { VersionDetails, ReleaseWarning } from "./versionDetails";
|
|
10
|
-
import { isLoading } from "@src/modules/loading";
|
|
11
|
-
import { LoadingKeysEnum } from "@src/modules/loading/types";
|
|
12
|
-
import { AppLayout, AppLayoutContent } from "@components/AppLayout";
|
|
13
14
|
|
|
14
15
|
export default function Changelog() {
|
|
15
|
-
const {
|
|
16
|
-
(store
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}),
|
|
21
|
-
);
|
|
16
|
+
const { packageManager } = useSelector((store: SliceMachineStoreType) => ({
|
|
17
|
+
packageManager: getPackageManager(store),
|
|
18
|
+
}));
|
|
19
|
+
const versions = useSliceMachineVersions();
|
|
20
|
+
const latestVersion = versions[0];
|
|
22
21
|
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
PackageVersion | undefined
|
|
27
|
-
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
28
|
-
>(latestVersion || undefined);
|
|
22
|
+
const [selectedVersion, setSelectedVersion] = useState<Version | undefined>(
|
|
23
|
+
latestVersion ?? undefined,
|
|
24
|
+
);
|
|
29
25
|
|
|
30
26
|
useEffect(() => {
|
|
31
27
|
setSelectedVersion(latestVersion);
|
|
32
28
|
}, [latestVersion]);
|
|
33
29
|
|
|
34
|
-
const showReleaseWarning =
|
|
35
|
-
changelog.sliceMachine.versions.length === 0 || !selectedVersion;
|
|
30
|
+
const showReleaseWarning = versions.length === 0 || !selectedVersion;
|
|
36
31
|
|
|
37
32
|
return (
|
|
38
33
|
<AppLayout>
|
|
39
34
|
<AppLayoutContent>
|
|
40
35
|
<BaseStyles sx={{ display: "flex", minWidth: 0 }}>
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
selectedVersion={selectedVersion}
|
|
46
|
-
selectVersion={(version) => setSelectedVersion(version)}
|
|
47
|
-
/>
|
|
36
|
+
<Navigation
|
|
37
|
+
selectedVersion={selectedVersion}
|
|
38
|
+
selectVersion={(version) => setSelectedVersion(version)}
|
|
39
|
+
/>
|
|
48
40
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
41
|
+
{showReleaseWarning ? (
|
|
42
|
+
<ReleaseWarning />
|
|
43
|
+
) : (
|
|
44
|
+
<ErrorBoundary renderError={() => <ReleaseWarning />}>
|
|
45
|
+
<Suspense fallback={<ProgressCircle />}>
|
|
54
46
|
<VersionDetails
|
|
55
|
-
changelog={changelog}
|
|
56
47
|
selectedVersion={selectedVersion}
|
|
57
48
|
packageManager={packageManager}
|
|
58
49
|
/>
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
) : (
|
|
62
|
-
<ProgressCircle />
|
|
50
|
+
</Suspense>
|
|
51
|
+
</ErrorBoundary>
|
|
63
52
|
)}
|
|
64
53
|
</BaseStyles>
|
|
65
54
|
</AppLayoutContent>
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import { tokens } from "@prismicio/editor-ui";
|
|
2
1
|
import React from "react";
|
|
3
2
|
import { Flex, Text } from "theme-ui";
|
|
4
|
-
import {
|
|
3
|
+
import { tokens } from "@prismicio/editor-ui";
|
|
4
|
+
|
|
5
|
+
import { Version } from "@slicemachine/manager";
|
|
6
|
+
import { useSliceMachineVersions } from "@src/features/changelog/useSliceMachineVersions";
|
|
7
|
+
import { useSliceMachineLatestNonBreakingVersion } from "@src/features/changelog/useSliceMachineLatestNonBreakingVersion";
|
|
8
|
+
import { useSliceMachineRunningVersion } from "@src/hooks/useSliceMachineRunningVersion";
|
|
9
|
+
import { useUpdateAvailable } from "@src/hooks/useUpdateAvailable";
|
|
10
|
+
|
|
5
11
|
import { VersionBadge } from "./VersionBadge";
|
|
6
12
|
|
|
7
13
|
export enum VersionTags {
|
|
@@ -11,21 +17,21 @@ export enum VersionTags {
|
|
|
11
17
|
}
|
|
12
18
|
|
|
13
19
|
interface NavigationProps {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
selectVersion: (version: PackageVersion) => void;
|
|
20
|
+
selectedVersion: Version | undefined;
|
|
21
|
+
selectVersion: (version: Version) => void;
|
|
17
22
|
}
|
|
18
23
|
|
|
19
24
|
export const Navigation: React.FC<NavigationProps> = ({
|
|
20
|
-
changelog,
|
|
21
25
|
selectedVersion,
|
|
22
26
|
selectVersion,
|
|
23
27
|
}) => {
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
const versions = useSliceMachineVersions();
|
|
29
|
+
const { sliceMachineUpdateAvailable, adapterUpdateAvailable } =
|
|
30
|
+
useUpdateAvailable();
|
|
31
|
+
const latestNonBreakingVersion = useSliceMachineLatestNonBreakingVersion();
|
|
32
|
+
const runningVersion = useSliceMachineRunningVersion();
|
|
33
|
+
|
|
34
|
+
const latestVersion: string | undefined = versions[0]?.version;
|
|
29
35
|
|
|
30
36
|
function findVersionTags(versionNumber: string): VersionTags[] {
|
|
31
37
|
const tags = [];
|
|
@@ -33,14 +39,12 @@ export const Navigation: React.FC<NavigationProps> = ({
|
|
|
33
39
|
// Display Latest or LatestNonBreaking tag
|
|
34
40
|
if (versionNumber === latestVersion) {
|
|
35
41
|
tags.push(VersionTags.Latest);
|
|
36
|
-
} else if (
|
|
37
|
-
versionNumber === changelog.sliceMachine.latestNonBreakingVersion
|
|
38
|
-
) {
|
|
42
|
+
} else if (versionNumber === latestNonBreakingVersion) {
|
|
39
43
|
tags.push(VersionTags.LatestNonBreaking);
|
|
40
44
|
}
|
|
41
45
|
|
|
42
46
|
// Display Current tag
|
|
43
|
-
if (versionNumber ===
|
|
47
|
+
if (versionNumber === runningVersion) {
|
|
44
48
|
tags.push(VersionTags.Current);
|
|
45
49
|
}
|
|
46
50
|
|
|
@@ -93,16 +97,16 @@ export const Navigation: React.FC<NavigationProps> = ({
|
|
|
93
97
|
overflow: "auto",
|
|
94
98
|
}}
|
|
95
99
|
>
|
|
96
|
-
{
|
|
100
|
+
{versions.map((packageVersion, index) => (
|
|
97
101
|
<VersionBadge
|
|
98
|
-
key={`versionBadge-${version
|
|
99
|
-
isSelected={
|
|
100
|
-
|
|
102
|
+
key={`versionBadge-${packageVersion.version}-${index}`}
|
|
103
|
+
isSelected={selectedVersion?.version === packageVersion.version}
|
|
104
|
+
onClick={() => selectVersion(packageVersion)}
|
|
105
|
+
versionNumber={packageVersion.version}
|
|
106
|
+
tags={findVersionTags(packageVersion.version)}
|
|
107
|
+
hasUpToDateVersions={
|
|
108
|
+
!sliceMachineUpdateAvailable && !adapterUpdateAvailable
|
|
101
109
|
}
|
|
102
|
-
onClick={() => selectVersion(version)}
|
|
103
|
-
versionNumber={version.versionNumber}
|
|
104
|
-
tags={findVersionTags(version.versionNumber)}
|
|
105
|
-
hasUpToDateVersions={hasUpToDateVersions}
|
|
106
110
|
/>
|
|
107
111
|
))}
|
|
108
112
|
</Flex>
|
package/components/Changelog/versionDetails/{ReleaseNoteDetails.tsx → ReleaseNotesDetails.tsx}
RENAMED
|
@@ -2,12 +2,12 @@ import React from "react";
|
|
|
2
2
|
import { Text } from "theme-ui";
|
|
3
3
|
import { marked } from "marked";
|
|
4
4
|
|
|
5
|
-
interface
|
|
6
|
-
|
|
5
|
+
interface ReleaseNotesDetailsProps {
|
|
6
|
+
releaseNotes: string;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export const
|
|
10
|
-
|
|
9
|
+
export const ReleaseNotesDetails: React.FC<ReleaseNotesDetailsProps> = ({
|
|
10
|
+
releaseNotes,
|
|
11
11
|
}) => {
|
|
12
12
|
return (
|
|
13
13
|
<Text
|
|
@@ -37,7 +37,7 @@ export const ReleaseNoteDetails: React.FC<ReleaseNoteDetailsProps> = ({
|
|
|
37
37
|
},
|
|
38
38
|
}}
|
|
39
39
|
dangerouslySetInnerHTML={{
|
|
40
|
-
__html: marked.parse(
|
|
40
|
+
__html: marked.parse(releaseNotes),
|
|
41
41
|
}}
|
|
42
42
|
/>
|
|
43
43
|
);
|
|
@@ -1,36 +1,40 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Button, Flex, Text } from "theme-ui";
|
|
3
3
|
import { AiFillWarning } from "react-icons/ai";
|
|
4
|
-
|
|
5
|
-
import {
|
|
4
|
+
|
|
5
|
+
import type { PackageManager, Version } from "@slicemachine/manager";
|
|
6
|
+
import { useSliceMachineVersions } from "@src/features/changelog/useSliceMachineVersions";
|
|
6
7
|
import CodeBlock from "@components/CodeBlock";
|
|
8
|
+
import { useAdapterName } from "@src/hooks/useAdapterName";
|
|
9
|
+
import { useUpdateAvailable } from "@src/hooks/useUpdateAvailable";
|
|
7
10
|
|
|
8
11
|
interface UpdateCommandBoxProps {
|
|
9
|
-
|
|
10
|
-
selectedVersion: PackageVersion;
|
|
12
|
+
selectedVersion: Version;
|
|
11
13
|
packageManager: PackageManager;
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
export const UpdateCommandBox: React.FC<UpdateCommandBoxProps> = ({
|
|
15
|
-
changelog,
|
|
16
17
|
selectedVersion,
|
|
17
18
|
packageManager,
|
|
18
19
|
}) => {
|
|
20
|
+
const versions = useSliceMachineVersions();
|
|
21
|
+
const adapterName = useAdapterName();
|
|
22
|
+
const { sliceMachineUpdateAvailable, adapterUpdateAvailable } =
|
|
23
|
+
useUpdateAvailable();
|
|
24
|
+
|
|
19
25
|
const isLatestSliceMachineVersion =
|
|
20
|
-
selectedVersion.
|
|
21
|
-
changelog.sliceMachine.versions[0].versionNumber;
|
|
26
|
+
selectedVersion.version === versions[0].version;
|
|
22
27
|
const sliceMachineVersionToInstall = isLatestSliceMachineVersion
|
|
23
28
|
? "latest"
|
|
24
|
-
: selectedVersion.
|
|
29
|
+
: selectedVersion.version;
|
|
25
30
|
const packagesSpecs = getPackagesSpecs({
|
|
26
31
|
sliceMachineVersionToInstall,
|
|
27
32
|
isLatestSliceMachineVersion,
|
|
28
|
-
adapterName
|
|
33
|
+
adapterName,
|
|
29
34
|
});
|
|
30
35
|
const installCommand = getInstallCommand(packageManager, packagesSpecs);
|
|
31
36
|
const isOnlyAdapterUpdate =
|
|
32
|
-
|
|
33
|
-
!changelog.sliceMachine.updateAvailable;
|
|
37
|
+
adapterUpdateAvailable && !sliceMachineUpdateAvailable;
|
|
34
38
|
|
|
35
39
|
return (
|
|
36
40
|
<>
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { type ThemeUIStyleObject, Text } from "theme-ui";
|
|
3
3
|
import { transparentize } from "@theme-ui/color";
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
import { VersionKind } from "@slicemachine/manager";
|
|
5
6
|
|
|
6
7
|
interface VersionKindLabelProps {
|
|
7
8
|
versionKind: VersionKind;
|
|
@@ -15,7 +16,7 @@ export const VersionKindLabel: React.FC<VersionKindLabelProps> = ({
|
|
|
15
16
|
padding: "2px 4px",
|
|
16
17
|
borderRadius: "4px",
|
|
17
18
|
textTransform: "uppercase",
|
|
18
|
-
...(versionKind ===
|
|
19
|
+
...(versionKind === "MAJOR"
|
|
19
20
|
? {
|
|
20
21
|
color: "purple",
|
|
21
22
|
bg: transparentize("purple", 0.85),
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import { tokens } from "@prismicio/editor-ui";
|
|
2
1
|
import React from "react";
|
|
3
2
|
import { Flex, Text } from "theme-ui";
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
3
|
+
import { AiFillWarning } from "react-icons/ai";
|
|
4
|
+
import { tokens } from "@prismicio/editor-ui";
|
|
5
|
+
|
|
6
|
+
import type { PackageManager, Version } from "@slicemachine/manager";
|
|
7
|
+
import { useSliceMachineReleaseNotes } from "@src/features/changelog/useSliceMachineReleaseNotes";
|
|
8
|
+
|
|
6
9
|
import { VersionKindLabel } from "./VersionKindLabel";
|
|
7
|
-
import {
|
|
10
|
+
import { ReleaseNotesDetails } from "./ReleaseNotesDetails";
|
|
8
11
|
import { UpdateCommandBox } from "./UpdateCommandBox";
|
|
9
|
-
import { AiFillWarning } from "react-icons/ai";
|
|
10
12
|
|
|
11
13
|
interface VersionDetailsProps {
|
|
12
|
-
|
|
13
|
-
selectedVersion: PackageVersion;
|
|
14
|
+
selectedVersion: Version;
|
|
14
15
|
packageManager: PackageManager;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
export const ReleaseWarning = () => (
|
|
18
|
-
<
|
|
19
|
+
<Flex sx={{ paddingLeft: "32px" }}>
|
|
19
20
|
Could not fetch release notes.{" "}
|
|
20
21
|
<a
|
|
21
22
|
href="https://github.com/prismicio/slice-machine/releases"
|
|
@@ -24,14 +25,15 @@ export const ReleaseWarning = () => (
|
|
|
24
25
|
>
|
|
25
26
|
Find out more on GitHub
|
|
26
27
|
</a>
|
|
27
|
-
</
|
|
28
|
+
</Flex>
|
|
28
29
|
);
|
|
29
30
|
|
|
30
31
|
export const VersionDetails: React.FC<VersionDetailsProps> = ({
|
|
31
|
-
changelog,
|
|
32
32
|
selectedVersion,
|
|
33
33
|
packageManager,
|
|
34
34
|
}) => {
|
|
35
|
+
const releaseNotes = useSliceMachineReleaseNotes(selectedVersion.version);
|
|
36
|
+
|
|
35
37
|
return (
|
|
36
38
|
<Flex sx={{ flexDirection: "column" }}>
|
|
37
39
|
<Flex
|
|
@@ -50,7 +52,7 @@ export const VersionDetails: React.FC<VersionDetailsProps> = ({
|
|
|
50
52
|
lineHeight: "32px",
|
|
51
53
|
}}
|
|
52
54
|
>
|
|
53
|
-
{`Version ${selectedVersion.
|
|
55
|
+
{`Version ${selectedVersion.version}`}
|
|
54
56
|
</Text>
|
|
55
57
|
{!!selectedVersion.kind && (
|
|
56
58
|
<VersionKindLabel versionKind={selectedVersion.kind} />
|
|
@@ -65,7 +67,7 @@ export const VersionDetails: React.FC<VersionDetailsProps> = ({
|
|
|
65
67
|
}}
|
|
66
68
|
>
|
|
67
69
|
{/* eslint-disable-next-line @typescript-eslint/strict-boolean-expressions */}
|
|
68
|
-
{
|
|
70
|
+
{releaseNotes?.includes("# Breaking Change") && (
|
|
69
71
|
<Flex
|
|
70
72
|
sx={{
|
|
71
73
|
padding: "16px",
|
|
@@ -85,13 +87,12 @@ export const VersionDetails: React.FC<VersionDetailsProps> = ({
|
|
|
85
87
|
)}
|
|
86
88
|
|
|
87
89
|
<UpdateCommandBox
|
|
88
|
-
changelog={changelog}
|
|
89
90
|
selectedVersion={selectedVersion}
|
|
90
91
|
packageManager={packageManager}
|
|
91
92
|
/>
|
|
92
|
-
|
|
93
|
-
{
|
|
94
|
-
<
|
|
93
|
+
|
|
94
|
+
{releaseNotes !== undefined ? (
|
|
95
|
+
<ReleaseNotesDetails releaseNotes={releaseNotes} />
|
|
95
96
|
) : (
|
|
96
97
|
<ReleaseWarning />
|
|
97
98
|
)}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
|
|
3
|
+
import { RightElement } from "@src/components/SideNav";
|
|
4
|
+
import { useSliceMachineRunningVersion } from "@src/hooks/useSliceMachineRunningVersion";
|
|
5
|
+
|
|
6
|
+
export const RunningVersion: FC = () => {
|
|
7
|
+
const sliceMachineRunningVersion = useSliceMachineRunningVersion();
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<RightElement data-cy="slicemachine-version">
|
|
11
|
+
v{sliceMachineRunningVersion}
|
|
12
|
+
</RightElement>
|
|
13
|
+
);
|
|
14
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
import Link from "next/link";
|
|
3
|
+
|
|
4
|
+
import { useUpdateAvailable } from "@src/hooks/useUpdateAvailable";
|
|
5
|
+
import { UpdateInfo } from "@src/components/SideNav";
|
|
6
|
+
|
|
7
|
+
export const UpdateBox: FC = () => {
|
|
8
|
+
const { sliceMachineUpdateAvailable, adapterUpdateAvailable } =
|
|
9
|
+
useUpdateAvailable();
|
|
10
|
+
|
|
11
|
+
if (!sliceMachineUpdateAvailable && !adapterUpdateAvailable) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return <UpdateInfo href="/changelog" component={Link} />;
|
|
16
|
+
};
|
|
@@ -25,16 +25,15 @@ const mockRouter = vi.mocked(Router);
|
|
|
25
25
|
vi.mock("next/router", () => import("next-router-mock"));
|
|
26
26
|
|
|
27
27
|
type renderSideNavigationArgs = {
|
|
28
|
-
canUpdate: boolean;
|
|
29
28
|
hasChanges?: boolean;
|
|
30
29
|
authStatus?: AuthStatus;
|
|
31
30
|
};
|
|
32
31
|
|
|
33
|
-
function renderSideNavigation(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
authStatus = AuthStatus.AUTHORIZED
|
|
37
|
-
|
|
32
|
+
function renderSideNavigation(
|
|
33
|
+
args: renderSideNavigationArgs = {},
|
|
34
|
+
): RenderReturnType {
|
|
35
|
+
const { hasChanges = false, authStatus = AuthStatus.AUTHORIZED } = args;
|
|
36
|
+
|
|
38
37
|
return render(<SideNavigation />, {
|
|
39
38
|
preloadedState: {
|
|
40
39
|
availableCustomTypes: {},
|
|
@@ -80,19 +79,6 @@ function renderSideNavigation({
|
|
|
80
79
|
manifest: {
|
|
81
80
|
apiEndpoint: "https://foo.cdn.prismic.io/api/v2",
|
|
82
81
|
},
|
|
83
|
-
changelog: {
|
|
84
|
-
sliceMachine: {
|
|
85
|
-
currentVersion: "",
|
|
86
|
-
updateAvailable: canUpdate,
|
|
87
|
-
latestNonBreakingVersion: null,
|
|
88
|
-
versions: [],
|
|
89
|
-
},
|
|
90
|
-
adapter: {
|
|
91
|
-
name: "",
|
|
92
|
-
updateAvailable: canUpdate,
|
|
93
|
-
versions: [],
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
82
|
} as unknown as FrontEndEnvironment,
|
|
97
83
|
userContext: {
|
|
98
84
|
hasSeenTutorialsToolTip: false,
|
|
@@ -109,7 +95,7 @@ describe("Side Navigation", () => {
|
|
|
109
95
|
});
|
|
110
96
|
|
|
111
97
|
test("Logo and repo area", async () => {
|
|
112
|
-
renderSideNavigation(
|
|
98
|
+
renderSideNavigation();
|
|
113
99
|
expect(await screen.findByText("foo")).toBeVisible();
|
|
114
100
|
expect(await screen.findByText("foo.prismic.io")).toBeVisible();
|
|
115
101
|
const link = await screen.findByTitle("Open prismic repository");
|
|
@@ -117,17 +103,6 @@ describe("Side Navigation", () => {
|
|
|
117
103
|
expect(link).toHaveAttribute("target", "_blank");
|
|
118
104
|
});
|
|
119
105
|
|
|
120
|
-
test("Update box when update is available", async () => {
|
|
121
|
-
renderSideNavigation({ canUpdate: true });
|
|
122
|
-
expect(await screen.findByText("Updates Available")).toBeVisible();
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
test("Update box when there are no updates", async () => {
|
|
126
|
-
renderSideNavigation({ canUpdate: false });
|
|
127
|
-
const element = await act(() => screen.queryByText("Updates Available"));
|
|
128
|
-
expect(element).toBeNull();
|
|
129
|
-
});
|
|
130
|
-
|
|
131
106
|
test.skip.each([
|
|
132
107
|
["Page types", "/"],
|
|
133
108
|
["Custom types", "/custom-types"],
|
|
@@ -139,7 +114,7 @@ describe("Side Navigation", () => {
|
|
|
139
114
|
])(
|
|
140
115
|
"internal navigation links: when clicking title %s it should navigate to %s",
|
|
141
116
|
async (title, path) => {
|
|
142
|
-
const { user } = renderSideNavigation(
|
|
117
|
+
const { user } = renderSideNavigation();
|
|
143
118
|
|
|
144
119
|
await act(() => mockRouter.push("/"));
|
|
145
120
|
|
|
@@ -155,7 +130,7 @@ describe("Side Navigation", () => {
|
|
|
155
130
|
);
|
|
156
131
|
|
|
157
132
|
test("should display the number of changes on the 'Review changes' item", async () => {
|
|
158
|
-
renderSideNavigation({
|
|
133
|
+
renderSideNavigation({ hasChanges: true });
|
|
159
134
|
|
|
160
135
|
expect(await screen.findByText("Review changes")).toBeVisible();
|
|
161
136
|
const changesItem = screen
|
|
@@ -188,7 +163,7 @@ describe("Side Navigation", () => {
|
|
|
188
163
|
}),
|
|
189
164
|
);
|
|
190
165
|
|
|
191
|
-
renderSideNavigation(
|
|
166
|
+
renderSideNavigation();
|
|
192
167
|
|
|
193
168
|
const link = (await screen.findByText("Academy")).parentElement
|
|
194
169
|
?.parentElement as HTMLElement;
|
|
@@ -204,7 +179,7 @@ describe("Side Navigation", () => {
|
|
|
204
179
|
});
|
|
205
180
|
|
|
206
181
|
test("Video Item not next", async () => {
|
|
207
|
-
renderSideNavigation(
|
|
182
|
+
renderSideNavigation();
|
|
208
183
|
|
|
209
184
|
const link = (await screen.findByText("Tutorial")).parentElement
|
|
210
185
|
?.parentElement as HTMLElement;
|
|
@@ -13,8 +13,6 @@ import {
|
|
|
13
13
|
SideNavLink,
|
|
14
14
|
SideNavListItem,
|
|
15
15
|
SideNavList,
|
|
16
|
-
UpdateInfo,
|
|
17
|
-
RightElement,
|
|
18
16
|
SideNav,
|
|
19
17
|
SideNavRepository,
|
|
20
18
|
} from "@src/components/SideNav/SideNav";
|
|
@@ -23,7 +21,6 @@ import { FolderIcon } from "@src/icons/FolderIcon";
|
|
|
23
21
|
import { userHasSeenTutorialsToolTip } from "@src/modules/userContext";
|
|
24
22
|
import { SliceMachineStoreType } from "@src/redux/type";
|
|
25
23
|
import useSliceMachineActions from "@src/modules/useSliceMachineActions";
|
|
26
|
-
import { getChangelog } from "@src/modules/environment";
|
|
27
24
|
import { CUSTOM_TYPES_MESSAGES } from "@src/features/customTypes/customTypesMessages";
|
|
28
25
|
import { useGitIntegrationExperiment } from "@src/features/settings/git/useGitIntegrationExperiment";
|
|
29
26
|
import { useRepositoryInformation } from "@src/hooks/useRepositoryInformation";
|
|
@@ -31,19 +28,19 @@ import { ErrorBoundary } from "@src/ErrorBoundary";
|
|
|
31
28
|
|
|
32
29
|
import { ChangesItem } from "./ChangesItem";
|
|
33
30
|
import { Environment } from "./Environment";
|
|
31
|
+
import { RunningVersion } from "./RunningVersion";
|
|
32
|
+
import { UpdateBox } from "./UpdateBox";
|
|
34
33
|
|
|
35
34
|
import * as styles from "./index.css";
|
|
36
35
|
|
|
37
36
|
const Navigation: FC = () => {
|
|
38
|
-
const {
|
|
37
|
+
const { hasSeenTutorialsToolTip } = useSelector(
|
|
39
38
|
(store: SliceMachineStoreType) => ({
|
|
40
|
-
changelog: getChangelog(store),
|
|
41
39
|
hasSeenTutorialsToolTip: userHasSeenTutorialsToolTip(store),
|
|
42
40
|
}),
|
|
43
41
|
);
|
|
44
42
|
const router = useRouter();
|
|
45
|
-
const {
|
|
46
|
-
useSliceMachineActions();
|
|
43
|
+
const { setSeenTutorialsToolTip } = useSliceMachineActions();
|
|
47
44
|
const { repositoryName, repositoryDomain, repositoryUrl } =
|
|
48
45
|
useRepositoryInformation();
|
|
49
46
|
const gitIntegrationExperiment = useGitIntegrationExperiment();
|
|
@@ -112,24 +109,11 @@ const Navigation: FC = () => {
|
|
|
112
109
|
</SideNavListItem>
|
|
113
110
|
</SideNavList>
|
|
114
111
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
const latestVersion =
|
|
121
|
-
changelog.sliceMachine.versions.length > 0
|
|
122
|
-
? changelog.sliceMachine.versions?.[0]
|
|
123
|
-
: null;
|
|
124
|
-
setUpdatesViewed({
|
|
125
|
-
latest: latestVersion && latestVersion.versionNumber,
|
|
126
|
-
latestNonBreaking:
|
|
127
|
-
changelog.sliceMachine.latestNonBreakingVersion,
|
|
128
|
-
});
|
|
129
|
-
}}
|
|
130
|
-
component={Link}
|
|
131
|
-
/>
|
|
132
|
-
)}
|
|
112
|
+
<ErrorBoundary>
|
|
113
|
+
<Suspense>
|
|
114
|
+
<UpdateBox />
|
|
115
|
+
</Suspense>
|
|
116
|
+
</ErrorBoundary>
|
|
133
117
|
|
|
134
118
|
<SideNavList position="bottom">
|
|
135
119
|
<SideNavListItem>
|
|
@@ -175,10 +159,11 @@ const Navigation: FC = () => {
|
|
|
175
159
|
active={router.asPath.startsWith("/changelog")}
|
|
176
160
|
component={Link}
|
|
177
161
|
RightElement={
|
|
178
|
-
<
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
162
|
+
<ErrorBoundary>
|
|
163
|
+
<Suspense>
|
|
164
|
+
<RunningVersion />
|
|
165
|
+
</Suspense>
|
|
166
|
+
</ErrorBoundary>
|
|
182
167
|
}
|
|
183
168
|
/>
|
|
184
169
|
</SideNavListItem>
|