Skip to content

Commit fe75349

Browse files
fix(approvals): name an unstaffed position by its label on the timeline; system rows read as the system's (#36030)
<!-- claude-projects-attribution: {"github_login":"os-sales"} --> _Requested by **Sales** · [project thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4Uu9E1xEXQLqcywxKaDrDfGYv)_ repo:objectstack#1 · os-sales · session_01L6bhgT9mNgD8oKM93bFzg5 Fixes #35418 Clause-②: yes (widening) — @objectstack/plugin-approvals adds the optional `ApprovalServiceOptions.positionLabelSource`; @object-ui/i18n adds approvalsInbox.systemActor and approvalsInbox.actSystemNote; nothing removed Metadata-protocol: none ## 维护者速读 - 审批动态里「转交给管理员」那条说明不再出现内部岗位名:中文读者看到「岗位「销售经理」无人任职」,没有翻译时用岗位自己的显示名,都没有才退回内部名。 - 系统自动写的条目(转交说明、排除提交人、无人可审、自动撤销等)操作人显示「系统」,说明类条目类型显示「系统说明」,不再是「评论 · —」;真人评论照旧是「评论 · 某人」。 - 属于「控制台核心业务操作体验」专题;只改显示,库里存的审计原文、转交规则都不动,出问题可直接撤回。 - 已知没做:「无人可审」说明里的「担任 position 'x' 的成员」也带内部岗位名(存的是拼好的整句),列为后续,不在本 PR。 ## What changes 1. **The routing note names a position by its label.** `admin-rescue-note.ts`: `adminRescueNoteText(note, render, positionLabel?)` maps each unheld-position clause's `value` through `positionLabel` before rendering; `adminRescuePositions` lists the note's position names. `ApprovalService.localizeRoutingNotes` builds the map per read (`notePositionLabels`): the reader's pack `positions.<name>.label` (new `ReaderLabels.positionLabel`, key spelled by `positionLabelKey` beside the flow keys), else the declared `label` from the new optional `ApprovalServiceOptions.positionLabelSource`, else nothing (the name stands). `ApprovalsServicePlugin` wires that source to the `metadata` service's `get('position', name)`, resolved lazily like the i18n source. A throwing source is caught: the read never fails on a label. The row's stored English `comment` (the audit text, and what a read with no locale is served) is unchanged and keeps the name. 2. **The timeline names the platform's rows.** `ApprovalActionTimeline.tsx`: a row with no `actor_id` reads its actor as `approvalsInbox.systemActor` ("System" / 系统) instead of "—"; a `comment` row with no actor (`isSystemNote`, new `utils/approvalSystemNote.ts`) reads its kind as `approvalsInbox.actSystemNote` ("System note" / 系统说明) instead of "Commented". `system:sla` keeps "System (SLA)". New keys in all eleven packs, translated. 3. **Docs.** `content/docs/automation/approvals.mdx`, "When a slate names no one": the stored note keeps the English with the position's name; a reader is served it in their language with the position's label, shown as a system note (the Docs Drift Check listed this page). The card allowed 「转交」 or 「系统」 for the kind. The three no-actor comment notes are not all hand-offs (admin routing, submitter exclusion, no approver), and telling them apart on the client would need a new field on the actions contract, so they share "System note" and the sentence itself says what happened. This reading was stated in the claim. ## Tests <details><summary>Approvals plugin</summary> - `admin-rescue-note.test.ts`: a position clause takes the label it is given and only a position does (team literal and an unknown position keep their names); a clause the pack lacks falls back to English with the label; the stored English keeps the name; `adminRescuePositions` dedupes and skips non-position and empty slots. - `reader-locale-labels.test.ts`: `positionLabelKey` spelling, held to `TranslationDataSchema` by the existing round trip; the pick reads `positions.<name>.label` in the negotiated locale. - `admin-rescue-named-slate.integration.test.ts`, new describe `[#35418] the note names an unheld position by its label` (real in-memory i18n with the plugin's catalog plus an app pack): zh-CN reads 「岗位「销售经理」无人任职」 and no `sales_manager`; en reads the declared label "position 'Sales Manager' has no holder"; ja-JP with no translation reads the declared label; CONTROL the stored row and a no-locale read keep the name; a throwing source keeps the name and does not fail the read. - Run: those three files 45 passed; `approval-service.test.ts` + `submitter-exclusion-note.test.ts` 486 passed. `pnpm --filter @objectstack/plugin-approvals typecheck` exit 0. </details> <details><summary>Console and i18n</summary> - `ApprovalActionTimeline.systemNote-35418.test.tsx`: en "System note · System" with no "Commented" and no "—"; a person's comment keeps "Commented · Bob" (live control in the same DOM); a no-actor `cancel` row names "System"; zh 「系统说明 · 系统」 and 「评论 · Bob」. 3 passed. - `pnpm --dir ui exec vitest run packages/i18n/` (includes all-locale key parity): 105 files passed, 1957 passed, 13 skipped. - eslint over the changed files: 0 errors (one pre-existing `no-explicit-any` warning in `ApprovalActionTimeline.tsx`, not on a changed line). </details> ## Follow-ups (not in this PR) - The no-approver note's `{{who}}` ("…a member who holds position 'crm_sales_manager'…") is stored pre-composed (`noApproverWho`), so it still names the machine name; labelling it means storing the slots instead of the joined string. ## Verification Read first: `admin-rescue-note.ts` (`labelledPosition`), `ApprovalService.localizeRoutingNotes` and `notePositionLabels`, the `positionLabelSource` wiring in `approvals-plugin.ts`, `ApprovalActionTimeline.tsx` (`actionText`, `actorName`). Two-minute check: `cd packages/plugins/plugin-approvals && pnpm exec vitest run src/admin-rescue-named-slate.integration.test.ts`; expect the `[#35418]` describe green. <details><summary>Local gates at 064e714</summary> `node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstack --ran`: 109 derived families accounted for, 109 run, 0 NOT-MEASURED (all with exit 0; the 28 families the docs commit added were run on 064e714, the other 81 on cfacf20, which differs from it only by that docs page). Four first answered on a shallow, partly built clone and were rerun after the prerequisite: `check-plugin-teardown-shape --self-test` (pinned fixture commit fetched), `pnpm --dir ui exec vitest run scripts/` (needed the `@objectstack/client` dist; then 172 files passed, 2 skipped), `check:dual-build-cjs-loads` and `check:i18n` (after a full `pnpm build`). `node scripts/pm/overlap-check.mjs`: clean against origin/main 9b3227f and 4 open PRs sharing the locale packs or `approval-service.ts` (#36018, #35994, #35969, #35968). CI families: not yet reported at open. </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01L6bhgT9mNgD8oKM93bFzg5 <!-- signed: repo:objectstack#1 · os-sales · session_01L6bhgT9mNgD8oKM93bFzg5 --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent dab4712 commit fe75349

23 files changed

Lines changed: 361 additions & 6 deletions
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
'@objectstack/plugin-approvals': patch
3+
'@object-ui/app-shell': patch
4+
'@object-ui/i18n': patch
5+
'@object-ui/console': patch
6+
---
7+
8+
fix(approvals): the approval timeline names an unstaffed position by its label, and the platform's own rows read as the system's
9+
10+
Clause-②: yes (widening) — @objectstack/plugin-approvals adds the optional `ApprovalServiceOptions.positionLabelSource`; @object-ui/i18n adds approvalsInbox.systemActor and approvalsInbox.actSystemNote; nothing removed
11+
Metadata-protocol: none
12+
13+
When a request goes to the organization's administrators because a position on its approver list has no holder, its timeline note named the position by its machine name ("岗位「crm_sales_manager」无人任职"). The note a reader is served now names it by its label: the reader's language pack (`positions.<name>.label`) first, else the position's declared `label`, else the name as before ("岗位「销售经理」无人任职"). The English the row stores for audit keeps the name.
14+
15+
On the timeline, a row no person took read its actor as "—", and the routing, submitter-exclusion and no-approver notes read as "Commented". A row with no actor now reads its actor as "System", and a `comment` row with no actor reads as "System note". A person's comment keeps "Commented" and its author.
16+
17+
New locale keys: `approvalsInbox.systemActor` and `approvalsInbox.actSystemNote`, in all eleven packs.

‎content/docs/automation/approvals.mdx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,11 @@ organization's capability, such as its owner, is on the slate for that.
575575

576576
The request says why. Its timeline carries a note, for example *Routed to this
577577
organization's administrators because the approver slate named no one: position
578-
'sales_manager' has no holder.*, and its node-config snapshot keeps the abandoned
578+
'sales_manager' has no holder.* That English, with the position's name, is what
579+
the row stores; a reader is served the note in their own language, and it names
580+
the position by its label (the language pack's translation, else the position's
581+
declared label), for example *岗位「销售经理」无人任职*. The timeline shows the
582+
note as a system note, by the system. Its node-config snapshot keeps the abandoned
579583
slate and the same reason under `__resolvedFrom` (`admin_rescue:abandoned`,
580584
`admin_rescue:reason`). The abandoned slate is replaced, not kept beside them: a
581585
holder staffed into the position after the request opened does not receive it,

‎packages/plugins/plugin-approvals/src/admin-rescue-named-slate.integration.test.ts‎

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,4 +475,75 @@ describe('an empty admin_rescue slate opens on the organization\'s administrator
475475
]);
476476
});
477477
});
478+
// [#35418] The note names an unheld position by its label, never by its
479+
// machine name: the reader's pack (`positions.<name>.label`) first, else the
480+
// position's declared `label`, else the name, as before.
481+
describe('[#35418] the note names an unheld position by its label', () => {
482+
let labelled: ApprovalService;
483+
const declared: Record<string, string> = { sales_manager: 'Sales Manager' };
484+
const noteFor = async (requestId: string, locale?: string) =>
485+
(await labelled.listActions(requestId, { ...as('u_sub', ORG), ...(locale ? { locale } : {}) }))
486+
.filter((a) => a.action === 'comment' && !a.actor_id)
487+
.map((a) => a.comment);
488+
489+
beforeAll(() => {
490+
const i18n = createMemoryI18n();
491+
for (const [locale, data] of Object.entries(ApprovalsTranslations)) {
492+
i18n.loadTranslations(locale, data as Record<string, unknown>);
493+
}
494+
// An app's pack, as `AppPlugin` loads it: zh-CN translates the position.
495+
i18n.loadTranslations('zh-CN', { positions: { sales_manager: { label: '销售经理' } } });
496+
labelled = new ApprovalService({
497+
engine: engine as any,
498+
clock: { now: () => new Date(now += 1000) },
499+
logger: { warn: () => {}, info: () => {}, error: () => {}, debug: () => {} } as any,
500+
i18nServiceSource: () => i18n,
501+
positionLabelSource: async (name) => declared[name],
502+
});
503+
});
504+
505+
it('a zh-CN reader reads the translated label, and never the machine name', async () => {
506+
const row = await open('label_zh', UNSTAFFED);
507+
const [comment] = await noteFor(row.id, 'zh-CN');
508+
expect(comment).toBe('审批人名单未指向任何人,因此已转交本组织管理员处理:岗位「销售经理」无人任职。');
509+
expect(comment).not.toContain('sales_manager');
510+
});
511+
512+
it('a reader whose pack holds no translation reads the declared label', async () => {
513+
const row = await open('label_en', UNSTAFFED);
514+
expect(await noteFor(row.id, 'en')).toEqual([
515+
"Routed to this organization's administrators because the approver slate named no one: "
516+
+ "position 'Sales Manager' has no holder.",
517+
]);
518+
expect((await noteFor(row.id, 'ja-JP'))[0]).toContain('役職「Sales Manager」');
519+
});
520+
521+
it('CONTROL: the stored row keeps the name, and a reader with no locale is served it', async () => {
522+
const row = await open('label_stored', UNSTAFFED);
523+
const ENGLISH = "Routed to this organization's administrators because the approver slate named no one: "
524+
+ "position 'sales_manager' has no holder.";
525+
expect((await actionsOf(row.id)).find((a) => a.action === 'comment')?.comment).toBe(ENGLISH);
526+
expect(await noteFor(row.id)).toEqual([ENGLISH]);
527+
});
528+
529+
it('a position no pack and no declaration knows keeps its name, and a failing source does not fail the read', async () => {
530+
const row = await open('label_unknown', UNSTAFFED);
531+
const bare = new ApprovalService({
532+
engine: engine as any,
533+
clock: { now: () => new Date(now += 1000) },
534+
logger: { warn: () => {}, info: () => {}, error: () => {}, debug: () => {} } as any,
535+
i18nServiceSource: () => {
536+
const i18n = createMemoryI18n();
537+
for (const [locale, data] of Object.entries(ApprovalsTranslations)) {
538+
i18n.loadTranslations(locale, data as Record<string, unknown>);
539+
}
540+
return i18n;
541+
},
542+
positionLabelSource: async () => { throw new Error('metadata exploded'); },
543+
});
544+
const served = (await bare.listActions(row.id, { ...as('u_sub', ORG), locale: 'zh-CN' }))
545+
.filter((a) => a.action === 'comment' && !a.actor_id);
546+
expect(served.map((a) => a.comment)).toEqual(['审批人名单未指向任何人,因此已转交本组织管理员处理:岗位「sales_manager」无人任职。']);
547+
});
548+
});
478549
});

‎packages/plugins/plugin-approvals/src/admin-rescue-note.test.ts‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
*/
99

1010
import { describe, it, expect } from 'vitest';
11-
import { adminRescueNoteOf, adminRescueNoteText, adminRescueReason, type ApprovalSentenceRender } from './admin-rescue-note.js';
11+
import {
12+
adminRescueNoteOf, adminRescueNoteText, adminRescuePositions, adminRescueReason, type ApprovalSentenceRender,
13+
} from './admin-rescue-note.js';
1214
import { approvalMessages } from './translations/messages.js';
1315

1416
/** A render over one shipped locale of the catalog, `{{hole}}` filled the `t()` way. */
@@ -48,6 +50,22 @@ describe('[#25576] the admin_rescue note', () => {
4850
expect(adminRescueNoteText(note, renderIn('zh-CN', ['approvalAdminRescueNote']))).toBeUndefined();
4951
});
5052

53+
it('[#35418] names an unheld position by the label the reader is given, and only a position', () => {
54+
const note = { abandoned: ['position:crm_sales_manager', 'position:crm_sales_director', 'team:crm_sales_manager'] };
55+
const label = (name: string) => (name === 'crm_sales_manager' ? '销售经理' : undefined);
56+
expect(adminRescueNoteText(note, renderIn('zh-CN'), label)).toBe(
57+
'审批人名单未指向任何人,因此已转交本组织管理员处理:岗位「销售经理」无人任职;'
58+
+ '岗位「crm_sales_director」无人任职;team「crm_sales_manager」未解析到任何人。',
59+
);
60+
// A clause the pack lacks falls back to its English, labelled the same way.
61+
expect(adminRescueNoteText({ abandoned: ['position:crm_sales_manager'] }, renderIn('zh-CN', ['approvalAdminRescuePositionUnheld']), label))
62+
.toBe("审批人名单未指向任何人,因此已转交本组织管理员处理:position '销售经理' has no holder。");
63+
// The stored English keeps the name.
64+
expect(adminRescueNoteText(note)).toContain("position 'crm_sales_manager' has no holder");
65+
expect(adminRescuePositions({ abandoned: ['position:a', 'team:b', 'position:a', 'position:', 'u_1', 'position:c'] }))
66+
.toEqual(['a', 'c']);
67+
});
68+
5169
it('reads only the shape it writes', () => {
5270
const good = { action_id: 'aact_1', abandoned: ['position:p'], fallback: 'not_declared' };
5371
expect(adminRescueNoteOf({ __adminRescueNote: good })).toEqual(good);

‎packages/plugins/plugin-approvals/src/admin-rescue-note.ts‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,19 +120,32 @@ export function adminRescueReason(
120120
.map(english).join(enMessages.approvalAdminRescueReasonSeparator);
121121
}
122122

123+
/**
124+
* [#35418] A position's display label for the reader, or `undefined` when none
125+
* is known (the position's name then stands).
126+
*/
127+
export type PositionLabelOf = (positionName: string) => string | undefined;
128+
123129
/**
124130
* The note's text. With no `render`, the English the row stores; with one,
125131
* the reader's language, or `undefined` when the note sentence itself is not
126132
* rendered (the stored comment then stands).
133+
*
134+
* [#35418] With `positionLabel` too, an unheld position is named by the label
135+
* it answers (`岗位「销售经理」无人任职`), never by its machine name
136+
* (`crm_sales_manager`), wherever one is known. The stored English keeps the
137+
* name: it is the audit text, and it identifies the position exactly.
127138
*/
128139
export function adminRescueNoteText(note: Omit<AdminRescueNote, 'action_id'>): string;
129140
export function adminRescueNoteText(
130141
note: Omit<AdminRescueNote, 'action_id'>,
131142
render: ApprovalSentenceRender,
143+
positionLabel?: PositionLabelOf,
132144
): string | undefined;
133145
export function adminRescueNoteText(
134146
note: Omit<AdminRescueNote, 'action_id'>,
135147
render?: ApprovalSentenceRender,
148+
positionLabel?: PositionLabelOf,
136149
): string | undefined {
137150
const clauses = reasonClauses(note.abandoned, note.fallback, note.submitter_excluded);
138151
if (!render) {
@@ -142,11 +155,30 @@ export function adminRescueNoteText(
142155
const separator = render(approvalMessageKey('approvalAdminRescueReasonSeparator'), {})
143156
?? enMessages.approvalAdminRescueReasonSeparator;
144157
const reason = clauses
158+
.map((clause) => labelledPosition(clause, positionLabel))
145159
.map((clause) => render(approvalMessageKey(clause.id), clause.params) ?? english(clause))
146160
.join(separator);
147161
return render(approvalMessageKey('approvalAdminRescueNote'), { reason });
148162
}
149163

164+
/** An unheld position's clause, its `value` the position's label where `positionLabel` knows one. */
165+
function labelledPosition(clause: Clause, positionLabel: PositionLabelOf | undefined): Clause {
166+
if (clause.id !== 'approvalAdminRescuePositionUnheld' || !positionLabel) return clause;
167+
const label = positionLabel(clause.params.value);
168+
return label ? { ...clause, params: { ...clause.params, value: label } } : clause;
169+
}
170+
171+
/** The position names an admin_rescue note's abandoned slate holds, each once. */
172+
export function adminRescuePositions(note: Pick<AdminRescueNote, 'abandoned'>): string[] {
173+
const names = new Set<string>();
174+
for (const slot of note.abandoned) {
175+
if (typeof slot === 'string' && slot.startsWith('position:') && slot.length > 'position:'.length) {
176+
names.add(slot.slice('position:'.length));
177+
}
178+
}
179+
return [...names];
180+
}
181+
150182
/**
151183
* The note a parsed node-config snapshot carries, or `undefined` when it
152184
* carries none or one this module did not write (the stored comment stands).

‎packages/plugins/plugin-approvals/src/approval-service.ts‎

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ import {
127127
ADMIN_RESCUE_NOTE_SNAPSHOT_KEY,
128128
adminRescueNoteOf,
129129
adminRescueNoteText,
130+
adminRescuePositions,
130131
adminRescueReason,
131132
type AdminRescueNote,
132133
} from './admin-rescue-note.js';
@@ -2074,6 +2075,17 @@ export interface ApprovalServiceOptions {
20742075
* authored text the request snapshotted when it opened.
20752076
*/
20762077
i18nServiceSource?: () => ReaderLabelI18n | undefined;
2078+
/**
2079+
* [#35418] A position's declared `label`, by its name: what a timeline note
2080+
* names an unheld position by when the reader's language pack holds no
2081+
* `positions.<name>.label`. The plugin answers it from the `metadata`
2082+
* service (`get('position', name)`), read per call for the reason
2083+
* {@link ApprovalServiceOptions.i18nServiceSource} is.
2084+
*
2085+
* Absent, or answering `undefined`, the note names the position by its
2086+
* name, as before.
2087+
*/
2088+
positionLabelSource?: (positionName: string) => Promise<string | undefined>;
20772089
/**
20782090
* [ADR-0142 D6] The `ownership-queue` service, through which a `queue`
20792091
* approver expands to the queue's members at node entry. Resolved LAZILY
@@ -2211,6 +2223,8 @@ export class ApprovalService implements IApprovalService, ObjectSchemaReadDelega
22112223
private readonly platformAdminStandings = new WeakMap<object, Map<string, Promise<boolean>>>();
22122224
/** [#24863] Lazily-resolved `i18n` service for the reader-locale display labels. */
22132225
private i18nServiceSource?: () => ReaderLabelI18n | undefined;
2226+
/** [#35418] A position's declared label, for a note that names an unheld position. */
2227+
private positionLabelSource?: (positionName: string) => Promise<string | undefined>;
22142228
/** [ADR-0142 D6] Lazily-resolved `ownership-queue` service a `queue` approver expands through. */
22152229
private ownershipQueues?: () => ApproverQueueSource | undefined;
22162230
/** [ADR-0157 D5] Lazily-resolved working-calendar service a `working_time` escalation counts through. */
@@ -2255,6 +2269,7 @@ export class ApprovalService implements IApprovalService, ObjectSchemaReadDelega
22552269
this.fieldVisibility = opts.fieldVisibility;
22562270
this.messageTranslator = opts.messageTranslator;
22572271
this.i18nServiceSource = opts.i18nServiceSource;
2272+
this.positionLabelSource = opts.positionLabelSource;
22582273
this.ownershipQueues = opts.ownershipQueues;
22592274
this.workCalendar = opts.workCalendar;
22602275
this.recordReaderVisibleObjects = new Set(
@@ -11346,13 +11361,41 @@ export class ApprovalService implements IApprovalService, ObjectSchemaReadDelega
1134611361
if (row && text) row.comment = text;
1134711362
};
1134811363
const rescue = adminRescueNoteOf(snapshot);
11349-
if (rescue) overlay(rescue.action_id, () => adminRescueNoteText(rescue, labels.sentence));
11364+
if (rescue) {
11365+
const positionLabels = await this.notePositionLabels(adminRescuePositions(rescue), labels);
11366+
overlay(rescue.action_id, () => adminRescueNoteText(rescue, labels.sentence, (name) => positionLabels.get(name)));
11367+
}
1135011368
const exclusion = submitterExclusionNoteOf(snapshot);
1135111369
if (exclusion) overlay(exclusion.action_id, () => submitterExclusionNoteText(exclusion, labels.sentence));
1135211370
const noApprover = noApproverNoteOf(snapshot);
1135311371
if (noApprover) overlay(noApprover.action_id, () => noApproverNoteText(noApprover, labels.sentence));
1135411372
}
1135511373

11374+
/**
11375+
* [#35418] The label a reader reads each of `positions` by: the reader's
11376+
* language pack (`positions.<name>.label`), else the position's declared
11377+
* `label` ({@link ApprovalServiceOptions.positionLabelSource}). A position
11378+
* neither answers is left out, and the note names it by its name. Display
11379+
* only: a failed read leaves the name standing, never fails the read.
11380+
*/
11381+
private async notePositionLabels(
11382+
positions: readonly string[],
11383+
labels: ReaderLabels,
11384+
): Promise<Map<string, string>> {
11385+
const out = new Map<string, string>();
11386+
for (const name of positions) {
11387+
let label = labels.positionLabel(name);
11388+
if (!label && this.positionLabelSource) {
11389+
try {
11390+
const declared = await this.positionLabelSource(name);
11391+
if (typeof declared === 'string' && declared.trim()) label = declared;
11392+
} catch { /* display-only — the name stands */ }
11393+
}
11394+
if (label) out.set(name, label);
11395+
}
11396+
return out;
11397+
}
11398+
1135611399
/**
1135711400
* `IFileAccessDelegate` — may this caller download a decision attachment?
1135811401
* (ADR-0104 D3 wave 2; declared by `sys_approval_action.fileAccessDelegate`.)

‎packages/plugins/plugin-approvals/src/approvals-plugin.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,18 @@ export class ApprovalsServicePlugin implements Plugin {
292292
// object labels in the reader's locale (`reader-locale-labels.ts`).
293293
// Without one, the door serves the labels as stored.
294294
i18nServiceSource: i18nService,
295+
// [#35418] A position's declared label, for the timeline note that names
296+
// an unheld position when the reader's pack holds no translation of it.
297+
// Resolved LAZILY for the reason the providers above are; absent, the
298+
// note names the position by its name.
299+
positionLabelSource: async (positionName) => {
300+
let metadata: { get?(type: string, name: string): Promise<unknown> } | undefined;
301+
try { metadata = ctx.getService('metadata'); } catch { return undefined; }
302+
if (typeof metadata?.get !== 'function') return undefined;
303+
const item = await metadata.get('position', positionName);
304+
const label = (item as { label?: unknown } | undefined)?.label;
305+
return typeof label === 'string' && label.trim() ? label : undefined;
306+
},
295307
// [ADR-0142 D6] The queue service a `queue` approver expands through.
296308
// Resolved LAZILY for the reason the providers above are: plugin-sharing
297309
// registers it and may start after this one. Absent, a queue approver

‎packages/plugins/plugin-approvals/src/reader-locale-labels.test.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
flowLabelKey,
2929
flowNameOfProcess,
3030
localizeRequestLabels,
31+
positionLabelKey,
3132
readerLabelsFor,
3233
type ReaderLabelI18n,
3334
} from './reader-locale-labels.js';
@@ -54,6 +55,7 @@ const ZH = {
5455
[flowLabelKey('account_approval')]: '客户审批',
5556
[approvalStepLabelKey('account_approval', 'manager_review')]: '经理审核',
5657
[objectLabelKey('account')]: '客户',
58+
[positionLabelKey('crm_sales_manager')]: '销售经理',
5759
};
5860

5961
describe('[#24863] every key the reader asks is one the translation contract declares', () => {
@@ -62,6 +64,7 @@ describe('[#24863] every key the reader asks is one the translation contract dec
6264
expect(approvalStepLabelKey('account_approval', 'manager_review'))
6365
.toBe('flows.account_approval.approvals.manager_review.label');
6466
expect(objectLabelKey('account')).toBe('objects.account.label');
67+
expect(positionLabelKey('crm_sales_manager')).toBe('positions.crm_sales_manager.label');
6568
});
6669

6770
it('a pack holding exactly those keys parses, and keeps each value at its address', () => {
@@ -70,6 +73,7 @@ describe('[#24863] every key the reader asks is one the translation contract dec
7073
expect(result.data.flows.account_approval.label).toBe('客户审批');
7174
expect(result.data.flows.account_approval.approvals.manager_review.label).toBe('经理审核');
7275
expect(result.data.objects.account.label).toBe('客户');
76+
expect(result.data.positions.crm_sales_manager.label).toBe('销售经理');
7377
});
7478

7579
it('control: the same round trip refuses a step key the face does not declare', () => {
@@ -98,6 +102,7 @@ describe('[#24863] the pick', () => {
98102
expect(labels.flowLabel('account_approval')).toBe('客户审批');
99103
expect(labels.stepLabel('account_approval', 'manager_review')).toBe('经理审核');
100104
expect(labels.objectLabel('account')).toBe('客户');
105+
expect(labels.positionLabel('crm_sales_manager')).toBe('销售经理');
101106
}
102107
});
103108

0 commit comments

Comments
 (0)