From bd334a118a8dd30cbcfd38cb1d7d2c488ed4e8a6 Mon Sep 17 00:00:00 2001 From: Laurent Nguyen Date: Wed, 17 Jul 2024 17:30:12 +0200 Subject: [PATCH 1/3] Prevent tabsManagerContainer width to grow beyond parent's width (#1911) --- less/documentDB.less | 1 + 1 file changed, 1 insertion(+) diff --git a/less/documentDB.less b/less/documentDB.less index bf5f87e3e..d9c0a61cb 100644 --- a/less/documentDB.less +++ b/less/documentDB.less @@ -2369,6 +2369,7 @@ a:link { display: flex; flex-direction: column; min-height: 300px; + min-width: 0; // This prevents it to grow past the parent's width if its content is too wide } .tabs { From e67c3f67742ea4aa543e46f3c802a91047bfd1a1 Mon Sep 17 00:00:00 2001 From: sindhuba <122321535+sindhuba@users.noreply.github.com> Date: Wed, 17 Jul 2024 10:12:36 -0700 Subject: [PATCH 2/3] Revert RBAC feature flag behavior (#1910) * Fix API endpoint for CassandraProxy query API * activate Mongo Proxy and Cassandra Proxy in Prod * Add CP Prod endpoint * Run npm format and tests * Revert code * fix bug that blocked local mongo proxy and cassandra proxy development * Add prod endpoint * fix pr check tests * Remove prod * Remove prod endpoint * Remove dev endpoint * Support data plane RBAC * Support data plane RBAC * Add additional changes for Portal RBAC functionality * Remove unnecessary code * Remove unnecessary code * Add code to fix VCoreMongo/PG bug * Address feedback * Add more logs for RBAC feature * Add more logs for RBAC features * Revert enableAADDataPlane feature flag behavior * Address feedback * Address comment --------- Co-authored-by: Asier Isayas --- src/Common/CosmosClient.ts | 4 +--- .../Panes/SettingsPane/SettingsPane.tsx | 17 +++++++++++------ src/hooks/useKnockoutExplorer.ts | 15 +-------------- 3 files changed, 13 insertions(+), 23 deletions(-) diff --git a/src/Common/CosmosClient.ts b/src/Common/CosmosClient.ts index 7e8a7f04c..f8491e564 100644 --- a/src/Common/CosmosClient.ts +++ b/src/Common/CosmosClient.ts @@ -18,10 +18,8 @@ const _global = typeof self === "undefined" ? window : self; export const tokenProvider = async (requestInfo: Cosmos.RequestInfo) => { const { verb, resourceId, resourceType, headers } = requestInfo; - const aadDataPlaneFeatureEnabled = - userContext.features.enableAadDataPlane && userContext.databaseAccount.properties.disableLocalAuth; const dataPlaneRBACOptionEnabled = userContext.dataPlaneRbacEnabled && userContext.apiType === "SQL"; - if (aadDataPlaneFeatureEnabled || (!userContext.features.enableAadDataPlane && dataPlaneRBACOptionEnabled)) { + if (userContext.features.enableAadDataPlane || dataPlaneRBACOptionEnabled) { Logger.logInfo( `AAD Data Plane Feature flag set to ${userContext.features.enableAadDataPlane} for account with disable local auth ${userContext.databaseAccount.properties.disableLocalAuth} `, "Explorer/tokenProvider", diff --git a/src/Explorer/Panes/SettingsPane/SettingsPane.tsx b/src/Explorer/Panes/SettingsPane/SettingsPane.tsx index bb1435077..ef277b53f 100644 --- a/src/Explorer/Panes/SettingsPane/SettingsPane.tsx +++ b/src/Explorer/Panes/SettingsPane/SettingsPane.tsx @@ -27,7 +27,7 @@ import { } from "Shared/StorageUtility"; import * as StringUtility from "Shared/StringUtility"; import { updateUserContext, userContext } from "UserContext"; -import { logConsoleInfo } from "Utils/NotificationConsoleUtils"; +import { logConsoleError, logConsoleInfo } from "Utils/NotificationConsoleUtils"; import * as PriorityBasedExecutionUtils from "Utils/PriorityBasedExecutionUtils"; import { useQueryCopilot } from "hooks/useQueryCopilot"; import { useSidePanel } from "hooks/useSidePanel"; @@ -171,13 +171,18 @@ export const SettingsPane: FunctionComponent<{ explorer: Explorer }> = ({ hasDataPlaneRbacSettingChanged: true, }); const { databaseAccount: account, subscriptionId, resourceGroup } = userContext; - if (!userContext.features.enableAadDataPlane) { - const keys: DatabaseAccountListKeysResult = await listKeys(subscriptionId, resourceGroup, account.name); + if (!userContext.features.enableAadDataPlane && !userContext.masterKey) { + try { + const keys: DatabaseAccountListKeysResult = await listKeys(subscriptionId, resourceGroup, account.name); - if (keys.primaryMasterKey) { - updateUserContext({ masterKey: keys.primaryMasterKey }); + if (keys.primaryMasterKey) { + updateUserContext({ masterKey: keys.primaryMasterKey }); - useDataPlaneRbac.setState({ dataPlaneRbacEnabled: false }); + useDataPlaneRbac.setState({ dataPlaneRbacEnabled: false }); + } + } catch (error) { + logConsoleError(`Error occurred fetching keys for the account." ${error.message}`); + throw error; } } } diff --git a/src/hooks/useKnockoutExplorer.ts b/src/hooks/useKnockoutExplorer.ts index 22cc0b51d..8a0bfa149 100644 --- a/src/hooks/useKnockoutExplorer.ts +++ b/src/hooks/useKnockoutExplorer.ts @@ -338,18 +338,6 @@ async function configureHostedWithAAD(config: AAD): Promise { ); await fetchAndUpdateKeys(subscriptionId, resourceGroup, account.name); } - } else { - Logger.logInfo( - `AAD Feature flag is enabled for account ${account.name} with disable local auth set to ${account.properties.disableLocalAuth} `, - "Explorer/configureHostedWithAAD", - ); - if (!account.properties.disableLocalAuth) { - Logger.logInfo( - `Fetching keys for ${userContext.apiType} account ${account.name} with AAD data plane feature enabled`, - "Explorer/configureHostedWithAAD", - ); - await fetchAndUpdateKeys(subscriptionId, resourceGroup, account.name); - } } } catch (e) { if (userContext.features.enableAadDataPlane) { @@ -470,7 +458,6 @@ async function fetchAndUpdateKeys(subscriptionId: string, resourceGroup: string, Logger.logInfo(`Fetching keys for ${userContext.apiType} account ${account}`, "Explorer/fetchAndUpdateKeys"); const keys = await listKeys(subscriptionId, resourceGroup, account); Logger.logInfo(`Keys fetched for ${userContext.apiType} account ${account}`, "Explorer/fetchAndUpdateKeys"); - updateUserContext({ masterKey: keys.primaryMasterKey, }); @@ -479,7 +466,7 @@ async function fetchAndUpdateKeys(subscriptionId: string, resourceGroup: string, "Explorer/fetchAndUpdateKeys", ); } catch (error) { - console.error("Error during fetching keys or updating user context:", error); + logConsoleError(`Error occurred fetching keys for the account." ${error.message}`); Logger.logError( `Error during fetching keys or updating user context: ${error} for ${userContext.apiType} account ${account}`, "Explorer/fetchAndUpdateKeys", From 7a1aa89cd13be9a5db5144b1daa9b83fe3d16f91 Mon Sep 17 00:00:00 2001 From: Asier Isayas Date: Wed, 17 Jul 2024 16:12:15 -0400 Subject: [PATCH 3/3] Add Cassandra Shell tab (#1913) Co-authored-by: Asier Isayas --- src/Explorer/ContextMenuButtonFactory.tsx | 10 ++++++++ .../CommandBarComponentButtonFactory.tsx | 23 +++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/Explorer/ContextMenuButtonFactory.tsx b/src/Explorer/ContextMenuButtonFactory.tsx index 90c78e365..dc5705256 100644 --- a/src/Explorer/ContextMenuButtonFactory.tsx +++ b/src/Explorer/ContextMenuButtonFactory.tsx @@ -100,6 +100,16 @@ export const createCollectionContextMenuButton = ( }); } + if (useNotebook.getState().isShellEnabled && userContext.apiType === "Cassandra") { + items.push({ + iconSrc: HostedTerminalIcon, + onClick: () => { + container.openNotebookTerminal(ViewModels.TerminalKind.Cassandra); + }, + label: "Open Cassandra Shell", + }); + } + if ( configContext.platform !== Platform.Fabric && (userContext.apiType === "SQL" || userContext.apiType === "Gremlin") diff --git a/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.tsx b/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.tsx index 919fc1cc2..18442b1ca 100644 --- a/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.tsx +++ b/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.tsx @@ -1,6 +1,7 @@ import { KeyboardAction } from "KeyboardShortcuts"; import { ReactTabKind, useTabs } from "hooks/useTabs"; import * as React from "react"; +import { useEffect, useState } from "react"; import AddCollectionIcon from "../../../../images/AddCollection.svg"; import AddDatabaseIcon from "../../../../images/AddDatabase.svg"; import AddSqlQueryIcon from "../../../../images/AddSqlQuery_16x16.svg"; @@ -8,6 +9,7 @@ import AddStoredProcedureIcon from "../../../../images/AddStoredProcedure.svg"; import AddTriggerIcon from "../../../../images/AddTrigger.svg"; import AddUdfIcon from "../../../../images/AddUdf.svg"; import BrowseQueriesIcon from "../../../../images/BrowseQuery.svg"; +import EntraIDIcon from "../../../../images/EntraID.svg"; import FeedbackIcon from "../../../../images/Feedback-Command.svg"; import HomeIcon from "../../../../images/Home_16.svg"; import HostedTerminalIcon from "../../../../images/Hosted-Terminal.svg"; @@ -15,7 +17,6 @@ import OpenQueryFromDiskIcon from "../../../../images/OpenQueryFromDisk.svg"; import OpenInTabIcon from "../../../../images/open-in-tab.svg"; import SettingsIcon from "../../../../images/settings_15x15.svg"; import SynapseIcon from "../../../../images/synapse-link.svg"; -import EntraIDIcon from "../../../../images/EntraID.svg"; import { AuthType } from "../../../AuthType"; import * as Constants from "../../../Common/Constants"; import { Platform, configContext } from "../../../ConfigContext"; @@ -34,7 +35,6 @@ import { LoadQueryPane } from "../../Panes/LoadQueryPane/LoadQueryPane"; import { SettingsPane, useDataPlaneRbac } from "../../Panes/SettingsPane/SettingsPane"; import { useDatabases } from "../../useDatabases"; import { SelectedNodeState, useSelectedNode } from "../../useSelectedNode"; -import { useEffect, useState } from "react"; let counter = 0; @@ -161,6 +161,25 @@ export function createContextCommandBarButtons( buttons.push(newMongoShellBtn); } + if ( + useNotebook.getState().isShellEnabled && + !selectedNodeState.isDatabaseNodeOrNoneSelected() && + userContext.apiType === "Cassandra" + ) { + const label: string = "Open Cassandra Shell"; + const newCassandraShellButton: CommandButtonComponentProps = { + iconSrc: HostedTerminalIcon, + iconAlt: label, + onCommandClick: () => { + container.openNotebookTerminal(ViewModels.TerminalKind.Cassandra); + }, + commandButtonLabel: label, + ariaLabel: label, + hasPopup: true, + }; + buttons.push(newCassandraShellButton); + } + return buttons; }