Skip to content

Self-hosted homelab infrastructure visualizer — interactive network diagram with live status monitoring

refactor(rack): tidy the device modal's last row and its actions

Pouzorf51dd131c109
diff --git a/frontend/src/rack/__tests__/RackDeviceModal.test.tsx b/frontend/src/rack/__tests__/RackDeviceModal.test.tsx
index 9684239..51daca0 100644
--- a/frontend/src/rack/__tests__/RackDeviceModal.test.tsx
+++ b/frontend/src/rack/__tests__/RackDeviceModal.test.tsx
@@ -268,6 +268,18 @@ describe('RackDeviceModal — adding', () => {
expect(columns).toContainElement(screen.getByRole('button', { name: 'Add port' }))
})
+ it('pairs Status with the colour override on one row, and rules off the actions', () => {
+ store().openDeviceEditor()
+ render(<RackDeviceModal />)
+
+ const row = screen.getByLabelText('Status').closest('.grid')!
+ expect(row).toContainElement(screen.getByLabelText('Colour override'))
+
+ // The footer is not part of the last section — Save must read as an action
+ // on the whole form.
+ expect(screen.getByRole('button', { name: /^(Save|Add)$/ }).closest('.border-t')).not.toBeNull()
+ })
+
/** The titles of the rules the form is split by, in document order. */
function sectionTitles() {
return screen
diff --git a/frontend/src/rack/components/RackDeviceModal.tsx b/frontend/src/rack/components/RackDeviceModal.tsx
index 59c6264..959ae48 100644
--- a/frontend/src/rack/components/RackDeviceModal.tsx
+++ b/frontend/src/rack/components/RackDeviceModal.tsx
@@ -614,6 +614,7 @@ function DeviceForm({ deviceId, onClose }: { deviceId: string | null; onClose: (
</Field>
</div>
+ <div className="grid grid-cols-2 gap-3">
<Field label="Status">
<select
className={inputClass}
@@ -654,6 +655,7 @@ function DeviceForm({ deviceId, onClose }: { deviceId: string | null; onClose: (
</div>
</Field>
</div>
+ </div>
<div className="flex flex-col gap-3">
{/* An accessory has no ports, so it gets no heading either — a
@@ -702,7 +704,9 @@ function DeviceForm({ deviceId, onClose }: { deviceId: string | null; onClose: (
</div>
</div>
- <div className="mt-1 flex items-center gap-2">
+ {/* Rule between the form and its actions, so Save never reads as part
+ of the last section. */}
+ <div className="mt-1 flex items-center gap-2 border-t border-[#30363d] pt-3">
{isEdit && (
<Button
type="button"
diff --git a/frontend/src/rack/components/SectionHeader.tsx b/frontend/src/rack/components/SectionHeader.tsx
index bfd07ce..caddf15 100644
--- a/frontend/src/rack/components/SectionHeader.tsx
+++ b/frontend/src/rack/components/SectionHeader.tsx
@@ -15,7 +15,9 @@ export function SectionHeader({
return (
<div
data-testid="section-header"
- className="flex items-center justify-between gap-2 border-b border-[#30363d] pb-1"
+ // Fixed height, so a rule with a button in its `aside` still lines up
+ // with the plain one beside it.
+ className="flex h-7 items-center justify-between gap-2 border-b border-[#30363d]"
>
<span className="text-[11px] font-semibold uppercase tracking-wider text-muted-foreground/70">
{children}