Skip to content

Commit

Permalink
showInformationMessage - show 'Add to Workspace' button only if works… (
Browse files Browse the repository at this point in the history
#203)

* showInformationMessage - show 'Add to Workspace' button only if workspace is open

* showInformationMessage - show 'Add to Workspace' button only if workspace is open

* version: 0.0.65
  • Loading branch information
tomer-epstein authored Mar 25, 2020
1 parent fc223f1 commit 23d0d09
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "Apache 2.0",
"description": "Provide rich user experience for Yeoman generators using VSCode extension or the browser",
"repository": "https://github.com/SAP/yeoman-ui",
"version": "0.0.64",
"version": "0.0.65",
"engines": {
"vscode": "^1.39.2"
},
Expand Down
2 changes: 1 addition & 1 deletion backend/src/vscode-youi-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class VSCodeYouiEvents implements YouiEvents {
VSCodeYouiEvents.installing = false;
if (success) {
const OpenWorkspace = 'Open in New Workspace';
const AddToWorkspace = 'Add to Workspace';
const AddToWorkspace = (vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length) ? 'Add to Workspace' : undefined;
vscode.window.showInformationMessage('The project has been successfully generated.\nWhat would you like to do with it?', AddToWorkspace, OpenWorkspace).then(selection => {
if (selection === OpenWorkspace) {
this.executeCommand("vscode.openFolder", targetPath);
Expand Down
13 changes: 12 additions & 1 deletion backend/tests/vscode-youi-events.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,24 @@ describe('vscode-youi-events unit test', () => {
});

describe("doGeneratorDone", () => {
it("on success", () => {
it("on success workspace is open", () => {
eventsMock.expects("doClose");
_.set(vscode, "window.showInformationMessage", () => {return Promise.resolve("");});
_.set(vscode, "workspace.workspaceFolders", []);
_.set(vscode, "workspace.workspaceFolders.length", 1);
windowMock.expects("showInformationMessage").withExactArgs('The project has been successfully generated.\nWhat would you like to do with it?', 'Add to Workspace', 'Open in New Workspace').resolves();
events.doGeneratorDone(true, "success message", "testDestinationRoot");
});

it("on success workspace is closed", () => {
eventsMock.expects("doClose");
_.set(vscode, "window.showInformationMessage", () => {return Promise.resolve("");});
_.set(vscode, "workspace.workspaceFolders", undefined);
_.set(vscode, "workspace.workspaceFolders.length", 0);
windowMock.expects("showInformationMessage").withExactArgs('The project has been successfully generated.\nWhat would you like to do with it?', undefined, 'Open in New Workspace').resolves();
events.doGeneratorDone(true, "success message", "testDestinationRoot");
});

it("on failure", () => {
eventsMock.expects("doClose");
_.set(vscode, "window.showErrorMessage", () => {return Promise.resolve("");});
Expand Down

0 comments on commit 23d0d09

Please sign in to comment.