Skip to content

Conversation

@michelroegl-brunner
Copy link
Member

Overview

This PR adds a view toggle feature that allows users to switch between card view (default) and list view on both the Available Scripts and Downloaded Scripts pages.

Features Added

  • View Toggle Component: Clean toggle button with grid/list icons positioned below the FilterBar
  • List View Layout: Horizontal card design showing scripts in a compact row format
  • Enhanced Information Display: List view shows additional metadata:
    • Categories with tag icon
    • Creation date with calendar icon
    • OS and version with computer icon (e.g., 'Debian 12')
    • Default port with terminal icon (e.g., 'Port: 8080')
    • Script ID with info icon
  • Persistent Settings: View preference is saved and restored across page reloads
  • Consistent Experience: Same view mode applies to both Available and Downloaded scripts pages

Technical Implementation

  • Added ViewToggle.tsx component with active state styling
  • Created ScriptCardList.tsx component with horizontal layout design
  • Implemented /api/settings/view-mode endpoint following existing settings pattern
  • Updated ScriptCard interface to include OS, version, and port information
  • Enhanced getScriptCardsWithCategories API to provide additional metadata
  • Modified ScriptsGrid.tsx and DownloadedScriptsTab.tsx with conditional rendering

User Experience

  • Default view remains card (grid) layout for familiarity
  • Toggle button is easily accessible below the filter controls
  • List view provides more information density for power users
  • Smooth transitions between views
  • Settings persist across browser sessions

Files Changed

  • src/app/_components/ViewToggle.tsx (new)
  • src/app/_components/ScriptCardList.tsx (new)
  • src/app/api/settings/view-mode/route.ts (new)
  • src/app/_components/ScriptsGrid.tsx (modified)
  • src/app/_components/DownloadedScriptsTab.tsx (modified)
  • src/server/api/routers/scripts.ts (modified)
  • src/types/script.ts (modified)

Testing

  • ✅ View toggle works on both Available and Downloaded scripts pages
  • ✅ View preference persists across page reloads
  • ✅ List view displays all enhanced information correctly
  • ✅ Card view remains unchanged and functional
  • ✅ No linting errors introduced

- Add ViewToggle component with grid/list icons and active state styling
- Create ScriptCardList component with horizontal layout design
- Add view-mode API endpoint for GET/POST operations to persist view preference
- Update ScriptsGrid and DownloadedScriptsTab with view mode state and conditional rendering
- Enhance list view with additional information:
  - Categories with tag icon
  - Creation date with calendar icon
  - OS and version with computer icon
  - Default port with terminal icon
  - Script ID with info icon
- View preference persists across page reloads
- Same view mode applies to both Available and Downloaded scripts pages
- List view shows same information as card view but in compact horizontal layout
- Fix unsafe argument type errors in view mode loading
- Use proper type guards for viewMode validation
- Replace logical OR with nullish coalescing operator
- Add explicit type casting for API response validation
@michelroegl-brunner michelroegl-brunner merged commit d819cd7 into main Oct 10, 2025
4 checks passed
@michelroegl-brunner michelroegl-brunner deleted the feature/view-toggle-card-list branch October 14, 2025 06:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants