@nanocollective/roster 0.1.0-beta.14 → 0.1.0-beta.15
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/dist/agents-NMGVORU3.js +232 -0
- package/dist/chunk-E3EVPK4I.js +338 -0
- package/dist/chunk-QCKEGMXD.js +562 -0
- package/dist/cli.js +1689 -820
- package/dist/compose-56JIIIHA.js +15 -0
- package/dist/connectors-ZVEPXSAR.js +23 -0
- package/dist/worker/assets/assets/css/connectors.css +50 -0
- package/dist/worker/assets/assets/js/api.js +3 -0
- package/dist/worker/assets/assets/js/app.js +4 -1
- package/dist/worker/assets/assets/js/icons.js +2 -0
- package/dist/worker/assets/assets/js/state.js +11 -1
- package/dist/worker/assets/assets/js/views/connectors.js +290 -0
- package/dist/worker/assets/index.html +4 -0
- package/dist/worker/index.js +2743 -1014
- package/docs/README.md +1 -0
- package/docs/architecture.md +1 -1
- package/docs/commands.md +37 -1
- package/docs/connectors.md +157 -0
- package/docs/cost.md +1 -1
- package/docs/developing.md +2 -2
- package/docs/doctor-codes.md +5 -1
- package/docs/export.md +1 -1
- package/docs/extending.md +1 -1
- package/docs/hosting.md +12 -1
- package/docs/memory.md +1 -1
- package/docs/org-yaml.md +25 -1
- package/docs/portal.md +18 -1
- package/docs/prompts.md +1 -1
- package/docs/security.md +17 -1
- package/docs/session-workflow.md +23 -5
- package/docs/staff-yaml.md +1 -1
- package/docs/troubleshooting.md +1 -1
- package/docs/upgrading.md +1 -1
- package/docs/writing-a-charter.md +1 -1
- package/package.json +2 -1
- package/templates/brain/.github/workflows/%%STAFF%%-daily.yaml +8 -6
- package/templates/brain/.github/workflows/%%STAFF%%-mention.yaml +8 -6
- package/templates/ops/.github/workflows/session.yaml +52 -11
- package/templates/ops/agents.mjs +38 -11
- package/templates/ops/compose.mjs +12 -0
- package/templates/ops/connectors.mjs +722 -0
- package/templates/ops/prompts/_identity.md +14 -0
- package/templates/portal/css/connectors.css +50 -0
- package/templates/portal/index.html +4 -0
- package/templates/portal/js/api.js +3 -0
- package/templates/portal/js/app.js +4 -1
- package/templates/portal/js/icons.js +2 -0
- package/templates/portal/js/state.js +11 -1
- package/templates/portal/js/views/connectors.js +290 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
CATALOGUE,
|
|
4
|
+
connectorsOf,
|
|
5
|
+
declared,
|
|
6
|
+
prepare,
|
|
7
|
+
readOnlyMode,
|
|
8
|
+
secretName,
|
|
9
|
+
serverFor,
|
|
10
|
+
wiringFor,
|
|
11
|
+
withConnectors
|
|
12
|
+
} from "./chunk-QCKEGMXD.js";
|
|
13
|
+
export {
|
|
14
|
+
CATALOGUE,
|
|
15
|
+
connectorsOf,
|
|
16
|
+
declared,
|
|
17
|
+
prepare,
|
|
18
|
+
readOnlyMode,
|
|
19
|
+
secretName,
|
|
20
|
+
serverFor,
|
|
21
|
+
wiringFor,
|
|
22
|
+
withConnectors
|
|
23
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/* Connectors: what is connected, as rows, and what can be, as a grid of cards. */
|
|
2
|
+
|
|
3
|
+
.connhead{font:600 13px var(--sans);color:var(--ink-dim);margin:22px 0 10px;letter-spacing:0}
|
|
4
|
+
.connhead:first-child{margin-top:4px}
|
|
5
|
+
h1 + div > .connhead:first-child,h1 + .connerr + div > .connhead:first-child{margin-top:20px}
|
|
6
|
+
.connerr{background:color-mix(in srgb,var(--err) 9%,transparent);border-radius:var(--r);padding:10px 12px;
|
|
7
|
+
margin:0 0 14px;font-size:13px}
|
|
8
|
+
|
|
9
|
+
.connlist{display:flex;flex-direction:column;border:1px solid var(--line);border-radius:var(--r-lg);
|
|
10
|
+
background:var(--panel);box-shadow:var(--shadow-sm);overflow:hidden;max-width:880px}
|
|
11
|
+
.connrow{display:grid;grid-template-columns:32px minmax(0,1fr) auto auto;gap:14px;align-items:center;
|
|
12
|
+
padding:12px 16px;border-top:1px solid var(--line)}
|
|
13
|
+
.connrow:first-child{border-top:0}
|
|
14
|
+
.conntext{display:flex;flex-direction:column;gap:5px;min-width:0}
|
|
15
|
+
.conntext b{font:600 14px var(--sans);letter-spacing:-.01em}
|
|
16
|
+
.connwho{display:flex;gap:5px;flex-wrap:wrap}
|
|
17
|
+
.connacts{margin:0;flex-wrap:nowrap}
|
|
18
|
+
.connacts .ghbtn.danger{color:var(--err);border-color:color-mix(in srgb,var(--err) 40%,transparent)}
|
|
19
|
+
|
|
20
|
+
.connicon{display:grid;place-items:center;width:32px;height:32px;border-radius:9px;flex:none;
|
|
21
|
+
background:var(--accent-soft);color:var(--accent);--ic:16px}
|
|
22
|
+
|
|
23
|
+
.conngrid{display:grid;gap:10px;grid-template-columns:repeat(auto-fill,minmax(210px,1fr));max-width:880px}
|
|
24
|
+
.conncard{display:flex;align-items:flex-start;gap:12px;text-align:left;padding:14px;border:1px solid var(--line);
|
|
25
|
+
border-radius:var(--r-lg);background:var(--panel);color:var(--ink);cursor:pointer;box-shadow:var(--shadow-sm);
|
|
26
|
+
transition:border-color .15s var(--ease),transform .15s var(--ease),box-shadow .15s var(--ease)}
|
|
27
|
+
.conncard > span:last-child{display:flex;flex-direction:column;gap:3px;min-width:0}
|
|
28
|
+
.conncard b{font:600 13.5px var(--sans);line-height:1.3}
|
|
29
|
+
.conncard small{font-size:12px;color:var(--ink-dim);line-height:1.45}
|
|
30
|
+
.conncard:hover{border-color:var(--accent);box-shadow:var(--shadow)}
|
|
31
|
+
.conncard:active{transform:translateY(1px)}
|
|
32
|
+
.conncard:focus-visible{outline:none;box-shadow:0 0 0 3px var(--accent-soft);border-color:var(--accent)}
|
|
33
|
+
|
|
34
|
+
.connform{max-width:520px}
|
|
35
|
+
.connform .sub{margin-bottom:14px}
|
|
36
|
+
.connsteps{margin:0 0 12px;padding-left:20px;font-size:13.5px;line-height:1.6}
|
|
37
|
+
.connsteps li{padding-left:2px}
|
|
38
|
+
.connform .setupform{margin:16px 0 10px}
|
|
39
|
+
.conncheck p{margin:8px 0 0;font-size:13px}
|
|
40
|
+
.connsub{font:600 12px var(--sans);color:var(--ink-dim);margin:18px 0 8px}
|
|
41
|
+
.connstaff{display:flex;flex-direction:column;gap:6px;margin-bottom:10px}
|
|
42
|
+
.conntick{display:flex;align-items:center;gap:9px;font-size:13.5px;cursor:pointer;width:fit-content}
|
|
43
|
+
.conntick input{width:15px;height:15px;accent-color:var(--accent);margin:0}
|
|
44
|
+
.connfoot{margin-top:18px}
|
|
45
|
+
|
|
46
|
+
@media (max-width:640px){
|
|
47
|
+
.connrow{grid-template-columns:32px minmax(0,1fr);row-gap:10px}
|
|
48
|
+
.connrow > .chip{grid-column:2;justify-self:start}
|
|
49
|
+
.connacts{grid-column:2}
|
|
50
|
+
}
|
|
@@ -45,6 +45,9 @@ export async function getOrgWithProgress(onStep) {
|
|
|
45
45
|
throw new Error("The org did not arrive. Reload to try again.");
|
|
46
46
|
}
|
|
47
47
|
export const getDocs = () => json("/api/docs");
|
|
48
|
+
|
|
49
|
+
/** Connectors: the catalogue, what this org has, and whether each one's key is stored. */
|
|
50
|
+
export const getConnectors = () => json("/api/connectors");
|
|
48
51
|
export const getInbox = (force) => json("/api/inbox" + (force ? "?refresh=1" : ""));
|
|
49
52
|
export const getSync = () => json("/api/sync").catch(() => null);
|
|
50
53
|
|
|
@@ -18,6 +18,7 @@ import { onRender } from "./router.js";
|
|
|
18
18
|
import { ORG_WIDE, S, VIEWS, applyHash, humanLabel, readHash, writeHash } from "./state.js";
|
|
19
19
|
import { viewBrain } from "./views/brain.js";
|
|
20
20
|
import { viewChanged } from "./views/changed.js";
|
|
21
|
+
import { viewConnectors } from "./views/connectors.js";
|
|
21
22
|
import { viewDocs } from "./views/docs.js";
|
|
22
23
|
import { viewGraph } from "./views/graph.js";
|
|
23
24
|
import { viewHealth } from "./views/health.js";
|
|
@@ -39,6 +40,7 @@ const SCREEN = {
|
|
|
39
40
|
runs: viewRuns,
|
|
40
41
|
org: viewOrg,
|
|
41
42
|
staff: viewStaff,
|
|
43
|
+
connectors: viewConnectors,
|
|
42
44
|
docs: viewDocs,
|
|
43
45
|
brain: viewBrain,
|
|
44
46
|
memory: viewBrain,
|
|
@@ -65,6 +67,7 @@ const NAV = [
|
|
|
65
67
|
["#inboxnav", "inbox"],
|
|
66
68
|
["#runsnav", "runs"],
|
|
67
69
|
["#staffnav", "staff"],
|
|
70
|
+
["#connectorsnav", "connectors"],
|
|
68
71
|
["#orgnav", "org"],
|
|
69
72
|
["#docsnav", "docs"],
|
|
70
73
|
];
|
|
@@ -107,7 +110,7 @@ export async function boot() {
|
|
|
107
110
|
/* Every one of these reads a tenant, so during setup they answer 409 and the sidebar is a
|
|
108
111
|
row of four dead ends beside an empty Staff heading. There is one thing to do on this
|
|
109
112
|
screen; the navigation comes back with the org. */
|
|
110
|
-
for (const el of document.querySelectorAll("#sidesearch, #homenav, #inboxnav, #runsnav, #orgnav, #staffnav, #docsnav, #refreshall, .sect, #stafflist")) {
|
|
113
|
+
for (const el of document.querySelectorAll("#sidesearch, #homenav, #inboxnav, #runsnav, #orgnav, #staffnav, #connectorsnav, #docsnav, #refreshall, .sect, #stafflist")) {
|
|
111
114
|
el.hidden = true;
|
|
112
115
|
}
|
|
113
116
|
for (const slot of document.querySelectorAll("[data-icon]")) {
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
const PATHS = {
|
|
16
|
+
"plug":
|
|
17
|
+
"<path d=\"M12 22v-5\" /> <path d=\"M9 8V2\" /> <path d=\"M15 8V2\" /> <path d=\"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z\" />",
|
|
16
18
|
"search":
|
|
17
19
|
"<circle cx=\"11\" cy=\"11\" r=\"8\" /> <path d=\"m21 21-4.3-4.3\" />",
|
|
18
20
|
"lightbulb":
|
|
@@ -22,7 +22,17 @@ export const VIEWS = [
|
|
|
22
22
|
export const VIEW_ALIAS = { memory: "brain" };
|
|
23
23
|
|
|
24
24
|
/** Screens that belong to the org rather than to one staff member. */
|
|
25
|
-
export const ORG_WIDE = new Set([
|
|
25
|
+
export const ORG_WIDE = new Set([
|
|
26
|
+
"setup",
|
|
27
|
+
"home",
|
|
28
|
+
"inbox",
|
|
29
|
+
"prs",
|
|
30
|
+
"runs",
|
|
31
|
+
"org",
|
|
32
|
+
"staff",
|
|
33
|
+
"connectors",
|
|
34
|
+
"docs",
|
|
35
|
+
]);
|
|
26
36
|
|
|
27
37
|
/** The two screens that read the inbox, and so share its filters and its `?t=` thread. */
|
|
28
38
|
const INBOXY = new Set(["inbox", "prs"]);
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
/* The Connectors screen: outside services the staff can use in their runs.
|
|
2
|
+
*
|
|
3
|
+
* What is connected, as cards, and what can be, as a grid. Picking one opens a sheet with how
|
|
4
|
+
* to get its key, the key, who gets it, and Save. A key is checked with the service before it is
|
|
5
|
+
* stored, goes to GitHub as a secret, and is never shown again. A service that only signs in
|
|
6
|
+
* (Notion) signs in through the hosted portal instead.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { getConnectors, post } from "../api.js";
|
|
10
|
+
import { sheet } from "../dialog.js";
|
|
11
|
+
import { el } from "../dom.js";
|
|
12
|
+
import { icon } from "../icons.js";
|
|
13
|
+
import { render } from "../router.js";
|
|
14
|
+
|
|
15
|
+
/* The last answer, so a repaint after Save does not flash an empty screen. */
|
|
16
|
+
let last = null;
|
|
17
|
+
|
|
18
|
+
export function viewConnectors(m) {
|
|
19
|
+
m.append(el("h1", { textContent: "Connectors" }));
|
|
20
|
+
const notice = signInNotice();
|
|
21
|
+
if (notice) m.append(notice);
|
|
22
|
+
const body = el("div");
|
|
23
|
+
m.append(body);
|
|
24
|
+
if (last) draw(body, last);
|
|
25
|
+
else body.append(el("p", { className: "sub", textContent: "Loading…" }));
|
|
26
|
+
getConnectors()
|
|
27
|
+
.then((d) => {
|
|
28
|
+
if (d.error) throw new Error(d.error);
|
|
29
|
+
last = d;
|
|
30
|
+
body.replaceChildren();
|
|
31
|
+
draw(body, d);
|
|
32
|
+
})
|
|
33
|
+
.catch((err) => body.replaceChildren(el("p", { className: "err", textContent: String(err.message || err) })));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** A sign-in that came back with a problem says so once, from the URL it came back to. */
|
|
37
|
+
function signInNotice() {
|
|
38
|
+
const q = (location.hash.split("?")[1] ?? "");
|
|
39
|
+
const e = new URLSearchParams(q).get("e");
|
|
40
|
+
if (!e) return null;
|
|
41
|
+
history.replaceState?.(null, "", location.hash.replace(/\?.*$/, ""));
|
|
42
|
+
return el("p", { className: "err connerr", textContent: e });
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function draw(body, d) {
|
|
46
|
+
const have = new Set(d.connectors.map((c) => c.catalogue ?? c.id));
|
|
47
|
+
|
|
48
|
+
if (d.connectors.length) {
|
|
49
|
+
const list = el("div", { className: "connlist" });
|
|
50
|
+
for (const c of d.connectors) list.append(row(c, d));
|
|
51
|
+
body.append(el("h2", { className: "connhead", textContent: "Connected" }), list);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const grid = el("div", { className: "conngrid" });
|
|
55
|
+
for (const e of d.catalogue) {
|
|
56
|
+
if (have.has(e.id)) continue;
|
|
57
|
+
// One Notion, whichever this portal can do: signing in where it keeps sign-ins, a key elsewhere.
|
|
58
|
+
if (e.auth === "oauth" && !d.signIn) continue;
|
|
59
|
+
if (e.id === "notion-key" && d.signIn && !have.has("notion-key")) continue;
|
|
60
|
+
const card = el("button", { className: "conncard" }, [
|
|
61
|
+
el("span", { className: "connicon" }, [icon("plug")]),
|
|
62
|
+
el("span", {}, [el("b", { textContent: shortName(e) }), el("small", { textContent: e.summary })]),
|
|
63
|
+
]);
|
|
64
|
+
card.onclick = () => open(e, null, d);
|
|
65
|
+
grid.append(card);
|
|
66
|
+
}
|
|
67
|
+
body.append(el("h2", { className: "connhead", textContent: d.connectors.length ? "Add another" : "Add a service" }), grid);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** "Notion (integration key)" is only Notion where it is the one Notion on offer. */
|
|
71
|
+
function shortName(e) {
|
|
72
|
+
return e.name.replace(/ \(.*\)$/, "");
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function row(c, d) {
|
|
76
|
+
const e = d.catalogue.find((x) => x.id === (c.catalogue ?? c.id));
|
|
77
|
+
const status = c.problem
|
|
78
|
+
? el("span", { className: "chip hot", textContent: "Needs fixing" })
|
|
79
|
+
: c.auth === "oauth"
|
|
80
|
+
? c.signedIn
|
|
81
|
+
? el("span", { className: "chip ok", textContent: "Signed in" })
|
|
82
|
+
: el("span", { className: "chip warm", textContent: "Not signed in" })
|
|
83
|
+
: c.keys === "stored"
|
|
84
|
+
? el("span", { className: "chip ok", textContent: "Key stored" })
|
|
85
|
+
: c.keys === "unknown"
|
|
86
|
+
? el("span", { className: "chip", textContent: "Key not checked" })
|
|
87
|
+
: el("span", { className: "chip warm", textContent: c.keys === "partial" ? "Key on some repos" : "No key" });
|
|
88
|
+
|
|
89
|
+
const who = el("div", { className: "connwho" });
|
|
90
|
+
for (const h of c.staff) who.append(el("span", { className: "chip", textContent: h }));
|
|
91
|
+
if (c.readOnly) who.append(el("span", { className: "chip cool", textContent: "read only" }));
|
|
92
|
+
|
|
93
|
+
const edit = el("button", { className: "ghbtn", textContent: "Edit" });
|
|
94
|
+
edit.onclick = () => open(e ?? custom(c), c, d);
|
|
95
|
+
edit.disabled = !d.canWrite || !e;
|
|
96
|
+
const remove = el("button", { className: "ghbtn", textContent: "Remove" });
|
|
97
|
+
remove.disabled = !d.canWrite;
|
|
98
|
+
remove.onclick = () => confirmRemove(c, remove);
|
|
99
|
+
|
|
100
|
+
return el("div", { className: "connrow" }, [
|
|
101
|
+
el("span", { className: "connicon" }, [icon("plug")]),
|
|
102
|
+
el("div", { className: "conntext" }, [
|
|
103
|
+
el("b", { textContent: c.name }),
|
|
104
|
+
c.problem ? el("span", { className: "err", textContent: c.problem }) : who,
|
|
105
|
+
]),
|
|
106
|
+
status,
|
|
107
|
+
el("div", { className: "row connacts" }, [edit, remove]),
|
|
108
|
+
]);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** A hand-written connector the catalogue does not describe: editable in org.yaml only. */
|
|
112
|
+
function custom(c) {
|
|
113
|
+
return { id: c.id, name: c.name, fields: [], steps: [], auth: c.auth };
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async function confirmRemove(c, btn) {
|
|
117
|
+
if (btn.dataset.sure !== "1") {
|
|
118
|
+
btn.dataset.sure = "1";
|
|
119
|
+
btn.textContent = "Remove " + c.name + "?";
|
|
120
|
+
btn.classList.add("danger");
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
btn.disabled = true;
|
|
124
|
+
btn.textContent = "Removing…";
|
|
125
|
+
try {
|
|
126
|
+
await post({ id: c.id }, "/api/connectors/remove");
|
|
127
|
+
last = null;
|
|
128
|
+
render();
|
|
129
|
+
} catch (err) {
|
|
130
|
+
btn.textContent = String(err.message || err);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/* --------------------------------- the sheet --------------------------------- */
|
|
135
|
+
|
|
136
|
+
function open(e, c, d) {
|
|
137
|
+
let box = null;
|
|
138
|
+
const node = form(e, c, d, () => box?.close());
|
|
139
|
+
box = sheet({ node, onClose: () => {} });
|
|
140
|
+
if (!box) document.querySelector("#main")?.append(node);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function form(e, c, d, close) {
|
|
144
|
+
const out = el("div", { className: "connform" });
|
|
145
|
+
out.append(el("h2", { className: "sheettitle", textContent: (c ? "" : "Connect ") + shortName(e) }));
|
|
146
|
+
if (!c) out.append(el("p", { className: "sub", textContent: e.summary }));
|
|
147
|
+
|
|
148
|
+
const oauth = e.auth === "oauth";
|
|
149
|
+
if (!c && e.steps.length && !oauth) {
|
|
150
|
+
const ol = el("ol", { className: "connsteps" });
|
|
151
|
+
for (const s of e.steps) ol.append(el("li", { textContent: s }));
|
|
152
|
+
out.append(ol);
|
|
153
|
+
if (e.link) {
|
|
154
|
+
out.append(
|
|
155
|
+
el("a", { className: "ghbtn", href: e.link, target: "_blank", rel: "noopener", textContent: "Open " + shortName(e) }),
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const fields = el("div", { className: "setupform" });
|
|
161
|
+
const inputs = {};
|
|
162
|
+
for (const f of e.fields) {
|
|
163
|
+
const input = el("input", {
|
|
164
|
+
type: f.secret ? "password" : "text",
|
|
165
|
+
autocomplete: "off",
|
|
166
|
+
spellcheck: false,
|
|
167
|
+
placeholder: f.secret && c ? "Leave empty to keep the stored key" : f.required ? "" : "Optional",
|
|
168
|
+
value: f.secret ? "" : (c?.settings?.[f.id] ?? ""),
|
|
169
|
+
});
|
|
170
|
+
inputs[f.id] = { input, f };
|
|
171
|
+
fields.append(el("label", { className: "field" }, [el("span", { textContent: f.label }), input]));
|
|
172
|
+
}
|
|
173
|
+
if (e.fields.length) out.append(fields);
|
|
174
|
+
|
|
175
|
+
const checked = el("div", { className: "conncheck" });
|
|
176
|
+
const secretInputs = Object.values(inputs).filter((x) => x.f.secret);
|
|
177
|
+
if (e.canCheck && secretInputs.length) {
|
|
178
|
+
const check = el("button", { className: "ghbtn", textContent: "Check key" });
|
|
179
|
+
check.onclick = async () => {
|
|
180
|
+
check.disabled = true;
|
|
181
|
+
check.textContent = "Checking…";
|
|
182
|
+
try {
|
|
183
|
+
const r = await post({ id: e.id, values: valuesOf(inputs) }, "/api/connectors/check");
|
|
184
|
+
checked.replaceChildren(result(r));
|
|
185
|
+
} catch (err) {
|
|
186
|
+
checked.replaceChildren(el("p", { className: "err", textContent: String(err.message || err) }));
|
|
187
|
+
} finally {
|
|
188
|
+
check.disabled = false;
|
|
189
|
+
check.textContent = "Check key";
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
out.append(el("div", { className: "row" }, [check]), checked);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const picked = new Set(c ? c.staff : (e.suggest ?? []).filter((h) => d.staff.some((s) => s.handle === h)));
|
|
196
|
+
if (!picked.size && d.staff.length === 1) picked.add(d.staff[0].handle);
|
|
197
|
+
const who = el("div", { className: "connstaff" });
|
|
198
|
+
for (const s of d.staff) {
|
|
199
|
+
const box = el("input", { type: "checkbox", checked: picked.has(s.handle) });
|
|
200
|
+
box.onchange = () => (box.checked ? picked.add(s.handle) : picked.delete(s.handle));
|
|
201
|
+
who.append(el("label", { className: "conntick" }, [box, el("span", { textContent: s.name })]));
|
|
202
|
+
}
|
|
203
|
+
out.append(el("h3", { className: "connsub", textContent: "Who can use it" }), who);
|
|
204
|
+
|
|
205
|
+
let ro = null;
|
|
206
|
+
if (e.readOnly) {
|
|
207
|
+
ro = el("input", { type: "checkbox", checked: Boolean(c?.readOnly) });
|
|
208
|
+
out.append(el("label", { className: "conntick" }, [ro, el("span", { textContent: "Read only" })]));
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const status = el("div");
|
|
212
|
+
const cancel = el("button", { className: "ghbtn", textContent: "Cancel" });
|
|
213
|
+
cancel.onclick = close;
|
|
214
|
+
const save = el("button", { className: "ghbtn primary" });
|
|
215
|
+
|
|
216
|
+
if (oauth && !c?.signedIn) {
|
|
217
|
+
save.textContent = "Sign in to " + e.name;
|
|
218
|
+
save.disabled = !d.signIn || !d.canWrite;
|
|
219
|
+
if (!d.signIn) {
|
|
220
|
+
out.append(el("p", { className: "sub", textContent: "Signing in needs the hosted portal." }));
|
|
221
|
+
}
|
|
222
|
+
save.onclick = async () => {
|
|
223
|
+
if (!picked.size) return status.replaceChildren(el("p", { className: "err", textContent: "Pick at least one staff member." }));
|
|
224
|
+
save.disabled = true;
|
|
225
|
+
save.textContent = "Opening " + e.name + "…";
|
|
226
|
+
try {
|
|
227
|
+
const r = await post({ id: e.id, staff: [...picked], readOnly: Boolean(ro?.checked) }, "/api/connectors/signin");
|
|
228
|
+
location.href = r.url;
|
|
229
|
+
} catch (err) {
|
|
230
|
+
save.disabled = false;
|
|
231
|
+
save.textContent = "Sign in to " + e.name;
|
|
232
|
+
status.replaceChildren(el("p", { className: "err", textContent: String(err.message || err) }));
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
} else {
|
|
236
|
+
save.textContent = "Save";
|
|
237
|
+
save.disabled = !d.canWrite;
|
|
238
|
+
save.onclick = async () => {
|
|
239
|
+
if (!picked.size) return status.replaceChildren(el("p", { className: "err", textContent: "Pick at least one staff member." }));
|
|
240
|
+
save.disabled = true;
|
|
241
|
+
save.textContent = "Saving…";
|
|
242
|
+
try {
|
|
243
|
+
await post(
|
|
244
|
+
{
|
|
245
|
+
id: e.id,
|
|
246
|
+
staff: [...picked],
|
|
247
|
+
readOnly: Boolean(ro?.checked),
|
|
248
|
+
settings: settingsOf(inputs),
|
|
249
|
+
values: valuesOf(inputs, true),
|
|
250
|
+
},
|
|
251
|
+
"/api/connectors/save",
|
|
252
|
+
);
|
|
253
|
+
last = null;
|
|
254
|
+
close();
|
|
255
|
+
render();
|
|
256
|
+
} catch (err) {
|
|
257
|
+
save.disabled = false;
|
|
258
|
+
save.textContent = "Save";
|
|
259
|
+
status.replaceChildren(el("p", { className: "err", textContent: String(err.message || err) }));
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
out.append(status, el("div", { className: "row connfoot" }, [save, cancel]));
|
|
265
|
+
if (!d.canWrite) out.append(el("p", { className: "sub", textContent: "You are view-only, so you cannot change connectors." }));
|
|
266
|
+
return out;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function result(r) {
|
|
270
|
+
if (r.state === "ok") return el("p", { className: "okline", textContent: "The key works." });
|
|
271
|
+
if (r.state === "limited") return el("p", { className: "okline", textContent: r.note });
|
|
272
|
+
if (r.state === "rejected") return el("p", { className: "err", textContent: r.note });
|
|
273
|
+
return el("p", { className: "sub", textContent: r.note });
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/** Every field's value, for checking; only the keys, for storing. */
|
|
277
|
+
function valuesOf(inputs, keysOnly = false) {
|
|
278
|
+
const out = {};
|
|
279
|
+
for (const [id, { input, f }] of Object.entries(inputs)) {
|
|
280
|
+
if (keysOnly && !f.secret) continue;
|
|
281
|
+
out[id] = String(input.value ?? "").trim();
|
|
282
|
+
}
|
|
283
|
+
return out;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function settingsOf(inputs) {
|
|
287
|
+
const out = {};
|
|
288
|
+
for (const [id, { input, f }] of Object.entries(inputs)) if (!f.secret) out[id] = String(input.value ?? "").trim();
|
|
289
|
+
return out;
|
|
290
|
+
}
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
<link rel="stylesheet" href="/assets/css/health.css">
|
|
21
21
|
<link rel="stylesheet" href="/assets/css/runs.css">
|
|
22
22
|
<link rel="stylesheet" href="/assets/css/setup.css">
|
|
23
|
+
<link rel="stylesheet" href="/assets/css/connectors.css">
|
|
23
24
|
</head>
|
|
24
25
|
<body>
|
|
25
26
|
<div class="app">
|
|
@@ -56,6 +57,9 @@
|
|
|
56
57
|
<button class="nav" id="staffnav" data-view="staff">
|
|
57
58
|
<span class="ic" data-icon="person"></span> Staff
|
|
58
59
|
</button>
|
|
60
|
+
<button class="nav" id="connectorsnav" data-view="connectors" title="Outside services the staff can use">
|
|
61
|
+
<span class="ic" data-icon="plug"></span> Connectors
|
|
62
|
+
</button>
|
|
59
63
|
<button class="nav" id="docsnav" data-view="docs">
|
|
60
64
|
<span class="ic" data-icon="docs"></span> Docs
|
|
61
65
|
</button>
|