Skip to content

Commit 6228609

Browse files
committed
feat(account): route Profile to custom React component
1 parent 47a92f4 commit 6228609

3 files changed

Lines changed: 56 additions & 14 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
'@objectstack/platform-objects': patch
3+
---
4+
5+
Account App: route Profile to a custom React component instead of the
6+
generic sys_user record page.
7+
8+
The Account App's `nav_account_profile` entry switched from
9+
`type: 'object'` (sys_user record, current user id) to
10+
`type: 'component'` with `componentRef: 'account:profile_card'`.
11+
End users now see a settings-form-style "My Profile" card
12+
(avatar / name / password / SSO recovery) registered by the Console
13+
runtime, while the `sys_user` slotted record page (`SysUserDetailPage`)
14+
is unchanged and remains the admin view reached from Setup → Users.
15+
16+
This is a behavioural change for any Studio override that mutates
17+
`nav_account_profile`: the entry no longer has `objectName`,
18+
`recordId`, or `requiresObject`. Override consumers should drop
19+
those fields and target `componentRef: 'account:profile_card'`
20+
(or restore the previous nav item type explicitly).
21+
22+
Requires a Console build that registers `account:profile_card`
23+
(included in the matching `@object-ui/console` release pinned via
24+
`.objectui-sha`).
25+
26+
Verified end-to-end: login → Account App → 个人资料 sidebar item
27+
→ `/_console/apps/account/component/account/profile_card` renders
28+
the React Profile card; editing Name and clicking Save Changes
29+
POSTs `/api/v1/auth/update-user` (200) and persists.
30+
31+
The upstream `@object-ui/console` release also fixes a latent
32+
`useState` bug in the same ProfilePage: when mounted under
33+
`<Suspense>` before `AuthProvider` resolves, `user` is null on
34+
first render and `setName(user?.name ?? '')` initialised to `''`
35+
with no follow-up sync. A `useEffect` now mirrors `user.name`
36+
into local state. This was masked when the page was only reached
37+
via the System Hub route (where `AuthGuard` ensured user was
38+
already loaded) and is exposed by the new mount path.

‎packages/platform-objects/src/apps/account.app.ts‎

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,20 @@ export const ACCOUNT_APP: App = {
4545
// manage their own 2FA / linked accounts / personal OAuth apps. RLS on
4646
// each object scopes rows to the caller.
4747
navigation: [
48-
// Profile is the canonical landing — name, email, avatar, verification
49-
// status. Uses `type: 'object' + recordId: '{current_user_id}'` so it
50-
// resolves to the sys_user record page; the slotted SysUserDetailPage
51-
// (kind: 'slotted', isDefault: true) tailors that page into a proper
52-
// self-service profile (highlight chips, grouped detail sections, no
53-
// Discussion thread) without losing the record-context features
54-
// (related lists, header actions, RLS-aware edit).
48+
// Profile is the canonical landing — a hand-written React settings card
49+
// (Vercel/Linear style) registered in the Console SPA as
50+
// `account:profile_card`. The renderer reads the current user via
51+
// `useAuth()` and writes via `client.auth.updateUser`, so there is no
52+
// sys_user record context here — this is intentional. The admin-facing
53+
// sys_user record page (see `pages/sys-user.page.ts`) stays focused on
54+
// record browsing (Identity/Audit fields, related lists, admin actions)
55+
// and is reached through Setup, never from the Account App.
5556
{
5657
id: 'nav_account_profile',
57-
type: 'object',
58+
type: 'component',
5859
label: 'Profile',
59-
objectName: 'sys_user',
60-
recordId: '{current_user_id}',
60+
componentRef: 'account:profile_card',
6161
icon: 'user-circle',
62-
requiresObject: 'sys_user',
6362
},
6463

6564
// --- Inbox & work assigned to me -----------------------------------

‎packages/platform-objects/src/pages/sys-user.page.ts‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@ import type { Page } from '@objectstack/spec/ui';
55
/**
66
* sys_user — Record Detail Page (slotted, default for ALL sys_user records)
77
*
8-
* Tailors the synthesized admin form into a layout that works for both:
9-
* • the end user landing on their own profile from the Account App, and
10-
* • an admin opening someone else's user record from Setup.
8+
* **Audience**: admins browsing user records from Setup.
9+
*
10+
* The Account App's "Profile" entry no longer routes here — it points at
11+
* the `account:profile_card` Console component for a settings-form-style
12+
* personal profile. This page therefore optimizes for the admin
13+
* use case: scanning a user's signals (email/verification/2FA/role),
14+
* reviewing related sessions/orgs/oauth/api-keys, and triggering
15+
* admin actions (ban / impersonate / set_role).
1116
*
1217
* Strategy
1318
* --------

0 commit comments

Comments
 (0)