[PR #7080] feat(clients): let the admin choose which table columns to show #6636

Open
opened 2026-11-07 14:34:18 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/7080
Author: @Mo7amadd
Created: 11/5/2026
Status: 🔄 Open

Base: main ← Head: feat/clients-column-picker


📝 Commits (3)

  • 8569637 feat(clients): let the admin choose which table columns to show
  • bf314e7 test(clients): cover the column picker
  • 1a8fd2d feat(i18n): add pages.clients.columns to all locales

📊 Changes

19 files changed (+274 additions, -2 deletions)

View changed files

➕ frontend/src/pages/clients/ClientColumnPicker.tsx (+58 -0)
📝 frontend/src/pages/clients/ClientsPage.css (+5 -0)
📝 frontend/src/pages/clients/ClientsPage.tsx (+19 -2)
➕ frontend/src/pages/clients/columnVisibility.ts (+69 -0)
➕ frontend/src/test/client-column-picker.test.tsx (+109 -0)
📝 internal/web/translation/ar-EG.json (+1 -0)
📝 internal/web/translation/en-US.json (+1 -0)
📝 internal/web/translation/es-ES.json (+1 -0)
📝 internal/web/translation/fa-IR.json (+1 -0)
📝 internal/web/translation/id-ID.json (+1 -0)
📝 internal/web/translation/ja-JP.json (+1 -0)
📝 internal/web/translation/pt-BR.json (+1 -0)
📝 internal/web/translation/ru-RU.json (+1 -0)
📝 internal/web/translation/sk-SK.json (+1 -0)
📝 internal/web/translation/tr-TR.json (+1 -0)
📝 internal/web/translation/uk-UA.json (+1 -0)
📝 internal/web/translation/vi-VN.json (+1 -0)
📝 internal/web/translation/zh-CN.json (+1 -0)
📝 internal/web/translation/zh-TW.json (+1 -0)

📄 Description

Summary

Adds a Columns button next to Filter on the Clients page. It opens a menu of checkboxes to show or hide table columns; the choice is remembered per browser.

Why

Not every column is useful in every setup. On my panel, Speed shows "—" for almost every client, and together with Attached inbounds it pushes Remaining and Duration off-screen on a laptop, so I scroll sideways for the two columns I actually look at.

What changed

  • ClientColumnPicker.tsx: an antd Dropdown menu with one checkbox per column. It stays open while columns are ticked (only the trigger, an outside click or Escape closes it), opens with focus inside so arrow keys work, and the trigger carries aria-haspopup / aria-expanded.
  • columnVisibility.ts: the list of hideable columns, the localStorage hook (key clientsHiddenColumns) and two pure helpers the page uses to build the menu options and to apply hidden to the column list.
    • The Client column is not hideable; a tampered stored value naming it is ignored.
    • Group is not offered while there are no groups (it is already hidden then); a stored choice for it is kept until groups exist again.
  • ClientsPage.tsx: the existing columns memo becomes baseColumns; columns is derived from it plus the hidden set. The picker is rendered on desktop only (the mobile card view has no columns).
  • scroll.x changes from 1200 to 'max-content', so hiding columns can actually remove the horizontal scrollbar. Every column already has an explicit width, so with nothing hidden the table lays out exactly as before.
  • New i18n key pages.clients.columns in all 14 locales.

Type of change

  • New feature

Areas affected

  • Frontend (UI / panel pages)

How was this tested?

  • npm run typecheck, npm run lint, npm run format:check, npx vitest run --project unit --project components (1982 tests, 5 of them new), npm run build and npm run build-storybook pass.
  • New src/test/client-column-picker.test.tsx renders the real picker, the hook and the helpers through an antd Table. Every test was checked against a deliberately broken implementation and goes red:
    • persistence removed → "keeps a column hidden on the next visit"
    • Client made hideable → "never hides or offers the client column"
    • the !column.hidden guard removed → "keeps Group hidden … while no groups exist"
    • the menu closing on every tick → "stays open while columns are ticked"
    • a toggle that drops other hidden keys → two tests
  • Manual check in npm run dev with a mocked API (120 clients) at 1366×768 and 1920×900, light and dark: tick/untick columns, reload, hide enough columns to make the horizontal scrollbar disappear, switch to mobile width (no button there).

Screenshots / recordings

columns-menu-open columns-menu-closed

Breaking changes

None. With nothing hidden the table shows the same columns as before.

Checklist

  • I tested the change locally and confirmed the described behavior.
  • I added or updated tests for the new behavior (when applicable).
  • go build ./... and the test suite pass locally. (Frontend-only change; no Go code touched, so the Go suite was not run.)
  • For frontend changes: npm run lint, npm run typecheck, and npm run build pass.
  • I updated the Wiki / README / API docs if user-facing behavior changed.
  • My commits follow the project's existing message style.
  • I have no unrelated changes mixed into this PR.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/7080 **Author:** [@Mo7amadd](https://github.com/Mo7amadd) **Created:** 11/5/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/clients-column-picker` --- ### 📝 Commits (3) - [`8569637`](https://github.com/MHSanaei/3x-ui/commit/8569637b972281a9c58ac181d2a0c600d6718938) feat(clients): let the admin choose which table columns to show - [`bf314e7`](https://github.com/MHSanaei/3x-ui/commit/bf314e7e7fbad0a3446fd7200b680ae6c68738ee) test(clients): cover the column picker - [`1a8fd2d`](https://github.com/MHSanaei/3x-ui/commit/1a8fd2dfe543a7a631b700f488466c8d28223192) feat(i18n): add pages.clients.columns to all locales ### 📊 Changes **19 files changed** (+274 additions, -2 deletions) <details> <summary>View changed files</summary> ➕ `frontend/src/pages/clients/ClientColumnPicker.tsx` (+58 -0) 📝 `frontend/src/pages/clients/ClientsPage.css` (+5 -0) 📝 `frontend/src/pages/clients/ClientsPage.tsx` (+19 -2) ➕ `frontend/src/pages/clients/columnVisibility.ts` (+69 -0) ➕ `frontend/src/test/client-column-picker.test.tsx` (+109 -0) 📝 `internal/web/translation/ar-EG.json` (+1 -0) 📝 `internal/web/translation/en-US.json` (+1 -0) 📝 `internal/web/translation/es-ES.json` (+1 -0) 📝 `internal/web/translation/fa-IR.json` (+1 -0) 📝 `internal/web/translation/id-ID.json` (+1 -0) 📝 `internal/web/translation/ja-JP.json` (+1 -0) 📝 `internal/web/translation/pt-BR.json` (+1 -0) 📝 `internal/web/translation/ru-RU.json` (+1 -0) 📝 `internal/web/translation/sk-SK.json` (+1 -0) 📝 `internal/web/translation/tr-TR.json` (+1 -0) 📝 `internal/web/translation/uk-UA.json` (+1 -0) 📝 `internal/web/translation/vi-VN.json` (+1 -0) 📝 `internal/web/translation/zh-CN.json` (+1 -0) 📝 `internal/web/translation/zh-TW.json` (+1 -0) </details> ### 📄 Description ## Summary Adds a **Columns** button next to Filter on the Clients page. It opens a menu of checkboxes to show or hide table columns; the choice is remembered per browser. ## Why Not every column is useful in every setup. On my panel, Speed shows "—" for almost every client, and together with Attached inbounds it pushes Remaining and Duration off-screen on a laptop, so I scroll sideways for the two columns I actually look at. ## What changed - `ClientColumnPicker.tsx`: an antd `Dropdown` menu with one checkbox per column. It stays open while columns are ticked (only the trigger, an outside click or Escape closes it), opens with focus inside so arrow keys work, and the trigger carries `aria-haspopup` / `aria-expanded`. - `columnVisibility.ts`: the list of hideable columns, the `localStorage` hook (key `clientsHiddenColumns`) and two pure helpers the page uses to build the menu options and to apply `hidden` to the column list. - The Client column is not hideable; a tampered stored value naming it is ignored. - Group is not offered while there are no groups (it is already hidden then); a stored choice for it is kept until groups exist again. - `ClientsPage.tsx`: the existing `columns` memo becomes `baseColumns`; `columns` is derived from it plus the hidden set. The picker is rendered on desktop only (the mobile card view has no columns). - `scroll.x` changes from `1200` to `'max-content'`, so hiding columns can actually remove the horizontal scrollbar. Every column already has an explicit width, so with nothing hidden the table lays out exactly as before. - New i18n key `pages.clients.columns` in all 14 locales. ## Type of change - [x] New feature ## Areas affected - [x] Frontend (UI / panel pages) ## How was this tested? - `npm run typecheck`, `npm run lint`, `npm run format:check`, `npx vitest run --project unit --project components` (1982 tests, 5 of them new), `npm run build` and `npm run build-storybook` pass. - New `src/test/client-column-picker.test.tsx` renders the real picker, the hook and the helpers through an antd `Table`. Every test was checked against a deliberately broken implementation and goes red: - persistence removed → "keeps a column hidden on the next visit" - Client made hideable → "never hides or offers the client column" - the `!column.hidden` guard removed → "keeps Group hidden … while no groups exist" - the menu closing on every tick → "stays open while columns are ticked" - a toggle that drops other hidden keys → two tests - Manual check in `npm run dev` with a mocked API (120 clients) at 1366×768 and 1920×900, light and dark: tick/untick columns, reload, hide enough columns to make the horizontal scrollbar disappear, switch to mobile width (no button there). ## Screenshots / recordings <img width="1290" height="700" alt="columns-menu-open" src="https://github.com/user-attachments/assets/cf690df7-b7cb-4ffb-b0fe-b5f0d1d05bf4" /> <img width="1291" height="700" alt="columns-menu-closed" src="https://github.com/user-attachments/assets/993f5388-ed93-4afb-871d-6a1e611eae45" /> ## Breaking changes None. With nothing hidden the table shows the same columns as before. ## Checklist - [x] I tested the change locally and confirmed the described behavior. - [x] I added or updated tests for the new behavior (when applicable). - [ ] `go build ./...` and the test suite pass locally. *(Frontend-only change; no Go code touched, so the Go suite was not run.)* - [x] For frontend changes: `npm run lint`, `npm run typecheck`, and `npm run build` pass. - [ ] I updated the Wiki / README / API docs if user-facing behavior changed. - [x] My commits follow the project's existing message style. - [x] I have no unrelated changes mixed into this PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#6636
No description provided.