sanity-plugin-dashboard-widget-netlify 1.1.0 → 1.3.0
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 +5 -4
- package/dist/3rdparty-typings/sanity.d.js +2 -0
- package/dist/3rdparty-typings/{sanity-parts.d.js.map → sanity.d.js.map} +1 -1
- package/dist/components/NetlifyWidget.js +56 -42
- package/dist/components/NetlifyWidget.js.map +1 -1
- package/dist/components/SiteItem/Links.js +2 -1
- package/dist/components/SiteItem/Links.js.map +1 -1
- package/dist/components/SiteItem/index.js +51 -24
- package/dist/components/SiteItem/index.js.map +1 -1
- package/dist/components/SiteList.js +41 -36
- package/dist/components/SiteList.js.map +1 -1
- package/dist/props.js +3 -2
- package/dist/props.js.map +1 -1
- package/package.json +11 -4
- package/dist/3rdparty-typings/sanity-parts.d.js +0 -2
- package/dist/components/NetlifyWidget.css +0 -41
- package/dist/components/NetlifyWidget.css.d.js +0 -23
- package/dist/components/NetlifyWidget.css.d.js.map +0 -1
- package/dist/components/SiteItem/SiteItem.css +0 -25
- package/dist/components/SiteItem/SiteItem.css.d.js +0 -17
- package/dist/components/SiteItem/SiteItem.css.d.js.map +0 -1
package/README.md
CHANGED
|
@@ -57,11 +57,12 @@ To get dashboard support in Sanity Studio in general:
|
|
|
57
57
|
`title` - Override the widget default title
|
|
58
58
|
|
|
59
59
|
`sites[]` - Your Netlify sites to show deploys for
|
|
60
|
-
- `apiId`- The Netfliy API
|
|
61
|
-
- `buildHookId` - The id of a build hook you have created for your site within the Netlify administration panel (see *Settings >
|
|
62
|
-
- `title` - Override the site name with a custom title
|
|
60
|
+
- `apiId`- The Netfliy API ID of your site (see *Site Settings > General > Site Details > Site Information -> API ID*).
|
|
61
|
+
- `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*).
|
|
63
62
|
- `name` - The Netlify site name
|
|
64
|
-
- `
|
|
63
|
+
- `title` - Override the site name with a custom title
|
|
64
|
+
- `url` - Optionally override site deployment url. By default it is inferred to be `https://netlify-site-name.netlify.app`.
|
|
65
|
+
- `branch` - Optionally pass the name of a branch to deploy
|
|
65
66
|
|
|
66
67
|
## Developing on this module
|
|
67
68
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"sanity
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"sanity.d.js"}
|
|
@@ -3,56 +3,70 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default =
|
|
6
|
+
exports.default = NetlifyWidget;
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _SiteList = _interopRequireDefault(require("./SiteList"));
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _dashboard = require("@sanity/dashboard");
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
15
|
+
|
|
16
|
+
var _ui = require("@sanity/ui");
|
|
17
|
+
|
|
18
|
+
var _templateObject;
|
|
15
19
|
|
|
16
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
21
|
|
|
18
|
-
|
|
19
|
-
render() {
|
|
20
|
-
var netlifySitesUrl = 'https://app.netlify.com/account/sites';
|
|
21
|
-
var _this$props = this.props,
|
|
22
|
-
title = _this$props.title,
|
|
23
|
-
description = _this$props.description,
|
|
24
|
-
isLoading = _this$props.isLoading,
|
|
25
|
-
sites = _this$props.sites,
|
|
26
|
-
onDeploy = _this$props.onDeploy;
|
|
27
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
28
|
-
className: _NetlifyWidget.default.container
|
|
29
|
-
}, /*#__PURE__*/_react.default.createElement("header", {
|
|
30
|
-
className: _NetlifyWidget.default.header
|
|
31
|
-
}, /*#__PURE__*/_react.default.createElement("h2", {
|
|
32
|
-
className: _NetlifyWidget.default.title
|
|
33
|
-
}, title)), /*#__PURE__*/_react.default.createElement("div", {
|
|
34
|
-
className: _NetlifyWidget.default.content
|
|
35
|
-
}, description && /*#__PURE__*/_react.default.createElement("p", {
|
|
36
|
-
className: _NetlifyWidget.default.description,
|
|
37
|
-
dangerouslySetInnerHTML: {
|
|
38
|
-
__html: description
|
|
39
|
-
}
|
|
40
|
-
}), /*#__PURE__*/_react.default.createElement(_SiteList.default, {
|
|
41
|
-
isLoading: isLoading,
|
|
42
|
-
onDeploy: onDeploy,
|
|
43
|
-
sites: sites
|
|
44
|
-
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
45
|
-
className: _NetlifyWidget.default.footer
|
|
46
|
-
}, /*#__PURE__*/_react.default.createElement(_anchor.default, {
|
|
47
|
-
disabled: isLoading,
|
|
48
|
-
href: isLoading ? undefined : netlifySitesUrl,
|
|
49
|
-
bleed: true,
|
|
50
|
-
color: "primary",
|
|
51
|
-
kind: "simple"
|
|
52
|
-
}, "Manage sites at Netlify")));
|
|
53
|
-
}
|
|
22
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
54
23
|
|
|
55
|
-
|
|
24
|
+
var ContentCard = (0, _styledComponents.default)(_ui.Card)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n min-height: 66px;\n"])));
|
|
56
25
|
|
|
57
|
-
|
|
26
|
+
function NetlifyWidget(props) {
|
|
27
|
+
var netlifySitesUrl = 'https://app.netlify.com/account/sites';
|
|
28
|
+
var title = props.title,
|
|
29
|
+
description = props.description,
|
|
30
|
+
isLoading = props.isLoading,
|
|
31
|
+
sites = props.sites,
|
|
32
|
+
onDeploy = props.onDeploy;
|
|
33
|
+
|
|
34
|
+
var footer = /*#__PURE__*/_react.default.createElement(_ui.Flex, {
|
|
35
|
+
direction: "column",
|
|
36
|
+
align: "stretch"
|
|
37
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.Button, {
|
|
38
|
+
as: "a",
|
|
39
|
+
href: isLoading ? undefined : netlifySitesUrl,
|
|
40
|
+
disabled: isLoading,
|
|
41
|
+
paddingX: 2,
|
|
42
|
+
paddingY: 4,
|
|
43
|
+
mode: "bleed",
|
|
44
|
+
tone: "primary",
|
|
45
|
+
text: "Manage sites at Netlify",
|
|
46
|
+
loading: isLoading,
|
|
47
|
+
target: "_blank"
|
|
48
|
+
}));
|
|
49
|
+
|
|
50
|
+
return /*#__PURE__*/_react.default.createElement(_dashboard.DashboardWidget, {
|
|
51
|
+
header: title,
|
|
52
|
+
footer: footer
|
|
53
|
+
}, /*#__PURE__*/_react.default.createElement(ContentCard, {
|
|
54
|
+
paddingY: 1
|
|
55
|
+
}, description && /*#__PURE__*/_react.default.createElement(_ui.Box, {
|
|
56
|
+
paddingY: 3,
|
|
57
|
+
paddingX: 3
|
|
58
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.Text, {
|
|
59
|
+
as: "p",
|
|
60
|
+
size: 1,
|
|
61
|
+
muted: true
|
|
62
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
63
|
+
dangerouslySetInnerHTML: {
|
|
64
|
+
__html: description
|
|
65
|
+
}
|
|
66
|
+
}))), /*#__PURE__*/_react.default.createElement(_SiteList.default, {
|
|
67
|
+
isLoading: isLoading,
|
|
68
|
+
onDeploy: onDeploy,
|
|
69
|
+
sites: sites
|
|
70
|
+
})));
|
|
71
|
+
}
|
|
58
72
|
//# sourceMappingURL=NetlifyWidget.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/NetlifyWidget.tsx"],"names":["
|
|
1
|
+
{"version":3,"sources":["../../src/components/NetlifyWidget.tsx"],"names":["ContentCard","Card","NetlifyWidget","props","netlifySitesUrl","title","description","isLoading","s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,CAAnB;AAAsB,IAAA,KAAK;AAA3B,kBAA4B;AAAM,IAAA,uBAAuB,EAAE;AAACM,MAAAA,MAAM,EAAEN;AAAT;AAA/B,IAA5B,CAA/B,CAFJ,eAIE,6BAAC,iBAAD;AAAU,IAAA,SAAS,EAAEC,SAArB;AAAgC,IAAA,QAAQ,EAAEE,QAA1C;AAAoD,IAAA,KAAK,EAAED;AAA3D,IAJF,CADF,CADF;AAUD","sourcesContent":["import React from 'react'\nimport {Props} from '../types'\nimport SiteList from './SiteList'\nimport {DashboardWidget} from '@sanity/dashboard'\nimport styled from 'styled-components'\nimport {Button, Flex, Card, Text, Box} from '@sanity/ui'\n\nconst ContentCard = styled(Card)`\n min-height: 66px;\n`\n\nexport default function NetlifyWidget(props: Props) {\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 />\n </Flex>\n )\n\n return (\n <DashboardWidget header={title} footer={footer}>\n <ContentCard paddingY={1}>\n {description && (\n <Box paddingY={3} paddingX={3}><Text as=\"p\" size={1} muted><span dangerouslySetInnerHTML={{__html: description}} /></Text></Box>\n )}\n <SiteList isLoading={isLoading} onDeploy={onDeploy} sites={sites} />\n </ContentCard>\n </DashboardWidget>\n )\n}\n"],"file":"NetlifyWidget.js"}
|
|
@@ -13,7 +13,8 @@ var Link = props => {
|
|
|
13
13
|
var url = props.url,
|
|
14
14
|
children = props.children;
|
|
15
15
|
return /*#__PURE__*/_react.default.createElement("span", null, /*#__PURE__*/_react.default.createElement("a", {
|
|
16
|
-
href: url
|
|
16
|
+
href: url,
|
|
17
|
+
target: "_blank"
|
|
17
18
|
}, children));
|
|
18
19
|
};
|
|
19
20
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/SiteItem/Links.tsx"],"names":["Link","props","url","children","Links","adminUrl"],"mappings":";;;;;;;AAAA;;;;AAEA,IAAMA,IAAsC,GAAIC,KAAD,IAAW;AAAA,MACjDC,GADiD,GAChCD,KADgC,CACjDC,GADiD;AAAA,MAC5CC,QAD4C,GAChCF,KADgC,CAC5CE,QAD4C;AAGxD,sBACE,wDACE;AAAG,IAAA,IAAI,EAAED;
|
|
1
|
+
{"version":3,"sources":["../../../src/components/SiteItem/Links.tsx"],"names":["Link","props","url","children","Links","adminUrl"],"mappings":";;;;;;;AAAA;;;;AAEA,IAAMA,IAAsC,GAAIC,KAAD,IAAW;AAAA,MACjDC,GADiD,GAChCD,KADgC,CACjDC,GADiD;AAAA,MAC5CC,QAD4C,GAChCF,KADgC,CAC5CE,QAD4C;AAGxD,sBACE,wDACE;AAAG,IAAA,IAAI,EAAED,GAAT;AAAc,IAAA,MAAM,EAAC;AAArB,KAA+BC,QAA/B,CADF,CADF;AAKD,CARD;;AAeA,IAAMC,KAA+B,GAAIH,KAAD,IAAW;AAAA,MAC1CC,GAD0C,GACzBD,KADyB,CAC1CC,GAD0C;AAAA,MACrCG,QADqC,GACzBJ,KADyB,CACrCI,QADqC;;AAGjD,MAAIH,GAAG,IAAIG,QAAX,EAAqB;AACnB,wBACE,6DACG,6BAAC,IAAD;AAAM,MAAA,GAAG,EAAEH;AAAX,cADH,qBACgC,6BAAC,IAAD;AAAM,MAAA,GAAG,EAAEG;AAAX,eADhC,MADF;AAKD;;AAED,MAAIH,GAAJ,EAAS;AACP,wBAAO,6BAAC,IAAD;AAAM,MAAA,GAAG,EAAEA;AAAX,gBAAP;AACD;;AACD,MAAIG,QAAJ,EAAc;AACZ,wBAAO,6BAAC,IAAD;AAAM,MAAA,GAAG,EAAEA;AAAX,iBAAP;AACD;;AACD,SAAO,IAAP;AACD,CAlBD;;eAoBeD,K","sourcesContent":["import React, {FunctionComponent} from 'react'\n\nconst Link: FunctionComponent<{url: string}> = (props) => {\n const {url, children} = props\n\n return (\n <span>\n <a href={url} target=\"_blank\">{children}</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"],"file":"Links.js"}
|
|
@@ -7,9 +7,7 @@ exports.default = exports.IMAGE_PULL_INTERVAL = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
var _SiteItem = _interopRequireDefault(require("./SiteItem.css"));
|
|
10
|
+
var _ui = require("@sanity/ui");
|
|
13
11
|
|
|
14
12
|
var _Links = _interopRequireDefault(require("./Links"));
|
|
15
13
|
|
|
@@ -34,19 +32,20 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
34
32
|
var IMAGE_PULL_INTERVAL = 10000;
|
|
35
33
|
exports.IMAGE_PULL_INTERVAL = IMAGE_PULL_INTERVAL;
|
|
36
34
|
|
|
37
|
-
var getImageUrl = siteId => {
|
|
35
|
+
var getImageUrl = (siteId, branchName) => {
|
|
38
36
|
var baseUrl = "https://api.netlify.com/api/v1/badges/".concat(siteId, "/deploy-status");
|
|
39
37
|
var time = new Date().getTime();
|
|
40
|
-
|
|
38
|
+
var branch = "branch=".concat(branchName);
|
|
39
|
+
return branchName ? "".concat(baseUrl, "?").concat(time, "&").concat(branch) : "".concat(baseUrl, "?").concat(time);
|
|
41
40
|
};
|
|
42
41
|
|
|
43
|
-
var useBadgeImage = siteId => {
|
|
44
|
-
var _useState = (0, _react.useState)(() => getImageUrl(siteId)),
|
|
42
|
+
var useBadgeImage = (siteId, branchName) => {
|
|
43
|
+
var _useState = (0, _react.useState)(() => getImageUrl(siteId, branchName)),
|
|
45
44
|
_useState2 = _slicedToArray(_useState, 2),
|
|
46
45
|
src = _useState2[0],
|
|
47
46
|
setSrc = _useState2[1];
|
|
48
47
|
|
|
49
|
-
var update = (0, _react.useCallback)(() => setSrc(getImageUrl(siteId)), [siteId]);
|
|
48
|
+
var update = (0, _react.useCallback)(() => setSrc(getImageUrl(siteId, branchName)), [siteId]);
|
|
50
49
|
(0, _react.useEffect)(() => {
|
|
51
50
|
var interval = window.setInterval(update, IMAGE_PULL_INTERVAL);
|
|
52
51
|
return () => window.clearInterval(interval);
|
|
@@ -64,38 +63,66 @@ var useDeploy = (site, onDeploy, updateBadge) => {
|
|
|
64
63
|
};
|
|
65
64
|
|
|
66
65
|
var SiteItem = props => {
|
|
66
|
+
var _useState3 = (0, _react.useState)(false),
|
|
67
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
68
|
+
hasBadgeError = _useState4[0],
|
|
69
|
+
setHasBadgeError = _useState4[1];
|
|
70
|
+
|
|
67
71
|
var site = props.site,
|
|
68
72
|
onDeploy = props.onDeploy;
|
|
69
73
|
var id = site.id,
|
|
74
|
+
name = site.name,
|
|
70
75
|
title = site.title,
|
|
71
76
|
url = site.url,
|
|
72
77
|
adminUrl = site.adminUrl,
|
|
73
|
-
buildHookId = site.buildHookId
|
|
78
|
+
buildHookId = site.buildHookId,
|
|
79
|
+
branch = site.branch;
|
|
74
80
|
|
|
75
|
-
var _useBadgeImage = useBadgeImage(id),
|
|
81
|
+
var _useBadgeImage = useBadgeImage(id, branch),
|
|
76
82
|
_useBadgeImage2 = _slicedToArray(_useBadgeImage, 2),
|
|
77
83
|
badge = _useBadgeImage2[0],
|
|
78
84
|
updateBadge = _useBadgeImage2[1];
|
|
79
85
|
|
|
80
86
|
var handleDeploy = useDeploy(site, onDeploy, updateBadge);
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
87
|
+
|
|
88
|
+
var handleBadgeError = () => {
|
|
89
|
+
setHasBadgeError(true);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
return /*#__PURE__*/_react.default.createElement(_ui.Flex, {
|
|
93
|
+
as: "li"
|
|
94
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.Box, {
|
|
95
|
+
flex: 1,
|
|
96
|
+
paddingY: 2,
|
|
97
|
+
paddingX: 3
|
|
98
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.Stack, {
|
|
99
|
+
space: 2
|
|
100
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.Text, {
|
|
101
|
+
as: "h4"
|
|
102
|
+
}, title || name, /*#__PURE__*/_react.default.createElement(_Links.default, {
|
|
88
103
|
url: url,
|
|
89
104
|
adminUrl: adminUrl
|
|
90
|
-
})), /*#__PURE__*/_react.default.createElement(
|
|
105
|
+
})), /*#__PURE__*/_react.default.createElement(_ui.Flex, {
|
|
106
|
+
justify: "flex-start"
|
|
107
|
+
}, !hasBadgeError && /*#__PURE__*/_react.default.createElement("img", {
|
|
91
108
|
src: badge,
|
|
109
|
+
onError: handleBadgeError,
|
|
92
110
|
alt: "Badge"
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
111
|
+
}), hasBadgeError && /*#__PURE__*/_react.default.createElement(_ui.Card, {
|
|
112
|
+
tone: "critical",
|
|
113
|
+
radius: 2,
|
|
114
|
+
padding: 2
|
|
115
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.Label, {
|
|
116
|
+
size: 0,
|
|
117
|
+
muted: true
|
|
118
|
+
}, "Failed to load badge"))))), buildHookId ? /*#__PURE__*/_react.default.createElement(_ui.Box, {
|
|
119
|
+
paddingY: 2,
|
|
120
|
+
paddingX: 3
|
|
121
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.Button, {
|
|
122
|
+
mode: "ghost",
|
|
123
|
+
onClick: handleDeploy,
|
|
124
|
+
text: "Deploy"
|
|
125
|
+
})) : null);
|
|
99
126
|
};
|
|
100
127
|
|
|
101
128
|
var _default = SiteItem;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/SiteItem/index.tsx"],"names":["IMAGE_PULL_INTERVAL","getImageUrl","siteId","baseUrl","time","Date","getTime","useBadgeImage","src","setSrc","update","interval","window","setInterval","clearInterval","useDeploy","site","onDeploy","updateBadge","timeoutRef","clearTimeout","current","setTimeout","SiteItem","props","
|
|
1
|
+
{"version":3,"sources":["../../../src/components/SiteItem/index.tsx"],"names":["IMAGE_PULL_INTERVAL","getImageUrl","siteId","branchName","baseUrl","time","Date","getTime","branch","useBadgeImage","src","setSrc","update","interval","window","setInterval","clearInterval","useDeploy","site","onDeploy","updateBadge","timeoutRef","clearTimeout","current","setTimeout","SiteItem","props","hasBadgeError","setHasBadgeError","id","name","title","url","adminUrl","buildHookId","badge","handleDeploy","handleBadgeError"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;;;;;;;;;;;;;;;;;;;AAOO,IAAMA,mBAAmB,GAAG,KAA5B;;;AAEP,IAAMC,WAAW,GAAG,CAACC,MAAD,EAAiBC,UAAjB,KAAyC;AAC3D,MAAMC,OAAO,mDAA4CF,MAA5C,mBAAb;AACA,MAAMG,IAAI,GAAG,IAAIC,IAAJ,GAAWC,OAAX,EAAb;AACA,MAAMC,MAAM,oBAAaL,UAAb,CAAZ;AAEA,SAAOA,UAAU,aAAMC,OAAN,cAAiBC,IAAjB,cAAyBG,MAAzB,cAAuCJ,OAAvC,cAAkDC,IAAlD,CAAjB;AACD,CAND;;AAQA,IAAMI,aAAa,GAAG,CAACP,MAAD,EAAiBC,UAAjB,KAA0C;AAAA,kBACxC,qBAAS,MAAMF,WAAW,CAACC,MAAD,EAASC,UAAT,CAA1B,CADwC;AAAA;AAA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AA,IAAI,EAAE,CAAb;AAAgB,IAAA,KAAK;AAArB,4BAA7C,CAFpB,CANF,CADF,CADF,EAeGO,WAAW,gBACV,6BAAC,OAAD;AAAK,IAAA,QAAQ,EAAE,CAAf;AAAkB,IAAA,QAAQ,EAAE;AAA5B,kBACE,6BAAC,UAAD;AAAQ,IAAA,IAAI,EAAC,OAAb;AAAqB,IAAA,OAAO,EAAEE,YAA9B;AAA4C,IAAA,IAAI,EAAC;AAAjD,IADF,CADU,GAIR,IAnBN,CADF;AAuBD,CAlCD;;eAoCeX,Q","sourcesContent":["import React, {FunctionComponent, useCallback, useEffect, useRef, useState} from 'react'\nimport {Button, Flex, Box, Card, Text, Stack, Label} from '@sanity/ui'\nimport {DeployAction, Site} from '../../types'\nimport Links from './Links'\n\ninterface Props {\n site: Site\n onDeploy: DeployAction\n}\n\nexport const 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])\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 space={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 && <Card tone=\"critical\" radius={2} padding={2}><Label size={0} muted>Failed to load badge</Label></Card>}\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"],"file":"index.js"}
|
|
@@ -3,50 +3,55 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default =
|
|
7
|
-
|
|
8
|
-
var _spinner = _interopRequireDefault(require("part:@sanity/components/loading/spinner"));
|
|
6
|
+
exports.default = SiteList;
|
|
9
7
|
|
|
10
8
|
var _react = _interopRequireDefault(require("react"));
|
|
11
9
|
|
|
12
|
-
var _NetlifyWidget = _interopRequireDefault(require("./NetlifyWidget.css"));
|
|
13
|
-
|
|
14
10
|
var _SiteItem = _interopRequireDefault(require("./SiteItem"));
|
|
15
11
|
|
|
12
|
+
var _ui = require("@sanity/ui");
|
|
13
|
+
|
|
16
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return /*#__PURE__*/_react.default.createElement("ul", {
|
|
39
|
-
className: _NetlifyWidget.default.sites
|
|
40
|
-
}, sites.map((site, index) => {
|
|
41
|
-
return /*#__PURE__*/_react.default.createElement(_SiteItem.default, {
|
|
42
|
-
onDeploy: onDeploy,
|
|
43
|
-
site: site,
|
|
44
|
-
key: "site-".concat(index)
|
|
45
|
-
});
|
|
46
|
-
}));
|
|
16
|
+
function SiteList(props) {
|
|
17
|
+
var isLoading = props.isLoading,
|
|
18
|
+
onDeploy = props.onDeploy,
|
|
19
|
+
sites = props.sites;
|
|
20
|
+
|
|
21
|
+
if (isLoading) {
|
|
22
|
+
return /*#__PURE__*/_react.default.createElement(_ui.Card, {
|
|
23
|
+
padding: 4
|
|
24
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.Flex, {
|
|
25
|
+
direction: "column",
|
|
26
|
+
justify: "center",
|
|
27
|
+
align: "center"
|
|
28
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.Spinner, {
|
|
29
|
+
muted: true
|
|
30
|
+
}), /*#__PURE__*/_react.default.createElement(_ui.Box, {
|
|
31
|
+
marginTop: 3
|
|
32
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.Text, {
|
|
33
|
+
muted: true
|
|
34
|
+
}, "Loading sites\u2026"))));
|
|
47
35
|
}
|
|
48
36
|
|
|
49
|
-
|
|
37
|
+
if (!sites || sites && sites.length === 0) {
|
|
38
|
+
return /*#__PURE__*/_react.default.createElement(_ui.Card, {
|
|
39
|
+
tone: "critical",
|
|
40
|
+
padding: 3
|
|
41
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.Text, null, "No sites are defined in the widget options. Please check your config."));
|
|
42
|
+
}
|
|
50
43
|
|
|
51
|
-
|
|
44
|
+
return /*#__PURE__*/_react.default.createElement(_ui.Box, {
|
|
45
|
+
paddingY: 2
|
|
46
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.Stack, {
|
|
47
|
+
as: "ul",
|
|
48
|
+
space: 2
|
|
49
|
+
}, sites.map((site, index) => {
|
|
50
|
+
return /*#__PURE__*/_react.default.createElement(_SiteItem.default, {
|
|
51
|
+
onDeploy: onDeploy,
|
|
52
|
+
site: site,
|
|
53
|
+
key: "site-".concat(index)
|
|
54
|
+
});
|
|
55
|
+
})));
|
|
56
|
+
}
|
|
52
57
|
//# sourceMappingURL=SiteList.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/SiteList.tsx"],"names":["SiteList","
|
|
1
|
+
{"version":3,"sources":["../../src/components/SiteList.tsx"],"names":["SiteList","props","isLoading","onDeploy","sites","length","map","site","index"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;;;AAQe,SAASA,QAAT,CAAkBC,KAAlB,EAAgC;AAAA,MACtCC,SADsC,GACRD,KADQ,CACtCC,SADsC;AAAA,MAC3BC,QAD2B,GACRF,KADQ,CAC3BE,QAD2B;AAAA,MACjBC,KADiB,GACRH,KADQ,CACjBG,KADiB;;AAE7C,MAAIF,SAAJ,EAAe;AACb,wBACE,6BAAC,QAAD;AAAM,MAAA,OAAO,EAAE;AAAf,oBACE,6BAAC,QAAD;AAAM,MAAA,SAAS,EAAC,QAAhB;AAAyB,MAAA,OAAO,EAAC,QAAjC;AAA0C,MAAA,KAAK,EAAC;AAAhD,oBACE,6BAAC,WAAD;AAAS,MAAA,KAAK;AAAd,MADF,eAEE,6BAAC,OAAD;AAAK,MAAA,SAAS,EAAE;AAAhB,oBACE,6BAAC,QAAD;AAAM,MAAA,KAAK;AAAX,6BADF,CAFF,CADF,CADF;AAUD;;AACD,MAAI,CAACE,KAAD,IAAWA,KAAK,IAAIA,KAAK,CAACC,MAAN,KAAiB,CAAzC,EAA6C;AAC3C,wBACE,6BAAC,QAAD;AAAM,MAAA,IAAI,EAAC,UAAX;AAAsB,MAAA,OAAO,EAAE;AAA/B,oBACE,6BAAC,QAAD,gFADF,CADF;AAKD;;AACD,sBACE,6BAAC,OAAD;AAAK,IAAA,QAAQ,EAAE;AAAf,kBACE,6BAAC,SAAD;AAAO,IAAA,EAAE,EAAC,IAAV;AAAe,IAAA,KAAK,EAAE;AAAtB,KACGD,KAAK,CAACE,GAAN,CAAU,CAACC,IAAD,EAAOC,KAAP,KAAiB;AAC1B,wBAAO,6BAAC,iBAAD;AAAU,MAAA,QAAQ,EAAEL,QAApB;AAA8B,MAAA,IAAI,EAAEI,IAApC;AAA0C,MAAA,GAAG,iBAAUC,KAAV;AAA7C,MAAP;AACD,GAFA,CADH,CADF,CADF;AASD","sourcesContent":["import React from 'react'\nimport {DeployAction, Site} from '../types'\nimport SiteItem from './SiteItem'\nimport {Flex, Box, Card, Text, Spinner, Stack} from '@sanity/ui'\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\" space={2}>\n {sites.map((site, index) => {\n return <SiteItem onDeploy={onDeploy} site={site} key={`site-${index}`} />\n })}\n </Stack>\n </Box>\n )\n}\n"],"file":"SiteList.js"}
|
package/dist/props.js
CHANGED
|
@@ -48,8 +48,9 @@ var props$ = options => {
|
|
|
48
48
|
name: site.name,
|
|
49
49
|
title: site.title,
|
|
50
50
|
buildHookId: site.buildHookId,
|
|
51
|
-
url: site.url || site.name && "https://".concat(site.name, ".netlify.app/"),
|
|
52
|
-
adminUrl: site.name && "https://app.netlify.com/sites/".concat(site.name)
|
|
51
|
+
url: site.url || site.branch && "https://".concat(site.branch, "--").concat(site.name, ".netlify.app/") || site.name && "https://".concat(site.name, ".netlify.app/"),
|
|
52
|
+
adminUrl: site.name && "https://app.netlify.com/sites/".concat(site.name),
|
|
53
|
+
branch: site.branch
|
|
53
54
|
}));
|
|
54
55
|
|
|
55
56
|
var _createEventHandler = (0, _reactPropsStream.createEventHandler)(),
|
package/dist/props.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/props.ts"],"names":["noop","undefined","INITIAL_PROPS","title","sites","isLoading","onDeploy","props$","options","configuredSites","map","site","id","apiId","name","buildHookId","url","adminUrl","onDeploy$","setSitesAction$","pipe","type","deployAction$","deployResult$","deployCompletedAction$","result","error","stateReducer$","subscribe","description"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;;;;;;;;;;;;;;;;;;;AAEA,IAAMA,IAAI,GAAG,MAAMC,SAAnB;;AAEA,IAAMC,aAAa,GAAG;AACpBC,EAAAA,KAAK,EAAE,eADa;AAEpBC,EAAAA,KAAK,EAAE,EAFa;AAGpBC,EAAAA,SAAS,EAAE,IAHS;AAIpBC,EAAAA,QAAQ,EAAEN;AAJU,CAAtB,C,CAOA;;AACO,IAAMO,MAAM,GAAIC,OAAD,IAA4B;AAChD,MAAMC,eAAe,GAAG,CAACD,OAAO,CAACJ,KAAR,IAAiB,EAAlB,EAAsBM,GAAtB,CAA2BC,IAAD,KAAW;AAC3DC,IAAAA,EAAE,EAAED,IAAI,CAACE,KADkD;AAE3DC,IAAAA,IAAI,EAAEH,IAAI,CAACG,IAFgD;AAG3DX,IAAAA,KAAK,EAAEQ,IAAI,CAACR,KAH+C;AAI3DY,IAAAA,WAAW,EAAEJ,IAAI,CAACI,WAJyC;AAK3DC,IAAAA,GAAG,EAAEL,IAAI,CAACK,GAAL,IAAaL,IAAI,CAACG,IAAL,sBAAwBH,IAAI,CAACG,IAA7B,
|
|
1
|
+
{"version":3,"sources":["../src/props.ts"],"names":["noop","undefined","INITIAL_PROPS","title","sites","isLoading","onDeploy","props$","options","configuredSites","map","site","id","apiId","name","buildHookId","url","branch","adminUrl","onDeploy$","setSitesAction$","pipe","type","deployAction$","deployResult$","deployCompletedAction$","result","error","stateReducer$","subscribe","description"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;;;;;;;;;;;;;;;;;;;AAEA,IAAMA,IAAI,GAAG,MAAMC,SAAnB;;AAEA,IAAMC,aAAa,GAAG;AACpBC,EAAAA,KAAK,EAAE,eADa;AAEpBC,EAAAA,KAAK,EAAE,EAFa;AAGpBC,EAAAA,SAAS,EAAE,IAHS;AAIpBC,EAAAA,QAAQ,EAAEN;AAJU,CAAtB,C,CAOA;;AACO,IAAMO,MAAM,GAAIC,OAAD,IAA4B;AAChD,MAAMC,eAAe,GAAG,CAACD,OAAO,CAACJ,KAAR,IAAiB,EAAlB,EAAsBM,GAAtB,CAA2BC,IAAD,KAAW;AAC3DC,IAAAA,EAAE,EAAED,IAAI,CAACE,KADkD;AAE3DC,IAAAA,IAAI,EAAEH,IAAI,CAACG,IAFgD;AAG3DX,IAAAA,KAAK,EAAEQ,IAAI,CAACR,KAH+C;AAI3DY,IAAAA,WAAW,EAAEJ,IAAI,CAACI,WAJyC;AAK3DC,IAAAA,GAAG,EAAEL,IAAI,CAACK,GAAL,IAAaL,IAAI,CAACM,MAAL,sBAA0BN,IAAI,CAACM,MAA/B,eAA0CN,IAAI,CAACG,IAA/C,kBAAb,IAAqFH,IAAI,CAACG,IAAL,sBAAwBH,IAAI,CAACG,IAA7B,kBAL/B;AAM3DI,IAAAA,QAAQ,EAAEP,IAAI,CAACG,IAAL,4CAA8CH,IAAI,CAACG,IAAnD,CANiD;AAO3DG,IAAAA,MAAM,EAAEN,IAAI,CAACM;AAP8C,GAAX,CAA1B,CAAxB;;AADgD,4BAWlB,2CAXkB;AAAA;AAAA,MAWzCE,SAXyC;AAAA,MAW9Bb,QAX8B;;AAYhD,MAAMc,eAAe,GAAG,cAAGX,eAAH,EAAoBY,IAApB,CAAyB,oBAAKjB,KAAD,KAAY;AAACkB,IAAAA,IAAI,EAAE,UAAP;AAAmBlB,IAAAA;AAAnB,GAAZ,CAAJ,CAAzB,CAAxB;AACA,MAAMmB,aAAa,GAAGJ,SAAS,CAACE,IAAV,CAAe,oBAAKV,IAAD,KAAW;AAACW,IAAAA,IAAI,EAAE,gBAAP;AAAyBX,IAAAA;AAAzB,GAAX,CAAJ,CAAf,CAAtB;AACA,MAAMa,aAAa,GAAGL,SAAS,CAACE,IAAV,CAAe,0BAAWV,IAAD,IAAU,oBAAOA,IAAP,CAApB,CAAf,CAAtB;AACA,MAAMc,sBAAsB,GAAGD,aAAa,CAACH,IAAd,CAC7B,oBACGK,MAAD;AAAcJ,IAAAA,IAAI,EAAE;AAApB,KAA2CI,MAA3C,CADF,EAEE,2BAAYC,KAAD,IAAW,cAAG;AAACL,IAAAA,IAAI,EAAE,eAAP;AAAwBK,IAAAA;AAAxB,GAAH,CAAtB,CAFF,CAD6B,CAA/B;AAOA,mBAAMP,eAAN,EAAuBG,aAAvB,EAAsCE,sBAAtC,EAA8DJ,IAA9D,CAAmEO,uBAAnE,EAAkFC,SAAlF;AAEA,SAAO,cAAGpB,eAAH,EAAoBY,IAApB,CACL,oBAAKjB,KAAD,KAAY;AACdA,IAAAA,KADc;AAEdD,IAAAA,KAAK,EAAEK,OAAO,CAACL,KAAR,IAAiBD,aAAa,CAACC,KAFxB;AAGd2B,IAAAA,WAAW,EAAEtB,OAAO,CAACsB,WAHP;AAIdzB,IAAAA,SAAS,EAAE,KAJG;AAKdC,IAAAA;AALc,GAAZ,CAAJ,CADK,EAQL,0BAAUJ,aAAV,CARK,CAAP;AAUD,CAlCM","sourcesContent":["import {merge, of} from 'rxjs'\nimport {createEventHandler} from 'react-props-stream'\nimport {catchError, map, startWith, switchMap} from 'rxjs/operators'\nimport {deploy} from './datastores/deploy'\nimport {Site, WidgetOptions} from './types'\nimport {stateReducer$} from './reducers'\n\nconst noop = () => undefined\n\nconst INITIAL_PROPS = {\n title: 'Netlify sites',\n sites: [],\n isLoading: true,\n onDeploy: noop,\n}\n\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\nexport const props$ = (options: WidgetOptions) => {\n const configuredSites = (options.sites || []).map((site) => ({\n id: site.apiId,\n name: site.name,\n title: site.title,\n buildHookId: site.buildHookId,\n url: site.url || (site.branch && `https://${site.branch}--${site.name}.netlify.app/`) || (site.name && `https://${site.name}.netlify.app/`),\n adminUrl: site.name && `https://app.netlify.com/sites/${site.name}`,\n branch: site.branch\n }))\n\n const [onDeploy$, onDeploy] = createEventHandler<Site>()\n const setSitesAction$ = of(configuredSites).pipe(map((sites) => ({type: 'setSites', sites})))\n const deployAction$ = onDeploy$.pipe(map((site) => ({type: 'deploy/started', site})))\n const deployResult$ = onDeploy$.pipe(switchMap((site) => deploy(site)))\n const deployCompletedAction$ = deployResult$.pipe(\n map(\n (result) => ({type: 'deploy/completed', ...result}),\n catchError((error) => of({type: 'deploy/failed', error}))\n )\n )\n\n merge(setSitesAction$, deployAction$, deployCompletedAction$).pipe(stateReducer$).subscribe()\n\n return of(configuredSites).pipe(\n map((sites) => ({\n sites,\n title: options.title || INITIAL_PROPS.title,\n description: options.description,\n isLoading: false,\n onDeploy,\n })),\n startWith(INITIAL_PROPS)\n )\n}\n"],"file":"props.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sanity-plugin-dashboard-widget-netlify",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Sanity Studio Dashboard Widget for triggering Netlify builds",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"lint": "eslint .",
|
|
35
35
|
"prebuild": "rimraf dist",
|
|
36
36
|
"build": "sanipack build",
|
|
37
|
-
"watch": "sanipack watch",
|
|
37
|
+
"watch": "sanipack build --watch",
|
|
38
38
|
"test": "jest --coverage",
|
|
39
39
|
"test:watch": "jest --coverage --watch",
|
|
40
40
|
"test:prod": "npm run lint && npm run test -- --no-cache",
|
|
@@ -52,16 +52,22 @@
|
|
|
52
52
|
"rxjs": "^6.0.0"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@sanity/base": ">=2.
|
|
56
|
-
"
|
|
55
|
+
"@sanity/base": ">=2.13.0",
|
|
56
|
+
"@sanity/dashboard": ">=2.13.0",
|
|
57
|
+
"@sanity/ui": "^0.36.12",
|
|
58
|
+
"react": "^16.9 || ^17",
|
|
59
|
+
"styled-components": "^5.2.0"
|
|
57
60
|
},
|
|
58
61
|
"devDependencies": {
|
|
62
|
+
"@sanity/dashboard": ">=2.13.0",
|
|
63
|
+
"@sanity/ui": "^0.36.12",
|
|
59
64
|
"@testing-library/jest-dom": "^5.11.4",
|
|
60
65
|
"@testing-library/react": "^11.0.4",
|
|
61
66
|
"@types/jest": "^26.0.20",
|
|
62
67
|
"@types/node": "^10.11.0",
|
|
63
68
|
"@types/react": "^17.0.0",
|
|
64
69
|
"@types/react-dom": "^17.0.0",
|
|
70
|
+
"@types/styled-components": "^5.1.14",
|
|
65
71
|
"@typescript-eslint/eslint-plugin": "^4.18.0",
|
|
66
72
|
"@typescript-eslint/parser": "^4.18.0",
|
|
67
73
|
"eslint": "^7.22.0",
|
|
@@ -75,6 +81,7 @@
|
|
|
75
81
|
"react-dom": "^17.0.0",
|
|
76
82
|
"rimraf": "^2.6.2",
|
|
77
83
|
"sanipack": "^1.0.8",
|
|
84
|
+
"styled-components": "^5.2.0",
|
|
78
85
|
"ts-jest": "^26.0.0",
|
|
79
86
|
"tsconfig-paths-jest": "0.0.1",
|
|
80
87
|
"typescript": "^4.0.3"
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
@import 'part:@sanity/base/theme/variables-style';
|
|
2
|
-
|
|
3
|
-
.container {
|
|
4
|
-
composes: container from 'part:@sanity/dashboard/widget-styles';
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
.description {
|
|
8
|
-
padding: var(--small-padding) var(--medium-padding) var(--medium-padding);
|
|
9
|
-
margin: 0;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.header {
|
|
13
|
-
composes: header from 'part:@sanity/dashboard/widget-styles';
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.title {
|
|
17
|
-
composes: title from 'part:@sanity/dashboard/widget-styles';
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.error {
|
|
21
|
-
color: var(--state-danger-color);
|
|
22
|
-
padding: var(--medium-padding);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.content {
|
|
26
|
-
position: relative;
|
|
27
|
-
padding: var(--small-padding) 0;
|
|
28
|
-
border-top: 1px solid var(--hairline-color);
|
|
29
|
-
min-height: 66px;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
.sites {
|
|
33
|
-
list-style: none;
|
|
34
|
-
margin: 0;
|
|
35
|
-
padding: 0;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.footer {
|
|
39
|
-
composes: footer from 'part:@sanity/dashboard/widget-styles';
|
|
40
|
-
border-top: 1px solid var(--hairline-color);
|
|
41
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.footer = exports.sites = exports.content = exports.error = exports.title = exports.header = exports.description = exports.container = void 0;
|
|
7
|
-
var container;
|
|
8
|
-
exports.container = container;
|
|
9
|
-
var description;
|
|
10
|
-
exports.description = description;
|
|
11
|
-
var header;
|
|
12
|
-
exports.header = header;
|
|
13
|
-
var title;
|
|
14
|
-
exports.title = title;
|
|
15
|
-
var error;
|
|
16
|
-
exports.error = error;
|
|
17
|
-
var content;
|
|
18
|
-
exports.content = content;
|
|
19
|
-
var sites;
|
|
20
|
-
exports.sites = sites;
|
|
21
|
-
var footer;
|
|
22
|
-
exports.footer = footer;
|
|
23
|
-
//# sourceMappingURL=NetlifyWidget.css.d.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/NetlifyWidget.css.d.ts"],"names":["container","description","header","title","error","content","sites","footer"],"mappings":";;;;;;AAAO,IAAMA,SAAN;;AACA,IAAMC,WAAN;;AACA,IAAMC,MAAN;;AACA,IAAMC,KAAN;;AACA,IAAMC,KAAN;;AACA,IAAMC,OAAN;;AACA,IAAMC,KAAN;;AACA,IAAMC,MAAN","sourcesContent":["export const container: string\nexport const description: string\nexport const header: string\nexport const title: string\nexport const error: string\nexport const content: string\nexport const sites: string\nexport const footer: string\ninterface Namespace {\n\t\"container\": string,\n\t\"description\": string,\n\t\"header\": string,\n\t\"title\": string,\n\t\"error\": string,\n\t\"content\": string,\n\t\"sites\": string,\n\t\"footer\": string,\n}\ndeclare const netlifyWidget: Namespace\nexport default netlifyWidget\n"],"file":"NetlifyWidget.css.d.js"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
@import 'part:@sanity/base/theme/variables-style';
|
|
2
|
-
|
|
3
|
-
.root {
|
|
4
|
-
display: flex;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
.status {
|
|
8
|
-
flex: 1;
|
|
9
|
-
padding: var(--small-padding) var(--medium-padding) var(--small-padding) var(--medium-padding);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.error {
|
|
13
|
-
color: var(--state-danger-color);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.title {
|
|
17
|
-
font-weight: 400;
|
|
18
|
-
line-height: 1.3em;
|
|
19
|
-
margin: 0 0 calc(var(--small-padding) / 2);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.actions {
|
|
23
|
-
padding: var(--small-padding) var(--medium-padding);
|
|
24
|
-
display: flex;
|
|
25
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.actions = exports.title = exports.error = exports.status = exports.root = void 0;
|
|
7
|
-
var root;
|
|
8
|
-
exports.root = root;
|
|
9
|
-
var status;
|
|
10
|
-
exports.status = status;
|
|
11
|
-
var error;
|
|
12
|
-
exports.error = error;
|
|
13
|
-
var title;
|
|
14
|
-
exports.title = title;
|
|
15
|
-
var actions;
|
|
16
|
-
exports.actions = actions;
|
|
17
|
-
//# sourceMappingURL=SiteItem.css.d.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/SiteItem/SiteItem.css.d.ts"],"names":["root","status","error","title","actions"],"mappings":";;;;;;AAAO,IAAMA,IAAN;;AACA,IAAMC,MAAN;;AACA,IAAMC,KAAN;;AACA,IAAMC,KAAN;;AACA,IAAMC,OAAN","sourcesContent":["export const root: string\nexport const status: string\nexport const error: string\nexport const title: string\nexport const actions: string\ninterface Namespace {\n\t\"root\": string,\n\t\"status\": string,\n\t\"error\": string,\n\t\"title\": string,\n\t\"actions\": string,\n}\ndeclare const siteItem: Namespace\nexport default siteItem\n"],"file":"SiteItem.css.d.js"}
|