Repository navigation
Commit f339060
feat(ui): New Package offers 「同时创建应用」 / Also create an app, ticked by default (#37338)
Fixes #37134
Clause-②: no
Metadata-protocol: none
## 维护者速读
-
在设置的「软件包」页点「新建软件包」,或从「添加应用」菜单、首页等「新建空白应用」入口进到同一个对话框时,名称下面多了一个勾选项「同时创建应用」,默认勾上;勾上时一次确定就同时建好软件包和同名应用,进到
Studio 左上角显示应用名;取消勾选就和以前一样只建软件包。
- 这是 Studio 重构专题的一步:去掉 Studio
首页以后,原来首页上一步建好包和应用的入口没了,这个勾选项把它补回到唯一的新建软件包对话框里。
-
如果应用的名字已被别的应用占用,什么都不会写入,对话框直接说明是哪个应用占用了,可以到「高级」里改命名空间或取消勾选;软件包建好但应用没能上线时会弹提示。只改界面,不改服务器和数据,可以直接撤回。
- 无。
## What changes
- **The create-package dialog offers 「同时创建应用」 / "Also create an app",
ticked on every opening.** `PackageFormDialog` in create mode with a
`newApp` step now draws the checkbox under the description in the Basics
card. Ticked, it runs the step exactly as the Studio home's door did
(#36748): reserve a free app name before any write (a taken one refuses
the whole confirm, opens Advanced and writes nothing), `POST
/api/v1/packages`, then the app's draft under the first-write pin and
that one item's publish. Unticked, it posts the package alone, as
before. A refused app after the package landed keeps the existing
`appFailed` toast.
- **The dialog keeps its package face.** `newApp` used to reword the
whole dialog for an app (title 「新建应用」, 「应用 ID」, the help rows). That
face's only host, the Studio home, was removed by #36908, and the card
puts the choice in the package dialog, so the rewording branch
(`withAppDoorWording` and the `appDoor` ternaries) is removed. Success
with an app now reads "Created package “NAME” and its app." (new key); a
409 and a generic failure read the package dialog's own lines.
- **Every door gets it.** `CreatePackageDialog` builds
`newAppStep(client, locale)` and passes it; it is the only create-mode
mount of `PackageFormDialog` in app-shell. Its doors: Setup → Packages'
New Package button (both faces), the `?new=package` door that the
console's 「新建空白应用」 entries open (#36908), and ResourceListPage's
create-a-package-first prompt. `onCreated` still answers with the
package id, so each door lands where it did: Setup's admin face in
Studio on the new package (whose header then names the app), the
development face on the list, the resource list on `./new?package=…`.
- **Strings:** `engine.packages.create.alsoApp`,
`engine.packages.create.alsoAppHint` and
`engine.packages.create.createdWithApp` in the studio catalogue (en,
zh). Additive only; no key removed.
- Not touched: the server, and decision 5's fallback for app-less
packages (#36899): an installed, older or unticked package still shows
its package name in Studio's header.
## Tests
- `PackageFormDialog.newAppStep-36748.test.tsx` (the shared harness:
real dialog, real `newAppStep`, real metadata client and
`StudioDesignSurface` over a stateful fetch stub). New top-level
describes, all mounting the real `CreatePackageDialog`:
- the box is there and ticked on every opening, in en and zh (unticked,
cancelled, reopened: ticked again);
- ticked: `POST package` → `PUT app draft` → `POST app publish`, the app
is the new package's, the toast, and Studio's header names the app;
- unticked: only `POST /api/v1/packages`, no app or draft, the package
toast, the header names the package;
- ticked with both candidate app names taken: the refusal names the
holding app, Advanced opens, nothing is written; unticking clears the
refusal and the package alone goes through;
- every door: a source read of app-shell finds `CreatePackageDialog`
mounted exactly in `PackagesPage.tsx` and `ResourceListPage.tsx`, no
other create-mode `PackageFormDialog`, and the wrapper passing
`newAppStep(client, locale)`.
- The #36748 cases survived #36908's move whole (three cases). Case 1
pinned the app-worded face this card removes; it now pins the package
face with the box ticked, plus a CONTROL that a dialog without a step
offers no box. Case 2's toast assertion reads the new success line; the
rest of it (writes, header, back link) is unchanged.
- `PackagesPage.installedAppsUpdates-34722.test.tsx`: the page's dialog
stand-in now reports whether it was handed the step; three cases pin it
for the admin face's button, the `?new=package` door and the development
face's button.
<details><summary>Ablations — each one red, then restored by
hash</summary>
Mutations through `scripts/ablation-replace.mjs` (anchor must hit,
on-disk counts printed), restored with `git checkout HEAD -- PATH` and
checked by blob hash and an empty `git diff HEAD`. app-shell's tests
import the dialog and the page by relative path, so no `dist/` is in the
resolution path.
| # | Mutation | Red |
|:--|:--|:--|
| A1 | `appStep` always `undefined` (ticked creates no app) | 4: both
"ticked" cases and both "taken" cases |
| A2 | `appStep` ignores the box | 2: "unticked" and the
taken-then-untick case |
| A3 | the taken arm never fires | 2: both "taken" cases |
| A4 | the box resets to unticked on open | 8: every case that reads the
default |
| A5 | `CreatePackageDialog` passes `newApp={undefined}` | 9: the three
PackagesPage door cases, every `CreatePackageDialog` case, the wrapper
source pin |
| A6 | ResourceListPage mounts `PackageFormDialog mode="create"` itself
| 2: both door source pins |
A5's first attempt used an empty replacement, which the tool refused
(nothing landed); it was re-run with `newApp={undefined}`. All six
restore lines matched the HEAD blob.
</details>
## Acceptance notes
- The card's file surface names "the Studio package switcher" as a call
site. It no longer exists: the top-bar switcher was removed by #36501
(`PackageSwitcher.tsx` now only exports a toast id), so there is no such
door to wire. The doors that exist are listed above.
- The app-worded rows (`engine.studio.newApp.title`, `description`,
`advancedHint`, `id`, `help.*`, `nsDerived`, `exists`, `failed`) have no
reader after this change. They stay, because this card removes no
released key; `nameTaken` and `appFailed` are still read. The en
catalogue's comment says so. `check:i18n-dead-keys` is report-only.
- The submit button stays "Create package" with the box ticked; the
checkbox and its hint say an app comes with it.
- A Studio-only author who cannot open Setup → Packages still has no New
Package door (#36908's note); that is #37139's, not this card's.
## Verification
Two-minute check: `pnpm dev`, open Setup → Packages, New Package, type a
name, keep 「同时创建应用」 ticked, Create. Expected: the toast "Created package
“NAME” and its app.", then Studio on the new package with 「‹ Back to app
· NAME」 in the header. Repeat unticked: the package toast, and the
header shows the package name.
Read first: `PackageFormDialog.tsx` (the `appStep` line in `submit()`
and the checkbox in the Basics card), `PackagesPage.tsx`
(`CreatePackageDialog`), then the new describes at the end of
`PackageFormDialog.newAppStep-36748.test.tsx`.
<details><summary>Local runs (head 97fa2d8)</summary>
All at head `97fa2d83` unless noted; exit codes captured before any
pipe.
- vitest, `PackageFormDialog.newAppStep-36748`: Test Files 1 passed (1),
Tests 11 passed (11); lock VERDICT command-exit 0.
- vitest, `PackageFormDialog*`,
`PackagesPage.installedAppsUpdates-34722`, `CreatePackageDialog*` (at
`4179e152`, test-only rename since): Test Files 17 passed (17), Tests
195 passed; then `PackagesPage*`, `ResourceListPage*`,
`EditPackageDialog*`, `StudioDesignSurface.createApp*`: Test Files 36
passed (36), Tests 313 passed (313).
- `pnpm --filter @object-ui/app-shell type-check` (src +
`tsconfig.test.json`), after building the `@object-ui/app-shell^...`
closure: lock VERDICT command-exit 0, 0 TS errors.
- eslint `--no-inline-config` on the six touched source files: exit 0
(warnings only, all pre-existing lines).
- `pnpm --dir ui exec vitest run scripts/`: Test Files 172 passed, 2
skipped (174); Tests 5130 passed. The first run on `28a9d57a` failed
`check-test-path-roots` on the new test (a local named `path` read as
the fetch stub's URL path); fixed by the rename in `97fa2d83`.
- `check:test-source-alias` exit 0 · `check:i18n-keys` exit 0 ·
`scripts/pm/overlap-check.mjs` VERDICT clean exit 0 (merges cleanly with
main and #37315, which shares the two studio catalogues).
- `dispatch-gates.mjs --commands`: 39 derived families, all run at
`97fa2d83`, all exit 0; `--ran` reconciliation: 39 derived, 39 run, 0
NOT-MEASURED (a derived zero: every row carries its exit code).
</details>
<!-- signed: repo:objectstack#4 · os-justin ·
session_01QSeKYkkwuF6UuFtu85Yd5H -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent a182fbe commit f339060
7 files changed
Lines changed: 365 additions & 80 deletions
File tree
- .changeset
- ui/packages
- app-shell/src/views/metadata-admin
- 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 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
9 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
| |||
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
24 | 32 | | |
25 | 33 | | |
26 | 34 | | |
| |||
59 | 67 | | |
60 | 68 | | |
61 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
62 | 73 | | |
| 74 | + | |
63 | 75 | | |
64 | 76 | | |
65 | 77 | | |
| |||
206 | 218 | | |
207 | 219 | | |
208 | 220 | | |
209 | | - | |
210 | | - | |
| 221 | + | |
| 222 | + | |
211 | 223 | | |
212 | 224 | | |
213 | 225 | | |
214 | | - | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
215 | 229 | | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
221 | 238 | | |
222 | 239 | | |
223 | 240 | | |
| |||
245 | 262 | | |
246 | 263 | | |
247 | 264 | | |
248 | | - | |
| 265 | + | |
| 266 | + | |
249 | 267 | | |
250 | 268 | | |
251 | 269 | | |
| |||
280 | 298 | | |
281 | 299 | | |
282 | 300 | | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
0 commit comments