diff --git a/src/Explorer/ComponentRegisterer.ts b/src/Explorer/ComponentRegisterer.ts index c7e7ee087..de781159a 100644 --- a/src/Explorer/ComponentRegisterer.ts +++ b/src/Explorer/ComponentRegisterer.ts @@ -67,7 +67,6 @@ ko.components.register("table-query-select-pane", new PaneComponents.TableQueryS ko.components.register("cassandra-add-collection-pane", new PaneComponents.CassandraAddCollectionPaneComponent()); ko.components.register("settings-pane", new PaneComponents.SettingsPaneComponent()); ko.components.register("execute-sproc-params-pane", new PaneComponents.ExecuteSprocParamsComponent()); -ko.components.register("renew-adhoc-access-pane", new PaneComponents.RenewAdHocAccessPane()); ko.components.register("upload-items-pane", new PaneComponents.UploadItemsPaneComponent()); ko.components.register("load-query-pane", new PaneComponents.LoadQueryPaneComponent()); ko.components.register("save-query-pane", new PaneComponents.SaveQueryPaneComponent()); diff --git a/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap b/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap index eb2b6b943..b5868d658 100644 --- a/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap +++ b/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap @@ -32,10 +32,8 @@ exports[`SettingsComponent renders 1`] = ` "_closeModalDialog": [Function], "_closeSynapseLinkModalDialog": [Function], "_dialogProps": [Function], - "_importExplorerConfigComplete": false, "_isAfecFeatureRegistered": [Function], "_isInitializingNotebooks": false, - "_isInitializingSparkConnectionInfo": false, "_isSystemDatabasePredicate": [Function], "_openShareDialog": [Function], "_panes": Array [ @@ -440,22 +438,6 @@ exports[`SettingsComponent renders 1`] = ` "validPartitionKeyValue": [Function], "visible": [Function], }, - RenewAdHocAccessPane { - "_renewShareAccess": [Function], - "accessKey": [Function], - "container": [Circular], - "firstFieldHasFocus": [Function], - "formErrors": [Function], - "formErrorsDetails": [Function], - "id": "renewadhocaccesspane", - "isExecuting": [Function], - "isHelperImageVisible": [Function], - "isTemplateReady": [Function], - "onShowHelperImageClick": [Function], - "onShowHelperImageKeyPress": [Function], - "title": [Function], - "visible": [Function], - }, UploadItemsPane { "container": [Circular], "fileUploadSummaryText": [Function], @@ -1051,22 +1033,6 @@ exports[`SettingsComponent renders 1`] = ` "refreshDatabaseAccount": [Function], "refreshNotebookList": [Function], "refreshTreeTitle": [Function], - "renewAdHocAccessPane": RenewAdHocAccessPane { - "_renewShareAccess": [Function], - "accessKey": [Function], - "container": [Circular], - "firstFieldHasFocus": [Function], - "formErrors": [Function], - "formErrorsDetails": [Function], - "id": "renewadhocaccesspane", - "isExecuting": [Function], - "isHelperImageVisible": [Function], - "isTemplateReady": [Function], - "onShowHelperImageClick": [Function], - "onShowHelperImageKeyPress": [Function], - "title": [Function], - "visible": [Function], - }, "renewToken": [Function], "renewTokenError": [Function], "resourceTokenCollection": [Function], @@ -1169,8 +1135,6 @@ exports[`SettingsComponent renders 1`] = ` "shareAccessUrl": [Function], "shareTokenCopyHelperText": [Function], "shareUrlCopyHelperText": [Function], - "shouldShowContextSwitchPrompt": [Function], - "shouldShowDataAccessExpiryDialog": [Function], "shouldShowShareDialogContents": [Function], "signInAad": [Function], "sparkClusterConnectionInfo": [Function], @@ -1313,10 +1277,8 @@ exports[`SettingsComponent renders 1`] = ` "_closeModalDialog": [Function], "_closeSynapseLinkModalDialog": [Function], "_dialogProps": [Function], - "_importExplorerConfigComplete": false, "_isAfecFeatureRegistered": [Function], "_isInitializingNotebooks": false, - "_isInitializingSparkConnectionInfo": false, "_isSystemDatabasePredicate": [Function], "_openShareDialog": [Function], "_panes": Array [ @@ -1721,22 +1683,6 @@ exports[`SettingsComponent renders 1`] = ` "validPartitionKeyValue": [Function], "visible": [Function], }, - RenewAdHocAccessPane { - "_renewShareAccess": [Function], - "accessKey": [Function], - "container": [Circular], - "firstFieldHasFocus": [Function], - "formErrors": [Function], - "formErrorsDetails": [Function], - "id": "renewadhocaccesspane", - "isExecuting": [Function], - "isHelperImageVisible": [Function], - "isTemplateReady": [Function], - "onShowHelperImageClick": [Function], - "onShowHelperImageKeyPress": [Function], - "title": [Function], - "visible": [Function], - }, UploadItemsPane { "container": [Circular], "fileUploadSummaryText": [Function], @@ -2332,22 +2278,6 @@ exports[`SettingsComponent renders 1`] = ` "refreshDatabaseAccount": [Function], "refreshNotebookList": [Function], "refreshTreeTitle": [Function], - "renewAdHocAccessPane": RenewAdHocAccessPane { - "_renewShareAccess": [Function], - "accessKey": [Function], - "container": [Circular], - "firstFieldHasFocus": [Function], - "formErrors": [Function], - "formErrorsDetails": [Function], - "id": "renewadhocaccesspane", - "isExecuting": [Function], - "isHelperImageVisible": [Function], - "isTemplateReady": [Function], - "onShowHelperImageClick": [Function], - "onShowHelperImageKeyPress": [Function], - "title": [Function], - "visible": [Function], - }, "renewToken": [Function], "renewTokenError": [Function], "resourceTokenCollection": [Function], @@ -2450,8 +2380,6 @@ exports[`SettingsComponent renders 1`] = ` "shareAccessUrl": [Function], "shareTokenCopyHelperText": [Function], "shareUrlCopyHelperText": [Function], - "shouldShowContextSwitchPrompt": [Function], - "shouldShowDataAccessExpiryDialog": [Function], "shouldShowShareDialogContents": [Function], "signInAad": [Function], "sparkClusterConnectionInfo": [Function], @@ -2607,10 +2535,8 @@ exports[`SettingsComponent renders 1`] = ` "_closeModalDialog": [Function], "_closeSynapseLinkModalDialog": [Function], "_dialogProps": [Function], - "_importExplorerConfigComplete": false, "_isAfecFeatureRegistered": [Function], "_isInitializingNotebooks": false, - "_isInitializingSparkConnectionInfo": false, "_isSystemDatabasePredicate": [Function], "_openShareDialog": [Function], "_panes": Array [ @@ -3015,22 +2941,6 @@ exports[`SettingsComponent renders 1`] = ` "validPartitionKeyValue": [Function], "visible": [Function], }, - RenewAdHocAccessPane { - "_renewShareAccess": [Function], - "accessKey": [Function], - "container": [Circular], - "firstFieldHasFocus": [Function], - "formErrors": [Function], - "formErrorsDetails": [Function], - "id": "renewadhocaccesspane", - "isExecuting": [Function], - "isHelperImageVisible": [Function], - "isTemplateReady": [Function], - "onShowHelperImageClick": [Function], - "onShowHelperImageKeyPress": [Function], - "title": [Function], - "visible": [Function], - }, UploadItemsPane { "container": [Circular], "fileUploadSummaryText": [Function], @@ -3626,22 +3536,6 @@ exports[`SettingsComponent renders 1`] = ` "refreshDatabaseAccount": [Function], "refreshNotebookList": [Function], "refreshTreeTitle": [Function], - "renewAdHocAccessPane": RenewAdHocAccessPane { - "_renewShareAccess": [Function], - "accessKey": [Function], - "container": [Circular], - "firstFieldHasFocus": [Function], - "formErrors": [Function], - "formErrorsDetails": [Function], - "id": "renewadhocaccesspane", - "isExecuting": [Function], - "isHelperImageVisible": [Function], - "isTemplateReady": [Function], - "onShowHelperImageClick": [Function], - "onShowHelperImageKeyPress": [Function], - "title": [Function], - "visible": [Function], - }, "renewToken": [Function], "renewTokenError": [Function], "resourceTokenCollection": [Function], @@ -3744,8 +3638,6 @@ exports[`SettingsComponent renders 1`] = ` "shareAccessUrl": [Function], "shareTokenCopyHelperText": [Function], "shareUrlCopyHelperText": [Function], - "shouldShowContextSwitchPrompt": [Function], - "shouldShowDataAccessExpiryDialog": [Function], "shouldShowShareDialogContents": [Function], "signInAad": [Function], "sparkClusterConnectionInfo": [Function], @@ -3888,10 +3780,8 @@ exports[`SettingsComponent renders 1`] = ` "_closeModalDialog": [Function], "_closeSynapseLinkModalDialog": [Function], "_dialogProps": [Function], - "_importExplorerConfigComplete": false, "_isAfecFeatureRegistered": [Function], "_isInitializingNotebooks": false, - "_isInitializingSparkConnectionInfo": false, "_isSystemDatabasePredicate": [Function], "_openShareDialog": [Function], "_panes": Array [ @@ -4296,22 +4186,6 @@ exports[`SettingsComponent renders 1`] = ` "validPartitionKeyValue": [Function], "visible": [Function], }, - RenewAdHocAccessPane { - "_renewShareAccess": [Function], - "accessKey": [Function], - "container": [Circular], - "firstFieldHasFocus": [Function], - "formErrors": [Function], - "formErrorsDetails": [Function], - "id": "renewadhocaccesspane", - "isExecuting": [Function], - "isHelperImageVisible": [Function], - "isTemplateReady": [Function], - "onShowHelperImageClick": [Function], - "onShowHelperImageKeyPress": [Function], - "title": [Function], - "visible": [Function], - }, UploadItemsPane { "container": [Circular], "fileUploadSummaryText": [Function], @@ -4907,22 +4781,6 @@ exports[`SettingsComponent renders 1`] = ` "refreshDatabaseAccount": [Function], "refreshNotebookList": [Function], "refreshTreeTitle": [Function], - "renewAdHocAccessPane": RenewAdHocAccessPane { - "_renewShareAccess": [Function], - "accessKey": [Function], - "container": [Circular], - "firstFieldHasFocus": [Function], - "formErrors": [Function], - "formErrorsDetails": [Function], - "id": "renewadhocaccesspane", - "isExecuting": [Function], - "isHelperImageVisible": [Function], - "isTemplateReady": [Function], - "onShowHelperImageClick": [Function], - "onShowHelperImageKeyPress": [Function], - "title": [Function], - "visible": [Function], - }, "renewToken": [Function], "renewTokenError": [Function], "resourceTokenCollection": [Function], @@ -5025,8 +4883,6 @@ exports[`SettingsComponent renders 1`] = ` "shareAccessUrl": [Function], "shareTokenCopyHelperText": [Function], "shareUrlCopyHelperText": [Function], - "shouldShowContextSwitchPrompt": [Function], - "shouldShowDataAccessExpiryDialog": [Function], "shouldShowShareDialogContents": [Function], "signInAad": [Function], "sparkClusterConnectionInfo": [Function], diff --git a/src/Explorer/Explorer.tsx b/src/Explorer/Explorer.tsx index 8e93ef53d..53ca9c341 100644 --- a/src/Explorer/Explorer.tsx +++ b/src/Explorer/Explorer.tsx @@ -21,7 +21,6 @@ import { readDatabases } from "../Common/dataAccess/readDatabases"; import EditTableEntityPane from "./Panes/Tables/EditTableEntityPane"; import { normalizeArmEndpoint } from "../Common/EnvironmentUtility"; import GraphStylingPane from "./Panes/GraphStylingPane"; -import hasher from "hasher"; import NewVertexPane from "./Panes/NewVertexPane"; import NotebookV2Tab, { NotebookTabOptions } from "./Tabs/NotebookV2Tab"; import Q from "q"; @@ -29,7 +28,7 @@ import ResourceTokenCollection from "./Tree/ResourceTokenCollection"; import * as TelemetryProcessor from "../Shared/Telemetry/TelemetryProcessor"; import TerminalTab from "./Tabs/TerminalTab"; import { Action, ActionModifiers } from "../Shared/Telemetry/TelemetryConstants"; -import { ActionContracts, MessageTypes } from "../Contracts/ExplorerContracts"; +import { MessageTypes } from "../Contracts/ExplorerContracts"; import { ArcadiaResourceManager } from "../SparkClusterManager/ArcadiaResourceManager"; import { ArcadiaWorkspaceItem } from "./Controls/Arcadia/ArcadiaMenuPicker"; import { AuthType } from "../AuthType"; @@ -47,18 +46,16 @@ import { ExecuteSprocParamsPane } from "./Panes/ExecuteSprocParamsPane"; import { ExplorerMetrics } from "../Common/Constants"; import { ExplorerSettings } from "../Shared/ExplorerSettings"; import { FileSystemUtil } from "./Notebook/FileSystemUtil"; -import { handleOpenAction } from "./OpenActions"; import { IGalleryItem } from "../Juno/JunoClient"; import { LoadQueryPane } from "./Panes/LoadQueryPane"; import * as Logger from "../Common/Logger"; -import { sendMessage, sendCachedDataMessage, handleCachedDataMessage } from "../Common/MessageHandler"; +import { sendMessage, sendCachedDataMessage } from "../Common/MessageHandler"; import { NotebookContentItem, NotebookContentItemType } from "./Notebook/NotebookContentItem"; import { NotebookUtil } from "./Notebook/NotebookUtil"; import { NotebookWorkspaceManager } from "../NotebookWorkspaceManager/NotebookWorkspaceManager"; import * as NotificationConsoleUtils from "../Utils/NotificationConsoleUtils"; import { QueriesClient } from "../Common/QueriesClient"; import { QuerySelectPane } from "./Panes/Tables/QuerySelectPane"; -import { RenewAdHocAccessPane } from "./Panes/RenewAdHocAccessPane"; import { ResourceProviderClientFactory } from "../ResourceProvider/ResourceProviderClientFactory"; import { ResourceTreeAdapter } from "./Tree/ResourceTreeAdapter"; import { ResourceTreeAdapterForResourceToken } from "./Tree/ResourceTreeAdapterForResourceToken"; @@ -204,7 +201,6 @@ export default class Explorer { public cassandraAddCollectionPane: CassandraAddCollectionPane; public settingsPane: SettingsPane; public executeSprocParamsPane: ExecuteSprocParamsPane; - public renewAdHocAccessPane: RenewAdHocAccessPane; public uploadItemsPane: UploadItemsPane; public uploadItemsPaneAdapter: UploadItemsPaneAdapter; public loadQueryPane: LoadQueryPane; @@ -238,8 +234,6 @@ export default class Explorer { public shareAccessUrl: ko.Observable; public shareUrlCopyHelperText: ko.Observable; public shareTokenCopyHelperText: ko.Observable; - public shouldShowDataAccessExpiryDialog: ko.Observable; - public shouldShowContextSwitchPrompt: ko.Observable; public isSchemaEnabled: ko.Computed; // Notebooks @@ -258,10 +252,8 @@ export default class Explorer { public notebookManager?: any; // This is dynamically loaded private _panes: ContextualPaneBase[] = []; - private _importExplorerConfigComplete: boolean = false; private _isSystemDatabasePredicate: (database: ViewModels.Database) => boolean = (database) => false; private _isInitializingNotebooks: boolean; - private _isInitializingSparkConnectionInfo: boolean; private notebookBasePath: ko.Observable; private _arcadiaManager: ArcadiaResourceManager; private notebookToImport: { @@ -320,7 +312,6 @@ export default class Explorer { this.isAccountReady = ko.observable(false); this.selfServeType = ko.observable(undefined); this._isInitializingNotebooks = false; - this._isInitializingSparkConnectionInfo = false; this.arcadiaToken = ko.observable(); this.arcadiaToken.subscribe((token: string) => { if (token) { @@ -429,8 +420,6 @@ export default class Explorer { } }); this.shouldShowShareDialogContents = ko.observable(false); - this.shouldShowDataAccessExpiryDialog = ko.observable(false); - this.shouldShowContextSwitchPrompt = ko.observable(false); this.isGalleryPublishEnabled = ko.computed( () => configContext.ENABLE_GALLERY_PUBLISH || this.isFeatureEnabled(Constants.Features.enableGalleryPublish) ); @@ -715,13 +704,6 @@ export default class Explorer { container: this, }); - this.renewAdHocAccessPane = new RenewAdHocAccessPane({ - id: "renewadhocaccesspane", - visible: ko.observable(false), - - container: this, - }); - this.uploadItemsPane = new UploadItemsPane({ id: "uploaditemspane", visible: ko.observable(false), @@ -790,7 +772,6 @@ export default class Explorer { this.cassandraAddCollectionPane, this.settingsPane, this.executeSprocParamsPane, - this.renewAdHocAccessPane, this.uploadItemsPane, this.loadQueryPane, this.saveQueryPane, @@ -1173,138 +1154,10 @@ export default class Explorer { ); } - public renewShareAccess(token: string): Q.Promise { - if (!this.renewExplorerShareAccess) { - return Q.reject("Not implemented"); - } - - const deferred: Q.Deferred = Q.defer(); - const id: string = NotificationConsoleUtils.logConsoleMessage( - ConsoleDataType.InProgress, - "Initiating connection to account" - ); - this.renewExplorerShareAccess(this, token) - .then( - () => { - NotificationConsoleUtils.logConsoleMessage(ConsoleDataType.Info, "Connection successful"); - this.renewAdHocAccessPane && this.renewAdHocAccessPane.close(); - deferred.resolve(); - }, - (error: any) => { - NotificationConsoleUtils.logConsoleMessage( - ConsoleDataType.Error, - `Failed to connect: ${getErrorMessage(error)}` - ); - deferred.reject(error); - } - ) - .finally(() => { - NotificationConsoleUtils.clearInProgressMessageWithId(id); - }); - - return deferred.promise; - } - - public displayGuestAccessTokenRenewalPrompt(): void { - if (!$("#dataAccessTokenModal").dialog("instance")) { - const connectButton = { - text: "Connect", - class: "connectDialogButtons connectButton connectOkBtns", - click: () => { - this.renewAdHocAccessPane.open(); - $("#dataAccessTokenModal").dialog("close"); - }, - }; - const cancelButton = { - text: "Cancel", - class: "connectDialogButtons cancelBtn", - click: () => { - $("#dataAccessTokenModal").dialog("close"); - }, - }; - - $("#dataAccessTokenModal").dialog({ - autoOpen: false, - buttons: [connectButton, cancelButton], - closeOnEscape: false, - draggable: false, - dialogClass: "no-close", - height: 180, - modal: true, - position: { my: "center center", at: "center center", of: window }, - resizable: false, - title: "Temporary access expired", - width: 435, - close: (event: Event, ui: JQueryUI.DialogUIParams) => this.shouldShowDataAccessExpiryDialog(false), - }); - $("#dataAccessTokenModal").dialog("option", "classes", { - "ui-dialog-titlebar": "connectTitlebar", - }); - } - this.shouldShowDataAccessExpiryDialog(true); - $("#dataAccessTokenModal").dialog("open"); - } - public isConnectExplorerVisible(): boolean { return $("#connectExplorer").is(":visible") || false; } - public displayContextSwitchPromptForConnectionString(connectionString: string): void { - const yesButton = { - text: "OK", - class: "connectDialogButtons okBtn connectOkBtns", - click: () => { - $("#contextSwitchPrompt").dialog("close"); - this.tabsManager.closeTabs(); // clear all tabs so we dont leave any tabs from previous session open - this.renewShareAccess(connectionString); - }, - }; - const noButton = { - text: "Cancel", - class: "connectDialogButtons cancelBtn", - click: () => { - $("#contextSwitchPrompt").dialog("close"); - }, - }; - - if (!$("#contextSwitchPrompt").dialog("instance")) { - $("#contextSwitchPrompt").dialog({ - autoOpen: false, - buttons: [yesButton, noButton], - closeOnEscape: false, - draggable: false, - dialogClass: "no-close", - height: 255, - modal: true, - position: { my: "center center", at: "center center", of: window }, - resizable: false, - title: "Switch account", - width: 440, - close: (event: Event, ui: JQueryUI.DialogUIParams) => this.shouldShowDataAccessExpiryDialog(false), - }); - $("#contextSwitchPrompt").dialog("option", "classes", { - "ui-dialog-titlebar": "connectTitlebar", - }); - $("#contextSwitchPrompt").dialog("option", "open", (event: Event, ui: JQueryUI.DialogUIParams) => { - $(".ui-dialog ").css("z-index", 1001); - $("#contextSwitchPrompt").parent().siblings(".ui-widget-overlay").css("z-index", 1000); - }); - } - $("#contextSwitchPrompt").dialog("option", "buttons", [yesButton, noButton]); // rebind buttons so callbacks accept current connection string - this.shouldShowContextSwitchPrompt(true); - $("#contextSwitchPrompt").dialog("open"); - } - - public displayConnectExplorerForm(): void { - $("#divExplorer").hide(); - $("#connectExplorer").css("display", "flex"); - } - - public hideConnectExplorerForm(): void { - $("#connectExplorer").hide(); - $("#divExplorer").show(); - } - public isReadWriteToggled: () => boolean = (): boolean => { return this.shareAccessToggleState() === ShareAccessToggleState.ReadWrite; }; @@ -1728,60 +1581,6 @@ export default class Explorer { this._addSynapseLinkDialogProps.valueHasMutated(); }; - public handleMessage(message: any) { - const openAction: ActionContracts.DataExplorerAction = message.openAction; - if (!!openAction) { - if (this.isRefreshingExplorer()) { - const subscription = this.databases.subscribe((databases: ViewModels.Database[]) => { - handleOpenAction(openAction, this.nonSystemDatabases(), this); - subscription.dispose(); - }); - } else { - handleOpenAction(openAction, this.nonSystemDatabases(), this); - } - } - if (message.actionType === ActionContracts.ActionType.TransmitCachedData) { - handleCachedDataMessage(message); - return; - } - if (message.type) { - switch (message.type) { - case MessageTypes.UpdateLocationHash: - if (!message.locationHash) { - break; - } - hasher.replaceHash(message.locationHash); - RouteHandler.getInstance().parseHash(message.locationHash); - break; - case MessageTypes.SendNotification: - if (!message.message) { - break; - } - NotificationConsoleUtils.logConsoleMessage( - message.consoleDataType || ConsoleDataType.Info, - message.message, - message.id - ); - break; - case MessageTypes.ClearNotification: - if (!message.id) { - break; - } - NotificationConsoleUtils.clearInProgressMessageWithId(message.id); - break; - case MessageTypes.LoadingStatus: - if (!message.text) { - break; - } - this._setLoadingStatusText(message.text, message.title); - break; - } - return; - } - - this.splashScreenAdapter.forceRender(); - } - public findSelectedDatabase(): ViewModels.Database { if (!this.selectedNode()) { return null; @@ -1859,7 +1658,6 @@ export default class Explorer { this.isAuthWithResourceToken(inputs.isAuthWithresourceToken ?? false); this.setFeatureFlagsFromFlights(inputs.flights); this.setSelfServeType(inputs); - this._importExplorerConfigComplete = true; updateConfigContext({ BACKEND_ENDPOINT: inputs.extensionEndpoint || configContext.BACKEND_ENDPOINT, diff --git a/src/Explorer/OpenActions.ts b/src/Explorer/OpenActions.ts index 01f6af793..4997a7266 100644 --- a/src/Explorer/OpenActions.ts +++ b/src/Explorer/OpenActions.ts @@ -146,12 +146,6 @@ function openPane(action: ActionContracts.OpenPane, explorer: Explorer) { ) { explorer.closeAllPanes(); !explorer.isConnectExplorerVisible() && explorer.settingsPane.open(); - } else if ( - action.paneKind === ActionContracts.PaneKind.AdHocAccess || - (action).paneKind === ActionContracts.PaneKind[ActionContracts.PaneKind.AdHocAccess] - ) { - explorer.closeAllPanes(); - !explorer.isConnectExplorerVisible() && explorer.renewAdHocAccessPane.open(); } } diff --git a/src/Explorer/Panes/PaneComponents.ts b/src/Explorer/Panes/PaneComponents.ts index 289ef3aee..6bd6698b6 100644 --- a/src/Explorer/Panes/PaneComponents.ts +++ b/src/Explorer/Panes/PaneComponents.ts @@ -11,7 +11,6 @@ import TableQuerySelectPaneTemplate from "./Tables/TableQuerySelectPane.html"; import CassandraAddCollectionPaneTemplate from "./CassandraAddCollectionPane.html"; import SettingsPaneTemplate from "./SettingsPane.html"; import ExecuteSprocParamsPaneTemplate from "./ExecuteSprocParamsPane.html"; -import RenewAdHocAccessPaneTemplate from "./RenewAdHocAccessPane.html"; import UploadItemsPaneTemplate from "./UploadItemsPane.html"; import LoadQueryPaneTemplate from "./LoadQueryPane.html"; import SaveQueryPaneTemplate from "./SaveQueryPane.html"; @@ -144,15 +143,6 @@ export class ExecuteSprocParamsComponent { } } -export class RenewAdHocAccessPane { - constructor() { - return { - viewModel: PaneComponent, - template: RenewAdHocAccessPaneTemplate, - }; - } -} - export class UploadItemsPaneComponent { constructor() { return { diff --git a/src/Explorer/Panes/RenewAdHocAccessPane.html b/src/Explorer/Panes/RenewAdHocAccessPane.html deleted file mode 100644 index 06720f700..000000000 --- a/src/Explorer/Panes/RenewAdHocAccessPane.html +++ /dev/null @@ -1,90 +0,0 @@ -
-
-
- -
-
- -
- -
- Close -
-
- - - -
-
- Error - - - More details - -
-
- - - -
-
Provide a valid account connection string
- -
- Show renew access image - Hide renew access image - Where do I find the Connection String? -
-
- To get the connection string, navigate to your Azure Cosmos DB account in Azure Portal, select Keys and - copy the connection string. - -
-
-
-
-
- -
-
- - -
- -
- -
-
diff --git a/src/Explorer/Panes/RenewAdHocAccessPane.ts b/src/Explorer/Panes/RenewAdHocAccessPane.ts deleted file mode 100644 index 33b5fa1c5..000000000 --- a/src/Explorer/Panes/RenewAdHocAccessPane.ts +++ /dev/null @@ -1,101 +0,0 @@ -import * as ko from "knockout"; -import * as Constants from "../../Common/Constants"; -import * as DataModels from "../../Contracts/DataModels"; -import * as ViewModels from "../../Contracts/ViewModels"; -import { parseConnectionString } from "../../Platform/Hosted/Helpers/ConnectionStringParser"; -import { ContextualPaneBase } from "./ContextualPaneBase"; -import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent"; -import { DefaultExperienceUtility } from "../../Shared/DefaultExperienceUtility"; -import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils"; -import { getErrorMessage } from "../../Common/ErrorHandlingUtils"; - -export class RenewAdHocAccessPane extends ContextualPaneBase { - public accessKey: ko.Observable; - public isHelperImageVisible: ko.Observable; - - constructor(options: ViewModels.PaneOptions) { - super(options); - this.title("Connect to Azure Cosmos DB"); - this.accessKey = ko.observable(); - this.isHelperImageVisible = ko.observable(false); - } - - public submit(): void { - this.formErrors(""); - this.formErrorsDetails(""); - - if (this._shouldShowContextSwitchPrompt()) { - this.container.displayContextSwitchPromptForConnectionString(this.accessKey()); - } else if (!!this.formErrors()) { - return; - } else { - this.isExecuting(true); - this._renewShareAccess(); - } - } - - public onShowHelperImageClick = (src: any, event: MouseEvent): void => { - this.isHelperImageVisible(!this.isHelperImageVisible()); - }; - - public onShowHelperImageKeyPress = (src: any, event: KeyboardEvent): boolean => { - if (event.keyCode === Constants.KeyCodes.Enter || event.keyCode === Constants.KeyCodes.Space) { - this.onShowHelperImageClick(src, null); - return false; - } - - return true; - }; - - private _shouldShowContextSwitchPrompt(): boolean { - const inputMetadata: DataModels.AccessInputMetadata = parseConnectionString(this.accessKey()); - const apiKind: DataModels.ApiKind = - this.container && DefaultExperienceUtility.getApiKindFromDefaultExperience(this.container.defaultExperience()); - const hasOpenedTabs: boolean = - (this.container && this.container.tabsManager && this.container.tabsManager.openedTabs().length > 0) || false; - - if (!inputMetadata || inputMetadata.apiKind == null || !inputMetadata.accountName) { - this.formErrors("Invalid connection string input"); - this.formErrorsDetails("Please enter a valid connection string"); - } - - if ( - !inputMetadata || - this.formErrors() || - !this.container || - apiKind == null || - !this.container.databaseAccount || - !this.container.defaultExperience || - !hasOpenedTabs || - (this.container.databaseAccount().name === inputMetadata.accountName && - apiKind === inputMetadata.apiKind && - !hasOpenedTabs) - ) { - return false; - } - - return true; - } - - private _renewShareAccess = (): void => { - this.container - .renewShareAccess(this.accessKey()) - .fail((error: any) => { - const errorMessage: string = getErrorMessage(error); - NotificationConsoleUtils.logConsoleMessage(ConsoleDataType.Error, `Failed to connect: ${errorMessage}`); - this.formErrors(errorMessage); - this.formErrorsDetails(errorMessage); - }) - .finally(() => { - this.isExecuting(false); - }); - }; - - public close(): void { - super.close(); - this.isHelperImageVisible(false); - this.formErrors(""); - this.formErrorsDetails(""); - this.accessKey(""); - } -} diff --git a/src/Explorer/Tables/TableDataClient.ts b/src/Explorer/Tables/TableDataClient.ts index fb4481682..7603fc89e 100644 --- a/src/Explorer/Tables/TableDataClient.ts +++ b/src/Explorer/Tables/TableDataClient.ts @@ -1,7 +1,7 @@ import * as ko from "knockout"; import Q from "q"; -import { displayTokenRenewalPromptForStatus, getAuthorizationHeader } from "../../Utils/AuthorizationUtils"; +import { getAuthorizationHeader } from "../../Utils/AuthorizationUtils"; import { AuthType } from "../../AuthType"; import { ConsoleDataType } from "../../Explorer/Menus/NotificationConsole/NotificationConsoleComponent"; import { FeedOptions } from "@azure/cosmos"; @@ -281,7 +281,6 @@ export class CassandraAPIDataClient extends TableDataClient { paginationToken, }, beforeSend: this.setAuthorizationHeader, - error: this.handleAjaxError, cache: false, }); shouldNotify && @@ -444,7 +443,6 @@ export class CassandraAPIDataClient extends TableDataClient { tableId: collection.id(), }, beforeSend: this.setAuthorizationHeader, - error: this.handleAjaxError, cache: false, }) .then( @@ -494,7 +492,6 @@ export class CassandraAPIDataClient extends TableDataClient { tableId: collection.id(), }, beforeSend: this.setAuthorizationHeader, - error: this.handleAjaxError, cache: false, }) .then( @@ -533,7 +530,6 @@ export class CassandraAPIDataClient extends TableDataClient { query: query, }, beforeSend: this.setAuthorizationHeader, - error: this.handleAjaxError, cache: false, }).then( (data: any) => { @@ -582,12 +578,4 @@ export class CassandraAPIDataClient extends TableDataClient { private getCassandraPartitionKeyProperty(collection: ViewModels.Collection): string { return collection.cassandraKeys.partitionKeys[0].property; } - - private handleAjaxError = (xhrObj: XMLHttpRequest, textStatus: string, errorThrown: string): void => { - if (!xhrObj) { - return; - } - - displayTokenRenewalPromptForStatus(xhrObj.status); - }; } diff --git a/src/Main.tsx b/src/Main.tsx index a09cb71fb..ac7f77018 100644 --- a/src/Main.tsx +++ b/src/Main.tsx @@ -340,7 +340,6 @@ const App: React.FunctionComponent = () => {
-
@@ -355,33 +354,7 @@ const App: React.FunctionComponent = () => {
- {/* Global access token expiration dialog - Start */} -
-
-

Please reconnect to the account using the connection string.

-
-
{/* Global access token expiration dialog - End */} - {/* Context switch prompt - Start */} -
-
-

- Please save your work before you switch! When you switch to a different Azure Cosmos DB account, current - Data Explorer tabs will be closed. -

-

Proceed anyway?

-
-
diff --git a/src/Utils/AuthorizationUtils.test.ts b/src/Utils/AuthorizationUtils.test.ts index 08bcd31e2..8c5cbafa1 100644 --- a/src/Utils/AuthorizationUtils.test.ts +++ b/src/Utils/AuthorizationUtils.test.ts @@ -58,48 +58,4 @@ describe("AuthorizationUtils", () => { ).toBeDefined(); }); }); - - describe("displayTokenRenewalPromptForStatus()", () => { - let explorer = new Explorer() as jest.Mocked; - - beforeEach(() => { - jest.clearAllMocks(); - window.dataExplorer = explorer; - updateConfigContext({ - platform: Platform.Hosted, - }); - }); - - afterEach(() => { - window.dataExplorer = undefined; - }); - - it("should not open token renewal prompt if status code is undefined", () => { - AuthorizationUtils.displayTokenRenewalPromptForStatus(undefined); - expect(explorer.displayGuestAccessTokenRenewalPrompt).not.toHaveBeenCalled(); - }); - - it("should not open token renewal prompt if status code is null", () => { - AuthorizationUtils.displayTokenRenewalPromptForStatus(null); - expect(explorer.displayGuestAccessTokenRenewalPrompt).not.toHaveBeenCalled(); - }); - - it("should not open token renewal prompt if status code is not 401", () => { - AuthorizationUtils.displayTokenRenewalPromptForStatus(Constants.HttpStatusCodes.Forbidden); - expect(explorer.displayGuestAccessTokenRenewalPrompt).not.toHaveBeenCalled(); - }); - - it("should not open token renewal prompt if running on a different platform", () => { - updateConfigContext({ - platform: Platform.Portal, - }); - AuthorizationUtils.displayTokenRenewalPromptForStatus(Constants.HttpStatusCodes.Unauthorized); - expect(explorer.displayGuestAccessTokenRenewalPrompt).not.toHaveBeenCalled(); - }); - - it("should open token renewal prompt if running on hosted platform and status code is 401", () => { - AuthorizationUtils.displayTokenRenewalPromptForStatus(Constants.HttpStatusCodes.Unauthorized); - expect(explorer.displayGuestAccessTokenRenewalPrompt).toHaveBeenCalled(); - }); - }); }); diff --git a/src/Utils/AuthorizationUtils.ts b/src/Utils/AuthorizationUtils.ts index 2482733e0..051b827db 100644 --- a/src/Utils/AuthorizationUtils.ts +++ b/src/Utils/AuthorizationUtils.ts @@ -40,17 +40,3 @@ export function decryptJWTToken(token: string) { return JSON.parse(tokenPayload); } - -export function displayTokenRenewalPromptForStatus(httpStatusCode: number): void { - const explorer = window.dataExplorer; - - if ( - httpStatusCode == null || - httpStatusCode != Constants.HttpStatusCodes.Unauthorized || - configContext.platform !== Platform.Hosted - ) { - return; - } - - explorer.displayGuestAccessTokenRenewalPrompt(); -} diff --git a/src/hooks/useKnockoutExplorer.ts b/src/hooks/useKnockoutExplorer.ts index 3f8c1a28d..79980ad9c 100644 --- a/src/hooks/useKnockoutExplorer.ts +++ b/src/hooks/useKnockoutExplorer.ts @@ -8,6 +8,7 @@ import { ActionType, DataExplorerAction } from "../Contracts/ActionContracts"; import { MessageTypes } from "../Contracts/ExplorerContracts"; import { DataExplorerInputsFrame } from "../Contracts/ViewModels"; import Explorer, { ExplorerParams } from "../Explorer/Explorer"; +import { handleOpenAction } from "../Explorer/OpenActions"; import { AAD, ConnectionString, @@ -199,6 +200,7 @@ function configurePortal() { // Check for init message const message: PortalMessage = event.data?.data; const inputs = message?.inputs; + const openAction = message?.openAction; if (inputs) { if ( configContext.BACKEND_ENDPOINT && @@ -210,6 +212,9 @@ function configurePortal() { explorer.configure(inputs); applyExplorerBindings(explorer); + if (openAction) { + handleOpenAction(openAction, explorer.nonSystemDatabases(), explorer); + } } }, false