This reverts commit 83b13de685
.
This commit is contained in:
parent
728eeefa17
commit
c4257bf4a9
|
@ -48,31 +48,16 @@ export function sendCachedDataMessage<TResponseDataModel>(
|
|||
|
||||
export function sendMessage(data: any): void {
|
||||
if (canSendMessage()) {
|
||||
const dataExplorerWindow = getDataExplorerWindow();
|
||||
if (dataExplorerWindow) {
|
||||
dataExplorerWindow.parent.postMessage(
|
||||
{
|
||||
signature: "pcIframe",
|
||||
data: data
|
||||
},
|
||||
dataExplorerWindow.document.referrer
|
||||
);
|
||||
}
|
||||
window.parent.postMessage(
|
||||
{
|
||||
signature: "pcIframe",
|
||||
data: data
|
||||
},
|
||||
window.document.referrer
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const getDataExplorerWindow = (): Window => {
|
||||
// Traverse up the window to find a window with `dataExplorerPlatform` property
|
||||
let dataExplorerWindow: Window = window;
|
||||
// TODO: Need to `any` here since the window imports Explorer which can't be in strict mode yet
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
while (!(dataExplorerWindow as any).dataExplorerPlatform && dataExplorerWindow.parent) {
|
||||
dataExplorerWindow = dataExplorerWindow.parent;
|
||||
}
|
||||
|
||||
return dataExplorerWindow;
|
||||
};
|
||||
|
||||
export function canSendMessage(): boolean {
|
||||
return window.parent !== window;
|
||||
}
|
||||
|
|
|
@ -70,8 +70,7 @@ export enum Action {
|
|||
NotebooksGitHubManualRepoAdd,
|
||||
NotebooksGitHubManageRepo,
|
||||
NotebooksGitHubCommit,
|
||||
NotebooksGitHubDisconnect,
|
||||
OpenTerminal
|
||||
NotebooksGitHubDisconnect
|
||||
}
|
||||
|
||||
export const ActionModifiers = {
|
||||
|
|
|
@ -4,8 +4,6 @@ import "@jupyterlab/terminal/style/index.css";
|
|||
import "./index.css";
|
||||
import { ServerConnection } from "@jupyterlab/services";
|
||||
import { JupyterLabAppFactory } from "./JupyterLabAppFactory";
|
||||
import { Action } from "../Shared/Telemetry/TelemetryConstants";
|
||||
import * as TelemetryProcessor from "../Shared/Telemetry/TelemetryProcessor";
|
||||
|
||||
const getUrlVars = (): { [key: string]: string } => {
|
||||
const vars: { [key: string]: string } = {};
|
||||
|
@ -16,7 +14,10 @@ const getUrlVars = (): { [key: string]: string } => {
|
|||
return vars;
|
||||
};
|
||||
|
||||
const createServerSettings = (urlVars: { [key: string]: string }): ServerConnection.ISettings => {
|
||||
const main = (): void => {
|
||||
const urlVars = getUrlVars();
|
||||
console.log("URL parameters", urlVars);
|
||||
|
||||
let body: BodyInit;
|
||||
if (urlVars.hasOwnProperty("terminalEndpoint")) {
|
||||
body = JSON.stringify({
|
||||
|
@ -38,29 +39,14 @@ const createServerSettings = (urlVars: { [key: string]: string }): ServerConnect
|
|||
fetch: window.parent.fetch
|
||||
};
|
||||
}
|
||||
const serverSettings = ServerConnection.makeSettings(options);
|
||||
|
||||
return ServerConnection.makeSettings(options);
|
||||
};
|
||||
|
||||
const main = async (): Promise<void> => {
|
||||
const urlVars = getUrlVars();
|
||||
const serverSettings = createServerSettings(urlVars);
|
||||
|
||||
const startTime = TelemetryProcessor.traceStart(Action.OpenTerminal, {
|
||||
baseUrl: serverSettings.baseUrl
|
||||
});
|
||||
|
||||
try {
|
||||
if (urlVars.hasOwnProperty("terminal")) {
|
||||
await JupyterLabAppFactory.createTerminalApp(serverSettings);
|
||||
} else {
|
||||
throw new Error("Only terminal is supported");
|
||||
}
|
||||
|
||||
TelemetryProcessor.traceSuccess(Action.OpenTerminal, startTime);
|
||||
} catch (error) {
|
||||
TelemetryProcessor.traceFailure(Action.OpenTerminal, startTime);
|
||||
if (urlVars.hasOwnProperty("terminal")) {
|
||||
JupyterLabAppFactory.createTerminalApp(serverSettings);
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Error("Only terminal is supported");
|
||||
};
|
||||
|
||||
window.addEventListener("load", main);
|
||||
|
|
Loading…
Reference in New Issue