OpenLiberty / liberty-tools-vscode

Visual Studio Code extension for Liberty Tools
https://marketplace.visualstudio.com/items?itemName=Open-Liberty.liberty-dev-vscode-ext
Eclipse Public License 2.0
17 stars 34 forks source link

Difficult to add project manually to liberty dashboard #206

Open turkeylurkey opened 1 year ago

turkeylurkey commented 1 year ago

When you need to add a project to the liberty dashboard manually it is hard to find where to click. Here is a portion of the Explorer: image Section 1 is the project name. You would think you'd click here to add it to liberty but no. If it did work here no list of projects would be needed. Section 2 is all the files in the project. This list is normally quite long and fills the entire window. Adding the "Add to Liberty Dashboard" menu item here is ok but perhaps not ideal. Maybe pom.xml is special and the menu item could be added for that one file. Section 3 is the only area it works. Quite a small area and not normally visible. You have to manually scroll to the bottom to reveal this area. Section 4 is another area you might expect to right click to get the context menu and see the "Add to Liberty Dashboard" menu item

TrevCraw commented 1 year ago

Expected behaviour is ability to manually add project to Liberty dashboard from sections 1 and 4. If selecting from section 4 (the space in the Liberty dashboard), expected behaviour would be to prompt users on which project they would like to add. If selecting from section 1 (the project root folder), expected behaviour would be that we add the selected project to the dashboard - no project prompt required.

anusreelakshmi934 commented 9 months ago

Based on my understanding, it appears that the required functionality doesn't have direct APIs involved in VSCode. Currently, only the explorerResourceIsFolder and explorerResourceIsRoot conditions are available. To address this issue we may need to implement a custom solution. For the specific case mentioned in section 4, we have to verify that the selected item is a folder and it contains the necessary build files. If the check returns true, indicating the presence of build files, you can then update the "when" condition for "add/remove project to Liberty dashboard" action in the package.json file accordingly.

In summary, we have to implement a custom function to check for build files in the selected folder and dynamically adjust the when condition in the package.json file based on the result of this check.

anusreelakshmi934 commented 8 months ago

I've implemented a function called hasPomXmlOrBuildGradle() to verify if a folder contains either a pom.xml or build.gradle file. This function is then registered in the extension.ts file as vscode.commands.registerCommand('myExtension.hasPomXmlOrBuildGradle', () => devCommands.hasPomXmlOrBuildGradle()).

In the package.json file, the liberty.dev.add.project command is executed only when hasPomXmlOrBuildGradle() returns true.

Despite attempting to directly set the return value to true rather than devCommands.hasPomXmlOrBuildGradle(), the process remains ineffective.

anusreelakshmi934 commented 5 months ago

The function hasPomXmlOrBuildGradle() doesnt seem to work properly and we are not able to verify if a folder contains either a pom.xml or build.gradle file eventhough function is then registered in the extension.ts file. May need to further look into whether the implementation of the function is wrong or not.

anusreelakshmi934 commented 5 months ago

Progress on this issue is saved on this branch: - https://github.com/anusreelakshmi934/liberty-tools-vscode/tree/feature%23206. This change has added a three dots in the corner of liberty dashboard that has - "Add project to Liberty Dashboard" and "Remove project from Liberty Dashboard" . Attaching ss below :

image

But to implement a custom function to check for build files in the selected folder is not currently in working condition. needs further look in implementing the function