create-pmos 0.469.0 → 0.471.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 +27 -27
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/board-publish-ui-test.js +161 -0
- package/workspace/board-shared-ui-test.js +155 -0
- package/workspace/briefing-premium-board-test.js +1 -1
- package/workspace/changelog.json +26 -0
- package/workspace/guide/published-board.md +51 -3
- package/workspace/lib/board-publish-choices.js +25 -0
- package/workspace/lib/boards-host.js +20 -4
- package/workspace/lib/boards-teams.js +99 -0
- package/workspace/lib/routes-board-publish.js +44 -7
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/bd-publish.css +44 -0
- package/workspace/public/pm/bd-publish.js +152 -0
- package/workspace/public/pm/bd-shared.css +31 -0
- package/workspace/public/pm/bd-shared.js +153 -0
- package/workspace/public/pm/premium-board.js +16 -4
- package/workspace/public/pm/readonly.js +1 -1
- package/workspace/public/premium-board.html +3 -0
- package/workspace/test-lists/board-publish-b.json +4 -2
- package/workspace/test-lists/board-publish-d.json +11 -0
|
@@ -11,10 +11,14 @@
|
|
|
11
11
|
* and sent only to the host as the bearer. It is never returned to the browser, never logged, never written to a record (D08).
|
|
12
12
|
* The host holds the key's hash; a key can publish and remove its own links only.
|
|
13
13
|
*
|
|
14
|
+
* THE TEAMS this workspace joined (lib/boards-teams.js) are kept in state.json too: { name, host, password }. The team password is a secret on this computer
|
|
15
|
+
* like the publish key: mode 0600, never returned to the browser, never logged (D08).
|
|
16
|
+
*
|
|
14
17
|
* THE LINKS. state.json also keeps, for each open link: { id, url, team, name, kind, selection, ws, board, by, made, ends, views }. The link's
|
|
15
18
|
* password is NOT kept: it is shown once at publish. Republish keeps the same link and password (the host owns it).
|
|
16
19
|
*
|
|
17
|
-
* THE HOST ADDRESS comes from PMOS_BOARDS_HOST (an https origin; plain http only for 127.0.0.1 and localhost, for tests)
|
|
20
|
+
* THE HOST ADDRESS comes from PMOS_BOARDS_HOST (an https origin; plain http only for 127.0.0.1 and localhost, for tests), else from the address the PM saved on the
|
|
21
|
+
* Publish popover (state.json host). Neither set, nothing is sent.
|
|
18
22
|
*
|
|
19
23
|
* hostOrigin(env) -> string | null
|
|
20
24
|
* readState(dir) · links(dir) -> the state | the links newest first (ended ones dropped)
|
|
@@ -45,9 +49,21 @@ function hostOrigin(env = process.env) {
|
|
|
45
49
|
}
|
|
46
50
|
|
|
47
51
|
function readState(dir) {
|
|
48
|
-
try { const s = JSON.parse(fs.readFileSync(fileOf(dir), 'utf8')); return { key: typeof s.key === 'string' ? s.key : null, links: Array.isArray(s.links) ? s.links : [] }; }
|
|
49
|
-
catch { return { key: null, links: [] }; }
|
|
52
|
+
try { const s = JSON.parse(fs.readFileSync(fileOf(dir), 'utf8')); return { key: typeof s.key === 'string' ? s.key : null, host: typeof s.host === 'string' ? s.host : '', teams: Array.isArray(s.teams) ? s.teams : [], links: Array.isArray(s.links) ? s.links : [] }; }
|
|
53
|
+
catch { return { key: null, host: '', teams: [], links: [] }; }
|
|
54
|
+
}
|
|
55
|
+
/** The address the PM saved on the Publish popover ('' when none). The environment variable PMOS_BOARDS_HOST wins over it (see addressOf). */
|
|
56
|
+
function savedHost(dir) { return readState(dir).host || ''; }
|
|
57
|
+
/** Save the host address: '' clears it. Returns { ok, host } or { ok: false, error } with a sentence for the PM. */
|
|
58
|
+
function setHost(dir, value) {
|
|
59
|
+
const v = String(value == null ? '' : value).trim();
|
|
60
|
+
if (v === '') { const st = readState(dir); st.host = ''; writeState(dir, st); return { ok: true, host: '' }; }
|
|
61
|
+
const o = hostOrigin({ PMOS_BOARDS_HOST: v });
|
|
62
|
+
if (!o) return { ok: false, error: 'Use an https address with no path, such as https://boards.example.com.' };
|
|
63
|
+
const st = readState(dir); st.host = o; writeState(dir, st); return { ok: true, host: o };
|
|
50
64
|
}
|
|
65
|
+
/** The environment variables a call reads: the variable wins, then the saved address. */
|
|
66
|
+
const addressOf = (dir, env = process.env) => ({ PMOS_BOARDS_HOST: (env && env.PMOS_BOARDS_HOST) || savedHost(dir) });
|
|
51
67
|
function writeState(dir, st) {
|
|
52
68
|
const f = fileOf(dir);
|
|
53
69
|
fs.mkdirSync(path.dirname(f), { recursive: true, mode: 0o700 });
|
|
@@ -134,4 +150,4 @@ async function turnOff(dir, id, opts = {}) {
|
|
|
134
150
|
return { ok: true };
|
|
135
151
|
}
|
|
136
152
|
|
|
137
|
-
module.exports = { DAYS, TEAM_RX, MAX_PACK, hostOrigin, readState, links, publish, republish, turnOff };
|
|
153
|
+
module.exports = { DAYS, TEAM_RX, MAX_PACK, hostOrigin, savedHost, setHost, addressOf, readState, writeState, links, publish, republish, turnOff };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* boards-teams.js — the teams this workspace joined, and the Shared view's reads (initiative board-publish, slice 4; PRD T1 to T6; D103).
|
|
3
|
+
*
|
|
4
|
+
* A TEAM is { name, host, password }, kept in <runtime state>/board-publish/state.json (lib/boards-host.js): the host it lives on, and the team password.
|
|
5
|
+
* The password is a secret on this computer: mode 0600, never returned to the browser, never logged (D08). Every function here takes the state folder.
|
|
6
|
+
*
|
|
7
|
+
* THE CONTRACT with the host (board-host/src/core.js):
|
|
8
|
+
* GET <host>/api/teams/<team>/links X-Team-Password -> { ok, links: [{ id, name, kind, by, made, ends, views, url }] }
|
|
9
|
+
* POST <host>/api/teams/<team>/open/<id> X-Team-Password -> { ok, url } one-time, 5 minutes
|
|
10
|
+
* A refusal is { ok: false, error } with a plain sentence. 403 is a wrong password, 429 a lockout (the sentence names the minutes), 404 an unknown team.
|
|
11
|
+
*
|
|
12
|
+
* parseInvite(text) -> { host, team, password } | { error } "<host>/join#<team>.<password>", each part percent-encoded
|
|
13
|
+
* join(dir, { invite | host, team, password }, { fetch }) -> { ok, team } | { ok: false, error } verifies with the host before it keeps anything
|
|
14
|
+
* leave(dir, team) -> { ok } forgets the password here; the host is not told
|
|
15
|
+
* names(dir) -> [string]
|
|
16
|
+
* readAll(dir, { fetch }) -> [{ team, host, ok: true, links } | { team, host, ok: false, kind, error }] all teams at once; one failing never hides another
|
|
17
|
+
* open(dir, team, id, { fetch }) -> { ok, url } | { ok: false, error }
|
|
18
|
+
* kind of a failure: 'password' | 'locked' | 'missing' | 'unreachable' | 'other'. Nothing from a read is kept: an unreadable team has no old rows. */
|
|
19
|
+
const Host = require('./boards-host.js');
|
|
20
|
+
|
|
21
|
+
const TIMEOUT_MS = 15000;
|
|
22
|
+
const MAX_TEAMS = 20;
|
|
23
|
+
|
|
24
|
+
function parseInvite(text) {
|
|
25
|
+
let u; try { u = new URL(String(text || '').trim()); } catch { return { error: 'This is not an invite link. It looks like https://boards.example.com/join#Team.password.' }; }
|
|
26
|
+
const host = u.username || u.password ? null : Host.hostOrigin({ PMOS_BOARDS_HOST: u.origin });
|
|
27
|
+
const m = /^#([^.]+)\.(.+)$/.exec(u.hash || '');
|
|
28
|
+
if (!host || u.pathname !== '/join' || !m) return { error: 'This is not an invite link. It looks like https://boards.example.com/join#Team.password.' };
|
|
29
|
+
let team; let password; try { team = decodeURIComponent(m[1]); password = decodeURIComponent(m[2]); } catch { return { error: 'This is not an invite link. It looks like https://boards.example.com/join#Team.password.' }; }
|
|
30
|
+
if (!Host.TEAM_RX.test(team)) return { error: 'The team name in this link is not valid.' };
|
|
31
|
+
if (password.length < 8 || password.length > 100) return { error: 'The password in this link is not valid.' };
|
|
32
|
+
return { host, team, password };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** One call to a host with the team password. Never throws. { ok, status, body } | { ok: false, kind, error } */
|
|
36
|
+
async function call(host, method, p, password, fetchFn) {
|
|
37
|
+
const f = fetchFn || (typeof fetch === 'function' ? fetch : null);
|
|
38
|
+
if (!f) return { ok: false, kind: 'unreachable', error: 'This computer cannot reach the host (no network client).' };
|
|
39
|
+
const ctl = typeof AbortController === 'function' ? new AbortController() : null; const timer = ctl ? setTimeout(() => ctl.abort(), TIMEOUT_MS) : null;
|
|
40
|
+
try {
|
|
41
|
+
const res = await f(host + p, { method, redirect: 'error', signal: ctl ? ctl.signal : undefined, headers: { 'X-Team-Password': password, Accept: 'application/json' } });
|
|
42
|
+
let j = null; try { j = await res.json(); } catch { /* not JSON */ }
|
|
43
|
+
if (res.ok && j && j.ok !== false) return { ok: true, status: res.status, body: j };
|
|
44
|
+
const say = (j && typeof j.error === 'string' && j.error.slice(0, 240)) || '';
|
|
45
|
+
if (res.status === 403) return { ok: false, kind: 'password', error: 'The team password does not work. Ask for a new invite link.' };
|
|
46
|
+
if (res.status === 429) return { ok: false, kind: 'locked', error: say || 'Too many wrong tries. Try again in a few minutes.' };
|
|
47
|
+
if (res.status === 404) return { ok: false, kind: 'missing', error: say || 'There is no such team on that host.' };
|
|
48
|
+
return { ok: false, kind: 'other', error: say || 'The host refused the request (' + res.status + ').' };
|
|
49
|
+
} catch (e) {
|
|
50
|
+
return { ok: false, kind: 'unreachable', error: e && e.name === 'AbortError' ? 'The host did not answer in time. Try again.' : 'The host could not be reached. Check the connection.' };
|
|
51
|
+
} finally { if (timer) clearTimeout(timer); }
|
|
52
|
+
}
|
|
53
|
+
const teamPath = (team) => '/api/teams/' + encodeURIComponent(team);
|
|
54
|
+
|
|
55
|
+
async function join(dir, o, opts = {}) {
|
|
56
|
+
let host; let team; let password;
|
|
57
|
+
if (o.invite != null && String(o.invite).trim() !== '') {
|
|
58
|
+
const p = parseInvite(o.invite); if (p.error) return { ok: false, error: p.error };
|
|
59
|
+
({ host, team, password } = p);
|
|
60
|
+
} else {
|
|
61
|
+
host = Host.hostOrigin({ PMOS_BOARDS_HOST: String(o.host || '').trim() }); team = String(o.team || '').trim(); password = String(o.password || '');
|
|
62
|
+
if (!host) return { ok: false, error: 'Use an https address for the host, such as https://boards.example.com.' };
|
|
63
|
+
if (!Host.TEAM_RX.test(team)) return { ok: false, error: 'A team name is letters, numbers, spaces, dots, dashes and underscores, up to 40.' };
|
|
64
|
+
if (password.length < 8 || password.length > 100) return { ok: false, error: 'A team password is 8 to 100 characters.' };
|
|
65
|
+
}
|
|
66
|
+
const st = Host.readState(dir);
|
|
67
|
+
if (!st.teams.some((t) => t.name === team && t.host === host) && st.teams.length >= MAX_TEAMS) return { ok: false, error: 'This computer has joined 20 teams. Leave one first.' };
|
|
68
|
+
const r = await call(host, 'GET', teamPath(team) + '/links', password, opts.fetch);
|
|
69
|
+
if (!r.ok) return { ok: false, error: r.error, kind: r.kind };
|
|
70
|
+
const cur = Host.readState(dir);
|
|
71
|
+
cur.teams = cur.teams.filter((t) => !(t.name === team && t.host === host)).concat([{ name: team, host, password }]);
|
|
72
|
+
Host.writeState(dir, cur);
|
|
73
|
+
return { ok: true, team };
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function leave(dir, team) { const st = Host.readState(dir); const had = st.teams.some((t) => t.name === team); st.teams = st.teams.filter((t) => t.name !== team); Host.writeState(dir, st); return { ok: had }; }
|
|
77
|
+
const names = (dir) => Host.readState(dir).teams.map((t) => t.name);
|
|
78
|
+
|
|
79
|
+
async function readAll(dir, opts = {}) {
|
|
80
|
+
const teams = Host.readState(dir).teams;
|
|
81
|
+
return Promise.all(teams.map(async (t) => {
|
|
82
|
+
const r = await call(t.host, 'GET', teamPath(t.name) + '/links', t.password, opts.fetch);
|
|
83
|
+
if (!r.ok) return { team: t.name, host: new URL(t.host).host, ok: false, kind: r.kind, error: r.kind === 'password' ? 'The team password no longer works. Ask for a new invite link.' : r.error };
|
|
84
|
+
const links = (Array.isArray(r.body.links) ? r.body.links : []).filter((l) => l && typeof l.id === 'string' && typeof l.url === 'string' && l.url.startsWith(t.host + '/'))
|
|
85
|
+
.map((l) => ({ id: l.id, name: String(l.name || ''), kind: String(l.kind || ''), by: String(l.by || ''), made: l.made || '', ends: l.ends || '', views: Number(l.views) || 0 }));
|
|
86
|
+
return { team: t.name, host: new URL(t.host).host, ok: true, links };
|
|
87
|
+
}));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async function open(dir, team, id, opts = {}) {
|
|
91
|
+
const t = Host.readState(dir).teams.find((x) => x.name === team);
|
|
92
|
+
if (!t) return { ok: false, error: 'This computer has not joined that team.' };
|
|
93
|
+
const r = await call(t.host, 'POST', teamPath(team) + '/open/' + encodeURIComponent(id), t.password, opts.fetch);
|
|
94
|
+
if (!r.ok) return { ok: false, error: r.kind === 'password' ? 'The team password no longer works. Ask for a new invite link.' : r.error };
|
|
95
|
+
const url = r.body.url; if (typeof url !== 'string' || !url.startsWith(t.host + '/b/')) return { ok: false, error: 'The host sent an address this workspace does not accept.' };
|
|
96
|
+
return { ok: true, url };
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
module.exports = { parseInvite, join, leave, names, readAll, open, MAX_TEAMS };
|
|
@@ -5,6 +5,11 @@
|
|
|
5
5
|
* POST /api/board-publish { ws, board, select, team, password, days, shared_by } -> { ok, id, url, ends }
|
|
6
6
|
* POST /api/board-publish/republish { id } -> { ok, ends } the same selection, as the board is now; same link, same password
|
|
7
7
|
* POST /api/board-publish/off { id } -> { ok } the host deletes the copy at once
|
|
8
|
+
* POST /api/board-publish/host { host } -> { ok, host } save the host address ('' clears it); PMOS_BOARDS_HOST wins over it
|
|
9
|
+
* GET /api/board-publish/shared -> { ok, readAt, yours, teams } the Shared view: your links, and each joined team read now (lib/boards-teams.js)
|
|
10
|
+
* POST /api/board-publish/join { invite } or { host, team, password } -> { ok, team } verified with the host first; the password stays on this computer
|
|
11
|
+
* POST /api/board-publish/leave { team } -> { ok } forgets the team here
|
|
12
|
+
* POST /api/board-publish/open { team, id } -> { ok, url } a one-time address for a team member, opened in a browser tab
|
|
8
13
|
*
|
|
9
14
|
* EVERY POST IS A PAGE PRESS (pm-guard requirePagePress): only a press on the page publishes, not a request an agent session makes (PRD P2, D97 S3).
|
|
10
15
|
* THE SECRET SCAN runs on the finished pack before anything leaves (P3): a hit blocks the publish and the answer names the rule, never the text (D08).
|
|
@@ -17,6 +22,7 @@ const guard = require('./pm-guard.js');
|
|
|
17
22
|
const Host = require('./boards-host.js');
|
|
18
23
|
const shareStore = require('./share-store.js');
|
|
19
24
|
const secretScan = require('./secret-scan.js');
|
|
25
|
+
const Teams = require('./boards-teams.js');
|
|
20
26
|
|
|
21
27
|
const PUBLIC = path.join(__dirname, '..', 'public');
|
|
22
28
|
let versionMemo = null;
|
|
@@ -49,6 +55,16 @@ async function makePack(req, ctx, q) {
|
|
|
49
55
|
return { ok: true, pack: out.body.pack };
|
|
50
56
|
}
|
|
51
57
|
|
|
58
|
+
let byMemo = null;
|
|
59
|
+
/** The name shown as "shared by": PMOS_PM_NAME, else git's user.name on this computer, else the account name. The PM does not type it. */
|
|
60
|
+
function sharedBy() {
|
|
61
|
+
if (byMemo !== null) return byMemo;
|
|
62
|
+
let n = String(process.env.PMOS_PM_NAME || '').trim();
|
|
63
|
+
if (!n) { try { const r = require('child_process').spawnSync('git', ['config', '--global', 'user.name'], { encoding: 'utf8', timeout: 3000 }); n = String(r.stdout || '').trim(); } catch { /* none */ } }
|
|
64
|
+
if (!n) { try { n = require('os').userInfo().username; } catch { n = ''; } }
|
|
65
|
+
return (byMemo = n.slice(0, 60));
|
|
66
|
+
}
|
|
67
|
+
|
|
52
68
|
const kindOf = (pack) => (pack && pack.scope && pack.scope.kind) || 'multi';
|
|
53
69
|
const stateDir = (ctx) => ctx.runtimeDir;
|
|
54
70
|
|
|
@@ -57,14 +73,22 @@ module.exports = {
|
|
|
57
73
|
prefixes: ['/api/board-publish'],
|
|
58
74
|
handle: async (req, res, url, ctx) => {
|
|
59
75
|
const p = url.pathname;
|
|
60
|
-
if (
|
|
76
|
+
if (!/^\/api\/board-publish(\/(republish|off|host|shared|join|leave|open))?$/.test(p)) return false;
|
|
61
77
|
const send = (obj, code) => { ctx.json(res, obj, code); return true; };
|
|
62
78
|
const dir = stateDir(ctx);
|
|
63
79
|
if (!dir) return send({ ok: false, error: 'No state folder.' }, 500);
|
|
64
80
|
|
|
81
|
+
const env = Host.addressOf(dir); // the environment variable wins, so a computer set up by hand keeps working; else the address saved on the popover
|
|
65
82
|
if (req.method === 'GET' && p === '/api/board-publish') {
|
|
66
|
-
const origin = Host.hostOrigin();
|
|
67
|
-
|
|
83
|
+
const origin = Host.hostOrigin(env);
|
|
84
|
+
const ws = url.searchParams.get('ws'); let choices = null;
|
|
85
|
+
if (ws) { try { choices = await require('./board-publish-choices.js').choicesOf(req, ctx, ws, url.searchParams.get('board') || ws); } catch { choices = null; } }
|
|
86
|
+
return send({ ok: true, host: origin ? new URL(origin).host : null, days: Host.DAYS, password: shareStore.newPassword(), choices, teams: Teams.names(dir), links: Host.links(dir).map((l) => ({ id: l.id, url: l.url, team: l.team, name: l.name, kind: l.kind, by: l.by, made: l.made, ends: l.ends, views: l.views })) });
|
|
87
|
+
}
|
|
88
|
+
// the Shared view's read (slice 4): your own links and every joined team's list, read now from each host. Nothing is kept from the read.
|
|
89
|
+
if (req.method === 'GET' && p === '/api/board-publish/shared') {
|
|
90
|
+
const teams = await Teams.readAll(dir);
|
|
91
|
+
return send({ ok: true, readAt: new Date().toISOString(), yours: Host.links(dir).map((l) => ({ id: l.id, url: l.url, team: l.team, name: l.name, kind: l.kind, by: l.by, made: l.made, ends: l.ends, views: l.views })), teams });
|
|
68
92
|
}
|
|
69
93
|
if (req.method !== 'POST') return send({ ok: false, error: 'GET or POST only' }, 405);
|
|
70
94
|
|
|
@@ -75,8 +99,21 @@ module.exports = {
|
|
|
75
99
|
// D103 point 6 and PRD P2: a copy leaves this computer only on a press by the person. D98 lets an agent session take PM-only acts; this one it does not.
|
|
76
100
|
if (g.actor && /^agent/.test(String(g.actor.by || ''))) return send({ ok: false, error: 'Publishing is a press on the page. An agent session cannot publish, republish or turn off a board.' }, 403);
|
|
77
101
|
|
|
102
|
+
if (p === '/api/board-publish/join') { // a team is joined by a pasted invite link, or by host, team and password typed
|
|
103
|
+
const r = await Teams.join(dir, { invite: body.invite, host: body.host, team: body.team, password: body.password });
|
|
104
|
+
return send(r.ok ? { ok: true, team: r.team } : { ok: false, error: r.error, kind: r.kind }, r.ok ? 200 : (r.kind === 'locked' ? 429 : 400));
|
|
105
|
+
}
|
|
106
|
+
if (p === '/api/board-publish/leave') { const r = Teams.leave(dir, String(body.team || '')); return send(r.ok ? { ok: true } : { ok: false, error: 'This computer has not joined that team.' }, r.ok ? 200 : 404); }
|
|
107
|
+
if (p === '/api/board-publish/open') { // the one-time address of a team's board, to open in a browser tab
|
|
108
|
+
const r = await Teams.open(dir, String(body.team || ''), String(body.id || ''));
|
|
109
|
+
return send(r.ok ? { ok: true, url: r.url } : { ok: false, error: r.error }, r.ok ? 200 : 502);
|
|
110
|
+
}
|
|
111
|
+
if (p === '/api/board-publish/host') { // the address of the host, saved from the popover: a page press like the rest
|
|
112
|
+
const r = Host.setHost(dir, body.host);
|
|
113
|
+
return send(r.ok ? { ok: true, host: r.host } : { ok: false, error: r.error }, r.ok ? 200 : 400);
|
|
114
|
+
}
|
|
78
115
|
if (p === '/api/board-publish/off') {
|
|
79
|
-
const r = await Host.turnOff(dir, String(body.id || ''));
|
|
116
|
+
const r = await Host.turnOff(dir, String(body.id || ''), { env });
|
|
80
117
|
return send(r.ok ? { ok: true } : { ok: false, error: r.error }, r.ok ? 200 : (r.status || 502));
|
|
81
118
|
}
|
|
82
119
|
|
|
@@ -91,7 +128,7 @@ module.exports = {
|
|
|
91
128
|
} else {
|
|
92
129
|
const days = Number(body.days);
|
|
93
130
|
if (!Host.DAYS.includes(days)) return send({ ok: false, error: 'Ends in 1, 7 or 30 days.' }, 400);
|
|
94
|
-
sel = { ws: body.ws, board: body.board || body.ws, select: Array.isArray(body.select) ? body.select.map((s) => s.kind + ':' + s.id).join(',') : String(body.select || ''), by: String(body.shared_by || '').slice(0, 60), ends: new Date(now + days * 86400000).toISOString() };
|
|
131
|
+
sel = { ws: body.ws, board: body.board || body.ws, select: Array.isArray(body.select) ? body.select.map((s) => s.kind + ':' + s.id).join(',') : String(body.select || ''), by: String(body.shared_by || '').slice(0, 60) || sharedBy(), ends: new Date(now + days * 86400000).toISOString() };
|
|
95
132
|
}
|
|
96
133
|
const pk = await makePack(req, ctx, Object.assign({}, sel, { at: new Date(now).toISOString(), viewer: viewerVersion() }));
|
|
97
134
|
if (!pk.ok) return send({ ok: false, error: pk.error }, pk.status || 502);
|
|
@@ -99,11 +136,11 @@ module.exports = {
|
|
|
99
136
|
if (hits.length) return send({ ok: false, error: 'This board holds what looks like a secret (' + hits.join(', ') + '). Remove it, then publish again.', secrets: hits }, 422);
|
|
100
137
|
|
|
101
138
|
if (p === '/api/board-publish/republish') {
|
|
102
|
-
const r = await Host.republish(dir, meta.id, pk.pack);
|
|
139
|
+
const r = await Host.republish(dir, meta.id, pk.pack, { env });
|
|
103
140
|
return send(r.ok ? { ok: true, ends: r.ends } : { ok: false, error: r.error }, r.ok ? 200 : (r.status || 502));
|
|
104
141
|
}
|
|
105
142
|
const selection = Array.isArray(body.select) ? body.select.map((s) => ({ kind: String(s.kind), id: String(s.id) })) : String(body.select || '').split(',').filter(Boolean).map((s) => ({ kind: s.slice(0, s.indexOf(':')), id: s.slice(s.indexOf(':') + 1) }));
|
|
106
|
-
const r = await Host.publish(dir, { pack: pk.pack, team: body.team, name: pk.pack.scope.label, kind: kindOf(pk.pack), by: sel.by, days: Number(body.days), password: body.password == null ? '' : body.password, selection, ws: sel.ws, board: sel.board });
|
|
143
|
+
const r = await Host.publish(dir, { pack: pk.pack, team: body.team, name: pk.pack.scope.label, kind: kindOf(pk.pack), by: sel.by, days: Number(body.days), password: body.password == null ? '' : body.password, selection, ws: sel.ws, board: sel.board }, { env });
|
|
107
144
|
return send(r.ok ? { ok: true, id: r.id, url: r.url, ends: r.ends } : { ok: false, error: r.error }, r.ok ? 200 : (r.status || 502));
|
|
108
145
|
},
|
|
109
146
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.471.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pmos-workspace",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.471.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/* pm/bd-publish.css — the Publish popover (pm/bd-publish.js). It looks like the viewer's share popover (premium-vw-doc.css .vwshp): the same card, rows,
|
|
2
|
+
* switch, segmented control and Open links list. A bottom sheet on a phone. Design: prototype/board-publish/publish-popover-design.html. */
|
|
3
|
+
.bppop{position:absolute;right:0;top:calc(100% + 6px);z-index:30;width:360px;max-width:min(360px,calc(100vw - 32px));max-height:min(80vh,640px);overflow:auto;padding:8px;border-radius:12px;background:var(--card-solid);border:1px solid var(--hair);box-shadow:0 10px 30px rgb(0 0 0 / .14);color:var(--ink);font:inherit;text-align:left}
|
|
4
|
+
.bppop .i{width:16px;height:16px;flex:none;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;color:var(--ink-3)}
|
|
5
|
+
.bppop .bpeye{font:500 11px var(--mono);letter-spacing:.08em;text-transform:uppercase;color:var(--ink-3);padding:8px 8px 2px}
|
|
6
|
+
.bppop .bpchips{display:flex;flex-wrap:wrap;gap:6px;padding:2px 8px 6px}
|
|
7
|
+
.bppop .bpchip{display:inline-flex;align-items:center;gap:6px;min-height:36px;padding:0 12px;border-radius:99px;border:1px solid var(--hair);background:var(--card-solid);color:inherit;font:inherit;cursor:pointer}
|
|
8
|
+
.bppop .bpchip small{font:500 11px var(--mono);color:var(--ink-3)}
|
|
9
|
+
.bppop .bpchip[aria-pressed="true"]{border-color:var(--solid);color:var(--solid);font-weight:600;background:color-mix(in srgb,var(--solid) 10%,transparent)}
|
|
10
|
+
.bppop .bpchip.add{border-style:dashed}
|
|
11
|
+
.bppop .bpmenu{display:grid;margin:0 8px 6px;border:1px solid var(--hair);border-radius:8px;max-height:180px;overflow:auto}
|
|
12
|
+
.bppop .bpmenu button{min-height:40px;padding:0 12px;border:0;background:transparent;color:inherit;font:inherit;text-align:left;cursor:pointer}
|
|
13
|
+
.bppop .bpmenu button:hover{background:color-mix(in srgb, var(--ink) 6%, transparent)}
|
|
14
|
+
.bppop .bpfield{display:grid;gap:2px;padding:2px 8px}.bppop .bpfield>label{font-size:12px;color:var(--ink-3)}
|
|
15
|
+
.bppop .bpinp,.bppop .bpinp2{min-height:40px;border:1px solid var(--hair);border-radius:8px;background:var(--card-solid);color:inherit;font:inherit}
|
|
16
|
+
.bppop .bpinp{padding:0 12px;width:100%}
|
|
17
|
+
.bppop .bpinp2{display:flex;align-items:center;gap:8px;padding:0 6px 0 12px}.bppop .bpinp2 input{flex:1;min-width:0;border:0;background:transparent;color:inherit;font:500 12px var(--mono);outline:0;min-height:38px}
|
|
18
|
+
.bppop .bpline2{display:flex;align-items:center;gap:10px;min-height:40px;padding:2px 8px}.bppop .bpg{flex:1;min-width:0}
|
|
19
|
+
.bppop .bpsw{width:48px;height:40px;border:0;background:transparent;position:relative;cursor:pointer;flex:none;padding:0}
|
|
20
|
+
.bppop .bpsw::before{content:"";position:absolute;left:6px;top:9px;width:36px;height:22px;border-radius:99px;background:var(--hair)}
|
|
21
|
+
.bppop .bpsw::after{content:"";position:absolute;left:9px;top:12px;width:16px;height:16px;border-radius:50%;background:var(--card-solid)}
|
|
22
|
+
.bppop .bpsw[aria-checked="true"]::before{background:var(--solid)}.bppop .bpsw[aria-checked="true"]::after{left:auto;right:9px}
|
|
23
|
+
.bppop .bpseg{display:inline-flex;border:1px solid var(--hair);border-radius:8px;overflow:hidden}
|
|
24
|
+
.bppop .bpseg button{border:0;background:transparent;color:var(--ink-2);min-height:36px;padding:0 12px;font:inherit;cursor:pointer}
|
|
25
|
+
.bppop .bpseg button[aria-pressed="true"]{background:color-mix(in srgb, var(--ink) 6%, transparent);color:inherit;font-weight:600}
|
|
26
|
+
.bppop .bpbtn{display:inline-flex;align-items:center;justify-content:center;min-height:40px;padding:0 14px;border-radius:8px;border:1px solid var(--hair);background:var(--card-solid);color:inherit;font:600 14px inherit;font-family:inherit;cursor:pointer;text-decoration:none}
|
|
27
|
+
.bppop .bpbtn.pri{background:var(--solid);border-color:var(--solid);color:var(--on-solid)}
|
|
28
|
+
.bppop .bpbtn.sm{min-height:34px;padding:0 10px;font-size:12px}
|
|
29
|
+
.bppop .bpbtn.bad{color:var(--bad)}.bppop .bpbtn.bad.sure{background:color-mix(in srgb,var(--bad) 12%,transparent)}
|
|
30
|
+
.bppop .bpbtn:disabled{opacity:.55;cursor:default}
|
|
31
|
+
.bppop .bpgo{margin:6px 8px 2px;width:calc(100% - 16px)}
|
|
32
|
+
.bppop .bpnote{color:var(--ink-3);font-size:12px;padding:4px 8px;margin:0}
|
|
33
|
+
.bppop .bperr{margin:4px 8px;padding:8px 10px;border-radius:8px;background:color-mix(in srgb,var(--bad) 12%,transparent);color:var(--bad);font-size:14px}
|
|
34
|
+
.bppop .bplink{display:inline-flex;align-items:center;border:0;background:transparent;color:var(--solid);font:inherit;text-decoration:underline;cursor:pointer;padding:0 8px;min-height:36px}
|
|
35
|
+
.bppop .bpsep{height:1px;background:var(--hair);margin:8px 0 2px}
|
|
36
|
+
.bppop .bplnk{margin:2px 8px;padding:10px 12px;border-radius:8px;background:color-mix(in srgb, var(--ink) 6%, transparent);display:grid;gap:8px}
|
|
37
|
+
.bppop .bpline{display:flex;align-items:center;gap:8px}.bppop .bplnk code{font:500 12px var(--mono);overflow-wrap:anywhere}
|
|
38
|
+
.bppop .bpact{display:flex;gap:10px;align-items:center;flex-wrap:wrap}.bppop .bpok{color:var(--ink-2);font-size:14px}
|
|
39
|
+
.bppop .bprow{display:flex;align-items:center;gap:8px;padding:6px 8px}.bppop .bprow .bpg b{display:block;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
40
|
+
.bppop .bprow em{font-style:normal;color:var(--ink-3);font-size:12px}.bppop .bprow em.soon{color:var(--bad)}
|
|
41
|
+
.bppop .bpempty{display:grid;gap:10px;padding:12px 8px 10px;justify-items:start}.bppop .bpempty p{margin:0;color:var(--ink-2)}
|
|
42
|
+
.bppop :focus-visible{outline:2px solid var(--ember);outline-offset:2px}
|
|
43
|
+
#bdPublish{position:relative}#bdPublish .bpn{position:absolute;top:2px;right:0;min-width:16px;padding:0 5px;border-radius:99px;background:var(--solid);color:var(--on-solid);font:600 11px var(--mono);text-align:center;line-height:16px}
|
|
44
|
+
@media (max-width:640px){.bppop{position:fixed;left:0;right:0;bottom:0;top:auto;width:auto;max-width:none;max-height:85vh;border-radius:16px 16px 0 0;border-width:1px 0 0;padding:12px 12px calc(18px + env(safe-area-inset-bottom,0px));box-shadow:0 -8px 30px rgb(0 0 0 / .18)}}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/* pm/bd-publish.js — the Publish popover on the Board (initiative board-publish, slice 2, page side; planning/prd/board-publish-prd.md P1 to P5; D103).
|
|
2
|
+
* Design: prototype/board-publish/publish-popover-design.html (PM approved 2026-10-31). It makes a read-only copy of part of the Board and puts it on
|
|
3
|
+
* the team's host through POST /api/board-publish, which is a page press: only a press here publishes, never an agent session.
|
|
4
|
+
*
|
|
5
|
+
* What to share chips: this board's product, the programs that hold one of its initiatives, and any initiatives (the picker)
|
|
6
|
+
* Team optional, typed; the host says when there is no such team (slice 4 turns it into the list of joined teams)
|
|
7
|
+
* Password on by default with a generated one (GET /api/board-publish), the PM can change it or turn it off
|
|
8
|
+
* Ends 1, 7 or 30 days
|
|
9
|
+
* Link ready the link and the password, one Copy, shown once (the workspace does not keep the password)
|
|
10
|
+
* Open links only when there are any: Republish (same link, same password) and Turn off (a second press confirms)
|
|
11
|
+
* No host before the host address is set: one sentence and the address field. The note on the form has a Change button to set it again.
|
|
12
|
+
*
|
|
13
|
+
* open(btn, { ws, board }) the popover under the button (a sheet at the bottom on a phone)
|
|
14
|
+
* publishHtml(S) the popover's inside as HTML. Pure. COUNT(links) · refreshCount(btn) */
|
|
15
|
+
import { pmGet, pmPost } from './http.js';
|
|
16
|
+
|
|
17
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
18
|
+
const day = (iso) => { try { return new Date(iso).toLocaleDateString(undefined, { day: 'numeric', month: 'short' }); } catch { return ''; } };
|
|
19
|
+
const svg = (d) => `<svg class="i" viewBox="0 0 24 24" aria-hidden="true">${d}</svg>`;
|
|
20
|
+
const LOCK = svg('<rect x="5" y="11" width="14" height="10" rx="2"/><path d="M8 11V8a4 4 0 0 1 8 0v3"/>');
|
|
21
|
+
const LINK = svg('<path d="M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1"/>');
|
|
22
|
+
const PLUS = svg('<path d="M12 5v14M5 12h14"/>');
|
|
23
|
+
const SOON_MS = 36 * 3600 * 1000;
|
|
24
|
+
|
|
25
|
+
export const COUNT = (links) => (Array.isArray(links) ? links.length : 0);
|
|
26
|
+
const keyOf = (k, id) => k + ':' + id;
|
|
27
|
+
const chip = (S, kind, c, extra = '') => `<button type="button" class="bpchip" data-bp-sel="${esc(keyOf(kind, c.id))}" aria-pressed="${S.sel.has(keyOf(kind, c.id))}">${esc(c.label)} <small>${extra || kind}</small></button>`;
|
|
28
|
+
|
|
29
|
+
/** The popover's inside. S = { phase, host, days, choices, sel:Set, team, pw, pass, err, busy, made, links, off, iniOpen, copied, now } */
|
|
30
|
+
export function publishHtml(S) {
|
|
31
|
+
if (S.phase === 'loading') return '<p class="bpnote">Reading your board…</p>';
|
|
32
|
+
if (!S.host) {
|
|
33
|
+
return `<div class="bpempty"><b>Publishing needs a board host</b><p>Ask whoever runs it for its address and add it here once. Nothing is sent before that.</p></div>`
|
|
34
|
+
+ `<div class="bpfield"><label for="bpHost">Board host address</label><div class="bpinp2"><input id="bpHost" type="url" inputmode="url" spellcheck="false" autocomplete="off" placeholder="https://boards.example.com" value="${esc(S.hostIn || '')}"><button type="button" class="bpbtn sm pri" data-bp="savehost">Save</button></div></div>`
|
|
35
|
+
+ (S.err ? `<p class="bperr" role="alert">${esc(S.err)}</p>` : '');
|
|
36
|
+
}
|
|
37
|
+
const list = S.links && S.links.length
|
|
38
|
+
? `<div class="bpsep"></div><div class="bpeye">Open links · ${S.links.length}</div>` + S.links.map((l) => {
|
|
39
|
+
const soon = S.now && l.ends && Date.parse(l.ends) - S.now < SOON_MS;
|
|
40
|
+
return `<div class="bprow">${LOCK}<span class="bpg"><b>${esc(l.name || 'Board')}</b><em${soon ? ' class="soon"' : ''}>${l.team ? esc(l.team) + ' · ' : ''}ends ${esc(day(l.ends))}${l.views ? ' · ' + l.views + (l.views === 1 ? ' view' : ' views') : ''}</em></span>`
|
|
41
|
+
+ `<button type="button" class="bpbtn sm" data-bp-re="${esc(l.id)}"${S.busy ? ' disabled' : ''}>Republish</button>`
|
|
42
|
+
+ `<button type="button" class="bpbtn sm bad${S.off === l.id ? ' sure' : ''}" data-bp-off="${esc(l.id)}">${S.off === l.id ? 'Sure? Turn off' : 'Turn off'}</button></div>`;
|
|
43
|
+
}).join('') : '';
|
|
44
|
+
if (S.made) {
|
|
45
|
+
return `<div class="bpeye">Link ready</div><div class="bplnk"><div class="bpline">${LINK}<code>${esc(S.made.url)}</code></div>`
|
|
46
|
+
+ (S.made.pass ? `<div class="bpline">${LOCK}<code>${esc(S.made.pass)}</code></div>` : '')
|
|
47
|
+
+ `<div class="bpact"><button type="button" class="bpbtn pri" data-bp="copy">${S.made.pass ? 'Copy link and password' : 'Copy link'}</button><span class="bpok" role="status">${esc(S.copied || '')}</span></div></div>`
|
|
48
|
+
+ `<p class="bpnote">${esc(S.made.name)}${S.made.team ? ' · for the ' + esc(S.made.team) + ' team' : ''} · ends ${esc(day(S.made.ends))}.${S.made.pass ? ' Send the password in a different message. This is the only time it is shown.' : ''}</p>`
|
|
49
|
+
+ `<button type="button" class="bpbtn bpgo" data-bp="done">Done</button>` + list;
|
|
50
|
+
}
|
|
51
|
+
const c = S.choices || { products: [], programs: [], initiatives: [] };
|
|
52
|
+
const picked = c.initiatives.filter((i) => S.sel.has(keyOf('initiative', i.id)));
|
|
53
|
+
const chips = c.products.map((p) => chip(S, 'product', p)).join('') + c.programs.map((p) => chip(S, 'program', p)).join('') + picked.map((i) => chip(S, 'initiative', i)).join('')
|
|
54
|
+
+ (c.initiatives.length ? `<button type="button" class="bpchip add" data-bp="ini" aria-expanded="${!!S.iniOpen}">${PLUS}An initiative</button>` : '');
|
|
55
|
+
const menu = S.iniOpen ? `<div class="bpmenu" role="menu">${c.initiatives.filter((i) => !S.sel.has(keyOf('initiative', i.id))).map((i) => `<button type="button" role="menuitem" data-bp-add="${esc(i.id)}">${esc(i.label)}</button>`).join('') || '<p class="bpnote">Every initiative is picked.</p>'}</div>` : '';
|
|
56
|
+
return `<div class="bpeye">What to share</div><div class="bpchips">${chips}</div>${menu}`
|
|
57
|
+
+ `<div class="bpfield"><label for="bpTeam">Team</label><input id="bpTeam" class="bpinp" type="text" maxlength="40" autocomplete="off" placeholder="None" value="${esc(S.team)}"></div>`
|
|
58
|
+
+ `<div class="bpline2">${LOCK}<span class="bpg">Password</span><button type="button" class="bpsw" role="switch" aria-checked="${S.pw}" aria-label="Password" data-bp="pw"></button></div>`
|
|
59
|
+
+ (S.pw ? `<div class="bpfield"><div class="bpinp2"><input id="bpPass" type="text" spellcheck="false" autocomplete="off" aria-label="Password" value="${esc(S.pass)}"><button type="button" class="bpbtn sm" data-bp="newpw">New</button></div></div>` : '')
|
|
60
|
+
+ `<div class="bpline2"><span class="bpg">Ends</span><div class="bpseg" role="group" aria-label="Link ends after">${[1, 7, 30].map((d) => `<button type="button" data-bp-days="${d}" aria-pressed="${S.days === d}">${d === 1 ? '1 day' : d + ' days'}</button>`).join('')}</div></div>`
|
|
61
|
+
+ `<p class="bpnote">Sends a read-only copy of today's board to ${esc(S.host)}. It holds titles, stages, dates, owners and task names. <button type="button" class="bplink" data-bp="changehost">Change</button></p>`
|
|
62
|
+
+ (S.err ? `<p class="bperr" role="alert">${esc(S.err)}</p>` : '')
|
|
63
|
+
+ `<button type="button" class="bpbtn pri bpgo" data-bp="make"${S.busy || !S.sel.size ? ' disabled' : ''}>${S.busy ? 'Publishing…' : 'Publish'}</button>`
|
|
64
|
+
+ (S.busy ? '<p class="bpnote" role="status">Checking for secrets, then sending…</p>' : '') + list;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function css() {
|
|
68
|
+
for (const href of ['/pm/premium-vw-doc.css', '/pm/bd-publish.css']) {
|
|
69
|
+
if (document.querySelector(`link[href="${href}"]`)) continue;
|
|
70
|
+
const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = href; document.head.appendChild(l);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Show the number of open links on the button, and nothing when there are none (zero is silence). */
|
|
75
|
+
export async function refreshCount(btn) {
|
|
76
|
+
const n = btn && btn.querySelector('.bpn'); if (!n) return;
|
|
77
|
+
const r = await pmGet('/api/board-publish').catch(() => null); const c = r && r.ok ? COUNT(r.links) : 0;
|
|
78
|
+
n.textContent = c ? String(c) : ''; n.hidden = !c;
|
|
79
|
+
document.dispatchEvent(new CustomEvent('bd:links', { detail: { n: c } })); // the Shared tab's number follows your own links until it has read the teams
|
|
80
|
+
btn.setAttribute('aria-label', 'Publish a read-only copy of the board' + (c ? '. ' + c + (c === 1 ? ' open link' : ' open links') : ''));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function open(btn, ctx) {
|
|
84
|
+
const old = document.querySelector('.bppop');
|
|
85
|
+
if (old) { old.remove(); btn.setAttribute('aria-expanded', 'false'); return; }
|
|
86
|
+
css();
|
|
87
|
+
const S = { phase: 'loading', host: null, days: 7, choices: null, sel: new Set(), team: '', pw: true, pass: '', err: '', busy: false, made: null, links: [], off: null, iniOpen: false, copied: '', now: Date.now() };
|
|
88
|
+
const m = document.createElement('div');
|
|
89
|
+
m.className = 'bppop'; m.setAttribute('role', 'dialog'); m.setAttribute('aria-label', 'Publish a read-only copy of the board'); m.dataset.escLayer = '1';
|
|
90
|
+
const close = (focus) => { document.removeEventListener('keydown', onKey, true); document.removeEventListener('pointerdown', onOut, true); m.remove(); btn.setAttribute('aria-expanded', 'false'); if (focus) btn.focus(); };
|
|
91
|
+
const onKey = (e) => { if (e.key === 'Escape' && m.isConnected) { e.stopPropagation(); close(true); } };
|
|
92
|
+
const onOut = (e) => { if (m.isConnected && !m.contains(e.target) && !btn.contains(e.target)) close(false); };
|
|
93
|
+
const draw = (focus) => {
|
|
94
|
+
const keep = { team: m.querySelector('#bpTeam'), pass: m.querySelector('#bpPass'), host: m.querySelector('#bpHost') };
|
|
95
|
+
if (keep.team) S.team = keep.team.value; if (keep.pass) S.pass = keep.pass.value; if (keep.host) S.hostIn = keep.host.value;
|
|
96
|
+
m.innerHTML = publishHtml(S);
|
|
97
|
+
const f = focus && m.querySelector(focus); if (f) f.focus();
|
|
98
|
+
};
|
|
99
|
+
const load = async () => {
|
|
100
|
+
const q = '/api/board-publish?ws=' + encodeURIComponent(ctx.ws) + '&board=' + encodeURIComponent(ctx.board || ctx.ws);
|
|
101
|
+
const r = await pmGet(q).catch(() => null);
|
|
102
|
+
if (!r || !r.ok) { S.phase = 'form'; S.err = (r && r.error) || 'The workspace did not answer. Try again.'; return draw(); }
|
|
103
|
+
S.phase = 'form'; S.host = r.host; S.links = r.links || []; S.choices = r.choices; if (!S.pass) S.pass = r.password || ''; S.now = Date.now();
|
|
104
|
+
if (!S.sel.size && S.choices && S.choices.products[0]) S.sel.add(keyOf('product', S.choices.products[0].id));
|
|
105
|
+
draw(); refreshCount(btn);
|
|
106
|
+
};
|
|
107
|
+
m.onclick = async (e) => {
|
|
108
|
+
e.stopPropagation();
|
|
109
|
+
const b = e.target.closest('button, a'); if (!b) return;
|
|
110
|
+
if (b.dataset.bpSel) { const k = b.dataset.bpSel; if (S.sel.has(k)) S.sel.delete(k); else S.sel.add(k); S.err = ''; return draw(`[data-bp-sel="${CSS.escape(k)}"]`); }
|
|
111
|
+
if (b.dataset.bpDays) { S.days = Number(b.dataset.bpDays); return draw(`[data-bp-days="${S.days}"]`); }
|
|
112
|
+
if (b.dataset.bpAdd) { S.sel.add(keyOf('initiative', b.dataset.bpAdd)); S.iniOpen = false; return draw('[data-bp="ini"]'); }
|
|
113
|
+
const act = b.dataset.bp;
|
|
114
|
+
if (act === 'changehost') { S.host = null; S.hostIn = ''; S.err = ''; return draw('#bpHost'); }
|
|
115
|
+
if (act === 'savehost') {
|
|
116
|
+
const v = ((m.querySelector('#bpHost') || {}).value || '').trim(); S.hostIn = v; S.err = '';
|
|
117
|
+
const r = await pmPost('/api/board-publish/host', { host: v }).catch(() => null);
|
|
118
|
+
if (!r || !r.ok) { S.err = (r && r.error) || 'The address was not saved.'; return draw('#bpHost'); }
|
|
119
|
+
S.phase = 'loading'; draw(); return load();
|
|
120
|
+
}
|
|
121
|
+
if (act === 'ini') { S.iniOpen = !S.iniOpen; return draw('[data-bp="ini"]'); }
|
|
122
|
+
if (act === 'pw') { S.pw = !S.pw; return draw('[data-bp="pw"]'); }
|
|
123
|
+
if (act === 'newpw') { const r = await pmGet('/api/board-publish').catch(() => null); if (r && r.ok) S.pass = r.password; return draw('#bpPass'); }
|
|
124
|
+
if (act === 'done') { S.made = null; S.err = ''; S.copied = ''; S.pass = ''; return load(); }
|
|
125
|
+
if (act === 'copy') {
|
|
126
|
+
const text = S.made.pass ? S.made.url + '\nPassword: ' + S.made.pass : S.made.url;
|
|
127
|
+
try { await navigator.clipboard.writeText(text); S.copied = 'Copied'; } catch { S.copied = 'Select the text and copy it'; }
|
|
128
|
+
return draw('[data-bp="copy"]');
|
|
129
|
+
}
|
|
130
|
+
if (act === 'make') {
|
|
131
|
+
draw(); if (S.busy) return; S.busy = true; S.err = ''; draw();
|
|
132
|
+
const select = [...S.sel].map((k) => { const i = k.indexOf(':'); return { kind: k.slice(0, i), id: k.slice(i + 1) }; });
|
|
133
|
+
const r = await pmPost('/api/board-publish', { ws: ctx.ws, board: ctx.board || ctx.ws, select, team: S.team.trim(), password: S.pw ? S.pass : '', days: S.days }).catch(() => null);
|
|
134
|
+
S.busy = false;
|
|
135
|
+
if (r && r.ok) { const l = (await pmGet('/api/board-publish').catch(() => null)) || {}; S.links = l.links || S.links; S.made = { url: r.url, pass: S.pw ? S.pass : '', ends: r.ends, team: S.team.trim(), name: (S.links.find((x) => x.id === r.id) || {}).name || 'Board' }; S.pass = ''; S.err = ''; draw('[data-bp="copy"]'); return refreshCount(btn); }
|
|
136
|
+
S.err = (r && r.error) || 'The workspace did not answer. Try again.'; return draw();
|
|
137
|
+
}
|
|
138
|
+
if (b.dataset.bpRe) {
|
|
139
|
+
S.busy = true; S.err = ''; draw(); const r = await pmPost('/api/board-publish/republish', { id: b.dataset.bpRe }).catch(() => null); S.busy = false;
|
|
140
|
+
S.err = r && r.ok ? '' : (r && r.error) || 'The workspace did not answer. Try again.'; const l = await pmGet('/api/board-publish').catch(() => null); if (l && l.ok) S.links = l.links; return draw();
|
|
141
|
+
}
|
|
142
|
+
if (b.dataset.bpOff) {
|
|
143
|
+
if (S.off !== b.dataset.bpOff) { S.off = b.dataset.bpOff; return draw(`[data-bp-off="${CSS.escape(S.off)}"]`); }
|
|
144
|
+
const r = await pmPost('/api/board-publish/off', { id: S.off }).catch(() => null);
|
|
145
|
+
if (r && r.ok) S.links = S.links.filter((x) => x.id !== S.off); else S.err = (r && r.error) || 'The link could not be turned off.';
|
|
146
|
+
S.off = null; draw(); return refreshCount(btn);
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
btn.parentElement.appendChild(m); btn.setAttribute('aria-expanded', 'true');
|
|
150
|
+
document.addEventListener('keydown', onKey, true); document.addEventListener('pointerdown', onOut, true);
|
|
151
|
+
draw(); load();
|
|
152
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/* pm/bd-shared.css — the Shared tab of the Board (pm/bd-shared.js). The chips row, the table, the pills, the avatars and the buttons are the Board's own
|
|
2
|
+
* (cozy-board.css: .bd-dchips, .bd-dtw, .bd-dt, .bd-pill, .bd-av, .bd-btn); this file only sets the columns of the table and the join form. */
|
|
3
|
+
#cShared .bd-dt { grid-template-columns: 40px minmax(0, 1.5fr) 96px 96px minmax(0, 1fr) 84px 70px 130px 190px; }
|
|
4
|
+
#cShared .bd-dby { display: flex; gap: 6px; justify-content: flex-end; overflow: visible; }
|
|
5
|
+
#cShared .bdsh-gone { opacity: .5; }
|
|
6
|
+
#cShared .bdsh-cards { display: none; }
|
|
7
|
+
#cShared .bd-btn.on { border-color: var(--bad); color: var(--bad); }
|
|
8
|
+
#cShared .bdsh-join { display: grid; gap: 12px; padding: 22px 8px 14px; justify-items: start; max-width: 560px; }
|
|
9
|
+
#cShared .bdsh-join > b { font-size: var(--fs-4); font-weight: 800; }
|
|
10
|
+
#cShared .bdsh-join p { margin: 0; }
|
|
11
|
+
#cShared .bdsh-fr { display: flex; gap: 8px; width: 100%; max-width: 520px; }
|
|
12
|
+
#cShared .bdsh-in { flex: 1; min-width: 0; min-height: 44px; padding: 0 14px; border: 1px solid var(--hair); border-radius: 12px; background: var(--card-solid); color: var(--ink); font: inherit; width: 100%; max-width: 520px; }
|
|
13
|
+
#cShared .bdsh-fr .bdsh-in { width: auto; }
|
|
14
|
+
#cShared .bdsh-go { min-height: 44px; background: var(--solid); color: var(--on-solid); border-color: var(--solid); }
|
|
15
|
+
#cShared .bdsh-go:disabled { opacity: .6; }
|
|
16
|
+
#cShared .bdsh-alt, #cShared .bdsh-lk { border: 0; background: none; color: inherit; font: inherit; text-decoration: underline; cursor: pointer; min-height: 36px; padding: 0 2px; }
|
|
17
|
+
#cShared .bdsh-fine { font-size: var(--fs-1); margin: 8px 4px 0; }
|
|
18
|
+
#cShared .bdsh-pad { padding: 24px 8px; margin: 0; max-width: 560px; }
|
|
19
|
+
#cShared .bdsh-ban { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 10px 16px; margin: 8px 0; border: 1px solid var(--hair); border-radius: 14px; background: var(--card-solid); }
|
|
20
|
+
#cShared .bdsh-ban > span { flex: 1 1 240px; min-width: 0; }
|
|
21
|
+
#cShared .bdsh-tl { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 8px; }
|
|
22
|
+
#cShared :focus-visible { outline: 2px solid var(--ember); outline-offset: 2px; }
|
|
23
|
+
@media (max-width: 720px) {
|
|
24
|
+
#cShared .bdsh-table { display: none; }
|
|
25
|
+
#cShared .bdsh-cards { display: block; }
|
|
26
|
+
#cShared .bdsh-card { padding: 10px 4px; border-bottom: 1px solid var(--hair); display: grid; gap: 2px; }
|
|
27
|
+
#cShared .bdsh-l1 { display: flex; gap: 8px; align-items: baseline; }
|
|
28
|
+
#cShared .bdsh-nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
|
|
29
|
+
#cShared .bdsh-act { display: flex; gap: 8px; padding-top: 6px; }
|
|
30
|
+
#cShared .bdsh-fr { flex-wrap: wrap; }
|
|
31
|
+
}
|