Remove Explorer.configure (#884)
This commit is contained in:
parent
006230262c
commit
fc9f287d0a
|
@ -53,9 +53,6 @@ exports[`SettingsComponent renders 1`] = `
|
||||||
},
|
},
|
||||||
"refreshNotebookList": [Function],
|
"refreshNotebookList": [Function],
|
||||||
"resourceTokenCollection": [Function],
|
"resourceTokenCollection": [Function],
|
||||||
"resourceTokenCollectionId": [Function],
|
|
||||||
"resourceTokenDatabaseId": [Function],
|
|
||||||
"resourceTokenPartitionKey": [Function],
|
|
||||||
"resourceTree": ResourceTreeAdapter {
|
"resourceTree": ResourceTreeAdapter {
|
||||||
"container": [Circular],
|
"container": [Circular],
|
||||||
"copyNotebook": [Function],
|
"copyNotebook": [Function],
|
||||||
|
@ -121,9 +118,6 @@ exports[`SettingsComponent renders 1`] = `
|
||||||
},
|
},
|
||||||
"refreshNotebookList": [Function],
|
"refreshNotebookList": [Function],
|
||||||
"resourceTokenCollection": [Function],
|
"resourceTokenCollection": [Function],
|
||||||
"resourceTokenCollectionId": [Function],
|
|
||||||
"resourceTokenDatabaseId": [Function],
|
|
||||||
"resourceTokenPartitionKey": [Function],
|
|
||||||
"resourceTree": ResourceTreeAdapter {
|
"resourceTree": ResourceTreeAdapter {
|
||||||
"container": [Circular],
|
"container": [Circular],
|
||||||
"copyNotebook": [Function],
|
"copyNotebook": [Function],
|
||||||
|
@ -202,9 +196,6 @@ exports[`SettingsComponent renders 1`] = `
|
||||||
},
|
},
|
||||||
"refreshNotebookList": [Function],
|
"refreshNotebookList": [Function],
|
||||||
"resourceTokenCollection": [Function],
|
"resourceTokenCollection": [Function],
|
||||||
"resourceTokenCollectionId": [Function],
|
|
||||||
"resourceTokenDatabaseId": [Function],
|
|
||||||
"resourceTokenPartitionKey": [Function],
|
|
||||||
"resourceTree": ResourceTreeAdapter {
|
"resourceTree": ResourceTreeAdapter {
|
||||||
"container": [Circular],
|
"container": [Circular],
|
||||||
"copyNotebook": [Function],
|
"copyNotebook": [Function],
|
||||||
|
@ -270,9 +261,6 @@ exports[`SettingsComponent renders 1`] = `
|
||||||
},
|
},
|
||||||
"refreshNotebookList": [Function],
|
"refreshNotebookList": [Function],
|
||||||
"resourceTokenCollection": [Function],
|
"resourceTokenCollection": [Function],
|
||||||
"resourceTokenCollectionId": [Function],
|
|
||||||
"resourceTokenDatabaseId": [Function],
|
|
||||||
"resourceTokenPartitionKey": [Function],
|
|
||||||
"resourceTree": ResourceTreeAdapter {
|
"resourceTree": ResourceTreeAdapter {
|
||||||
"container": [Circular],
|
"container": [Circular],
|
||||||
"copyNotebook": [Function],
|
"copyNotebook": [Function],
|
||||||
|
|
|
@ -99,10 +99,7 @@ export default class Explorer {
|
||||||
private resourceTree: ResourceTreeAdapter;
|
private resourceTree: ResourceTreeAdapter;
|
||||||
|
|
||||||
// Resource Token
|
// Resource Token
|
||||||
public resourceTokenDatabaseId: ko.Observable<string>;
|
|
||||||
public resourceTokenCollectionId: ko.Observable<string>;
|
|
||||||
public resourceTokenCollection: ko.Observable<ViewModels.CollectionBase>;
|
public resourceTokenCollection: ko.Observable<ViewModels.CollectionBase>;
|
||||||
public resourceTokenPartitionKey: ko.Observable<string>;
|
|
||||||
public isResourceTokenCollectionNodeSelected: ko.Computed<boolean>;
|
public isResourceTokenCollectionNodeSelected: ko.Computed<boolean>;
|
||||||
public resourceTreeForResourceToken: ResourceTreeAdapterForResourceToken;
|
public resourceTreeForResourceToken: ResourceTreeAdapterForResourceToken;
|
||||||
|
|
||||||
|
@ -177,11 +174,7 @@ export default class Explorer {
|
||||||
this.memoryUsageInfo = ko.observable<DataModels.MemoryUsageInfo>();
|
this.memoryUsageInfo = ko.observable<DataModels.MemoryUsageInfo>();
|
||||||
|
|
||||||
this.queriesClient = new QueriesClient(this);
|
this.queriesClient = new QueriesClient(this);
|
||||||
|
|
||||||
this.resourceTokenDatabaseId = ko.observable<string>();
|
|
||||||
this.resourceTokenCollectionId = ko.observable<string>();
|
|
||||||
this.resourceTokenCollection = ko.observable<ViewModels.CollectionBase>();
|
this.resourceTokenCollection = ko.observable<ViewModels.CollectionBase>();
|
||||||
this.resourceTokenPartitionKey = ko.observable<string>();
|
|
||||||
this.isSchemaEnabled = ko.computed<boolean>(() => userContext.features.enableSchema);
|
this.isSchemaEnabled = ko.computed<boolean>(() => userContext.features.enableSchema);
|
||||||
|
|
||||||
this.databases = ko.observableArray<ViewModels.Database>();
|
this.databases = ko.observableArray<ViewModels.Database>();
|
||||||
|
@ -356,6 +349,7 @@ export default class Explorer {
|
||||||
if (configContext.enableSchemaAnalyzer) {
|
if (configContext.enableSchemaAnalyzer) {
|
||||||
userContext.features.enableSchemaAnalyzer = true;
|
userContext.features.enableSchemaAnalyzer = true;
|
||||||
}
|
}
|
||||||
|
this.isAccountReady(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public openEnableSynapseLinkDialog(): void {
|
public openEnableSynapseLinkDialog(): void {
|
||||||
|
@ -426,21 +420,17 @@ export default class Explorer {
|
||||||
return this.selectedNode() == null;
|
return this.selectedNode() == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public refreshDatabaseForResourceToken(): Q.Promise<any> {
|
public refreshDatabaseForResourceToken(): Promise<void> {
|
||||||
const databaseId = this.resourceTokenDatabaseId();
|
const databaseId = userContext.parsedResourceToken?.databaseId;
|
||||||
const collectionId = this.resourceTokenCollectionId();
|
const collectionId = userContext.parsedResourceToken?.collectionId;
|
||||||
if (!databaseId || !collectionId) {
|
if (!databaseId || !collectionId) {
|
||||||
return Q.reject();
|
return Promise.reject();
|
||||||
}
|
}
|
||||||
|
|
||||||
const deferred: Q.Deferred<void> = Q.defer();
|
return readCollection(databaseId, collectionId).then((collection: DataModels.Collection) => {
|
||||||
readCollection(databaseId, collectionId).then((collection: DataModels.Collection) => {
|
|
||||||
this.resourceTokenCollection(new ResourceTokenCollection(this, databaseId, collection));
|
this.resourceTokenCollection(new ResourceTokenCollection(this, databaseId, collection));
|
||||||
this.selectedNode(this.resourceTokenCollection());
|
this.selectedNode(this.resourceTokenCollection());
|
||||||
deferred.resolve();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return deferred.promise;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public refreshAllDatabases(isInitialLoad?: boolean): Q.Promise<any> {
|
public refreshAllDatabases(isInitialLoad?: boolean): Q.Promise<any> {
|
||||||
|
@ -704,17 +694,6 @@ export default class Explorer {
|
||||||
return false;
|
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 {
|
public findSelectedCollection(): ViewModels.Collection {
|
||||||
return (this.selectedNode().nodeKind === "Collection"
|
return (this.selectedNode().nodeKind === "Collection"
|
||||||
? this.selectedNode()
|
? this.selectedNode()
|
||||||
|
|
|
@ -42,9 +42,6 @@ exports[`GitHub Repos Panel should render Default properly 1`] = `
|
||||||
},
|
},
|
||||||
"refreshNotebookList": [Function],
|
"refreshNotebookList": [Function],
|
||||||
"resourceTokenCollection": [Function],
|
"resourceTokenCollection": [Function],
|
||||||
"resourceTokenCollectionId": [Function],
|
|
||||||
"resourceTokenDatabaseId": [Function],
|
|
||||||
"resourceTokenPartitionKey": [Function],
|
|
||||||
"resourceTree": ResourceTreeAdapter {
|
"resourceTree": ResourceTreeAdapter {
|
||||||
"container": [Circular],
|
"container": [Circular],
|
||||||
"copyNotebook": [Function],
|
"copyNotebook": [Function],
|
||||||
|
|
|
@ -32,9 +32,6 @@ exports[`StringInput Pane should render Create new directory properly 1`] = `
|
||||||
},
|
},
|
||||||
"refreshNotebookList": [Function],
|
"refreshNotebookList": [Function],
|
||||||
"resourceTokenCollection": [Function],
|
"resourceTokenCollection": [Function],
|
||||||
"resourceTokenCollectionId": [Function],
|
|
||||||
"resourceTokenDatabaseId": [Function],
|
|
||||||
"resourceTokenPartitionKey": [Function],
|
|
||||||
"resourceTree": ResourceTreeAdapter {
|
"resourceTree": ResourceTreeAdapter {
|
||||||
"container": [Circular],
|
"container": [Circular],
|
||||||
"copyNotebook": [Function],
|
"copyNotebook": [Function],
|
||||||
|
|
|
@ -34,9 +34,6 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database
|
||||||
"refreshAllDatabases": [Function],
|
"refreshAllDatabases": [Function],
|
||||||
"refreshNotebookList": [Function],
|
"refreshNotebookList": [Function],
|
||||||
"resourceTokenCollection": [Function],
|
"resourceTokenCollection": [Function],
|
||||||
"resourceTokenCollectionId": [Function],
|
|
||||||
"resourceTokenDatabaseId": [Function],
|
|
||||||
"resourceTokenPartitionKey": [Function],
|
|
||||||
"resourceTree": ResourceTreeAdapter {
|
"resourceTree": ResourceTreeAdapter {
|
||||||
"container": [Circular],
|
"container": [Circular],
|
||||||
"copyNotebook": [Function],
|
"copyNotebook": [Function],
|
||||||
|
|
|
@ -4,6 +4,7 @@ import * as DataModels from "../../Contracts/DataModels";
|
||||||
import * as ViewModels from "../../Contracts/ViewModels";
|
import * as ViewModels from "../../Contracts/ViewModels";
|
||||||
import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants";
|
import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants";
|
||||||
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
||||||
|
import { userContext } from "../../UserContext";
|
||||||
import Explorer from "../Explorer";
|
import Explorer from "../Explorer";
|
||||||
import DocumentsTab from "../Tabs/DocumentsTab";
|
import DocumentsTab from "../Tabs/DocumentsTab";
|
||||||
import QueryTab from "../Tabs/QueryTab";
|
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`,
|
hashLocation: `${Constants.HashRoutePrefixes.collectionsWithIds(this.databaseId, this.id())}/query`,
|
||||||
queryText: queryText,
|
queryText: queryText,
|
||||||
partitionKey: collection.partitionKey,
|
partitionKey: collection.partitionKey,
|
||||||
resourceTokenPartitionKey: this.container.resourceTokenPartitionKey(),
|
resourceTokenPartitionKey: userContext.parsedResourceToken.partitionKey,
|
||||||
onLoadStartKey: startKey,
|
onLoadStartKey: startKey,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -132,7 +133,7 @@ export default class ResourceTokenCollection implements ViewModels.CollectionBas
|
||||||
|
|
||||||
documentsTab = new DocumentsTab({
|
documentsTab = new DocumentsTab({
|
||||||
partitionKey: this.partitionKey,
|
partitionKey: this.partitionKey,
|
||||||
resourceTokenPartitionKey: this.container.resourceTokenPartitionKey(),
|
resourceTokenPartitionKey: userContext.parsedResourceToken.partitionKey,
|
||||||
documentIds: ko.observableArray<DocumentId>([]),
|
documentIds: ko.observableArray<DocumentId>([]),
|
||||||
tabKind: ViewModels.CollectionTabKind.Documents,
|
tabKind: ViewModels.CollectionTabKind.Documents,
|
||||||
title: "Items",
|
title: "Items",
|
||||||
|
|
|
@ -142,7 +142,7 @@ export class TabRouteHandler {
|
||||||
databaseId,
|
databaseId,
|
||||||
collectionId
|
collectionId
|
||||||
);
|
);
|
||||||
userContext.apiType === "SQL" && collection.onDocumentDBDocumentsClick();
|
userContext.apiType === "SQL" && collection?.onDocumentDBDocumentsClick();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,11 @@ interface UserContext {
|
||||||
readonly features: Features;
|
readonly features: Features;
|
||||||
readonly addCollectionFlight: string;
|
readonly addCollectionFlight: string;
|
||||||
readonly hasWriteAccess: boolean;
|
readonly hasWriteAccess: boolean;
|
||||||
|
readonly parsedResourceToken?: {
|
||||||
|
databaseId: string;
|
||||||
|
collectionId: string;
|
||||||
|
partitionKey?: string;
|
||||||
|
};
|
||||||
collectionCreationDefaults: CollectionCreationDefaults;
|
collectionCreationDefaults: CollectionCreationDefaults;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -120,9 +120,6 @@ async function configureHostedWithAAD(config: AAD, explorerParams: ExplorerParam
|
||||||
masterKey: keys.primaryMasterKey,
|
masterKey: keys.primaryMasterKey,
|
||||||
});
|
});
|
||||||
const explorer = new Explorer(explorerParams);
|
const explorer = new Explorer(explorerParams);
|
||||||
explorer.configure({
|
|
||||||
databaseAccount: account,
|
|
||||||
});
|
|
||||||
return explorer;
|
return explorer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,9 +142,6 @@ function configureHostedWithConnectionString(config: ConnectionString, explorerP
|
||||||
masterKey: config.masterKey,
|
masterKey: config.masterKey,
|
||||||
});
|
});
|
||||||
const explorer = new Explorer(explorerParams);
|
const explorer = new Explorer(explorerParams);
|
||||||
explorer.configure({
|
|
||||||
databaseAccount,
|
|
||||||
});
|
|
||||||
return explorer;
|
return explorer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,33 +160,31 @@ function configureHostedWithResourceToken(config: ResourceToken, explorerParams:
|
||||||
authType: AuthType.ResourceToken,
|
authType: AuthType.ResourceToken,
|
||||||
resourceToken: parsedResourceToken.resourceToken,
|
resourceToken: parsedResourceToken.resourceToken,
|
||||||
endpoint: parsedResourceToken.accountEndpoint,
|
endpoint: parsedResourceToken.accountEndpoint,
|
||||||
|
parsedResourceToken: {
|
||||||
|
databaseId: parsedResourceToken.databaseId,
|
||||||
|
collectionId: parsedResourceToken.collectionId,
|
||||||
|
partitionKey: parsedResourceToken.partitionKey,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
const explorer = new Explorer(explorerParams);
|
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;
|
return explorer;
|
||||||
}
|
}
|
||||||
|
|
||||||
function configureHostedWithEncryptedToken(config: EncryptedToken, explorerParams: ExplorerParams): Explorer {
|
function configureHostedWithEncryptedToken(config: EncryptedToken, explorerParams: ExplorerParams): Explorer {
|
||||||
|
const apiExperience = DefaultExperienceUtility.getDefaultExperienceFromApiKind(config.encryptedTokenMetadata.apiKind);
|
||||||
updateUserContext({
|
updateUserContext({
|
||||||
authType: AuthType.EncryptedToken,
|
authType: AuthType.EncryptedToken,
|
||||||
accessToken: encodeURIComponent(config.encryptedToken),
|
accessToken: encodeURIComponent(config.encryptedToken),
|
||||||
});
|
|
||||||
const apiExperience = DefaultExperienceUtility.getDefaultExperienceFromApiKind(config.encryptedTokenMetadata.apiKind);
|
|
||||||
const explorer = new Explorer(explorerParams);
|
|
||||||
explorer.configure({
|
|
||||||
databaseAccount: {
|
databaseAccount: {
|
||||||
id: "",
|
id: "",
|
||||||
|
location: "",
|
||||||
|
type: "",
|
||||||
name: config.encryptedTokenMetadata.accountName,
|
name: config.encryptedTokenMetadata.accountName,
|
||||||
kind: getDatabaseAccountKindFromExperience(apiExperience),
|
kind: getDatabaseAccountKindFromExperience(apiExperience),
|
||||||
properties: getDatabaseAccountPropertiesFromMetadata(config.encryptedTokenMetadata),
|
properties: getDatabaseAccountPropertiesFromMetadata(config.encryptedTokenMetadata),
|
||||||
tags: {},
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
const explorer = new Explorer(explorerParams);
|
||||||
return explorer;
|
return explorer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,7 +215,11 @@ async function configurePortal(explorerParams: ExplorerParams): Promise<Explorer
|
||||||
console.dir(message);
|
console.dir(message);
|
||||||
updateContextsFromPortalMessage(message);
|
updateContextsFromPortalMessage(message);
|
||||||
const explorer = new Explorer(explorerParams);
|
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);
|
resolve(explorer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -255,7 +251,6 @@ async function configurePortal(explorerParams: ExplorerParams): Promise<Explorer
|
||||||
|
|
||||||
updateContextsFromPortalMessage(inputs);
|
updateContextsFromPortalMessage(inputs);
|
||||||
const explorer = new Explorer(explorerParams);
|
const explorer = new Explorer(explorerParams);
|
||||||
explorer.configure(inputs);
|
|
||||||
resolve(explorer);
|
resolve(explorer);
|
||||||
if (openAction) {
|
if (openAction) {
|
||||||
handleOpenAction(openAction, explorer.databases(), explorer);
|
handleOpenAction(openAction, explorer.databases(), explorer);
|
||||||
|
|
Loading…
Reference in New Issue