Skip to content

Conversation

@withlin
Copy link
Contributor

@withlin withlin commented Dec 26, 2025

  • add drag-and-drop ordering in table settings and store order in URL
  • render table columns in chosen order and restyle drag handle
  • add TableLogs order unit test

Fixes: #714

Checklist

The following checks are mandatory:

@withlin withlin changed the title vmui: allow table column reordering app/vmui: allow table column reordering Dec 26, 2025
@valyala valyala added the web-ui Issues related to the user interface: layout, styling, usability, or UI-specific bugs. label Dec 26, 2025
@valyala valyala requested a review from Loori-R December 26, 2025 22:31
@valyala
Copy link
Contributor

valyala commented Dec 26, 2025

@withlin , thank you for the pull request!

@Loori-R , @arturminchukov , could you review it?

- add drag-and-drop ordering in table settings and store order in URL
- render table columns in chosen order and restyle drag handle
- add TableLogs order unit test

Testing: npm run lint:local; npm test
Fixes: VictoriaMetrics#714
@withlin withlin force-pushed the feature/vmui-table-column-ordering branch from f5fbc53 to 762f8c6 Compare December 27, 2025 13:18
Copy link
Contributor

@Loori-R Loori-R left a comment

Choose a reason for hiding this comment

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

Image

Thanks for the PR - overall looks good.
Just a couple of minor UI follow-ups (see attached screenshot):

  1. Please add the column order index (#1, #2, …) to the drag list as shown in the screenshot, to make the current order easier to scan and verify.
  2. Please limit the height of the reorder list (similar to the checkbox list) and make it scrollable, as shown in the screenshot, to avoid the modal growing too tall when many columns are selected.


const handleDragOver = (column: string) => (e: DragEvent) => {
e.preventDefault();
if (dragOverColumn === column) return;
Copy link
Contributor

Choose a reason for hiding this comment

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

dragOverColumn can be stale here. This check can be removed - setting the same value won’t trigger a re-render.

Comment on lines +155 to +156
setDragOverColumn(null);
setDraggingColumn(null);
Copy link
Contributor

Choose a reason for hiding this comment

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

Cleanup logic is duplicated here - consider calling handleDragEnd() instead of resetting the state inline:

Suggested change
setDragOverColumn(null);
setDraggingColumn(null);
handleDragEnd();

Comment on lines +55 to +60
return displayColumns.reduce<typeof tableColumns>((acc, key) => {
const column = tableColumnsMap.get(key);
if (column) acc.push(column);
return acc;
}, []);
}, [tableColumnsMap, displayColumns, tableCompact]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the column config is derived from the key, tableColumnsMap/reduce (and even columns as a source list) look redundant here. We can build the Table columns directly from displayColumns to keep the requested order and simplify the code.

Suggested change
return displayColumns.reduce<typeof tableColumns>((acc, key) => {
const column = tableColumnsMap.get(key);
if (column) acc.push(column);
return acc;
}, []);
}, [tableColumnsMap, displayColumns, tableCompact]);
return displayColumns.map((key) => ({
key: key as keyof Logs,
title: key,
className: getColumnClass(key),
}));
}, [displayColumns, tableCompact]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

web-ui Issues related to the user interface: layout, styling, usability, or UI-specific bugs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vmui: Add the ability to order table view columns

3 participants