Skip to content

Conversation

@omkarK06
Copy link
Contributor

@omkarK06 omkarK06 commented Sep 1, 2024

fix #4424

Summary by CodeRabbit

  • New Features

    • Introduced a new utility for reordering selected fields based on grid column order, enhancing user experience when managing data fields.
    • Improved drag-and-drop functionality for table columns, ensuring the timestamp column is prioritized in the order.
  • Bug Fixes

    • Enhanced error handling by streamlining logging processes.
  • Documentation

    • Updated component methods to clarify the use of new field management logic.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 1, 2024

Walkthrough

The changes introduce a new utility function, reorderArrayByReference, and the reorderSelectedFields function in the useLogs composable, enhancing the management of selected fields based on the grid column order. Additionally, modifications to the IndexList.vue, SearchResult.vue, and TenstackTable.vue components improve the handling of selected fields and drag-and-drop events, streamlining the logic and encapsulating functionality more effectively.

Changes

Files Change Summary
web/src/composables/useLogs.ts Introduced reorderArrayByReference for sorting arrays based on a reference array. Added reorderSelectedFields to manage selected fields order and exported it. Modified error handling by removing a console log statement.
web/src/plugins/logs/IndexList.vue Added reorderSelectedFields function to manage selected fields, replacing direct manipulation of searchObj.data.stream.selectedFields with a local variable for improved readability and maintainability.
web/src/plugins/logs/SearchResult.vue Enhanced closeColumn method by using a local selectedFields variable populated by reorderSelectedFields, improving clarity and ensuring original data structure is updated only after local modifications.
web/src/plugins/logs/TenstackTable.vue Modified @end event handler to remove the event parameter. Simplified handleDragEnd logic to filter out timestamp_column from columnOrder and ensure it is always the first element after drag events.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the ☢️ Bug Something isn't working label Sep 1, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b0d0302 and be6c9a1.

Files selected for processing (4)
  • web/src/composables/useLogs.ts (4 hunks)
  • web/src/plugins/logs/IndexList.vue (2 hunks)
  • web/src/plugins/logs/SearchResult.vue (3 hunks)
  • web/src/plugins/logs/TenstackTable.vue (2 hunks)
Additional comments not posted (7)
web/src/plugins/logs/TenstackTable.vue (2)

59-59: LGTM!

The change simplifies the event handling by removing the unused event parameter, as the handleDragEnd function no longer requires the event object.


618-627: LGTM!

The change streamlines the logic and alters the behavior of how the column order is managed after a drag event, focusing on ensuring the timestamp_column is always the first element. The change is valid and improves the code readability.

web/src/plugins/logs/SearchResult.vue (2)

334-335: LGTM!

The change encapsulates the field management logic by retrieving the current selection of fields using the reorderSelectedFields method before any modifications are made. This potentially improves readability and maintainability by separating the concerns of field reordering and state management.


339-343: LGTM!

The change alters the control flow such that the selected fields are now stored in a local variable, which is updated based on user actions. After the modification, the updated list of selected fields is then assigned back to searchObj.data.stream.selectedFields. This change encapsulates the field management logic and improves the clarity of the code.

web/src/plugins/logs/IndexList.vue (2)

702-702: LGTM!

The change introduces a new function reorderSelectedFields which modifies how selected fields are managed within the component. This change enhances the component's functionality by introducing a more structured approach to handling selected fields.


788-797: LGTM!

The change encapsulates the field management logic by first retrieving the current selection of fields, storing them in a local variable, updating the local variable based on user actions, and then assigning the updated list back to searchObj.data.stream.selectedFields. This change improves the readability and maintainability of the code by separating the concerns of field reordering and state management.

web/src/composables/useLogs.ts (1)

Line range hint 4018-4084: Approved: New utility functions for reordering selected fields based on grid column order.

The introduced utility functions, reorderArrayByReference and reorderSelectedFields, enhance the management of selected fields based on the current grid column order.

reorderArrayByReference sorts the first array based on the order of elements in the second array, moving elements not found in the second array to the end.

reorderSelectedFields reorders the selected fields by:

  1. Creating a copy of the currently selected fields.
  2. Retrieving the column order for the selected stream.
  3. Removing the timestamp column from the column order if not selected.
  4. Calling reorderArrayByReference to reorder the selected fields according to the column order.

The code is well-structured, follows best practices, and no major issues or potential bugs were identified.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between be6c9a1 and 22ff17a.

Files selected for processing (1)
  • web/src/composables/useLogs.ts (4 hunks)
Additional comments not posted (2)
web/src/composables/useLogs.ts (2)

4018-4029: LGTM!

The new utility function reorderArrayByReference looks good. It correctly reorders arr1 based on the order of elements in arr2, moving elements not found in arr2 to the end.


4031-4048: LGTM!

The new function reorderSelectedFields looks good. It correctly reorders the selected fields based on the grid column order. It handles the case where the timestamp column may not be included and uses the reorderArrayByReference utility function to perform the reordering.

@omkarK06 omkarK06 merged commit c51d60e into main Sep 1, 2024
@omkarK06 omkarK06 deleted the fix/table_reordering_fixes branch September 1, 2024 10:31
nikhilsaikethe pushed a commit that referenced this pull request Sep 3, 2024
fix #4424 

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit


- **New Features**
- Introduced a new utility for reordering selected fields based on grid
column order, enhancing user experience when managing data fields.
- Improved drag-and-drop functionality for table columns, ensuring the
timestamp column is prioritized in the order.

- **Bug Fixes**
	- Enhanced error handling by streamlining logging processes.

- **Documentation**
- Updated component methods to clarify the use of new field management
logic.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

☢️ Bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Logs- Table/column issues

4 participants