9.3 KiB
Theme fixes from the first dogfood: doc notes
Notes for the THEMES.md and README chapters. Each section says what changed and what the docs should say.
The app shell knows the area (layout.app model area)
AppLayoutModel.area says where the user is and carries the model of that area's own layout:
type AppArea =
| { kind: 'dashboard' } // the dashboard and any page outside the areas below
| ({ kind: 'account' } & AccountLayoutModel) // { nav }
| ({ kind: 'server' } & ServerLayoutModel) // { name, identifier, uuid, internalId, state, conflict, adminLink, nav, server }
| ({ kind: 'admin' } & AdminLayoutModel); // { nav, user }
nav.itemsare the same items the area's layout gets: filtered by subuser permissions and egg rules. Render them with<Navigation items={area.nav.items}>, which applies extension screen gates and badges.- A sidebar theme draws every navigation in
layout.appand overrideslayout.server,layout.accountandlayout.adminwith thin layouts, e.g.({ children }) => <Main>{children}</Main>. Render the area's slots (server.navigation.before/afterwithdata={area.server},account.navigation.*,panel.navigation.*) where the shell draws that navigation. The dev-mode "renders none of its slots" check counts slots a view's enclosing views render, so a thin layout does not warn when the shell renders its slots. - Fixtures:
layout.apphasaccountArea,serverAreaandadminAreabesides the dashboard ones (user,admin,schemes,logo).
Recipe (sidebar part):
function AreaNav({ area }: { area: AppArea }) {
if (area.kind === 'dashboard') return null;
const items = area.kind === 'server' && area.adminLink ? [...area.nav.items, area.adminLink] : area.nav.items;
return (
<nav aria-label={area.kind === 'server' ? area.name : 'Section'}>
{area.kind === 'server' && <Badge>{area.state ?? 'unknown'}</Badge>}
<Navigation items={items}>
{(item, { badge }) => (
<NavigationLink item={item}>
{item.icon && <NamedIcon name={item.icon} size={16} aria-hidden />}
{item.label}
{badge}
</NavigationLink>
)}
</Navigation>
</nav>
);
}
Server power state on layout.server (state, uuid)
ServerLayoutModel gained uuid and state: ServerRunState | null ('offline' | 'starting' | 'running' | 'stopping', as server.power and server.stats name it). It is the cached resources query, fetched once
when the server opens and kept live by the server's websocket, which now writes every status event into
that cache (so dashboard cards returning from a server show the latest state too). Fixtures: owner,
subuser, admin are running; new offline; installing and suspended are offline.
<Main>
- Exactly one
<main>renders, from the outermost<Main>; nested ones render their children in place. - A nested
<Main className="…">now keeps its classes on a<div>around its children instead of dropping them. A nested<Main>without a class adds no element.
Failing layers
- A theme or extension layer that throws falls back to the layer below once. If a layer below the failed
one throws too (classic included), the panel's standard error notice renders for that view, with a
Retry that tries the failed layer again. Nothing re-renders in a loop (before, an effect throwing in
classic under a failed theme layer re-mounted forever, e.g.
server.graphswithoutResizeObserver). - Each failure logs one
console.error:[extensions] "<layer id>" failed in view "<view>": <error>. - The inspector is gone (see below); the console line is how to spot a failing layer.
Strict test renderers
renderView(name, options)throws when the view fails to render, and when any theme or extension layer throws:The "theme" layer of view "server.graphs" failed: <message>(aViewLayerErrorwithview,layerandcause). Nested views count.{ strict: false }lets layers fall back as in the panel. Failures after the first render (say on a click) are thrown byunmount().createViewTestHost(name, options)is strict too: the layer under test or a nested layer that throws fails the render (the error propagates out of RTL'srender/act).{ strict: false }opts out.ViewLayerErroris exported from@pterodactyl/sdk/testing.renderView(name, { slots: { 'server.navigation.before': () => <span>probe</span> } })mounts components in slots as an extension'sslots.registerwould, typed per slot; they are removed on unmount. Use it to test that a view renders the slots it replaces.- The SDK's Vitest setup (
pterodactylTestSetup) now providesResizeObserver,IntersectionObserver(inert) andmatchMedia(matches nothing) besidesPointerEventandscrollTo. Theme tests need no stubs;vi.stubGlobalstill replaces them where a test drives them. usePanelLocation()works in views rendered from fixtures (tests): outside a route it returns the path with emptyparamsandsearchinstead of throwing.
Navigation details
-
Every core nav item has an
icon(lucide name forNamedIcon):- account: Account
user-round, API Credentialskey-round, SSH Keysterminal, Activityhistory; - server: Console
square-terminal, Filesfolder, Databasesdatabase, Schedulescalendar-clock, Usersusers, Backupsarchive, Networknetwork, Startuprocket, Settingssettings, Activityhistory; the admin link staysexternal-link; - admin: Activity is now
history(the rest had icons already). AppLayoutLink.icon: dashboardlayers, adminuser-cog, accountuser-round. Classic still shows its account and server tabs as text (extension screens keep their icons), throughviews/layout/tabLabel.tsx, whichejectcopies with those layouts; its admin sidebar now shows the history icon for Activity instead of the fallback puzzle.
- account: Account
-
DropdownMenu.Itemtakesdestination(aPanelDestination): the item renders as a link (<a href>,role="menuitem", same skin parts) that navigates and closes the menu.<DropdownMenu.Item destination={{ to: '/account' }}>Account</DropdownMenu.Item> -
Closing a drawer on navigation: an effect on the path, which also works in tests.
const { pathname } = usePanelLocation(); useEffect(() => setOpen(false), [pathname]);No
useOnNavigatehook was added; this is two lines and needs no new concept.
Layout spacing tokens
--layout-gutter(defaultcalc(var(--spacing) * 4)): page content's side margin until it centres.--layout-content-width(existing): its maximum width (max-w-panel).page-widthutility: the geometryPageContentBlockandServerContentBlockuse (max width--layout-content-width,--layout-gutterat the sides, centred fromxl). Put it on a layout's own header to line up with the pages below:<header className="page-width mt-4 sm:mt-6">. Core renders exactly as before.
Palette
text-white, bg-black/15 etc. work in theme builds again: --color-white and --color-black are
defined after the palette reset. transparent, current and inherit always worked. The rest of
Tailwind's default palette stays removed; add colours in @theme as before. Core's compiled CSS is
unchanged.
Packaging
defineThemeConfig({ …, sourcemap }): off by default for themes, because a map embeds the sources.sourcemap: trueturns it on (e.g. for a private build). Extensions keepsourcemap: true.p:extension:packleaves*.mapfiles out of the archive unless given--sourcemaps.- The theme scaffold's
npm run packpasses--force, so re-packing replaces the archive, and its.gitignore(shared with extensions) ignores*.pteroext.
Scaffold paths
p:extension:make <id> --path=<dir>creates the package in exactly<dir>.--out=<dir>(unchanged) is the parent: the package goes in<dir>/<id>.--helpsays so.- Passing both fails before writing anything.
Removed: the theme workbench
/panel/theme-workbench, page.admin.themeWorkbench, the workbench components, the UI-kit gallery
(themes/gallery.tsx), preview frames and the portal-container context that sent overlays into them,
and the Workbench button on the Themes page are gone. View fixtures, renderView, renderPrimitive
(same primitive names), createViewTestHost and preloadTheme remain; tests are the way to render views
without a backend. Docs should drop the workbench section, its URL parameters (view, fixture, scheme,
width, ui) and the scaffold README's mention (done in the stub). Portal renders into
#modal-portal, or the body where there is none (as in tests), so createViewTestHost no longer adds a
#modal-portal for the file manager. Dialogs, menus, selects and tooltips portal into the body again.
The planned useViewDocument() hook and the width= URL parameter fix were dropped with the workbench.
Removed: the inspector
The Alt-click inspector, its floating button, the data-view wrappers, the view probes
(ViewInspectionContext), ?inspect=1 and SiteConfiguration.theme.inspect (server payload and client
type) are gone. Failing layers log a console.error naming the view and the layer instead.