Skip to content

feat: add column visibility management to nodes table #751

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

truongsinh
Copy link

Features:

Description

Related Issues

Changes Made

  • Add generic column management system with TypeScript support
  • Implement ColumnVisibilityControl component with dropdown interface
  • Add persistent column visibility settings via Zustand store
  • Extend nodes table with additional columns (role, battery, uptime, etc.)
  • Refactor table cell rendering to use helper functions
  • Add comprehensive documentation and examples
  • Support internationalization for column settings

Feature

  • Toggle visibility of table columns individually
  • Reset columns to default configuration
  • Persistent settings across sessions
  • Generic system reusable for other tables
  • Proper TypeScript types throughout
  • Existing UI component patterns maintained

Checklist

  • Code follows project style guidelines
  • Documentation has been updated or added
  • Tests have been added or updated
  • All i18n translation labels have been added (read
    CONTRIBUTING_I18N_DEVELOPER_GUIDE.md for more details)

- Add generic column management system with TypeScript support
- Implement ColumnVisibilityControl component with dropdown interface
- Add persistent column visibility settings via Zustand store
- Extend nodes table with additional columns (role, battery, uptime, etc.)
- Refactor table cell rendering to use helper functions
- Add comprehensive documentation and examples
- Support internationalization for column settings

Features:
- Toggle visibility of table columns individually
- Reset columns to default configuration
- Persistent settings across sessions
- Generic system reusable for other tables
- Proper TypeScript types throughout
- Existing UI component patterns maintained
@Copilot Copilot AI review requested due to automatic review settings August 1, 2025 19:44
Copy link

vercel bot commented Aug 1, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
web-test ✅ Ready (Inspect) Visit Preview Aug 1, 2025 7:44pm

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a comprehensive column visibility management system to the nodes table, allowing users to toggle individual columns on/off and persist their preferences. The implementation provides a generic, reusable system with TypeScript support that can be extended to other tables.

Key changes:

  • Added generic column management hooks and components with full TypeScript support
  • Implemented persistent column visibility settings using Zustand store with localStorage
  • Extended nodes table with additional columns (role, battery, uptime, position, etc.) that are hidden by default

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/web/src/pages/Nodes/index.tsx Refactored nodes page to use new column management system and helper functions
packages/web/src/core/stores/createTableColumnStore.ts Generic factory for creating column management state in Zustand stores
packages/web/src/core/stores/appStore.ts Extended app store with nodes table column management and persistence
packages/web/src/core/hooks/useColumnManager.ts Generic hook for managing table column visibility and state
packages/web/src/components/generic/Table/index.tsx Added null safety check for table cell sorting
packages/web/src/components/generic/Table/NodeCellHelpers.tsx Helper functions for rendering different node table cell types
packages/web/src/components/generic/ColumnVisibilityControl/index.tsx Barrel export for column visibility components
packages/web/src/components/generic/ColumnVisibilityControl/README.md Comprehensive documentation with usage examples
packages/web/src/components/generic/ColumnVisibilityControl/GenericColumnVisibilityControl.tsx Reusable dropdown component for column visibility management
packages/web/src/components/generic/ColumnVisibilityControl/ColumnVisibilityControl.tsx Nodes-specific wrapper for the generic column control
packages/web/public/i18n/locales/en/nodes.json Added translation keys for column settings

set(
produce((draft: any) => {
// Access the nodesTableColumns property instead of columns
const columns = draft.nodesTableColumns;
Copy link
Preview

Copilot AI Aug 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded property name 'nodesTableColumns' makes this factory function tightly coupled to the nodes table implementation. Consider making the property name configurable via the config parameter to maintain true genericity.

Suggested change
const columns = draft.nodesTableColumns;
const columns = draft[columnsKey];

Copilot uses AI. Check for mistakes.

updateColumn: (columnId: string, updates: Partial<T>) => {
set(
produce((draft: any) => {
const columns = draft.nodesTableColumns;
Copy link
Preview

Copilot AI Aug 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same hardcoded property name issue as above - this limits reusability of the factory function for other tables.

Suggested change
const columns = draft.nodesTableColumns;
const columns = draft[columnsKey];

Copilot uses AI. Check for mistakes.

resetColumnsToDefault: () => {
set(
produce((draft: any) => {
draft.nodesTableColumns = defaultColumns;
Copy link
Preview

Copilot AI Aug 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoded property name continues the pattern of tight coupling. The factory should accept a property name parameter to be truly generic.

Suggested change
draft.nodesTableColumns = defaultColumns;
draft[columnProperty] = defaultColumns;

Copilot uses AI. Check for mistakes.

setColumns: (columns: T[]) => {
set(
produce((draft: any) => {
draft.nodesTableColumns = columns;
Copy link
Preview

Copilot AI Aug 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final instance of the hardcoded property name that should be configurable for generic reuse.

Suggested change
draft.nodesTableColumns = columns;
draft[columnsKey] = columns;

Copilot uses AI. Check for mistakes.


case "role": {
const roleName =
Protobuf.Config.Config_DeviceConfig_Role[node.user?.role ?? 0] ??
Copy link
Preview

Copilot AI Aug 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The role property access assumes it exists on user object, but the actual property path might be different. Verify the correct property path for device role in the Protobuf schema.

Suggested change
Protobuf.Config.Config_DeviceConfig_Role[node.user?.role ?? 0] ??
Protobuf.Config.Config_DeviceConfig_Role[node.user?.deviceConfig?.role ?? 0] ??

Copilot uses AI. Check for mistakes.

@danditomaso
Copy link
Collaborator

@truongsinh Thanks for the PR. We always appreciate first time contributors. You'll need to add a description to your PR.

@danditomaso
Copy link
Collaborator

One small style issue I had found. It looks like there is inconsistent spacing around the button, if you could ensure the button has equal spacing around it to provide a consistent look.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants