fix(webui): the workflows read leaves out system-only templates
The workflows read listed the triage template, which only the client hid. The read handler now drops every template the organization vocabulary marks system-only, and the Console's read supplier in cli.mjs drops them too. The client filter stays. (#1873, lane triage-followups)
This commit is contained in:
1 parent
0354452971
commit
b7649ecd73
4 files changed
+15
-9
No files matched your search
@@ -39,7 +39,7 @@ import { composeSnapshot, readSystemConfig, readOrgConfig } from './triage-snaps
|
||||
import { busesStopped } from '../../cli/src/proxy-admin-host.mjs';
|
||||
import { agentLevelsWriteRoutes } from './agent-levels-write.mjs';
|
||||
import { RESTART_EXIT } from '../../cli/src/org-console.mjs';
|
||||
import { ID_PATTERN } from '../../organization/src/vocabulary.mjs';
|
||||
import { ID_PATTERN, systemOnly } from '../../organization/src/vocabulary.mjs';
|
||||
import { selectorScope } from '../../organization/src/selector.mjs';
|
||||
// The bus verifies the Console's exact same-tree script in /proc, whose argv preserves a
|
||||
// relative shell argument even though Node's process.argv resolves it. Re-exec the same
|
||||
@@ -204,8 +204,9 @@ try {
|
||||
// and the preview are reads over requestRead.
|
||||
templatesWrite: session.user === undefined && sendOn ? templatesCaller(consoleCall({ dataRoot: root, socket: paths.socket, business: id })) : null,
|
||||
// Starter packs SP6 (#1873): the owner's workflow read, the organization file and its revision as the
|
||||
// writer reads them (the read `mosaic org workflow set` takes its revision from), and the V2 template names.
|
||||
workflowsRead: session.user === undefined ? () => ({ ...organizationWriter({ dir: configDir(), rolesDir: rolesDir() }).read(id), templates: templateHashes(rolesDir()).map(t => t.template) }) : null,
|
||||
// writer reads them (the read `mosaic org workflow set` takes its revision from), and the V2 template names
|
||||
// less the system-only ones.
|
||||
workflowsRead: session.user === undefined ? () => ({ ...organizationWriter({ dir: configDir(), rolesDir: rolesDir() }).read(id), templates: templateHashes(rolesDir()).map(t => t.template).filter(t => !systemOnly(t)) }) : null,
|
||||
reads: consoleReads({ root: REPO, queueRoot: options.checkout ?? REPO, system, configDir: configDir(), rolesDir: rolesDir(), business: id, orgRoot: root }),
|
||||
};
|
||||
},
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
// console cap alone, and runs the merge, the digest and the held-credential check itself. `workflows`
|
||||
// (SP6) is the owner's read of the organization file as the writer reads it ({document, revision,
|
||||
// templates}), the same read `mosaic org workflow set` takes its revision from; no bus verb answers it.
|
||||
import { systemOnly } from '../../organization/src/vocabulary.mjs';
|
||||
|
||||
export const PACKS_ROUTE = /^\/api\/(?:packs(?:\/(preview|apply|hire))?|board|workflows(?:\/([^/]+))?)$/;
|
||||
// Which requests the pack route answers. GET and HEAD /api/board stay the Board read (the Console's own task
|
||||
// board through its upstream); every other method on /api/board is this route's (POST writes, the rest 405).
|
||||
@@ -171,7 +173,8 @@ async function workflowsRead(res, { workflows, live, session, writable }) {
|
||||
}
|
||||
const roles = {
|
||||
definitions: Object.keys(plain(doc.definitions) ? doc.definitions : {}).sort(),
|
||||
templates: current.templates.filter(n => typeof n === 'string').sort(),
|
||||
// #1873 triage-followups: a system-only template (organization vocabulary SYSTEM_ONLY) is never offered.
|
||||
templates: current.templates.filter(n => typeof n === 'string' && !systemOnly(n)).sort(),
|
||||
};
|
||||
return json(res, 200, { workflows: flowsOf(doc), projects, roles, revision: current.revision, writable });
|
||||
}
|
||||
@@ -40,8 +40,8 @@
|
||||
return value;
|
||||
}
|
||||
const plain = v => v !== null && typeof v === 'object' && !Array.isArray(v);
|
||||
// #1873: the templates no organization may hold (organization vocabulary SYSTEM_ONLY). The read may still
|
||||
// list them; a step role never resolves to one and the picker never offers one.
|
||||
// #1873: the templates no organization may hold (organization vocabulary SYSTEM_ONLY). The server leaves
|
||||
// them out of the read; this filter stays so a step role never resolves to one and the picker never offers one.
|
||||
const SYSTEM_ONLY = ['triage'];
|
||||
const offered = list => (list || []).filter(r => !SYSTEM_ONLY.includes(r));
|
||||
async function read(org, s) {
|
||||
|
||||
@@ -262,8 +262,10 @@ test('SP6 GET /workflows returns the org and code-project workflows, the role na
|
||||
assert.deepEqual(body.projects, Object.fromEntries(Object.entries(doc.projects).map(([id, p]) => [id, p.workflows ?? {}])));
|
||||
assert.deepEqual(body.projects.stack, doc.projects.stack.workflows);
|
||||
assert.deepEqual(body.roles.definitions, ['triage']);
|
||||
assert.deepEqual(body.roles.templates, templateHashes(join(f.root, 'roles')).map(x => x.template).sort());
|
||||
assert.ok(body.roles.templates.includes('coder') && !body.roles.templates.includes('ghost'));
|
||||
// #1873 triage-followups: the shipped triage template is system-only, so the read leaves it out.
|
||||
assert.ok(templateHashes(join(f.root, 'roles')).some(x => x.template === 'triage'), 'the fixture ships the triage template');
|
||||
assert.deepEqual(body.roles.templates, templateHashes(join(f.root, 'roles')).map(x => x.template).filter(n => n !== 'triage').sort());
|
||||
assert.ok(body.roles.templates.includes('coder') && !body.roles.templates.includes('ghost') && !body.roles.templates.includes('triage'));
|
||||
assert.equal(body.revision, createHash('sha256').update(readFileSync(f.file)).digest('hex'), 'the revision is the writer\'s: the hash of the file bytes');
|
||||
assert.equal(body.writable, true);
|
||||
assert.equal(JSON.stringify(body).includes(f.root), false, 'no host path leaves');
|
||||
@@ -283,7 +285,7 @@ test('SP6 GET /workflows returns the org and code-project workflows, the role na
|
||||
|
||||
test('SP6 GET /workflows leaves out a library project and answers outcome-unknown for a read it cannot trust', async t => {
|
||||
const REV = 'a'.repeat(64);
|
||||
const read = { document: { projects: { code: { workflows: { w: FLOW('W') } }, lib: { kind: 'library', workflows: { never: FLOW('N') } }, bare: {} } }, revision: REV, templates: ['coder', 7] };
|
||||
const read = { document: { projects: { code: { workflows: { w: FLOW('W') } }, lib: { kind: 'library', workflows: { never: FLOW('N') } }, bare: {} } }, revision: REV, templates: ['coder', 7, 'triage'] };
|
||||
const f = await fixture(t, { workflows: () => read });
|
||||
const [status, body] = await call(f, `${ORG}/workflows`);
|
||||
assert.equal(status, 200, JSON.stringify(body));
|
||||
|
||||
Reference in new issue
Block a user