Skip to content

Commit 2cbd4e5

Browse files
committed
fix(ui): runs launched in the mock carry their location and target
1 parent 6d34620 commit 2cbd4e5

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

‎ui/src/lib/api/mock/operate-store.ts‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -564,18 +564,18 @@ export class MockOperate {
564564
if (job?.kind === 'group') {
565565
const members = this.#children(source).filter((c) => mode === 'all' || affected(c).length);
566566
if (!members.length) throw new ApiError('Nothing to rerun: no node failed or was skipped', 409);
567-
const parent = this.#create({ id, origin: 'rerun', jobKey: job.key, rerunOf: runId, by: user, select: [], exclude: [], flags: {}, nodes: [], priority: job.priority });
567+
const parent = this.#create(scope, { id, origin: 'rerun', jobKey: job.key, rerunOf: runId, by: user, select: [], exclude: [], flags: {}, nodes: [], priority: job.priority });
568568
members.forEach((c, i) => {
569569
const nodes = mode === 'all' ? c.script.nodes : affected(c);
570-
this.#create({ id: `${id}-${i + 1}`, origin: 'rerun', jobKey: c.run.jobKey, parent: id, rerunOf: c.run.id, by: user, select: mode === 'all' ? c.script.select : nodes, exclude: mode === 'all' ? c.script.exclude : [], flags: c.script.flags, nodes, priority: job.priority });
570+
this.#create(scope, { id: `${id}-${i + 1}`, origin: 'rerun', jobKey: c.run.jobKey, parent: id, rerunOf: c.run.id, by: user, select: mode === 'all' ? c.script.select : nodes, exclude: mode === 'all' ? c.script.exclude : [], flags: c.script.flags, nodes, priority: job.priority });
571571
});
572572
parent.run.childRunCount = members.length;
573573
this.#ctx.changes.emit('runs');
574574
return this.#ctx.reply(this.#view(parent, scope));
575575
}
576576
const nodes = mode === 'all' ? source.script.nodes : affected(source);
577577
if (!nodes.length) throw new ApiError('Nothing to rerun: no node failed or was skipped', 409);
578-
const rec = this.#create({
578+
const rec = this.#create(scope, {
579579
id,
580580
origin: 'rerun',
581581
jobKey: source.run.jobKey,
@@ -609,10 +609,10 @@ export class MockOperate {
609609
const id = this.#newId();
610610
if (job.kind === 'group') {
611611
if (options.select?.length || options.exclude?.length) throw new ApiError('invalid control-plane data: a job group cannot be narrowed; narrow one of its jobs', 400);
612-
const parent = this.#create({ id, origin: 'manual', jobKey: key, by: user, select: [], exclude: [], flags, nodes: [], priority: job.priority });
612+
const parent = this.#create(scope, { id, origin: 'manual', jobKey: key, by: user, select: [], exclude: [], flags, nodes: [], priority: job.priority });
613613
job.members.forEach((m, i) => {
614614
const member = jobDef(m)!;
615-
this.#create({ id: `${id}-${i + 1}`, origin: 'manual', jobKey: m, parent: id, by: user, select: selectorTerms(member), exclude: member.exclude, flags: { ...flags, ...Object.fromEntries(Object.entries(member.settings).map(([k, v]) => [k, v === true ? true : String(v)])) }, nodes: jobNodes(m), priority: job.priority });
615+
this.#create(scope, { id: `${id}-${i + 1}`, origin: 'manual', jobKey: m, parent: id, by: user, select: selectorTerms(member), exclude: member.exclude, flags: { ...flags, ...Object.fromEntries(Object.entries(member.settings).map(([k, v]) => [k, v === true ? true : String(v)])) }, nodes: jobNodes(m), priority: job.priority });
616616
});
617617
parent.run.childRunCount = job.members.length;
618618
this.#ctx.changes.emit('runs');
@@ -624,7 +624,7 @@ export class MockOperate {
624624
const nodes = jobNodes(key).filter((n) => (!options.select?.length || named(options.select, n)) && !named(options.exclude, n));
625625
if (narrowed && !nodes.length) throw new ApiError("invalid control-plane data: the selectors leave none of the job's nodes", 400);
626626
const narrowing = narrowed ? { select: options.select ?? [], exclude: options.exclude ?? [] } : null;
627-
const rec = this.#create({ id, origin: 'manual', jobKey: key, narrowing, by: user, select: selectorTerms(job), exclude: job.exclude, flags, nodes, priority: job.priority });
627+
const rec = this.#create(scope, { id, origin: 'manual', jobKey: key, narrowing, by: user, select: selectorTerms(job), exclude: job.exclude, flags, nodes, priority: job.priority });
628628
this.#ctx.changes.emit('runs');
629629
return this.#ctx.reply(this.#view(rec, scope));
630630
}
@@ -639,7 +639,7 @@ export class MockOperate {
639639
const denied = check.permissions.find((p) => !p.allowed);
640640
if (denied) throw new ApiError(denied.reason ?? `missing ${denied.action} permission for this target`, 403);
641641
const parts = parseCommand(request.command.join(' '));
642-
const rec = this.#create({
642+
const rec = this.#create(scope, {
643643
id: this.#newId(),
644644
origin: 'manual',
645645
jobKey: null,
@@ -1016,7 +1016,7 @@ export class MockOperate {
10161016
return id;
10171017
}
10181018

1019-
#create(spec: {
1019+
#create(scope: Scope, spec: {
10201020
id: string;
10211021
origin: Run['origin'];
10221022
jobKey: string | null;
@@ -1055,8 +1055,8 @@ export class MockOperate {
10551055
requestedBy: spec.by,
10561056
priority: spec.priority,
10571057
rewriteHistory: Object.keys(spec.flags).some((f) => flagSpec(spec.verb ?? 'build', f)?.requires === 'run.rewrite_history'),
1058-
locationId: '',
1059-
target: '',
1058+
locationId: scope.locationId,
1059+
target: this.#ctx.target(scope),
10601060
snapshotId: 'snap-7d2e41a',
10611061
gitRevision: '7d2e41a',
10621062
queuedAt: now,

0 commit comments

Comments
 (0)