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

Removed legacy component to setup shortcuts #8416

Merged
merged 10 commits into from
Sep 9, 2024

Conversation

bsekachev
Copy link
Member

@bsekachev bsekachev commented Sep 8, 2024

Motivation and context

  • The intention of this component was understood by users wrong way
  • We already have a general approach to setup shortcuts
  • Finally, it does not work as I discovered

image

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

  • New Features

    • Enhanced label management and shortcut handling in the Labels List component.
    • Improved functionality for handling different shape types associated with labels.
  • Bug Fixes

    • Streamlined state management to reduce re-renders and improve efficiency.
  • Style

    • Removed obsolete styles related to shortcut buttons and popovers, simplifying the UI design.
  • Documentation

    • Updated internal logic for control updates in the annotation reducer for better state management.

Copy link
Contributor

coderabbitai bot commented Sep 8, 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 changes involve significant modifications to the LabelItemComponent and LabelsListComponent, focusing on the management of label properties and shortcuts. The Props interface for LabelItemComponent has been simplified by removing several properties, leading to the elimination of related UI elements. In LabelsListComponent, state management has been optimized, and the handling of label shortcuts has been refactored. Additionally, CSS styles for shortcut buttons and popovers have been removed, and a new condition has been added to the annotation reducer to control updates to the active control state.

Changes

Files Change Summary
cvat-ui/src/components/.../label-item.tsx Removed properties from Props interface and LabelItemComponent, eliminated related UI components, and adjusted layout for label name display.
cvat-ui/src/components/.../labels-list.tsx Streamlined state management, refactored key mapping logic, updated handleHelper function, and enhanced label applicability checks.
cvat-ui/src/components/.../styles.scss Removed CSS class definitions for shortcut buttons and popovers, indicating a shift in UI design.
cvat-ui/src/reducers/.../annotation-reducer.ts Added a condition to control the update of activeControl based on payload.updateCurrentControl.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant LabelsListComponent
    participant AnnotationReducer

    User->>LabelsListComponent: Interacts with label
    LabelsListComponent->>AnnotationReducer: Dispatch action with payload
    AnnotationReducer->>AnnotationReducer: Check updateCurrentControl
    alt updateCurrentControl is true
        AnnotationReducer->>AnnotationReducer: Update activeControl
    end
Loading

🐇 In a world of labels, bright and neat,
A change has come, oh what a treat!
With shortcuts gone, and props so few,
The interface shines, fresh as the dew.
Hopping along, we celebrate this day,
For simpler paths lead us on our way! 🌼


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.

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 c8f57e3 and 69fb246.

Files selected for processing (5)
  • cvat-ui/src/components/annotation-page/standard-workspace/objects-side-bar/label-item.tsx (2 hunks)
  • cvat-ui/src/components/annotation-page/standard-workspace/objects-side-bar/labels-list.tsx (4 hunks)
  • cvat-ui/src/components/annotation-page/standard-workspace/objects-side-bar/styles.scss (1 hunks)
  • cvat-ui/src/containers/annotation-page/standard-workspace/objects-side-bar/label-item.tsx (2 hunks)
  • cvat-ui/src/reducers/annotation-reducer.ts (1 hunks)
Files skipped from review due to trivial changes (2)
  • cvat-ui/src/components/annotation-page/standard-workspace/objects-side-bar/styles.scss
  • cvat-ui/src/containers/annotation-page/standard-workspace/objects-side-bar/label-item.tsx
Additional comments not posted (6)
cvat-ui/src/components/annotation-page/standard-workspace/objects-side-bar/label-item.tsx (2)

2-2: Update copyright year.

The copyright year has been updated to include 2024, reflecting the current year.


65-65: Column span adjustment for label name.

The column span for the label name has been increased from 12 to 15. This change will affect the visual layout of the component, potentially allowing more space for the label name to be displayed. Ensure that this adjustment aligns with the UI design requirements.

cvat-ui/src/components/annotation-page/standard-workspace/objects-side-bar/labels-list.tsx (3)

10-10: Addition of ShapeType import.

The import of ShapeType from cvat-core-wrapper has been added, indicating an enhancement in the component's ability to manage different shape types associated with labels. This change should be verified to ensure it integrates well with the existing label management logic.

Verification successful

Integration of ShapeType Verified

The addition of ShapeType from cvat-core-wrapper is well-integrated with the existing label management logic. It is used in various parts of the codebase related to annotation and label management, such as reducers and actions, confirming its role in managing different shape types associated with labels.

  • Files where ShapeType is used include:
    • cvat-ui/src/utils/opencv-wrapper/opencv-wrapper.ts
    • cvat-ui/src/reducers/annotation-reducer.ts
    • cvat-ui/src/actions/annotation-actions.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify integration of ShapeType with label management logic.

# Test: Search for usage of ShapeType in label management.
rg --type javascript -A 5 $'ShapeType in label management'

Length of output: 94


Script:

#!/bin/bash
# Description: Search for usage of ShapeType in TypeScript files to verify its integration with label management logic.

# Use ast-grep to find occurrences of ShapeType in TypeScript files.
ast-grep --lang typescript --pattern 'ShapeType' 

Length of output: 12504


72-72: Updated handleHelper function.

The handleHelper function has been updated to utilize the new state structure, improving the clarity of how label IDs are processed. This update should be verified to ensure it correctly handles label interactions based on the new state structure.


39-44: Refactored state management using useSelector.

The state management has been streamlined by consolidating multiple useSelector calls into a single call that retrieves labels and keyMap, utilizing shallowEqual for performance optimization. This change reduces the number of re-renders and improves efficiency by minimizing the number of state slices being monitored. Ensure that this refactoring does not affect the expected behavior of the component.

cvat-ui/src/reducers/annotation-reducer.ts (1)

471-487: Added condition to control activeControl updates.

A new condition has been added to check if payload.updateCurrentControl is true before updating the activeControl. This change is intended to prevent unintended updates to the control state and should be verified to ensure it does not introduce any regressions or conflicts with other parts of the application.

Copy link

sonarcloud bot commented Sep 9, 2024

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.58%. Comparing base (632c4ce) to head (8e77970).
Report is 1 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #8416   +/-   ##
========================================
  Coverage    83.57%   83.58%           
========================================
  Files          396      396           
  Lines        41906    41907    +1     
  Branches      3881     3883    +2     
========================================
+ Hits         35024    35027    +3     
+ Misses        6882     6880    -2     
Components Coverage Δ
cvat-ui 79.53% <100.00%> (+0.01%) ⬆️
cvat-server 87.18% <ø> (ø)

@bsekachev bsekachev merged commit cc5a016 into develop Sep 9, 2024
34 checks passed
This was referenced Sep 9, 2024
@bsekachev bsekachev deleted the bs/removed_legacy_component_to_setup_shortcuts branch September 12, 2024 09:51
bschultz96 pushed a commit to bschultz96/cvat that referenced this pull request Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants