Refactor DocumentClientUtilityBase to not be a class (#115)

This commit is contained in:
Steve Faulkner
2020-07-27 12:58:27 -05:00
committed by GitHub
parent 6d142f16f9
commit 2e49ed45c3
48 changed files with 1567 additions and 1754 deletions

View File

@@ -21,6 +21,13 @@ import DeleteIcon from "../../../images/delete.svg";
import { QueryIterator, ItemDefinition, Resource, ConflictDefinition } from "@azure/cosmos";
import { MinimalQueryIterator } from "../../Common/IteratorUtilities";
import Explorer from "../Explorer";
import {
queryConflicts,
deleteConflict,
deleteDocument,
createDocument,
updateDocument
} from "../../Common/DocumentClientUtilityBase";
export default class ConflictsTab extends TabsBase {
public selectedConflictId: ko.Observable<ViewModels.ConflictId>;
@@ -286,7 +293,7 @@ export default class ConflictsTab extends TabsBase {
if (selectedConflict.operationType === Constants.ConflictOperationType.Replace) {
const documentContent = JSON.parse(this.selectedConflictContent());
operationPromise = this._container.documentClientUtility.updateDocument(
operationPromise = updateDocument(
this.collection,
selectedConflict.buildDocumentIdFromConflict(documentContent[selectedConflict.partitionKeyProperty]),
documentContent
@@ -296,13 +303,13 @@ export default class ConflictsTab extends TabsBase {
if (selectedConflict.operationType === Constants.ConflictOperationType.Create) {
const documentContent = JSON.parse(this.selectedConflictContent());
operationPromise = this._container.documentClientUtility.createDocument(this.collection, documentContent);
operationPromise = createDocument(this.collection, documentContent);
}
if (selectedConflict.operationType === Constants.ConflictOperationType.Delete && !!this.selectedConflictContent()) {
const documentContent = JSON.parse(this.selectedConflictContent());
operationPromise = this._container.documentClientUtility.deleteDocument(
operationPromise = deleteDocument(
this.collection,
selectedConflict.buildDocumentIdFromConflict(documentContent[selectedConflict.partitionKeyProperty])
);
@@ -311,7 +318,7 @@ export default class ConflictsTab extends TabsBase {
return operationPromise
.then(
() => {
return this._container.documentClientUtility.deleteConflict(this.collection, selectedConflict).then(() => {
return deleteConflict(this.collection, selectedConflict).then(() => {
this.conflictIds.remove((conflictId: ViewModels.ConflictId) => conflictId.rid === selectedConflict.rid);
this.selectedConflictContent("");
this.selectedConflictCurrent("");
@@ -370,8 +377,7 @@ export default class ConflictsTab extends TabsBase {
conflictResourceId: selectedConflict.resourceId
});
return this._container.documentClientUtility
.deleteConflict(this.collection, selectedConflict)
return deleteConflict(this.collection, selectedConflict)
.then(
() => {
this.conflictIds.remove((conflictId: ViewModels.ConflictId) => conflictId.rid === selectedConflict.rid);
@@ -491,7 +497,7 @@ export default class ConflictsTab extends TabsBase {
const query: string = undefined;
let options: any = {};
options.enableCrossPartitionQuery = HeadersUtility.shouldEnableCrossPartitionKey();
return this.documentClientUtility.queryConflicts(this.collection.databaseId, this.collection.id(), query, options);
return queryConflicts(this.collection.databaseId, this.collection.id(), query, options);
}
public loadNextPage(): Q.Promise<any> {

View File

@@ -18,6 +18,7 @@ import { CosmosClient } from "../../Common/CosmosClient";
import { PlatformType } from "../../PlatformType";
import { RequestOptions } from "@azure/cosmos/dist-esm";
import Explorer from "../Explorer";
import { updateOfferThroughputBeyondLimit, updateOffer } from "../../Common/DocumentClientUtilityBase";
const updateThroughputBeyondLimitWarningMessage: string = `
You are about to request an increase in throughput beyond the pre-allocated capacity.
@@ -499,13 +500,13 @@ export default class DatabaseSettingsTab extends TabsBase implements ViewModels.
delete newOffer.content.offerAutopilotSettings;
}
const updateOfferPromise = this.container.documentClientUtility
.updateOffer(this.database.offer(), newOffer, headerOptions)
.then((updatedOffer: DataModels.Offer) => {
const updateOfferPromise = updateOffer(this.database.offer(), newOffer, headerOptions).then(
(updatedOffer: DataModels.Offer) => {
this.database.offer(updatedOffer);
this.database.offer.valueHasMutated();
this._wasAutopilotOriginallySet(this.isAutoPilotSelected());
});
}
);
promises.push(updateOfferPromise);
} else {
if (this.throughput.editableIsDirty() || this.isAutoPilotSelected.editableIsDirty()) {
@@ -527,32 +528,30 @@ export default class DatabaseSettingsTab extends TabsBase implements ViewModels.
throughput: newThroughput,
offerIsRUPerMinuteThroughputEnabled: false
};
const updateOfferBeyondLimitPromise: Q.Promise<void> = this.documentClientUtility
.updateOfferThroughputBeyondLimit(requestPayload)
.then(
() => {
this.database.offer().content.offerThroughput = originalThroughputValue;
this.throughput(originalThroughputValue);
this.notificationStatusInfo(
throughputApplyDelayedMessage(this.isAutoPilotSelected(), newThroughput, this.database.id())
);
this.throughput.valueHasMutated(); // force component re-render
},
(error: any) => {
TelemetryProcessor.traceFailure(
Action.UpdateSettings,
{
databaseAccountName: this.container.databaseAccount().name,
databaseName: this.database && this.database.id(),
defaultExperience: this.container.defaultExperience(),
dataExplorerArea: Constants.Areas.Tab,
tabTitle: this.tabTitle(),
error: error
},
startKey
);
}
);
const updateOfferBeyondLimitPromise: Q.Promise<void> = updateOfferThroughputBeyondLimit(requestPayload).then(
() => {
this.database.offer().content.offerThroughput = originalThroughputValue;
this.throughput(originalThroughputValue);
this.notificationStatusInfo(
throughputApplyDelayedMessage(this.isAutoPilotSelected(), newThroughput, this.database.id())
);
this.throughput.valueHasMutated(); // force component re-render
},
(error: any) => {
TelemetryProcessor.traceFailure(
Action.UpdateSettings,
{
databaseAccountName: this.container.databaseAccount().name,
databaseName: this.database && this.database.id(),
defaultExperience: this.container.defaultExperience(),
dataExplorerArea: Constants.Areas.Tab,
tabTitle: this.tabTitle(),
error: error
},
startKey
);
}
);
promises.push(updateOfferBeyondLimitPromise);
} else {
const newOffer: DataModels.Offer = {
@@ -577,13 +576,13 @@ export default class DatabaseSettingsTab extends TabsBase implements ViewModels.
newOffer.content.offerAutopilotSettings = { maxThroughput: 0 };
}
const updateOfferPromise = this.container.documentClientUtility
.updateOffer(this.database.offer(), newOffer, headerOptions)
.then((updatedOffer: DataModels.Offer) => {
const updateOfferPromise = updateOffer(this.database.offer(), newOffer, headerOptions).then(
(updatedOffer: DataModels.Offer) => {
this._wasAutopilotOriginallySet(this.isAutoPilotSelected());
this.database.offer(updatedOffer);
this.database.offer.valueHasMutated();
});
}
);
promises.push(updateOfferPromise);
}

View File

@@ -3,7 +3,6 @@ import * as ViewModels from "../../Contracts/ViewModels";
import * as Constants from "../../Common/Constants";
import DocumentsTab from "./DocumentsTab";
import Explorer from "../Explorer";
import DocumentClientUtilityBase from "../../Common/DocumentClientUtilityBase";
describe("Documents tab", () => {
describe("buildQuery", () => {
@@ -14,7 +13,6 @@ describe("Documents tab", () => {
tabKind: ViewModels.CollectionTabKind.Documents,
title: "",
tabPath: "",
documentClientUtility: new DocumentClientUtilityBase(),
selfLink: "",
hashLocation: "",
isActive: ko.observable<boolean>(false),
@@ -28,13 +26,11 @@ describe("Documents tab", () => {
describe("showPartitionKey", () => {
const explorer = new Explorer({
documentClientUtility: null,
notificationsClient: null,
isEmulator: false
});
const mongoExplorer = new Explorer({
documentClientUtility: null,
notificationsClient: null,
isEmulator: false
});
@@ -97,7 +93,6 @@ describe("Documents tab", () => {
tabKind: ViewModels.CollectionTabKind.Documents,
title: "",
tabPath: "",
documentClientUtility: new DocumentClientUtilityBase(),
selfLink: "",
hashLocation: "",
isActive: ko.observable<boolean>(false),
@@ -116,7 +111,6 @@ describe("Documents tab", () => {
tabKind: ViewModels.CollectionTabKind.Documents,
title: "",
tabPath: "",
documentClientUtility: new DocumentClientUtilityBase(),
selfLink: "",
hashLocation: "",
isActive: ko.observable<boolean>(false),
@@ -135,7 +129,6 @@ describe("Documents tab", () => {
tabKind: ViewModels.CollectionTabKind.Documents,
title: "",
tabPath: "",
documentClientUtility: new DocumentClientUtilityBase(),
selfLink: "",
hashLocation: "",
isActive: ko.observable<boolean>(false),
@@ -154,7 +147,6 @@ describe("Documents tab", () => {
tabKind: ViewModels.CollectionTabKind.Documents,
title: "",
tabPath: "",
documentClientUtility: new DocumentClientUtilityBase(),
selfLink: "",
hashLocation: "",
isActive: ko.observable<boolean>(false),
@@ -173,7 +165,6 @@ describe("Documents tab", () => {
tabKind: ViewModels.CollectionTabKind.Documents,
title: "",
tabPath: "",
documentClientUtility: new DocumentClientUtilityBase(),
selfLink: "",
hashLocation: "",
isActive: ko.observable<boolean>(false),

View File

@@ -26,6 +26,13 @@ import { extractPartitionKey, PartitionKeyDefinition, QueryIterator, ItemDefinit
import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent";
import { NotificationConsoleUtils } from "../../Utils/NotificationConsoleUtils";
import Explorer from "../Explorer";
import {
readDocument,
queryDocuments,
deleteDocument,
updateDocument,
createDocument
} from "../../Common/DocumentClientUtilityBase";
export default class DocumentsTab extends TabsBase implements ViewModels.DocumentsTab {
public selectedDocumentId: ko.Observable<ViewModels.DocumentId>;
@@ -442,8 +449,7 @@ export default class DocumentsTab extends TabsBase implements ViewModels.Documen
});
const document = JSON.parse(this.selectedDocumentContent());
this.isExecuting(true);
return this.documentClientUtility
.createDocument(this.collection, document)
return createDocument(this.collection, document)
.then(
(savedDocument: any) => {
const value: string = this.renderObjectForEditor(savedDocument || {}, null, 4);
@@ -516,8 +522,7 @@ export default class DocumentsTab extends TabsBase implements ViewModels.Documen
tabTitle: this.tabTitle()
});
this.isExecuting(true);
return this.documentClientUtility
.updateDocument(this.collection, selectedDocumentId, documentContent)
return updateDocument(this.collection, selectedDocumentId, documentContent)
.then(
(updatedDocument: any) => {
const value: string = this.renderObjectForEditor(updatedDocument || {}, null, 4);
@@ -665,7 +670,7 @@ export default class DocumentsTab extends TabsBase implements ViewModels.Documen
};
protected __deleteDocument(documentId: ViewModels.DocumentId): Q.Promise<any> {
return this.documentClientUtility.deleteDocument(this.collection, documentId);
return deleteDocument(this.collection, documentId);
}
private _deleteDocument(selectedDocumentId: ViewModels.DocumentId): Q.Promise<any> {
@@ -724,12 +729,12 @@ export default class DocumentsTab extends TabsBase implements ViewModels.Documen
options.partitionKey = this._resourceTokenPartitionKey;
}
return this.documentClientUtility.queryDocuments(this.collection.databaseId, this.collection.id(), query, options);
return queryDocuments(this.collection.databaseId, this.collection.id(), query, options);
}
public selectDocument(documentId: ViewModels.DocumentId): Q.Promise<any> {
this.selectedDocumentId(documentId);
return this.documentClientUtility.readDocument(this.collection, documentId).then((content: any) => {
return readDocument(this.collection, documentId).then((content: any) => {
this.initDocumentEditor(documentId, content);
});
}

View File

@@ -83,7 +83,6 @@ export default class GraphTab extends TabsBase implements ViewModels.Tab {
onIsFilterQueryLoading: (isFilterQueryLoading: boolean): void => this.isFilterQueryLoading(isFilterQueryLoading),
onIsValidQuery: (isValidQuery: boolean): void => this.isValidQuery(isValidQuery),
collectionPartitionKeyProperty: options.collectionPartitionKeyProperty,
documentClientUtility: this.documentClientUtility,
collectionRid: this.rid,
collectionSelfLink: options.selfLink,
graphBackendEndpoint: GraphTab.getGremlinEndpoint(options.account),
@@ -101,7 +100,6 @@ export default class GraphTab extends TabsBase implements ViewModels.Tab {
this.isFilterQueryLoading = ko.observable(false);
this.isValidQuery = ko.observable(true);
this.documentClientUtility = options.documentClientUtility;
this.toolbarViewModel = ko.observable<Toolbar>();
}

View File

@@ -25,7 +25,6 @@ describe("Query Tab", () => {
database: database,
title: "",
tabPath: "",
documentClientUtility: container.documentClientUtility,
selfLink: "",
isActive: ko.observable<boolean>(false),
hashLocation: "",
@@ -51,7 +50,7 @@ describe("Query Tab", () => {
let explorer: Explorer;
beforeEach(() => {
explorer = new Explorer({ documentClientUtility: null, notificationsClient: null, isEmulator: false });
explorer = new Explorer({ notificationsClient: null, isEmulator: false });
});
it("should be true for accounts using SQL API", () => {
@@ -71,7 +70,7 @@ describe("Query Tab", () => {
let explorer: Explorer;
beforeEach(() => {
explorer = new Explorer({ documentClientUtility: null, notificationsClient: null, isEmulator: false });
explorer = new Explorer({ notificationsClient: null, isEmulator: false });
});
it("should be visible when using a supported API", () => {

View File

@@ -16,6 +16,7 @@ import { QueryUtils } from "../../Utils/QueryUtils";
import SaveQueryIcon from "../../../images/save-cosmos.svg";
import { MinimalQueryIterator } from "../../Common/IteratorUtilities";
import { queryDocuments, queryDocumentsPage } from "../../Common/DocumentClientUtilityBase";
enum ToggleState {
Result,
@@ -290,12 +291,7 @@ export default class QueryTab extends TabsBase implements ViewModels.QueryTab, V
options.enableCrossPartitionQuery = HeadersUtility.shouldEnableCrossPartitionKey();
const queryDocuments = (firstItemIndex: number) =>
this.documentClientUtility.queryDocumentsPage(
this.collection && this.collection.id(),
this._iterator,
firstItemIndex,
options
);
queryDocumentsPage(this.collection && this.collection.id(), this._iterator, firstItemIndex, options);
this.isExecuting(true);
return QueryUtils.queryPagesUntilContentPresent(firstItemIndex, queryDocuments)
.then(
@@ -497,9 +493,9 @@ export default class QueryTab extends TabsBase implements ViewModels.QueryTab, V
}
return Q(
this.documentClientUtility
.queryDocuments(this.collection.databaseId, this.collection.id(), this.sqlStatementToExecute(), options)
.then(iterator => (this._iterator = iterator))
queryDocuments(this.collection.databaseId, this.collection.id(), this.sqlStatementToExecute(), options).then(
iterator => (this._iterator = iterator)
)
);
}

View File

@@ -4,7 +4,6 @@ import * as ko from "knockout";
import * as ViewModels from "../../Contracts/ViewModels";
import Collection from "../Tree/Collection";
import Database from "../Tree/Database";
import DocumentClientUtilityBase from "../../Common/DocumentClientUtilityBase";
import Explorer from "../Explorer";
import SettingsTab from "../Tabs/SettingsTab";
@@ -63,8 +62,6 @@ describe("Settings tab", () => {
tabKind: ViewModels.CollectionTabKind.Settings,
title: "Scale & Settings",
tabPath: "",
documentClientUtility: undefined,
selfLink: "",
hashLocation: "",
isActive: ko.observable(false),
@@ -80,7 +77,7 @@ describe("Settings tab", () => {
};
beforeEach(() => {
explorer = new Explorer({ documentClientUtility: null, notificationsClient: null, isEmulator: false });
explorer = new Explorer({ notificationsClient: null, isEmulator: false });
explorer.hasAutoPilotV2FeatureFlag = ko.computed<boolean>(() => true);
});
@@ -179,7 +176,7 @@ describe("Settings tab", () => {
let explorer: Explorer;
beforeEach(() => {
explorer = new Explorer({ documentClientUtility: null, notificationsClient: null, isEmulator: false });
explorer = new Explorer({ notificationsClient: null, isEmulator: false });
explorer.hasAutoPilotV2FeatureFlag = ko.computed<boolean>(() => true);
});
@@ -188,8 +185,6 @@ describe("Settings tab", () => {
tabKind: ViewModels.CollectionTabKind.Settings,
title: "Scale & Settings",
tabPath: "",
documentClientUtility: new DocumentClientUtilityBase(),
selfLink: "",
hashLocation: "",
isActive: ko.observable(false),
@@ -212,7 +207,6 @@ describe("Settings tab", () => {
tabKind: ViewModels.CollectionTabKind.Settings,
title: "Scale & Settings",
tabPath: "",
documentClientUtility: new DocumentClientUtilityBase(),
selfLink: "",
hashLocation: "",
@@ -231,7 +225,6 @@ describe("Settings tab", () => {
tabKind: ViewModels.CollectionTabKind.Settings,
title: "Scale & Settings",
tabPath: "",
documentClientUtility: new DocumentClientUtilityBase(),
selfLink: "",
hashLocation: "",
@@ -261,7 +254,7 @@ describe("Settings tab", () => {
let explorer: Explorer;
beforeEach(() => {
explorer = new Explorer({ documentClientUtility: null, notificationsClient: null, isEmulator: false });
explorer = new Explorer({ notificationsClient: null, isEmulator: false });
explorer.hasAutoPilotV2FeatureFlag = ko.computed<boolean>(() => true);
});
@@ -270,7 +263,6 @@ describe("Settings tab", () => {
tabKind: ViewModels.CollectionTabKind.Settings,
title: "Scale & Settings",
tabPath: "",
documentClientUtility: new DocumentClientUtilityBase(),
selfLink: "",
hashLocation: "",
@@ -287,7 +279,6 @@ describe("Settings tab", () => {
tabKind: ViewModels.CollectionTabKind.Settings,
title: "Scale & Settings",
tabPath: "",
documentClientUtility: new DocumentClientUtilityBase(),
selfLink: "",
hashLocation: "",
@@ -313,7 +304,6 @@ describe("Settings tab", () => {
tabKind: ViewModels.CollectionTabKind.Settings,
title: "Scale & Settings",
tabPath: "",
documentClientUtility: new DocumentClientUtilityBase(),
selfLink: "",
hashLocation: "",
@@ -346,7 +336,6 @@ describe("Settings tab", () => {
function getCollection(defaultApi: string, partitionKeyOption: PartitionKeyOption) {
const explorer = new Explorer({
documentClientUtility: null,
notificationsClient: null,
isEmulator: false
});
@@ -394,7 +383,6 @@ describe("Settings tab", () => {
tabKind: ViewModels.CollectionTabKind.Settings,
title: "Scale & Settings",
tabPath: "",
documentClientUtility: new DocumentClientUtilityBase(),
selfLink: "",
hashLocation: "",
@@ -483,7 +471,6 @@ describe("Settings tab", () => {
describe("AutoPilot", () => {
function getCollection(autoPilotTier: DataModels.AutopilotTier) {
const explorer = new Explorer({
documentClientUtility: null,
notificationsClient: null,
isEmulator: false
});
@@ -540,7 +527,6 @@ describe("Settings tab", () => {
tabKind: ViewModels.CollectionTabKind.Settings,
title: "Scale & Settings",
tabPath: "",
documentClientUtility: new DocumentClientUtilityBase(),
selfLink: "",
hashLocation: "",

View File

@@ -18,6 +18,11 @@ import { CosmosClient } from "../../Common/CosmosClient";
import { PlatformType } from "../../PlatformType";
import { RequestOptions } from "@azure/cosmos/dist-esm";
import Explorer from "../Explorer";
import {
updateOfferThroughputBeyondLimit,
updateOffer,
updateCollection
} from "../../Common/DocumentClientUtilityBase";
const ttlWarning: string = `
The system will automatically delete items based on the TTL value (in seconds) you provide, without needing a delete operation explicitly issued by a client application.
@@ -1062,9 +1067,8 @@ export default class SettingsTab extends TabsBase implements ViewModels.WaitsFor
}
const newCollection: DataModels.Collection = _.extend({}, this.collection.rawDataModel, newCollectionAttributes);
const updateCollectionPromise = this.container.documentClientUtility
.updateCollection(this.collection.databaseId, this.collection, newCollection)
.then((updatedCollection: DataModels.Collection) => {
const updateCollectionPromise = updateCollection(this.collection.databaseId, this.collection, newCollection).then(
(updatedCollection: DataModels.Collection) => {
this.collection.rawDataModel = updatedCollection;
this.collection.defaultTtl(updatedCollection.defaultTtl);
this.collection.analyticalStorageTtl(updatedCollection.analyticalStorageTtl);
@@ -1073,7 +1077,8 @@ export default class SettingsTab extends TabsBase implements ViewModels.WaitsFor
this.collection.conflictResolutionPolicy(updatedCollection.conflictResolutionPolicy);
this.collection.changeFeedPolicy(updatedCollection.changeFeedPolicy);
this.collection.geospatialConfig(updatedCollection.geospatialConfig);
});
}
);
promises.push(updateCollectionPromise);
}
@@ -1147,48 +1152,46 @@ export default class SettingsTab extends TabsBase implements ViewModels.WaitsFor
throughput: newThroughput,
offerIsRUPerMinuteThroughputEnabled: isRUPerMinuteThroughputEnabled
};
const updateOfferBeyondLimitPromise: Q.Promise<void> = this.documentClientUtility
.updateOfferThroughputBeyondLimit(requestPayload)
.then(
() => {
this.collection.offer().content.offerThroughput = originalThroughputValue;
this.throughput(originalThroughputValue);
this.notificationStatusInfo(
throughputApplyDelayedMessage(
this.isAutoPilotSelected(),
originalThroughputValue,
this._getThroughputUnit(),
this.collection.databaseId,
this.collection.id(),
newThroughput
)
);
this.throughput.valueHasMutated(); // force component re-render
},
(error: any) => {
TelemetryProcessor.traceFailure(
Action.UpdateSettings,
{
databaseAccountName: this.container.databaseAccount().name,
databaseName: this.collection && this.collection.databaseId,
collectionName: this.collection && this.collection.id(),
defaultExperience: this.container.defaultExperience(),
dataExplorerArea: Constants.Areas.Tab,
tabTitle: this.tabTitle(),
error: error
},
startKey
);
}
);
const updateOfferBeyondLimitPromise: Q.Promise<void> = updateOfferThroughputBeyondLimit(requestPayload).then(
() => {
this.collection.offer().content.offerThroughput = originalThroughputValue;
this.throughput(originalThroughputValue);
this.notificationStatusInfo(
throughputApplyDelayedMessage(
this.isAutoPilotSelected(),
originalThroughputValue,
this._getThroughputUnit(),
this.collection.databaseId,
this.collection.id(),
newThroughput
)
);
this.throughput.valueHasMutated(); // force component re-render
},
(error: any) => {
TelemetryProcessor.traceFailure(
Action.UpdateSettings,
{
databaseAccountName: this.container.databaseAccount().name,
databaseName: this.collection && this.collection.databaseId,
collectionName: this.collection && this.collection.id(),
defaultExperience: this.container.defaultExperience(),
dataExplorerArea: Constants.Areas.Tab,
tabTitle: this.tabTitle(),
error: error
},
startKey
);
}
);
promises.push(updateOfferBeyondLimitPromise);
} else {
const updateOfferPromise = this.documentClientUtility
.updateOffer(this.collection.offer(), newOffer, headerOptions)
.then((updatedOffer: DataModels.Offer) => {
const updateOfferPromise = updateOffer(this.collection.offer(), newOffer, headerOptions).then(
(updatedOffer: DataModels.Offer) => {
this.collection.offer(updatedOffer);
this.collection.offer.valueHasMutated();
});
}
);
promises.push(updateOfferPromise);
}

View File

@@ -10,6 +10,7 @@ import ScriptTabBase from "./ScriptTabBase";
import TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
import ExecuteQueryIcon from "../../../images/ExecuteQuery.svg";
import StoredProcedure from "../Tree/StoredProcedure";
import { createStoredProcedure, updateStoredProcedure } from "../../Common/DocumentClientUtilityBase";
enum ToggleState {
Result = "result",
@@ -81,8 +82,7 @@ export default class StoredProcedureTab extends ScriptTabBase implements ViewMod
dataExplorerArea: Constants.Areas.Tab,
tabTitle: this.tabTitle()
});
return this.documentClientUtility
.updateStoredProcedure(this.collection, data)
return updateStoredProcedure(this.collection, data)
.then(
(updatedResource: DataModels.StoredProcedure) => {
this.resource(updatedResource);
@@ -240,8 +240,7 @@ export default class StoredProcedureTab extends ScriptTabBase implements ViewMod
tabTitle: this.tabTitle()
});
return this.documentClientUtility
.createStoredProcedure(this.collection, resource)
return createStoredProcedure(this.collection, resource)
.then(
createdResource => {
this.tabTitle(createdResource.id);

View File

@@ -7,13 +7,11 @@ import { RouteHandler } from "../../RouteHandlers/RouteHandler";
import { WaitsForTemplateViewModel } from "../WaitsForTemplateViewModel";
import TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
import ThemeUtility from "../../Common/ThemeUtility";
import DocumentClientUtilityBase from "../../Common/DocumentClientUtilityBase";
import Explorer from "../Explorer";
// TODO: Use specific actions for logging telemetry data
export default class TabsBase extends WaitsForTemplateViewModel implements ViewModels.Tab {
public closeTabButton: ViewModels.Button;
public documentClientUtility: DocumentClientUtilityBase;
public node: ViewModels.TreeNode;
public collection: ViewModels.CollectionBase;
public database: ViewModels.Database;
@@ -39,7 +37,6 @@ export default class TabsBase extends WaitsForTemplateViewModel implements ViewM
const id = new Date().getTime().toString();
this._theme = ThemeUtility.getMonacoTheme(options.theme);
this.documentClientUtility = options.documentClientUtility;
this.node = options.node;
this.collection = options.collection;
this.database = options.database;

View File

@@ -1,7 +1,6 @@
import * as ko from "knockout";
import * as ViewModels from "../../Contracts/ViewModels";
import { TabsManager } from "./TabsManager";
import DocumentClientUtilityBase from "../../Common/DocumentClientUtilityBase";
import DocumentsTab from "./DocumentsTab";
import Explorer from "../Explorer";
import QueryTab from "./QueryTab";
@@ -15,7 +14,7 @@ describe("Tabs manager tests", () => {
let documentsTab: DocumentsTab;
beforeAll(() => {
explorer = new Explorer({ documentClientUtility: undefined, notificationsClient: undefined, isEmulator: false });
explorer = new Explorer({ notificationsClient: undefined, isEmulator: false });
explorer.databaseAccount = ko.observable<ViewModels.DatabaseAccount>({
id: "test",
name: "test",
@@ -49,7 +48,6 @@ describe("Tabs manager tests", () => {
database,
title: "",
tabPath: "",
documentClientUtility: explorer.documentClientUtility,
selfLink: "",
isActive: ko.observable<boolean>(false),
hashLocation: "",
@@ -63,7 +61,6 @@ describe("Tabs manager tests", () => {
collection,
title: "",
tabPath: "",
documentClientUtility: new DocumentClientUtilityBase(),
selfLink: "",
hashLocation: "",
isActive: ko.observable<boolean>(false),

View File

@@ -7,6 +7,7 @@ import ScriptTabBase from "./ScriptTabBase";
import editable from "../../Common/EditableUtility";
import TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
import Trigger from "../Tree/Trigger";
import { createTrigger, updateTrigger } from "../../Common/DocumentClientUtilityBase";
export default class TriggerTab extends ScriptTabBase implements ViewModels.TriggerTab {
public collection: ViewModels.Collection;
@@ -41,8 +42,7 @@ export default class TriggerTab extends ScriptTabBase implements ViewModels.Trig
tabTitle: this.tabTitle()
});
return this.documentClientUtility
.updateTrigger(this.collection, data)
return updateTrigger(this.collection, data)
.then(
(createdResource: DataModels.Trigger) => {
this.resource(createdResource);
@@ -119,8 +119,7 @@ export default class TriggerTab extends ScriptTabBase implements ViewModels.Trig
tabTitle: this.tabTitle()
});
return this.documentClientUtility
.createTrigger(this.collection, resource)
return createTrigger(this.collection, resource)
.then(
(createdResource: DataModels.Trigger) => {
this.tabTitle(createdResource.id);

View File

@@ -6,6 +6,7 @@ import { Action } from "../../Shared/Telemetry/TelemetryConstants";
import ScriptTabBase from "./ScriptTabBase";
import TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
import UserDefinedFunction from "../Tree/UserDefinedFunction";
import { createUserDefinedFunction, updateUserDefinedFunction } from "../../Common/DocumentClientUtilityBase";
export default class UserDefinedFunctionTab extends ScriptTabBase implements ViewModels.UserDefinedFunctionTab {
public collection: ViewModels.Collection;
@@ -34,8 +35,7 @@ export default class UserDefinedFunctionTab extends ScriptTabBase implements Vie
tabTitle: this.tabTitle()
});
return this.documentClientUtility
.updateUserDefinedFunction(this.collection, data)
return updateUserDefinedFunction(this.collection, data)
.then(
(createdResource: DataModels.UserDefinedFunction) => {
this.resource(createdResource);
@@ -104,8 +104,7 @@ export default class UserDefinedFunctionTab extends ScriptTabBase implements Vie
tabTitle: this.tabTitle()
});
return this.documentClientUtility
.createUserDefinedFunction(this.collection, resource)
return createUserDefinedFunction(this.collection, resource)
.then(
(createdResource: DataModels.UserDefinedFunction) => {
this.tabTitle(createdResource.id);