Skip to content

Conversation

@omkarK06
Copy link
Contributor

@omkarK06 omkarK06 commented Aug 30, 2024

fix #4396

  1. On opening log details, api call is made to fetch traces streams. This should only happen if log-traces correlation is enabled
  2. When we add columns to table, table width does not reset to the available columns.

fix #4405

Summary by CodeRabbit

  • New Features

    • Enhanced column width calculation for improved table layout.
    • Conditional rendering of the view trace button based on available trace options.
    • Dynamic management of default column visibility in search results.
  • Improvements

    • Optimized data retrieval logic to reduce unnecessary fetching.
    • Updated table component to allow dynamic control over column behavior and sorting.
    • Enhanced responsiveness of the table to dynamic data changes.
  • Bug Fixes

    • Cleaned up console logs for better maintainability.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 30, 2024

Walkthrough

The changes involve modifications to several components in the codebase, focusing on enhancing the functionality and responsiveness of table displays and UI elements related to logs and search results. Key updates include adjustments to column width calculations, conditional rendering of UI elements based on data availability, and the introduction of new properties to improve layout management.

Changes

Files Change Summary
web/src/composables/useLogs.ts Updated column width calculation logic to include additional padding and increased iteration count, simplifying the return statement for maximum width.
web/src/plugins/logs/JsonPreview.vue Enhanced conditional logic for rendering the view trace button and optimized data retrieval based on button visibility, along with minor console log cleanups.
web/src/plugins/logs/SearchResult.vue Introduced a new prop :default-columns to manage default column visibility based on selectedFields length, improving responsiveness to user selections.
web/src/plugins/logs/TenstackTable.vue Modified column width handling and sorting logic based on defaultColumns, introduced a new defaultColumns prop, and updated watch functions for responsiveness.

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 ☢️ Bug Something isn't working 🧹 Updates labels Aug 30, 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

Outside diff range, codebase verification and nitpick comments (1)
web/src/composables/useLogs.ts (1)

Line range hint 3113-3138: Refactor suggestion: Improve column width calculation logic.

The logic for calculating column widths has been updated to include additional padding and consider more items in the iteration. However, the implementation can be further optimized by abstracting the width calculation into a separate function to improve readability and maintainability. Additionally, the magic numbers (e.g., 16, 24, 800, 150) should be replaced with named constants to enhance code clarity.

Consider refactoring the column width calculation logic into a separate function and using named constants for magic numbers. Here's a proposed refactor:

- let max = context.measureText(field).width + 16;
+ const PADDING = 16;
+ let max = context.measureText(field).width + PADDING;

- max += 24; // 24px padding
+ const ADDITIONAL_PADDING = 24;
+ max += ADDITIONAL_PADDING;

- if (max > 800) return 800;
- if (max < 150) return 150;
+ const MAX_WIDTH = 800;
+ const MIN_WIDTH = 150;
+ if (max > MAX_WIDTH) return MAX_WIDTH;
+ if (max < MIN_WIDTH) return MIN_WIDTH;
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8139725 and 52c411e.

Files selected for processing (4)
  • web/src/composables/useLogs.ts (2 hunks)
  • web/src/plugins/logs/JsonPreview.vue (4 hunks)
  • web/src/plugins/logs/SearchResult.vue (1 hunks)
  • web/src/plugins/logs/TenstackTable.vue (8 hunks)
Additional comments not posted (5)
web/src/plugins/logs/JsonPreview.vue (2)

15-15: Conditional rendering logic improved for view trace button.

The updated condition ensures that the button is only displayed when appropriate, enhancing the user interface by preventing unnecessary elements from being shown when there are no trace options available.


278-278: Optimized data fetching based on UI visibility.

The conditional execution of getTracesStreams() based on the visibility of the view trace button is a good practice, as it prevents unnecessary network requests and resource usage when the button is not displayed.

Run the following script to verify the function usage:

Verification successful

Conditional logic for getTracesStreams is correctly implemented.

The function getTracesStreams is called conditionally based on showViewTraceBtn.value, as intended. This ensures that the function is only executed when necessary, optimizing resource usage. No other occurrences of the function call were found, confirming the change is isolated and correctly applied.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `getTracesStreams` match the new conditional logic.

# Test: Search for the function usage. Expect: Only occurrences of the new conditional logic.
rg --type vue -A 5 $'getTracesStreams'

Length of output: 65


Script:

#!/bin/bash
# Find all .vue files and search for the function `getTracesStreams` within them.
fd --extension vue --exec rg 'getTracesStreams' {}

Length of output: 149

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

393-396: Introduction of defaultColumns prop enhances configurability.

The new defaultColumns prop with a default value of true provides additional control over the table's column configuration, allowing for dynamic adjustments based on the application's state.


26-26: Dynamic column width calculation based on defaultColumns.

The new logic for calculating the width of table columns based on the defaultColumns prop enhances flexibility and responsiveness of the table layout.

Run the following script to verify the column width calculations:

Verification successful

Dynamic column width calculation based on defaultColumns is correctly implemented.

The defaultColumns prop is used in various expressions to dynamically adjust the table's layout and width, confirming the review comment's observation. The implementation aligns with the intended functionality.

  • File: web/src/plugins/logs/TenstackTable.vue
  • Occurrences: Multiple conditional expressions affecting layout and width.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the dynamic column width calculations based on `defaultColumns`.

# Test: Search for the usage of `defaultColumns` in column width calculations. Expect: Only occurrences of the new logic.
rg --type vue -A 5 $'defaultColumns'

Length of output: 63


Script:

#!/bin/bash
# Description: Verify the dynamic column width calculations based on `defaultColumns`.

# Test: Search for the usage of `defaultColumns` in the codebase to verify its role in column width calculations.
rg -A 5 'defaultColumns'

Length of output: 2165

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

144-144: Dynamic adjustment of default column visibility based on selectedFields.

The new prop binding for :default-columns dynamically adjusts the visibility of default columns based on the length of the selectedFields array, enhancing the responsiveness and user experience of the component.

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 52c411e and 2f3f221.

Files selected for processing (1)
  • web/src/plugins/logs/TenstackTable.vue (10 hunks)
Files skipped from review as they are similar to previous changes (1)
  • web/src/plugins/logs/TenstackTable.vue

@omkarK06 omkarK06 force-pushed the fix/tables_ui_fixes branch from 9373b64 to 2a540a4 Compare August 30, 2024 10:39
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 2f3f221 and 2a540a4.

Files selected for processing (4)
  • web/src/composables/useLogs.ts (3 hunks)
  • web/src/plugins/logs/JsonPreview.vue (4 hunks)
  • web/src/plugins/logs/SearchResult.vue (1 hunks)
  • web/src/plugins/logs/TenstackTable.vue (10 hunks)
Files skipped from review as they are similar to previous changes (4)
  • web/src/composables/useLogs.ts
  • web/src/plugins/logs/JsonPreview.vue
  • web/src/plugins/logs/SearchResult.vue
  • web/src/plugins/logs/TenstackTable.vue

@omkarK06 omkarK06 merged commit a24a330 into main Aug 30, 2024
@omkarK06 omkarK06 deleted the fix/tables_ui_fixes branch August 30, 2024 11:04
nikhilsaikethe pushed a commit that referenced this pull request Sep 3, 2024
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit


- **New Features**
	- Enhanced column width calculation for improved table layout.
- Conditional rendering of the view trace button based on available
trace options.
	- Dynamic management of default column visibility in search results.

- **Improvements**
	- Optimized data retrieval logic to reduce unnecessary fetching.
- Updated table component to allow dynamic control over column behavior
and sorting.
	- Enhanced responsiveness of the table to dynamic data changes.

- **Bug Fixes**
	- Cleaned up console logs for better maintainability.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@coderabbitai coderabbitai bot mentioned this pull request Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

☢️ Bug Something isn't working 🧹 Updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The width of the bar changes when hovering over the chart, showing '0' Logs- Issues/ Observations

3 participants