querysub 0.253.0 → 0.255.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.253.0",
3
+ "version": "0.255.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",
@@ -7,6 +7,8 @@ import { css } from "../../4-dom/css";
7
7
  import { formatTime } from "socket-function/src/formatting/format";
8
8
  import { formatTimeJSX } from "../../misc/formatJSX";
9
9
  import { MachineController } from "../machineController";
10
+ import { closeAllModals } from "../../5-diagnostics/Modal";
11
+ import { unique } from "../../misc";
10
12
 
11
13
  module.hotreload = true;
12
14
 
@@ -25,7 +27,9 @@ export class RenderGitRefInfo extends qreact.Component<{
25
27
  useQuerysub: this.props.isQuerysub,
26
28
  });
27
29
  if (!gitRefInfo) return undefined;
28
- return <div className={css.fontWeight("normal")}>{formatTimeJSX(gitRefInfo.time)} AGO {gitRefInfo.description}</div>;
30
+ return <div className={css.fontWeight("normal")}>
31
+ {formatTimeJSX(gitRefInfo.time)} AGO <span className={css.hsl(0, 0, 80).pad2(5, 2).italic}>{gitRefInfo.description}</span>
32
+ </div>;
29
33
  }
30
34
  }
31
35
 
@@ -42,7 +46,7 @@ export class UpdateButtons extends qreact.Component<{
42
46
  let { gitRef, repoUrl } = service.parameters;
43
47
  return repoUrl === gitInfo?.repoUrl && gitRef !== gitInfo?.latestRef;
44
48
  });
45
- let outdatedRefs = outdatedServices.map(service => service.parameters.gitRef);
49
+ let outdatedRefs = unique(outdatedServices.map(service => service.parameters.gitRef));
46
50
 
47
51
  return <>
48
52
  {!!gitInfo?.querysubUncommitted.length && <button
@@ -52,13 +56,15 @@ export class UpdateButtons extends qreact.Component<{
52
56
  showFullscreenModal({
53
57
  content: <div>
54
58
  <InputLabel
55
- label="Commit message (enter to commit, escape to cancel)"
59
+ label="Commit message (shift+enter to commit, escape to cancel)"
56
60
  value={""}
57
61
  textarea
58
62
  fillWidth
59
- onChangeValue={value => {
63
+ focusOnMount
64
+ onChangeValue={async value => {
60
65
  if (!value) return;
61
- void controller.commitPushAndPublishQuerysub.promise(value);
66
+ await controller.commitPushAndPublishQuerysub.promise(value);
67
+ closeAllModals();
62
68
  }}
63
69
  />
64
70
  <div className={css.vbox(5)}>
@@ -76,7 +82,10 @@ export class UpdateButtons extends qreact.Component<{
76
82
  {bigEmoji("📚", -5)}
77
83
  Publish & Commit & Push Querysub & Update Package.json ({gitInfo?.querysubUncommitted.length} Files Changed)
78
84
  </div>
79
- <RenderGitRefInfo gitRef={gitInfo.querysubRef} isQuerysub />
85
+ <div className={css.hbox(5)}>
86
+ <b>Current</b>
87
+ <RenderGitRefInfo gitRef={gitInfo.querysubRef} isQuerysub />
88
+ </div>
80
89
  </button>}
81
90
  {!!gitInfo?.uncommitted.length && <button
82
91
  className={buttonStyle.hsl(210, 40, 50)}
@@ -85,13 +94,15 @@ export class UpdateButtons extends qreact.Component<{
85
94
  showFullscreenModal({
86
95
  content: <div>
87
96
  <InputLabel
88
- label="Commit message (enter to commit, escape to cancel)"
97
+ label="Commit message (shift+enter to commit, escape to cancel)"
89
98
  value={""}
90
99
  textarea
91
100
  fillWidth
92
- onChangeValue={value => {
101
+ focusOnMount
102
+ onChangeValue={async value => {
93
103
  if (!value) return;
94
- void controller.commitPushService.promise(value);
104
+ await controller.commitPushService.promise(value);
105
+ closeAllModals();
95
106
  }}
96
107
  />
97
108
  <div className={css.vbox(5)}>
@@ -93,12 +93,12 @@ class MachineControllerBase {
93
93
  machineNodeId: string;
94
94
  gitRef: string;
95
95
  }) {
96
- await MachineController(config.machineNodeId).deployService.promise({
96
+ await MachineController(config.machineNodeId).deployMachine.promise({
97
97
  gitRef: config.gitRef,
98
98
  });
99
99
  }
100
100
 
101
- public async deployService(config: {
101
+ public async deployMachine(config: {
102
102
  gitRef: string;
103
103
  }) {
104
104
  let gitFolder = os.homedir() + "/machine-alwaysup";
@@ -120,12 +120,17 @@ export const MachineController = getSyncedController(SocketFunction.register(
120
120
  streamScreenOutput: {},
121
121
  watchOtherScreenOutput: {},
122
122
  deployMachineFromBrowser: {},
123
- deployService: {},
123
+ deployMachine: {},
124
124
  }),
125
125
  () => ({
126
126
  hooks: [assertIsManagementUser],
127
127
  }),
128
- ));
128
+ ), {
129
+ writes: {
130
+ deployMachineFromBrowser: ["MachineInfo"],
131
+ deployMachine: ["MachineInfo"],
132
+ }
133
+ });
129
134
 
130
135
  let callbacks = new Map<string, (data: string) => Promise<void>>();
131
136
  export async function watchScreenOutput(config: {
@@ -305,8 +305,8 @@ export const MachineServiceController = getSyncedController(
305
305
  addServiceConfig: ["ServiceConfig", "ServiceConfigList"],
306
306
  setServiceConfigs: ["ServiceConfig"],
307
307
  deleteServiceConfig: ["ServiceConfig", "ServiceConfigList"],
308
- commitPushService: ["gitInfo"],
309
- commitPushAndPublishQuerysub: ["gitInfo"],
308
+ commitPushService: ["gitInfo", "ServiceConfig"],
309
+ commitPushAndPublishQuerysub: ["gitInfo", "ServiceConfig"],
310
310
  },
311
311
  reads: {
312
312
  getMachineList: ["MachineInfoList"],
@@ -2,5 +2,5 @@ import { qreact } from "../4-dom/qreact";
2
2
  import { formatTime, formatVeryNiceDateTime } from "socket-function/src/formatting/format";
3
3
 
4
4
  export function formatTimeJSX(time: number) {
5
- return <span title={formatVeryNiceDateTime(time)}>({formatTime(Date.now() - time)})</span>;
5
+ return <span title={formatVeryNiceDateTime(time)}>{formatTime(Date.now() - time)}</span>;
6
6
  }
package/src/misc.ts CHANGED
@@ -49,4 +49,8 @@ export function joinVNodes(vNodes: preact.ComponentChild[], delimitter: preact.C
49
49
 
50
50
  export function clamp(value: number, min: number, max: number) {
51
51
  return Math.max(min, Math.min(max, value));
52
+ }
53
+
54
+ export function unique<T>(array: T[]): T[] {
55
+ return Array.from(new Set(array));
52
56
  }