Repository navigation
Commit ff784ef
feat(studio): Add view in the Interfaces list-view panel creates a kanban, calendar or other list view (#27870)
domain:ui#3 · os-bill · session_01Utp6CaJoinvGQSbHeDaWBe
<!-- claude-projects-attribution: {"github_login":"os-bill"} -->
_Requested by **Bill** · [project
thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wgKZpitbtaBebZpZsTXoTeoa)_
## 维护者速读
- 改了什么:Studio
界面支柱里,对象的列表视图属性面板多了「添加视图」按钮。点开就是控制台已有的新建视图对话框:先选视图类型(表格、看板、日历、画廊……,来自
spec
的列表视图类型),再按字段标签选该类型必填的字段(看板的分组字段、日历的开始日期和标题字段),再填名称和键。视图直接完整地存进本包草稿,随后属性面板和画布都切到这个新视图,面板上有「返回
…」回到导航入口原来打开的视图。
- 为什么改:以前面板只能编辑入口打开的那一个视图(通常是默认表格),Studio 里没有任何办法新建看板、日历等视图(#27521 第 31
行)。
-
风险与回滚:只改前端;新视图从不设为默认视图,导航入口不改,默认表格一个字节都不写;用的是控制台加视图入口同一个构建器(`buildNewViewSpec`
+ `viewEnvelope`),所以草稿里不会出现半成品视图;键已被占用时什么都不写、对话框不关、提示原因。回滚即 revert 本 PR。
-
先看:`ui/packages/app-shell/src/views/studio-design/ObjectListViewInspector.tsx`(`createView`、面板里的「添加视图」与「返回」)、`ObjectListViewInspector.addView-27836.test.tsx`、`StudioDesignSurface.tsx`(打开对话框前先发出面板里未保存的修改)。
- 两分钟验证:`pnpm --dir ui exec vitest run
packages/app-shell/src/views/studio-design/ObjectListViewInspector.addView-27836.test.tsx`,预期
1 个文件 4 条全部通过(看板、日历、返回入口视图、键重名被拒)。
- 需要你做的:无,席位落地。
Fixes #27836
Clause-②: no
Metadata-protocol: none
## What changes
**Measured first, on `main` at `9ae6384e`.** The Interfaces pillar's
list-view panel (`ObjectListViewInspector`) edits exactly one view: the
one the open nav entry lands on (`listViewTargetOf`), usually the
object's default grid. Nothing in Studio creates a view of another type.
Once a view exists, the panel already edits any list view's columns,
filter and sort, and a kanban's card section (`KanbanCardSection`); a
calendar, gallery, timeline, gantt, map, chart or tree has no section of
its own (see Acceptance notes). The canvas already renders whatever view
the panel holds (`StudioCanvasListViewContext` feeds `object-view`'s
`listViews`), so a kanban or calendar view in the panel shows as a board
or calendar on the canvas.
**"Add view"** is a button at the top of the panel. It opens the
console's existing `CreateViewDialog`, unchanged:
- the type grid is the dialog's total record over
`ListViewVisualization`, which `@object-ui/core` derives from the spec's
view type enum, so no list is kept here;
- the dialog asks the chosen type's required fields first and keeps
Create disabled until each is picked; its field pickers here read the
same fields as the panel's own pickers (the object's fields minus the
platform's hidden system columns), shown by label;
- then a label and a key.
On Create, the new hook method
`useObjectListViewDraft().createView(payload)`:
1. builds the body the console's add-view door builds:
`buildNewViewSpec` (with the panel's seed columns as the fallback, which
mirrors them into `kanban.columns` as the spec requires) wrapped by
`viewEnvelope` (`OBJECT.KEY`, `viewKind: 'list'`, the label,
`config.data` bound to the object);
2. refuses a name a view already holds, published
(`client.list('view')`) or drafted in any package (`client.listDrafts({
type: 'view' })`), writing nothing, as the pillar's New dashboard /
report / page create does;
3. saves it to the package draft with `If-None-Match: *`, so the door
also refuses one drafted between that read and the save;
4. then the panel and the canvas show it. The choice is stamped with the
nav entry it was made on, so it expires by construction when another
leaf opens. "Back to …" shows the entry's view again.
The view is born complete, so the draft never holds a half-made view and
the held-input rule has nothing to hold. It is never the object's
default (`isDefault` is not written), and the nav entry is not changed:
the running app lists every view of the object in its view switcher. A
refusal (taken key, or the door's own refusal) keeps the dialog open
with the author's input, as `CreateViewDialog`'s contract asks, and a
toast says why in the designer locale.
Opening the dialog first sends the panel's pending edit (the pillar's
list-view autosave `flush`), because the view the panel shows changes
once the new one is created and the autosave drops an edit begun on
another target.
## Tests
`ObjectListViewInspector.addView-27836.test.tsx`: the REAL hook, panel
and Create View dialog over a REAL `MetadataClient`, whose transport
judges every view PUT with the installed spec's `view` schema (422 on
refusal):
- a kanban: one PUT, to `acme_task.pipeline_board` in the package with
`If-None-Match: *`, accepted by the spec, `kanban.groupByField:
'status'`, no `isDefault`, no write to the default view; the panel then
shows the board with its card section;
- a calendar: `calendar: { startDateField: 'due_date', titleField:
'title' }`, picked by label, accepted; the panel shows it;
- "Back to …" returns the panel to `acme_task.default`;
- a taken key: no PUT, the dialog stays open, the toast names the key,
the panel stays on the default view.
## Acceptance notes
- **Editing a non-grid view's own settings is not built here.** After
creation, a kanban's card section is editable (it already was); a
calendar's start-date and title fields, and the type-specific blocks of
gallery, timeline, gantt, map, chart and tree, are set only by the
dialog. The panel still edits their columns, filter and sort. Filed by
the seat as #27895.
- **A view created here is reopened in Studio only through a nav entry
that names it.** The panel shows the view it created until another leaf
opens; there is no view switcher inside the panel. In the running app
the view is in the object's view switcher once published. Filed by the
seat as #27896.
- The dialog's own copy (type names, field prompts) comes from the
console bundle (`console.objectView.*`, through `useObjectTranslation`),
so it follows the app's language rather than the Studio's designer
locale; the panel's new strings are in the studio bundle (en, zh).
- Publishing: the view is an ordinary package draft
(`client.save('view', …, { mode: 'draft', packageId })`), published with
the package like every other Studio draft; not exercised in a browser
here.
- No docs page under `content/docs/` describes this panel; none was
changed.
## Verification
Readings for this head are in the report comment on #27836 (tests,
ablation, type-check, the derived gate list reconciled with `--ran`).
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 784dc9a commit ff784ef
6 files changed
Lines changed: 443 additions & 9 deletions
File tree
- .changeset
- ui/packages
- app-shell/src/views/studio-design
- i18n/src/namespaces/studio
| 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 | |
|---|---|---|---|
| |||
| 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 | + | |
| 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 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
0 commit comments