Repository navigation
Commit 3acbeff
refactor(app-shell): move ObjectView's list toolbar affordances into a sibling hook (slice 7) (#26374)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9VtKf3F9dzJPJM4RRtABaEc)_
Part of #25992 (slice 7 of the move-only split; slices 1 to 6 landed as
#26152, #26233, #26310, #26336 and #26353, and the card stays open for
the slices listed below).
Clause-②: no
Metadata-protocol: none
## What moved
Base `3db7bbfc` (slices 5+6 merged).
`ui/packages/app-shell/src/views/ObjectView.tsx` is 2926 lines there.
Concern **D** of the seam table, the list toolbar's affordances, moves
verbatim into the custom hook `useObjectViewToolbarAffordances` in a new
sibling module
`ui/packages/app-shell/src/views/objectViewToolbarAffordances.ts`. It
moves in two blocks:
- lines 503–534: the environment list's entitlements
(`isEnvironmentList`, `useEnvironmentEntitlements`), the read gate on
the object's list actions (`listActionsReadable`, `listActions`), and
`localizedToolbarActions`,
- lines 563–682: the create predicates (`objectCanCreate`,
`createVisible`, `createDisabled`), `listAddRecordOpensCreate`,
`pageOffersCreate` with the capability gate and predicate scope it
reads, and the import predicates (`objectCanImport`, `importVisible`,
`importDisabled`), with every docblock.
The hook is called as `useObjectViewToolbarAffordances({ objectDef,
dataSource, actionRuntime, refreshKey, perms, localizeActionTexts,
newVerdict, importVerdict })`. It returns the twelve names the rest of
the component reads, and the component destructures them under their
original names. No identifier is renamed and no context is added. The
parameters are typed from their sources, with no `any`:
`ConsoleObjectViewProps['objects'][number]`, `DataSource`,
`Pick<ConsoleActionRuntime, 'authFetch'>`, `ReturnType<typeof
usePermissions>`, `ReturnType<typeof useActionTextLocalizer>`, and
`ReturnType<typeof resolveAffordance>` for both verdicts.
**What stays.** The verdict memo between the two blocks (lines 536–557:
`newVerdict` and `importVerdict` from `resolveAffordance('listNew' |
'listImport', …)`) stays in the component and is passed in.
`affordanceGrantMap-12082.test.tsx` keys the `listImport` row's reader
by file: the write site `ImportWizard > legacyImport :: create` names
`ObjectView.tsx` as a file that reads `listImport`, and every file it
names must read one of its rows. Keeping the `resolveAffordance` call
here keeps that census green with no test edit. The three-line comment
on `refreshKey` after the memo stays too.
**Hook order.** The hook is called right after the verdict memo, so the
first block's hooks (`useEnvironmentEntitlements`, the
`localizedToolbarActions` memo) now run after that memo instead of
before it. They share no value with it, the order is the same on every
render, and no effect sits between them, so the effects' order is
unchanged.
**Imports.** Each import moves with its only readers: `useRowPredicate`,
`useCapabilityGate`, `usePredicateScope`, `RowCrudPredicates`,
`listToolbarDrawsAction`, `mayReadObject` and
`useEnvironmentEntitlements`. Nothing new is exported from
`ObjectView.tsx`, and the package entry is untouched. `ObjectView.tsx`
goes from 2926 to 2797 lines.
Move-only proof: the multiset of non-blank lines of the base
`ObjectView.tsx` is contained in new `ObjectView.tsx` plus
`objectViewToolbarAffordances.ts`. The only base lines missing are the
two import lines that lost a moved name (`managedByEmptyState.js`,
`@object-ui/react`), each replaced by its trimmed form. The added lines
are the trimmed imports and the new import, the module header and
imports, the hook signature and parameter types, the `return` object,
and in `ObjectView.tsx` the call with its destructuring and two-line
comment.
## Test edits
None. `affordanceGrantMap-12082` is covered by keeping the verdict memo
in place (above). No other source reader of `ObjectView.tsx` names a
moved line.
## Seam table rows this PR changes (measured on `3db7bbfc`)
The full table (regions A to Q) is in #26336.
| # | Concern | Lines on `3db7bbfc` | Reads | Read by | Slice |
|---|---|---|---|---|---|
| D | Environment entitlements, list actions, create and import toolbar
predicates | 503–534, 563–682 | A (`localizeActionTexts`), C
(`objectDef`, `perms`, `refreshKey`, `actionRuntime`), D-verdicts, prop
`dataSource` | G, O, P, Q | **7, this PR** |
| D-verdicts | `resolveAffordance` verdicts for `listNew` and
`listImport` | 536–557 | C (`objectDef`, `perms`) | D | stays (grant
census reads it in this file) |
## Remaining slices (the last closes the card)
- **Slice 8 — G + H + L-filter:** header toolbar actions, the list URL
state and the URL/user filter block into sibling hooks; re-points
`ObjectView.urlFilterSuffix-9196.test.ts` to the new file as a path-only
edit if L-filter moves.
- **Slice 9 — N + P:** the view tab bar and the plugin schema plus
header chrome.
- **Slice 10 — Q:** the JSX return's `PageHeader`, import wizard and
`NavigationOverlay` blocks into sub-components with explicit props.
- **Slice 11 — B + I + O (closes the card):** the view-config and
view-tab CRUD handlers and `renderListView`, with the
`writeRefusalCensus-11583` rows and the `relayRungCensus-7559` read
re-pointed (path and file-key changes only).
## Verification
See the os-dev-report comment on the card for the full readings:
app-shell `type-check` after rebuilding its dependency closure, every
`ObjectView.*` test in `views/`, the `AppContent*` tests, every other
test that reads `ObjectView.tsx` as source, the app-shell tests that
touch environment entitlements, the managed-by empty state, the object
read gate or the CRUD affordances, eslint on the 2 touched files, the
derived dispatch gates, and a Console build.
## Acceptance notes
- eslint: 0 errors, and no new warning. The two files report 131
warnings, the same count as the base `ObjectView.tsx` alone; the two in
the new module are casts moved verbatim (`(import.meta as any).env`, the
`(a: any)` map callback).
Changeset: `.changeset/25992-objectview-toolbar-affordances-split.md`
(patch, `@object-ui/app-shell`).
---
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01QciHBvFJXnhZqXmdqpDtpz
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 2e7127b commit 3acbeff
3 files changed
Lines changed: 249 additions & 159 deletions
File tree
- .changeset
- ui/packages/app-shell/src/views
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
77 | 76 | | |
78 | 77 | | |
79 | 78 | | |
80 | 79 | | |
81 | | - | |
82 | | - | |
| 80 | + | |
83 | 81 | | |
84 | 82 | | |
85 | 83 | | |
86 | 84 | | |
87 | 85 | | |
88 | 86 | | |
89 | 87 | | |
90 | | - | |
| 88 | + | |
91 | 89 | | |
92 | 90 | | |
93 | 91 | | |
94 | 92 | | |
95 | | - | |
96 | 93 | | |
97 | 94 | | |
98 | 95 | | |
| |||
125 | 122 | | |
126 | 123 | | |
127 | 124 | | |
| 125 | + | |
128 | 126 | | |
129 | 127 | | |
130 | 128 | | |
| |||
500 | 498 | | |
501 | 499 | | |
502 | 500 | | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
507 | | - | |
508 | | - | |
509 | | - | |
510 | | - | |
511 | | - | |
512 | | - | |
513 | | - | |
514 | | - | |
515 | | - | |
516 | | - | |
517 | | - | |
518 | | - | |
519 | | - | |
520 | | - | |
521 | | - | |
522 | | - | |
523 | | - | |
524 | | - | |
525 | | - | |
526 | | - | |
527 | | - | |
528 | | - | |
529 | | - | |
530 | | - | |
531 | | - | |
532 | | - | |
533 | | - | |
534 | | - | |
535 | | - | |
536 | 501 | | |
537 | 502 | | |
538 | 503 | | |
| |||
556 | 521 | | |
557 | 522 | | |
558 | 523 | | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
559 | 550 | | |
560 | 551 | | |
561 | 552 | | |
562 | 553 | | |
563 | | - | |
564 | | - | |
565 | | - | |
566 | | - | |
567 | | - | |
568 | | - | |
569 | | - | |
570 | | - | |
571 | | - | |
572 | | - | |
573 | | - | |
574 | | - | |
575 | | - | |
576 | | - | |
577 | | - | |
578 | | - | |
579 | | - | |
580 | | - | |
581 | | - | |
582 | | - | |
583 | | - | |
584 | | - | |
585 | | - | |
586 | | - | |
587 | | - | |
588 | | - | |
589 | | - | |
590 | | - | |
591 | | - | |
592 | | - | |
593 | | - | |
594 | | - | |
595 | | - | |
596 | | - | |
597 | | - | |
598 | | - | |
599 | | - | |
600 | | - | |
601 | | - | |
602 | | - | |
603 | | - | |
604 | | - | |
605 | | - | |
606 | | - | |
607 | | - | |
608 | | - | |
609 | | - | |
610 | | - | |
611 | | - | |
612 | | - | |
613 | | - | |
614 | | - | |
615 | | - | |
616 | | - | |
617 | | - | |
618 | | - | |
619 | | - | |
620 | | - | |
621 | | - | |
622 | | - | |
623 | | - | |
624 | | - | |
625 | | - | |
626 | | - | |
627 | | - | |
628 | | - | |
629 | | - | |
630 | | - | |
631 | | - | |
632 | | - | |
633 | | - | |
634 | | - | |
635 | | - | |
636 | | - | |
637 | | - | |
638 | | - | |
639 | | - | |
640 | | - | |
641 | | - | |
642 | | - | |
643 | | - | |
644 | | - | |
645 | | - | |
646 | | - | |
647 | | - | |
648 | | - | |
649 | | - | |
650 | | - | |
651 | | - | |
652 | | - | |
653 | | - | |
654 | | - | |
655 | | - | |
656 | | - | |
657 | | - | |
658 | | - | |
659 | | - | |
660 | | - | |
661 | | - | |
662 | | - | |
663 | | - | |
664 | | - | |
665 | | - | |
666 | | - | |
667 | | - | |
668 | | - | |
669 | | - | |
670 | | - | |
671 | | - | |
672 | | - | |
673 | | - | |
674 | | - | |
675 | | - | |
676 | | - | |
677 | | - | |
678 | | - | |
679 | | - | |
680 | | - | |
681 | | - | |
682 | | - | |
683 | | - | |
684 | 554 | | |
685 | 555 | | |
686 | 556 | | |
| |||
0 commit comments