Remove Explorer.configure (#884)

This commit is contained in:
Steve Faulkner 2021-06-10 17:02:07 -07:00 committed by GitHub
parent 006230262c
commit fc9f287d0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 29 additions and 70 deletions

View File

@ -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],

View File

@ -99,10 +99,7 @@ export default class Explorer {
private resourceTree: ResourceTreeAdapter;
// Resource Token
public resourceTokenDatabaseId: ko.Observable<string>;
public resourceTokenCollectionId: ko.Observable<string>;
public resourceTokenCollection: ko.Observable<ViewModels.CollectionBase>;
public resourceTokenPartitionKey: ko.Observable<string>;
public isResourceTokenCollectionNodeSelected: ko.Computed<boolean>;
public resourceTreeForResourceToken: ResourceTreeAdapterForResourceToken;
@ -177,11 +174,7 @@ export default class Explorer {
this.memoryUsageInfo = ko.observable<DataModels.MemoryUsageInfo>();
this.queriesClient = new QueriesClient(this);
this.resourceTokenDatabaseId = ko.observable<string>();
this.resourceTokenCollectionId = ko.observable<string>();
this.resourceTokenCollection = ko.observable<ViewModels.CollectionBase>();
this.resourceTokenPartitionKey = ko.observable<string>();
this.isSchemaEnabled = ko.computed<boolean>(() => userContext.features.enableSchema);
this.databases = ko.observableArray<ViewModels.Database>();
@ -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<any> {
const databaseId = this.resourceTokenDatabaseId();
const collectionId = this.resourceTokenCollectionId();
public refreshDatabaseForResourceToken(): Promise<void> {
const databaseId = userContext.parsedResourceToken?.databaseId;
const collectionId = userContext.parsedResourceToken?.collectionId;
if (!databaseId || !collectionId) {
return Q.reject();
return Promise.reject();
}
const deferred: Q.Deferred<void> = 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<any> {
@ -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()

View File

@ -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],

View File

@ -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],

View File

@ -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],

View File

@ -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<DocumentId>([]),
tabKind: ViewModels.CollectionTabKind.Documents,
title: "Items",

View File

@ -142,7 +142,7 @@ export class TabRouteHandler {
databaseId,
collectionId
);
userContext.apiType === "SQL" && collection.onDocumentDBDocumentsClick();
userContext.apiType === "SQL" && collection?.onDocumentDBDocumentsClick();
});
}

View File

@ -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;
}

View File

@ -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<Explorer
console.dir(message);
updateContextsFromPortalMessage(message);
const explorer = new Explorer(explorerParams);
explorer.configure(message);
// 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(message));
}
resolve(explorer);
}
}
@ -255,7 +251,6 @@ async function configurePortal(explorerParams: ExplorerParams): Promise<Explorer
updateContextsFromPortalMessage(inputs);
const explorer = new Explorer(explorerParams);
explorer.configure(inputs);
resolve(explorer);
if (openAction) {
handleOpenAction(openAction, explorer.databases(), explorer);