mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-21 09:51:11 +00:00
Remove Explorer Stub and ViewModel.Explorer (#101)
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import * as ViewModels from "../../Contracts/ViewModels";
|
||||
import { AccountKind, TagNames, DefaultAccountExperience } from "../../Common/Constants";
|
||||
|
||||
import Explorer from "../../Explorer/Explorer";
|
||||
@@ -8,7 +7,7 @@ import DocumentClientUtilityBase from "../../Common/DocumentClientUtilityBase";
|
||||
import { DataAccessUtility } from "./DataAccessUtility";
|
||||
|
||||
export default class EmulatorExplorerFactory {
|
||||
public static createExplorer(): ViewModels.Explorer {
|
||||
public static createExplorer(): Explorer {
|
||||
DocumentClientUtilityBase;
|
||||
const documentClientUtility: DocumentClientUtilityBase = new DocumentClientUtilityBase(new DataAccessUtility());
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import * as ViewModels from "../../Contracts/ViewModels";
|
||||
import EmulatorExplorerFactory from "./ExplorerFactory";
|
||||
import Explorer from "../../Explorer/Explorer";
|
||||
|
||||
export function initializeExplorer(): ViewModels.Explorer {
|
||||
const explorer = EmulatorExplorerFactory.createExplorer();
|
||||
return explorer;
|
||||
export function initializeExplorer(): Explorer {
|
||||
return EmulatorExplorerFactory.createExplorer();
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ export default class AuthHeadersUtil {
|
||||
const url: string = `${
|
||||
AuthHeadersUtil.extensionEndpoint
|
||||
}/api/tokens/generateToken${AuthHeadersUtil._generateResourceUrl()}`;
|
||||
const explorer: ViewModels.Explorer = (<any>window).dataExplorer;
|
||||
const explorer = window.dataExplorer;
|
||||
const headers: any = { authorization: CosmosClient.authorizationToken() };
|
||||
headers[Constants.HttpHeaders.getReadOnlyKey] = !explorer.hasWriteAccess();
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import DocumentClientUtilityBase from "../../Common/DocumentClientUtilityBase";
|
||||
import { DataAccessUtility } from "./DataAccessUtility";
|
||||
|
||||
export default class HostedExplorerFactory {
|
||||
public createExplorer(): ViewModels.Explorer {
|
||||
public createExplorer(): Explorer {
|
||||
var documentClientUtility = new DocumentClientUtilityBase(new DataAccessUtility());
|
||||
|
||||
const explorer = new Explorer({
|
||||
@@ -17,7 +17,7 @@ export default class HostedExplorerFactory {
|
||||
return explorer;
|
||||
}
|
||||
|
||||
public static reInitializeDocumentClientUtilityForExplorer(explorer: ViewModels.Explorer): void {
|
||||
public static reInitializeDocumentClientUtilityForExplorer(explorer: Explorer): void {
|
||||
if (!!explorer) {
|
||||
const documentClientUtility = new DocumentClientUtilityBase(new DataAccessUtility());
|
||||
explorer.rebindDocumentClientUtility(documentClientUtility);
|
||||
|
||||
@@ -23,6 +23,7 @@ import { MessageTypes } from "../../Contracts/ExplorerContracts";
|
||||
import { SessionStorageUtility, StorageKey } from "../../Shared/StorageUtility";
|
||||
import { SubscriptionUtilMappings } from "../../Shared/Constants";
|
||||
import "../../Explorer/Tables/DataTable/DataTableBindingManager";
|
||||
import Explorer from "../../Explorer/Explorer";
|
||||
|
||||
export default class Main {
|
||||
private static _databaseAccountId: string;
|
||||
@@ -32,8 +33,8 @@ export default class Main {
|
||||
private static _features: { [key: string]: string };
|
||||
// For AAD, Need to post message to hosted frame to do the auth
|
||||
// Use local deferred variable as work around until we find better solution
|
||||
private static _getAadAccessDeferred: Q.Deferred<ViewModels.Explorer>;
|
||||
private static _explorer: ViewModels.Explorer;
|
||||
private static _getAadAccessDeferred: Q.Deferred<Explorer>;
|
||||
private static _explorer: Explorer;
|
||||
|
||||
public static isUsingEncryptionToken(): boolean {
|
||||
const params = new URLSearchParams(window.parent.location.search);
|
||||
@@ -43,11 +44,11 @@ export default class Main {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static initializeExplorer(): Q.Promise<ViewModels.Explorer> {
|
||||
public static initializeExplorer(): Q.Promise<Explorer> {
|
||||
window.addEventListener("message", this._handleMessage.bind(this), false);
|
||||
this._features = {};
|
||||
const params = new URLSearchParams(window.parent.location.search);
|
||||
const deferred: Q.Deferred<ViewModels.Explorer> = Q.defer<ViewModels.Explorer>();
|
||||
const deferred: Q.Deferred<Explorer> = Q.defer<Explorer>();
|
||||
let authType: string = null;
|
||||
|
||||
// Encrypted token flow
|
||||
@@ -74,7 +75,7 @@ export default class Main {
|
||||
return Q.reject("Sign in needed");
|
||||
}
|
||||
|
||||
const explorer: ViewModels.Explorer = this._instantiateExplorer();
|
||||
const explorer: Explorer = this._instantiateExplorer();
|
||||
if (authType === AuthType.EncryptedToken) {
|
||||
MessageHandler.sendMessage({
|
||||
type: MessageTypes.UpdateAccountSwitch,
|
||||
@@ -109,7 +110,7 @@ export default class Main {
|
||||
return Q(null);
|
||||
}
|
||||
this._explorer = explorer;
|
||||
this._getAadAccessDeferred = Q.defer<ViewModels.Explorer>();
|
||||
this._getAadAccessDeferred = Q.defer<Explorer>();
|
||||
return this._getAadAccessDeferred.promise.finally(() => {
|
||||
this._getAadAccessDeferred = null;
|
||||
});
|
||||
@@ -135,7 +136,7 @@ export default class Main {
|
||||
return features;
|
||||
}
|
||||
|
||||
public static configureTokenValidationDisplayPrompt(explorer: ViewModels.Explorer): void {
|
||||
public static configureTokenValidationDisplayPrompt(explorer: Explorer): void {
|
||||
const authType: AuthType = (<any>window).authType;
|
||||
if (
|
||||
!explorer ||
|
||||
@@ -182,7 +183,7 @@ export default class Main {
|
||||
};
|
||||
}
|
||||
|
||||
public static renewExplorerAccess = (explorer: ViewModels.Explorer, connectionString: string): Q.Promise<void> => {
|
||||
public static renewExplorerAccess = (explorer: Explorer, connectionString: string): Q.Promise<void> => {
|
||||
if (!connectionString) {
|
||||
console.error("Missing or invalid connection string input");
|
||||
Q.reject("Missing or invalid connection string input");
|
||||
@@ -249,7 +250,7 @@ export default class Main {
|
||||
return deferred.promise.timeout(Constants.ClientDefaults.requestTimeoutMs);
|
||||
};
|
||||
|
||||
public static getUninitializedExplorerForGuestAccess(): ViewModels.Explorer {
|
||||
public static getUninitializedExplorerForGuestAccess(): Explorer {
|
||||
const explorer = Main._instantiateExplorer();
|
||||
if (window.authType === AuthType.AAD) {
|
||||
this._explorer = explorer;
|
||||
@@ -260,7 +261,7 @@ export default class Main {
|
||||
}
|
||||
|
||||
private static _initDataExplorerFrameInputs(
|
||||
explorer: ViewModels.Explorer,
|
||||
explorer: Explorer,
|
||||
masterKey?: string /* master key extracted from connection string if available */,
|
||||
account?: DatabaseAccount,
|
||||
authorizationToken?: string /* access key */
|
||||
@@ -372,7 +373,7 @@ export default class Main {
|
||||
return Q.reject(`Unsupported AuthType ${authType}`);
|
||||
}
|
||||
|
||||
private static _instantiateExplorer(): ViewModels.Explorer {
|
||||
private static _instantiateExplorer(): Explorer {
|
||||
const hostedExplorerFactory = new HostedExplorerFactory();
|
||||
const explorer = hostedExplorerFactory.createExplorer();
|
||||
// workaround to resolve cyclic refs with view
|
||||
@@ -395,7 +396,7 @@ export default class Main {
|
||||
return explorer;
|
||||
}
|
||||
|
||||
private static _showGuestAccessTokenRenewalPromptInMs(explorer: ViewModels.Explorer, interval: number): void {
|
||||
private static _showGuestAccessTokenRenewalPromptInMs(explorer: Explorer, interval: number): void {
|
||||
if (interval != null && !isNaN(interval)) {
|
||||
setTimeout(() => {
|
||||
explorer.displayGuestAccessTokenRenewalPrompt();
|
||||
@@ -454,7 +455,7 @@ export default class Main {
|
||||
}
|
||||
|
||||
private static _renewExplorerAccessWithResourceToken = (
|
||||
explorer: ViewModels.Explorer,
|
||||
explorer: Explorer,
|
||||
connectionString: string
|
||||
): Q.Promise<void> => {
|
||||
window.authType = AuthType.ResourceToken;
|
||||
@@ -506,7 +507,7 @@ export default class Main {
|
||||
};
|
||||
|
||||
private static _setExplorerReady(
|
||||
explorer: ViewModels.Explorer,
|
||||
explorer: Explorer,
|
||||
masterKey?: string,
|
||||
account?: DatabaseAccount,
|
||||
authorizationToken?: string
|
||||
|
||||
@@ -70,7 +70,7 @@ export class DataAccessUtility extends DataAccessUtilityBase {
|
||||
options: any
|
||||
): Q.Promise<void> {
|
||||
const deferred: Q.Deferred<void> = Q.defer<void>();
|
||||
const explorer: ViewModels.Explorer = (<any>window).dataExplorer;
|
||||
const explorer = window.dataExplorer;
|
||||
const url: string = `${explorer.extensionEndpoint()}/api/offerthroughputrequest/updatebeyondspecifiedlimit`;
|
||||
const authorizationHeader: ViewModels.AuthorizationTokenHeaderMetadata = getAuthorizationHeader();
|
||||
const requestOptions: any = _.extend({}, options, {});
|
||||
|
||||
@@ -6,7 +6,7 @@ import DocumentClientUtilityBase from "../../Common/DocumentClientUtilityBase";
|
||||
import { DataAccessUtility } from "./DataAccessUtility";
|
||||
|
||||
export default class PortalExplorerFactory {
|
||||
public createExplorer(): ViewModels.Explorer {
|
||||
public createExplorer(): Explorer {
|
||||
var documentClientUtility = new DocumentClientUtilityBase(new DataAccessUtility());
|
||||
|
||||
var explorer = new Explorer({
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import * as ViewModels from "../../Contracts/ViewModels";
|
||||
import PortalExplorerFactory from "./ExplorerFactory";
|
||||
import "../../Explorer/Tables/DataTable/DataTableBindingManager";
|
||||
import Explorer from "../../Explorer/Explorer";
|
||||
|
||||
export function initializeExplorer(): ViewModels.Explorer {
|
||||
export function initializeExplorer(): Explorer {
|
||||
const portalExplorerFactory = new PortalExplorerFactory();
|
||||
const explorer = portalExplorerFactory.createExplorer();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user