slice-machine-ui 1.23.2-alpha.bmo-add-github-settings-page.4 → 1.23.2-alpha.dev-env-default-active.2
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/.depcheckrc +0 -3
- package/components/DeleteVariationModal/index.tsx +0 -1
- package/components/Forms/RenameVariationModal/RenameVariationModal.tsx +1 -0
- package/components/ModalFormCard/index.tsx +1 -0
- package/components/Navigation/index.tsx +12 -25
- package/components/ReviewModal/ReviewForm.tsx +1 -0
- package/lib/builders/common/EditModal/Form.jsx +1 -0
- package/lib/builders/common/Zone/Card/components/NewField.tsx +1 -0
- package/out/404.html +1 -1
- package/out/_next/static/RPiYsHNCOerXD0jYQi5Za/_buildManifest.js +1 -0
- package/out/_next/static/chunks/18539003-5cc559566b738915.js +97 -0
- package/out/_next/static/chunks/318-ce7e74f18f2d5b22.js +1 -0
- package/out/_next/static/chunks/376-7e784d6069e01654.js +8 -0
- package/out/_next/static/chunks/{727-2235967a881f9035.js → 727-3a3bc32518778317.js} +1 -1
- package/out/_next/static/chunks/731-501990ebe6a71b32.js +1 -0
- package/out/_next/static/chunks/904-9a4c1264727ae89a.js +1 -0
- package/out/_next/static/chunks/pages/_app-6e77d1b7e4feb181.js +432 -0
- package/out/_next/static/chunks/pages/{changelog-02cd80dad6f40878.js → changelog-afd18276fe018b24.js} +1 -1
- package/out/_next/static/chunks/pages/{changes-8de69920dfb5a48f.js → changes-2a976f9efeb719aa.js} +1 -1
- package/out/_next/static/chunks/pages/{labs-39b50541a4c370bf.js → labs-ee206005948f8e87.js} +1 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/{simulator-b12346e58ac9abea.js → simulator-897ca93c114a1435.js} +1 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-b2a9d773ce5d7739.js +1 -0
- package/out/_next/static/chunks/pages/slices-e9c70c082ca3e3f9.js +1 -0
- package/out/_next/static/css/200244e3e0463c39.css +1 -0
- package/out/_next/static/css/{838fd8bb5a7c32b0.css → 37153180c3b0dd66.css} +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/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 +6 -9
- package/src/components/FieldSet/FieldSet.stories.tsx +11 -20
- package/src/features/environments/actions/setEnvironment.ts +2 -2
- package/src/features/slices/convertLegacySlice/ConvertLegacySliceAsNewSliceDialog.tsx +1 -0
- package/src/features/slices/convertLegacySlice/ConvertLegacySliceAsNewVariationDialog.tsx +1 -0
- package/src/features/slices/convertLegacySlice/ConvertLegacySliceMergeWithIdenticalDialog.tsx +1 -0
- package/test/src/modules/__fixtures__/serverState.ts +2 -1
- package/out/_next/static/chunks/18539003-5f78714a35fde4a1.js +0 -97
- package/out/_next/static/chunks/318-bd030cc1725e23b5.js +0 -1
- package/out/_next/static/chunks/731-a9b66ccdc3fae2c2.js +0 -1
- package/out/_next/static/chunks/777-8c5507e3b119b5dc.js +0 -8
- package/out/_next/static/chunks/904-6d6937d53ea2761e.js +0 -1
- package/out/_next/static/chunks/pages/_app-027b9e90438a0d83.js +0 -434
- package/out/_next/static/chunks/pages/settings-41fc2a11b6be2683.js +0 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-62b55bae7f1b3793.js +0 -1
- package/out/_next/static/chunks/pages/slices-81e382c3374273df.js +0 -1
- package/out/_next/static/css/3c26dbbbd8f4be12.css +0 -1
- package/out/_next/static/css/ca32882a5d2d8d88.css +0 -1
- package/out/_next/static/eFhKCr9d2Q8SjtAKgFjlm/_buildManifest.js +0 -1
- package/out/settings.html +0 -1
- package/pages/settings.tsx +0 -1
- package/postcss.config.js +0 -10
- package/src/components/RelativeTime/RelativeTime.stories.tsx +0 -25
- package/src/components/RelativeTime/RelativeTime.tsx +0 -40
- package/src/components/RelativeTime/index.ts +0 -1
- package/src/features/settings/SettingsPage.tsx +0 -29
- package/src/features/settings/git/ConnectGitRepository.tsx +0 -116
- 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 -86
- package/src/features/settings/git/GitRepositoryDisconnectDialog.tsx +0 -60
- 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/SettingsIcon.tsx +0 -19
- /package/out/_next/static/{eFhKCr9d2Q8SjtAKgFjlm → RPiYsHNCOerXD0jYQi5Za}/_ssgManifest.js +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.FieldSet_flex__qy2tm{all:unset;display:flex}.FieldSet_column__NS4qQ{flex-direction:column}.FieldSet_root__XVbMv{border-color:var(--grey6);border-radius:6px;border-style:solid;border-width:1px;box-shadow:var(--box-shadow-1);overflow-x:hidden}.FieldSet_row__END9k{align-items:center;flex-direction:row;gap:8px;padding-inline:16px}.FieldSet_borderBottom__L01vK{box-sizing:border-box}.FieldSet_borderBottom__L01vK:not(:last-child){border-bottom:1px solid var(--grey6)}.FieldSet_legend__JjRCM{background-color:var(--grey2);height:48px;order:0}.FieldSet_header__0Q7YD{background-color:var(--grey2);height:72px;order:1}.FieldSet_content__PDj3t{background-color:var(--grey1);order:2;padding:16px}.FieldSet_list__HoMpl{max-height:256px;order:2;overflow-y:auto}.FieldSet_listItem__P0SKW{background-color:var(--grey1);flex-shrink:0;height:64px}.FieldSet_listItemText__J0_Fr{flex-grow:1}.FieldSet_borderTop__qyC9U:not(:first-child){box-shadow:0 -1px 0 0 var(--grey6)}.FieldSet_footer__thBWh{background-color:var(--grey1);height:48px;order:3;padding-right:8px}.FieldSet_footerText__mKIv2{flex-grow:1}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
self.__BUILD_MANIFEST=function(s,c,a,e,t,i,f,b,n,u,d,h,l,k,j,p,g,o,r){return{__rewrites:{beforeFiles:[],afterFiles:[],fallback:[]},"/":[a,j,p,"static/chunks/pages/index-64cfb8b0948ba8ef.js"],"/_error":["static/chunks/pages/_error-69b4f498bafdd188.js"],"/changelog":[s,e,"static/chunks/870-0c7a8a9622de78b7.js","static/chunks/pages/changelog-02cd80dad6f40878.js"],"/changes":[s,t,"static/chunks/8eec4907-b712959d9f984b68.js",i,"static/chunks/918-5bb55fb464e34768.js",c,b,"static/css/838fd8bb5a7c32b0.css","static/chunks/pages/changes-8de69920dfb5a48f.js"],"/custom-types":[a,j,p,"static/chunks/pages/custom-types-94b8f8dbf7727412.js"],"/custom-types/[customTypeId]":[s,n,u,d,h,e,f,i,l,g,c,a,k,o,r,"static/chunks/pages/custom-types/[customTypeId]-3f862ad6111a1fc0.js"],"/labs":["static/chunks/pages/labs-39b50541a4c370bf.js"],"/page-types/[pageTypeId]":[s,n,u,d,h,e,f,i,l,g,c,a,k,o,r,"static/chunks/pages/page-types/[pageTypeId]-d1ffca11c42f2603.js"],"/settings":["static/css/ca32882a5d2d8d88.css","static/chunks/pages/settings-41fc2a11b6be2683.js"],"/slices":[s,t,f,c,b,"static/css/f8eb526e10bc2441.css","static/chunks/pages/slices-81e382c3374273df.js"],"/slices/[lib]/[sliceName]/[variation]":[s,t,n,u,d,h,e,f,i,l,c,k,b,"static/css/b22c0750c14cc089.css","static/chunks/pages/slices/[lib]/[sliceName]/[variation]-62b55bae7f1b3793.js"],"/slices/[lib]/[sliceName]/[variation]/simulator":[t,"static/chunks/72585f70-28b4d7d5384b3703.js","static/chunks/18539003-5f78714a35fde4a1.js","static/chunks/777-8c5507e3b119b5dc.js","static/chunks/pages/slices/[lib]/[sliceName]/[variation]/simulator-b12346e58ac9abea.js"],sortedPages:["/","/_app","/_error","/changelog","/changes","/custom-types","/custom-types/[customTypeId]","/labs","/page-types/[pageTypeId]","/settings","/slices","/slices/[lib]/[sliceName]/[variation]","/slices/[lib]/[sliceName]/[variation]/simulator"]}}("static/chunks/59b4e022-7a3b5554b806349f.js","static/chunks/25-37d6fa7f064be04b.js","static/chunks/731-a9b66ccdc3fae2c2.js","static/chunks/183-4feb6bb3eddbc768.js","static/chunks/c8eae200-966ce352f7b5d2b9.js","static/chunks/543-f8766685f7f451e2.js","static/chunks/50-cfc2514205b86001.js","static/chunks/286-ed90373e9a469944.js","static/chunks/f36c6662-03bb5e9d9aa0b0aa.js","static/chunks/4c744e84-e3161d754618373f.js","static/chunks/065a3ddb-9a38ca0d60f0bf2f.js","static/chunks/1cc2734a-2c5b6c0367fcde86.js","static/chunks/696-b12edad30a3617e5.js","static/chunks/318-bd030cc1725e23b5.js","static/chunks/727-2235967a881f9035.js","static/css/be1f49e49a5aa7eb.css","static/chunks/474-5a072e6fac61f703.js","static/chunks/904-6d6937d53ea2761e.js","static/css/72465cc1225f28a2.css"),self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();
|
package/out/settings.html
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/css/3c26dbbbd8f4be12.css" as="style"/><link rel="stylesheet" href="/_next/static/css/3c26dbbbd8f4be12.css" data-n-g=""/><link rel="preload" href="/_next/static/css/ca32882a5d2d8d88.css" as="style"/><link rel="stylesheet" href="/_next/static/css/ca32882a5d2d8d88.css" data-n-p=""/><noscript data-n-css=""></noscript><script defer="" nomodule="" src="/_next/static/chunks/polyfills-c67a75d1b6f99dc8.js"></script><script src="/_next/static/chunks/webpack-2f903acb0cccbf9e.js" defer=""></script><script src="/_next/static/chunks/framework-cdccea7a52cc6e81.js" defer=""></script><script src="/_next/static/chunks/main-5e6780279ca21cb9.js" defer=""></script><script src="/_next/static/chunks/pages/_app-027b9e90438a0d83.js" defer=""></script><script src="/_next/static/chunks/pages/settings-41fc2a11b6be2683.js" defer=""></script><script src="/_next/static/eFhKCr9d2Q8SjtAKgFjlm/_buildManifest.js" defer=""></script><script src="/_next/static/eFhKCr9d2Q8SjtAKgFjlm/_ssgManifest.js" defer=""></script></head><body><div id="__next"></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{}},"page":"/settings","query":{},"buildId":"eFhKCr9d2Q8SjtAKgFjlm","runtimeConfig":{"sentryEnvironment":"alpha"},"nextExport":true,"autoExport":true,"isFallback":false,"scriptLoader":[]}</script></body></html>
|
package/pages/settings.tsx
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { SettingsPage as default } from "@src/features/settings/SettingsPage";
|
package/postcss.config.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
-
|
|
3
|
-
import { RelativeTime } from "./RelativeTime";
|
|
4
|
-
|
|
5
|
-
type Story = StoryObj<typeof meta>;
|
|
6
|
-
|
|
7
|
-
const meta = {
|
|
8
|
-
component: RelativeTime,
|
|
9
|
-
argTypes: {
|
|
10
|
-
date: { control: "date" },
|
|
11
|
-
},
|
|
12
|
-
} satisfies Meta<typeof RelativeTime>;
|
|
13
|
-
|
|
14
|
-
export default meta;
|
|
15
|
-
|
|
16
|
-
export const Default = {
|
|
17
|
-
args: {
|
|
18
|
-
date: new Date("1 Jan 2024"),
|
|
19
|
-
},
|
|
20
|
-
render: ({ date, ...otherArgs }) => (
|
|
21
|
-
// The `date` control converts the `date` arg into a UNIX timestamp. That's
|
|
22
|
-
// why we need to convert it back into a `Date` object.
|
|
23
|
-
<RelativeTime {...otherArgs} date={new Date(date)} />
|
|
24
|
-
),
|
|
25
|
-
} satisfies Story;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { Text } from "@prismicio/editor-ui";
|
|
2
|
-
import type { FC } from "react";
|
|
3
|
-
|
|
4
|
-
type RelativeTimeProps = {
|
|
5
|
-
date: Date;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export const RelativeTime: FC<RelativeTimeProps> = ({
|
|
9
|
-
date,
|
|
10
|
-
...otherProps
|
|
11
|
-
}) => (
|
|
12
|
-
<Text {...otherProps} color="inherit" variant="inherit">
|
|
13
|
-
{formatRelativeTime(date)}
|
|
14
|
-
</Text>
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
const rtf = new Intl.RelativeTimeFormat("en", {
|
|
18
|
-
numeric: "auto",
|
|
19
|
-
style: "narrow",
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
function formatRelativeTime(date: Date, now = new Date()): string {
|
|
23
|
-
return rtf.format(differenceInCalendarDays(date, now), "day");
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const millisecondsInDay = 1_000 * 60 * 60 * 24;
|
|
27
|
-
|
|
28
|
-
// Adapted from: https://github.com/date-fns/date-fns/blob/6f44a167e71053999c10aa9462d7f0c52fec0faa/src/differenceInCalendarDays/index.ts.
|
|
29
|
-
function differenceInCalendarDays(dateLeft: Date, dateRight: Date): number {
|
|
30
|
-
const startOfDayLeft = startOfDay(dateLeft);
|
|
31
|
-
const startOfDayRight = startOfDay(dateRight);
|
|
32
|
-
return Math.round((+startOfDayLeft - +startOfDayRight) / millisecondsInDay);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Adapted from: https://github.com/date-fns/date-fns/blob/6f44a167e71053999c10aa9462d7f0c52fec0faa/src/startOfDay/index.ts.
|
|
36
|
-
function startOfDay(date: Date): Date {
|
|
37
|
-
const newDate = new Date(date);
|
|
38
|
-
newDate.setHours(0, 0, 0, 0);
|
|
39
|
-
return newDate;
|
|
40
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { RelativeTime } from "./RelativeTime";
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Box } from "@prismicio/editor-ui";
|
|
2
|
-
import Head from "next/head";
|
|
3
|
-
import type { FC } from "react";
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
AppLayout,
|
|
7
|
-
AppLayoutBreadcrumb,
|
|
8
|
-
AppLayoutContent,
|
|
9
|
-
AppLayoutHeader,
|
|
10
|
-
} from "@components/AppLayout";
|
|
11
|
-
import { ConnectGitRepository } from "@src/features/settings/git/ConnectGitRepository";
|
|
12
|
-
|
|
13
|
-
export const SettingsPage: FC = () => (
|
|
14
|
-
<>
|
|
15
|
-
<Head>
|
|
16
|
-
<title>Settings - Slice Machine</title>
|
|
17
|
-
</Head>
|
|
18
|
-
<AppLayout>
|
|
19
|
-
<AppLayoutHeader>
|
|
20
|
-
<AppLayoutBreadcrumb folder="Settings" />
|
|
21
|
-
</AppLayoutHeader>
|
|
22
|
-
<AppLayoutContent>
|
|
23
|
-
<Box flexDirection="column" maxWidth={600}>
|
|
24
|
-
<ConnectGitRepository />
|
|
25
|
-
</Box>
|
|
26
|
-
</AppLayoutContent>
|
|
27
|
-
</AppLayout>
|
|
28
|
-
</>
|
|
29
|
-
);
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Button,
|
|
3
|
-
ErrorBoundary,
|
|
4
|
-
IconButton,
|
|
5
|
-
Tooltip,
|
|
6
|
-
} from "@prismicio/editor-ui";
|
|
7
|
-
import {
|
|
8
|
-
isUnauthenticatedError,
|
|
9
|
-
isUnauthorizedError,
|
|
10
|
-
} from "@slicemachine/manager/client";
|
|
11
|
-
import { type FC, type ReactNode, Suspense } from "react";
|
|
12
|
-
|
|
13
|
-
import {
|
|
14
|
-
FieldSet,
|
|
15
|
-
FieldSetContent,
|
|
16
|
-
FieldSetFooter,
|
|
17
|
-
FieldSetLegend,
|
|
18
|
-
} from "@src/components/FieldSet";
|
|
19
|
-
import { ConnectGitRepositoryBlankSlate } from "@src/features/settings/git/ConnectGitRepositoryBlankSlate";
|
|
20
|
-
import { GitProviderConnectButtons } from "@src/features/settings/git/GitProviderConnectButtons";
|
|
21
|
-
import { GitRepositoriesList } from "@src/features/settings/git/GitRepositoriesList";
|
|
22
|
-
import {
|
|
23
|
-
GitRepositoriesSearch,
|
|
24
|
-
GitRepositoriesSearchSkeleton,
|
|
25
|
-
} from "@src/features/settings/git/GitRepositoriesSearch";
|
|
26
|
-
import { useGitOwners } from "@src/features/settings/git/useGitOwners";
|
|
27
|
-
import { useLinkedGitRepos } from "@src/features/settings/git/useLinkedGitRepos";
|
|
28
|
-
import useSliceMachineActions from "@src/modules/useSliceMachineActions";
|
|
29
|
-
|
|
30
|
-
export const ConnectGitRepository: FC = () => (
|
|
31
|
-
<FieldSet>
|
|
32
|
-
<FieldSetLegend>Connected Git Repository</FieldSetLegend>
|
|
33
|
-
<ErrorBoundary renderError={renderError}>
|
|
34
|
-
<Suspense fallback={<GitRepositoriesSearchSkeleton gitOwnerSelect />}>
|
|
35
|
-
<Content />
|
|
36
|
-
</Suspense>
|
|
37
|
-
</ErrorBoundary>
|
|
38
|
-
<FieldSetFooter
|
|
39
|
-
action={
|
|
40
|
-
<Tooltip content="Documentation is coming soon." side="bottom">
|
|
41
|
-
<IconButton disabled icon="openInNew" />
|
|
42
|
-
</Tooltip>
|
|
43
|
-
}
|
|
44
|
-
>
|
|
45
|
-
Learn more about Prismic for Git
|
|
46
|
-
</FieldSetFooter>
|
|
47
|
-
</FieldSet>
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
const Content: FC = () => {
|
|
51
|
-
const { linkedGitRepos } = useLinkedGitRepos();
|
|
52
|
-
return linkedGitRepos.length > 0 ? (
|
|
53
|
-
<GitRepositoriesList mode="unlink" repos={linkedGitRepos} />
|
|
54
|
-
) : (
|
|
55
|
-
<UnlinkedRepositoryContent />
|
|
56
|
-
);
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const UnlinkedRepositoryContent: FC = () => {
|
|
60
|
-
const owners = useGitOwners();
|
|
61
|
-
return owners.length > 0 ? (
|
|
62
|
-
<GitRepositoriesSearch owners={owners} />
|
|
63
|
-
) : (
|
|
64
|
-
<FieldSetContent>
|
|
65
|
-
<GitProviderConnectButtons />
|
|
66
|
-
</FieldSetContent>
|
|
67
|
-
);
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
function renderError(error: unknown, reset: () => void): ReactNode {
|
|
71
|
-
if (isUnauthenticatedError(error)) {
|
|
72
|
-
return <UnauthenticatedErrorContent />;
|
|
73
|
-
} else if (isUnauthorizedError(error)) {
|
|
74
|
-
return <UnauthorizedErrorContent />;
|
|
75
|
-
} else {
|
|
76
|
-
return <UnknownErrorContent reset={reset} />;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const UnauthenticatedErrorContent: FC = () => {
|
|
81
|
-
const { openLoginModal } = useSliceMachineActions();
|
|
82
|
-
return (
|
|
83
|
-
<FieldSetContent>
|
|
84
|
-
<ConnectGitRepositoryBlankSlate
|
|
85
|
-
title="It seems like you are logged out"
|
|
86
|
-
description="Log in to connect a Git repository."
|
|
87
|
-
action={<Button onClick={openLoginModal}>Log in to Prismic</Button>}
|
|
88
|
-
/>
|
|
89
|
-
</FieldSetContent>
|
|
90
|
-
);
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
const UnauthorizedErrorContent: FC = () => (
|
|
94
|
-
<FieldSetContent>
|
|
95
|
-
<ConnectGitRepositoryBlankSlate
|
|
96
|
-
title="It seems like you do not have permission"
|
|
97
|
-
description="An owner or admin is required to connect a Git repository."
|
|
98
|
-
/>
|
|
99
|
-
</FieldSetContent>
|
|
100
|
-
);
|
|
101
|
-
|
|
102
|
-
type UnknownErrorContentProps = { reset: () => void };
|
|
103
|
-
|
|
104
|
-
const UnknownErrorContent: FC<UnknownErrorContentProps> = ({ reset }) => (
|
|
105
|
-
<FieldSetContent>
|
|
106
|
-
<ConnectGitRepositoryBlankSlate
|
|
107
|
-
title="Unable to fetch data"
|
|
108
|
-
description="An error occurred while fetching the list of connected Git repositories."
|
|
109
|
-
action={
|
|
110
|
-
<Button color="grey" onClick={reset}>
|
|
111
|
-
Retry
|
|
112
|
-
</Button>
|
|
113
|
-
}
|
|
114
|
-
/>
|
|
115
|
-
</FieldSetContent>
|
|
116
|
-
);
|
|
@@ -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, tokens } from "@prismicio/editor-ui";
|
|
2
|
-
import type { GitOwner } from "@slicemachine/manager";
|
|
3
|
-
import type { ComponentProps, FC } from "react";
|
|
4
|
-
|
|
5
|
-
import { gitProviderToConfig } from "@src/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={tokens.color.greyLight11} />;
|
|
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 = ComponentProps<typeof Select>["sx"];
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { BitbucketIcon } from "@src/icons/BitbucketIcon";
|
|
2
|
-
import { GitHubIcon } from "@src/icons/GitHubIcon";
|
|
3
|
-
import { GitLabIcon } from "@src/icons/GitLabIcon";
|
|
4
|
-
import { managerClient } from "@src/managerClient";
|
|
5
|
-
|
|
6
|
-
export type GitProvider = keyof typeof gitProviderToConfig;
|
|
7
|
-
|
|
8
|
-
const GITHUB_APP_SLUG = "prismic-prod-internal-test";
|
|
9
|
-
|
|
10
|
-
export const gitProviderToConfig = {
|
|
11
|
-
gitHub: {
|
|
12
|
-
connect: async () => {
|
|
13
|
-
const state = await managerClient.git.createGitHubAuthState();
|
|
14
|
-
const url = new URL(
|
|
15
|
-
`https://github.com/apps/${GITHUB_APP_SLUG}/installations/new`,
|
|
16
|
-
);
|
|
17
|
-
url.searchParams.set("state", state.key);
|
|
18
|
-
window.open(url, "git-hub-app-installation");
|
|
19
|
-
},
|
|
20
|
-
Icon: GitHubIcon,
|
|
21
|
-
name: "GitHub",
|
|
22
|
-
supported: true,
|
|
23
|
-
},
|
|
24
|
-
bitbucket: {
|
|
25
|
-
connect: () => {
|
|
26
|
-
throw new Error("Not implemented.");
|
|
27
|
-
},
|
|
28
|
-
Icon: BitbucketIcon,
|
|
29
|
-
name: "Bitbucket",
|
|
30
|
-
supported: false,
|
|
31
|
-
},
|
|
32
|
-
gitLab: {
|
|
33
|
-
connect: () => {
|
|
34
|
-
throw new Error("Not implemented.");
|
|
35
|
-
},
|
|
36
|
-
Icon: GitLabIcon,
|
|
37
|
-
name: "GitLab",
|
|
38
|
-
supported: false,
|
|
39
|
-
},
|
|
40
|
-
};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { keys } from "@prismicio/editor-support/Object";
|
|
2
|
-
import { Button, ButtonGroup, Text, tokens } from "@prismicio/editor-ui";
|
|
3
|
-
import { type ComponentProps, type FC, useState } from "react";
|
|
4
|
-
import { toast } from "react-toastify";
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
type GitProvider,
|
|
8
|
-
gitProviderToConfig,
|
|
9
|
-
} from "@src/features/settings/git/GitProvider";
|
|
10
|
-
|
|
11
|
-
export const GitProviderConnectButtons: FC = () => (
|
|
12
|
-
<ButtonGroup>
|
|
13
|
-
{keys(gitProviderToConfig).map((provider) => (
|
|
14
|
-
<GitProviderConnectButton
|
|
15
|
-
key={provider}
|
|
16
|
-
provider={provider}
|
|
17
|
-
sx={{ flexBasis: 0, flexGrow: 1 }}
|
|
18
|
-
/>
|
|
19
|
-
))}
|
|
20
|
-
</ButtonGroup>
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
type GitProviderConnectButtonProps = { provider: GitProvider; sx?: SX };
|
|
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={tokens.color.greyLight11} />}
|
|
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 = ComponentProps<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 "@src/components/FieldSet";
|
|
6
|
-
import { RelativeTime } from "@src/components/RelativeTime";
|
|
7
|
-
import { GitRepositoryConnectDialog } from "@src/features/settings/git/GitRepositoryConnectDialog";
|
|
8
|
-
import { GitRepositoryDisconnectDialog } from "@src/features/settings/git/GitRepositoryDisconnectDialog";
|
|
9
|
-
import { useLinkedGitRepos } from "@src/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 "@src/components/FieldSet";
|
|
5
|
-
import { ConnectGitRepositoryBlankSlate } from "@src/features/settings/git/ConnectGitRepositoryBlankSlate";
|
|
6
|
-
import { GitOwnerSelect } from "@src/features/settings/git/GitOwnerSelect";
|
|
7
|
-
import {
|
|
8
|
-
GitRepositoriesList,
|
|
9
|
-
GitRepositoriesListSkeleton,
|
|
10
|
-
} from "@src/features/settings/git/GitRepositoriesList";
|
|
11
|
-
import { useGitRepos } from "@src/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
|
-
);
|