Skip to content

Commit 6a715ca

Browse files
committed
fix(ui,platform-objects): invitation screens — labelled statuses, role help, resend as a confirmation, param dialog format check and focus
Invitation statuses carry display labels. Every role picker that grants an organization role explains each role on its own line, and Change Role names the member. Resend confirms with the row's email and role carried over. The workspace cancel dialog dismisses with Keep invitation. The console's param dialog checks email and url params against the form's format rule and marks the field. The param, confirm and result dialogs open on the first editable field and return focus to their opener. The sign-in page tells an invitee without the link to open it, and the accept page says the user joined before Continue enters the organization. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibyekmZuiE5TVrwDWqH
1 parent af99f3c commit 6a715ca

11 files changed

Lines changed: 682 additions & 16 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
'@objectstack/platform-objects': patch
3+
'@object-ui/app-shell': patch
4+
'@object-ui/plugin-form': patch
5+
'@object-ui/i18n': patch
6+
'@object-ui/console': patch
7+
---
8+
9+
Clause-②: yes (widening: `@object-ui/app-shell` exports `InvitationLinkHint` and `@object-ui/plugin-form` exports `useInitialFieldFocus`; no accept set moves)
10+
Metadata-protocol: none (platform object metadata only, no authorable key: `sys_invitation.status` options gain display labels, with `rejected` read as "Declined"; the role param of the four `invite_user` actions, `sys_member.add_member` and `sys_member.update_member_role` gains one shared `helpText`; `sys_invitation.resend_invitation` gains a `description` and carries its email and role over from the row; `sys_member.update_member_role` gains a `description` naming the member; the `expired` invitations list projects `role`)
11+
12+
The Invitations screens read more clearly and behave more predictably. Invitation statuses show as labels (Pending, Accepted, Declined, Expired, Canceled) instead of raw values. Every role picker that grants an organization role explains each role on its own line, and Change Role names the member it changes. Resend is a confirmation that names the invitee and keeps the invitation's email and role, instead of an editable form. The workspace's cancel dialog dismisses with "Keep invitation".
13+
14+
The console's action dialogs check an email or URL param before anything runs and mark a malformed value on its field. They open on their first editable field instead of Cancel, and closing one returns focus to the control that opened it: an action button that was disabled while its action ran, a row menu's trigger, or the first opener when a param dialog hands over to a result dialog. This applies to every action that uses the param, confirm and result dialogs.
15+
16+
The sign-in page tells a visitor to open their invitation link where sign-up is by invitation only. After accepting an invitation, the page says the user joined the organization and as which role, and Continue enters it.
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
//
3+
// #27521 — the metadata half of the Invitations screens (rows 7, 8 and 9 of
4+
// the 18.3.0 RC walkthrough):
5+
//
6+
// - row 7: `sys_invitation.status` options carry display labels, read from a
7+
// map keyed by the spec enum, instead of the raw lowercase values;
8+
// - row 8: every picker that grants a membership role explains each role in
9+
// one shared help text, and Change Role names the member it changes;
10+
// - row 9: Resend Invitation is a confirmation, not an editable form: its
11+
// email and role are carried over from the row, and every list of
12+
// invitations projects both;
13+
// - the translated bundles carry a translation of every new leaf, never the
14+
// English source `--fill=default` seeds a new key with.
15+
16+
import { describe, expect, it } from 'vitest';
17+
import { BUILTIN_MEMBERSHIP_ROLE_OPTIONS, InvitationStatus } from '@objectstack/spec/identity';
18+
import { enObjects } from '../apps/translations/en.objects.generated.js';
19+
import { zhCNObjects } from '../apps/translations/zh-CN.objects.generated.js';
20+
import { jaJPObjects } from '../apps/translations/ja-JP.objects.generated.js';
21+
import { esESObjects } from '../apps/translations/es-ES.objects.generated.js';
22+
import { MEMBERSHIP_ROLE_PARAM_HELP } from './membership-role-help.js';
23+
import { SysInvitation } from './sys-invitation.object.js';
24+
import { SysMember } from './sys-member.object.js';
25+
import { SysOrganization } from './sys-organization.object.js';
26+
import { SysUser } from './sys-user.object.js';
27+
28+
type Action = Record<string, any>;
29+
type Param = Record<string, any>;
30+
31+
function action(object: unknown, name: string): Action {
32+
const found = ((object as { actions?: Action[] }).actions ?? []).find((a) => a.name === name);
33+
if (!found) throw new Error(`no action ${name}`);
34+
return found;
35+
}
36+
37+
function param(declared: Action, name: string): Param {
38+
const found = ((declared.params ?? []) as Param[]).find((p) => (p.field ?? p.name) === name);
39+
if (!found) throw new Error(`no param ${name} on ${declared.name}`);
40+
return found;
41+
}
42+
43+
/** Every role picker that grants a membership role, as `[object, action, declaration]`. */
44+
const ROLE_PICKERS: Array<[string, string, unknown]> = [
45+
['sys_user', 'invite_user', SysUser],
46+
['sys_member', 'invite_user', SysMember],
47+
['sys_invitation', 'invite_user', SysInvitation],
48+
['sys_organization', 'invite_user', SysOrganization],
49+
['sys_member', 'add_member', SysMember],
50+
['sys_member', 'update_member_role', SysMember],
51+
];
52+
53+
const TRANSLATED = [
54+
['zh-CN', zhCNObjects],
55+
['ja-JP', jaJPObjects],
56+
['es-ES', esESObjects],
57+
] as const;
58+
59+
const bundleObject = (bundle: unknown, object: string): Record<string, any> | undefined =>
60+
(bundle as Record<string, Record<string, any>>)?.[object];
61+
62+
describe('row 7 — invitation status options are labelled', () => {
63+
const options = (SysInvitation as any).fields.status.options as Array<{ value: string; label: string }>;
64+
65+
it('labels every value of the spec enum, in its order', () => {
66+
expect(options.map((o) => o.value)).toEqual([...InvitationStatus.options]);
67+
for (const option of options) {
68+
expect(option.label, option.value).not.toBe(option.value);
69+
expect(option.label[0], option.value).toBe(option.label[0].toUpperCase());
70+
}
71+
});
72+
73+
it('reads `rejected` as "Declined", the invitee\'s own action', () => {
74+
expect(options.find((o) => o.value === 'rejected')?.label).toBe('Declined');
75+
});
76+
77+
it('serves the labels in the English bundle', () => {
78+
const en = bundleObject(enObjects, 'sys_invitation')?.fields?.status?.options;
79+
expect(en).toEqual(Object.fromEntries(options.map((o) => [o.value, o.label])));
80+
});
81+
});
82+
83+
describe('row 8 — one role help text, a line per role', () => {
84+
it('has one line per membership role, labelled and ordered as the options are', () => {
85+
const lines = MEMBERSHIP_ROLE_PARAM_HELP.split('\n');
86+
expect(lines.map((line) => line.split(': ')[0])).toEqual(BUILTIN_MEMBERSHIP_ROLE_OPTIONS.map((o) => o.label));
87+
for (const line of lines) expect(line.split(': ')[1]?.length, line).toBeGreaterThan(10);
88+
});
89+
90+
it.each(ROLE_PICKERS)('%s.%s declares it on its role param', (_object, name, declaration) => {
91+
expect(param(action(declaration, name), 'role').helpText).toBe(MEMBERSHIP_ROLE_PARAM_HELP);
92+
});
93+
94+
it('Change Role names the member it changes, with a fallback for a row without the user', () => {
95+
const changeRole = action(SysMember, 'update_member_role');
96+
expect(changeRole.description).toContain("${record.user_id?.name ?? 'this member'}");
97+
expect(changeRole.confirmText).toBeUndefined();
98+
});
99+
});
100+
101+
describe('row 9 — Resend Invitation is a confirmation', () => {
102+
const resend = action(SysInvitation, 'resend_invitation');
103+
104+
it('asks its question in `description`, naming the invitee', () => {
105+
expect(resend.description).toContain('${record.email}');
106+
// The spec refuses `confirmText` beside `params` on a registered action.
107+
expect(resend.confirmText).toBeUndefined();
108+
});
109+
110+
it.each(['email', 'role'])('carries %s over from the row, unchanged', (name) => {
111+
expect(param(resend, name)).toMatchObject({ required: true, defaultFromRow: true, carryOver: true });
112+
});
113+
114+
it.each(Object.keys((SysInvitation as any).listViews))(
115+
'the %s list projects both carried-over columns, so its rows can resend',
116+
(view) => {
117+
const columns = ((SysInvitation as any).listViews[view].columns as Array<string | { field: string }>)
118+
.map((c) => (typeof c === 'string' ? c : c.field));
119+
expect(columns).toEqual(expect.arrayContaining(['email', 'role']));
120+
},
121+
);
122+
});
123+
124+
describe('the new copy in the translated bundles', () => {
125+
const leaves = (bundle: unknown): Array<[string, unknown]> => [
126+
...ROLE_PICKERS.map(([object, name]): [string, unknown] => [
127+
`${object}.${name}.params.role.helpText`,
128+
bundleObject(bundle, object)?._actions?.[name]?.params?.role?.helpText,
129+
]),
130+
['sys_invitation.resend_invitation.description', bundleObject(bundle, 'sys_invitation')?._actions?.resend_invitation?.description],
131+
['sys_member.update_member_role.description', bundleObject(bundle, 'sys_member')?._actions?.update_member_role?.description],
132+
];
133+
134+
const english = new Map(leaves(enObjects));
135+
136+
it.each(TRANSLATED)('%s translates every new leaf', (_locale, bundle) => {
137+
for (const [path, value] of leaves(bundle)) {
138+
expect(typeof value, path).toBe('string');
139+
expect(value, path).not.toBe(english.get(path));
140+
}
141+
});
142+
143+
it.each(TRANSLATED)('%s keeps the holes the console fills', (_locale, bundle) => {
144+
const byPath = new Map(leaves(bundle));
145+
expect(byPath.get('sys_invitation.resend_invitation.description')).toContain('${record.email}');
146+
expect(byPath.get('sys_member.update_member_role.description')).toMatch(/\$\{record\.user_id\?\.name \?\? '[^']+'\}/);
147+
});
148+
149+
it.each(TRANSLATED)('%s keeps one help line per role', (_locale, bundle) => {
150+
const help = bundleObject(bundle, 'sys_member')?._actions?.add_member?.params?.role?.helpText as string;
151+
expect(help.split('\n')).toHaveLength(BUILTIN_MEMBERSHIP_ROLE_OPTIONS.length);
152+
});
153+
});
Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
22

3+
import { BUILTIN_MEMBERSHIP_ROLE_OPTIONS, type BuiltinMembershipRole } from '@objectstack/spec/identity';
4+
5+
/**
6+
* What each role of the closed membership vocabulary (ADR-0108) lets a member
7+
* do. Keyed by the spec's role type, so a role the vocabulary gains fails to
8+
* compile here until it is explained.
9+
*/
10+
const MEMBERSHIP_ROLE_DUTIES: Record<BuiltinMembershipRole, string> = {
11+
owner: 'full control of the organization, including deleting it.',
12+
admin: 'manages members, invitations, teams and organization settings.',
13+
delegated_admin: 'invites people and places them only where an administrator has delegated that.',
14+
member: 'works in the organization\'s apps with the access their permission sets give.',
15+
external: 'someone from outside the organization, such as a supplier or customer, who sees only what is shared with them.',
16+
};
17+
318
/**
419
* The help under every role picker that grants an organization membership
520
* role: the four `invite_user` mirrors (sys_user, sys_member, sys_invitation,
@@ -8,14 +23,10 @@
823
* Declared as the param's `helpText`, not inherited from the field: the field
924
* help differs per object (`sys_member.role` describes the stored column,
1025
* `sys_invitation.role` the role an invitation confers), so a dialog reached
11-
* from two entry points used to explain the same choice two ways and name none
12-
* of the roles. One line per role of the closed vocabulary (ADR-0108), in its
13-
* display order; the param dialog keeps the line breaks.
26+
* from two entry points would explain the same choice two ways and name none
27+
* of the roles. One line per role, labelled and ordered as the pickers'
28+
* options are; the param dialog keeps the line breaks.
1429
*/
15-
export const MEMBERSHIP_ROLE_PARAM_HELP = [
16-
'Owner: full control of the organization, including deleting it.',
17-
'Admin: manages members, invitations, teams and organization settings.',
18-
'Delegated Admin: invites people and places them only where an administrator has delegated that.',
19-
'Member: works in the organization\'s apps with the access their permission sets give.',
20-
'External: someone from outside the organization, such as a supplier or customer, who sees only what is shared with them.',
21-
].join('\n');
30+
export const MEMBERSHIP_ROLE_PARAM_HELP = BUILTIN_MEMBERSHIP_ROLE_OPTIONS
31+
.map((option) => `${option.label}: ${MEMBERSHIP_ROLE_DUTIES[option.value as BuiltinMembershipRole]}`)
32+
.join('\n');

‎packages/platform-objects/src/identity/sys-invitation.object.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ export const SysInvitation = ObjectSchema.create({
128128
label: 'Resend Invitation',
129129
// A confirmation, not a form: the question rides `description` (one
130130
// dialog, see `action-confirm-one-dialog.test.ts`) and both params are
131-
// carried over from the row. Editing them did nothing useful: invite-member
132-
// renews a pending invitation with its STORED role whatever role is sent,
133-
// and a changed email invited a different person.
131+
// carried over from the row. invite-member renews a pending invitation
132+
// with its stored role whatever role is sent, and another email would
133+
// invite a different person, so neither is the user's to edit here.
134134
description: 'Resend the invitation to ${record.email}? Its expiry date starts over.',
135135
icon: 'send',
136136
variant: 'secondary',
@@ -147,7 +147,7 @@ export const SysInvitation = ObjectSchema.create({
147147
outcomeMessages: { ...RESEND_INVITATION_OUTCOME_MESSAGES },
148148
refreshAfter: true,
149149
// Both seeded from the row, so every list view that offers this action
150-
// projects `email` and `role` (`resend-invitation-confirm.test.ts`).
150+
// projects `email` and `role` (`invitation-screens-copy.test.ts`).
151151
params: [
152152
{ field: 'email', required: true, defaultFromRow: true, carryOver: true },
153153
{ field: 'role', required: true, defaultFromRow: true, carryOver: true },

‎ui/apps/console/src/pages/auth/__tests__/signUpFollowsPosture-11691.test.tsx‎

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
import '@testing-library/jest-dom/vitest';
3838
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
39-
import { render, screen, cleanup, waitFor } from '@testing-library/react';
39+
import { act, render, screen, cleanup, waitFor } from '@testing-library/react';
4040
import userEvent from '@testing-library/user-event';
4141
import { MemoryRouter, Routes, Route, useLocation } from 'react-router-dom';
4242
import { I18nProvider } from '@object-ui/i18n';
@@ -221,6 +221,33 @@ describe('LoginPage — the "Sign up" link follows the audience posture (objectu
221221
});
222222
});
223223

224+
describe('LoginPage — an invitee without the link is told to open it (objectstack#27521 row 11)', () => {
225+
const HINT = builtInLocales.en.auth.login.invitationLinkHint;
226+
227+
it('under invite_only on a deployment with an owner, says so in the card', async () => {
228+
renderAt('/login', configFor('invite_only'));
229+
await loginConfigApplied();
230+
expect(await screen.findByTestId('invitation-link-hint')).toHaveTextContent(HINT);
231+
expect(screen.getByTestId('login-card')).toContainElement(screen.getByTestId('invitation-link-hint'));
232+
});
233+
234+
it('is not drawn where a sign-up is offered or for an invitation redirect', async () => {
235+
for (const [path, config, hasOwner] of [
236+
['/login', configFor('open'), true],
237+
['/login', configFor('invite_only'), false],
238+
[`/login${INVITE_QUERY}`, configFor('invite_only'), true],
239+
] as const) {
240+
renderAt(path, config, { hasOwner });
241+
await loginConfigApplied();
242+
await act(async () => {
243+
await new Promise((resolve) => setTimeout(resolve, 0));
244+
});
245+
expect(screen.queryByTestId('invitation-link-hint'), `${path} owner=${hasOwner}`).toBeNull();
246+
cleanup();
247+
}
248+
});
249+
});
250+
224251
describe('RegisterPage — explains invitation-only registration before the form (objectui#11691)', () => {
225252
it('under invite_only without an invitation, explains instead of rendering the form', async () => {
226253
renderAt('/register', configFor('invite_only'));

‎ui/packages/app-shell/src/console/auth/__tests__/defaultPagesFollowPosture-11705.test.tsx‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,32 @@ describe('DefaultLoginPage — the "Sign up" link follows the audience posture (
221221
});
222222
});
223223

224+
describe('DefaultLoginPage — an invitee without the link is told to open it (objectstack#27521 row 11)', () => {
225+
const HINT = en.login.invitationLinkHint;
226+
227+
it('under invite_only on a deployment with an owner, says so under the form', async () => {
228+
renderAt('/login', configFor('invite_only'));
229+
await loginConfigApplied();
230+
expect(await screen.findByText(HINT)).toBeInTheDocument();
231+
expect(screen.queryByRole('link', SIGN_UP_LINK)).toBeNull();
232+
});
233+
234+
it('is not drawn where a sign-up is offered, for an invitation redirect, or with sign-up off', async () => {
235+
for (const [path, config, hasOwner] of [
236+
['/login', configFor('open'), true],
237+
['/login', configFor('invite_only'), false],
238+
[`/login${INVITE_QUERY}`, configFor('invite_only'), true],
239+
['/login', configFor('invite_only', SIGN_UP_OFF), true],
240+
] as const) {
241+
renderAt(path, config, { hasOwner });
242+
await loginConfigApplied();
243+
await settle();
244+
expect(screen.queryByText(HINT), `${path} ${JSON.stringify(config.features)} owner=${hasOwner}`).toBeNull();
245+
cleanup();
246+
}
247+
});
248+
});
249+
224250
describe('DefaultRegisterPage — explains invitation-only registration before the form (objectui#11705)', () => {
225251
it('under invite_only without an invitation, explains instead of rendering the form', async () => {
226252
renderAt('/register', configFor('invite_only'));

‎ui/packages/app-shell/src/console/organizations/__tests__/org-i18n-holdouts-4474.test.tsx‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,14 @@ describe('#4474 family 3 — icon-only buttons carry a translated aria-label —
432432
await waitFor(() => expect(screen.getByLabelText('复制邀请链接')).toBeInTheDocument());
433433
});
434434

435+
it('the cancel dialog dismisses with "Keep invitation", not a second "Cancel" (objectstack#27521 row 9)', async () => {
436+
renderIn('en', <InvitationsPage />);
437+
await waitFor(() => expect(screen.getByTestId('invitations-page')).toBeInTheDocument());
438+
fireEvent.click(screen.getByLabelText('Cancel invitation'));
439+
expect(await screen.findByRole('button', { name: 'Keep invitation' })).toBeInTheDocument();
440+
expect(screen.queryByRole('button', { name: 'Cancel' })).toBeNull();
441+
});
442+
435443
it('MUST NOT CHANGE — en aria-labels stay the English the card measured', async () => {
436444
renderIn('en', <InvitationsPage />);
437445
await waitFor(() => expect(screen.getByTestId('invitations-page')).toBeInTheDocument());

0 commit comments

Comments
 (0)