Skip to content

Commit

Permalink
updated the message and clear the global states if the user ops not t…
Browse files Browse the repository at this point in the history
…o save the workspace
  • Loading branch information
JoshwinThomasIBM authored and JoshwinThomasIBM committed Nov 15, 2024
1 parent 8de7a68 commit bbb61bf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/liberty/devCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ function isWin(): boolean {
/*
Method adds a project which is selected by the user from the list to the liberty dashboard
*/
export async function addProjectsToTheDashBoard(projectProvider : ProjectProvider,selection:string): Promise<void>{
export async function addProjectsToTheDashBoard(projectProvider : ProjectProvider,selection:string): Promise<void>{
const result = await projectProvider.addUserSelectedPath(selection,projectProvider.getProjects());
const message = localize(`add.project.manually.message.${result}`, selection);
(result !== 0) ? console.error(message) : console.info(message); projectProvider.fireChangeEvent();
Expand Down
10 changes: 8 additions & 2 deletions src/liberty/libertyProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,22 @@ export class ProjectProvider implements vscode.TreeDataProvider<LibertyProject>
return new Promise((resolve) => {
try {
vscode.window.showInformationMessage(
'You are currently in an untitled workspace. Would you like to save it?',
'Please save the workspace first, as manually added projects to the dashboard may not persist in the next VS Code session if the workspace is not saved.',
{ modal: true },
'Save Workspace'
).then(async (selection) => {
if (selection === 'Save Workspace') {
//setting workspaceSaveInProgress to true and storing it in globalstate for identifyting that the workspace is saved and needs to
//save the manually adde projects to the dashboard
//save the manually added projects to the dashboard
await this._context.globalState.update('workspaceSaveInProgress',true);
//opens the saveWorkspace as dialog box
await vscode.commands.executeCommand('workbench.action.saveWorkspaceAs');
//after execution of above line , if save is opted the workspace reloads and reinitialisation of the workspace happens based on the
//activation events in package.json, if cancel is opted then the workspace is not going to be saved
//so below lines will clear workspaceSaveInProgress and selectedProject from the global state
await this._context.globalState.update('workspaceSaveInProgress',false);
await this._context.globalState.update('selectedProject',undefined);
resolve();
}else {
// No workspace save was initiated
resolve();
Expand Down

0 comments on commit bbb61bf

Please sign in to comment.