From 5110eaf10f0fa9ead06cf052a00f400396374b6c Mon Sep 17 00:00:00 2001
From: 0xMMMMMM <4688216+0xMMMMMM@users.noreply.github.com>
Date: Sun, 8 Dec 2024 06:26:12 +0700
Subject: [PATCH] refactor: reorganize systems table options into single
dropdown
Combines view type, sort by and visible fields into a single dropdown menu for better organization.
---
.../systems-table/systems-table.tsx | 154 +++++++++---------
1 file changed, 80 insertions(+), 74 deletions(-)
diff --git a/beszel/site/src/components/systems-table/systems-table.tsx b/beszel/site/src/components/systems-table/systems-table.tsx
index 6c8d6eb..66d306d 100644
--- a/beszel/site/src/components/systems-table/systems-table.tsx
+++ b/beszel/site/src/components/systems-table/systems-table.tsx
@@ -53,6 +53,9 @@ import {
ChevronDownIcon,
LayoutGridIcon,
LayoutListIcon,
+ XCircle,
+ ArrowDownIcon,
+ ArrowUpIcon,
} from "lucide-react"
import { useEffect, useMemo, useState } from "react"
import { $hubVersion, $systems, pb } from "@/lib/stores"
@@ -334,85 +337,88 @@ export default function SystemsTable() {
setFilter(e.target.value)} className="px-4" />
-
- {viewMode === 'grid' && (
-
-
-
-
-
- {table.getAllColumns().map((column) => {
- if (column.id === t`Actions` || !column.getCanSort()) return null
-
- const isCurrentSort = sorting[0]?.id === column.id
- const sortDirection = sorting[0]?.desc ? '↓' : '↑'
-
- return (
- {
- const isDesc = sorting[0]?.id === column.id && !sorting[0]?.desc
- setSorting([{ id: column.id, desc: isDesc }])
- }}
- >
- {column.id} {isCurrentSort && sortDirection}
-
- )
- })}
- {sorting.length > 0 && (
- <>
-
- setSorting([])}>
- Clear Sort
-
- >
- )}
-
-
- )}
-
- {table
- .getAllColumns()
- .filter((column) => column.getCanHide())
- .map((column) => {
- return (
- column.toggleVisibility(!!value)}
- >
- {column.id}
-
- )
- })}
+
+
+
+
+ View Type
+
+ setViewMode('table')}
+ className="gap-2"
+ >
+
+ Table
+
+ setViewMode('grid')}
+ className="gap-2"
+ >
+
+ Grid
+
+
+
+
+
+ Sort by
+
+ {table.getAllColumns().map((column) => {
+ if (column.id === t`Actions` || !column.getCanSort()) return null
+
+ const isCurrentSort = sorting[0]?.id === column.id
+ const sortDirection = sorting[0]?.desc ?
:
+
+ return (
+
{
+ const isDesc = sorting[0]?.id === column.id && !sorting[0]?.desc
+ setSorting([{ id: column.id, desc: isDesc }])
+ }}
+ >
+ {isCurrentSort && sortDirection}
+ {column.id}
+
+ )
+ })}
+ {sorting.length > 0 && (
+
setSorting([])}>
+
+ Clear Sort
+
+ )}
+
+
+
+
+ Visible Fields
+
+ {table
+ .getAllColumns()
+ .filter((column) => column.getCanHide())
+ .map((column) => {
+ return (
+ column.toggleVisibility(!!value)}
+ >
+ {column.id}
+
+ )
+ })}
+
+