From 659d5a667741faf616ecc0233ca9790af3b6ed88 Mon Sep 17 00:00:00 2001 From: Srinath Narayanan Date: Thu, 8 Jul 2021 03:22:13 -0700 Subject: [PATCH] Added postgreSQL terminal --- src/Contracts/ViewModels.ts | 3 ++- src/Explorer/Explorer.tsx | 4 ++++ .../CommandBarComponentButtonFactory.tsx | 14 ++++++++++++++ src/Explorer/Tabs/TerminalTab.tsx | 4 ++++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/Contracts/ViewModels.ts b/src/Contracts/ViewModels.ts index 210d34075..7eb64bab1 100644 --- a/src/Contracts/ViewModels.ts +++ b/src/Contracts/ViewModels.ts @@ -3,7 +3,7 @@ import { Resource, StoredProcedureDefinition, TriggerDefinition, - UserDefinedFunctionDefinition, + UserDefinedFunctionDefinition } from "@azure/cosmos"; import Explorer from "../Explorer/Explorer"; import { ConsoleData } from "../Explorer/Menus/NotificationConsole/ConsoleData"; @@ -370,6 +370,7 @@ export enum TerminalKind { Default = 0, Mongo = 1, Cassandra = 2, + PostgreSQL = 3 } export interface DataExplorerInputsFrame { diff --git a/src/Explorer/Explorer.tsx b/src/Explorer/Explorer.tsx index 27c0e9cb2..2e6827f71 100644 --- a/src/Explorer/Explorer.tsx +++ b/src/Explorer/Explorer.tsx @@ -1164,6 +1164,10 @@ export default class Explorer { title = "Cassandra Shell"; break; + case ViewModels.TerminalKind.PostgreSQL: + title = "PostgreSQL Shell"; + break; + default: throw new Error("Terminal kind: ${kind} not supported"); } diff --git a/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.tsx b/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.tsx index 35f2ee82d..62f86ccbb 100644 --- a/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.tsx +++ b/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.tsx @@ -72,6 +72,7 @@ export function createStaticCommandBarButtons( } buttons.push(createOpenTerminalButton(container)); + buttons.push(createOpenPostgreSQLTerminalButton(container)); buttons.push(createNotebookWorkspaceResetButton(container)); if ( @@ -468,6 +469,19 @@ function createOpenTerminalButton(container: Explorer): CommandButtonComponentPr }; } +function createOpenPostgreSQLTerminalButton(container: Explorer): CommandButtonComponentProps { + const label = "Open PostgreSQL Terminal"; + return { + iconSrc: CosmosTerminalIcon, + iconAlt: label, + onCommandClick: () => container.openNotebookTerminal(ViewModels.TerminalKind.PostgreSQL), + commandButtonLabel: label, + hasPopup: false, + disabled: false, + ariaLabel: label, + }; +} + function createOpenMongoTerminalButton(container: Explorer): CommandButtonComponentProps { const label = "Open Mongo Shell"; const tooltip = diff --git a/src/Explorer/Tabs/TerminalTab.tsx b/src/Explorer/Tabs/TerminalTab.tsx index c0c7bf8c6..a7207a22c 100644 --- a/src/Explorer/Tabs/TerminalTab.tsx +++ b/src/Explorer/Tabs/TerminalTab.tsx @@ -91,6 +91,10 @@ export default class TerminalTab extends TabsBase { endpointSuffix = "cassandra"; break; + case ViewModels.TerminalKind.PostgreSQL: + endpointSuffix = "postgreSQL"; + break; + default: throw new Error(`Terminal kind: ${options.kind} not supported`); }