From 2e3e547a46e1a7cce51eb1990874e0491cf851b0 Mon Sep 17 00:00:00 2001 From: victor-meng <56978073+victor-meng@users.noreply.github.com> Date: Thu, 31 Mar 2022 12:13:08 -0700 Subject: [PATCH] Fix scale tab not showing the correct throughput mode and value and remove freetierautoscalethroughput feature flag (#1245) --- src/Common/Constants.ts | 1 - .../Controls/Settings/SettingsComponent.tsx | 18 +++++++++++++----- .../ThroughputInputAutoPilotV3Component.tsx | 4 ++-- ...hputInputAutoPilotV3Component.test.tsx.snap | 2 +- .../ThroughputInput/ThroughputInput.tsx | 17 +++++------------ .../ThroughputInput.test.tsx.snap | 6 +++--- .../AddDatabasePanel/AddDatabasePanel.tsx | 7 +++---- src/Platform/Hosted/extractFeatures.ts | 2 -- src/Utils/AutoPilotUtils.ts | 7 +------ src/hooks/useKnockoutExplorer.ts | 3 --- 10 files changed, 28 insertions(+), 39 deletions(-) diff --git a/src/Common/Constants.ts b/src/Common/Constants.ts index 124030cbd..e40977ded 100644 --- a/src/Common/Constants.ts +++ b/src/Common/Constants.ts @@ -99,7 +99,6 @@ export class Flights { public static readonly PhoenixNotebooks = "phoenixnotebooks"; public static readonly PhoenixFeatures = "phoenixfeatures"; public static readonly NotebooksDownBanner = "notebooksdownbanner"; - public static readonly FreeTierAutoscaleThroughput = "freetierautoscalethroughput"; } export class AfecFeatures { diff --git a/src/Explorer/Controls/Settings/SettingsComponent.tsx b/src/Explorer/Controls/Settings/SettingsComponent.tsx index 2121d9e27..ee3393ee9 100644 --- a/src/Explorer/Controls/Settings/SettingsComponent.tsx +++ b/src/Explorer/Controls/Settings/SettingsComponent.tsx @@ -202,6 +202,7 @@ export class SettingsComponent extends React.Component { + private getAutoscaleBaselineValues = (): Partial => { const autoscaleMaxThroughput = this.offer?.autoscaleMaxThroughput; if (autoscaleMaxThroughput && AutoPilotUtils.isValidAutoPilotThroughput(autoscaleMaxThroughput)) { - this.setState({ + return { isAutoPilotSelected: true, wasAutopilotOriginallySet: true, autoPilotThroughput: autoscaleMaxThroughput, autoPilotThroughputBaseline: autoscaleMaxThroughput, - }); + }; } + + return { + isAutoPilotSelected: false, + wasAutopilotOriginallySet: false, + autoPilotThroughput: undefined, + autoPilotThroughputBaseline: undefined, + }; }; public hasProvisioningTypeChanged = (): boolean => @@ -567,7 +574,8 @@ export class SettingsComponent extends React.Component { const baselineValues = this.getBaselineValues(); - this.setState(baselineValues as SettingsComponentState); + const autoscaleBaselineValues = this.getAutoscaleBaselineValues(); + this.setState({ ...baselineValues, ...autoscaleBaselineValues } as SettingsComponentState); }; private getBaselineValues = (): Partial => { diff --git a/src/Explorer/Controls/Settings/SettingsSubComponents/ThroughputInputComponents/ThroughputInputAutoPilotV3Component.tsx b/src/Explorer/Controls/Settings/SettingsSubComponents/ThroughputInputComponents/ThroughputInputAutoPilotV3Component.tsx index d64387aeb..2a508412d 100644 --- a/src/Explorer/Controls/Settings/SettingsSubComponents/ThroughputInputComponents/ThroughputInputAutoPilotV3Component.tsx +++ b/src/Explorer/Controls/Settings/SettingsSubComponents/ThroughputInputComponents/ThroughputInputAutoPilotV3Component.tsx @@ -19,7 +19,7 @@ import { Action, ActionModifiers } from "../../../../../Shared/Telemetry/Telemet import * as TelemetryProcessor from "../../../../../Shared/Telemetry/TelemetryProcessor"; import { userContext } from "../../../../../UserContext"; import * as AutoPilotUtils from "../../../../../Utils/AutoPilotUtils"; -import { autoPilotThroughput1K, autoPilotThroughput4K } from "../../../../../Utils/AutoPilotUtils"; +import { autoPilotThroughput1K } from "../../../../../Utils/AutoPilotUtils"; import { calculateEstimateNumber, usageInGB } from "../../../../../Utils/PricingUtils"; import { Int32 } from "../../../../Panes/Tables/Validators/EntityPropertyValidationCommon"; import { @@ -540,7 +540,7 @@ export class ThroughputInputAutoPilotV3Component extends React.Component< step={AutoPilotUtils.autoPilotIncrementStep} value={this.overrideWithProvisionedThroughputSettings() ? "" : this.props.maxAutoPilotThroughput?.toString()} onChange={this.onAutoPilotThroughputChange} - min={userContext.features.freetierAutoscaleThroughput ? autoPilotThroughput1K : autoPilotThroughput4K} + min={autoPilotThroughput1K} errorMessage={this.props.throughputError} /> {!this.overrideWithProvisionedThroughputSettings() && this.getAutoPilotUsageCost()} diff --git a/src/Explorer/Controls/Settings/SettingsSubComponents/ThroughputInputComponents/__snapshots__/ThroughputInputAutoPilotV3Component.test.tsx.snap b/src/Explorer/Controls/Settings/SettingsSubComponents/ThroughputInputComponents/__snapshots__/ThroughputInputAutoPilotV3Component.test.tsx.snap index db2a3576f..efc16b929 100644 --- a/src/Explorer/Controls/Settings/SettingsSubComponents/ThroughputInputComponents/__snapshots__/ThroughputInputAutoPilotV3Component.test.tsx.snap +++ b/src/Explorer/Controls/Settings/SettingsSubComponents/ThroughputInputComponents/__snapshots__/ThroughputInputAutoPilotV3Component.test.tsx.snap @@ -145,7 +145,7 @@ exports[`ThroughputInputAutoPilotV3Component autopilot input visible 1`] = ` id="autopilotInput" key="auto pilot throughput input" label="Max RU/s" - min={4000} + min={1000} onChange={[Function]} required={true} step={1000} diff --git a/src/Explorer/Controls/ThroughputInput/ThroughputInput.tsx b/src/Explorer/Controls/ThroughputInput/ThroughputInput.tsx index c7bb00212..54078f936 100644 --- a/src/Explorer/Controls/ThroughputInput/ThroughputInput.tsx +++ b/src/Explorer/Controls/ThroughputInput/ThroughputInput.tsx @@ -34,9 +34,7 @@ export const ThroughputInput: FunctionComponent = ({ }: ThroughputInputProps) => { const [isAutoscaleSelected, setIsAutoScaleSelected] = useState(true); const [throughput, setThroughput] = useState( - isFreeTier && userContext.features.freetierAutoscaleThroughput - ? AutoPilotUtils.autoPilotThroughput1K - : AutoPilotUtils.autoPilotThroughput4K + isFreeTier ? AutoPilotUtils.autoPilotThroughput1K : AutoPilotUtils.autoPilotThroughput4K ); const [isCostAcknowledged, setIsCostAcknowledged] = useState(false); const [throughputError, setThroughputError] = useState(""); @@ -157,10 +155,9 @@ export const ThroughputInput: FunctionComponent = ({ const handleOnChangeMode = (event: React.ChangeEvent, mode: string): void => { if (mode === "Autoscale") { - const defaultThroughput = - isFreeTier && userContext.features.freetierAutoscaleThroughput - ? AutoPilotUtils.autoPilotThroughput1K - : AutoPilotUtils.autoPilotThroughput4K; + const defaultThroughput = isFreeTier + ? AutoPilotUtils.autoPilotThroughput1K + : AutoPilotUtils.autoPilotThroughput4K; setThroughput(defaultThroughput); setIsAutoScaleSelected(true); setThroughputValue(defaultThroughput); @@ -236,11 +233,7 @@ export const ThroughputInput: FunctionComponent = ({ }} onChange={(event, newInput?: string) => onThroughputValueChange(newInput)} step={AutoPilotUtils.autoPilotIncrementStep} - min={ - userContext.features.freetierAutoscaleThroughput - ? AutoPilotUtils.autoPilotThroughput1K - : AutoPilotUtils.autoPilotThroughput4K - } + min={AutoPilotUtils.autoPilotThroughput1K} value={throughput.toString()} aria-label="Max request units per second" required={true} diff --git a/src/Explorer/Controls/ThroughputInput/__snapshots__/ThroughputInput.test.tsx.snap b/src/Explorer/Controls/ThroughputInput/__snapshots__/ThroughputInput.test.tsx.snap index 0ef66b3d9..4695591cd 100644 --- a/src/Explorer/Controls/ThroughputInput/__snapshots__/ThroughputInput.test.tsx.snap +++ b/src/Explorer/Controls/ThroughputInput/__snapshots__/ThroughputInput.test.tsx.snap @@ -1638,7 +1638,7 @@ exports[`ThroughputInput Pane should render Default properly 1`] = ` aria-label="Max request units per second" errorMessage="" key=".0:$.2" - min={4000} + min={1000} onChange={[Function]} required={true} step={1000} @@ -1660,7 +1660,7 @@ exports[`ThroughputInput Pane should render Default properly 1`] = ` aria-label="Max request units per second" deferredValidationTime={200} errorMessage="" - min={4000} + min={1000} onChange={[Function]} required={true} resizable={true} @@ -1956,7 +1956,7 @@ exports[`ThroughputInput Pane should render Default properly 1`] = ` aria-invalid={false} className="ms-TextField-field field-64" id="TextField2" - min={4000} + min={1000} onBlur={[Function]} onChange={[Function]} onFocus={[Function]} diff --git a/src/Explorer/Panes/AddDatabasePanel/AddDatabasePanel.tsx b/src/Explorer/Panes/AddDatabasePanel/AddDatabasePanel.tsx index 708358568..3493c6505 100644 --- a/src/Explorer/Panes/AddDatabasePanel/AddDatabasePanel.tsx +++ b/src/Explorer/Panes/AddDatabasePanel/AddDatabasePanel.tsx @@ -146,10 +146,9 @@ export const AddDatabasePanel: FunctionComponent = ({ // TODO add feature flag that disables validation for customers with custom accounts if (isAutoscaleSelected) { if (!AutoPilotUtils.isValidAutoPilotThroughput(throughput)) { - const minAutoPilotThroughput = userContext.features.freetierAutoscaleThroughput - ? AutoPilotUtils.autoPilotThroughput1K - : AutoPilotUtils.autoPilotThroughput4K; - setFormErrors(`Please enter a value greater than ${minAutoPilotThroughput} for autopilot throughput`); + setFormErrors( + `Please enter a value greater than ${AutoPilotUtils.autoPilotThroughput1K} for autopilot throughput` + ); return false; } } diff --git a/src/Platform/Hosted/extractFeatures.ts b/src/Platform/Hosted/extractFeatures.ts index fce2da5df..bf58951e2 100644 --- a/src/Platform/Hosted/extractFeatures.ts +++ b/src/Platform/Hosted/extractFeatures.ts @@ -37,7 +37,6 @@ export type Features = { phoenixNotebooks?: boolean; phoenixFeatures?: boolean; notebooksDownBanner: boolean; - freetierAutoscaleThroughput: boolean; }; export function extractFeatures(given = new URLSearchParams(window.location.search)): Features { @@ -90,7 +89,6 @@ export function extractFeatures(given = new URLSearchParams(window.location.sear partitionKeyDefault2: "true" === get("pkpartitionkeytest"), notebooksDownBanner: "true" === get("notebooksDownBanner"), enableThroughputCap: "true" === get("enablethroughputcap"), - freetierAutoscaleThroughput: "true" === get("freetierautoscalethroughput"), }; } diff --git a/src/Utils/AutoPilotUtils.ts b/src/Utils/AutoPilotUtils.ts index 05bca7978..57d1bf5f2 100644 --- a/src/Utils/AutoPilotUtils.ts +++ b/src/Utils/AutoPilotUtils.ts @@ -1,5 +1,3 @@ -import { userContext } from "UserContext"; - export const autoPilotThroughput1K = 1000; export const autoPilotIncrementStep = 1000; export const autoPilotThroughput4K = 4000; @@ -8,10 +6,7 @@ export function isValidAutoPilotThroughput(maxThroughput: number): boolean { if (!maxThroughput) { return false; } - const minAutoPilotThroughput = userContext.features.freetierAutoscaleThroughput - ? autoPilotThroughput4K - : autoPilotThroughput1K; - if (maxThroughput < minAutoPilotThroughput) { + if (maxThroughput < autoPilotThroughput1K) { return false; } if (maxThroughput % 1000) { diff --git a/src/hooks/useKnockoutExplorer.ts b/src/hooks/useKnockoutExplorer.ts index 0be3f5b7d..af9ab2640 100644 --- a/src/hooks/useKnockoutExplorer.ts +++ b/src/hooks/useKnockoutExplorer.ts @@ -378,9 +378,6 @@ function updateContextsFromPortalMessage(inputs: DataExplorerInputsFrame) { if (inputs.flights.indexOf(Flights.NotebooksDownBanner) !== -1) { userContext.features.notebooksDownBanner = true; } - if (inputs.flights.indexOf(Flights.FreeTierAutoscaleThroughput) !== -1) { - userContext.features.freetierAutoscaleThroughput = true; - } } }