Skip to content

refactor(frontend): audit & standardize component usage across all pages #21

Open

Description

@SckyzO

Context

The frontend design system has matured significantly. A full component library exists and is documented at the /templates/default route (TemplateDefaultPage.tsx). However, many pages were built before the library was complete and contain:

  • Inline component re-implementations that duplicate shared components
  • Imports from templates/EmptyPage for things that now live in dedicated component files
  • LoadingState spinners in list/table contexts where skeleton loaders would be more appropriate
  • Various patterns that should now use shared primitives

This issue tracks the full audit and standardisation effort. It should be done on a dedicated PR: refactor/frontend-component-standardisation.


Design System Reference (READ THIS FIRST)

Canonical showcase

Route: /templates/default
File: frontend/src/app/pages/templates/TemplateDefaultPage.tsx

This is the single source of truth. Every shared component is demonstrated there with all variants. Always consult it before implementing anything.

Component inventory

Category Component Import path
Layout PageHeader @app/pages/templates/EmptyPage
PageBreadcrumb @app/pages/templates/EmptyPage
SectionCard @app/pages/templates/EmptyPage
Modal, ModalHeader, ModalFooter @app/components/layout/Modal
Drawer, DrawerHeader @app/components/layout/Drawer
Tabs @app/components/layout/Tabs
ConfirmationModal @app/components/layout/ConfirmationModal
Actions PageActionButton, PageActionIconButton @app/components/PageActionButton
RefreshButton, useAutoRefresh @app/components/RefreshButton
Feedback LoadingState @app/components/feedback/LoadingState
EmptyState @app/components/feedback/EmptyState
ErrorState @app/components/feedback/ErrorState
UI Primitives Spinner @app/components/ui/Spinner
StatusPill @app/components/ui/StatusPill
StatusDot @app/components/ui/StatusDot
IconBox @app/components/ui/IconBox
AlertBanner @app/components/ui/AlertBanner
SelectInput @app/components/ui/SelectInput
Dropdown @app/components/ui/Dropdown
Tooltip, TooltipHelp @app/components/ui/Tooltip
SectionLabel @app/components/ui/SectionLabel
ZoomBar @app/components/ui/ZoomBar
StatefulSaveButton @app/components/ui/StatefulSaveButton
UnsavedIndicator @app/components/ui/UnsavedIndicator
Sk, SkeletonText, SkeletonTable, SkeletonList @app/components/ui/Skeleton
Forms SearchInput @app/components/forms/SearchInput
FilterPills @app/components/forms/FilterPills
SegmentedControl @app/components/forms/SegmentedControl
ToggleSwitch @app/components/forms/ToggleSwitch
StepperInput @app/components/forms/StepperInput
NumberInput @app/components/forms/NumberInput
FormRow @app/components/forms/FormRow
Data KpiCard @app/components/data/KpiCard
MiniCalendar @app/components/data/MiniCalendar
Timeline (variants: dot / avatar / card) @app/components/data/Timeline

PageActionButton variants

variant="outline"        // default — gray border
variant="primary"        // brand filled
variant="brand-outline"  // brand border
variant="danger-outline" // red border

Input style pattern (forms inside modals/cards)

const inputCls = 'focus:border-brand-500 h-9 w-full rounded-lg border border-gray-200 bg-white px-3 text-sm focus:outline-none dark:border-gray-700 dark:bg-gray-800 dark:text-white dark:placeholder-gray-500';

useAutoRefresh usage pattern

// Hook does NOT call on mount — requires a separate useEffect for initial load
const { autoRefreshMs, onIntervalChange } = useAutoRefresh('page-key', fetchData);
useEffect(() => { void fetchData(); }, [fetchData]);

Known Issues Found During Audit

1. Inline Toggle components duplicating ToggleSwitch

At least 4 files define their own inline Toggle component instead of using ToggleSwitch:

  • frontend/src/app/pages/views/ClusterPage.tsx (line ~186)
  • frontend/src/app/pages/NotificationsFullPage.tsx (inline toggle ~line 708)
  • frontend/src/components/settings/sections/ViewsSettingsSection.tsx (line 55)
  • frontend/src/components/settings/sections/SecuritySettingsSection.tsx (line 14)

Fix: Replace with <ToggleSwitch checked={...} onChange={...} label="..." /> from @app/components/forms/ToggleSwitch.

2. LoadingState / EmptyState / ErrorState imported from wrong source

Several pages import these from templates/EmptyPage instead of the dedicated component files:

// ❌ Wrong
import { LoadingState, EmptyState, ErrorState } from './templates/EmptyPage';

// ✅ Correct
import { LoadingState } from '@app/components/feedback/LoadingState';
import { EmptyState } from '@app/components/feedback/EmptyState';
import { ErrorState } from '@app/components/feedback/ErrorState';

Affected app pages:
NotificationsFullPage, PlaylistCenterPage, LogsPage, views/SitePage, views/ClusterPage, views/RoomPage, slurm/Slurm*, all editors/ pages.

3. LoadingState in list/table contexts → migrate to SkeletonList / SkeletonTable

LoadingState (centered spinner) should be replaced by skeleton presets in list/table pages for better perceived performance:

Page Skeleton to use
NotificationsFullPage SkeletonTable
slurm/SlurmAlertsPage SkeletonList
slurm/SlurmNodesPage SkeletonTable
slurm/SlurmPartitionsPage SkeletonTable
editors/MetricsEditorPage SkeletonList
editors/TemplatesEditorPage SkeletonList
editors/ChecksEditorPage SkeletonList
editors/RackTemplateEditorPage SkeletonList

4. StatusBadge from templates/EmptyPage vs StatusPill

templates/EmptyPage exports a StatusBadge. The canonical components are now StatusPill and StatusDot from @app/components/ui/. Audit occurrences and migrate where possible.

5. Settings sections with non-standard form patterns

ViewsSettingsSection.tsx and SecuritySettingsSection.tsx use inline Toggle components and raw label/control divs instead of FormRow + ToggleSwitch. Standardise to the FormRow pattern used in TemplateDefaultPage section 5.5.


Pages to Audit (full checklist)

App pages

  • pages/NotificationsFullPage.tsx — import sources, inline toggle, SkeletonTable
  • pages/LogsPage.tsx — import sources
  • pages/PlaylistCenterPage.tsx — import sources
  • pages/ProfilePage.tsx — import sources
  • pages/AboutPage.tsx — import sources
  • pages/DashboardPage.tsx — general audit
  • pages/MaintenancesPage.tsx ✅ reference implementation — skip

Infrastructure views

  • pages/views/SitePage.tsx
  • pages/views/RoomPage.tsx
  • pages/views/ClusterPage.tsx — inline Toggle
  • pages/views/RackPage.tsx
  • pages/views/DevicePage.tsx
  • pages/views/WorldMapPage.tsx

Slurm pages

  • pages/slurm/SlurmOverviewPage.tsx
  • pages/slurm/SlurmAlertsPage.tsx
  • pages/slurm/SlurmNodesPage.tsx
  • pages/slurm/SlurmPartitionsPage.tsx
  • pages/slurm/SlurmWallV2Page.tsx

Editors

  • pages/editors/SettingsPage.tsx
  • pages/editors/ChecksEditorPage.tsx
  • pages/editors/MetricsEditorPage.tsx
  • pages/editors/TemplatesEditorPage.tsx
  • pages/editors/RackTemplateEditorPage.tsx
  • pages/editors/TopologyEditorPage.tsx
  • pages/editors/DatacenterEditorPage.tsx
  • pages/editors/RackEditorPage.tsx

Settings components

  • components/settings/sections/ViewsSettingsSection.tsx
  • components/settings/sections/SecuritySettingsSection.tsx
  • Other sections/ files

Implementation Rules for This PR

  1. No functional changes — pure refactoring. Same behaviour, better imports and smaller files.
  2. Run make lint after every file — 0 errors, 0 warnings required.
  3. MaintenancesPage.tsx is the gold standard — built against the current design system from scratch. Use it as reference.
  4. Consult /templates/default for every component before using it.
  5. Do not introduce new abstractions — only migrate to existing shared components.
  6. Work file by file, commit per logical group (e.g. refactor(slurm): migrate to shared components).

What Good Looks Like (reference: MaintenancesPage.tsx)

// ✅ Imports
import { PageHeader, PageBreadcrumb, SectionCard } from '@app/pages/templates/EmptyPage';
import { Modal, ModalHeader, ModalFooter } from '@app/components/layout/Modal';
import { RefreshButton, useAutoRefresh } from '@app/components/RefreshButton';
import { PageActionButton } from '@app/components/PageActionButton';
import { IconBox } from '@app/components/ui/IconBox';
import { SelectInput } from '@app/components/ui/SelectInput';
import { AlertBanner } from '@app/components/ui/AlertBanner';
import { FilterPills } from '@app/components/forms/FilterPills';
import { SkeletonList } from '@app/components/ui/Skeleton';
import { EmptyState } from '@app/components/feedback/EmptyState';
import { ErrorState } from '@app/components/feedback/ErrorState';

// ✅ Loading state in list context
{loading ? (
  <div className="-mx-6 -mb-6">
    <SkeletonList rows={3} />
  </div>
) : error ? (
  <ErrorState message={error} onRetry={fetchData} />
) : items.length === 0 ? (
  <EmptyState title="..." description="..." icon={...} />
) : (
  <div className="-mx-6 -mb-6">
    {items.map((item) => <Row key={item.id} ... />)}
  </div>
)}

Activity

  1. added
    enhancement
    on Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions