Skip to content

Commit b8ae9c9

Browse files
Torsten Brummclaude
andcommitted
Register layouts in PageLayouts so they appear in admin UI
Both layouts (DefaultView, SideBySideView) are now registered in RT's PageLayouts config (RT::Ticket → Display) at plugin load time, making them visible in Admin → Page Layouts alongside built-in layouts and assignable to queues by administrators. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent c1d728e commit b8ae9c9

2 files changed

Lines changed: 43 additions & 17 deletions

File tree

README.md

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ Switchable ticket display layouts for **Request Tracker 6**.
44

55
Users can choose between two named page layouts — both via their personal
66
preferences and via a one-click toggle button directly in the ticket menu bar.
7-
No administrator involvement is required after installation.
7+
Both layouts are also available in the RT admin interface under
8+
*Admin → Page Layouts*, where they can be assigned to queues like any
9+
built-in layout.
810

911
---
1012

@@ -70,29 +72,42 @@ Narrow metadata column next to a wide transaction history.
7072

7173
## How it works
7274

73-
RT 6 determines the layout of a ticket display page via
74-
`HTML::Mason::Commands::GetPageLayout`, which consults the global
75-
`%PageLayoutMapping` configuration. Because that mapping is global and cannot
76-
vary per user, this extension wraps `GetPageLayout` through RT's standard
77-
overlay mechanism (`lib/RT/Interface/Web_Overlay.pm`). The wrapper checks the
78-
current user's `TicketViewLayout` preference on every ticket display request
79-
and, when a preference is set, returns the matching layout data structure
80-
directly — bypassing the global mapping entirely for that user.
75+
### Layout registration
8176

82-
The preference itself is registered as an `Overridable` RT config option with
83-
a Select widget, so it appears automatically in the standard RT Preferences
84-
page under *Ticket display* without any additional template changes.
77+
At startup the extension registers both layouts in two places:
78+
79+
- **`PageLayouts`** — RT's config key for named layout definitions
80+
(`RT::Ticket → Display → LayoutName`). This makes them appear in
81+
*Admin → Page Layouts* alongside the built-in layouts and allows
82+
administrators to assign them to queues via the normal admin interface.
83+
- **`PageLayoutMapping`** — indirectly, because once a layout name is in
84+
`PageLayouts`, an admin can add a queue assignment there just like any other
85+
layout.
86+
87+
### Per-user preference override
88+
89+
Because the `PageLayout` queue mapping is global, the extension also wraps
90+
`HTML::Mason::Commands::GetPageLayout` via RT's standard overlay mechanism
91+
(`lib/RT/Interface/Web_Overlay.pm`). On every ticket display request the
92+
wrapper checks the current user's `TicketViewLayout` preference and, when set,
93+
returns the matching layout directly — taking priority over any queue-level
94+
assignment for that user.
95+
96+
The preference is registered as an `Overridable` RT config option with a
97+
Select widget so it appears automatically in *Preferences → Ticket display*
98+
without any additional template changes.
99+
100+
### Toggle button
85101

86102
The toggle button is injected into the ticket menu bar via the
87103
`Elements/Tabs/Privileged` callback, using the same `raw_html` / `sort_order`
88-
pattern that RT core uses for Bookmark and Timer. Clicking it performs a GET
89-
request to a small helper page (`SideBySideView/SetLayout.html`) that writes
90-
the new value into the user's preferences and redirects back to the ticket,
91-
which then re-renders with the new layout.
104+
pattern that RT core uses for Bookmark and Timer. Clicking it sends a GET
105+
request to `SideBySideView/SetLayout.html`, which writes the new value into
106+
the user's preferences and redirects back to the ticket.
92107

93108
| File | Role |
94109
|------|------|
95-
| `lib/RT/Extension/SideBySideView.pm` | Registers the `TicketViewLayout` preference meta, defines both layout data structures, and adds the `layout-split` SVG icon to RT's icon set. |
110+
| `lib/RT/Extension/SideBySideView.pm` | Registers the `TicketViewLayout` preference meta, defines both layout data structures, registers them in `PageLayouts`, and adds the `layout-split` SVG icon to RT's icon set. |
96111
| `lib/RT/Interface/Web_Overlay.pm` | Loaded by RT's overlay mechanism at startup. Wraps `GetPageLayout` to honour the per-user layout preference for ticket display pages. |
97112
| `html/Ticket/Elements/SideBySideViewToggle` | Renders the icon link in the menu bar. Reads the current preference and links to the opposite layout. |
98113
| `html/Callbacks/SideBySideView/Elements/Tabs/Privileged` | Adds the toggle element to the ticket page menu at `sort_order => 97` (before Bookmark at 98, Timer at 99). |

lib/RT/Extension/SideBySideView.pm

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,17 @@ our %LAYOUTS = (
9696
],
9797
);
9898

99+
# Register our layouts in RT's PageLayouts so they appear in the admin UI
100+
{
101+
my $pl = RT->Config->Get('PageLayouts');
102+
if ( ref $pl eq 'HASH' ) {
103+
my $ticket_display = $pl->{'RT::Ticket'}{'Display'} //= {};
104+
for my $name ( keys %LAYOUTS ) {
105+
$ticket_display->{$name} //= $LAYOUTS{$name};
106+
}
107+
}
108+
}
109+
99110
=head1 NAME
100111
101112
RT::Extension::SideBySideView - Switchable ticket display layouts for RT 6

0 commit comments

Comments
 (0)