Skip to content

Make ServerManager extension as optional, do not prevent this extension working. #188

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

Merged
merged 3 commits into from
Jul 9, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@
"onDebugInitialConfigurations"
],
"main": "./dist/extension",
"extensionDependencies": [
"intersystems-community.servermanager"
],
"contributes": {
"menus": {
"commandPalette": [
Expand Down Expand Up @@ -712,6 +709,11 @@
"type": "boolean",
"default": false,
"description": "Output the action that VSCode should perform as requested by the server in JSON format."
},
"objectscript.ignoreInstallServerManager": {
"type": "boolean",
"default": false,
"markdownDescription": "Do not offer to install `#intersystems-community.servermanager#` extension"
}
}
},
Expand Down
37 changes: 37 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,40 @@ export const checkConnection = (clearCookies = false): void => {
});
};

async function serverManager(): Promise<void> {
const extId = "intersystems-community.servermanager";
const ignore =
config("ignoreInstallServerManager") ||
vscode.workspace.getConfiguration("intersystems.servers").get("/ignore", false);
if (ignore || vscode.extensions.getExtension(extId)) {
return;
}
return vscode.window
.showInformationMessage(
`Extension InterSystems® Server Manager have not installed,
it's recommended to install it.`,
"Install",
"Skip",
"Ignore"
)
.then(async (action) => {
switch (action) {
case "Install":
await vscode.commands.executeCommand("workbench.extensions.installExtension", extId);
// eslint-disable-next-line no-fallthrough
case "View":
Copy link
Contributor

Choose a reason for hiding this comment

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

showInformationMessage doesn't offer "View" option

Copy link
Member Author

Choose a reason for hiding this comment

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

My thoughts were, do not offer too many buttons, and was not sure if it's a good idea to install it from information message, not from extension page

Copy link
Contributor

Choose a reason for hiding this comment

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

In which case why is case "View": here?

await vscode.commands.executeCommand("workbench.extensions.search", `@tag:"intersystems"`);
await vscode.commands.executeCommand("extension.open", extId);
break;
case "Ignore":
config().update("ignoreInstallServerManager", true, vscode.ConfigurationTarget.Global);
break;
case "Skip":
default:
}
});
}

export async function activate(context: vscode.ExtensionContext): Promise<void> {
if (!packageJson.version.includes("SNAPSHOT")) {
reporter = new TelemetryReporter(extensionId, extensionVersion, aiKey);
Expand Down Expand Up @@ -540,6 +574,9 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
...proposed
);
reporter && reporter.sendTelemetryEvent("extensionActivated");

// offer to install servermanager extension
await serverManager();
}

export function deactivate(): void {
Expand Down
1 change: 1 addition & 0 deletions test-fixtures/test.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"objectscript.conn": {
"active": false
},
"objectscript.ignoreInstallServerManager": true,
"intersystems.servers": {
}
}
Expand Down