sanity-plugin-dashboard-widget-netlify 2.0.4 → 3.0.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/README.md +30 -46
- package/dist/index.d.ts +37 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +220 -0
- package/dist/index.js.map +1 -0
- package/package.json +39 -100
- package/lib/index.d.mts +0 -45
- package/lib/index.d.ts +0 -45
- package/lib/index.js +0 -172
- package/lib/index.js.map +0 -1
- package/lib/index.mjs +0 -176
- package/lib/index.mjs.map +0 -1
- package/sanity.json +0 -8
- package/src/components/NetlifyWidget.tsx +0 -47
- package/src/components/SiteItem/Links.tsx +0 -40
- package/src/components/SiteItem/index.tsx +0 -79
- package/src/components/SiteList.tsx +0 -42
- package/src/datastores/deploy.ts +0 -14
- package/src/http/jsonRequest.ts +0 -33
- package/src/http/statusCodeRequest.ts +0 -33
- package/src/http/utils/createAbortController.ts +0 -8
- package/src/index.ts +0 -7
- package/src/plugin.tsx +0 -16
- package/src/props.ts +0 -55
- package/src/reducers.ts +0 -53
- package/src/types.ts +0 -33
- package/src/widget.tsx +0 -18
- package/v2-incompatible.js +0 -11
package/README.md
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
# Sanity Dashboard Widget: Netlify
|
|
2
2
|
|
|
3
|
-
>This is a **Sanity Studio v3** plugin.
|
|
4
|
-
> For the v2 version, please refer to the [v2-branch](https://github.com/sanity-io/sanity-plugin-dashboard-widget-netlify/tree/studio-v2).
|
|
5
|
-
|
|
6
3
|
Sanity Studio Dashboard Widget for triggering Netlify builds.
|
|
7
4
|
|
|
8
5
|
## Install
|
|
@@ -24,8 +21,8 @@ Ensure that you have followed install and usage instructions for [@sanity/dashbo
|
|
|
24
21
|
Add it as a widget to @sanity/dashboard plugin in sanity.config.ts (or .js):
|
|
25
22
|
|
|
26
23
|
```js
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
24
|
+
import {dashboardTool} from '@sanity/dashboard'
|
|
25
|
+
import {netlifyWidget} from 'sanity-plugin-dashboard-widget-netlify'
|
|
29
26
|
|
|
30
27
|
export default defineConfig({
|
|
31
28
|
// ...
|
|
@@ -33,55 +30,42 @@ export default defineConfig({
|
|
|
33
30
|
dashboardTool({
|
|
34
31
|
widgets: [
|
|
35
32
|
netlifyWidget({
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
})
|
|
53
|
-
]
|
|
54
|
-
})
|
|
55
|
-
]
|
|
33
|
+
title: 'My Netlify deploys',
|
|
34
|
+
sites: [
|
|
35
|
+
{
|
|
36
|
+
title: 'Sanity Studio',
|
|
37
|
+
apiId: 'xxxxx-yyyy-zzzz-xxxx-yyyyyyyy',
|
|
38
|
+
buildHookId: 'xxxyyyxxxyyyyxxxyyy',
|
|
39
|
+
name: 'sanity-gatsby-blog-20-studio',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
title: 'Website',
|
|
43
|
+
apiId: 'yyyyy-xxxxx-zzzz-xxxx-yyyyyyyy',
|
|
44
|
+
buildHookId: 'yyyyxxxxxyyyxxdxxx',
|
|
45
|
+
name: 'sanity-gatsby-blog-20-web',
|
|
46
|
+
url: 'https://my-sanity-deployment.com',
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
}),
|
|
50
|
+
],
|
|
51
|
+
}),
|
|
52
|
+
],
|
|
56
53
|
})
|
|
57
54
|
```
|
|
58
55
|
|
|
59
56
|
### Widget options
|
|
57
|
+
|
|
60
58
|
`title` - Override the widget default title
|
|
61
59
|
|
|
62
60
|
`sites[]` - Your Netlify sites to show deploys for
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
61
|
+
|
|
62
|
+
- `apiId`- The Netfliy API ID of your site (see _Site Settings > General > Site Details > Site Information -> API ID_).
|
|
63
|
+
- `buildHookId` - The id of a build hook you have created for your site within the Netlify administration panel (see _Site Settings > Build & Deploy > Continuous Deployment -> Build Hooks_).
|
|
64
|
+
- `name` - The Netlify site name
|
|
65
|
+
- `title` - Override the site name with a custom title
|
|
66
|
+
- `url` - Optionally override site deployment url. By default it is inferred to be `https://netlify-site-name.netlify.app`.
|
|
67
|
+
- `branch` - Optionally pass the name of a branch to deploy
|
|
69
68
|
|
|
70
69
|
## License
|
|
71
70
|
|
|
72
71
|
MIT-licensed. See LICENSE.
|
|
73
|
-
|
|
74
|
-
## Develop & test
|
|
75
|
-
|
|
76
|
-
This plugin uses [@sanity/plugin-kit](https://github.com/sanity-io/plugin-kit)
|
|
77
|
-
with default configuration for build & watch scripts.
|
|
78
|
-
|
|
79
|
-
See [Testing a plugin in Sanity Studio](https://github.com/sanity-io/plugin-kit#testing-a-plugin-in-sanity-studio)
|
|
80
|
-
on how to run this plugin with hotreload in the studio.
|
|
81
|
-
|
|
82
|
-
### Release new version
|
|
83
|
-
|
|
84
|
-
Run ["CI & Release" workflow](https://github.com/sanity-io/sanity-plugin-dashboard-widget-netlify/actions/workflows/main.yml).
|
|
85
|
-
Make sure to select the main branch and check "Release new version".
|
|
86
|
-
|
|
87
|
-
Semantic release will only release on configured branches, so it is safe to run release on any branch.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { DashboardWidget, LayoutConfig } from "@sanity/dashboard";
|
|
2
|
+
interface SiteWidgetOption {
|
|
3
|
+
apiId: string;
|
|
4
|
+
name?: string;
|
|
5
|
+
title: string;
|
|
6
|
+
buildHookId: string;
|
|
7
|
+
url?: string;
|
|
8
|
+
branch?: string;
|
|
9
|
+
}
|
|
10
|
+
interface WidgetOptions {
|
|
11
|
+
title?: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
sites: SiteWidgetOption[];
|
|
14
|
+
}
|
|
15
|
+
interface Site {
|
|
16
|
+
title: string;
|
|
17
|
+
name?: string;
|
|
18
|
+
id: string;
|
|
19
|
+
url?: string;
|
|
20
|
+
adminUrl?: string;
|
|
21
|
+
buildHookId: string;
|
|
22
|
+
branch?: string;
|
|
23
|
+
}
|
|
24
|
+
type DeployAction = (site: Site) => void;
|
|
25
|
+
interface NetlifyWidgetProps {
|
|
26
|
+
title?: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
sites?: Site[];
|
|
29
|
+
isLoading: boolean;
|
|
30
|
+
onDeploy: DeployAction;
|
|
31
|
+
}
|
|
32
|
+
type NetlifyWidgetConfig = WidgetOptions & {
|
|
33
|
+
layout?: LayoutConfig;
|
|
34
|
+
};
|
|
35
|
+
declare function netlifyWidget(config: NetlifyWidgetConfig): DashboardWidget;
|
|
36
|
+
export { DeployAction, type NetlifyWidgetConfig, NetlifyWidgetProps, Site, SiteWidgetOption, WidgetOptions, netlifyWidget };
|
|
37
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/plugin.tsx"],"mappings":";UAAiB,gBAAA;EACf,KAAA;EACA,IAAA;EACA,KAAA;EACA,WAAA;EACA,GAAA;EACA,MAAA;AAAA;AAAA,UAEe,aAAA;EACf,KAAA;EACA,WAAA;EACA,KAAA,EAAO,gBAAgB;AAAA;AAAA,UAGR,IAAA;EACf,KAAA;EACA,IAAA;EACA,EAAA;EACA,GAAA;EACA,QAAA;EACA,WAAA;EACA,MAAA;AAAA;AAAA,KAGU,YAAA,IAAgB,IAAU,EAAJ,IAAI;AAAA,UAErB,kBAAA;EACf,KAAA;EACA,WAAA;EACA,KAAA,GAAQ,IAAA;EACR,SAAA;EACA,QAAA,EAAU,YAAY;AAAA;AAAA,KC1BZ,mBAAA,GAAsB,aAAA;EAAiB,MAAA,GAAS,YAAY;AAAA;AAAA,iBAExD,aAAA,CAAc,MAAA,EAAQ,mBAAA,GAAsB,eAAe"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { DashboardWidgetContainer } from "@sanity/dashboard";
|
|
4
|
+
import { Flex, Text, Card, Label, Box, Stack, Button, Spinner } from "@sanity/ui";
|
|
5
|
+
import { styled } from "styled-components";
|
|
6
|
+
import { useState, useEffect, useRef } from "react";
|
|
7
|
+
const Link = (props) => {
|
|
8
|
+
const $ = c(3), {
|
|
9
|
+
url,
|
|
10
|
+
children
|
|
11
|
+
} = props;
|
|
12
|
+
let t0;
|
|
13
|
+
return $[0] !== children || $[1] !== url ? (t0 = /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx("a", { href: url, target: "_blank", rel: "noreferrer", children }) }), $[0] = children, $[1] = url, $[2] = t0) : t0 = $[2], t0;
|
|
14
|
+
}, Links = (props) => {
|
|
15
|
+
const $ = c(11), {
|
|
16
|
+
url,
|
|
17
|
+
adminUrl
|
|
18
|
+
} = props;
|
|
19
|
+
if (url && adminUrl) {
|
|
20
|
+
let t0;
|
|
21
|
+
$[0] !== url ? (t0 = /* @__PURE__ */ jsx(Link, { url, children: "view" }), $[0] = url, $[1] = t0) : t0 = $[1];
|
|
22
|
+
let t1;
|
|
23
|
+
$[2] !== adminUrl ? (t1 = /* @__PURE__ */ jsx(Link, { url: adminUrl, children: "admin" }), $[2] = adminUrl, $[3] = t1) : t1 = $[3];
|
|
24
|
+
let t2;
|
|
25
|
+
return $[4] !== t0 || $[5] !== t1 ? (t2 = /* @__PURE__ */ jsxs("span", { children: [
|
|
26
|
+
"(",
|
|
27
|
+
t0,
|
|
28
|
+
", ",
|
|
29
|
+
t1,
|
|
30
|
+
")"
|
|
31
|
+
] }), $[4] = t0, $[5] = t1, $[6] = t2) : t2 = $[6], t2;
|
|
32
|
+
}
|
|
33
|
+
if (url) {
|
|
34
|
+
let t0;
|
|
35
|
+
return $[7] !== url ? (t0 = /* @__PURE__ */ jsx(Link, { url, children: "(view)" }), $[7] = url, $[8] = t0) : t0 = $[8], t0;
|
|
36
|
+
}
|
|
37
|
+
if (adminUrl) {
|
|
38
|
+
let t0;
|
|
39
|
+
return $[9] !== adminUrl ? (t0 = /* @__PURE__ */ jsx(Link, { url: adminUrl, children: "(admin)" }), $[9] = adminUrl, $[10] = t0) : t0 = $[10], t0;
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
}, IMAGE_PULL_INTERVAL = 1e4, getImageUrl = (siteId, branchName) => {
|
|
43
|
+
const baseUrl = `https://api.netlify.com/api/v1/badges/${siteId}/deploy-status`, time = (/* @__PURE__ */ new Date()).getTime(), branch = `branch=${branchName}`;
|
|
44
|
+
return branchName ? `${baseUrl}?${time}&${branch}` : `${baseUrl}?${time}`;
|
|
45
|
+
}, useBadgeImage = (siteId, branchName) => {
|
|
46
|
+
const $ = c(12);
|
|
47
|
+
let t0;
|
|
48
|
+
$[0] !== branchName || $[1] !== siteId ? (t0 = () => getImageUrl(siteId, branchName), $[0] = branchName, $[1] = siteId, $[2] = t0) : t0 = $[2];
|
|
49
|
+
const [src, setSrc] = useState(t0);
|
|
50
|
+
let t1;
|
|
51
|
+
$[3] !== branchName || $[4] !== siteId ? (t1 = () => setSrc(getImageUrl(siteId, branchName)), $[3] = branchName, $[4] = siteId, $[5] = t1) : t1 = $[5];
|
|
52
|
+
const update = t1;
|
|
53
|
+
let t2, t3;
|
|
54
|
+
$[6] !== update ? (t2 = () => {
|
|
55
|
+
const interval = window.setInterval(update, IMAGE_PULL_INTERVAL);
|
|
56
|
+
return () => window.clearInterval(interval);
|
|
57
|
+
}, t3 = [update], $[6] = update, $[7] = t2, $[8] = t3) : (t2 = $[7], t3 = $[8]), useEffect(t2, t3);
|
|
58
|
+
let t4;
|
|
59
|
+
return $[9] !== src || $[10] !== update ? (t4 = [src, update], $[9] = src, $[10] = update, $[11] = t4) : t4 = $[11], t4;
|
|
60
|
+
}, useDeploy = (site, onDeploy, updateBadge) => {
|
|
61
|
+
const $ = c(6), timeoutRef = useRef(-1);
|
|
62
|
+
let t0, t1;
|
|
63
|
+
$[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = () => () => window.clearTimeout(timeoutRef.current), t1 = [], $[0] = t0, $[1] = t1) : (t0 = $[0], t1 = $[1]), useEffect(t0, t1);
|
|
64
|
+
let t2;
|
|
65
|
+
return $[2] !== onDeploy || $[3] !== site || $[4] !== updateBadge ? (t2 = () => {
|
|
66
|
+
onDeploy(site), timeoutRef.current = window.setTimeout(updateBadge, 1e3);
|
|
67
|
+
}, $[2] = onDeploy, $[3] = site, $[4] = updateBadge, $[5] = t2) : t2 = $[5], t2;
|
|
68
|
+
}, SiteItem = (props) => {
|
|
69
|
+
const $ = c(24), [hasBadgeError, setHasBadgeError] = useState(!1), {
|
|
70
|
+
site,
|
|
71
|
+
onDeploy
|
|
72
|
+
} = props, {
|
|
73
|
+
id,
|
|
74
|
+
name,
|
|
75
|
+
title,
|
|
76
|
+
url,
|
|
77
|
+
adminUrl,
|
|
78
|
+
buildHookId,
|
|
79
|
+
branch
|
|
80
|
+
} = site, [badge, updateBadge] = useBadgeImage(id, branch), handleDeploy = useDeploy(site, onDeploy, updateBadge);
|
|
81
|
+
let t0;
|
|
82
|
+
$[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = () => {
|
|
83
|
+
setHasBadgeError(!0);
|
|
84
|
+
}, $[0] = t0) : t0 = $[0];
|
|
85
|
+
const handleBadgeError = t0, t1 = title || name;
|
|
86
|
+
let t2;
|
|
87
|
+
$[1] !== adminUrl || $[2] !== url ? (t2 = /* @__PURE__ */ jsx(Links, { url, adminUrl }), $[1] = adminUrl, $[2] = url, $[3] = t2) : t2 = $[3];
|
|
88
|
+
let t3;
|
|
89
|
+
$[4] !== t1 || $[5] !== t2 ? (t3 = /* @__PURE__ */ jsxs(Text, { as: "h4", children: [
|
|
90
|
+
t1,
|
|
91
|
+
t2
|
|
92
|
+
] }), $[4] = t1, $[5] = t2, $[6] = t3) : t3 = $[6];
|
|
93
|
+
let t4;
|
|
94
|
+
$[7] !== badge || $[8] !== hasBadgeError ? (t4 = !hasBadgeError && /* @__PURE__ */ jsx("img", { src: badge, onError: handleBadgeError, alt: "Badge" }), $[7] = badge, $[8] = hasBadgeError, $[9] = t4) : t4 = $[9];
|
|
95
|
+
let t5;
|
|
96
|
+
$[10] !== hasBadgeError ? (t5 = hasBadgeError && /* @__PURE__ */ jsx(Card, { tone: "critical", radius: 2, padding: 2, children: /* @__PURE__ */ jsx(Label, { size: 0, muted: !0, children: "Failed to load badge" }) }), $[10] = hasBadgeError, $[11] = t5) : t5 = $[11];
|
|
97
|
+
let t6;
|
|
98
|
+
$[12] !== t4 || $[13] !== t5 ? (t6 = /* @__PURE__ */ jsxs(Flex, { justify: "flex-start", children: [
|
|
99
|
+
t4,
|
|
100
|
+
t5
|
|
101
|
+
] }), $[12] = t4, $[13] = t5, $[14] = t6) : t6 = $[14];
|
|
102
|
+
let t7;
|
|
103
|
+
$[15] !== t3 || $[16] !== t6 ? (t7 = /* @__PURE__ */ jsx(Box, { flex: 1, paddingY: 2, paddingX: 3, children: /* @__PURE__ */ jsxs(Stack, { gap: 2, children: [
|
|
104
|
+
t3,
|
|
105
|
+
t6
|
|
106
|
+
] }) }), $[15] = t3, $[16] = t6, $[17] = t7) : t7 = $[17];
|
|
107
|
+
let t8;
|
|
108
|
+
$[18] !== buildHookId || $[19] !== handleDeploy ? (t8 = buildHookId ? /* @__PURE__ */ jsx(Box, { paddingY: 2, paddingX: 3, children: /* @__PURE__ */ jsx(Button, { mode: "ghost", onClick: handleDeploy, text: "Deploy" }) }) : null, $[18] = buildHookId, $[19] = handleDeploy, $[20] = t8) : t8 = $[20];
|
|
109
|
+
let t9;
|
|
110
|
+
return $[21] !== t7 || $[22] !== t8 ? (t9 = /* @__PURE__ */ jsxs(Flex, { as: "li", children: [
|
|
111
|
+
t7,
|
|
112
|
+
t8
|
|
113
|
+
] }), $[21] = t7, $[22] = t8, $[23] = t9) : t9 = $[23], t9;
|
|
114
|
+
};
|
|
115
|
+
function SiteList(props) {
|
|
116
|
+
const $ = c(10), {
|
|
117
|
+
isLoading,
|
|
118
|
+
onDeploy,
|
|
119
|
+
sites
|
|
120
|
+
} = props;
|
|
121
|
+
if (isLoading) {
|
|
122
|
+
let t02;
|
|
123
|
+
$[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t02 = /* @__PURE__ */ jsx(Spinner, { muted: !0 }), $[0] = t02) : t02 = $[0];
|
|
124
|
+
let t12;
|
|
125
|
+
return $[1] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t12 = /* @__PURE__ */ jsx(Card, { padding: 4, children: /* @__PURE__ */ jsxs(Flex, { direction: "column", justify: "center", align: "center", children: [
|
|
126
|
+
t02,
|
|
127
|
+
/* @__PURE__ */ jsx(Box, { marginTop: 3, children: /* @__PURE__ */ jsx(Text, { muted: !0, children: "Loading sites\u2026" }) })
|
|
128
|
+
] }) }), $[1] = t12) : t12 = $[1], t12;
|
|
129
|
+
}
|
|
130
|
+
if (!sites || sites && sites.length === 0) {
|
|
131
|
+
let t02;
|
|
132
|
+
return $[2] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t02 = /* @__PURE__ */ jsx(Card, { tone: "critical", padding: 3, children: /* @__PURE__ */ jsx(Text, { children: "No sites are defined in the widget options. Please check your config." }) }), $[2] = t02) : t02 = $[2], t02;
|
|
133
|
+
}
|
|
134
|
+
let t0;
|
|
135
|
+
if ($[3] !== onDeploy || $[4] !== sites) {
|
|
136
|
+
let t12;
|
|
137
|
+
$[6] !== onDeploy ? (t12 = (site) => /* @__PURE__ */ jsx(SiteItem, { onDeploy, site }, site.id), $[6] = onDeploy, $[7] = t12) : t12 = $[7], t0 = sites.map(t12), $[3] = onDeploy, $[4] = sites, $[5] = t0;
|
|
138
|
+
} else
|
|
139
|
+
t0 = $[5];
|
|
140
|
+
let t1;
|
|
141
|
+
return $[8] !== t0 ? (t1 = /* @__PURE__ */ jsx(Box, { paddingY: 2, children: /* @__PURE__ */ jsx(Stack, { as: "ul", gap: 2, children: t0 }) }), $[8] = t0, $[9] = t1) : t1 = $[9], t1;
|
|
142
|
+
}
|
|
143
|
+
const ContentCard = styled(Card).withConfig({
|
|
144
|
+
displayName: "ContentCard",
|
|
145
|
+
componentId: "sc-18okvlc-0"
|
|
146
|
+
})`min-height:66px;`;
|
|
147
|
+
function NetlifyWidget(props) {
|
|
148
|
+
const $ = c(16), {
|
|
149
|
+
title,
|
|
150
|
+
description,
|
|
151
|
+
isLoading,
|
|
152
|
+
sites,
|
|
153
|
+
onDeploy
|
|
154
|
+
} = props, t0 = isLoading ? void 0 : "https://app.netlify.com/account/sites";
|
|
155
|
+
let t1;
|
|
156
|
+
$[0] !== isLoading || $[1] !== t0 ? (t1 = /* @__PURE__ */ jsx(Flex, { direction: "column", align: "stretch", children: /* @__PURE__ */ jsx(Button, { as: "a", href: t0, disabled: isLoading, paddingX: 2, paddingY: 4, mode: "bleed", tone: "primary", text: "Manage sites at Netlify", loading: isLoading, target: "_blank", rel: "noopener noreferrer" }) }), $[0] = isLoading, $[1] = t0, $[2] = t1) : t1 = $[2];
|
|
157
|
+
const footer = t1;
|
|
158
|
+
let t2;
|
|
159
|
+
$[3] !== description ? (t2 = description && /* @__PURE__ */ jsx(Box, { paddingY: 3, paddingX: 3, children: /* @__PURE__ */ jsx(Text, { as: "p", size: 1, muted: !0, children: /* @__PURE__ */ jsx("span", { dangerouslySetInnerHTML: {
|
|
160
|
+
__html: description
|
|
161
|
+
} }) }) }), $[3] = description, $[4] = t2) : t2 = $[4];
|
|
162
|
+
let t3;
|
|
163
|
+
$[5] !== isLoading || $[6] !== onDeploy || $[7] !== sites ? (t3 = /* @__PURE__ */ jsx(SiteList, { isLoading, onDeploy, sites }), $[5] = isLoading, $[6] = onDeploy, $[7] = sites, $[8] = t3) : t3 = $[8];
|
|
164
|
+
let t4;
|
|
165
|
+
$[9] !== t2 || $[10] !== t3 ? (t4 = /* @__PURE__ */ jsxs(ContentCard, { paddingY: 1, children: [
|
|
166
|
+
t2,
|
|
167
|
+
t3
|
|
168
|
+
] }), $[9] = t2, $[10] = t3, $[11] = t4) : t4 = $[11];
|
|
169
|
+
let t5;
|
|
170
|
+
return $[12] !== footer || $[13] !== t4 || $[14] !== title ? (t5 = /* @__PURE__ */ jsx(DashboardWidgetContainer, { header: title, footer, children: t4 }), $[12] = footer, $[13] = t4, $[14] = title, $[15] = t5) : t5 = $[15], t5;
|
|
171
|
+
}
|
|
172
|
+
const DEFAULT_TITLE = "Netlify sites";
|
|
173
|
+
function toSite(option) {
|
|
174
|
+
const {
|
|
175
|
+
apiId,
|
|
176
|
+
name,
|
|
177
|
+
title,
|
|
178
|
+
buildHookId,
|
|
179
|
+
url,
|
|
180
|
+
branch
|
|
181
|
+
} = option;
|
|
182
|
+
return {
|
|
183
|
+
id: apiId,
|
|
184
|
+
name,
|
|
185
|
+
title,
|
|
186
|
+
buildHookId,
|
|
187
|
+
url: url || (branch && name ? `https://${branch}--${name}.netlify.app/` : void 0) || (name ? `https://${name}.netlify.app/` : void 0),
|
|
188
|
+
adminUrl: name ? `https://app.netlify.com/sites/${name}` : void 0,
|
|
189
|
+
branch
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
function deploy(site) {
|
|
193
|
+
site.buildHookId && fetch(`https://api.netlify.com/build_hooks/${site.buildHookId}`, {
|
|
194
|
+
method: "POST"
|
|
195
|
+
}).catch(() => {
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
function Widget(options) {
|
|
199
|
+
const $ = c(8);
|
|
200
|
+
let t0;
|
|
201
|
+
$[0] !== options.sites ? (t0 = options.sites || [], $[0] = options.sites, $[1] = t0) : t0 = $[1];
|
|
202
|
+
let t1;
|
|
203
|
+
$[2] !== t0 ? (t1 = t0.map(toSite), $[2] = t0, $[3] = t1) : t1 = $[3];
|
|
204
|
+
const sites = t1, t2 = options.title || DEFAULT_TITLE;
|
|
205
|
+
let t3;
|
|
206
|
+
return $[4] !== options.description || $[5] !== sites || $[6] !== t2 ? (t3 = /* @__PURE__ */ jsx(NetlifyWidget, { title: t2, description: options.description, sites, isLoading: !1, onDeploy: deploy }), $[4] = options.description, $[5] = sites, $[6] = t2, $[7] = t3) : t3 = $[7], t3;
|
|
207
|
+
}
|
|
208
|
+
function netlifyWidget(config) {
|
|
209
|
+
return {
|
|
210
|
+
name: "netlify-widget",
|
|
211
|
+
component: () => /* @__PURE__ */ jsx(Widget, { ...config }),
|
|
212
|
+
layout: config.layout ?? {
|
|
213
|
+
width: "medium"
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
export {
|
|
218
|
+
netlifyWidget
|
|
219
|
+
};
|
|
220
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/components/SiteItem/Links.tsx","../src/components/SiteItem/index.tsx","../src/components/SiteList.tsx","../src/components/NetlifyWidget.tsx","../src/widget.tsx","../src/plugin.tsx"],"sourcesContent":["import type {FunctionComponent, PropsWithChildren} from 'react'\n\nconst Link = (props: PropsWithChildren<{url: string}>) => {\n const {url, children} = props\n\n return (\n <span>\n <a href={url} target=\"_blank\" rel=\"noreferrer\">\n {children}\n </a>\n </span>\n )\n}\n\ntype Props = {\n url?: string\n adminUrl?: string\n}\n\nconst Links: FunctionComponent<Props> = (props) => {\n const {url, adminUrl} = props\n\n if (url && adminUrl) {\n return (\n <span>\n (<Link url={url}>view</Link>, <Link url={adminUrl}>admin</Link>)\n </span>\n )\n }\n\n if (url) {\n return <Link url={url}>(view)</Link>\n }\n if (adminUrl) {\n return <Link url={adminUrl}>(admin)</Link>\n }\n return null\n}\n\nexport default Links\n","import {Button, Flex, Box, Card, Text, Stack, Label} from '@sanity/ui'\nimport {type FunctionComponent, useCallback, useEffect, useRef, useState} from 'react'\n\nimport {type DeployAction, type Site} from '../../types'\nimport Links from './Links'\n\ninterface Props {\n site: Site\n onDeploy: DeployAction\n}\n\nconst IMAGE_PULL_INTERVAL = 10000\n\nconst getImageUrl = (siteId: string, branchName?: string) => {\n const baseUrl = `https://api.netlify.com/api/v1/badges/${siteId}/deploy-status`\n const time = new Date().getTime()\n const branch = `branch=${branchName}`\n\n return branchName ? `${baseUrl}?${time}&${branch}` : `${baseUrl}?${time}`\n}\n\nconst useBadgeImage = (siteId: string, branchName?: string) => {\n const [src, setSrc] = useState(() => getImageUrl(siteId, branchName))\n const update = useCallback(() => setSrc(getImageUrl(siteId, branchName)), [siteId, branchName])\n\n useEffect(() => {\n const interval = window.setInterval(update, IMAGE_PULL_INTERVAL)\n return () => window.clearInterval(interval)\n }, [update])\n\n return [src, update] as const\n}\n\nconst useDeploy = (site: Site, onDeploy: DeployAction, updateBadge: () => void) => {\n const timeoutRef = useRef(-1)\n useEffect(() => () => window.clearTimeout(timeoutRef.current), [])\n\n return useCallback(() => {\n onDeploy(site)\n timeoutRef.current = window.setTimeout(updateBadge, 1000)\n }, [site, onDeploy, updateBadge])\n}\n\nconst SiteItem: FunctionComponent<Props> = (props) => {\n const [hasBadgeError, setHasBadgeError] = useState(false)\n const {site, onDeploy} = props\n const {id, name, title, url, adminUrl, buildHookId, branch} = site\n\n const [badge, updateBadge] = useBadgeImage(id, branch)\n const handleDeploy = useDeploy(site, onDeploy, updateBadge)\n const handleBadgeError = () => {\n setHasBadgeError(true)\n }\n\n return (\n <Flex as=\"li\">\n <Box flex={1} paddingY={2} paddingX={3}>\n <Stack gap={2}>\n <Text as=\"h4\">\n {title || name}\n <Links url={url} adminUrl={adminUrl} />\n </Text>\n\n <Flex justify=\"flex-start\">\n {!hasBadgeError && <img src={badge} onError={handleBadgeError} alt=\"Badge\" />}\n {hasBadgeError && (\n <Card tone=\"critical\" radius={2} padding={2}>\n <Label size={0} muted>\n Failed to load badge\n </Label>\n </Card>\n )}\n </Flex>\n </Stack>\n </Box>\n\n {buildHookId ? (\n <Box paddingY={2} paddingX={3}>\n <Button mode=\"ghost\" onClick={handleDeploy} text=\"Deploy\" />\n </Box>\n ) : null}\n </Flex>\n )\n}\n\nexport default SiteItem\n","import {Flex, Box, Card, Text, Spinner, Stack} from '@sanity/ui'\n\nimport {type DeployAction, type Site} from '../types'\nimport SiteItem from './SiteItem'\n\ninterface Props {\n isLoading: boolean\n sites?: Site[]\n onDeploy: DeployAction\n}\n\nexport default function SiteList(props: Props) {\n const {isLoading, onDeploy, sites} = props\n if (isLoading) {\n return (\n <Card padding={4}>\n <Flex direction=\"column\" justify=\"center\" align=\"center\">\n <Spinner muted />\n <Box marginTop={3}>\n <Text muted>Loading sites…</Text>\n </Box>\n </Flex>\n </Card>\n )\n }\n if (!sites || (sites && sites.length === 0)) {\n return (\n <Card tone=\"critical\" padding={3}>\n <Text>No sites are defined in the widget options. Please check your config.</Text>\n </Card>\n )\n }\n return (\n <Box paddingY={2}>\n <Stack as=\"ul\" gap={2}>\n {sites.map((site) => {\n return <SiteItem onDeploy={onDeploy} site={site} key={site.id} />\n })}\n </Stack>\n </Box>\n )\n}\n","import {DashboardWidgetContainer} from '@sanity/dashboard'\nimport {Button, Flex, Card, Text, Box} from '@sanity/ui'\nimport {styled} from 'styled-components'\n\nimport {type NetlifyWidgetProps} from '../types'\nimport SiteList from './SiteList'\n\nconst ContentCard = styled(Card)`\n min-height: 66px;\n`\n\nexport default function NetlifyWidget(props: NetlifyWidgetProps) {\n const netlifySitesUrl = 'https://app.netlify.com/account/sites'\n const {title, description, isLoading, sites, onDeploy} = props\n\n const footer = (\n <Flex direction=\"column\" align=\"stretch\">\n <Button\n as=\"a\"\n href={isLoading ? undefined : netlifySitesUrl}\n disabled={isLoading}\n paddingX={2}\n paddingY={4}\n mode=\"bleed\"\n tone=\"primary\"\n text=\"Manage sites at Netlify\"\n loading={isLoading}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n />\n </Flex>\n )\n\n return (\n <DashboardWidgetContainer header={title} footer={footer}>\n <ContentCard paddingY={1}>\n {description && (\n <Box paddingY={3} paddingX={3}>\n <Text as=\"p\" size={1} muted>\n <span dangerouslySetInnerHTML={{__html: description}} />\n </Text>\n </Box>\n )}\n <SiteList isLoading={isLoading} onDeploy={onDeploy} sites={sites} />\n </ContentCard>\n </DashboardWidgetContainer>\n )\n}\n","import type {ReactNode} from 'react'\n\nimport NetlifyWidget from './components/NetlifyWidget'\nimport type {Site, SiteWidgetOption, WidgetOptions} from './types'\n\nconst DEFAULT_TITLE = 'Netlify sites'\n\nfunction toSite(option: SiteWidgetOption): Site {\n const {apiId, name, title, buildHookId, url, branch} = option\n\n return {\n id: apiId,\n name,\n title,\n buildHookId,\n url:\n url ||\n (branch && name ? `https://${branch}--${name}.netlify.app/` : undefined) ||\n (name ? `https://${name}.netlify.app/` : undefined),\n adminUrl: name ? `https://app.netlify.com/sites/${name}` : undefined,\n branch,\n }\n}\n\nfunction deploy(site: Site): void {\n if (!site.buildHookId) {\n return\n }\n\n fetch(`https://api.netlify.com/build_hooks/${site.buildHookId}`, {method: 'POST'}).catch(() => {\n // Build hook failures are intentionally ignored; the deploy badge will\n // keep reflecting the actual deploy status of the site.\n })\n}\n\nexport default function Widget(options: WidgetOptions): ReactNode {\n const sites = (options.sites || []).map(toSite)\n\n return (\n <NetlifyWidget\n title={options.title || DEFAULT_TITLE}\n description={options.description}\n sites={sites}\n isLoading={false}\n onDeploy={deploy}\n />\n )\n}\n","import {type DashboardWidget, type LayoutConfig} from '@sanity/dashboard'\n\nimport {type WidgetOptions} from './types'\nimport Widget from './widget'\n\nexport type NetlifyWidgetConfig = WidgetOptions & {layout?: LayoutConfig}\n\nexport function netlifyWidget(config: NetlifyWidgetConfig): DashboardWidget {\n return {\n name: 'netlify-widget',\n component: () => {\n return <Widget {...config} />\n },\n layout: config.layout ?? {width: 'medium'},\n }\n}\n"],"names":["Link","props","$","_c","url","children","t0","Links","adminUrl","t1","t2","IMAGE_PULL_INTERVAL","getImageUrl","siteId","branchName","baseUrl","time","Date","getTime","branch","useBadgeImage","src","setSrc","useState","update","t3","interval","window","setInterval","clearInterval","useEffect","t4","useDeploy","site","onDeploy","updateBadge","timeoutRef","useRef","Symbol","for","clearTimeout","current","setTimeout","SiteItem","hasBadgeError","setHasBadgeError","id","name","title","buildHookId","badge","handleDeploy","handleBadgeError","t5","t6","t7","t8","t9","SiteList","isLoading","sites","length","map","ContentCard","styled","Card","withConfig","displayName","componentId","NetlifyWidget","description","undefined","footer","__html","DEFAULT_TITLE","toSite","option","apiId","deploy","fetch","method","catch","Widget","options","netlifyWidget","config","component","layout","width"],"mappings":";;;;;;AAEA,MAAMA,OAAOC,CAAAA,UAAA;AAAA,QAAAC,IAAAC,EAAA,CAAA,GACX;AAAA,IAAAC;AAAAA,IAAAC;AAAAA,EAAAA,IAAwBJ;AAAK,MAAAK;AAAA,SAAAJ,EAAA,CAAA,MAAAG,YAAAH,SAAAE,OAG3BE,KAAA,oBAAA,UACE,UAAA,oBAAA,KAAA,EAASF,MAAAA,KAAY,QAAA,UAAa,KAAA,cAC/BC,SAAAA,CACH,GACF,GAAOH,OAAAG,UAAAH,OAAAE,KAAAF,OAAAI,MAAAA,KAAAJ,EAAA,CAAA,GAJPI;AAIO,GASLC,QAAkCN,CAAAA,UAAA;AAAA,QAAAC,IAAAC,EAAA,EAAA,GACtC;AAAA,IAAAC;AAAAA,IAAAI;AAAAA,EAAAA,IAAwBP;AAExB,MAAIG,OAAAI,UAAe;AAAA,QAAAF;AAAAJ,aAAAE,OAGZE,KAAA,oBAAC,MAAA,EAAUF,KAAK,UAAA,OAAA,CAAI,GAAOF,OAAAE,KAAAF,OAAAI,MAAAA,KAAAJ,EAAA,CAAA;AAAA,QAAAO;AAAAP,aAAAM,YAAEC,KAAA,oBAAC,MAAA,EAAUD,KAAAA,UAAU,UAAA,SAAK,GAAON,O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AAA,IACDkB,UAAAA,QAAM,GAChB5E,EAAA,CAAA,IAAAiF,QAAAb,aAAApE,OAAA0D,OAAA1D,OAAAQ,IAAAR,OAAAuB,MAAAA,KAAAvB,EAAA,CAAA,GANFuB;AAME;ACtCC,SAAS2D,cAAcC,QAA8C;AAC1E,SAAO;AAAA,IACLtC,MAAM;AAAA,IACNuC,WAAWA,MACF,oBAAC,QAAA,EAAO,GAAID,OAAAA,CAAO;AAAA,IAE5BE,QAAQF,OAAOE,UAAU;AAAA,MAACC,OAAO;AAAA,IAAA;AAAA,EAAQ;AAE7C;"}
|
package/package.json
CHANGED
|
@@ -1,123 +1,62 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sanity-plugin-dashboard-widget-netlify",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "Sanity Studio Dashboard Widget for triggering Netlify builds",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"sanity",
|
|
7
|
-
"plugin",
|
|
8
6
|
"dashboard",
|
|
9
|
-
"
|
|
10
|
-
"
|
|
7
|
+
"netlify",
|
|
8
|
+
"plugin",
|
|
9
|
+
"sanity",
|
|
10
|
+
"widget"
|
|
11
11
|
],
|
|
12
|
-
"homepage": "https://github.com/sanity-io/sanity-plugin-dashboard-widget-netlify#readme",
|
|
12
|
+
"homepage": "https://github.com/sanity-io/plugins/tree/main/plugins/sanity-plugin-dashboard-widget-netlify#readme",
|
|
13
13
|
"bugs": {
|
|
14
|
-
"url": "https://github.com/sanity-io/
|
|
15
|
-
},
|
|
16
|
-
"repository": {
|
|
17
|
-
"type": "git",
|
|
18
|
-
"url": "git@github.com:sanity-io/sanity-plugin-dashboard-widget-netlify.git"
|
|
14
|
+
"url": "https://github.com/sanity-io/plugins/issues"
|
|
19
15
|
},
|
|
20
16
|
"license": "MIT",
|
|
21
17
|
"author": "Sanity.io <hello@sanity.io>",
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
"import": "./lib/index.mjs",
|
|
27
|
-
"require": "./lib/index.js",
|
|
28
|
-
"default": "./lib/index.js"
|
|
29
|
-
},
|
|
30
|
-
"./package.json": "./package.json"
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+ssh://git@github.com/sanity-io/plugins.git",
|
|
21
|
+
"directory": "plugins/sanity-plugin-dashboard-widget-netlify"
|
|
31
22
|
},
|
|
32
|
-
"main": "./lib/index.js",
|
|
33
|
-
"module": "./lib/index.mjs",
|
|
34
|
-
"types": "./lib/index.d.ts",
|
|
35
23
|
"files": [
|
|
36
|
-
"
|
|
37
|
-
"lib",
|
|
38
|
-
"v2-incompatible.js",
|
|
39
|
-
"sanity.json"
|
|
24
|
+
"dist"
|
|
40
25
|
],
|
|
41
|
-
"
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"link-watch": "plugin-kit link-watch",
|
|
47
|
-
"lint": "eslint .",
|
|
48
|
-
"prepare": "husky install",
|
|
49
|
-
"prepublishOnly": "npm run compile && npm run build",
|
|
50
|
-
"test:prod": "npm run lint && npm run test -- --no-cache",
|
|
51
|
-
"test:watch": "jest --coverage --watch",
|
|
52
|
-
"watch": "pkg-utils watch --strict"
|
|
53
|
-
},
|
|
54
|
-
"prettier": {
|
|
55
|
-
"bracketSpacing": false,
|
|
56
|
-
"printWidth": 100,
|
|
57
|
-
"semi": false,
|
|
58
|
-
"singleQuote": true
|
|
26
|
+
"type": "module",
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": "./dist/index.js",
|
|
30
|
+
"./package.json": "./package.json"
|
|
59
31
|
},
|
|
60
32
|
"dependencies": {
|
|
61
|
-
"@sanity/
|
|
62
|
-
"@sanity/ui": "^2.16.4",
|
|
63
|
-
"abort-controller": "^2.0.3",
|
|
64
|
-
"react-props-stream": "^1.0.1",
|
|
65
|
-
"rxjs": "^6.6.7"
|
|
33
|
+
"@sanity/ui": "^3.2.0"
|
|
66
34
|
},
|
|
67
35
|
"devDependencies": {
|
|
68
|
-
"@
|
|
69
|
-
"@
|
|
70
|
-
"@
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"@
|
|
78
|
-
"@
|
|
79
|
-
"@
|
|
80
|
-
"@types/react": "^18",
|
|
81
|
-
"@types/react-dom": "^18",
|
|
82
|
-
"@typescript-eslint/eslint-plugin": "^5.42.0",
|
|
83
|
-
"@typescript-eslint/parser": "^5.42.0",
|
|
84
|
-
"eslint": "^8.26.0",
|
|
85
|
-
"eslint-config-prettier": "^8.5.0",
|
|
86
|
-
"eslint-config-sanity": "^6.0.0",
|
|
87
|
-
"eslint-plugin-prettier": "^4.2.1",
|
|
88
|
-
"eslint-plugin-react": "^7.31.10",
|
|
89
|
-
"eslint-plugin-react-hooks": "^4.6.0",
|
|
90
|
-
"husky": "^8.0.1",
|
|
91
|
-
"jest": "^29.2.2",
|
|
92
|
-
"jest-date-mock": "^1.0.8",
|
|
93
|
-
"jest-environment-jsdom": "^29.2.2",
|
|
94
|
-
"lint-staged": "^13.0.3",
|
|
95
|
-
"prettier": "^2.7.1",
|
|
96
|
-
"prettier-plugin-packagejson": "^2.3.0",
|
|
97
|
-
"react": "^18",
|
|
98
|
-
"react-dom": "^18",
|
|
99
|
-
"rimraf": "^3.0.2",
|
|
100
|
-
"sanity": "^3.0.0",
|
|
101
|
-
"styled-components": "^6.1.19",
|
|
102
|
-
"ts-jest": "^29.0.3",
|
|
103
|
-
"typescript": "5.8.3"
|
|
36
|
+
"@sanity/pkg-utils": "^10.5.5",
|
|
37
|
+
"@types/react": "^19.2.17",
|
|
38
|
+
"@types/react-dom": "^19.2.3",
|
|
39
|
+
"babel-plugin-react-compiler": "^1.0.0",
|
|
40
|
+
"babel-plugin-styled-components": "^2.3.0",
|
|
41
|
+
"react": "^19.2.7",
|
|
42
|
+
"react-dom": "^19.2.7",
|
|
43
|
+
"sanity": "^6.0.0",
|
|
44
|
+
"styled-components": "^6.4.2",
|
|
45
|
+
"@repo/package.config": "0.0.0",
|
|
46
|
+
"@repo/tsconfig": "0.0.0",
|
|
47
|
+
"@sanity/dashboard": "6.0.1"
|
|
104
48
|
},
|
|
105
49
|
"peerDependencies": {
|
|
106
|
-
"
|
|
107
|
-
"react": "^
|
|
108
|
-
"
|
|
109
|
-
"
|
|
110
|
-
"
|
|
50
|
+
"react": "^19.2",
|
|
51
|
+
"react-dom": "^19.2",
|
|
52
|
+
"sanity": "^5 || ^6.0.0-0",
|
|
53
|
+
"styled-components": "^6.1",
|
|
54
|
+
"@sanity/dashboard": "^6.0.1"
|
|
111
55
|
},
|
|
112
56
|
"engines": {
|
|
113
|
-
"node": ">=
|
|
57
|
+
"node": ">=20.19 <22 || >=22.12"
|
|
114
58
|
},
|
|
115
|
-
"
|
|
116
|
-
"
|
|
117
|
-
},
|
|
118
|
-
"sanityPlugin": {
|
|
119
|
-
"verifyPackage": {
|
|
120
|
-
"babelConfig": false
|
|
121
|
-
}
|
|
59
|
+
"scripts": {
|
|
60
|
+
"build": "pkg build --strict --check --clean"
|
|
122
61
|
}
|
|
123
|
-
}
|
|
62
|
+
}
|
package/lib/index.d.mts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import {DashboardWidget} from '@sanity/dashboard'
|
|
2
|
-
import {LayoutConfig} from '@sanity/dashboard'
|
|
3
|
-
|
|
4
|
-
export declare type DeployAction = (site: Site) => void
|
|
5
|
-
|
|
6
|
-
export declare function netlifyWidget(config: NetlifyWidgetConfig): DashboardWidget
|
|
7
|
-
|
|
8
|
-
export declare type NetlifyWidgetConfig = WidgetOptions & {
|
|
9
|
-
layout?: LayoutConfig
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export declare interface NetlifyWidgetProps {
|
|
13
|
-
title?: string
|
|
14
|
-
description?: string
|
|
15
|
-
sites?: Site[]
|
|
16
|
-
isLoading: boolean
|
|
17
|
-
onDeploy: DeployAction
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export declare interface Site {
|
|
21
|
-
title: string
|
|
22
|
-
name?: string
|
|
23
|
-
id: string
|
|
24
|
-
url?: string
|
|
25
|
-
adminUrl?: string
|
|
26
|
-
buildHookId: string
|
|
27
|
-
branch?: string
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export declare interface SiteWidgetOption {
|
|
31
|
-
apiId: string
|
|
32
|
-
name?: string
|
|
33
|
-
title: string
|
|
34
|
-
buildHookId: string
|
|
35
|
-
url?: string
|
|
36
|
-
branch?: string
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export declare interface WidgetOptions {
|
|
40
|
-
title?: string
|
|
41
|
-
description?: string
|
|
42
|
-
sites: SiteWidgetOption[]
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export {}
|