querysub 0.513.0 → 0.514.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/package.json
CHANGED
|
@@ -195,6 +195,9 @@ export class UpdateServiceButtons extends qreact.Component<{
|
|
|
195
195
|
export class DeployMachineButtons extends qreact.Component<{
|
|
196
196
|
machines: MachineInfo[];
|
|
197
197
|
}> {
|
|
198
|
+
state = t.state({
|
|
199
|
+
isDeploying: t.type(false),
|
|
200
|
+
});
|
|
198
201
|
render() {
|
|
199
202
|
let controller = MachineServiceController(SocketFunction.browserNodeId());
|
|
200
203
|
const gitInfo = controller.getGitInfo();
|
|
@@ -208,25 +211,38 @@ export class DeployMachineButtons extends qreact.Component<{
|
|
|
208
211
|
return <>
|
|
209
212
|
{outdatedMachines.length > 0 && <div
|
|
210
213
|
className={buttonStyle.alignSelf("stretch").hsl(120, 70, 50)}
|
|
211
|
-
onClick={
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
214
|
+
onClick={() => {
|
|
215
|
+
if (this.state.isDeploying) return;
|
|
216
|
+
this.state.isDeploying = true;
|
|
217
|
+
// Props are synchronized state, so everything the async work needs is captured HERE, in the synced part
|
|
218
|
+
let machineNodeIds = outdatedMachines.map(machine => machine.applyNodeId);
|
|
219
|
+
let gitRef = gitInfo.latestRef;
|
|
220
|
+
Querysub.onCommitFinished(async () => {
|
|
221
|
+
try {
|
|
222
|
+
let machineController = MachineController(SocketFunction.browserNodeId());
|
|
223
|
+
try {
|
|
224
|
+
await Promise.allSettled(machineNodeIds.map(machineNodeId => {
|
|
225
|
+
return machineController.deployMachineFromBrowser.promise({
|
|
226
|
+
machineNodeId,
|
|
227
|
+
gitRef,
|
|
228
|
+
});
|
|
229
|
+
}));
|
|
230
|
+
} catch (error) {
|
|
231
|
+
// They should always end with a disconnect (which means the machine updated, so obviously it disconnected from us)
|
|
232
|
+
if (!String(error).includes("disconnected")) {
|
|
233
|
+
throw error;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
} finally {
|
|
237
|
+
Querysub.commit(() => {
|
|
238
|
+
this.state.isDeploying = false;
|
|
218
239
|
});
|
|
219
|
-
}));
|
|
220
|
-
} catch (error) {
|
|
221
|
-
// They should always end with a disconnect (which means the machine updated, so obviously it disconnected from us)
|
|
222
|
-
if (!String(error).includes("disconnected")) {
|
|
223
|
-
throw error;
|
|
224
240
|
}
|
|
225
|
-
}
|
|
241
|
+
});
|
|
226
242
|
}}
|
|
227
243
|
>
|
|
228
244
|
<div>
|
|
229
|
-
{bigEmoji("🎯", -4)} <span>Deploy {outdatedMachines.length} Machines</span>
|
|
245
|
+
{bigEmoji("🎯", -4)} <span>{this.state.isDeploying && "⏳ Deploying..." || `Deploy ${outdatedMachines.length} Machines`}</span>
|
|
230
246
|
</div>
|
|
231
247
|
<div className={css.hbox(5)}>
|
|
232
248
|
<b>New</b>
|