diff --git a/package-lock.json b/package-lock.json index 4635ddf5c..47b42c598 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6359,7 +6359,6 @@ "version": "5.7.1", "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", - "dev": true, "requires": { "base64-js": "^1.3.1", "ieee754": "^1.1.13" @@ -14691,6 +14690,14 @@ "requires": { "nan": "2.14.1", "prebuild-install": "5.3.3" + }, + "dependencies": { + "nan": { + "version": "2.14.1", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.1.tgz", + "integrity": "sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw==", + "optional": true + } } }, "killable": { @@ -20134,7 +20141,6 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.1.tgz", "integrity": "sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng==", - "dev": true, "requires": { "chownr": "^1.1.1", "mkdirp-classic": "^0.5.2", diff --git a/src/Common/OfferUtility.test.ts b/src/Common/OfferUtility.test.ts index 5b8a39a69..d24310758 100644 --- a/src/Common/OfferUtility.test.ts +++ b/src/Common/OfferUtility.test.ts @@ -24,7 +24,8 @@ describe("parseSDKOfferResponse", () => { autoscaleMaxThroughput: undefined, minimumThroughput: 400, id: "test", - offerDefinition: mockOfferDefinition + offerDefinition: mockOfferDefinition, + offerReplacePending: false }; expect(OfferUtility.parseSDKOfferResponse(mockResponse)).toEqual(expectedResult); @@ -54,7 +55,8 @@ describe("parseSDKOfferResponse", () => { autoscaleMaxThroughput: 5000, minimumThroughput: 400, id: "test", - offerDefinition: mockOfferDefinition + offerDefinition: mockOfferDefinition, + offerReplacePending: false }; expect(OfferUtility.parseSDKOfferResponse(mockResponse)).toEqual(expectedResult); diff --git a/src/Common/OfferUtility.ts b/src/Common/OfferUtility.ts index a71dc7c84..a6e1377fe 100644 --- a/src/Common/OfferUtility.ts +++ b/src/Common/OfferUtility.ts @@ -1,5 +1,6 @@ import { Offer, SDKOfferDefinition } from "../Contracts/DataModels"; import { OfferResponse } from "@azure/cosmos"; +import { HttpHeaders } from "./Constants"; export const parseSDKOfferResponse = (offerResponse: OfferResponse): Offer => { const offerDefinition: SDKOfferDefinition = offerResponse?.resource; @@ -18,7 +19,7 @@ export const parseSDKOfferResponse = (offerResponse: OfferResponse): Offer => { manualThroughput: undefined, minimumThroughput, offerDefinition, - headers: offerResponse.headers + offerReplacePending: offerResponse.headers?.[HttpHeaders.offerReplacePending] === "true" }; } @@ -28,6 +29,6 @@ export const parseSDKOfferResponse = (offerResponse: OfferResponse): Offer => { manualThroughput: offerContent.offerThroughput, minimumThroughput, offerDefinition, - headers: offerResponse.headers + offerReplacePending: offerResponse.headers?.[HttpHeaders.offerReplacePending] === "true" }; }; diff --git a/src/Common/dataAccess/readCollectionOffer.ts b/src/Common/dataAccess/readCollectionOffer.ts index f7d97a4b0..9d0ed5fc3 100644 --- a/src/Common/dataAccess/readCollectionOffer.ts +++ b/src/Common/dataAccess/readCollectionOffer.ts @@ -105,7 +105,8 @@ const readCollectionOfferWithARM = async (databaseId: string, collectionId: stri id: offerId, autoscaleMaxThroughput: autoscaleSettings.maxThroughput, manualThroughput: undefined, - minimumThroughput + minimumThroughput, + offerReplacePending: resource.offerReplacePending === "true" }; } @@ -113,7 +114,8 @@ const readCollectionOfferWithARM = async (databaseId: string, collectionId: stri id: offerId, autoscaleMaxThroughput: undefined, manualThroughput: resource.throughput, - minimumThroughput + minimumThroughput, + offerReplacePending: resource.offerReplacePending === "true" }; } diff --git a/src/Common/dataAccess/readDatabaseOffer.ts b/src/Common/dataAccess/readDatabaseOffer.ts index 1f4a67acd..9e99745c7 100644 --- a/src/Common/dataAccess/readDatabaseOffer.ts +++ b/src/Common/dataAccess/readDatabaseOffer.ts @@ -77,7 +77,8 @@ const readDatabaseOfferWithARM = async (databaseId: string): Promise => { id: offerId, autoscaleMaxThroughput: autoscaleSettings.maxThroughput, manualThroughput: undefined, - minimumThroughput + minimumThroughput, + offerReplacePending: resource.offerReplacePending === "true" }; } @@ -85,7 +86,8 @@ const readDatabaseOfferWithARM = async (databaseId: string): Promise => { id: offerId, autoscaleMaxThroughput: undefined, manualThroughput: resource.throughput, - minimumThroughput + minimumThroughput, + offerReplacePending: resource.offerReplacePending === "true" }; } diff --git a/src/Contracts/DataModels.ts b/src/Contracts/DataModels.ts index 8df58ba18..505090c18 100644 --- a/src/Contracts/DataModels.ts +++ b/src/Contracts/DataModels.ts @@ -214,7 +214,7 @@ export interface Offer { manualThroughput: number; minimumThroughput: number; offerDefinition?: SDKOfferDefinition; - headers?: any; + offerReplacePending: boolean; } export interface SDKOfferDefinition extends Resource { diff --git a/src/Explorer/Controls/Settings/SettingsComponent.test.tsx b/src/Explorer/Controls/Settings/SettingsComponent.test.tsx index c230753e4..c8ea4f390 100644 --- a/src/Explorer/Controls/Settings/SettingsComponent.test.tsx +++ b/src/Explorer/Controls/Settings/SettingsComponent.test.tsx @@ -92,7 +92,8 @@ describe("SettingsComponent", () => { autoscaleMaxThroughput: 10000, manualThroughput: undefined, minimumThroughput: 400, - id: "test" + id: "test", + offerReplacePending: false }); const props = { ...baseProps }; diff --git a/src/Explorer/Controls/Settings/SettingsComponent.tsx b/src/Explorer/Controls/Settings/SettingsComponent.tsx index fc9d88e05..704bebb24 100644 --- a/src/Explorer/Controls/Settings/SettingsComponent.tsx +++ b/src/Explorer/Controls/Settings/SettingsComponent.tsx @@ -295,7 +295,7 @@ export class SettingsComponent extends React.Component { - return !!this.collection?.offer()?.headers?.[Constants.HttpHeaders.offerReplacePending]; + return this.collection?.offer()?.offerReplacePending; }; public onSaveClick = async (): Promise => { diff --git a/src/Explorer/Controls/Settings/SettingsSubComponents/ScaleComponent.test.tsx b/src/Explorer/Controls/Settings/SettingsSubComponents/ScaleComponent.test.tsx index 628ac46ea..cab9803b7 100644 --- a/src/Explorer/Controls/Settings/SettingsSubComponents/ScaleComponent.test.tsx +++ b/src/Explorer/Controls/Settings/SettingsSubComponents/ScaleComponent.test.tsx @@ -59,7 +59,7 @@ describe("ScaleComponent", () => { autoscaleMaxThroughput: maxThroughput, minimumThroughput: 400, id: "offer", - headers: { "x-ms-offer-replace-pending": true } + offerReplacePending: true }); const newProps = { ...baseProps, diff --git a/src/Explorer/Controls/Settings/SettingsSubComponents/ScaleComponent.tsx b/src/Explorer/Controls/Settings/SettingsSubComponents/ScaleComponent.tsx index c8f193b44..10aaa0cbf 100644 --- a/src/Explorer/Controls/Settings/SettingsSubComponents/ScaleComponent.tsx +++ b/src/Explorer/Controls/Settings/SettingsSubComponents/ScaleComponent.tsx @@ -116,7 +116,7 @@ export class ScaleComponent extends React.Component { } const offer = this.props.collection?.offer(); - if (offer?.headers?.[Constants.HttpHeaders.offerReplacePending]) { + if (offer?.offerReplacePending) { const throughput = offer.manualThroughput || offer.autoscaleMaxThroughput; return getThroughputApplyShortDelayMessage( this.props.isAutoPilotSelected, diff --git a/src/Explorer/Controls/Settings/TestUtils.tsx b/src/Explorer/Controls/Settings/TestUtils.tsx index 020d1e2e5..6a318bf80 100644 --- a/src/Explorer/Controls/Settings/TestUtils.tsx +++ b/src/Explorer/Controls/Settings/TestUtils.tsx @@ -23,7 +23,8 @@ export const collection = ({ autoscaleMaxThroughput: undefined, manualThroughput: 10000, minimumThroughput: 6000, - id: "offer" + id: "offer", + offerReplacePending: false }), conflictResolutionPolicy: ko.observable( {} as DataModels.ConflictResolutionPolicy diff --git a/src/Explorer/Tabs/DatabaseSettingsTab.ts b/src/Explorer/Tabs/DatabaseSettingsTab.ts index 1ae0e6e2a..75f441af4 100644 --- a/src/Explorer/Tabs/DatabaseSettingsTab.ts +++ b/src/Explorer/Tabs/DatabaseSettingsTab.ts @@ -230,9 +230,7 @@ export default class DatabaseSettingsTab extends TabsBase implements ViewModels. return this.throughputTitle() + this.requestUnitsUsageCost(); }); this.pendingNotification = ko.observable(); - this._offerReplacePending = ko.observable( - !!this.database.offer()?.headers?.[Constants.HttpHeaders.offerReplacePending] - ); + this._offerReplacePending = ko.observable(!!this.database.offer()?.offerReplacePending); this.notificationStatusInfo = ko.observable(""); this.shouldShowNotificationStatusPrompt = ko.computed(() => this.notificationStatusInfo().length > 0); this.warningMessage = ko.computed(() => { @@ -241,7 +239,7 @@ export default class DatabaseSettingsTab extends TabsBase implements ViewModels. } const offer = this.database.offer(); - if (offer?.headers?.[Constants.HttpHeaders.offerReplacePending]) { + if (offer?.offerReplacePending) { const throughput = offer.manualThroughput || offer.autoscaleMaxThroughput; return throughputApplyShortDelayMessage(this.isAutoPilotSelected(), throughput, this.database.id()); }