Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
23 changes: 5 additions & 18 deletions src/commands/serverActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
} from "../utils";
import { mainCommandMenu, mainSourceControlMenu } from "./studio";
import { AtelierAPI } from "../api";
import { getCSPToken } from "../utils/getCSPToken";
import { isfsConfig } from "../utils/FileProviderUtil";

type ServerAction = { detail: string; id: string; label: string; rawLink?: string };
Expand Down Expand Up @@ -224,11 +223,11 @@ export async function serverActions(): Promise<void> {
}
switch (action.id) {
case "openPortal": {
vscode.env.openExternal(vscode.Uri.parse(`${serverUrl}${portalPath}`));
vscode.commands.executeCommand("workbench.action.browser.open", `${serverUrl}${portalPath}`);
break;
}
case "openClassReference": {
vscode.env.openExternal(vscode.Uri.parse(`${serverUrl}${classRef}`));
vscode.commands.executeCommand("workbench.action.browser.open", `${serverUrl}${classRef}`);
break;
}
case "openStudioAddin": {
Expand All @@ -248,15 +247,12 @@ export async function serverActions(): Promise<void> {
});
if (addin) {
sendStudioAddinTelemetryEvent(addin.label);
const token = await getCSPToken(api, addin.id);
let params = `Namespace=${nsEncoded}`;
params += `&User=${encodeURIComponent(username)}`;
if (project !== "") {
if (project != "") {
params += `&Project=${encodeURIComponent(project)}`;
}
params += `&CSPCHD=${token}`;
params += "&CSPSHARE=1";
vscode.env.openExternal(vscode.Uri.parse(`${serverUrl}${addin.id}?${params}`));
vscode.commands.executeCommand("workbench.action.browser.open", `${serverUrl}${addin.id}?${params}`);
}
}
break;
Expand All @@ -278,16 +274,7 @@ export async function serverActions(): Promise<void> {
break;
}
default: {
let url = vscode.Uri.parse(action.detail);
if (action.rawLink?.startsWith("${serverUrl}")) {
const token = await getCSPToken(api, url.path);
if (token.length > 0) {
url = url.with({
query: url.query.length ? `${url.query}&CSPCHD=${token}` : `CSPCHD=${token}`,
});
}
}
vscode.env.openExternal(url);
vscode.commands.executeCommand("workbench.action.browser.open", action.detail);
}
}
});
Expand Down
17 changes: 7 additions & 10 deletions src/commands/studio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,6 @@ export class StudioActions {
.then((answer) => (answer === "Yes" ? "1" : answer === "No" ? "0" : "2"));
case 2: {
// Run a CSP page/Template. The Target is the full path of CSP page/template on the connected server

// Do this ourself instead of using our new getCSPToken wrapper function, because that function reuses tokens which causes issues with
// webview when server is 2020.1.1 or greater, as session cookie scope is typically Strict, meaning that the webview
// cannot store the cookie. Consequence is web sessions may build up (they get a 900 second timeout)
const cspchd = await this.api
.actionQuery("select %Atelier_v1_Utils.General_GetCSPToken(?) token", [target])
.then((data) => data.result.content[0].token)
Expand All @@ -160,10 +156,8 @@ export class StudioActions {
if (message.result && message.result === "done") {
answer = "1";
panel.dispose();
} else if (typeof message.href == "string") {
const linkUri = vscode.Uri.parse(message.href);
// Only open http(s) links
if (/^https?$/.test(linkUri.scheme)) vscode.env.openExternal(linkUri);
} else if (typeof message.href == "string" && /^https?:\/\//.test(message.href)) {
vscode.commands.executeCommand("workbench.action.browser.open", message.href);
}
});
panel.onDidDispose(() => resolve(answer));
Expand Down Expand Up @@ -207,8 +201,11 @@ export class StudioActions {
}
case 3: {
// Run an EXE on the client.
if (/^(ht|f)tps?:\/\//i.test(target)) {
// Allow target that is a URL to be opened in an external browser
if (/^https?:\/\//.test(target)) {
// Allow https URLs to be opened in the Integrated Browser
vscode.commands.executeCommand("workbench.action.browser.open", target);
} else if (/^ftps?:\/\//.test(target)) {
// ftp links aren't supported by the Integrated Browser
vscode.env.openExternal(vscode.Uri.parse(target));
} else {
// Anything else is not supported
Expand Down
16 changes: 8 additions & 8 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -644,8 +644,9 @@ function proposedApiPrompt(active: boolean, added?: readonly vscode.WorkspaceFol
.then(async (action) => {
switch (action) {
case "Yes":
vscode.env.openExternal(
vscode.Uri.parse("https://github.com/intersystems-community/vscode-objectscript#enable-proposed-apis")
vscode.commands.executeCommand(
"workbench.action.browser.open",
"https://github.com/intersystems-community/vscode-objectscript#enable-proposed-apis"
);
break;
case "Never":
Expand Down Expand Up @@ -1784,12 +1785,11 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
.catch(() => {
// Swallow errors
})) ?? `/csp/${api.ns}`;
vscode.env.openExternal(
vscode.Uri.parse(
`${api.config.https ? "https" : "http"}://${api.config.host}:${api.config.port}${
api.config.pathPrefix
}${app}${path}`
)
vscode.commands.executeCommand(
"workbench.action.browser.open",
`${api.config.https ? "https" : "http"}://${api.config.host}:${api.config.port}${
api.config.pathPrefix
}${app}${path}`
);
}
}
Expand Down
28 changes: 0 additions & 28 deletions src/utils/getCSPToken.ts

This file was deleted.