mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-02-24 04:57:50 +00:00
resolve_DefaultExperienceUtility
This commit is contained in:
parent
854bd2c149
commit
a9e758f67c
@ -124,7 +124,6 @@ src/Explorer/Tables/TableEntityProcessor.ts
|
|||||||
src/Explorer/Tables/Utilities.ts
|
src/Explorer/Tables/Utilities.ts
|
||||||
src/Explorer/Tabs/ConflictsTab.ts
|
src/Explorer/Tabs/ConflictsTab.ts
|
||||||
src/Explorer/Tabs/DatabaseSettingsTab.ts
|
src/Explorer/Tabs/DatabaseSettingsTab.ts
|
||||||
src/Explorer/Tabs/DocumentsTab.test.ts
|
|
||||||
src/Explorer/Tabs/DocumentsTab.ts
|
src/Explorer/Tabs/DocumentsTab.ts
|
||||||
src/Explorer/Tabs/GraphTab.ts
|
src/Explorer/Tabs/GraphTab.ts
|
||||||
src/Explorer/Tabs/MongoDocumentsTab.ts
|
src/Explorer/Tabs/MongoDocumentsTab.ts
|
||||||
@ -145,7 +144,6 @@ src/Explorer/Tree/StoredProcedure.ts
|
|||||||
src/Explorer/Tree/TreeComponents.ts
|
src/Explorer/Tree/TreeComponents.ts
|
||||||
src/Explorer/Tree/Trigger.ts
|
src/Explorer/Tree/Trigger.ts
|
||||||
src/Explorer/Tree/UserDefinedFunction.ts
|
src/Explorer/Tree/UserDefinedFunction.ts
|
||||||
src/Explorer/WaitsForTemplateViewModel.ts
|
|
||||||
src/GitHub/GitHubClient.test.ts
|
src/GitHub/GitHubClient.test.ts
|
||||||
src/GitHub/GitHubClient.ts
|
src/GitHub/GitHubClient.ts
|
||||||
src/GitHub/GitHubConnector.ts
|
src/GitHub/GitHubConnector.ts
|
||||||
@ -159,8 +157,6 @@ src/Platform/Hosted/Authorization.ts
|
|||||||
src/Platform/Hosted/Helpers/ConnectionStringParser.test.ts
|
src/Platform/Hosted/Helpers/ConnectionStringParser.test.ts
|
||||||
src/ReactDevTools.ts
|
src/ReactDevTools.ts
|
||||||
src/Shared/Constants.ts
|
src/Shared/Constants.ts
|
||||||
src/Shared/DefaultExperienceUtility.test.ts
|
|
||||||
src/Shared/DefaultExperienceUtility.ts
|
|
||||||
src/Shared/ExplorerSettings.ts
|
src/Shared/ExplorerSettings.ts
|
||||||
src/Shared/PriceEstimateCalculator.ts
|
src/Shared/PriceEstimateCalculator.ts
|
||||||
src/Shared/StorageUtility.test.ts
|
src/Shared/StorageUtility.test.ts
|
||||||
@ -170,7 +166,6 @@ src/SparkClusterManager/ArcadiaResourceManager.ts
|
|||||||
src/SparkClusterManager/SparkClusterManager.ts
|
src/SparkClusterManager/SparkClusterManager.ts
|
||||||
src/Terminal/JupyterLabAppFactory.ts
|
src/Terminal/JupyterLabAppFactory.ts
|
||||||
src/Terminal/NotebookAppContracts.d.ts
|
src/Terminal/NotebookAppContracts.d.ts
|
||||||
src/Terminal/index.ts
|
|
||||||
src/TokenProviders/PortalTokenProvider.ts
|
src/TokenProviders/PortalTokenProvider.ts
|
||||||
src/TokenProviders/TokenProviderFactory.ts
|
src/TokenProviders/TokenProviderFactory.ts
|
||||||
src/Utils/PricingUtils.test.ts
|
src/Utils/PricingUtils.test.ts
|
||||||
|
@ -7,7 +7,7 @@ import { getErrorMessage, getErrorStack } from "../../../Common/ErrorHandlingUti
|
|||||||
import { Collection } from "../../../Contracts/ViewModels";
|
import { Collection } from "../../../Contracts/ViewModels";
|
||||||
import { useSidePanel } from "../../../hooks/useSidePanel";
|
import { useSidePanel } from "../../../hooks/useSidePanel";
|
||||||
import { useTabs } from "../../../hooks/useTabs";
|
import { useTabs } from "../../../hooks/useTabs";
|
||||||
import { DefaultExperienceUtility } from "../../../Shared/DefaultExperienceUtility";
|
import * as DefaultExperienceUtility from "../../../Shared/DefaultExperienceUtility";
|
||||||
import { Action, ActionModifiers } from "../../../Shared/Telemetry/TelemetryConstants";
|
import { Action, ActionModifiers } from "../../../Shared/Telemetry/TelemetryConstants";
|
||||||
import * as TelemetryProcessor from "../../../Shared/Telemetry/TelemetryProcessor";
|
import * as TelemetryProcessor from "../../../Shared/Telemetry/TelemetryProcessor";
|
||||||
import { userContext } from "../../../UserContext";
|
import { userContext } from "../../../UserContext";
|
||||||
|
@ -8,7 +8,7 @@ import { getErrorMessage, getErrorStack } from "../../Common/ErrorHandlingUtils"
|
|||||||
import { Collection, Database } from "../../Contracts/ViewModels";
|
import { Collection, Database } from "../../Contracts/ViewModels";
|
||||||
import { useSidePanel } from "../../hooks/useSidePanel";
|
import { useSidePanel } from "../../hooks/useSidePanel";
|
||||||
import { useTabs } from "../../hooks/useTabs";
|
import { useTabs } from "../../hooks/useTabs";
|
||||||
import { DefaultExperienceUtility } from "../../Shared/DefaultExperienceUtility";
|
import * as DefaultExperienceUtility from "../../Shared/DefaultExperienceUtility";
|
||||||
import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants";
|
import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants";
|
||||||
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
||||||
import { userContext } from "../../UserContext";
|
import { userContext } from "../../UserContext";
|
||||||
|
@ -10,7 +10,7 @@ describe("Documents tab", () => {
|
|||||||
describe("buildQuery", () => {
|
describe("buildQuery", () => {
|
||||||
it("should generate the right select query for SQL API", () => {
|
it("should generate the right select query for SQL API", () => {
|
||||||
const documentsTab = new DocumentsTab({
|
const documentsTab = new DocumentsTab({
|
||||||
partitionKey: null,
|
partitionKey: undefined,
|
||||||
documentIds: ko.observableArray<DocumentId>(),
|
documentIds: ko.observableArray<DocumentId>(),
|
||||||
tabKind: ViewModels.CollectionTabKind.Documents,
|
tabKind: ViewModels.CollectionTabKind.Documents,
|
||||||
title: "",
|
title: "",
|
||||||
@ -82,9 +82,9 @@ describe("Documents tab", () => {
|
|||||||
container: mongoExplorer,
|
container: mongoExplorer,
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be false for null or undefined collection", () => {
|
it("should be false for undefined or undefined collection", () => {
|
||||||
const documentsTab = new DocumentsTab({
|
const documentsTab = new DocumentsTab({
|
||||||
partitionKey: null,
|
partitionKey: undefined,
|
||||||
documentIds: ko.observableArray<DocumentId>(),
|
documentIds: ko.observableArray<DocumentId>(),
|
||||||
tabKind: ViewModels.CollectionTabKind.Documents,
|
tabKind: ViewModels.CollectionTabKind.Documents,
|
||||||
title: "",
|
title: "",
|
||||||
@ -94,10 +94,10 @@ describe("Documents tab", () => {
|
|||||||
expect(documentsTab.showPartitionKey).toBe(false);
|
expect(documentsTab.showPartitionKey).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be false for null or undefined partitionKey", () => {
|
it("should be false for undefined or undefined partitionKey", () => {
|
||||||
const documentsTab = new DocumentsTab({
|
const documentsTab = new DocumentsTab({
|
||||||
collection: collectionWithoutPartitionKey,
|
collection: collectionWithoutPartitionKey,
|
||||||
partitionKey: null,
|
partitionKey: undefined,
|
||||||
documentIds: ko.observableArray<DocumentId>(),
|
documentIds: ko.observableArray<DocumentId>(),
|
||||||
tabKind: ViewModels.CollectionTabKind.Documents,
|
tabKind: ViewModels.CollectionTabKind.Documents,
|
||||||
title: "",
|
title: "",
|
||||||
@ -110,7 +110,7 @@ describe("Documents tab", () => {
|
|||||||
it("should be true for non-Mongo accounts with system partitionKey", () => {
|
it("should be true for non-Mongo accounts with system partitionKey", () => {
|
||||||
const documentsTab = new DocumentsTab({
|
const documentsTab = new DocumentsTab({
|
||||||
collection: collectionWithSystemPartitionKey,
|
collection: collectionWithSystemPartitionKey,
|
||||||
partitionKey: null,
|
partitionKey: undefined,
|
||||||
documentIds: ko.observableArray<DocumentId>(),
|
documentIds: ko.observableArray<DocumentId>(),
|
||||||
tabKind: ViewModels.CollectionTabKind.Documents,
|
tabKind: ViewModels.CollectionTabKind.Documents,
|
||||||
title: "",
|
title: "",
|
||||||
@ -126,7 +126,7 @@ describe("Documents tab", () => {
|
|||||||
});
|
});
|
||||||
const documentsTab = new DocumentsTab({
|
const documentsTab = new DocumentsTab({
|
||||||
collection: mongoCollectionWithSystemPartitionKey,
|
collection: mongoCollectionWithSystemPartitionKey,
|
||||||
partitionKey: null,
|
partitionKey: undefined,
|
||||||
documentIds: ko.observableArray<DocumentId>(),
|
documentIds: ko.observableArray<DocumentId>(),
|
||||||
tabKind: ViewModels.CollectionTabKind.Documents,
|
tabKind: ViewModels.CollectionTabKind.Documents,
|
||||||
title: "",
|
title: "",
|
||||||
@ -139,7 +139,7 @@ describe("Documents tab", () => {
|
|||||||
it("should be true for non-system partitionKey", () => {
|
it("should be true for non-system partitionKey", () => {
|
||||||
const documentsTab = new DocumentsTab({
|
const documentsTab = new DocumentsTab({
|
||||||
collection: collectionWithNonSystemPartitionKey,
|
collection: collectionWithNonSystemPartitionKey,
|
||||||
partitionKey: null,
|
partitionKey: undefined,
|
||||||
documentIds: ko.observableArray<DocumentId>(),
|
documentIds: ko.observableArray<DocumentId>(),
|
||||||
tabKind: ViewModels.CollectionTabKind.Documents,
|
tabKind: ViewModels.CollectionTabKind.Documents,
|
||||||
title: "",
|
title: "",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import * as ko from "knockout";
|
import * as ko from "knockout";
|
||||||
import * as ViewModels from "../Contracts/ViewModels";
|
|
||||||
import * as Constants from "../Common/Constants";
|
import * as Constants from "../Common/Constants";
|
||||||
|
import * as ViewModels from "../Contracts/ViewModels";
|
||||||
|
|
||||||
export abstract class WaitsForTemplateViewModel implements ViewModels.WaitsForTemplate {
|
export abstract class WaitsForTemplateViewModel implements ViewModels.WaitsForTemplate {
|
||||||
public isTemplateReady: ko.Observable<boolean>;
|
public isTemplateReady: ko.Observable<boolean>;
|
||||||
@ -14,11 +14,11 @@ export abstract class WaitsForTemplateViewModel implements ViewModels.WaitsForTe
|
|||||||
callback(value);
|
callback(value);
|
||||||
});
|
});
|
||||||
|
|
||||||
document.addEventListener("keydown", function (e: KeyboardEvent) {
|
document.addEventListener("keydown", (e: KeyboardEvent) => {
|
||||||
// To trap keyboard focus in AddCollection pane
|
// To trap keyboard focus in AddCollection pane
|
||||||
let firstFocusableElement = document.getElementById("closeBtnAddCollection");
|
const firstFocusableElement = document.getElementById("closeBtnAddCollection");
|
||||||
let lastFocusableElement = document.getElementById("submitBtnAddCollection");
|
const lastFocusableElement = document.getElementById("submitBtnAddCollection");
|
||||||
var isTabPressed = e.keyCode === Constants.KeyCodes.Tab;
|
const isTabPressed = e.keyCode === Constants.KeyCodes.Tab;
|
||||||
if (isTabPressed) {
|
if (isTabPressed) {
|
||||||
if (e.shiftKey) {
|
if (e.shiftKey) {
|
||||||
/* shift + tab */ if (document.activeElement === firstFocusableElement) {
|
/* shift + tab */ if (document.activeElement === firstFocusableElement) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
import * as ko from "knockout";
|
||||||
import "../less/index.less";
|
import "../less/index.less";
|
||||||
import "./Libs/jquery";
|
import "./Libs/jquery";
|
||||||
|
|
||||||
import * as ko from "knockout";
|
|
||||||
|
|
||||||
class Index {
|
class Index {
|
||||||
public navigationSelection: ko.Observable<string>;
|
public navigationSelection: ko.Observable<string>;
|
||||||
@ -19,5 +19,5 @@ class Index {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var index = new Index();
|
const index = new Index();
|
||||||
ko.applyBindings(index);
|
ko.applyBindings(index);
|
||||||
|
@ -1,31 +1,31 @@
|
|||||||
import * as Constants from "../../Common/Constants";
|
import * as Constants from "../../Common/Constants";
|
||||||
import { configContext } from "../../ConfigContext";
|
import { configContext } from "../../ConfigContext";
|
||||||
import * as DataModels from "../../Contracts/DataModels";
|
import * as DataModels from "../../Contracts/DataModels";
|
||||||
import { DefaultExperienceUtility } from "../../Shared/DefaultExperienceUtility";
|
import * as DefaultExperienceUtility from "../../Shared/DefaultExperienceUtility";
|
||||||
import { userContext } from "../../UserContext";
|
import { userContext } from "../../UserContext";
|
||||||
|
|
||||||
export default class AuthHeadersUtil {
|
export const _generateResourceUrl = (): string => {
|
||||||
public static async generateEncryptedToken(readOnly: boolean = false): Promise<DataModels.GenerateTokenResponse> {
|
const { databaseAccount, resourceGroup, subscriptionId } = userContext;
|
||||||
const url = configContext.BACKEND_ENDPOINT + "/api/tokens/generateToken" + AuthHeadersUtil._generateResourceUrl();
|
const apiKind: DataModels.ApiKind = DefaultExperienceUtility.getApiKindFromDefaultExperience(userContext.apiType);
|
||||||
const headers: any = { authorization: userContext.authorizationToken };
|
const accountEndpoint = databaseAccount?.properties?.documentEndpoint || "";
|
||||||
headers[Constants.HttpHeaders.getReadOnlyKey] = readOnly;
|
const sid = subscriptionId || "";
|
||||||
|
const rg = resourceGroup || "";
|
||||||
const response = await fetch(url, { method: "POST", headers });
|
const dba = databaseAccount?.name || "";
|
||||||
const result = await response.json();
|
const resourceUrl = encodeURIComponent(accountEndpoint);
|
||||||
// This API has a quirk where the response must be parsed to JSON twice
|
const rid = "";
|
||||||
return JSON.parse(result);
|
const rtype = "";
|
||||||
}
|
return `?resourceUrl=${resourceUrl}&rid=${rid}&rtype=${rtype}&sid=${sid}&rg=${rg}&dba=${dba}&api=${apiKind}`;
|
||||||
|
|
||||||
private static _generateResourceUrl(): string {
|
|
||||||
const { databaseAccount, resourceGroup, subscriptionId } = userContext;
|
|
||||||
const apiKind: DataModels.ApiKind = DefaultExperienceUtility.getApiKindFromDefaultExperience(userContext.apiType);
|
|
||||||
const accountEndpoint = databaseAccount?.properties?.documentEndpoint || "";
|
|
||||||
const sid = subscriptionId || "";
|
|
||||||
const rg = resourceGroup || "";
|
|
||||||
const dba = databaseAccount?.name || "";
|
|
||||||
const resourceUrl = encodeURIComponent(accountEndpoint);
|
|
||||||
const rid = "";
|
|
||||||
const rtype = "";
|
|
||||||
return `?resourceUrl=${resourceUrl}&rid=${rid}&rtype=${rtype}&sid=${sid}&rg=${rg}&dba=${dba}&api=${apiKind}`;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const generateEncryptedToken = async (readOnly = false): Promise<DataModels.GenerateTokenResponse> => {
|
||||||
|
const url = configContext.BACKEND_ENDPOINT + "/api/tokens/generateToken" + _generateResourceUrl();
|
||||||
|
const headers: any = { authorization: userContext.authorizationToken };
|
||||||
|
headers[Constants.HttpHeaders.getReadOnlyKey] = readOnly;
|
||||||
|
|
||||||
|
const response = await fetch(url, { method: "POST", headers });
|
||||||
|
const result = await response.json();
|
||||||
|
// This API has a quirk where the response must be parsed to JSON twice
|
||||||
|
return JSON.parse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { AccountKind, CapabilityNames } from "../../Common/Constants";
|
import { AccountKind, CapabilityNames } from "../../Common/Constants";
|
||||||
import { AccessInputMetadata, ApiKind } from "../../Contracts/DataModels";
|
import { AccessInputMetadata, ApiKind } from "../../Contracts/DataModels";
|
||||||
import { DefaultExperienceUtility } from "../../Shared/DefaultExperienceUtility";
|
import * as DefaultExperienceUtility from "../../Shared/DefaultExperienceUtility";
|
||||||
import { userContext } from "../../UserContext";
|
import { userContext } from "../../UserContext";
|
||||||
|
|
||||||
export function getDatabaseAccountPropertiesFromMetadata(metadata: AccessInputMetadata): unknown {
|
export function getDatabaseAccountPropertiesFromMetadata(metadata: AccessInputMetadata): unknown {
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import * as DataModels from "../Contracts/DataModels";
|
import * as DataModels from "../Contracts/DataModels";
|
||||||
import { userContext } from "../UserContext";
|
import { userContext } from "../UserContext";
|
||||||
import { DefaultExperienceUtility } from "./DefaultExperienceUtility";
|
import * as DefaultExperienceUtility from "./DefaultExperienceUtility";
|
||||||
|
|
||||||
describe("Default Experience Utility", () => {
|
describe("Default Experience Utility", () => {
|
||||||
describe("getDefaultExperienceFromApiKind()", () => {
|
describe("getDefaultExperienceFromApiKind()", () => {
|
||||||
function runScenario(apiKind: number, expectedExperience: typeof userContext.apiType): void {
|
const runScenario = (apiKind: number, expectedExperience: typeof userContext.apiType): void => {
|
||||||
const resolvedExperience = DefaultExperienceUtility.getDefaultExperienceFromApiKind(apiKind);
|
const resolvedExperience = DefaultExperienceUtility.getDefaultExperienceFromApiKind(apiKind);
|
||||||
expect(resolvedExperience).toEqual(expectedExperience);
|
expect(resolvedExperience).toEqual(expectedExperience);
|
||||||
}
|
}
|
||||||
@ -35,7 +35,7 @@ describe("Default Experience Utility", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("getApiKindFromDefaultExperience()", () => {
|
describe("getApiKindFromDefaultExperience()", () => {
|
||||||
function runScenario(defaultExperience: typeof userContext.apiType, expectedApiKind: number): void {
|
const runScenario = (defaultExperience: typeof userContext.apiType, expectedApiKind: number): void => {
|
||||||
const resolvedApiKind = DefaultExperienceUtility.getApiKindFromDefaultExperience(defaultExperience);
|
const resolvedApiKind = DefaultExperienceUtility.getApiKindFromDefaultExperience(defaultExperience);
|
||||||
expect(resolvedApiKind).toEqual(expectedApiKind);
|
expect(resolvedApiKind).toEqual(expectedApiKind);
|
||||||
}
|
}
|
||||||
@ -60,8 +60,8 @@ describe("Default Experience Utility", () => {
|
|||||||
it("should return Graph", () => runScenario("Gremlin", DataModels.ApiKind.Graph));
|
it("should return Graph", () => runScenario("Gremlin", DataModels.ApiKind.Graph));
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("On null", () => {
|
describe("On undefined", () => {
|
||||||
it("should return SQL", () => runScenario(null, DataModels.ApiKind.SQL));
|
it("should return SQL", () => runScenario(undefined, DataModels.ApiKind.SQL));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,47 +1,45 @@
|
|||||||
import * as DataModels from "../Contracts/DataModels";
|
import * as DataModels from "../Contracts/DataModels";
|
||||||
import { userContext } from "../UserContext";
|
import { userContext } from "../UserContext";
|
||||||
|
|
||||||
export class DefaultExperienceUtility {
|
export const getApiKindFromDefaultExperience = (defaultExperience: typeof userContext.apiType): DataModels.ApiKind => {
|
||||||
public static getApiKindFromDefaultExperience(defaultExperience: typeof userContext.apiType): DataModels.ApiKind {
|
if (!defaultExperience) {
|
||||||
if (!defaultExperience) {
|
return DataModels.ApiKind.SQL;
|
||||||
return DataModels.ApiKind.SQL;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (defaultExperience) {
|
|
||||||
case "SQL":
|
|
||||||
return DataModels.ApiKind.SQL;
|
|
||||||
case "Mongo":
|
|
||||||
return DataModels.ApiKind.MongoDB;
|
|
||||||
case "Tables":
|
|
||||||
return DataModels.ApiKind.Table;
|
|
||||||
case "Cassandra":
|
|
||||||
return DataModels.ApiKind.Cassandra;
|
|
||||||
case "Gremlin":
|
|
||||||
return DataModels.ApiKind.Graph;
|
|
||||||
default:
|
|
||||||
return DataModels.ApiKind.SQL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static getDefaultExperienceFromApiKind(apiKind: DataModels.ApiKind): typeof userContext.apiType {
|
switch (defaultExperience) {
|
||||||
if (apiKind == null) {
|
case "SQL":
|
||||||
return "SQL";
|
return DataModels.ApiKind.SQL;
|
||||||
}
|
case "Mongo":
|
||||||
|
return DataModels.ApiKind.MongoDB;
|
||||||
switch (apiKind) {
|
case "Tables":
|
||||||
case DataModels.ApiKind.SQL:
|
return DataModels.ApiKind.Table;
|
||||||
return "SQL";
|
case "Cassandra":
|
||||||
case DataModels.ApiKind.MongoDB:
|
return DataModels.ApiKind.Cassandra;
|
||||||
case DataModels.ApiKind.MongoDBCompute:
|
case "Gremlin":
|
||||||
return "Mongo";
|
return DataModels.ApiKind.Graph;
|
||||||
case DataModels.ApiKind.Table:
|
default:
|
||||||
return "Tables";
|
return DataModels.ApiKind.SQL;
|
||||||
case DataModels.ApiKind.Cassandra:
|
}
|
||||||
return "Cassandra";
|
}
|
||||||
case DataModels.ApiKind.Graph:
|
|
||||||
return "Gremlin";
|
export const getDefaultExperienceFromApiKind = (apiKind: DataModels.ApiKind): typeof userContext.apiType => {
|
||||||
default:
|
if (apiKind === undefined) {
|
||||||
return "SQL";
|
return "SQL";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch (apiKind) {
|
||||||
|
case DataModels.ApiKind.SQL:
|
||||||
|
return "SQL";
|
||||||
|
case DataModels.ApiKind.MongoDB:
|
||||||
|
case DataModels.ApiKind.MongoDBCompute:
|
||||||
|
return "Mongo";
|
||||||
|
case DataModels.ApiKind.Table:
|
||||||
|
return "Tables";
|
||||||
|
case DataModels.ApiKind.Cassandra:
|
||||||
|
return "Cassandra";
|
||||||
|
case DataModels.ApiKind.Graph:
|
||||||
|
return "Gremlin";
|
||||||
|
default:
|
||||||
|
return "SQL";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,37 +5,35 @@ import { ServerConnection, TerminalManager } from "@jupyterlab/services";
|
|||||||
import { Terminal } from "@jupyterlab/terminal";
|
import { Terminal } from "@jupyterlab/terminal";
|
||||||
import { Panel, Widget } from "@phosphor/widgets";
|
import { Panel, Widget } from "@phosphor/widgets";
|
||||||
|
|
||||||
export class JupyterLabAppFactory {
|
export const createTerminalApp = async (serverSettings: ServerConnection.ISettings) => {
|
||||||
public static async createTerminalApp(serverSettings: ServerConnection.ISettings) {
|
const manager = new TerminalManager({
|
||||||
const manager = new TerminalManager({
|
serverSettings: serverSettings,
|
||||||
serverSettings: serverSettings,
|
});
|
||||||
});
|
const session = await manager.startNew();
|
||||||
const session = await manager.startNew();
|
const term = new Terminal(session, { theme: "dark", shutdownOnClose: true });
|
||||||
const term = new Terminal(session, { theme: "dark", shutdownOnClose: true });
|
|
||||||
|
|
||||||
if (!term) {
|
if (!term) {
|
||||||
console.error("Failed starting terminal");
|
console.error("Failed starting terminal");
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
term.title.closable = false;
|
|
||||||
term.addClass("terminalWidget");
|
|
||||||
|
|
||||||
let panel = new Panel();
|
|
||||||
panel.addWidget(term as any);
|
|
||||||
panel.id = "main";
|
|
||||||
|
|
||||||
// Attach the widget to the dom.
|
|
||||||
Widget.attach(panel, document.body);
|
|
||||||
|
|
||||||
// Handle resize events.
|
|
||||||
window.addEventListener("resize", () => {
|
|
||||||
panel.update();
|
|
||||||
});
|
|
||||||
|
|
||||||
// Dispose terminal when unloading.
|
|
||||||
window.addEventListener("unload", () => {
|
|
||||||
panel.dispose();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
term.title.closable = false;
|
||||||
|
term.addClass("terminalWidget");
|
||||||
|
|
||||||
|
const panel = new Panel();
|
||||||
|
panel.addWidget(term as any);
|
||||||
|
panel.id = "main";
|
||||||
|
|
||||||
|
// Attach the widget to the dom.
|
||||||
|
Widget.attach(panel, document.body);
|
||||||
|
|
||||||
|
// Handle resize events.
|
||||||
|
window.addEventListener("resize", () => {
|
||||||
|
panel.update();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Dispose terminal when unloading.
|
||||||
|
window.addEventListener("unload", () => {
|
||||||
|
panel.dispose();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import { Action } from "../Shared/Telemetry/TelemetryConstants";
|
|||||||
import * as TelemetryProcessor from "../Shared/Telemetry/TelemetryProcessor";
|
import * as TelemetryProcessor from "../Shared/Telemetry/TelemetryProcessor";
|
||||||
import { updateUserContext } from "../UserContext";
|
import { updateUserContext } from "../UserContext";
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
import { JupyterLabAppFactory } from "./JupyterLabAppFactory";
|
import { createTerminalApp } from "./JupyterLabAppFactory";
|
||||||
import { TerminalProps } from "./TerminalProps";
|
import { TerminalProps } from "./TerminalProps";
|
||||||
|
|
||||||
const createServerSettings = (props: TerminalProps): ServerConnection.ISettings => {
|
const createServerSettings = (props: TerminalProps): ServerConnection.ISettings => {
|
||||||
@ -54,7 +54,7 @@ const initTerminal = async (props: TerminalProps) => {
|
|||||||
const startTime = TelemetryProcessor.traceStart(Action.OpenTerminal, data);
|
const startTime = TelemetryProcessor.traceStart(Action.OpenTerminal, data);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await JupyterLabAppFactory.createTerminalApp(serverSettings);
|
await createTerminalApp(serverSettings);
|
||||||
TelemetryProcessor.traceSuccess(Action.OpenTerminal, data, startTime);
|
TelemetryProcessor.traceSuccess(Action.OpenTerminal, data, startTime);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
TelemetryProcessor.traceFailure(Action.OpenTerminal, data, startTime);
|
TelemetryProcessor.traceFailure(Action.OpenTerminal, data, startTime);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { GenerateTokenResponse } from "../Contracts/DataModels";
|
import { GenerateTokenResponse } from "../Contracts/DataModels";
|
||||||
import AuthHeadersUtil from "../Platform/Hosted/Authorization";
|
import * as AuthHeadersUtil from "../Platform/Hosted/Authorization";
|
||||||
|
|
||||||
export function useFullScreenURLs(): GenerateTokenResponse | undefined {
|
export function useFullScreenURLs(): GenerateTokenResponse | undefined {
|
||||||
const [state, setState] = useState<GenerateTokenResponse>();
|
const [state, setState] = useState<GenerateTokenResponse>();
|
||||||
|
@ -16,17 +16,17 @@ import {
|
|||||||
ConnectionString,
|
ConnectionString,
|
||||||
EncryptedToken,
|
EncryptedToken,
|
||||||
HostedExplorerChildFrame,
|
HostedExplorerChildFrame,
|
||||||
ResourceToken,
|
ResourceToken
|
||||||
} from "../HostedExplorerChildFrame";
|
} from "../HostedExplorerChildFrame";
|
||||||
import { emulatorAccount } from "../Platform/Emulator/emulatorAccount";
|
import { emulatorAccount } from "../Platform/Emulator/emulatorAccount";
|
||||||
import { extractFeatures } from "../Platform/Hosted/extractFeatures";
|
import { extractFeatures } from "../Platform/Hosted/extractFeatures";
|
||||||
import { parseResourceTokenConnectionString } from "../Platform/Hosted/Helpers/ResourceTokenUtils";
|
import { parseResourceTokenConnectionString } from "../Platform/Hosted/Helpers/ResourceTokenUtils";
|
||||||
import {
|
import {
|
||||||
getDatabaseAccountKindFromExperience,
|
getDatabaseAccountKindFromExperience,
|
||||||
getDatabaseAccountPropertiesFromMetadata,
|
getDatabaseAccountPropertiesFromMetadata
|
||||||
} from "../Platform/Hosted/HostedUtils";
|
} from "../Platform/Hosted/HostedUtils";
|
||||||
import { CollectionCreation } from "../Shared/Constants";
|
import { CollectionCreation } from "../Shared/Constants";
|
||||||
import { DefaultExperienceUtility } from "../Shared/DefaultExperienceUtility";
|
import * as DefaultExperienceUtility from "../Shared/DefaultExperienceUtility";
|
||||||
import { PortalEnv, updateUserContext, userContext } from "../UserContext";
|
import { PortalEnv, updateUserContext, userContext } from "../UserContext";
|
||||||
import { listKeys } from "../Utils/arm/generatedClients/cosmos/databaseAccounts";
|
import { listKeys } from "../Utils/arm/generatedClients/cosmos/databaseAccounts";
|
||||||
import { DatabaseAccountListKeysResult } from "../Utils/arm/generatedClients/cosmos/types";
|
import { DatabaseAccountListKeysResult } from "../Utils/arm/generatedClients/cosmos/types";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user