Repository navigation
Commit b86331d
fix(console): the Users import wizard maps a manager column to import-users' manager_id (#34649)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi96QpUuH77yeiDEFd5Vi6Pg1)_
Fixes #34536
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:控制台「用户导入」向导新增可映射列 `manager_id`(标签取 sys_user
字段的「Manager」),选项面板加一句说明;11 个语言包都加了对应文案。
- 为什么改:导入接口早就接受 manager 列(按上级的邮箱或手机号,在所有行导入后关联),但向导里映射不到,CSV
里的上级列在发请求前就被丢掉了,只能走 API。
- 风险与回滚:只动界面的可映射列表和文案,接口接受什么不变;回滚即撤掉本 PR,向导回到不能映射上级列的旧状态。
-
先看:`ui/packages/app-shell/src/views/IdentityImportPanels.tsx`(新增的一列与说明),`ui/packages/app-shell/src/views/__tests__/identityImportFields.endpointColumns-34536.test.ts`(读接口源码、两边漂移即红的钉子)。
- 两分钟验证:`pnpm --dir ui exec vitest run
packages/app-shell/src/views/__tests__/identityImportFields.endpointColumns-34536.test.ts
packages/app-shell/src/views/__tests__/identityImportFields.emailRule-11913.test.tsx`,预期两个文件全绿(11
个用例)。
- 需要你做的:无,席位落地。
## What changes
- `identityImportFields` (the Users import wizard's only list of mapping
targets) offers `manager_id`, typed `text` (the cell is an identity key,
not the lookup id the `sys_user` field stores) and labelled by the
object's `manager_id` field (fallback `Manager`).
- The identity import options panel carries a `managerHint` line
(`console.identityImport.managerHint`, added to every locale pack under
`ui/packages/i18n/src/locales/`; `zh-Hant` regenerated from `zh-Hans` by
`gen-zh-hant.mjs`). It says what the cell holds (the manager's email, or
phone number where phone sign-in is on), that managers are linked once
every row is in, and that an unresolved manager is reported on its row
while the user is still created.
- What `POST /api/v1/auth/admin/import-users` accepts is unchanged: no
file under `packages/` is edited.
### Why a drift pin and not one shared list
`@object-ui/app-shell` does not depend on `@objectstack/plugin-auth` (a
server plugin), and the endpoint's column names are not exported:
`MANAGER_COLUMN` / `POSITIONS_COLUMN` are module constants, and its
`sys_user` columns are read as `data.NAME` inside `createData`. One
runtime list both sides read would need either a new published export
(`plugin-auth`'s index re-exports `admin-import-users.ts` wholesale)
plus a console-to-server-plugin dependency, or a `packages/spec` export;
both are out of this card's ruled scope. So the pin reads the endpoint's
source: every `const X_COLUMN = 'NAME';` declaration (the second-pass
columns) and every `data.NAME` read between `async createData(` and
`async updateData(`, and requires the wizard's list to equal their
union, both directions. Each extraction asserts its anchor first, so a
refactor that moves the reads goes red instead of comparing nothing.
`pnpm check:cross-package-test-inputs` is green with the read (Test UI's
selector keeps a test that reads outside the ui workspace always-on).
## Tests
- `identityImportFields.endpointColumns-34536.test.ts` (new,
card-named): the drift pin above (4 cases).
- `identityImportFields.emailRule-11913.test.tsx` (existing harness for
`identityImportFields`, new top-level `describe`): `manager_id` is
offered as `text` with the object field's label; the options panel
explains it; and end to end, the real `ImportWizard` with the real
identity data source and a faked import-users endpoint: a pasted
`manager_id` column is auto-mapped and every row of the sent request
carries `manager_id`.
## Acceptance notes
- FROM, measured by the ablation below: with `manager_id` absent from
the list, a pasted file's manager column is dropped before the request:
the endpoint received `{ email, name }` rows with no `manager_id` (the
wizard sends mapped columns only, and only the list's columns can be
mapped).
- The manager cell holds an email address, or a phone number where phone
sign-in is on (`resolveManagerKey`); a user id reads as unreadable
there, so the hint does not offer one.
- Deliberately outside the pin: `image` and `locale`, which an upsert
may write on an existing user (`SYS_USER_IMPORT_UPDATE_FIELDS`) but the
create path does not read, and the phone column's legacy aliases
(`phoneNumber`, `phone`). Not measured: whether a create row carrying
`locale` or `image` drops it silently; the wizard has never offered
either column.
- `positions` keeps its literal `Positions` label: `sys_user` has no
`positions` field to take a label from, and `identityImportFields` holds
no translator, so the label treatment is not a one-line change.
## Verification
Readings on head `aa68e1cd5` unless noted.
Details
- Targeted ui tests: `pnpm --dir ui exec vitest run --maxWorkers=2
packages/i18n/` plus the seven `identityImport*` /
`IdentityImportPanels*` test files under
`packages/app-shell/src/views/__tests__/`: the first run (head
`099e1c34d`) was 1 failed / 108 passed files,
`zh-hant-generated.test.ts` (the zh-Hant pack is generated); fixed by
regenerating, commit `aa68e1cd5`; on `aa68e1cd5`: Test Files 109 passed
(109), Tests 1939 passed / 13 skipped.
- `pnpm --filter @object-ui/i18n run type-check` exit 0; `pnpm --filter
@object-ui/app-shell run type-check` (both tsconfigs, the test one
included) exit 0, after building each package's ui closure.
- Ablation 1 (wizard side): `scripts/ablation-replace.mjs` deleted the
`manager_id` entry (anchor 1 to 0, blob `f21b94a1b069` to
`443f297dd4c7`): 3 failed / 8 passed, the drift pin (`manager_id`
missing from the offered list) and both new wizard cases; restored, blob
equals HEAD, `git diff HEAD` empty.
- Ablation 2 (endpoint side): added `const DEPARTMENT_COLUMN =
'department';` to `admin-import-users.ts` (anchor 1 to 0, blob
`14e1ed54e29d` to `78034eddc871`): the drift pin red, `department`
expected and not offered; restored, blob equals HEAD. A first attempt
whose replacement contained its anchor was refused by the tool before
any test ran (a no-op, not a reading).
- `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack`: 40 commands, every one exit 0 (`--ran`: 40
derived, 40 run, 0 NOT-MEASURED) (readings in the os-dev-report comment
on #34536).
- `ui/packages/app-shell` full suite (about 2,300 files) is left to CI's
Test UI.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01ADHkmRXuRn93HphKp7kXEz)_
<!-- signed: repo:objectstack#2 · os-steve ·
session_01ADHkmRXuRn93HphKp7kXEz -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 6880b04 commit b86331d
15 files changed
Lines changed: 191 additions & 1 deletion
File tree
- .changeset
- ui/packages
- app-shell/src/views
- __tests__
- i18n/src/locales
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
47 | 52 | | |
48 | 53 | | |
49 | 54 | | |
| |||
80 | 85 | | |
81 | 86 | | |
82 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
83 | 93 | | |
84 | 94 | | |
85 | 95 | | |
| |||
150 | 160 | | |
151 | 161 | | |
152 | 162 | | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
153 | 173 | | |
154 | 174 | | |
155 | 175 | | |
| |||
168 | 188 | | |
169 | 189 | | |
170 | 190 | | |
| 191 | + | |
171 | 192 | | |
172 | 193 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| |||
81 | 82 | | |
82 | 83 | | |
83 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2133 | 2133 | | |
2134 | 2134 | | |
2135 | 2135 | | |
| 2136 | + | |
2136 | 2137 | | |
2137 | 2138 | | |
2138 | 2139 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1918 | 1918 | | |
1919 | 1919 | | |
1920 | 1920 | | |
| 1921 | + | |
1921 | 1922 | | |
1922 | 1923 | | |
1923 | 1924 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3050 | 3050 | | |
3051 | 3051 | | |
3052 | 3052 | | |
| 3053 | + | |
3053 | 3054 | | |
3054 | 3055 | | |
3055 | 3056 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1974 | 1974 | | |
1975 | 1975 | | |
1976 | 1976 | | |
| 1977 | + | |
1977 | 1978 | | |
1978 | 1979 | | |
1979 | 1980 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1970 | 1970 | | |
1971 | 1971 | | |
1972 | 1972 | | |
| 1973 | + | |
1973 | 1974 | | |
1974 | 1975 | | |
1975 | 1976 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1918 | 1918 | | |
1919 | 1919 | | |
1920 | 1920 | | |
| 1921 | + | |
1921 | 1922 | | |
1922 | 1923 | | |
1923 | 1924 | | |
| |||
0 commit comments