querysub 0.523.0 → 0.524.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "querysub",
3
- "version": "0.523.0",
3
+ "version": "0.524.0",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "note1": "note on node-forge fork, see https://github.com/digitalbazaar/forge/issues/744 for details",
@@ -46,6 +46,32 @@ export class UpdateButtons extends qreact.Component<{
46
46
  state = t.state({
47
47
  isDeploying: t.type(false),
48
48
  });
49
+ // Deploys all outdated services to latestRef. Scheduled releases use the configured overlap so the new instances are running before the old ones shut down; immediate skips the release entirely (old instances restart right away, no overlap).
50
+ private deployAll(outdatedServices: ServiceConfig[], latestRef: string, immediate: boolean) {
51
+ this.state.isDeploying = true;
52
+ // Props are synchronized state, so everything the async work needs is cloned into plain locals HERE, in the synced part
53
+ let toDeploy = outdatedServices.map(service => {
54
+ let updated = deepCloneJSON(service);
55
+ updated.parameters.gitRef = latestRef;
56
+ if (immediate) {
57
+ updated.parameters.releaseTime = undefined;
58
+ } else {
59
+ let overlap = updated.parameters.overlapTime || DEFAULT_OVERLAP_TIME;
60
+ updated.parameters.releaseTime = Date.now() + overlap;
61
+ }
62
+ return updated;
63
+ });
64
+ let controller = MachineServiceController(SocketFunction.browserNodeId());
65
+ Querysub.onCommitFinished(async () => {
66
+ try {
67
+ await controller.setServiceConfigs.promise(toDeploy);
68
+ } finally {
69
+ Querysub.commit(() => {
70
+ this.state.isDeploying = false;
71
+ });
72
+ }
73
+ });
74
+ }
49
75
  render() {
50
76
  let controller = MachineServiceController(SocketFunction.browserNodeId());
51
77
  const gitInfo = controller.getGitInfo();
@@ -98,30 +124,12 @@ export class UpdateButtons extends qreact.Component<{
98
124
  {bigEmoji("⬆️")} <span>Commit & Push ({gitInfo?.uncommitted.length} Files Changed)</span>
99
125
  </button>}
100
126
 
101
- {outdatedServices.length > 0 && gitInfo &&
127
+ {outdatedServices.length > 0 && gitInfo && <>
102
128
  <button
103
129
  className={buttonStyle.hsl(120, 70, 90)}
104
130
  disabled={this.state.isDeploying}
105
131
  onClick={() => {
106
- this.state.isDeploying = true;
107
- // Props are synchronized state, so everything the async work needs is cloned into plain locals HERE, in the synced part
108
- let toDeploy = outdatedServices.map(service => {
109
- let updated = deepCloneJSON(service);
110
- updated.parameters.gitRef = gitInfo.latestRef;
111
- // Release with the configured overlap, so the new instances are running before the old ones shut down
112
- let overlap = updated.parameters.overlapTime || DEFAULT_OVERLAP_TIME;
113
- updated.parameters.releaseTime = Date.now() + overlap;
114
- return updated;
115
- });
116
- Querysub.onCommitFinished(async () => {
117
- try {
118
- await controller.setServiceConfigs.promise(toDeploy);
119
- } finally {
120
- Querysub.commit(() => {
121
- this.state.isDeploying = false;
122
- });
123
- }
124
- });
132
+ this.deployAll(outdatedServices, gitInfo.latestRef, false);
125
133
  }}
126
134
  >
127
135
  <div>
@@ -136,7 +144,19 @@ export class UpdateButtons extends qreact.Component<{
136
144
  <RenderGitRefInfo gitRef={ref} />
137
145
  </div>)}
138
146
  </button>
139
- }
147
+ <button
148
+ className={buttonStyle.hsl(0, 70, 90)}
149
+ disabled={this.state.isDeploying}
150
+ title="Deploys immediately, with no overlap: the old instances are shut down right away"
151
+ onClick={() => {
152
+ this.deployAll(outdatedServices, gitInfo.latestRef, true);
153
+ }}
154
+ >
155
+ <div>
156
+ {bigEmoji("⚡")} <span>{this.state.isDeploying && "⏳ Deploying..." || `Deploy All (${outdatedServices.length}) Now (no delay)`}</span>
157
+ </div>
158
+ </button>
159
+ </>}
140
160
  </>;
141
161
  }
142
162
  }