From 5b71e534d29d4f5228a7dbab9e5c86f74a505c00 Mon Sep 17 00:00:00 2001
From: Mohammad <153328465+Mo7amadd@users.noreply.github.com>
Date: Tue, 24 Nov 2026 02:47:28 -0800
Subject: [PATCH] feat(clients): let the admin choose which table columns to
show (#7080)
On a laptop-width screen the Clients table is wider than the window, and columns such as Speed or Attached inbounds take width even when they show nothing useful.
Add a Columns menu beside Filter that hides any column except the client itself. The choice is kept in localStorage, the menu stays open while several columns are ticked, and the table sizes to its visible columns instead of a fixed 1200px.
---
.../src/pages/clients/ClientColumnPicker.tsx | 58 ++++++++++
frontend/src/pages/clients/ClientsPage.css | 5 +
frontend/src/pages/clients/ClientsPage.tsx | 21 +++-
.../src/pages/clients/columnVisibility.ts | 69 +++++++++++
.../src/test/client-column-picker.test.tsx | 109 ++++++++++++++++++
internal/web/translation/ar-EG.json | 1 +
internal/web/translation/en-US.json | 1 +
internal/web/translation/es-ES.json | 1 +
internal/web/translation/fa-IR.json | 1 +
internal/web/translation/id-ID.json | 1 +
internal/web/translation/ja-JP.json | 1 +
internal/web/translation/pt-BR.json | 1 +
internal/web/translation/ru-RU.json | 1 +
internal/web/translation/sk-SK.json | 1 +
internal/web/translation/tr-TR.json | 1 +
internal/web/translation/uk-UA.json | 1 +
internal/web/translation/vi-VN.json | 1 +
internal/web/translation/zh-CN.json | 1 +
internal/web/translation/zh-TW.json | 1 +
19 files changed, 274 insertions(+), 2 deletions(-)
create mode 100644 frontend/src/pages/clients/ClientColumnPicker.tsx
create mode 100644 frontend/src/pages/clients/columnVisibility.ts
create mode 100644 frontend/src/test/client-column-picker.test.tsx
diff --git a/frontend/src/pages/clients/ClientColumnPicker.tsx b/frontend/src/pages/clients/ClientColumnPicker.tsx
new file mode 100644
index 000000000..cd2d321ff
--- /dev/null
+++ b/frontend/src/pages/clients/ClientColumnPicker.tsx
@@ -0,0 +1,58 @@
+import { useState } from 'react';
+import { useTranslation } from 'react-i18next';
+import { Button, Checkbox, Dropdown } from 'antd';
+import { TableOutlined } from '@ant-design/icons';
+
+import type { ClientColumnOption, HideableClientColumn } from './columnVisibility';
+
+interface ClientColumnPickerProps {
+ options: ClientColumnOption[];
+ hidden: HideableClientColumn[];
+ onChange: (hidden: HideableClientColumn[]) => void;
+}
+
+export default function ClientColumnPicker({ options, hidden, onChange }: ClientColumnPickerProps) {
+ const { t } = useTranslation();
+ const [open, setOpen] = useState(false);
+
+ const toggle = (key: string) => {
+ const option = options.find((o) => o.key === key);
+ if (!option) return;
+ onChange(
+ hidden.includes(option.key)
+ ? hidden.filter((k) => k !== option.key)
+ : [...hidden, option.key],
+ );
+ };
+
+ return (
+ {
+ if (next || info.source === 'trigger') setOpen(next);
+ }}
+ menu={{
+ items: options.map((o) => ({
+ key: o.key,
+ label: (
+
+ {o.label}
+
+ ),
+ })),
+ onClick: ({ key }) => toggle(key),
+ }}
+ >
+ } aria-haspopup="menu" aria-expanded={open}>
+ {t('pages.clients.columns')}
+
+
+ );
+}
diff --git a/frontend/src/pages/clients/ClientsPage.css b/frontend/src/pages/clients/ClientsPage.css
index d197d5da7..d18c2f2f2 100644
--- a/frontend/src/pages/clients/ClientsPage.css
+++ b/frontend/src/pages/clients/ClientsPage.css
@@ -380,3 +380,8 @@
border-color: var(--ant-color-error-border);
background: var(--ant-color-error-bg);
}
+
+/* The menu item owns the click, so the box only shows the state. */
+.column-picker-check {
+ pointer-events: none;
+}
diff --git a/frontend/src/pages/clients/ClientsPage.tsx b/frontend/src/pages/clients/ClientsPage.tsx
index eb16928ce..845caa647 100644
--- a/frontend/src/pages/clients/ClientsPage.tsx
+++ b/frontend/src/pages/clients/ClientsPage.tsx
@@ -93,6 +93,8 @@ const BulkDetachInboundsModal = lazy(() => import('./BulkDetachInboundsModal'));
const TextModal = lazy(() => import('@/components/feedback/TextModal'));
const PromptModal = lazy(() => import('@/components/feedback/PromptModal'));
import { ClientInboundChips, ClientRowActions } from './RowCells';
+import ClientColumnPicker from './ClientColumnPicker';
+import { clientColumnOptions, hideClientColumns, useHiddenClientColumns } from './columnVisibility';
import { emptyFilters, activeFilterCount } from './filters';
import type { ClientFilters } from './filters';
import './ClientsPage.css';
@@ -1055,7 +1057,7 @@ export default function ClientsPage() {
if (pag?.pageSize) setPageSizeChoice(pag.pageSize);
};
- const columns = useMemo>(
+ const baseColumns = useMemo>(
() => [
{
title: t('pages.clients.actions'),
@@ -1241,6 +1243,14 @@ export default function ClientsPage() {
],
);
+ const [hiddenColumns, setHiddenColumns] = useHiddenClientColumns();
+
+ const columnOptions = useMemo(() => clientColumnOptions(baseColumns), [baseColumns]);
+ const columns = useMemo(
+ () => hideClientColumns(baseColumns, hiddenColumns),
+ [baseColumns, hiddenColumns],
+ );
+
const rowClassName = useCallback(
(record: ClientRecord) => {
const bucket = clientBucket(record);
@@ -1568,6 +1578,13 @@ export default function ClientsPage() {
{!isMobile && t('filter')}
+ {!isMobile && (
+
+ )}