sanity-plugin-dashboard-widget-vercel 0.1.5 → 1.1.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/CHANGELOG.md +33 -0
- package/README.md +38 -37
- package/lib/app.js +168 -0
- package/lib/client.js +17 -0
- package/lib/components/DeployButton/index.js +73 -27
- package/lib/components/Deployment/index.js +61 -66
- package/lib/components/DeploymentPlaceholder/index.js +25 -25
- package/lib/components/DeploymentTarget/index.js +61 -0
- package/lib/components/DeploymentTargets/index.js +31 -0
- package/lib/components/Deployments/index.js +117 -60
- package/lib/components/DialogForm/index.js +363 -0
- package/lib/components/FormFieldInputLabel/index.js +65 -0
- package/lib/components/FormFieldInputText/index.js +43 -0
- package/lib/components/PlaceholderAvatar/index.js +28 -0
- package/lib/components/PlaceholderText/index.js +35 -0
- package/lib/components/StateDebug/index.js +27 -10
- package/lib/components/StatusDot/index.js +11 -19
- package/lib/components/TableCell/index.js +79 -0
- package/lib/constants.js +25 -4
- package/lib/hooks/useDeployments.js +19 -10
- package/lib/index.js +2 -2
- package/lib/machines/deploy.js +27 -29
- package/lib/machines/deploymentTargetList.js +143 -0
- package/lib/machines/dialog.js +54 -0
- package/lib/machines/form.js +112 -0
- package/lib/machines/refresh.js +1 -2
- package/lib/types/index.js +1 -25
- package/lib/utils/fetcher.js +68 -31
- package/lib/utils/sanitizeFormData.js +34 -0
- package/package.json +40 -38
- package/lib/components/ConfigurationError/index.js +0 -27
- package/lib/components/TD/index.js +0 -38
- package/lib/components/TH/index.js +0 -39
- package/lib/components/Widget/index.css +0 -17
- package/lib/components/Widget/index.js +0 -67
- package/lib/machines/main.js +0 -99
- package/lib/styled/theme.js +0 -121
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,39 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [1.1.1](https://github.com/robinpyon/sanity-plugin-dashboard-widget-vercel/compare/v1.1.0...v1.1.1) (2022-01-03)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* correctly namespace deployment target _ids ([cd97cd3](https://github.com/robinpyon/sanity-plugin-dashboard-widget-vercel/commit/cd97cd39bd35260efe728c796d8cbadf4d788aa6))
|
|
11
|
+
|
|
12
|
+
## [1.1.0](https://github.com/robinpyon/sanity-plugin-dashboard-widget-vercel/compare/v1.0.0...v1.1.0) (2021-03-25)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* use API-versioned client if available ([44ca27f](https://github.com/robinpyon/sanity-plugin-dashboard-widget-vercel/commit/44ca27fbd0649be8c050aad8b7eecf67324ee65d))
|
|
18
|
+
|
|
19
|
+
## [1.0.0](https://github.com/robinpyon/sanity-plugin-dashboard-widget-vercel/compare/v0.1.5...v1.0.0) (2021-03-24)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### ⚠ BREAKING CHANGES
|
|
23
|
+
|
|
24
|
+
* Deployment targets are now configured within sanity - please remove any vercel
|
|
25
|
+
related configuration you may have stored inside your dashboard config file. Support for forcing
|
|
26
|
+
small layout has also been (temporarily) dropped.
|
|
27
|
+
|
|
28
|
+
### Features
|
|
29
|
+
|
|
30
|
+
* store tokens in a namespaced sanity document, add support for multiple deploy targets ([a1a3446](https://github.com/robinpyon/sanity-plugin-dashboard-widget-vercel/commit/a1a34464590934f1bf7adf3812f29acbef3ed314))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### Bug Fixes
|
|
34
|
+
|
|
35
|
+
* add eventless transitions to deployment target list machine ([7a6d921](https://github.com/robinpyon/sanity-plugin-dashboard-widget-vercel/commit/7a6d921e05c238adbb335331531999a31f680b14))
|
|
36
|
+
* set correct form defaults, update input descriptions, include target name in deploy button ([bf10600](https://github.com/robinpyon/sanity-plugin-dashboard-widget-vercel/commit/bf106000b1a69c9f127f517da98d901fbbbcd481))
|
|
37
|
+
|
|
5
38
|
### [0.1.5](https://github.com/robinpyon/sanity-plugin-dashboard-widget-vercel/compare/v0.1.4...v0.1.5) (2021-01-23)
|
|
6
39
|
|
|
7
40
|
### [0.1.4](https://github.com/robinpyon/sanity-plugin-dashboard-widget-vercel/compare/v0.1.3...v0.1.4) (2021-01-15)
|
package/README.md
CHANGED
|
@@ -2,13 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
View your recent [Vercel](https://vercel.com/) deployments and manually trigger builds directly from your [Sanity](https://www.sanity.io/) dashboard.
|
|
4
4
|
|
|
5
|
-

|
|
6
6
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
9
9
|
- Displays a list of recent builds along with deployment aliases, branch / commit messages, build age and creator
|
|
10
|
-
-
|
|
11
|
-
-
|
|
10
|
+
- Manually trigger deployments straight from your studio (via Vercel deploy hook URLs)
|
|
11
|
+
- Display (and deploy) multiple projects at once
|
|
12
|
+
- Customise the number of visible deployment line items
|
|
13
|
+
- Automatically refreshes deployments periodically, as well as immediately after a manual build is triggered
|
|
14
|
+
- Built with [Sanity UI](https://www.sanity.io/ui)
|
|
12
15
|
|
|
13
16
|
## Install
|
|
14
17
|
|
|
@@ -18,7 +21,7 @@ In your Sanity project folder:
|
|
|
18
21
|
sanity install dashboard-widget-vercel
|
|
19
22
|
```
|
|
20
23
|
|
|
21
|
-
### Configure
|
|
24
|
+
### Configure your dashboard
|
|
22
25
|
|
|
23
26
|
If you haven't configured a [dashboard](https://www.sanity.io/docs/dashboard) yet:
|
|
24
27
|
|
|
@@ -50,69 +53,67 @@ export default {
|
|
|
50
53
|
// ...
|
|
51
54
|
{
|
|
52
55
|
name: 'vercel',
|
|
53
|
-
options: {
|
|
54
|
-
deployLimit: 5,
|
|
55
|
-
deployHook: '%YOUR_DEPLOY_HOOK%', // optional
|
|
56
|
-
forceSmallLayout: false, // optional
|
|
57
|
-
projectId: '%YOUR_PROJECT_ID%',
|
|
58
|
-
teamId: '%YOUR_PROJECT_ID%', // optional
|
|
59
|
-
token: '%VERCEL_TOKEN%',
|
|
60
|
-
},
|
|
61
56
|
layout: {
|
|
62
|
-
width: '
|
|
57
|
+
width: 'full', // full width is recommended!
|
|
63
58
|
},
|
|
64
59
|
},
|
|
65
60
|
],
|
|
66
61
|
}
|
|
67
62
|
```
|
|
68
63
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
## Plugin options
|
|
72
|
-
|
|
73
|
-
### token: string (required)
|
|
64
|
+
### Add a deployment target
|
|
74
65
|
|
|
75
|
-
|
|
66
|
+
Simply visit your Sanity dashboard and click the '+' icon in the top right to add a new deploment target.
|
|
76
67
|
|
|
77
|
-
|
|
68
|
+
You'll need to fill in the following:
|
|
78
69
|
|
|
79
|
-
|
|
70
|
+
#### Name (required)
|
|
80
71
|
|
|
81
|
-
|
|
72
|
+
The name assigned to a deployment target, used purely for presentational purposes in the dashboard.
|
|
82
73
|
|
|
83
|
-
|
|
74
|
+
Note that all deployment targets are sorted alphabetically.
|
|
84
75
|
|
|
85
|
-
|
|
76
|
+
#### Vercel Account Token (required)
|
|
86
77
|
|
|
87
|
-
|
|
78
|
+
This can be created in Vercel under **Account > Settings > Tokens**.
|
|
88
79
|
|
|
89
|
-
|
|
80
|
+
#### Vercel Project ID (required)
|
|
90
81
|
|
|
91
|
-
|
|
82
|
+
This can be retrieved via [Vercel's API](https://vercel.com/docs/api#endpoints/projects/get-projects).
|
|
92
83
|
|
|
93
|
-
|
|
84
|
+
#### Vercel Team ID
|
|
94
85
|
|
|
95
86
|
Similar to project IDs, you can retrieve these via Vercel's API.
|
|
96
87
|
|
|
97
|
-
|
|
88
|
+
If your project is assigned to a team account, you must provide both team and project IDs.
|
|
98
89
|
|
|
99
|
-
|
|
90
|
+
#### Vercel Deploy Hook
|
|
100
91
|
|
|
101
|
-
Vercel deploy hook
|
|
92
|
+
The Vercel deploy hook URL used to trigger new builds.
|
|
102
93
|
|
|
103
|
-
|
|
94
|
+
Enabled a manual deployment button if provided.
|
|
104
95
|
|
|
105
96
|
These can be created in Vercel by going to **Project > Settings > Git > Deploy Hooks**.
|
|
106
97
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
This plugin uses media queries to render the table differently at varying breakpoints and works best if you specify `width: large` in the plugin `layout` object.
|
|
98
|
+
#### Number of deploys to display (min: 1, max: 15) (required)
|
|
110
99
|
|
|
111
|
-
|
|
100
|
+
The number of deployments to display and fetch.
|
|
112
101
|
|
|
113
102
|
## Good to know
|
|
114
103
|
|
|
115
|
-
|
|
104
|
+
### Token security
|
|
105
|
+
|
|
106
|
+
When setting up new deployment targets, you're asked to provide your Vercel account token. It's important to know that your Vercel token provides unrestricted API access to your entire Vercel account.
|
|
107
|
+
|
|
108
|
+
Your Vercel token and all other deployment settings are stored in the `vercel` namespace and by design, these [are not publicly accessible](https://www.sanity.io/docs/ids), even with a public dataset.
|
|
109
|
+
|
|
110
|
+
However, please note that this token is exposed to all _authenticated users_ in your Sanity studio.
|
|
111
|
+
|
|
112
|
+
If you need to limit exposure of this token to authenticated studio users, consider using [custom access control rules](https://www.sanity.io/docs/access-control) to limit access to documents of type `vercel.deploymentTarget`.
|
|
113
|
+
|
|
114
|
+
### Deployment considerations
|
|
115
|
+
|
|
116
|
+
Please also keep the following in mind when manually deploying:
|
|
116
117
|
|
|
117
118
|
> Triggering a Deploy Hook will not rebuild an existing deployment. Instead, it will create a new deployment using the latest source code available on the specified branch.
|
|
118
119
|
>
|
package/lib/app.js
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
11
|
+
|
|
12
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
|
+
|
|
14
|
+
var _icons = require("@sanity/icons");
|
|
15
|
+
|
|
16
|
+
var _ui = require("@sanity/ui");
|
|
17
|
+
|
|
18
|
+
var _react = require("@xstate/react");
|
|
19
|
+
|
|
20
|
+
var _groq = _interopRequireDefault(require("groq"));
|
|
21
|
+
|
|
22
|
+
var _react2 = _interopRequireDefault(require("react"));
|
|
23
|
+
|
|
24
|
+
var _reactQuery = require("react-query");
|
|
25
|
+
|
|
26
|
+
var _client = require("./client");
|
|
27
|
+
|
|
28
|
+
var _StateDebug = _interopRequireDefault(require("./components/StateDebug"));
|
|
29
|
+
|
|
30
|
+
var _constants = require("./constants");
|
|
31
|
+
|
|
32
|
+
var _deploymentTargetList = _interopRequireDefault(require("./machines/deploymentTargetList"));
|
|
33
|
+
|
|
34
|
+
var _DeploymentTargets = _interopRequireDefault(require("./components/DeploymentTargets"));
|
|
35
|
+
|
|
36
|
+
var _DialogForm = _interopRequireDefault(require("./components/DialogForm"));
|
|
37
|
+
|
|
38
|
+
var _dialog = _interopRequireDefault(require("./machines/dialog"));
|
|
39
|
+
|
|
40
|
+
var _templateObject;
|
|
41
|
+
|
|
42
|
+
var Widget = function Widget() {
|
|
43
|
+
// xstate
|
|
44
|
+
var _useMachine = (0, _react.useMachine)(_deploymentTargetList["default"], {
|
|
45
|
+
services: {
|
|
46
|
+
fetchDataService: function fetchDataService(_context, _event) {
|
|
47
|
+
return _client.client.fetch((0, _groq["default"])(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["*[_type == \"", "\"] | order(name asc)"])), _constants.DEPLOYMENT_TARGET_DOCUMENT_TYPE)).then(function (result) {
|
|
48
|
+
return result;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}),
|
|
53
|
+
_useMachine2 = (0, _slicedToArray2["default"])(_useMachine, 2),
|
|
54
|
+
deploymentTargetListState = _useMachine2[0],
|
|
55
|
+
deploymentTargetListStateTransition = _useMachine2[1];
|
|
56
|
+
|
|
57
|
+
var _useMachine3 = (0, _react.useMachine)(_dialog["default"]),
|
|
58
|
+
_useMachine4 = (0, _slicedToArray2["default"])(_useMachine3, 2),
|
|
59
|
+
dialogState = _useMachine4[0],
|
|
60
|
+
dialogStateTransition = _useMachine4[1];
|
|
61
|
+
|
|
62
|
+
var queryClient = new _reactQuery.QueryClient({
|
|
63
|
+
defaultOptions: {
|
|
64
|
+
queries: {
|
|
65
|
+
cacheTime: 0,
|
|
66
|
+
staleTime: 0
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}); // Callbacks
|
|
70
|
+
|
|
71
|
+
var handleDialogClose = function handleDialogClose() {
|
|
72
|
+
dialogStateTransition('CLOSE');
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
var handleDialogShowCreate = function handleDialogShowCreate() {
|
|
76
|
+
dialogStateTransition('CREATE');
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
var handleDialogShowEdit = function handleDialogShowEdit(deploymentTarget) {
|
|
80
|
+
dialogStateTransition('EDIT', {
|
|
81
|
+
deploymentTarget: deploymentTarget
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
var handleTargetCreate = function handleTargetCreate(deploymentTarget) {
|
|
86
|
+
deploymentTargetListStateTransition('CREATE', {
|
|
87
|
+
deploymentTarget: deploymentTarget
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
var handleTargetDelete = function handleTargetDelete(id) {
|
|
92
|
+
deploymentTargetListStateTransition('DELETE', {
|
|
93
|
+
id: id
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
var handleTargetUpdate = function handleTargetUpdate(deploymentTarget) {
|
|
98
|
+
deploymentTargetListStateTransition('UPDATE', {
|
|
99
|
+
deploymentTarget: deploymentTarget
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
return /*#__PURE__*/_react2["default"].createElement(_ui.ThemeProvider, {
|
|
104
|
+
scheme: "light",
|
|
105
|
+
theme: _ui.studioTheme
|
|
106
|
+
}, /*#__PURE__*/_react2["default"].createElement(_ui.ToastProvider, {
|
|
107
|
+
zOffset: _constants.Z_INDEX_TOAST_PROVIDER
|
|
108
|
+
}, /*#__PURE__*/_react2["default"].createElement(_reactQuery.QueryClientProvider, {
|
|
109
|
+
client: queryClient
|
|
110
|
+
}, /*#__PURE__*/_react2["default"].createElement(_ui.Card, {
|
|
111
|
+
radius: 2,
|
|
112
|
+
style: {
|
|
113
|
+
overflow: 'hidden '
|
|
114
|
+
}
|
|
115
|
+
}, /*#__PURE__*/_react2["default"].createElement(_StateDebug["default"], {
|
|
116
|
+
name: "List",
|
|
117
|
+
state: deploymentTargetListState
|
|
118
|
+
}), /*#__PURE__*/_react2["default"].createElement(_ui.Flex, {
|
|
119
|
+
align: "center",
|
|
120
|
+
justify: "space-between",
|
|
121
|
+
paddingX: 3,
|
|
122
|
+
paddingY: 2
|
|
123
|
+
}, /*#__PURE__*/_react2["default"].createElement(_ui.Text, {
|
|
124
|
+
size: 5,
|
|
125
|
+
weight: "semibold"
|
|
126
|
+
}, "Vercel deployments"), /*#__PURE__*/_react2["default"].createElement(_ui.Tooltip, {
|
|
127
|
+
content: /*#__PURE__*/_react2["default"].createElement(_ui.Box, {
|
|
128
|
+
padding: 2
|
|
129
|
+
}, /*#__PURE__*/_react2["default"].createElement(_ui.Text, {
|
|
130
|
+
muted: true,
|
|
131
|
+
size: 1
|
|
132
|
+
}, "Create new deployment target")),
|
|
133
|
+
placement: "left"
|
|
134
|
+
}, /*#__PURE__*/_react2["default"].createElement(_ui.Button, {
|
|
135
|
+
fontSize: 1,
|
|
136
|
+
icon: _icons.AddIcon,
|
|
137
|
+
onClick: handleDialogShowCreate,
|
|
138
|
+
mode: "bleed"
|
|
139
|
+
}))), /*#__PURE__*/_react2["default"].createElement(_ui.Box, null, deploymentTargetListState.matches('pending') && /*#__PURE__*/_react2["default"].createElement(_ui.Box, {
|
|
140
|
+
paddingX: 3,
|
|
141
|
+
paddingY: 4
|
|
142
|
+
}, /*#__PURE__*/_react2["default"].createElement(_ui.Text, null, "Loading...")), deploymentTargetListState.matches('ready.withoutData') && /*#__PURE__*/_react2["default"].createElement(_ui.Box, {
|
|
143
|
+
paddingX: 3,
|
|
144
|
+
paddingY: 4
|
|
145
|
+
}, /*#__PURE__*/_react2["default"].createElement(_ui.Text, null, "No deployment targets found.", ' ', /*#__PURE__*/_react2["default"].createElement("a", {
|
|
146
|
+
onClick: handleDialogShowCreate,
|
|
147
|
+
style: {
|
|
148
|
+
cursor: 'pointer'
|
|
149
|
+
}
|
|
150
|
+
}, "Create a new target?"))), deploymentTargetListState.matches('ready.withData') && /*#__PURE__*/_react2["default"].createElement(_DeploymentTargets["default"], {
|
|
151
|
+
items: deploymentTargetListState.context.results,
|
|
152
|
+
onDialogEdit: handleDialogShowEdit
|
|
153
|
+
}), deploymentTargetListState.matches('failed') && /*#__PURE__*/_react2["default"].createElement(_ui.Box, {
|
|
154
|
+
paddingX: 3,
|
|
155
|
+
paddingY: 4
|
|
156
|
+
}, /*#__PURE__*/_react2["default"].createElement(_ui.Text, null, "Failed to retrieve deployment targets. Please check the developer console log for more information.")))), dialogState.matches('create') && /*#__PURE__*/_react2["default"].createElement(_DialogForm["default"], {
|
|
157
|
+
onClose: handleDialogClose,
|
|
158
|
+
onCreate: handleTargetCreate
|
|
159
|
+
}), dialogState.matches('edit') && /*#__PURE__*/_react2["default"].createElement(_DialogForm["default"], {
|
|
160
|
+
deploymentTarget: dialogState.context.editDeploymentTarget,
|
|
161
|
+
onClose: handleDialogClose,
|
|
162
|
+
onDelete: handleTargetDelete,
|
|
163
|
+
onUpdate: handleTargetUpdate
|
|
164
|
+
}))));
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
var _default = Widget;
|
|
168
|
+
exports["default"] = _default;
|
package/lib/client.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.client = void 0;
|
|
9
|
+
|
|
10
|
+
var _client = _interopRequireDefault(require("part:@sanity/base/client"));
|
|
11
|
+
|
|
12
|
+
var _constants = require("./constants");
|
|
13
|
+
|
|
14
|
+
var client = typeof _client["default"].withConfig === 'function' ? _client["default"].withConfig({
|
|
15
|
+
apiVersion: _constants.API_VERSION
|
|
16
|
+
}) : _client["default"];
|
|
17
|
+
exports.client = client;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
4
|
+
|
|
3
5
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
6
|
|
|
5
7
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -9,45 +11,89 @@ exports["default"] = void 0;
|
|
|
9
11
|
|
|
10
12
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
13
|
|
|
12
|
-
var
|
|
14
|
+
var _icons = require("@sanity/icons");
|
|
13
15
|
|
|
14
|
-
var
|
|
16
|
+
var _ui = require("@sanity/ui");
|
|
15
17
|
|
|
16
|
-
var
|
|
18
|
+
var _react = require("@xstate/react");
|
|
17
19
|
|
|
18
|
-
var _react2 =
|
|
20
|
+
var _react2 = _interopRequireWildcard(require("react"));
|
|
19
21
|
|
|
20
22
|
var _constants = require("../../constants");
|
|
21
23
|
|
|
24
|
+
var _deploy = _interopRequireDefault(require("../../machines/deploy"));
|
|
25
|
+
|
|
26
|
+
var _StateDebug = _interopRequireDefault(require("../StateDebug"));
|
|
27
|
+
|
|
22
28
|
var DeployButton = function DeployButton(props) {
|
|
23
|
-
var
|
|
29
|
+
var deployHook = props.deployHook,
|
|
30
|
+
onDeploySuccess = props.onDeploySuccess,
|
|
31
|
+
targetName = props.targetName;
|
|
24
32
|
|
|
25
|
-
var
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
33
|
+
var _useMachine = (0, _react.useMachine)((0, _deploy["default"])(deployHook)),
|
|
34
|
+
_useMachine2 = (0, _slicedToArray2["default"])(_useMachine, 3),
|
|
35
|
+
deployState = _useMachine2[0],
|
|
36
|
+
deployStateTransition = _useMachine2[1],
|
|
37
|
+
deployStateInterpreter = _useMachine2[2];
|
|
38
|
+
|
|
39
|
+
var toast = (0, _ui.useToast)();
|
|
40
|
+
var isError = deployState.matches('error');
|
|
41
|
+
var isSuccess = deployState.matches('success'); // Callbacks
|
|
29
42
|
|
|
30
43
|
var handleDeploy = function handleDeploy() {
|
|
31
|
-
|
|
44
|
+
deployStateTransition({
|
|
32
45
|
type: 'DEPLOY'
|
|
33
46
|
});
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
}; // Effects
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
(0, _react2.useEffect)(function () {
|
|
51
|
+
if (isError) {
|
|
52
|
+
toast.push({
|
|
53
|
+
closable: true,
|
|
54
|
+
description: "Unable to queue deploy for ".concat(targetName, ": ").concat(deployState.context.error),
|
|
55
|
+
duration: 8000,
|
|
56
|
+
status: 'error',
|
|
57
|
+
title: _constants.WIDGET_NAME
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (isSuccess) {
|
|
62
|
+
toast.push({
|
|
63
|
+
closable: true,
|
|
64
|
+
description: "Deploy queued for ".concat(targetName),
|
|
65
|
+
duration: 8000,
|
|
66
|
+
status: 'success',
|
|
67
|
+
title: _constants.WIDGET_NAME
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}, [isError, isSuccess]);
|
|
71
|
+
(0, _react2.useEffect)(function () {
|
|
72
|
+
deployStateInterpreter.onTransition(function (state) {
|
|
73
|
+
if (state.value === 'success') {
|
|
74
|
+
if (onDeploySuccess) {
|
|
75
|
+
onDeploySuccess();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}, [deployStateInterpreter]);
|
|
80
|
+
return /*#__PURE__*/_react2["default"].createElement(_ui.Box, {
|
|
81
|
+
padding: 3,
|
|
82
|
+
style: {
|
|
83
|
+
position: 'relative'
|
|
84
|
+
}
|
|
85
|
+
}, /*#__PURE__*/_react2["default"].createElement(_StateDebug["default"], {
|
|
86
|
+
name: "Deploy",
|
|
87
|
+
state: deployState
|
|
88
|
+
}), /*#__PURE__*/_react2["default"].createElement(_ui.Button, {
|
|
89
|
+
disabled: deployState.context.disabled,
|
|
90
|
+
fontSize: 1,
|
|
91
|
+
icon: _icons.UploadIcon,
|
|
92
|
+
mode: "ghost",
|
|
93
|
+
onClick: handleDeploy,
|
|
94
|
+
padding: 3,
|
|
95
|
+
text: "".concat(deployState.context.label, " ").concat(targetName),
|
|
96
|
+
tone: "default"
|
|
51
97
|
}));
|
|
52
98
|
};
|
|
53
99
|
|
|
@@ -9,18 +9,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
9
9
|
});
|
|
10
10
|
exports["default"] = void 0;
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _ui = require("@sanity/ui");
|
|
13
13
|
|
|
14
14
|
var _react = _interopRequireWildcard(require("react"));
|
|
15
15
|
|
|
16
16
|
var _reactTimeAgo = _interopRequireDefault(require("react-time-ago"));
|
|
17
17
|
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
var _TD = _interopRequireDefault(require("../TD"));
|
|
18
|
+
var _TableCell = _interopRequireDefault(require("../TableCell"));
|
|
21
19
|
|
|
22
20
|
var _StatusDot = _interopRequireDefault(require("../StatusDot"));
|
|
23
21
|
|
|
22
|
+
var _icons = require("@sanity/icons");
|
|
23
|
+
|
|
24
24
|
var Deployment = function Deployment(props) {
|
|
25
25
|
var _deployment$meta, _deployment$meta2, _deployment$alias, _deployment$creator;
|
|
26
26
|
|
|
@@ -29,82 +29,77 @@ var Deployment = function Deployment(props) {
|
|
|
29
29
|
var commitMessage = deployment === null || deployment === void 0 ? void 0 : (_deployment$meta = deployment.meta) === null || _deployment$meta === void 0 ? void 0 : _deployment$meta.githubCommitMessage;
|
|
30
30
|
var commitRef = deployment === null || deployment === void 0 ? void 0 : (_deployment$meta2 = deployment.meta) === null || _deployment$meta2 === void 0 ? void 0 : _deployment$meta2.githubCommitRef;
|
|
31
31
|
var targetUrl = (_deployment$alias = deployment.alias) !== null && _deployment$alias !== void 0 ? _deployment$alias : deployment.url;
|
|
32
|
-
return /*#__PURE__*/_react["default"].createElement("tr", null, /*#__PURE__*/_react["default"].createElement(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
state: deployment.state,
|
|
38
|
-
sx: {
|
|
39
|
-
flexShrink: 0,
|
|
40
|
-
mr: 2
|
|
41
|
-
},
|
|
42
|
-
variant: "statusDot.smallOnly"
|
|
43
|
-
}), targetUrl ? /*#__PURE__*/_react["default"].createElement(_themeUi.Flex, {
|
|
44
|
-
sx: {
|
|
45
|
-
alignItems: 'center'
|
|
46
|
-
}
|
|
47
|
-
}, deployment.alias && /*#__PURE__*/_react["default"].createElement(_ioniconsSolid.ReturnDownForward, {
|
|
48
|
-
size: "12px",
|
|
32
|
+
return /*#__PURE__*/_react["default"].createElement("tr", null, /*#__PURE__*/_react["default"].createElement(_TableCell["default"], null, /*#__PURE__*/_react["default"].createElement(_ui.Flex, {
|
|
33
|
+
align: "center"
|
|
34
|
+
}, /*#__PURE__*/_react["default"].createElement(_ui.Box, {
|
|
35
|
+
display: ['block', 'block', 'block', 'block', 'none'],
|
|
36
|
+
marginRight: 3,
|
|
49
37
|
style: {
|
|
50
38
|
flexShrink: 0
|
|
51
39
|
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
40
|
+
}, /*#__PURE__*/_react["default"].createElement(_StatusDot["default"], {
|
|
41
|
+
state: deployment.state
|
|
42
|
+
})), targetUrl ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, deployment.alias && /*#__PURE__*/_react["default"].createElement(_icons.LinkIcon, null), /*#__PURE__*/_react["default"].createElement(_ui.Box, {
|
|
43
|
+
marginLeft: deployment.alias ? 1 : 0
|
|
44
|
+
}, /*#__PURE__*/_react["default"].createElement(_ui.Text, {
|
|
45
|
+
muted: !(deployment.state === 'READY'),
|
|
46
|
+
size: 1,
|
|
47
|
+
style: {
|
|
48
|
+
textDecoration: deployment.state === 'CANCELED' || deployment.state === 'ERROR' ? 'line-through' : 'normal'
|
|
49
|
+
},
|
|
50
|
+
textOverflow: "ellipsis"
|
|
51
|
+
}, deployment.state === 'READY' ? /*#__PURE__*/_react["default"].createElement("a", {
|
|
56
52
|
href: "https://".concat(targetUrl),
|
|
57
53
|
rel: "noopener noreferrer",
|
|
58
54
|
target: "_blank"
|
|
59
|
-
}, targetUrl) : /*#__PURE__*/_react["default"].createElement(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
color: "muted"
|
|
66
|
-
}, "Uploading..."))), /*#__PURE__*/_react["default"].createElement(_TD["default"], {
|
|
67
|
-
variant: "cells.state"
|
|
68
|
-
}, /*#__PURE__*/_react["default"].createElement(_themeUi.Flex, {
|
|
69
|
-
sx: {
|
|
70
|
-
alignItems: 'center'
|
|
71
|
-
}
|
|
55
|
+
}, targetUrl) : targetUrl))) : /*#__PURE__*/_react["default"].createElement(_ui.Text, {
|
|
56
|
+
size: 1
|
|
57
|
+
}, "Uploading..."))), /*#__PURE__*/_react["default"].createElement(_TableCell["default"], {
|
|
58
|
+
variant: "state"
|
|
59
|
+
}, /*#__PURE__*/_react["default"].createElement(_ui.Flex, {
|
|
60
|
+
align: "center"
|
|
72
61
|
}, /*#__PURE__*/_react["default"].createElement(_StatusDot["default"], {
|
|
73
|
-
state: deployment.state
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
62
|
+
state: deployment.state
|
|
63
|
+
}), /*#__PURE__*/_react["default"].createElement(_ui.Box, {
|
|
64
|
+
marginLeft: 2
|
|
65
|
+
}, /*#__PURE__*/_react["default"].createElement(_ui.Text, {
|
|
66
|
+
size: 1
|
|
77
67
|
}, deployment.state.trim().toLowerCase().replace(/^[a-z]/i, function (t) {
|
|
78
68
|
return t.toUpperCase();
|
|
79
|
-
})))), /*#__PURE__*/_react["default"].createElement(
|
|
80
|
-
variant: "
|
|
81
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
82
|
-
|
|
83
|
-
},
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
},
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
69
|
+
}))))), /*#__PURE__*/_react["default"].createElement(_TableCell["default"], {
|
|
70
|
+
variant: "branch"
|
|
71
|
+
}, /*#__PURE__*/_react["default"].createElement(_ui.Stack, {
|
|
72
|
+
space: 2
|
|
73
|
+
}, /*#__PURE__*/_react["default"].createElement(_ui.Text, {
|
|
74
|
+
size: 1,
|
|
75
|
+
textOverflow: "ellipsis"
|
|
76
|
+
}, commitRef), commitMessage && /*#__PURE__*/_react["default"].createElement(_ui.Text, {
|
|
77
|
+
muted: true,
|
|
78
|
+
size: 1,
|
|
79
|
+
textOverflow: "ellipsis"
|
|
80
|
+
}, commitMessage))), /*#__PURE__*/_react["default"].createElement(_TableCell["default"], {
|
|
81
|
+
variant: "age"
|
|
82
|
+
}, /*#__PURE__*/_react["default"].createElement(_ui.Flex, {
|
|
83
|
+
align: "center"
|
|
84
|
+
}, /*#__PURE__*/_react["default"].createElement(_ui.Text, {
|
|
85
|
+
size: 1
|
|
90
86
|
}, /*#__PURE__*/_react["default"].createElement(_reactTimeAgo["default"], {
|
|
91
87
|
date: date.current,
|
|
92
88
|
locale: "en-US",
|
|
93
89
|
timeStyle: "mini"
|
|
94
|
-
}))), /*#__PURE__*/_react["default"].createElement(
|
|
95
|
-
variant: "
|
|
96
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
position: 'absolute',
|
|
102
|
-
size: '100%',
|
|
103
|
-
top: 0
|
|
104
|
-
}
|
|
105
|
-
}, /*#__PURE__*/_react["default"].createElement(_themeUi.Image, {
|
|
90
|
+
})))), /*#__PURE__*/_react["default"].createElement(_TableCell["default"], {
|
|
91
|
+
variant: "creator"
|
|
92
|
+
}, /*#__PURE__*/_react["default"].createElement(_ui.Flex, {
|
|
93
|
+
align: "center",
|
|
94
|
+
justify: "center"
|
|
95
|
+
}, /*#__PURE__*/_react["default"].createElement("img", {
|
|
96
|
+
draggable: false,
|
|
106
97
|
src: "https://vercel.com/api/www/avatar/".concat(deployment === null || deployment === void 0 ? void 0 : (_deployment$creator = deployment.creator) === null || _deployment$creator === void 0 ? void 0 : _deployment$creator.uid, "?&s=48"),
|
|
107
|
-
|
|
98
|
+
style: {
|
|
99
|
+
borderRadius: '20px',
|
|
100
|
+
height: '20px',
|
|
101
|
+
width: '20px'
|
|
102
|
+
}
|
|
108
103
|
}))));
|
|
109
104
|
};
|
|
110
105
|
|