slice-machine-ui 2.17.3-beta.7 → 2.17.3-beta.9
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/out/404.html +1 -1
- package/out/_next/static/UBLEqMkM94kXQpW0VSAQo/_buildManifest.js +1 -0
- package/out/_next/static/chunks/248-6f20227ad4764216.js +1 -0
- package/out/_next/static/chunks/489-a42bd4eeb1350d97.js +1 -0
- package/out/_next/static/chunks/{630-29c729ad2a291ef6.js → 630-799c128fd87fa645.js} +1 -1
- package/out/_next/static/chunks/907-a42dc5698d5dc000.js +1 -0
- package/out/_next/static/chunks/pages/{_app-df4a4d1aaa9d7216.js → _app-13d39ac1e1c9aa27.js} +1 -1
- package/out/_next/static/chunks/pages/changelog-98836c22c6a40c5d.js +1 -0
- package/out/_next/static/chunks/pages/changes-2bd69f3877d60b26.js +1 -0
- package/out/_next/static/chunks/pages/labs-ad7f36c6f544c1a8.js +1 -0
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/simulator-0ecd552897e61e29.js +1 -0
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-8b6e7854cb3466d4.js +1 -0
- package/out/_next/static/chunks/pages/slices-fe1bb16ff3020762.js +1 -0
- package/out/changelog.html +1 -1
- package/out/changes.html +1 -1
- package/out/custom-types/[customTypeId].html +1 -1
- package/out/custom-types.html +1 -1
- package/out/index.html +1 -1
- package/out/labs.html +1 -1
- package/out/page-types/[pageTypeId].html +1 -1
- package/out/slices/[lib]/[sliceName]/[variation]/simulator.html +1 -1
- package/out/slices/[lib]/[sliceName]/[variation].html +1 -1
- package/out/slices.html +1 -1
- package/package.json +3 -3
- package/src/features/changes/PushChangesButton.tsx +4 -67
- package/src/features/customTypes/customTypesBuilder/CreateSliceFromImageModal/CreateSliceFromImageModal.tsx +8 -21
- package/src/features/customTypes/customTypesBuilder/SliceZoneBlankSlate.tsx +4 -12
- package/src/features/customTypes/customTypesBuilder/sliceCreationOptions.tsx +5 -11
- package/src/features/navigation/Navigation.tsx +1 -19
- package/src/legacy/components/ChangesItems/ChangesItems.tsx +1 -8
- package/src/legacy/components/Forms/CreateSliceModal/CreateSliceModal.tsx +3 -8
- package/src/legacy/components/Simulator/components/FailedConnect/index.tsx +51 -56
- package/src/legacy/components/ToasterContainer/index.tsx +3 -14
- package/src/legacy/lib/builders/CustomTypeBuilder/SliceZone/SlicesTemplatesModal.tsx +1 -4
- package/src/legacy/lib/builders/CustomTypeBuilder/SliceZone/UpdateSliceZoneModal.tsx +1 -5
- package/src/legacy/lib/builders/CustomTypeBuilder/SliceZone/index.tsx +4 -16
- package/src/legacy/lib/builders/SliceBuilder/index.tsx +1 -6
- package/src/legacy/lib/builders/common/Zone/components/ZoneEmptyState/ZoneEmptyState.tsx +5 -10
- package/src/pages/slices.tsx +10 -38
- package/out/_next/static/chunks/248-03446cd9e9f13730.js +0 -1
- package/out/_next/static/chunks/489-f1d584386a1ead7e.js +0 -1
- package/out/_next/static/chunks/907-590c914f55547b96.js +0 -1
- package/out/_next/static/chunks/pages/changelog-063c5e11dfc8fd55.js +0 -1
- package/out/_next/static/chunks/pages/changes-564336edb0ed18b0.js +0 -1
- package/out/_next/static/chunks/pages/labs-9630bfb1005be02b.js +0 -1
- package/out/_next/static/chunks/pages/settings-01f4aeb9112a1f87.js +0 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/simulator-5008e29008aa04f4.js +0 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-bd5e45632c419567.js +0 -1
- package/out/_next/static/chunks/pages/slices-a0aa3bbe2cf1689c.js +0 -1
- package/out/_next/static/css/e5f781f20e24a5ea.css +0 -1
- package/out/_next/static/i3RCInXoJzCEi4NnU8YGb/_buildManifest.js +0 -1
- package/out/settings.html +0 -1
- package/src/components/FieldSet/FieldSet.module.css +0 -84
- package/src/components/FieldSet/FieldSet.module.css.d.ts +0 -16
- package/src/components/FieldSet/FieldSet.stories.tsx +0 -244
- package/src/components/FieldSet/FieldSet.tsx +0 -67
- package/src/components/FieldSet/index.ts +0 -9
- package/src/features/builder/useSectionsNamingExperiment.ts +0 -15
- package/src/features/settings/SettingsPage.tsx +0 -50
- package/src/features/settings/git/ConnectGitRepository.tsx +0 -112
- package/src/features/settings/git/ConnectGitRepositoryBlankSlate.tsx +0 -33
- package/src/features/settings/git/GitOwnerSelect.tsx +0 -71
- package/src/features/settings/git/GitProvider.ts +0 -40
- package/src/features/settings/git/GitProviderConnectButtons.tsx +0 -63
- package/src/features/settings/git/GitRepositoriesList.tsx +0 -76
- package/src/features/settings/git/GitRepositoriesSearch.tsx +0 -69
- package/src/features/settings/git/GitRepositoryConnectDialog.tsx +0 -97
- package/src/features/settings/git/GitRepositoryDisconnectDialog.tsx +0 -62
- package/src/features/settings/git/useGitIntegrationExperiment.ts +0 -8
- package/src/features/settings/git/useGitOwners.ts +0 -12
- package/src/features/settings/git/useGitRepos.ts +0 -24
- package/src/features/settings/git/useLinkedGitRepos.ts +0 -41
- package/src/features/settings/git/useWriteAPIToken.ts +0 -23
- package/src/icons/BitbucketIcon.tsx +0 -19
- package/src/icons/GitHubIcon.tsx +0 -17
- package/src/icons/GitLabIcon.tsx +0 -19
- package/src/icons/SettingsIcon.tsx +0 -19
- package/src/pages/settings.tsx +0 -1
- package/src/utils/textConversion.ts +0 -11
- /package/out/_next/static/{i3RCInXoJzCEi4NnU8YGb → UBLEqMkM94kXQpW0VSAQo}/_ssgManifest.js +0 -0
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { Button, IconButton, Tooltip } from "@prismicio/editor-ui";
|
|
2
|
-
import {
|
|
3
|
-
isUnauthenticatedError,
|
|
4
|
-
isUnauthorizedError,
|
|
5
|
-
} from "@slicemachine/manager/client";
|
|
6
|
-
import { type FC, type ReactNode, Suspense } from "react";
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
FieldSet,
|
|
10
|
-
FieldSetContent,
|
|
11
|
-
FieldSetFooter,
|
|
12
|
-
FieldSetLegend,
|
|
13
|
-
} from "@/components/FieldSet";
|
|
14
|
-
import { ErrorBoundary } from "@/ErrorBoundary";
|
|
15
|
-
import { ConnectGitRepositoryBlankSlate } from "@/features/settings/git/ConnectGitRepositoryBlankSlate";
|
|
16
|
-
import { GitProviderConnectButtons } from "@/features/settings/git/GitProviderConnectButtons";
|
|
17
|
-
import { GitRepositoriesList } from "@/features/settings/git/GitRepositoriesList";
|
|
18
|
-
import {
|
|
19
|
-
GitRepositoriesSearch,
|
|
20
|
-
GitRepositoriesSearchSkeleton,
|
|
21
|
-
} from "@/features/settings/git/GitRepositoriesSearch";
|
|
22
|
-
import { useGitOwners } from "@/features/settings/git/useGitOwners";
|
|
23
|
-
import { useLinkedGitRepos } from "@/features/settings/git/useLinkedGitRepos";
|
|
24
|
-
import useSliceMachineActions from "@/modules/useSliceMachineActions";
|
|
25
|
-
|
|
26
|
-
export const ConnectGitRepository: FC = () => (
|
|
27
|
-
<FieldSet>
|
|
28
|
-
<FieldSetLegend>Connected Git Repository</FieldSetLegend>
|
|
29
|
-
<ErrorBoundary renderError={renderError}>
|
|
30
|
-
<Suspense fallback={<GitRepositoriesSearchSkeleton gitOwnerSelect />}>
|
|
31
|
-
<Content />
|
|
32
|
-
</Suspense>
|
|
33
|
-
</ErrorBoundary>
|
|
34
|
-
<FieldSetFooter
|
|
35
|
-
action={
|
|
36
|
-
<Tooltip content="Documentation is coming soon." side="bottom">
|
|
37
|
-
<IconButton disabled icon="openInNew" />
|
|
38
|
-
</Tooltip>
|
|
39
|
-
}
|
|
40
|
-
>
|
|
41
|
-
Learn more about Prismic for Git
|
|
42
|
-
</FieldSetFooter>
|
|
43
|
-
</FieldSet>
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
const Content: FC = () => {
|
|
47
|
-
const { linkedGitRepos } = useLinkedGitRepos();
|
|
48
|
-
return linkedGitRepos.length > 0 ? (
|
|
49
|
-
<GitRepositoriesList mode="unlink" repos={linkedGitRepos} />
|
|
50
|
-
) : (
|
|
51
|
-
<UnlinkedRepositoryContent />
|
|
52
|
-
);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const UnlinkedRepositoryContent: FC = () => {
|
|
56
|
-
const owners = useGitOwners();
|
|
57
|
-
return owners.length > 0 ? (
|
|
58
|
-
<GitRepositoriesSearch owners={owners} />
|
|
59
|
-
) : (
|
|
60
|
-
<FieldSetContent>
|
|
61
|
-
<GitProviderConnectButtons />
|
|
62
|
-
</FieldSetContent>
|
|
63
|
-
);
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
function renderError(error: unknown, reset: () => void): ReactNode {
|
|
67
|
-
if (isUnauthenticatedError(error)) {
|
|
68
|
-
return <UnauthenticatedErrorContent />;
|
|
69
|
-
} else if (isUnauthorizedError(error)) {
|
|
70
|
-
return <UnauthorizedErrorContent />;
|
|
71
|
-
} else {
|
|
72
|
-
return <UnknownErrorContent reset={reset} />;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const UnauthenticatedErrorContent: FC = () => {
|
|
77
|
-
const { openLoginModal } = useSliceMachineActions();
|
|
78
|
-
return (
|
|
79
|
-
<FieldSetContent>
|
|
80
|
-
<ConnectGitRepositoryBlankSlate
|
|
81
|
-
title="It seems like you are logged out"
|
|
82
|
-
description="Log in to connect a Git repository."
|
|
83
|
-
action={<Button onClick={openLoginModal}>Log in to Prismic</Button>}
|
|
84
|
-
/>
|
|
85
|
-
</FieldSetContent>
|
|
86
|
-
);
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
const UnauthorizedErrorContent: FC = () => (
|
|
90
|
-
<FieldSetContent>
|
|
91
|
-
<ConnectGitRepositoryBlankSlate
|
|
92
|
-
title="It seems like you do not have permission"
|
|
93
|
-
description="An owner or admin is required to connect a Git repository."
|
|
94
|
-
/>
|
|
95
|
-
</FieldSetContent>
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
type UnknownErrorContentProps = { reset: () => void };
|
|
99
|
-
|
|
100
|
-
const UnknownErrorContent: FC<UnknownErrorContentProps> = ({ reset }) => (
|
|
101
|
-
<FieldSetContent>
|
|
102
|
-
<ConnectGitRepositoryBlankSlate
|
|
103
|
-
title="Unable to fetch data"
|
|
104
|
-
description="An error occurred while fetching the list of connected Git repositories."
|
|
105
|
-
action={
|
|
106
|
-
<Button color="grey" onClick={reset}>
|
|
107
|
-
Retry
|
|
108
|
-
</Button>
|
|
109
|
-
}
|
|
110
|
-
/>
|
|
111
|
-
</FieldSetContent>
|
|
112
|
-
);
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { Box, ButtonGroup, Text } from "@prismicio/editor-ui";
|
|
2
|
-
import type { FC, ReactNode } from "react";
|
|
3
|
-
|
|
4
|
-
type ConnectGitRepositoryBlankSlateProps = {
|
|
5
|
-
title: string;
|
|
6
|
-
description: string;
|
|
7
|
-
action?: ReactNode;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export const ConnectGitRepositoryBlankSlate: FC<
|
|
11
|
-
ConnectGitRepositoryBlankSlateProps
|
|
12
|
-
> = ({ title, description, action }) => (
|
|
13
|
-
<Box
|
|
14
|
-
flexDirection="column"
|
|
15
|
-
/*
|
|
16
|
-
* TODO: these `padding` values actually don't match Figma, but they are the
|
|
17
|
-
* closest allowed by the `Box` component.
|
|
18
|
-
*/
|
|
19
|
-
padding={{ block: 72, inline: 100 }}
|
|
20
|
-
>
|
|
21
|
-
<Text align="center" variant="emphasized">
|
|
22
|
-
{title}
|
|
23
|
-
</Text>
|
|
24
|
-
<Text align="center" color="grey11">
|
|
25
|
-
{description}
|
|
26
|
-
</Text>
|
|
27
|
-
{Boolean(action) ? (
|
|
28
|
-
<ButtonGroup sx={{ alignSelf: "center", marginTop: 8 }}>
|
|
29
|
-
{action}
|
|
30
|
-
</ButtonGroup>
|
|
31
|
-
) : undefined}
|
|
32
|
-
</Box>
|
|
33
|
-
);
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { Select, SelectItem, theme } from "@prismicio/editor-ui";
|
|
2
|
-
import type { GitOwner } from "@slicemachine/manager";
|
|
3
|
-
import type { ComponentPropsWithoutRef, FC } from "react";
|
|
4
|
-
|
|
5
|
-
import { gitProviderToConfig } from "@/features/settings/git/GitProvider";
|
|
6
|
-
|
|
7
|
-
type GitOwnerSelectProps = {
|
|
8
|
-
disabled?: boolean;
|
|
9
|
-
owners?: GitOwner[];
|
|
10
|
-
selectedOwner?: GitOwner;
|
|
11
|
-
onSelectedOwnerChange?: (selectedOwner: GitOwner) => void;
|
|
12
|
-
sx?: SX;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const GitOwnerSelect: FC<GitOwnerSelectProps> = ({
|
|
16
|
-
disabled,
|
|
17
|
-
owners = [],
|
|
18
|
-
selectedOwner,
|
|
19
|
-
onSelectedOwnerChange,
|
|
20
|
-
sx,
|
|
21
|
-
}) => (
|
|
22
|
-
<Select
|
|
23
|
-
color="grey"
|
|
24
|
-
constrainContentWidth
|
|
25
|
-
disabled={disabled}
|
|
26
|
-
flexContent
|
|
27
|
-
onValueChange={(value) => {
|
|
28
|
-
const [provider, id] = parseGitOwnerKey(value);
|
|
29
|
-
const selectedOwner = owners.find(
|
|
30
|
-
(owner) => owner.provider === provider && owner.id === id,
|
|
31
|
-
);
|
|
32
|
-
if (selectedOwner) {
|
|
33
|
-
onSelectedOwnerChange?.(selectedOwner);
|
|
34
|
-
}
|
|
35
|
-
}}
|
|
36
|
-
placeholder="Owner"
|
|
37
|
-
renderStartIcon={() => <GitOwnerIcon owner={selectedOwner} />}
|
|
38
|
-
size="large"
|
|
39
|
-
sx={sx}
|
|
40
|
-
value={selectedOwner ? formatGitOwnerKey(selectedOwner) : undefined}
|
|
41
|
-
>
|
|
42
|
-
{owners.map((owner) => (
|
|
43
|
-
<SelectItem
|
|
44
|
-
key={formatGitOwnerKey(owner)}
|
|
45
|
-
renderStartIcon={() => <GitOwnerIcon owner={owner} />}
|
|
46
|
-
size="large"
|
|
47
|
-
value={formatGitOwnerKey(owner)}
|
|
48
|
-
>
|
|
49
|
-
{owner.name}
|
|
50
|
-
</SelectItem>
|
|
51
|
-
))}
|
|
52
|
-
</Select>
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
type GitOwnerIconProps = { owner: GitOwner | undefined };
|
|
56
|
-
|
|
57
|
-
const GitOwnerIcon: FC<GitOwnerIconProps> = ({ owner }) => {
|
|
58
|
-
const { Icon } = gitProviderToConfig[owner?.provider ?? "gitHub"];
|
|
59
|
-
return <Icon color={theme.color.grey11} />;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
function formatGitOwnerKey(owner: GitOwner): string {
|
|
63
|
-
return `${owner.provider}@${owner.id}`;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function parseGitOwnerKey(key: string): string[] {
|
|
67
|
-
return key.split("@");
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// TODO(DT-1928): export the `SX` type from `@prismicio/editor-ui`.
|
|
71
|
-
type SX = ComponentPropsWithoutRef<typeof Select>["sx"];
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { GIT_PROVIDER, GitProvider } from "@slicemachine/manager/client";
|
|
2
|
-
|
|
3
|
-
import { BitbucketIcon } from "@/icons/BitbucketIcon";
|
|
4
|
-
import { GitHubIcon } from "@/icons/GitHubIcon";
|
|
5
|
-
import { GitLabIcon } from "@/icons/GitLabIcon";
|
|
6
|
-
import { managerClient } from "@/managerClient";
|
|
7
|
-
|
|
8
|
-
export const gitProviderToConfig = {
|
|
9
|
-
gitHub: {
|
|
10
|
-
connect: async () => await openInstallationWindow("gitHub"),
|
|
11
|
-
Icon: GitHubIcon,
|
|
12
|
-
name: "GitHub",
|
|
13
|
-
supported: isSupported("gitHub"),
|
|
14
|
-
},
|
|
15
|
-
bitbucket: {
|
|
16
|
-
connect: async () => await openInstallationWindow("bitbucket"),
|
|
17
|
-
Icon: BitbucketIcon,
|
|
18
|
-
name: "Bitbucket",
|
|
19
|
-
supported: isSupported("bitbucket"),
|
|
20
|
-
},
|
|
21
|
-
gitLab: {
|
|
22
|
-
connect: async () => await openInstallationWindow("gitLab"),
|
|
23
|
-
Icon: GitLabIcon,
|
|
24
|
-
name: "GitLab",
|
|
25
|
-
supported: isSupported("gitLab"),
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
async function openInstallationWindow(provider: string) {
|
|
30
|
-
if (!isSupported(provider)) {
|
|
31
|
-
throw new Error("Not implemented.");
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const url = await managerClient.git.getProviderAppInstallURL({ provider });
|
|
35
|
-
window.open(url, "git-provider-app-installation");
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function isSupported(provider: string): provider is GitProvider {
|
|
39
|
-
return Boolean(Object.values<string>(GIT_PROVIDER).includes(provider));
|
|
40
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { keys } from "@prismicio/editor-support/Object";
|
|
2
|
-
import { Button, ButtonGroup, Text, theme } from "@prismicio/editor-ui";
|
|
3
|
-
import { type ComponentPropsWithoutRef, type FC, useState } from "react";
|
|
4
|
-
import { toast } from "react-toastify";
|
|
5
|
-
|
|
6
|
-
import { gitProviderToConfig } from "@/features/settings/git/GitProvider";
|
|
7
|
-
|
|
8
|
-
export const GitProviderConnectButtons: FC = () => (
|
|
9
|
-
<ButtonGroup>
|
|
10
|
-
{keys(gitProviderToConfig).map((provider) => (
|
|
11
|
-
<GitProviderConnectButton
|
|
12
|
-
key={provider}
|
|
13
|
-
provider={provider}
|
|
14
|
-
sx={{ flexBasis: 0, flexGrow: 1 }}
|
|
15
|
-
/>
|
|
16
|
-
))}
|
|
17
|
-
</ButtonGroup>
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
type GitProviderConnectButtonProps = {
|
|
21
|
-
provider: keyof typeof gitProviderToConfig;
|
|
22
|
-
sx?: SX;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const GitProviderConnectButton: FC<GitProviderConnectButtonProps> = ({
|
|
26
|
-
provider,
|
|
27
|
-
sx,
|
|
28
|
-
}) => {
|
|
29
|
-
const { connect, Icon, name, supported } = gitProviderToConfig[provider];
|
|
30
|
-
const [loading, setLoading] = useState(false);
|
|
31
|
-
return (
|
|
32
|
-
<Button
|
|
33
|
-
color="grey"
|
|
34
|
-
disabled={!supported}
|
|
35
|
-
loading={loading}
|
|
36
|
-
onClick={() => {
|
|
37
|
-
void (async () => {
|
|
38
|
-
setLoading(true);
|
|
39
|
-
try {
|
|
40
|
-
await connect();
|
|
41
|
-
} catch (error) {
|
|
42
|
-
const message = `Could not connect to ${name}`;
|
|
43
|
-
console.error(message, error);
|
|
44
|
-
toast.error(message);
|
|
45
|
-
setLoading(false);
|
|
46
|
-
}
|
|
47
|
-
})();
|
|
48
|
-
}}
|
|
49
|
-
renderStartIcon={() => <Icon color={theme.color.grey11} />}
|
|
50
|
-
sx={sx}
|
|
51
|
-
>
|
|
52
|
-
{name}
|
|
53
|
-
{supported ? undefined : (
|
|
54
|
-
<Text color="inherit" variant="small">
|
|
55
|
-
{" (soon)"}
|
|
56
|
-
</Text>
|
|
57
|
-
)}
|
|
58
|
-
</Button>
|
|
59
|
-
);
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
// TODO(DT-1928): export the `SX` type from `@prismicio/editor-ui`.
|
|
63
|
-
type SX = ComponentPropsWithoutRef<typeof Button>["sx"];
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { Button, Skeleton, Text } from "@prismicio/editor-ui";
|
|
2
|
-
import type { GitRepo, GitRepoSpecifier } from "@slicemachine/manager";
|
|
3
|
-
import type { FC } from "react";
|
|
4
|
-
|
|
5
|
-
import { FieldSetList, FieldSetListItem } from "@/components/FieldSet";
|
|
6
|
-
import { RelativeTime } from "@/components/RelativeTime";
|
|
7
|
-
import { GitRepositoryConnectDialog } from "@/features/settings/git/GitRepositoryConnectDialog";
|
|
8
|
-
import { GitRepositoryDisconnectDialog } from "@/features/settings/git/GitRepositoryDisconnectDialog";
|
|
9
|
-
import { useLinkedGitRepos } from "@/features/settings/git/useLinkedGitRepos";
|
|
10
|
-
|
|
11
|
-
type GitRepositoriesListProps =
|
|
12
|
-
| { mode: "link"; repos: GitRepo[] }
|
|
13
|
-
| { mode: "unlink"; repos: GitRepoSpecifier[] };
|
|
14
|
-
|
|
15
|
-
export const GitRepositoriesList: FC<GitRepositoriesListProps> = ({
|
|
16
|
-
mode,
|
|
17
|
-
repos,
|
|
18
|
-
}) => {
|
|
19
|
-
const { linkRepo, unlinkRepo } = useLinkedGitRepos();
|
|
20
|
-
return (
|
|
21
|
-
<FieldSetList>
|
|
22
|
-
{mode === "link"
|
|
23
|
-
? repos.map((repo) => (
|
|
24
|
-
<FieldSetListItem
|
|
25
|
-
action={
|
|
26
|
-
<GitRepositoryConnectDialog
|
|
27
|
-
linkRepo={linkRepo}
|
|
28
|
-
repo={repo}
|
|
29
|
-
trigger={<Button color="grey">Connect</Button>}
|
|
30
|
-
/>
|
|
31
|
-
}
|
|
32
|
-
key={`${repo.provider}@${repo.id}`}
|
|
33
|
-
>
|
|
34
|
-
{repo.name}
|
|
35
|
-
<Text color="grey11">
|
|
36
|
-
{" • "}
|
|
37
|
-
<RelativeTime date={repo.pushedAt} />
|
|
38
|
-
</Text>
|
|
39
|
-
</FieldSetListItem>
|
|
40
|
-
))
|
|
41
|
-
: repos.map((repo) => (
|
|
42
|
-
<FieldSetListItem
|
|
43
|
-
action={
|
|
44
|
-
<GitRepositoryDisconnectDialog
|
|
45
|
-
repo={repo}
|
|
46
|
-
trigger={<Button color="grey">Disconnect</Button>}
|
|
47
|
-
unlinkRepo={unlinkRepo}
|
|
48
|
-
/>
|
|
49
|
-
}
|
|
50
|
-
key={`${repo.provider}@${repo.owner}/${repo.name}`}
|
|
51
|
-
>
|
|
52
|
-
{repo.name}
|
|
53
|
-
</FieldSetListItem>
|
|
54
|
-
))}
|
|
55
|
-
</FieldSetList>
|
|
56
|
-
);
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export const GitRepositoriesListSkeleton: FC = () => (
|
|
60
|
-
<FieldSetList>
|
|
61
|
-
{[...Array(4).keys()].map((index) => (
|
|
62
|
-
<FieldSetListItem
|
|
63
|
-
action={<Skeleton height={32} width={67.59} />}
|
|
64
|
-
key={index}
|
|
65
|
-
>
|
|
66
|
-
<Skeleton
|
|
67
|
-
height={24}
|
|
68
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
69
|
-
// @ts-ignore TODO(DT-1918): add `verticalAlign: "middle"` to the `sx` prop.
|
|
70
|
-
sx={{ verticalAlign: "middle" }}
|
|
71
|
-
width={129.92}
|
|
72
|
-
/>
|
|
73
|
-
</FieldSetListItem>
|
|
74
|
-
))}
|
|
75
|
-
</FieldSetList>
|
|
76
|
-
);
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import type { GitOwner } from "@slicemachine/manager";
|
|
2
|
-
import { type FC, Suspense, useState } from "react";
|
|
3
|
-
|
|
4
|
-
import { FieldSetContent, FieldSetHeader } from "@/components/FieldSet";
|
|
5
|
-
import { ConnectGitRepositoryBlankSlate } from "@/features/settings/git/ConnectGitRepositoryBlankSlate";
|
|
6
|
-
import { GitOwnerSelect } from "@/features/settings/git/GitOwnerSelect";
|
|
7
|
-
import {
|
|
8
|
-
GitRepositoriesList,
|
|
9
|
-
GitRepositoriesListSkeleton,
|
|
10
|
-
} from "@/features/settings/git/GitRepositoriesList";
|
|
11
|
-
import { useGitRepos } from "@/features/settings/git/useGitRepos";
|
|
12
|
-
|
|
13
|
-
type GitRepositoriesSearchProps = { owners: GitOwner[] };
|
|
14
|
-
|
|
15
|
-
export const GitRepositoriesSearch: FC<GitRepositoriesSearchProps> = ({
|
|
16
|
-
owners,
|
|
17
|
-
}) => {
|
|
18
|
-
const [selectedOwner, setSelectedOwner] = useState(owners[0]);
|
|
19
|
-
return (
|
|
20
|
-
<>
|
|
21
|
-
<FieldSetHeader>
|
|
22
|
-
<GitOwnerSelect
|
|
23
|
-
owners={owners}
|
|
24
|
-
selectedOwner={selectedOwner}
|
|
25
|
-
onSelectedOwnerChange={setSelectedOwner}
|
|
26
|
-
sx={{ width: "calc(50% - 8px)" }}
|
|
27
|
-
/>
|
|
28
|
-
</FieldSetHeader>
|
|
29
|
-
<Suspense
|
|
30
|
-
fallback={<GitRepositoriesSearchSkeleton gitOwnerSelect={false} />}
|
|
31
|
-
>
|
|
32
|
-
<GitRepositoriesSearchResults owner={selectedOwner} />
|
|
33
|
-
</Suspense>
|
|
34
|
-
</>
|
|
35
|
-
);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
type GitRepositoriesSearchResultsProps = { owner: GitOwner };
|
|
39
|
-
|
|
40
|
-
const GitRepositoriesSearchResults: FC<GitRepositoriesSearchResultsProps> = ({
|
|
41
|
-
owner,
|
|
42
|
-
}) => {
|
|
43
|
-
const repos = useGitRepos({ provider: owner.provider, owner: owner.name });
|
|
44
|
-
return repos.length > 0 ? (
|
|
45
|
-
<GitRepositoriesList mode="link" repos={repos} />
|
|
46
|
-
) : (
|
|
47
|
-
<FieldSetContent>
|
|
48
|
-
<ConnectGitRepositoryBlankSlate
|
|
49
|
-
title="No Results Found"
|
|
50
|
-
description="Try selecting a different Git account or organization on the top left."
|
|
51
|
-
/>
|
|
52
|
-
</FieldSetContent>
|
|
53
|
-
);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
type GitRepositoriesSearchSkeletonProps = { gitOwnerSelect: boolean };
|
|
57
|
-
|
|
58
|
-
export const GitRepositoriesSearchSkeleton: FC<
|
|
59
|
-
GitRepositoriesSearchSkeletonProps
|
|
60
|
-
> = ({ gitOwnerSelect }) => (
|
|
61
|
-
<>
|
|
62
|
-
{gitOwnerSelect ? (
|
|
63
|
-
<FieldSetHeader>
|
|
64
|
-
<GitOwnerSelect disabled sx={{ width: "calc(50% - 8px)" }} />
|
|
65
|
-
</FieldSetHeader>
|
|
66
|
-
) : undefined}
|
|
67
|
-
<GitRepositoriesListSkeleton />
|
|
68
|
-
</>
|
|
69
|
-
);
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Box,
|
|
3
|
-
Dialog,
|
|
4
|
-
DialogActionButton,
|
|
5
|
-
DialogActionLink,
|
|
6
|
-
DialogActions,
|
|
7
|
-
DialogCancelButton,
|
|
8
|
-
DialogContent,
|
|
9
|
-
DialogHeader,
|
|
10
|
-
FormInput,
|
|
11
|
-
Text,
|
|
12
|
-
} from "@prismicio/editor-ui";
|
|
13
|
-
import type { GitRepo, GitRepoSpecifier } from "@slicemachine/manager";
|
|
14
|
-
import { Formik } from "formik";
|
|
15
|
-
import type { FC, ReactNode } from "react";
|
|
16
|
-
import { toast } from "react-toastify";
|
|
17
|
-
|
|
18
|
-
import { gitProviderToConfig } from "@/features/settings/git/GitProvider";
|
|
19
|
-
import { useWriteAPIToken } from "@/features/settings/git/useWriteAPIToken";
|
|
20
|
-
import { useRepositoryInformation } from "@/hooks/useRepositoryInformation";
|
|
21
|
-
|
|
22
|
-
type GitRepositoryConnectDialogProps = {
|
|
23
|
-
linkRepo: (repo: GitRepoSpecifier) => Promise<void>;
|
|
24
|
-
repo: GitRepo;
|
|
25
|
-
trigger: ReactNode;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
// TODO: Update form to make it work with editor-ui Form component when
|
|
29
|
-
// we start to work again on Git integration
|
|
30
|
-
export const GitRepositoryConnectDialog: FC<
|
|
31
|
-
GitRepositoryConnectDialogProps
|
|
32
|
-
> = ({ linkRepo, repo, trigger }) => {
|
|
33
|
-
const providerConfig = gitProviderToConfig[repo.provider];
|
|
34
|
-
const { updateToken } = useWriteAPIToken({ git: repo });
|
|
35
|
-
const { repositoryUrl } = useRepositoryInformation();
|
|
36
|
-
return (
|
|
37
|
-
<Dialog size={{ width: 448, height: "auto" }} trigger={trigger}>
|
|
38
|
-
<DialogHeader title="Prismic Write API token required" />
|
|
39
|
-
<DialogContent>
|
|
40
|
-
<Formik
|
|
41
|
-
initialValues={{ writeAPIToken: "" }}
|
|
42
|
-
validate={(values) => {
|
|
43
|
-
if (values.writeAPIToken.length === 0) {
|
|
44
|
-
return { writeAPIToken: "Cannot be empty" };
|
|
45
|
-
}
|
|
46
|
-
}}
|
|
47
|
-
onSubmit={async (values) => {
|
|
48
|
-
try {
|
|
49
|
-
await linkRepo(repo);
|
|
50
|
-
await updateToken(values.writeAPIToken);
|
|
51
|
-
} catch (error) {
|
|
52
|
-
const message = `Could not connect to ${repo.name}`;
|
|
53
|
-
console.error(message, error);
|
|
54
|
-
toast.error(message);
|
|
55
|
-
}
|
|
56
|
-
}}
|
|
57
|
-
>
|
|
58
|
-
{(formikProps) => (
|
|
59
|
-
<form onSubmit={formikProps.handleSubmit}>
|
|
60
|
-
<Box flexDirection="column" gap={4} padding={16}>
|
|
61
|
-
<FormInput
|
|
62
|
-
disabled={formikProps.isSubmitting}
|
|
63
|
-
error={typeof formikProps.errors.writeAPIToken === "string"}
|
|
64
|
-
label="Paste your Write API token"
|
|
65
|
-
onValueChange={(value) => {
|
|
66
|
-
void formikProps.setFieldValue("writeAPIToken", value);
|
|
67
|
-
}}
|
|
68
|
-
placeholder="Write API token"
|
|
69
|
-
value={formikProps.values.writeAPIToken}
|
|
70
|
-
/>
|
|
71
|
-
<Text color="grey11">
|
|
72
|
-
Required to sync models from {providerConfig.name} to Prismic.
|
|
73
|
-
</Text>
|
|
74
|
-
</Box>
|
|
75
|
-
<DialogActions>
|
|
76
|
-
<DialogActionLink
|
|
77
|
-
href={new URL("/settings/apps", repositoryUrl).href}
|
|
78
|
-
>
|
|
79
|
-
Create a Prismic Write API token
|
|
80
|
-
</DialogActionLink>
|
|
81
|
-
<DialogCancelButton size="medium" />
|
|
82
|
-
<DialogActionButton
|
|
83
|
-
disabled={!formikProps.isValid}
|
|
84
|
-
loading={formikProps.isSubmitting}
|
|
85
|
-
onClick={() => void formikProps.submitForm()}
|
|
86
|
-
size="medium"
|
|
87
|
-
>
|
|
88
|
-
Save Token
|
|
89
|
-
</DialogActionButton>
|
|
90
|
-
</DialogActions>
|
|
91
|
-
</form>
|
|
92
|
-
)}
|
|
93
|
-
</Formik>
|
|
94
|
-
</DialogContent>
|
|
95
|
-
</Dialog>
|
|
96
|
-
);
|
|
97
|
-
};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Box,
|
|
3
|
-
Dialog,
|
|
4
|
-
DialogActionButton,
|
|
5
|
-
DialogActions,
|
|
6
|
-
DialogCancelButton,
|
|
7
|
-
DialogContent,
|
|
8
|
-
DialogHeader,
|
|
9
|
-
Text,
|
|
10
|
-
} from "@prismicio/editor-ui";
|
|
11
|
-
import type { GitRepoSpecifier } from "@slicemachine/manager";
|
|
12
|
-
import { type FC, type ReactNode, useState } from "react";
|
|
13
|
-
import { toast } from "react-toastify";
|
|
14
|
-
|
|
15
|
-
type GitRepositoryDisconnectDialogProps = {
|
|
16
|
-
repo: GitRepoSpecifier;
|
|
17
|
-
trigger: ReactNode;
|
|
18
|
-
unlinkRepo: (repo: GitRepoSpecifier) => Promise<void>;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const GitRepositoryDisconnectDialog: FC<
|
|
22
|
-
GitRepositoryDisconnectDialogProps
|
|
23
|
-
> = ({ repo, trigger, unlinkRepo }) => {
|
|
24
|
-
const [loading, setLoading] = useState(false);
|
|
25
|
-
return (
|
|
26
|
-
<Dialog size={{ width: 448, height: "auto" }} trigger={trigger}>
|
|
27
|
-
<DialogHeader title="Remove Git Connection" />
|
|
28
|
-
<DialogContent>
|
|
29
|
-
<Box flexDirection="column" padding={16}>
|
|
30
|
-
<Text>
|
|
31
|
-
You will not be able to push your code alongside your models
|
|
32
|
-
anymore. Note that you can reconnect your Git repository at any
|
|
33
|
-
time. Are you sure you want to continue?
|
|
34
|
-
</Text>
|
|
35
|
-
</Box>
|
|
36
|
-
</DialogContent>
|
|
37
|
-
<DialogActions>
|
|
38
|
-
<DialogCancelButton size="medium" />
|
|
39
|
-
<DialogActionButton
|
|
40
|
-
size="medium"
|
|
41
|
-
color="tomato"
|
|
42
|
-
loading={loading}
|
|
43
|
-
onClick={() => {
|
|
44
|
-
void (async () => {
|
|
45
|
-
setLoading(true);
|
|
46
|
-
try {
|
|
47
|
-
await unlinkRepo(repo);
|
|
48
|
-
} catch (error) {
|
|
49
|
-
const message = `Could not disconnect from ${repo.name}`;
|
|
50
|
-
console.error(message, error);
|
|
51
|
-
toast.error(message);
|
|
52
|
-
}
|
|
53
|
-
setLoading(false);
|
|
54
|
-
})();
|
|
55
|
-
}}
|
|
56
|
-
>
|
|
57
|
-
Disconnect
|
|
58
|
-
</DialogActionButton>
|
|
59
|
-
</DialogActions>
|
|
60
|
-
</Dialog>
|
|
61
|
-
);
|
|
62
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { useExperimentVariant } from "@/hooks/useExperimentVariant";
|
|
2
|
-
|
|
3
|
-
type UseGitIntegrationExperimentReturnType = { eligible: boolean };
|
|
4
|
-
|
|
5
|
-
export function useGitIntegrationExperiment(): UseGitIntegrationExperimentReturnType {
|
|
6
|
-
const variant = useExperimentVariant("slicemachine-git-integration");
|
|
7
|
-
return { eligible: variant?.value === "on" };
|
|
8
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { useRequest } from "@prismicio/editor-support/Suspense";
|
|
2
|
-
import type { GitOwner } from "@slicemachine/manager";
|
|
3
|
-
|
|
4
|
-
import { managerClient } from "@/managerClient";
|
|
5
|
-
|
|
6
|
-
export function useGitOwners(): GitOwner[] {
|
|
7
|
-
return useRequest(getGitOwners, []);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
async function getGitOwners(): Promise<GitOwner[]> {
|
|
11
|
-
return await managerClient.git.fetchOwners();
|
|
12
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { useRequest } from "@prismicio/editor-support/Suspense";
|
|
2
|
-
import type { GitRepo } from "@slicemachine/manager";
|
|
3
|
-
|
|
4
|
-
import { managerClient } from "@/managerClient";
|
|
5
|
-
|
|
6
|
-
type UseGitReposArgs = Parameters<typeof managerClient.git.fetchRepos>[0];
|
|
7
|
-
|
|
8
|
-
export function useGitRepos(args: UseGitReposArgs): GitRepo[] {
|
|
9
|
-
return useRequest(getGitRepos, [
|
|
10
|
-
args.provider,
|
|
11
|
-
args.owner,
|
|
12
|
-
args.query,
|
|
13
|
-
args.page,
|
|
14
|
-
]);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
async function getGitRepos(
|
|
18
|
-
provider: "gitHub",
|
|
19
|
-
owner: string,
|
|
20
|
-
query?: string,
|
|
21
|
-
page?: number,
|
|
22
|
-
): Promise<GitRepo[]> {
|
|
23
|
-
return await managerClient.git.fetchRepos({ provider, owner, query, page });
|
|
24
|
-
}
|