diff --git a/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap b/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap index fb1761d1e..7351b3d91 100644 --- a/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap +++ b/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap @@ -53,9 +53,6 @@ exports[`SettingsComponent renders 1`] = ` }, "refreshNotebookList": [Function], "resourceTokenCollection": [Function], - "resourceTokenCollectionId": [Function], - "resourceTokenDatabaseId": [Function], - "resourceTokenPartitionKey": [Function], "resourceTree": ResourceTreeAdapter { "container": [Circular], "copyNotebook": [Function], @@ -121,9 +118,6 @@ exports[`SettingsComponent renders 1`] = ` }, "refreshNotebookList": [Function], "resourceTokenCollection": [Function], - "resourceTokenCollectionId": [Function], - "resourceTokenDatabaseId": [Function], - "resourceTokenPartitionKey": [Function], "resourceTree": ResourceTreeAdapter { "container": [Circular], "copyNotebook": [Function], @@ -202,9 +196,6 @@ exports[`SettingsComponent renders 1`] = ` }, "refreshNotebookList": [Function], "resourceTokenCollection": [Function], - "resourceTokenCollectionId": [Function], - "resourceTokenDatabaseId": [Function], - "resourceTokenPartitionKey": [Function], "resourceTree": ResourceTreeAdapter { "container": [Circular], "copyNotebook": [Function], @@ -270,9 +261,6 @@ exports[`SettingsComponent renders 1`] = ` }, "refreshNotebookList": [Function], "resourceTokenCollection": [Function], - "resourceTokenCollectionId": [Function], - "resourceTokenDatabaseId": [Function], - "resourceTokenPartitionKey": [Function], "resourceTree": ResourceTreeAdapter { "container": [Circular], "copyNotebook": [Function], diff --git a/src/Explorer/Explorer.tsx b/src/Explorer/Explorer.tsx index 3119bce96..65ec636ee 100644 --- a/src/Explorer/Explorer.tsx +++ b/src/Explorer/Explorer.tsx @@ -99,10 +99,7 @@ export default class Explorer { private resourceTree: ResourceTreeAdapter; // Resource Token - public resourceTokenDatabaseId: ko.Observable; - public resourceTokenCollectionId: ko.Observable; public resourceTokenCollection: ko.Observable; - public resourceTokenPartitionKey: ko.Observable; public isResourceTokenCollectionNodeSelected: ko.Computed; public resourceTreeForResourceToken: ResourceTreeAdapterForResourceToken; @@ -177,11 +174,7 @@ export default class Explorer { this.memoryUsageInfo = ko.observable(); this.queriesClient = new QueriesClient(this); - - this.resourceTokenDatabaseId = ko.observable(); - this.resourceTokenCollectionId = ko.observable(); this.resourceTokenCollection = ko.observable(); - this.resourceTokenPartitionKey = ko.observable(); this.isSchemaEnabled = ko.computed(() => userContext.features.enableSchema); this.databases = ko.observableArray(); @@ -356,6 +349,7 @@ export default class Explorer { if (configContext.enableSchemaAnalyzer) { userContext.features.enableSchemaAnalyzer = true; } + this.isAccountReady(true); } public openEnableSynapseLinkDialog(): void { @@ -426,21 +420,17 @@ export default class Explorer { return this.selectedNode() == null; } - public refreshDatabaseForResourceToken(): Q.Promise { - const databaseId = this.resourceTokenDatabaseId(); - const collectionId = this.resourceTokenCollectionId(); + public refreshDatabaseForResourceToken(): Promise { + const databaseId = userContext.parsedResourceToken?.databaseId; + const collectionId = userContext.parsedResourceToken?.collectionId; if (!databaseId || !collectionId) { - return Q.reject(); + return Promise.reject(); } - const deferred: Q.Deferred = Q.defer(); - readCollection(databaseId, collectionId).then((collection: DataModels.Collection) => { + return readCollection(databaseId, collectionId).then((collection: DataModels.Collection) => { this.resourceTokenCollection(new ResourceTokenCollection(this, databaseId, collection)); this.selectedNode(this.resourceTokenCollection()); - deferred.resolve(); }); - - return deferred.promise; } public refreshAllDatabases(isInitialLoad?: boolean): Q.Promise { @@ -704,17 +694,6 @@ export default class Explorer { return false; } - public configure(inputs: ViewModels.DataExplorerInputsFrame): void { - if (inputs != null) { - // In development mode, save the iframe message from the portal in session storage. - // This allows webpack hot reload to funciton properly - if (process.env.NODE_ENV === "development") { - sessionStorage.setItem("portalDataExplorerInitMessage", JSON.stringify(inputs)); - } - this.isAccountReady(true); - } - } - public findSelectedCollection(): ViewModels.Collection { return (this.selectedNode().nodeKind === "Collection" ? this.selectedNode() diff --git a/src/Explorer/Panes/GitHubReposPanel/__snapshots__/GitHubReposPanel.test.tsx.snap b/src/Explorer/Panes/GitHubReposPanel/__snapshots__/GitHubReposPanel.test.tsx.snap index 8d6d78c14..4395d874b 100644 --- a/src/Explorer/Panes/GitHubReposPanel/__snapshots__/GitHubReposPanel.test.tsx.snap +++ b/src/Explorer/Panes/GitHubReposPanel/__snapshots__/GitHubReposPanel.test.tsx.snap @@ -42,9 +42,6 @@ exports[`GitHub Repos Panel should render Default properly 1`] = ` }, "refreshNotebookList": [Function], "resourceTokenCollection": [Function], - "resourceTokenCollectionId": [Function], - "resourceTokenDatabaseId": [Function], - "resourceTokenPartitionKey": [Function], "resourceTree": ResourceTreeAdapter { "container": [Circular], "copyNotebook": [Function], diff --git a/src/Explorer/Panes/StringInputPane/__snapshots__/StringInputPane.test.tsx.snap b/src/Explorer/Panes/StringInputPane/__snapshots__/StringInputPane.test.tsx.snap index 090e3a56e..b892777ee 100644 --- a/src/Explorer/Panes/StringInputPane/__snapshots__/StringInputPane.test.tsx.snap +++ b/src/Explorer/Panes/StringInputPane/__snapshots__/StringInputPane.test.tsx.snap @@ -32,9 +32,6 @@ exports[`StringInput Pane should render Create new directory properly 1`] = ` }, "refreshNotebookList": [Function], "resourceTokenCollection": [Function], - "resourceTokenCollectionId": [Function], - "resourceTokenDatabaseId": [Function], - "resourceTokenPartitionKey": [Function], "resourceTree": ResourceTreeAdapter { "container": [Circular], "copyNotebook": [Function], diff --git a/src/Explorer/Panes/__snapshots__/DeleteDatabaseConfirmationPanel.test.tsx.snap b/src/Explorer/Panes/__snapshots__/DeleteDatabaseConfirmationPanel.test.tsx.snap index ab19afbce..d7b8bedaf 100644 --- a/src/Explorer/Panes/__snapshots__/DeleteDatabaseConfirmationPanel.test.tsx.snap +++ b/src/Explorer/Panes/__snapshots__/DeleteDatabaseConfirmationPanel.test.tsx.snap @@ -34,9 +34,6 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database "refreshAllDatabases": [Function], "refreshNotebookList": [Function], "resourceTokenCollection": [Function], - "resourceTokenCollectionId": [Function], - "resourceTokenDatabaseId": [Function], - "resourceTokenPartitionKey": [Function], "resourceTree": ResourceTreeAdapter { "container": [Circular], "copyNotebook": [Function], diff --git a/src/Explorer/Tree/ResourceTokenCollection.ts b/src/Explorer/Tree/ResourceTokenCollection.ts index 08dae8ca9..45155fe0e 100644 --- a/src/Explorer/Tree/ResourceTokenCollection.ts +++ b/src/Explorer/Tree/ResourceTokenCollection.ts @@ -4,6 +4,7 @@ import * as DataModels from "../../Contracts/DataModels"; import * as ViewModels from "../../Contracts/ViewModels"; import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants"; import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor"; +import { userContext } from "../../UserContext"; import Explorer from "../Explorer"; import DocumentsTab from "../Tabs/DocumentsTab"; import QueryTab from "../Tabs/QueryTab"; @@ -93,7 +94,7 @@ export default class ResourceTokenCollection implements ViewModels.CollectionBas hashLocation: `${Constants.HashRoutePrefixes.collectionsWithIds(this.databaseId, this.id())}/query`, queryText: queryText, partitionKey: collection.partitionKey, - resourceTokenPartitionKey: this.container.resourceTokenPartitionKey(), + resourceTokenPartitionKey: userContext.parsedResourceToken.partitionKey, onLoadStartKey: startKey, }); @@ -132,7 +133,7 @@ export default class ResourceTokenCollection implements ViewModels.CollectionBas documentsTab = new DocumentsTab({ partitionKey: this.partitionKey, - resourceTokenPartitionKey: this.container.resourceTokenPartitionKey(), + resourceTokenPartitionKey: userContext.parsedResourceToken.partitionKey, documentIds: ko.observableArray([]), tabKind: ViewModels.CollectionTabKind.Documents, title: "Items", diff --git a/src/RouteHandlers/TabRouteHandler.ts b/src/RouteHandlers/TabRouteHandler.ts index 6795fae8b..82a880191 100644 --- a/src/RouteHandlers/TabRouteHandler.ts +++ b/src/RouteHandlers/TabRouteHandler.ts @@ -142,7 +142,7 @@ export class TabRouteHandler { databaseId, collectionId ); - userContext.apiType === "SQL" && collection.onDocumentDBDocumentsClick(); + userContext.apiType === "SQL" && collection?.onDocumentDBDocumentsClick(); }); } diff --git a/src/UserContext.ts b/src/UserContext.ts index 78b68ffec..96bfc2ecf 100644 --- a/src/UserContext.ts +++ b/src/UserContext.ts @@ -44,6 +44,11 @@ interface UserContext { readonly features: Features; readonly addCollectionFlight: string; readonly hasWriteAccess: boolean; + readonly parsedResourceToken?: { + databaseId: string; + collectionId: string; + partitionKey?: string; + }; collectionCreationDefaults: CollectionCreationDefaults; } diff --git a/src/hooks/useKnockoutExplorer.ts b/src/hooks/useKnockoutExplorer.ts index 4d47be346..229ced926 100644 --- a/src/hooks/useKnockoutExplorer.ts +++ b/src/hooks/useKnockoutExplorer.ts @@ -120,9 +120,6 @@ async function configureHostedWithAAD(config: AAD, explorerParams: ExplorerParam masterKey: keys.primaryMasterKey, }); const explorer = new Explorer(explorerParams); - explorer.configure({ - databaseAccount: account, - }); return explorer; } @@ -145,9 +142,6 @@ function configureHostedWithConnectionString(config: ConnectionString, explorerP masterKey: config.masterKey, }); const explorer = new Explorer(explorerParams); - explorer.configure({ - databaseAccount, - }); return explorer; } @@ -166,33 +160,31 @@ function configureHostedWithResourceToken(config: ResourceToken, explorerParams: authType: AuthType.ResourceToken, resourceToken: parsedResourceToken.resourceToken, endpoint: parsedResourceToken.accountEndpoint, + parsedResourceToken: { + databaseId: parsedResourceToken.databaseId, + collectionId: parsedResourceToken.collectionId, + partitionKey: parsedResourceToken.partitionKey, + }, }); const explorer = new Explorer(explorerParams); - explorer.resourceTokenDatabaseId(parsedResourceToken.databaseId); - explorer.resourceTokenCollectionId(parsedResourceToken.collectionId); - if (parsedResourceToken.partitionKey) { - explorer.resourceTokenPartitionKey(parsedResourceToken.partitionKey); - } - explorer.configure({ databaseAccount }); return explorer; } function configureHostedWithEncryptedToken(config: EncryptedToken, explorerParams: ExplorerParams): Explorer { + const apiExperience = DefaultExperienceUtility.getDefaultExperienceFromApiKind(config.encryptedTokenMetadata.apiKind); updateUserContext({ authType: AuthType.EncryptedToken, accessToken: encodeURIComponent(config.encryptedToken), - }); - const apiExperience = DefaultExperienceUtility.getDefaultExperienceFromApiKind(config.encryptedTokenMetadata.apiKind); - const explorer = new Explorer(explorerParams); - explorer.configure({ databaseAccount: { id: "", + location: "", + type: "", name: config.encryptedTokenMetadata.accountName, kind: getDatabaseAccountKindFromExperience(apiExperience), properties: getDatabaseAccountPropertiesFromMetadata(config.encryptedTokenMetadata), - tags: {}, }, }); + const explorer = new Explorer(explorerParams); return explorer; } @@ -223,7 +215,11 @@ async function configurePortal(explorerParams: ExplorerParams): Promise