Fix offer update notification for AAD users (#338)

This commit is contained in:
Steve Faulkner 2020-12-11 13:38:57 -06:00 committed by GitHub
parent c21f42159f
commit ea39c1d092
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 33 additions and 20 deletions

10
package-lock.json generated
View File

@ -6359,7 +6359,6 @@
"version": "5.7.1", "version": "5.7.1",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz",
"integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==",
"dev": true,
"requires": { "requires": {
"base64-js": "^1.3.1", "base64-js": "^1.3.1",
"ieee754": "^1.1.13" "ieee754": "^1.1.13"
@ -14691,6 +14690,14 @@
"requires": { "requires": {
"nan": "2.14.1", "nan": "2.14.1",
"prebuild-install": "5.3.3" "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": { "killable": {
@ -20134,7 +20141,6 @@
"version": "2.1.1", "version": "2.1.1",
"resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.1.tgz", "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.1.tgz",
"integrity": "sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng==", "integrity": "sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng==",
"dev": true,
"requires": { "requires": {
"chownr": "^1.1.1", "chownr": "^1.1.1",
"mkdirp-classic": "^0.5.2", "mkdirp-classic": "^0.5.2",

View File

@ -24,7 +24,8 @@ describe("parseSDKOfferResponse", () => {
autoscaleMaxThroughput: undefined, autoscaleMaxThroughput: undefined,
minimumThroughput: 400, minimumThroughput: 400,
id: "test", id: "test",
offerDefinition: mockOfferDefinition offerDefinition: mockOfferDefinition,
offerReplacePending: false
}; };
expect(OfferUtility.parseSDKOfferResponse(mockResponse)).toEqual(expectedResult); expect(OfferUtility.parseSDKOfferResponse(mockResponse)).toEqual(expectedResult);
@ -54,7 +55,8 @@ describe("parseSDKOfferResponse", () => {
autoscaleMaxThroughput: 5000, autoscaleMaxThroughput: 5000,
minimumThroughput: 400, minimumThroughput: 400,
id: "test", id: "test",
offerDefinition: mockOfferDefinition offerDefinition: mockOfferDefinition,
offerReplacePending: false
}; };
expect(OfferUtility.parseSDKOfferResponse(mockResponse)).toEqual(expectedResult); expect(OfferUtility.parseSDKOfferResponse(mockResponse)).toEqual(expectedResult);

View File

@ -1,5 +1,6 @@
import { Offer, SDKOfferDefinition } from "../Contracts/DataModels"; import { Offer, SDKOfferDefinition } from "../Contracts/DataModels";
import { OfferResponse } from "@azure/cosmos"; import { OfferResponse } from "@azure/cosmos";
import { HttpHeaders } from "./Constants";
export const parseSDKOfferResponse = (offerResponse: OfferResponse): Offer => { export const parseSDKOfferResponse = (offerResponse: OfferResponse): Offer => {
const offerDefinition: SDKOfferDefinition = offerResponse?.resource; const offerDefinition: SDKOfferDefinition = offerResponse?.resource;
@ -18,7 +19,7 @@ export const parseSDKOfferResponse = (offerResponse: OfferResponse): Offer => {
manualThroughput: undefined, manualThroughput: undefined,
minimumThroughput, minimumThroughput,
offerDefinition, offerDefinition,
headers: offerResponse.headers offerReplacePending: offerResponse.headers?.[HttpHeaders.offerReplacePending] === "true"
}; };
} }
@ -28,6 +29,6 @@ export const parseSDKOfferResponse = (offerResponse: OfferResponse): Offer => {
manualThroughput: offerContent.offerThroughput, manualThroughput: offerContent.offerThroughput,
minimumThroughput, minimumThroughput,
offerDefinition, offerDefinition,
headers: offerResponse.headers offerReplacePending: offerResponse.headers?.[HttpHeaders.offerReplacePending] === "true"
}; };
}; };

View File

@ -105,7 +105,8 @@ const readCollectionOfferWithARM = async (databaseId: string, collectionId: stri
id: offerId, id: offerId,
autoscaleMaxThroughput: autoscaleSettings.maxThroughput, autoscaleMaxThroughput: autoscaleSettings.maxThroughput,
manualThroughput: undefined, manualThroughput: undefined,
minimumThroughput minimumThroughput,
offerReplacePending: resource.offerReplacePending === "true"
}; };
} }
@ -113,7 +114,8 @@ const readCollectionOfferWithARM = async (databaseId: string, collectionId: stri
id: offerId, id: offerId,
autoscaleMaxThroughput: undefined, autoscaleMaxThroughput: undefined,
manualThroughput: resource.throughput, manualThroughput: resource.throughput,
minimumThroughput minimumThroughput,
offerReplacePending: resource.offerReplacePending === "true"
}; };
} }

View File

@ -77,7 +77,8 @@ const readDatabaseOfferWithARM = async (databaseId: string): Promise<Offer> => {
id: offerId, id: offerId,
autoscaleMaxThroughput: autoscaleSettings.maxThroughput, autoscaleMaxThroughput: autoscaleSettings.maxThroughput,
manualThroughput: undefined, manualThroughput: undefined,
minimumThroughput minimumThroughput,
offerReplacePending: resource.offerReplacePending === "true"
}; };
} }
@ -85,7 +86,8 @@ const readDatabaseOfferWithARM = async (databaseId: string): Promise<Offer> => {
id: offerId, id: offerId,
autoscaleMaxThroughput: undefined, autoscaleMaxThroughput: undefined,
manualThroughput: resource.throughput, manualThroughput: resource.throughput,
minimumThroughput minimumThroughput,
offerReplacePending: resource.offerReplacePending === "true"
}; };
} }

View File

@ -214,7 +214,7 @@ export interface Offer {
manualThroughput: number; manualThroughput: number;
minimumThroughput: number; minimumThroughput: number;
offerDefinition?: SDKOfferDefinition; offerDefinition?: SDKOfferDefinition;
headers?: any; offerReplacePending: boolean;
} }
export interface SDKOfferDefinition extends Resource { export interface SDKOfferDefinition extends Resource {

View File

@ -92,7 +92,8 @@ describe("SettingsComponent", () => {
autoscaleMaxThroughput: 10000, autoscaleMaxThroughput: 10000,
manualThroughput: undefined, manualThroughput: undefined,
minimumThroughput: 400, minimumThroughput: 400,
id: "test" id: "test",
offerReplacePending: false
}); });
const props = { ...baseProps }; const props = { ...baseProps };

View File

@ -295,7 +295,7 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
!!this.collection.conflictResolutionPolicy(); !!this.collection.conflictResolutionPolicy();
public isOfferReplacePending = (): boolean => { public isOfferReplacePending = (): boolean => {
return !!this.collection?.offer()?.headers?.[Constants.HttpHeaders.offerReplacePending]; return this.collection?.offer()?.offerReplacePending;
}; };
public onSaveClick = async (): Promise<void> => { public onSaveClick = async (): Promise<void> => {

View File

@ -59,7 +59,7 @@ describe("ScaleComponent", () => {
autoscaleMaxThroughput: maxThroughput, autoscaleMaxThroughput: maxThroughput,
minimumThroughput: 400, minimumThroughput: 400,
id: "offer", id: "offer",
headers: { "x-ms-offer-replace-pending": true } offerReplacePending: true
}); });
const newProps = { const newProps = {
...baseProps, ...baseProps,

View File

@ -116,7 +116,7 @@ export class ScaleComponent extends React.Component<ScaleComponentProps> {
} }
const offer = this.props.collection?.offer(); const offer = this.props.collection?.offer();
if (offer?.headers?.[Constants.HttpHeaders.offerReplacePending]) { if (offer?.offerReplacePending) {
const throughput = offer.manualThroughput || offer.autoscaleMaxThroughput; const throughput = offer.manualThroughput || offer.autoscaleMaxThroughput;
return getThroughputApplyShortDelayMessage( return getThroughputApplyShortDelayMessage(
this.props.isAutoPilotSelected, this.props.isAutoPilotSelected,

View File

@ -23,7 +23,8 @@ export const collection = ({
autoscaleMaxThroughput: undefined, autoscaleMaxThroughput: undefined,
manualThroughput: 10000, manualThroughput: 10000,
minimumThroughput: 6000, minimumThroughput: 6000,
id: "offer" id: "offer",
offerReplacePending: false
}), }),
conflictResolutionPolicy: ko.observable<DataModels.ConflictResolutionPolicy>( conflictResolutionPolicy: ko.observable<DataModels.ConflictResolutionPolicy>(
{} as DataModels.ConflictResolutionPolicy {} as DataModels.ConflictResolutionPolicy

View File

@ -230,9 +230,7 @@ export default class DatabaseSettingsTab extends TabsBase implements ViewModels.
return this.throughputTitle() + this.requestUnitsUsageCost(); return this.throughputTitle() + this.requestUnitsUsageCost();
}); });
this.pendingNotification = ko.observable<DataModels.Notification>(); this.pendingNotification = ko.observable<DataModels.Notification>();
this._offerReplacePending = ko.observable<boolean>( this._offerReplacePending = ko.observable<boolean>(!!this.database.offer()?.offerReplacePending);
!!this.database.offer()?.headers?.[Constants.HttpHeaders.offerReplacePending]
);
this.notificationStatusInfo = ko.observable<string>(""); this.notificationStatusInfo = ko.observable<string>("");
this.shouldShowNotificationStatusPrompt = ko.computed<boolean>(() => this.notificationStatusInfo().length > 0); this.shouldShowNotificationStatusPrompt = ko.computed<boolean>(() => this.notificationStatusInfo().length > 0);
this.warningMessage = ko.computed<string>(() => { this.warningMessage = ko.computed<string>(() => {
@ -241,7 +239,7 @@ export default class DatabaseSettingsTab extends TabsBase implements ViewModels.
} }
const offer = this.database.offer(); const offer = this.database.offer();
if (offer?.headers?.[Constants.HttpHeaders.offerReplacePending]) { if (offer?.offerReplacePending) {
const throughput = offer.manualThroughput || offer.autoscaleMaxThroughput; const throughput = offer.manualThroughput || offer.autoscaleMaxThroughput;
return throughputApplyShortDelayMessage(this.isAutoPilotSelected(), throughput, this.database.id()); return throughputApplyShortDelayMessage(this.isAutoPilotSelected(), throughput, this.database.id());
} }