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

Improve quality UX #8865

Open
wants to merge 14 commits into
base: develop
Choose a base branch
from
Open

Improve quality UX #8865

wants to merge 14 commits into from

Conversation

klakhov
Copy link
Contributor

@klakhov klakhov commented Dec 24, 2024

Motivation and context

How has this been tested?

Checklist

  • I submit my changes into the develop branch
  • I have created a changelog fragment
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • I have linked related issues (see GitHub docs)
  • I have increased versions of npm packages if it is necessary
    (cvat-canvas,
    cvat-core,
    cvat-data and
    cvat-ui)

License

  • I submit my code changes under the same MIT License that covers the project.
    Feel free to contact the maintainers if that's a concern.

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced styling for the Quality Control page title.
    • Introduced new QualityTableHeader component for improved search and download functionalities.
    • Added search and CSV download capabilities to the Allocation Table.
  • Improvements

    • Updated layout and styling for various quality control components.
    • Improved responsiveness and clarity in the Quality Management Tab.
  • Bug Fixes

    • Adjusted Cypress tests to reflect updated selectors for the quality control management tab.

@klakhov klakhov added the ui/ux label Dec 24, 2024
Copy link
Contributor

coderabbitai bot commented Dec 24, 2024

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The pull request introduces enhancements to the quality control components in the CVAT UI. The changes focus on improving the user interface, adding new functionality like search and download capabilities for allocation tables, and refining the styling of quality control pages. The modifications span multiple files, including component logic, styles, and test selectors, with a primary emphasis on making the quality management tab more responsive and informative.

Changes

File Change Summary
cvat-ui/src/components/quality-control/quality-control-page.tsx Updated Title component CSS class to include cvat-quality-page-header
cvat-ui/src/components/quality-control/styles.scss Added new CSS classes and modified existing styles for quality control components, including overflow, text, and layout adjustments
cvat-ui/src/components/quality-control/task-quality/allocation-table.tsx Added pageWidth prop, implemented search and download functionalities, replaced header layout with new QualityTableHeader component
cvat-ui/src/components/quality-control/task-quality/quality-magement-tab.tsx Enhanced validation mode text, added table width tracking, replaced summary component with AnalyticsCard components
cvat-ui/src/components/quality-control/task-quality/quality-table-header.tsx New component with CSV download and search functionalities
tests/cypress/e2e/features/ground_truth_jobs.js Updated selectors for quality control management tab summary

Sequence Diagram

sequenceDiagram
    participant User
    participant QualityManagementTab
    participant AllocationTable
    participant QualityTableHeader

    User->>QualityManagementTab: Access Quality Control
    QualityManagementTab->>AllocationTable: Render with pageWidth
    AllocationTable->>QualityTableHeader: Use for Table Header
    User->>QualityTableHeader: Perform Search
    QualityTableHeader->>AllocationTable: Filter Data
    User->>QualityTableHeader: Download CSV
    QualityTableHeader-->>User: Trigger CSV Download
Loading

Poem

🐰 Hop, hop, quality control's new dance!
Tables that search with a rabbit's glance
Headers that shine, width adapting with grace
CSV downloads at a lightning-fast pace
CVAT's UI, now sleeker than before
A bunny's delight, innovation galore! 🔍

Finishing Touches

  • 📝 Generate Docstrings

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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

@klakhov klakhov marked this pull request as ready for review December 25, 2024 13:09
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

🧹 Nitpick comments (7)
cvat-ui/src/components/quality-control/task-quality/quality-table-header.tsx (3)

12-17: Consider creating a more explicit type for the onDownload return value
Defining a stronger contract (e.g., an interface) for { filename: string; data: ... } may improve clarity and reduce maintenance overhead, especially if additional metadata or file formats are supported in the future.


25-33: Potential large-file performance concern
For very large data sets, using Blob with an in-memory string can be memory-intensive. You may consider a streaming approach or chunked writing if there's a possibility of generating particularly large CSV files.


35-74: Recommend adding debounce for the search bar
The search function executes on each enterButton press by default, which is fine, but if you plan to add "onChange" searching or a heavier search logic in the future, consider a debounce to reduce performance overhead. Also, the component structure is well-structured and consistent with your styling approach.

cvat-ui/src/components/quality-control/task-quality/quality-magement-tab.tsx (1)

46-59: Responsive logic with useLayoutEffect
Listening to window resize events is an intuitive approach for responsive table design. Consider a small throttle or debounce if the parent container triggers many consecutive resize events (e.g., rapid window resizing).

cvat-ui/src/components/quality-control/task-quality/allocation-table.tsx (1)

80-80: Calculating frameNameWidth
Using the offset approach to derive a column’s width is pragmatic. However, ensure it scales well at very small or large screen sizes by possibly clamping (e.g. max/min).

cvat-ui/src/components/quality-control/styles.scss (2)

139-144: Consider removing !important flag

While the padding adjustments are good for consistency, using !important should be avoided. Consider increasing selector specificity instead:

- .ant-table-tbody .ant-table-cell {
-     padding: $grid-unit-size * 0.5 $grid-unit-size !important;
- }
+ .cvat-frame-allocation-table .ant-table-container .ant-table-tbody .ant-table-cell {
+     padding: $grid-unit-size * 0.5 $grid-unit-size;
+ }

155-170: Review negative margin impact on responsive layouts

The negative margins in .cvat-quality-control-management-tab-summary might cause layout issues on smaller screens or when the content overflows. Consider:

  1. Using padding on the parent container instead
  2. Adding media queries for responsive behavior
  3. Setting a min-width to prevent unwanted wrapping
.cvat-quality-control-management-tab-summary {
-    margin-left: - $grid-unit-size;
-    margin-right: - $grid-unit-size;
+    padding: 0 $grid-unit-size;
+    min-width: 320px;  // Add minimum width to prevent unwanted wrapping

    >.ant-col {
        padding: 0 $grid-unit-size;
    }
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d2c0713 and 39f44a2.

📒 Files selected for processing (6)
  • cvat-ui/src/components/quality-control/quality-control-page.tsx (1 hunks)
  • cvat-ui/src/components/quality-control/styles.scss (3 hunks)
  • cvat-ui/src/components/quality-control/task-quality/allocation-table.tsx (6 hunks)
  • cvat-ui/src/components/quality-control/task-quality/quality-magement-tab.tsx (3 hunks)
  • cvat-ui/src/components/quality-control/task-quality/quality-table-header.tsx (1 hunks)
  • tests/cypress/e2e/features/ground_truth_jobs.js (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • cvat-ui/src/components/quality-control/quality-control-page.tsx
🔇 Additional comments (21)
cvat-ui/src/components/quality-control/task-quality/quality-table-header.tsx (1)

19-23: Be cautious about CSV injection
When data contains malicious inputs (e.g., entries beginning with '=' or '+'), spreadsheet programs might interpret them as formulas. Consider sanitizing each cell to defend against CSV injection attacks.

Would you like help implementing a sanitization approach for cells starting with special characters?

cvat-ui/src/components/quality-control/task-quality/quality-magement-tab.tsx (7)

5-12: Multiple new imports for layout effect, references, and typing
Imports look appropriate for the planned responsive design changes, referencing both useLayoutEffect and useState. The usage of Text from antd/lib/typography/Text is consistent with the rest of the codebase’s styling approach.


32-34: Ref usage for container width
Using a ref to capture the container width is a neat way to dynamically size child components. Be mindful of cross-browser differences in how clientWidth is computed (e.g., if padding or borders matter).
[approve]


38-45: Fine-grained validation mode text
Assigning descriptive validationModeText provides clarity for the user. Ensuring all relevant modes are covered will prevent fallback to null.


63-76: Clear usage of AnalyticsCard
These cards neatly display important metrics (total, excluded, active). Implementation is straightforward and should help maintain clarity for end users.


83-91: Conditional rendering of validation mode
The conditionally rendered note on validation mode is straightforward. This text is helpful for user awareness.


93-93: Ref container reference for the table
Building on the earlier observation, referencing DOM elements is a standard practice. Looks good.


102-102: Passing pageWidth to <AllocationTable>
Sending the computed container width down to child components is a solid approach for dynamic interface adaptation.

cvat-ui/src/components/quality-control/task-quality/allocation-table.tsx (8)

21-21: Importing QualityTableHeader
Integrating the new header component is consistent with the modular approach to building UI components.


29-29: New prop pageWidth in Props
Clear addition for responsive layouts. Keep an eye on usage contexts to avoid null or undefined references if parent-level logic changes.


40-41: Offset constant
Defining COLUMNS_OFFSET_PERCENT offers clarity rather than using a numeric literal. Good for maintainability.


66-72: Implementing search logic
Filtering data based on user query is basic but effective. For extended search logic (fuzzy match, advanced queries), consider more sophisticated libraries.


74-78: Download logic
Exporting only the rest of fields and removing key in CSV is consistent with typical CSV structures. The approach is straightforward and aligns perfectly with the QualityTableHeader usage.


108-127: Rendering the “Name” column with a clickable button
The combination of a tooltip and clickable area is user-friendly. Providing href improves accessibility for screen readers. Great job.


159-190: Integrating QualityTableHeader
The new search & download features live neatly in the header. Conditional rendering of group operations based on selectedRowKeys is also well-handled.


200-200: Updating dataSource to filteredData
Ensures the table instantly re-renders upon search. Straightforward approach, consistent with the rest of the filtering logic.

tests/cypress/e2e/features/ground_truth_jobs.js (2)

277-277: Selector changed to .cvat-quality-control-management-tab-summary
Renaming the summary selector to match the new layout is consistent. Ensure references throughout the test suite are aligned with the updated naming to avoid breakages in future merges.


286-286: Verification checks for summary metrics
These additional assertions confirm that summary cards accurately reflect totals, excluded frames, and active frames. Very clear approach to E2E coverage.

cvat-ui/src/components/quality-control/styles.scss (3)

8-8: LGTM! Improved scroll handling

The change from overflow-y: auto to overflow: hidden auto is a good improvement that prevents unwanted horizontal scrollbars while maintaining vertical scrolling when needed.


151-151: Verify height adjustment across different screen sizes

The reduction in height calculation (from 33 to 30 grid units) might affect the content visibility. Please verify that this works well across different screen sizes and doesn't cause content truncation.


101-107: Verify RTL direction impact on LTR text

While the text overflow handling is good, using direction: rtl might affect the display of left-to-right text. Please verify that this doesn't cause issues with:

  1. Text alignment for different languages
  2. Special characters or numbers
  3. Text selection behavior

Run this script to check for potential text content:

✅ Verification successful

The previous script failed because the file type 'tsx' wasn't recognized. Let's try with standard TypeScript/JavaScript files and also look directly in the quality control component directory for any text content that might be displayed in this button.


Let me analyze the button's text content and usage based on the search results. I found that the button is used in the allocation table component and displays frame names with tooltips:


RTL direction is safe to use in this context

The direction: rtl is used in conjunction with text overflow handling properties for a specific purpose - to show text truncation from the left side instead of the default right side. This is a common CSS pattern when you want to show the end of the text rather than the beginning when it's truncated.

Looking at the code:

  1. The button is used to display frame names in the allocation table
  2. It's a link-type button that navigates to specific frames
  3. The RTL direction is specifically scoped to this button class and won't affect other components
  4. The text content is simple frame names/numbers that won't be affected by RTL direction

The combination of:

word-wrap: break-word;
word-break: break-word;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
direction: rtl;

is a valid pattern for left-side text truncation and won't cause issues with:

  • Text alignment (due to nowrap)
  • Special characters (due to isolated button scope)
  • Text selection (handled by browser)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for text content passed to this button component
rg -l --type ts --type tsx "cvat-open-frame-button"

Length of output: 79


Script:

#!/bin/bash
# Search for text content in TypeScript/JavaScript files
rg -l "cvat-open-frame-button" --type ts --type js

# Also search in the specific component directory for any text content
rg -A 5 "text|label|title" "cvat-ui/src/components/quality-control/"

Length of output: 37051


Script:

#!/bin/bash
# Let's check for any frame name or text content handling in the component
rg -A 5 "cvat-open-frame-button" "cvat-ui/src/components/quality-control/task-quality/allocation-table.tsx"

# Also check for any RTL-specific text or translations
rg "rtl|direction:" "cvat-ui/src/components/quality-control/"

Length of output: 966

@codecov-commenter
Copy link

codecov-commenter commented Dec 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.89%. Comparing base (331ff86) to head (a1242f2).
Report is 1 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #8865      +/-   ##
===========================================
- Coverage    73.93%   73.89%   -0.05%     
===========================================
  Files          411      412       +1     
  Lines        44245    44261      +16     
  Branches      3993     3993              
===========================================
- Hits         32714    32706       -8     
- Misses       11531    11555      +24     
Components Coverage Δ
cvat-ui 78.37% <ø> (-0.04%) ⬇️
cvat-server 70.09% <0.00%> (-0.05%) ⬇️

Copy link

sonarqubecloud bot commented Jan 9, 2025

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

Successfully merging this pull request may close these issues.

2 participants