Skip to content
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

Logs Panel: Table UI - Reordering table columns via drag-and-drop #79536

Merged

Conversation

gtk-grafana
Copy link
Contributor

@gtk-grafana gtk-grafana commented Dec 14, 2023

What is this feature?
Adding react-beautiful-dnd to field selection UI to facilitate ordering columns in table UI

Why do we need this feature?
The table UI facilities users to make associations between field values; customizing the order of fields is going to provide our users with the flexibility to do just that.

Who is this feature for?
Logs table users in explore

Which issue(s) does this PR fix?:

Fixes #78837

Special notes for your reviewer:

Please check that:

  • It works as expected from a user's perspective.
  • If this is a pre-GA feature, it is behind a feature toggle.
  • The docs are updated, and if this is a notable improvement, it's added to our What's New doc.

@gtk-grafana gtk-grafana self-assigned this Dec 19, 2023
@gtk-grafana
Copy link
Contributor Author

Bug: looks like the position of the field is preventing the query filters from working in the table cell.
image
image

@gtk-grafana
Copy link
Contributor Author

Ugh, the above bug is caused by parseLegacyLogsFrame which will just grab the first string field as the body. Looks like legacy dataframe format assumes that the first string field is the body, but allowing users to re-order will break that assumption.
But we do run parseLogsFrame before we re-order fields in the LogsTableWrap.tsx, and then we run it again in the LogsTable, which is where we get the erroneous result.
I'll take a look and see if we can pass the logsFrame result from LogsTableWrap instead of running parseLogsFrame twice.

@gtk-grafana
Copy link
Contributor Author

Was able to resolve the above bug by passing through the logsFrame before the transformations are applied

@gtk-grafana
Copy link
Contributor Author

gtk-grafana commented Jan 9, 2024

image

We added the drag icon used in the transformation UI to each selected field allowing users to reorder columns, and removed the percentage from active fields.

@niat22 Would love to review this when you have some time!

@gtk-grafana gtk-grafana marked this pull request as ready for review January 10, 2024 16:43
@gtk-grafana gtk-grafana requested review from a team as code owners January 10, 2024 16:43
@gtk-grafana gtk-grafana added no-backport Skip backport of PR no-changelog Skip including change in changelog/release notes labels Jan 10, 2024
@gtk-grafana gtk-grafana requested review from svennergr and a team January 16, 2024 13:15
Copy link
Contributor

@svennergr svennergr left a comment

Choose a reason for hiding this comment

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

Left a few comments. Overall just some nits, feature works great! 🚀

<div className={styles.columnWrapper} {...provided.droppableProps} ref={provided.innerRef}>
{labelKeys.sort(sortLabels(labels)).map((labelName, index) => (
<Draggable draggableId={labelName} key={labelName} index={index}>
{(provided: DraggableProvided) => (
Copy link
Contributor

@svennergr svennergr Jan 16, 2024

Choose a reason for hiding this comment

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

Would be great to get a slightly different background color - maybe just secondary? - on the draggable when it's being dragged. Looks like you could use something like this: https://github.com/atlassian/react-beautiful-dnd/blob/master/docs/api/draggable.md#2-snapshot-draggablestatesnapshot

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I played around with it for a bit: this is what I eventually pushed.
https://github.com/grafana/grafana/assets/109082771/addcb91d-cad5-4387-86fd-535f5b687719

public/app/features/explore/Logs/LogsTableActiveFields.tsx Outdated Show resolved Hide resolved
public/app/features/explore/Logs/LogsTableActiveFields.tsx Outdated Show resolved Hide resolved
public/app/features/explore/Logs/LogsTableActiveFields.tsx Outdated Show resolved Hide resolved
public/app/features/explore/Logs/LogsTableActiveFields.tsx Outdated Show resolved Hide resolved
public/app/features/explore/Logs/LogsTableActiveFields.tsx Outdated Show resolved Hide resolved
public/app/features/explore/Logs/LogsTableWrap.tsx Outdated Show resolved Hide resolved
public/app/features/explore/Logs/LogsTableNavField.tsx Outdated Show resolved Hide resolved
public/app/features/explore/Logs/LogsTableNavField.tsx Outdated Show resolved Hide resolved
public/app/features/explore/Logs/LogsTableWrap.tsx Outdated Show resolved Hide resolved
@svennergr svennergr self-requested a review January 16, 2024 20:13
Copy link
Contributor

@svennergr svennergr left a comment

Choose a reason for hiding this comment

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

Awesome! Thanks for the prompt changes 🚀🚀

@gtk-grafana gtk-grafana changed the title Logs Panel: Table UI - Reordering fields Logs Panel: Table UI - Reordering table columns via drag-and-drop Jan 16, 2024
@gtk-grafana gtk-grafana added add to changelog and removed no-changelog Skip including change in changelog/release notes labels Jan 16, 2024
@gtk-grafana gtk-grafana merged commit 7b8db64 into main Jan 16, 2024
19 checks passed
@gtk-grafana gtk-grafana deleted the gtk-grafana/issues/78837/logs-table-ui-column-ordering branch January 16, 2024 20:27
@grafana-delivery-bot grafana-delivery-bot bot modified the milestones: 10.3.x, 10.4.x Jan 16, 2024
s0lesurviv0r pushed a commit to s0lesurviv0r/grafana that referenced this pull request Feb 3, 2024
…afana#79536)

* Implement react-beautiful-dnd to facilitate column reordering
* Refactoring field display components
* Refactoring internal types to better align with Grafana style guide

---------

Co-authored-by: Sven Grossmann <sven.grossmann@grafana.com>
Ukochka pushed a commit that referenced this pull request Feb 14, 2024
…9536)

* Implement react-beautiful-dnd to facilitate column reordering
* Refactoring field display components
* Refactoring internal types to better align with Grafana style guide

---------

Co-authored-by: Sven Grossmann <sven.grossmann@grafana.com>
@aangelisc aangelisc modified the milestones: 10.4.x, 10.4.0 Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Logs Panel: Table UI - Reorder columns
3 participants