From 69aaf641657d3c25b5119cd59b18eff12e0c8c34 Mon Sep 17 00:00:00 2001 From: lrnselfreliance <33263708+lrnselfreliance@users.noreply.github.com> Date: Tue, 11 Aug 2026 19:12:02 -0600 Subject: [PATCH] ui: the Open button rejoins the service's other actions (#657) On the Control tab, each service's actions -- start/stop, restart, logs -- sit in a `.wrolpi-button-row`, a wrapping flex row. Open sat outside it, after the logs modal, so it was a block-level sibling of the row rather than a member of it: it landed on its own line under the others, on both the mobile and the desktop row. Move it inside the row, after logs. Nothing else changes -- same icon, same link, same order left to right -- and the row already wraps, so a narrow Actions column breaks it where it needs to instead of hard-coding a break at Open. The two row components are now exported so the test can mount them: `Media` renders neither branch under jsdom, where no media query matches, so `ServicesSection` yields no rows there at all and the buttons were untestable through the page. The test asserts that Open shares a `.wrolpi-button-row` with stop, restart and logs, and it fails on the old layout. 68 suites / 1202 tests pass; `npm run build` is clean. --- app/src/components/admin/ControllerPage.js | 50 ++++++++++--------- .../components/admin/ControllerPage.test.js | 44 +++++++++++++++- 2 files changed, 69 insertions(+), 25 deletions(-) diff --git a/app/src/components/admin/ControllerPage.js b/app/src/components/admin/ControllerPage.js index 5c39d240..05d1284c 100644 --- a/app/src/components/admin/ControllerPage.js +++ b/app/src/components/admin/ControllerPage.js @@ -270,7 +270,9 @@ function ServiceLogsModal({ } // Mobile service row - simplified layout -function MobileServiceRow({service, onAction}) { +// Exported so tests can mount a row directly: `Media` renders neither branch in jsdom, +// where no media query matches, so `ServicesSection` produces no rows at all there. +export function MobileServiceRow({service, onAction}) { const { loading, logsOpen, setLogsOpen, logs, logsLoading, linesCount, countdown, logsRef, handleAction, fetchLogs, handleViewLogs, handleLinesChange, handleDownloadLogs, @@ -320,6 +322,17 @@ function MobileServiceRow({service, onAction}) { role='primary' onClick={handleViewLogs} /> + {viewUrl && ( + + )} - {viewUrl && ( - - )} ); } // Desktop service row - full layout with all columns -function DesktopServiceRow({service, onAction, dockerized}) { +export function DesktopServiceRow({service, onAction, dockerized}) { const { loading, logsOpen, setLogsOpen, logs, logsLoading, linesCount, countdown, logsRef, handleAction, fetchLogs, handleViewLogs, handleLinesChange, handleDownloadLogs, @@ -402,6 +404,17 @@ function DesktopServiceRow({service, onAction, dockerized}) { role='primary' onClick={handleViewLogs} /> + {viewUrl && ( + + )} - {viewUrl && ( - - )} {!dockerized && ( diff --git a/app/src/components/admin/ControllerPage.test.js b/app/src/components/admin/ControllerPage.test.js index e2ff6c83..3ebc1901 100644 --- a/app/src/components/admin/ControllerPage.test.js +++ b/app/src/components/admin/ControllerPage.test.js @@ -4,7 +4,8 @@ import {BrowserRouter} from 'react-router'; import {MantineProvider} from '@mantine/core'; import {ThemeContext, SettingsContext} from '../../contexts/contexts'; import {cssVariablesResolver, mantineTheme} from '../../themes/mantine'; -import {ControllerPage} from './ControllerPage'; +import {ControllerPage, DesktopServiceRow, MobileServiceRow} from './ControllerPage'; +import {Table} from '../ui'; // Mock the controller API jest.mock('../../api/controller', () => ({ @@ -352,3 +353,44 @@ describe('ControllerPage in Docker mode', () => { }); }); }); + +describe('service action buttons', () => { + // `Media` renders neither branch in jsdom -- no media query matches -- so `ServicesSection` + // produces no rows there. Mount the rows themselves instead. + const renderRow = (RowComponent, extraProps = {}) => render( + + + + + + +
+
+
+ ); + + test.each([ + ['mobile', MobileServiceRow, {}], + ['desktop', DesktopServiceRow, {dockerized: false}], + ])('the %s row keeps Open on the same line as the other actions', (_name, RowComponent, extraProps) => { + renderRow(RowComponent, extraProps); + // Open used to sit outside `.wrolpi-button-row`, after the logs modal, which put it on a + // line of its own below the rest. It belongs in the flex row with them. + const row = screen.getByLabelText('Open wrolpi-api').closest('.wrolpi-button-row'); + expect(row).not.toBeNull(); + expect(within(row).getByLabelText('Stop wrolpi-api')).toBeInTheDocument(); + expect(within(row).getByLabelText('Restart wrolpi-api')).toBeInTheDocument(); + expect(within(row).getByLabelText('View logs for wrolpi-api')).toBeInTheDocument(); + }); +});