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

IEP-1255: Adding option to remove all versions #996

Merged
merged 1 commit into from
Jun 21, 2024
Merged

Conversation

alirana01
Copy link
Collaborator

@alirana01 alirana01 commented Jun 18, 2024

Description

Added an option to remove all the ESP-IDF version in the manager view also now you can delete the active version.

Fixes # (IEP-1255)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

How has this been tested?

Install multiple versions and try using Remove All button which should remove every version from the IDE. Also test removing the active version. Verify that the remove all button stays disabled when there are no versions in the IDE.

Test Configuration:

  • ESP-IDF Version: any
  • OS (Windows,Linux and macOS): all

Checklist

  • PR Self Reviewed
  • Applied Code formatting
  • Verified on all platforms - Windows,Linux and macOS

Summary by CodeRabbit

  • New Features

    • Added a "Remove All" button to facilitate the removal of all ESP-IDF versions from the IDE.
    • Introduced new message prompts for confirming the deletion of all ESP-IDF versions.
  • Enhancements

    • Enhanced the user interface by renaming refreshTable() to refreshEditorUI() for better clarity and functionality.
    • Updated UI components to handle actions related to removing all toolsets.
  • Bug Fixes

    • Improved environment cleanup logic when deleting an IDF entry to ensure complete removal of related toolchains and environment variables.

@alirana01 alirana01 self-assigned this Jun 18, 2024
Copy link

coderabbitai bot commented Jun 18, 2024

Walkthrough

The recent updates enhance the ESP-IDF tool management functionality by improving UI components and backend logic for environment and toolchain cleanup. Key updates include renaming UI refresh methods, adding a "Remove All" button in the tool manager page, updating necessary string constants, and handling user confirmations for mass operations. The changes aim to streamline user interactions and ensure proper resource management in the IDE.

Changes

Files Change Summary
.../ToolSetConfigurationManager.java Added logic to clean up environment variables and toolchains in the delete method.
.../IDFNewToolsWizard.java, .../ToolsActivationJobListener.java Renamed refreshTable() method calls to refreshEditorUI().
.../Messages.java, .../messages.properties Introduced new string constants and modified existing ones for tool manager UI updates.
.../ESPIDFMainTablePage.java Added "Remove All" button, updated editor refresh logic, and adjusted layout/functionalities.

Poem

In fields of code, the bunnies leap,

To tools refined, the users greet.

A table glows with clean UI,

Buttons fresh, the old goodbye.

With one swift click, away they fall,

A simpler life for all recall.

Let's cheer for progress, swift and bright,

In ESP's dawn, the future's light. ✨🐇🚀

Warning

Review ran into problems

Problems (1)
  • Git: Failed to clone repository. Please contact CodeRabbit support.

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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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
Collaborator Author

@alirana01 alirana01 left a comment

Choose a reason for hiding this comment

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

Self Review

Copy link

@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: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between cf7455e and 237825e.

Files selected for processing (6)
  • bundles/com.espressif.idf.core/src/com/espressif/idf/core/tools/ToolSetConfigurationManager.java (1 hunks)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/IDFNewToolsWizard.java (1 hunks)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/Messages.java (1 hunks)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/ToolsActivationJobListener.java (1 hunks)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/manager/pages/ESPIDFMainTablePage.java (9 hunks)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/messages.properties (1 hunks)
Files skipped from review due to trivial changes (1)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/install/IDFNewToolsWizard.java
Additional comments not posted (9)
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/ToolsActivationJobListener.java (1)

52-52: Refactored method call from refreshTable() to refreshEditorUI() aligns with UI consistency improvements.

#!/bin/bash
# Description: Verify that all instances of `refreshTable()` have been replaced with `refreshEditorUI()`.

# Test: Search for the old function usage. Expect: No occurrences of the old function.
rg --type java $'refreshTable'
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/Messages.java (1)

119-124: Added string constants for 'Remove All' functionality are appropriately named and support the new feature.

#!/bin/bash
# Description: Verify that new string constants are used consistently in the UI.

# Test: Search for the new constants usage. Expect: Occurrences in UI related files.
rg --type java $'EspIdfManagerRemoveAllBtn|EspIdfManagerMessageBoxDeleteAllConfirmMessage|EspIdfManagerMessageBoxDeleteAllConfirmMessageTitle'
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/messages.properties (1)

121-126: Updated and added properties in messages.properties correctly support the new 'Remove All' functionality.

#!/bin/bash
# Description: Verify that the updated properties are used consistently and correctly throughout the application.

# Test: Search for the updated properties usage. Expect: Occurrences in UI related files.
rg --type properties $'EspIdfManagerRemoveAllBtn|EspIdfManagerMessageBoxDeleteConfirmMessage|EspIdfManagerMessageBoxDeleteConfirmMessageTitle|EspIdfManagerMessageBoxDeleteAllConfirmMessage|EspIdfManagerMessageBoxDeleteAllConfirmMessageTitle'
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/manager/pages/ESPIDFMainTablePage.java (6)

39-39: Added import for LaunchBarListener seems appropriate for the new UI functionalities introduced.


63-64: Introduction of new class variables idfToolSets and removeAllButton to manage the state and control of the toolsets and their UI representation.


73-73: Initialization of idfToolSets in the createPage method aligns with the new functionality to manage toolsets dynamically.


Line range hint 82-114: Refactored refreshEditorUI method to handle dynamic UI updates more efficiently, especially with the disposal of UI elements to prevent memory leaks.


120-127: Logic to enable/disable the removeAllButton based on the presence of toolsets is clear and correctly implemented.


187-208: Ensure that the removeAllButton is appropriately tested, especially the scenario where the deletion of one toolset fails but others might still need to be processed.

#!/bin/bash
# Description: Verify `removeAllButton` functionality with partial failure scenarios.

# Test: Simulate partial failure in deletion and check for correct handling.
# Expect: Remaining toolsets should still be attempted for deletion.
echo "Simulate and verify partial failure scenario."

Comment on lines +187 to +208
removeAllButton = new Button(buttonComposite, SWT.PUSH);
removeAllButton.setText(Messages.EspIdfManagerRemoveAllBtn);
removeAllButton.addSelectionListener(new SelectionAdapter()
{
@Override
public void widgetSelected(SelectionEvent e)
{
MessageBox messageBox = new MessageBox(Display.getDefault().getActiveShell(),
SWT.ICON_WARNING | SWT.YES | SWT.NO);
messageBox.setMessage(Messages.EspIdfManagerMessageBoxDeleteAllConfirmMessage);
messageBox.setText(Messages.EspIdfManagerMessageBoxDeleteAllConfirmMessageTitle);
int response = messageBox.open();
if (response == SWT.YES)
{
for(IDFToolSet idfToolSet : idfToolSets)
{
toolSetConfigurationManager.delete(idfToolSet);
}
refreshEditorUI();
}
}
});
Copy link

Choose a reason for hiding this comment

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

Added functionality for the removeAllButton to handle the removal of all toolsets. The use of a confirmation dialog box is a good user experience practice. However, consider handling potential exceptions during the deletion process to improve robustness.

+ try {
+   for(IDFToolSet idfToolSet : idfToolSets) {
+     toolSetConfigurationManager.delete(idfToolSet);
+   }
+   refreshEditorUI();
+ } catch (Exception e) {
+   // Log error or inform user
+ }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
removeAllButton = new Button(buttonComposite, SWT.PUSH);
removeAllButton.setText(Messages.EspIdfManagerRemoveAllBtn);
removeAllButton.addSelectionListener(new SelectionAdapter()
{
@Override
public void widgetSelected(SelectionEvent e)
{
MessageBox messageBox = new MessageBox(Display.getDefault().getActiveShell(),
SWT.ICON_WARNING | SWT.YES | SWT.NO);
messageBox.setMessage(Messages.EspIdfManagerMessageBoxDeleteAllConfirmMessage);
messageBox.setText(Messages.EspIdfManagerMessageBoxDeleteAllConfirmMessageTitle);
int response = messageBox.open();
if (response == SWT.YES)
{
for(IDFToolSet idfToolSet : idfToolSets)
{
toolSetConfigurationManager.delete(idfToolSet);
}
refreshEditorUI();
}
}
});
removeAllButton = new Button(buttonComposite, SWT.PUSH);
removeAllButton.setText(Messages.EspIdfManagerRemoveAllBtn);
removeAllButton.addSelectionListener(new SelectionAdapter()
{
@Override
public void widgetSelected(SelectionEvent e)
{
MessageBox messageBox = new MessageBox(Display.getDefault().getActiveShell(),
SWT.ICON_WARNING | SWT.YES | SWT.NO);
messageBox.setMessage(Messages.EspIdfManagerMessageBoxDeleteAllConfirmMessage);
messageBox.setText(Messages.EspIdfManagerMessageBoxDeleteAllConfirmMessageTitle);
int response = messageBox.open();
if (response == SWT.YES)
{
try {
for(IDFToolSet idfToolSet : idfToolSets) {
toolSetConfigurationManager.delete(idfToolSet);
}
refreshEditorUI();
} catch (Exception e) {
// Log error or inform user
}
}
}
});

Comment on lines +53 to +65
// cleanup the env and toolchains
IDFEnvironmentVariables idfEnvironmentVariables = new IDFEnvironmentVariables();
idfEnvironmentVariables.removeAllEnvVariables();
try
{
ESPToolChainManager espToolChainManager = new ESPToolChainManager();
espToolChainManager.removeCmakeToolChains();
espToolChainManager.removeStdToolChains();
}
catch (Exception e)
{
Logger.log(e);
}
Copy link

Choose a reason for hiding this comment

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

Enhanced cleanup logic in the delete method ensures that environment variables and toolchains are properly removed. Consider adding more detailed logging to improve traceability.

// Suggested logging enhancement
Logger.log("Starting cleanup for toolset: " + idfToolSet.getId());
try
{
    ESPToolChainManager espToolChainManager = new ESPToolChainManager();
    espToolChainManager.removeCmakeToolChains();
    espToolChainManager.removeStdToolChains();    
}
catch (Exception e)
{
    Logger.log("Failed to clean up toolchains for: " + idfToolSet.getId(), e);
}
Logger.log("Completed cleanup for toolset: " + idfToolSet.getId());

@alirana01 alirana01 changed the title IEP-1225: Adding option to remove all versions IEP-1255: Adding option to remove all versions Jun 20, 2024
Copy link
Collaborator

@sigmaaa sigmaaa left a comment

Choose a reason for hiding this comment

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

LGTM!

@alirana01 alirana01 merged commit 1a98b2a into master Jun 21, 2024
7 checks passed
@alirana01 alirana01 deleted the IEP-1225 branch June 21, 2024 09:17
@AndriiFilippov
Copy link
Collaborator

@alirana01 hi !

Tested under:
OS: -Windows 10
ESP-IDF: v5.2

Install tools -> create project -> build -> delete all tools using "Remove All" button -> restart IDE -> clean "Project Full Clean" -> try to build project -> it is still building project with empty Tool Manager.

image

@alirana01
Copy link
Collaborator Author

@alirana01 hi !

Tested under: OS: -Windows 10 ESP-IDF: v5.2

Install tools -> create project -> build -> delete all tools using "Remove All" button -> restart IDE -> clean "Project Full Clean" -> try to build project -> it is still building project with empty Tool Manager.

Can you try restarting IDE the toolchains at times dont disappear until restart

@AndriiFilippov
Copy link
Collaborator

@alirana01 hi !
Tested under: OS: -Windows 10 ESP-IDF: v5.2
Install tools -> create project -> build -> delete all tools using "Remove All" button -> restart IDE -> clean "Project Full Clean" -> try to build project -> it is still building project with empty Tool Manager.

Can you try restarting IDE the toolchains at times dont disappear until restart

Please, read my comment above.

@kolipakakondal kolipakakondal added this to the v3.1.0 milestone Sep 4, 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.

4 participants