Skip to content

Commit bef7a34

Browse files
committed
fix: remove sorting by cpu/memory
1 parent 8c9db27 commit bef7a34

5 files changed

Lines changed: 13 additions & 19 deletions

File tree

spec/openapi.dashboard-api.yaml

Lines changed: 0 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/server/api/routers/templates.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ export const templatesRouter = createTRPCRouter({
4949
.enum([
5050
'name_asc',
5151
'name_desc',
52-
'cpu_count_asc',
53-
'cpu_count_desc',
54-
'memory_mb_asc',
55-
'memory_mb_desc',
5652
'created_at_asc',
5753
'created_at_desc',
5854
'updated_at_asc',

src/core/shared/contracts/dashboard-api.types.ts

Lines changed: 0 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/features/dashboard/templates/list/table-config.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export const useColumns = (deps: unknown[]) => {
6262
enableResizing: false,
6363
cell: CpuCell,
6464
filterFn: 'equals',
65-
sortDescFirst: true,
65+
enableSorting: false,
6666
},
6767
{
6868
accessorKey: 'memoryMB',
@@ -71,7 +71,7 @@ export const useColumns = (deps: unknown[]) => {
7171
enableResizing: false,
7272
cell: MemoryCell,
7373
filterFn: 'equals',
74-
sortDescFirst: true,
74+
enableSorting: false,
7575
},
7676
{
7777
accessorKey: 'diskSizeMB',

src/features/dashboard/templates/list/table.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ import { fallbackData, templatesTableConfig, useColumns } from './table-config'
4343

4444
const COLUMN_TO_SORT_BASE: Record<string, string> = {
4545
name: 'name',
46-
cpuCount: 'cpu_count',
47-
memoryMB: 'memory_mb',
4846
createdAt: 'created_at',
4947
updatedAt: 'updated_at',
5048
}
@@ -59,8 +57,14 @@ export default function TemplatesTable() {
5957
useTemplateTableStore()
6058
const { cpuCount, memoryMB, isPublic } = useTemplateTableStore()
6159

60+
// Persisted state (URL hash) may still reference columns that are no longer sortable.
61+
const activeSorting = useMemo(
62+
() => sorting.filter((s) => s.id in COLUMN_TO_SORT_BASE),
63+
[sorting]
64+
)
65+
6266
// Derive the single server sort token from the active sort column + direction.
63-
const sortColumn = sorting[0]
67+
const sortColumn = activeSorting[0]
6468
const sortBase =
6569
(sortColumn && COLUMN_TO_SORT_BASE[sortColumn.id]) ??
6670
TEMPLATES_DEFAULT_SORT_BASE
@@ -135,7 +139,7 @@ export default function TemplatesTable() {
135139
columns: columns ?? fallbackData,
136140
state: {
137141
globalFilter,
138-
sorting,
142+
sorting: activeSorting,
139143
columnSizing,
140144
},
141145
onGlobalFilterChange: setGlobalFilter,
@@ -190,7 +194,9 @@ export default function TemplatesTable() {
190194
<DataTableHead
191195
key={header.id}
192196
header={header}
193-
sorting={sorting.find((s) => s.id === header.id)?.desc}
197+
sorting={
198+
activeSorting.find((s) => s.id === header.id)?.desc
199+
}
194200
align={
195201
header.id === 'cpuCount' ||
196202
header.id === 'memoryMB' ||

0 commit comments

Comments
 (0)