From 5dde66b03265a5f25f3161efeaaafddb8ffea340 Mon Sep 17 00:00:00 2001 From: victor-meng <56978073+victor-meng@users.noreply.github.com> Date: Thu, 10 Nov 2022 10:46:55 -0800 Subject: [PATCH] Add check and guidance for networking settings (#1348) --- src/Contracts/DataModels.ts | 1 + src/Contracts/ExplorerContracts.ts | 1 + src/Contracts/ViewModels.ts | 1 - src/Explorer/Tabs/Tabs.tsx | 19 ++++++++++- src/Explorer/Tree/Collection.ts | 17 ---------- src/Explorer/Tree/ResourceTree.tsx | 3 +- src/Explorer/Tree/ResourceTreeAdapter.tsx | 3 +- src/Utils/APITypeUtils.ts | 15 +++++++++ src/Utils/NetworkUtility.ts | 40 +++++++++++++++++++++++ src/hooks/useKnockoutExplorer.ts | 3 ++ src/hooks/useTabs.ts | 4 +++ 11 files changed, 86 insertions(+), 21 deletions(-) create mode 100644 src/Utils/NetworkUtility.ts diff --git a/src/Contracts/DataModels.ts b/src/Contracts/DataModels.ts index 031a0686b..c913310a3 100644 --- a/src/Contracts/DataModels.ts +++ b/src/Contracts/DataModels.ts @@ -34,6 +34,7 @@ export interface DatabaseAccountExtendedProperties { capacity?: { totalThroughputLimit: number }; locations?: DatabaseAccountResponseLocation[]; postgresqlEndpoint?: string; + publicNetworkAccess?: string; } export interface DatabaseAccountResponseLocation { diff --git a/src/Contracts/ExplorerContracts.ts b/src/Contracts/ExplorerContracts.ts index b6d547660..fc689d248 100644 --- a/src/Contracts/ExplorerContracts.ts +++ b/src/Contracts/ExplorerContracts.ts @@ -37,6 +37,7 @@ export enum MessageTypes { OpenQuickstartBlade, OpenPostgreSQLPasswordReset, OpenPostgresNetworkingBlade, + OpenCosmosDBNetworkingBlade, } export { Versions, ActionContracts, Diagnostics }; diff --git a/src/Contracts/ViewModels.ts b/src/Contracts/ViewModels.ts index dbca00fed..4e0da2898 100644 --- a/src/Contracts/ViewModels.ts +++ b/src/Contracts/ViewModels.ts @@ -186,7 +186,6 @@ export interface Collection extends CollectionBase { onDrop(source: Collection, event: { originalEvent: DragEvent }): void; uploadFiles(fileList: FileList): Promise<{ data: UploadDetailsRecord[] }>; - getLabel(): string; getPendingThroughputSplitNotification(): Promise; } diff --git a/src/Explorer/Tabs/Tabs.tsx b/src/Explorer/Tabs/Tabs.tsx index c64b6ed56..2536e51e6 100644 --- a/src/Explorer/Tabs/Tabs.tsx +++ b/src/Explorer/Tabs/Tabs.tsx @@ -1,3 +1,6 @@ +import { MessageBar, MessageBarButton, MessageBarType } from "@fluentui/react"; +import { sendMessage } from "Common/MessageHandler"; +import { MessageTypes } from "Contracts/ExplorerContracts"; import { CollectionTabKind } from "Contracts/ViewModels"; import Explorer from "Explorer/Explorer"; import { SplashScreen } from "Explorer/SplashScreen/SplashScreen"; @@ -21,10 +24,24 @@ interface TabsProps { } export const Tabs = ({ explorer }: TabsProps): JSX.Element => { - const { openedTabs, openedReactTabs, activeTab, activeReactTab } = useTabs(); + const { openedTabs, openedReactTabs, activeTab, activeReactTab, showNetworkSettingsWarning } = useTabs(); return (
+ {showNetworkSettingsWarning && ( + sendMessage({ type: MessageTypes.OpenCosmosDBNetworkingBlade })}> + Change network settings + + } + messageBarIconProps={{ iconName: "WarningSolid", className: "messageBarWarningIcon" }} + > + The Network settings for this account are preventing access from Data Explorer. Please allow access from Azure + Portal to proceed. + + )}