diff --git a/src/Common/dataAccess/readCollectionQuotaInfo.ts b/src/Common/dataAccess/readCollectionQuotaInfo.ts deleted file mode 100644 index 81565f821..000000000 --- a/src/Common/dataAccess/readCollectionQuotaInfo.ts +++ /dev/null @@ -1,45 +0,0 @@ -import * as DataModels from "../../Contracts/DataModels"; -import * as HeadersUtility from "../HeadersUtility"; -import * as ViewModels from "../../Contracts/ViewModels"; -import { ContainerDefinition, Resource } from "@azure/cosmos"; -import { HttpHeaders } from "../Constants"; -import { RequestOptions } from "@azure/cosmos/dist-esm"; -import { client } from "../CosmosClient"; -import { handleError } from "../ErrorHandlingUtils"; -import { logConsoleProgress } from "../../Utils/NotificationConsoleUtils"; - -interface ResourceWithStatistics { - statistics: DataModels.Statistic[]; -} - -export const readCollectionQuotaInfo = async ( - collection: ViewModels.Collection -): Promise => { - const clearMessage = logConsoleProgress(`Querying containers for database ${collection.id}`); - const options: RequestOptions = {}; - options.populateQuotaInfo = true; - options.initialHeaders = options.initialHeaders || {}; - options.initialHeaders[HttpHeaders.populatePartitionStatistics] = true; - - try { - const response = await client() - .database(collection.databaseId) - .container(collection.id()) - .read(options); - const quota: DataModels.CollectionQuotaInfo = HeadersUtility.getQuota(response.headers); - const resource = response.resource as ContainerDefinition & Resource & ResourceWithStatistics; - quota["usageSizeInKB"] = resource.statistics.reduce( - (previousValue: number, currentValue: DataModels.Statistic) => previousValue + currentValue.sizeInKB, - 0 - ); - quota["numPartitions"] = resource.statistics.length; - quota["uniqueKeyPolicy"] = collection.uniqueKeyPolicy; // TODO: Remove after refactoring (#119617) - - return quota; - } catch (error) { - handleError(error, "ReadCollectionQuotaInfo", `Error while querying quota info for container ${collection.id}`); - throw error; - } finally { - clearMessage(); - } -}; diff --git a/src/Common/dataAccess/updateOfferThroughputBeyondLimit.test.ts b/src/Common/dataAccess/updateOfferThroughputBeyondLimit.test.ts deleted file mode 100644 index f90e45f02..000000000 --- a/src/Common/dataAccess/updateOfferThroughputBeyondLimit.test.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { updateOfferThroughputBeyondLimit } from "./updateOfferThroughputBeyondLimit"; - -describe("updateOfferThroughputBeyondLimit", () => { - it("should call fetch", async () => { - window.fetch = jest.fn(() => { - return { - ok: true - }; - }); - window.dataExplorer = { - logConsoleData: jest.fn(), - deleteInProgressConsoleDataWithId: jest.fn() - // eslint-disable-next-line @typescript-eslint/no-explicit-any - } as any; - await updateOfferThroughputBeyondLimit({ - subscriptionId: "foo", - resourceGroup: "foo", - databaseAccountName: "foo", - databaseName: "foo", - throughput: 1000000000, - offerIsRUPerMinuteThroughputEnabled: false - }); - expect(window.fetch).toHaveBeenCalled(); - }); -}); diff --git a/src/Common/dataAccess/updateOfferThroughputBeyondLimit.ts b/src/Common/dataAccess/updateOfferThroughputBeyondLimit.ts deleted file mode 100644 index 93a8f8737..000000000 --- a/src/Common/dataAccess/updateOfferThroughputBeyondLimit.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { Platform, configContext } from "../../ConfigContext"; -import { getAuthorizationHeader } from "../../Utils/AuthorizationUtils"; -import { AutoPilotOfferSettings } from "../../Contracts/DataModels"; -import { logConsoleProgress, logConsoleInfo } from "../../Utils/NotificationConsoleUtils"; -import { HttpHeaders } from "../Constants"; -import { handleError } from "../ErrorHandlingUtils"; - -interface UpdateOfferThroughputRequest { - subscriptionId: string; - resourceGroup: string; - databaseAccountName: string; - databaseName: string; - collectionName?: string; - throughput: number; - offerIsRUPerMinuteThroughputEnabled: boolean; - offerAutopilotSettings?: AutoPilotOfferSettings; -} - -export async function updateOfferThroughputBeyondLimit(request: UpdateOfferThroughputRequest): Promise { - if (configContext.platform !== Platform.Portal) { - throw new Error("Updating throughput beyond specified limit is not supported on this platform"); - } - - const resourceDescriptionInfo = request.collectionName - ? `database ${request.databaseName} and container ${request.collectionName}` - : `database ${request.databaseName}`; - - const clearMessage = logConsoleProgress( - `Requesting increase in throughput to ${request.throughput} for ${resourceDescriptionInfo}` - ); - - const url = `${configContext.BACKEND_ENDPOINT}/api/offerthroughputrequest/updatebeyondspecifiedlimit`; - const authorizationHeader = getAuthorizationHeader(); - - const response = await fetch(url, { - method: "POST", - body: JSON.stringify(request), - headers: { [authorizationHeader.header]: authorizationHeader.token, [HttpHeaders.contentType]: "application/json" } - }); - - if (response.ok) { - logConsoleInfo( - `Successfully requested an increase in throughput to ${request.throughput} for ${resourceDescriptionInfo}` - ); - clearMessage(); - return undefined; - } - - const error = await response.json(); - handleError( - error, - "updateOfferThroughputBeyondLimit", - `Failed to request an increase in throughput for ${request.throughput}` - ); - clearMessage(); - throw error; -} diff --git a/src/Contracts/DataModels.ts b/src/Contracts/DataModels.ts index 3aadf14cd..1d2430581 100644 --- a/src/Contracts/DataModels.ts +++ b/src/Contracts/DataModels.ts @@ -191,18 +191,6 @@ export interface OfferWithHeaders extends Offer { headers: any; } -export interface CollectionQuotaInfo { - storedProcedures: number; - triggers: number; - functions: number; - documentsSize: number; - collectionSize: number; - documentsCount: number; - usageSizeInKB: number; - numPartitions: number; - uniqueKeyPolicy?: UniqueKeyPolicy; // TODO: This should ideally not be a part of the collection quota. Remove after refactoring. (#119617) -} - export interface OfferThroughputInfo { minimumRUForCollection: number; numPhysicalPartitions: number; diff --git a/src/Contracts/ViewModels.ts b/src/Contracts/ViewModels.ts index ea27df1f3..12e57637b 100644 --- a/src/Contracts/ViewModels.ts +++ b/src/Contracts/ViewModels.ts @@ -117,7 +117,6 @@ export interface Collection extends CollectionBase { analyticalStorageTtl: ko.Observable; indexingPolicy: ko.Observable; uniqueKeyPolicy: DataModels.UniqueKeyPolicy; - quotaInfo: ko.Observable; offer: ko.Observable; conflictResolutionPolicy: ko.Observable; changeFeedPolicy: ko.Observable; diff --git a/src/Explorer/Controls/Settings/SettingsComponent.tsx b/src/Explorer/Controls/Settings/SettingsComponent.tsx index b6b1ba90a..c25e82884 100644 --- a/src/Explorer/Controls/Settings/SettingsComponent.tsx +++ b/src/Explorer/Controls/Settings/SettingsComponent.tsx @@ -1,54 +1,49 @@ +import { RequestOptions } from "@azure/cosmos/dist-esm"; +import { IPivotItemProps, IPivotProps, Pivot, PivotItem } from "office-ui-fabric-react"; import * as React from "react"; -import * as AutoPilotUtils from "../../../Utils/AutoPilotUtils"; -import * as Constants from "../../../Common/Constants"; -import * as DataModels from "../../../Contracts/DataModels"; -import * as SharedConstants from "../../../Shared/Constants"; -import * as ViewModels from "../../../Contracts/ViewModels"; import DiscardIcon from "../../../../images/discard.svg"; import SaveIcon from "../../../../images/save-cosmos.svg"; -import { traceStart, traceFailure, traceSuccess, trace } from "../../../Shared/Telemetry/TelemetryProcessor"; -import { Action, ActionModifiers } from "../../../Shared/Telemetry/TelemetryConstants"; -import { RequestOptions } from "@azure/cosmos/dist-esm"; -import Explorer from "../../Explorer"; -import { updateOffer } from "../../../Common/dataAccess/updateOffer"; +import * as Constants from "../../../Common/Constants"; +import { getIndexTransformationProgress } from "../../../Common/dataAccess/getIndexTransformationProgress"; +import { readMongoDBCollectionThroughRP } from "../../../Common/dataAccess/readMongoDBCollection"; import { updateCollection, updateMongoDBCollectionThroughRP } from "../../../Common/dataAccess/updateCollection"; +import { updateOffer } from "../../../Common/dataAccess/updateOffer"; +import { getErrorMessage, getErrorStack } from "../../../Common/ErrorHandlingUtils"; +import * as DataModels from "../../../Contracts/DataModels"; +import * as ViewModels from "../../../Contracts/ViewModels"; +import { Action, ActionModifiers } from "../../../Shared/Telemetry/TelemetryConstants"; +import { trace, traceFailure, traceStart, traceSuccess } from "../../../Shared/Telemetry/TelemetryProcessor"; +import { MongoDBCollectionResource, MongoIndex } from "../../../Utils/arm/generatedClients/2020-04-01/types"; +import * as AutoPilotUtils from "../../../Utils/AutoPilotUtils"; import { CommandButtonComponentProps } from "../../Controls/CommandButton/CommandButtonComponent"; -import { userContext } from "../../../UserContext"; -import { updateOfferThroughputBeyondLimit } from "../../../Common/dataAccess/updateOfferThroughputBeyondLimit"; +import Explorer from "../../Explorer"; import SettingsTab from "../../Tabs/SettingsTabV2"; -import { throughputUnit } from "./SettingsRenderUtils"; -import { ScaleComponent, ScaleComponentProps } from "./SettingsSubComponents/ScaleComponent"; -import { - MongoIndexingPolicyComponent, - MongoIndexingPolicyComponentProps -} from "./SettingsSubComponents/MongoIndexingPolicy/MongoIndexingPolicyComponent"; -import { - getMaxRUs, - hasDatabaseSharedThroughput, - GeospatialConfigType, - TtlType, - ChangeFeedPolicyState, - SettingsV2TabTypes, - getTabTitle, - isDirty, - AddMongoIndexProps, - MongoIndexTypes, - parseConflictResolutionMode, - parseConflictResolutionProcedure, - getMongoNotification -} from "./SettingsUtils"; +import "./SettingsComponent.less"; import { ConflictResolutionComponent, ConflictResolutionComponentProps } from "./SettingsSubComponents/ConflictResolutionComponent"; -import { SubSettingsComponent, SubSettingsComponentProps } from "./SettingsSubComponents/SubSettingsComponent"; -import { Pivot, PivotItem, IPivotProps, IPivotItemProps } from "office-ui-fabric-react"; -import "./SettingsComponent.less"; import { IndexingPolicyComponent, IndexingPolicyComponentProps } from "./SettingsSubComponents/IndexingPolicyComponent"; -import { MongoDBCollectionResource, MongoIndex } from "../../../Utils/arm/generatedClients/2020-04-01/types"; -import { readMongoDBCollectionThroughRP } from "../../../Common/dataAccess/readMongoDBCollection"; -import { getIndexTransformationProgress } from "../../../Common/dataAccess/getIndexTransformationProgress"; -import { getErrorMessage, getErrorStack } from "../../../Common/ErrorHandlingUtils"; +import { + MongoIndexingPolicyComponent, + MongoIndexingPolicyComponentProps +} from "./SettingsSubComponents/MongoIndexingPolicy/MongoIndexingPolicyComponent"; +import { ScaleComponent, ScaleComponentProps } from "./SettingsSubComponents/ScaleComponent"; +import { SubSettingsComponent, SubSettingsComponentProps } from "./SettingsSubComponents/SubSettingsComponent"; +import { + AddMongoIndexProps, + ChangeFeedPolicyState, + GeospatialConfigType, + getMongoNotification, + getTabTitle, + hasDatabaseSharedThroughput, + isDirty, + MongoIndexTypes, + parseConflictResolutionMode, + parseConflictResolutionProcedure, + SettingsV2TabTypes, + TtlType +} from "./SettingsUtils"; interface SettingsV2TabInfo { tab: SettingsV2TabTypes; @@ -450,7 +445,6 @@ export class SettingsComponent extends React.Component SharedConstants.CollectionCreation.DefaultCollectionRUs1Million && - this.container - ) { - const requestPayload = { - subscriptionId: userContext.subscriptionId, - databaseAccountName: userContext.databaseAccount.name, - resourceGroup: userContext.resourceGroup, - databaseName: this.collection.databaseId, - collectionName: this.collection.id(), - throughput: newThroughput, - offerIsRUPerMinuteThroughputEnabled: false - }; - - await updateOfferThroughputBeyondLimit(requestPayload); - this.collection.offer().content.offerThroughput = originalThroughputValue; + const updateOfferParams: DataModels.UpdateOfferParams = { + databaseId: this.collection.databaseId, + collectionId: this.collection.id(), + currentOffer: this.collection.offer(), + autopilotThroughput: this.state.isAutoPilotSelected ? this.state.autoPilotThroughput : undefined, + manualThroughput: this.state.isAutoPilotSelected ? undefined : newThroughput + }; + if (this.hasProvisioningTypeChanged()) { + if (this.state.isAutoPilotSelected) { + updateOfferParams.migrateToAutoPilot = true; + } else { + updateOfferParams.migrateToManual = true; + } + } + const updatedOffer: DataModels.Offer = await updateOffer(updateOfferParams); + this.collection.offer(updatedOffer); + this.setState({ isScaleSaveable: false, isScaleDiscardable: false }); + if (this.state.isAutoPilotSelected) { this.setState({ - isScaleSaveable: false, - isScaleDiscardable: false, - throughput: originalThroughputValue, - throughputBaseline: originalThroughputValue, - initialNotification: { - description: `Throughput update for ${newThroughput} ${throughputUnit}` - } as DataModels.Notification + autoPilotThroughput: updatedOffer.content.offerAutopilotSettings.maxThroughput, + autoPilotThroughputBaseline: updatedOffer.content.offerAutopilotSettings.maxThroughput }); } else { - const updateOfferParams: DataModels.UpdateOfferParams = { - databaseId: this.collection.databaseId, - collectionId: this.collection.id(), - currentOffer: this.collection.offer(), - autopilotThroughput: this.state.isAutoPilotSelected ? this.state.autoPilotThroughput : undefined, - manualThroughput: this.state.isAutoPilotSelected ? undefined : newThroughput - }; - if (this.hasProvisioningTypeChanged()) { - if (this.state.isAutoPilotSelected) { - updateOfferParams.migrateToAutoPilot = true; - } else { - updateOfferParams.migrateToManual = true; - } - } - const updatedOffer: DataModels.Offer = await updateOffer(updateOfferParams); - this.collection.offer(updatedOffer); - this.setState({ isScaleSaveable: false, isScaleDiscardable: false }); - if (this.state.isAutoPilotSelected) { - this.setState({ - autoPilotThroughput: updatedOffer.content.offerAutopilotSettings.maxThroughput, - autoPilotThroughputBaseline: updatedOffer.content.offerAutopilotSettings.maxThroughput - }); - } else { - this.setState({ - throughput: updatedOffer.content.offerThroughput, - throughputBaseline: updatedOffer.content.offerThroughput - }); - } + this.setState({ + throughput: updatedOffer.content.offerThroughput, + throughputBaseline: updatedOffer.content.offerThroughput + }); } } this.container.isRefreshingExplorer(false); diff --git a/src/Explorer/Controls/Settings/SettingsSubComponents/ScaleComponent.test.tsx b/src/Explorer/Controls/Settings/SettingsSubComponents/ScaleComponent.test.tsx index d87a3b914..1279dce2f 100644 --- a/src/Explorer/Controls/Settings/SettingsSubComponents/ScaleComponent.test.tsx +++ b/src/Explorer/Controls/Settings/SettingsSubComponents/ScaleComponent.test.tsx @@ -1,14 +1,13 @@ import { shallow } from "enzyme"; +import ko from "knockout"; import React from "react"; -import { ScaleComponent, ScaleComponentProps } from "./ScaleComponent"; -import { container, collection } from "../TestUtils"; -import { ThroughputInputAutoPilotV3Component } from "./ThroughputInputComponents/ThroughputInputAutoPilotV3Component"; -import Explorer from "../../../Explorer"; import * as Constants from "../../../../Common/Constants"; import * as DataModels from "../../../../Contracts/DataModels"; +import Explorer from "../../../Explorer"; import { throughputUnit } from "../SettingsRenderUtils"; -import * as SharedConstants from "../../../../Shared/Constants"; -import ko from "knockout"; +import { collection, container } from "../TestUtils"; +import { ScaleComponent, ScaleComponentProps } from "./ScaleComponent"; +import { ThroughputInputAutoPilotV3Component } from "./ThroughputInputComponents/ThroughputInputAutoPilotV3Component"; describe("ScaleComponent", () => { const nonNationalCloudContainer = new Explorer(); @@ -48,9 +47,7 @@ describe("ScaleComponent", () => { let wrapper = shallow(); expect(wrapper).toMatchSnapshot(); expect(wrapper.exists(ThroughputInputAutoPilotV3Component)).toEqual(true); - expect(wrapper.exists("#throughputApplyLongDelayMessage")).toEqual(true); expect(wrapper.exists("#throughputApplyShortDelayMessage")).toEqual(false); - expect(wrapper.find("#throughputApplyLongDelayMessage").html()).toContain(targetThroughput); const newCollection = { ...collection }; const maxThroughput = 5000; @@ -109,11 +106,6 @@ describe("ScaleComponent", () => { expect(scaleComponent.isAutoScaleEnabled()).toEqual(true); }); - it("getMaxRUThroughputInputLimit", () => { - const scaleComponent = new ScaleComponent(baseProps); - expect(scaleComponent.getMaxRUThroughputInputLimit()).toEqual(40000); - }); - it("getThroughputTitle", () => { let scaleComponent = new ScaleComponent(baseProps); expect(scaleComponent.getThroughputTitle()).toEqual("Throughput (6,000 - unlimited RU/s)"); @@ -126,26 +118,4 @@ describe("ScaleComponent", () => { scaleComponent = new ScaleComponent(newProps); expect(scaleComponent.getThroughputTitle()).toEqual("Throughput (autoscale)"); }); - - it("canThroughputExceedMaximumValue", () => { - let scaleComponent = new ScaleComponent(baseProps); - expect(scaleComponent.canThroughputExceedMaximumValue()).toEqual(true); - - const newProps = { ...baseProps, container: nonNationalCloudContainer }; - scaleComponent = new ScaleComponent(newProps); - expect(scaleComponent.canThroughputExceedMaximumValue()).toEqual(true); - }); - - it("getThroughputWarningMessage", () => { - const throughputBeyondLimit = SharedConstants.CollectionCreation.DefaultCollectionRUs1Million + 1000; - const throughputBeyondMaxRus = SharedConstants.CollectionCreation.DefaultCollectionRUs1Million - 1000; - - const newProps = { ...baseProps, container: nonNationalCloudContainer, throughput: throughputBeyondLimit }; - let scaleComponent = new ScaleComponent(newProps); - expect(scaleComponent.getThroughputWarningMessage().props.id).toEqual("updateThroughputBeyondLimitWarningMessage"); - - newProps.throughput = throughputBeyondMaxRus; - scaleComponent = new ScaleComponent(newProps); - expect(scaleComponent.getThroughputWarningMessage().props.id).toEqual("updateThroughputDelayedApplyWarningMessage"); - }); }); diff --git a/src/Explorer/Controls/Settings/SettingsSubComponents/ScaleComponent.tsx b/src/Explorer/Controls/Settings/SettingsSubComponents/ScaleComponent.tsx index c25bea722..c8ea5f659 100644 --- a/src/Explorer/Controls/Settings/SettingsSubComponents/ScaleComponent.tsx +++ b/src/Explorer/Controls/Settings/SettingsSubComponents/ScaleComponent.tsx @@ -1,24 +1,20 @@ +import { Label, MessageBar, MessageBarType, Stack, Text, TextField } from "office-ui-fabric-react"; import * as React from "react"; import * as Constants from "../../../../Common/Constants"; -import { ThroughputInputAutoPilotV3Component } from "./ThroughputInputComponents/ThroughputInputAutoPilotV3Component"; -import * as ViewModels from "../../../../Contracts/ViewModels"; +import { configContext, Platform } from "../../../../ConfigContext"; import * as DataModels from "../../../../Contracts/DataModels"; -import * as SharedConstants from "../../../../Shared/Constants"; +import * as ViewModels from "../../../../Contracts/ViewModels"; +import * as AutoPilotUtils from "../../../../Utils/AutoPilotUtils"; import Explorer from "../../../Explorer"; import { getTextFieldStyles, - subComponentStackProps, - titleAndInputStackProps, - throughputUnit, - getThroughputApplyLongDelayMessage, getThroughputApplyShortDelayMessage, - updateThroughputBeyondLimitWarningMessage, - updateThroughputDelayedApplyWarningMessage + subComponentStackProps, + throughputUnit, + titleAndInputStackProps } from "../SettingsRenderUtils"; -import { getMaxRUs, getMinRUs, hasDatabaseSharedThroughput } from "../SettingsUtils"; -import * as AutoPilotUtils from "../../../../Utils/AutoPilotUtils"; -import { Text, TextField, Stack, Label, MessageBar, MessageBarType } from "office-ui-fabric-react"; -import { configContext, Platform } from "../../../../ConfigContext"; +import { getMinRUs, hasDatabaseSharedThroughput } from "../SettingsUtils"; +import { ThroughputInputAutoPilotV3Component } from "./ThroughputInputComponents/ThroughputInputAutoPilotV3Component"; export interface ScaleComponentProps { collection: ViewModels.Collection; @@ -75,40 +71,17 @@ export class ScaleComponent extends React.Component { ); }; - public getMaxRUThroughputInputLimit = (): number => { - if (configContext.platform === Platform.Hosted && this.props.collection.partitionKey) { - return SharedConstants.CollectionCreation.DefaultCollectionRUs1Million; - } - - return getMaxRUs(this.props.collection, this.props.container); - }; - public getThroughputTitle = (): string => { if (this.props.isAutoPilotSelected) { return AutoPilotUtils.getAutoPilotHeaderText(); } const minThroughput: string = getMinRUs(this.props.collection, this.props.container).toLocaleString(); - const maxThroughput: string = - this.canThroughputExceedMaximumValue() && !this.props.isFixedContainer - ? "unlimited" - : getMaxRUs(this.props.collection, this.props.container).toLocaleString(); + const maxThroughput: string = !this.props.isFixedContainer ? "unlimited" : "10000"; return `Throughput (${minThroughput} - ${maxThroughput} RU/s)`; }; - public canThroughputExceedMaximumValue = (): boolean => { - return ( - !this.props.isFixedContainer && - configContext.platform === Platform.Portal && - !this.props.container.isRunningOnNationalCloud() - ); - }; - public getInitialNotificationElement = (): JSX.Element => { - if (this.props.initialNotification) { - return this.getLongDelayMessage(); - } - const offer = this.props.collection?.offer && this.props.collection.offer(); if ( offer && @@ -135,47 +108,6 @@ export class ScaleComponent extends React.Component { return undefined; }; - public getThroughputWarningMessage = (): JSX.Element => { - const throughputExceedsBackendLimits: boolean = - this.canThroughputExceedMaximumValue() && - getMaxRUs(this.props.collection, this.props.container) <= - SharedConstants.CollectionCreation.DefaultCollectionRUs1Million && - this.props.throughput > SharedConstants.CollectionCreation.DefaultCollectionRUs1Million; - - if (throughputExceedsBackendLimits && !!this.props.collection.partitionKey && !this.props.isFixedContainer) { - return updateThroughputBeyondLimitWarningMessage; - } - - const throughputExceedsMaxValue: boolean = - !this.isEmulator && this.props.throughput > getMaxRUs(this.props.collection, this.props.container); - - if (throughputExceedsMaxValue && !!this.props.collection.partitionKey && !this.props.isFixedContainer) { - return updateThroughputDelayedApplyWarningMessage; - } - - return undefined; - }; - - public getLongDelayMessage = (): JSX.Element => { - const matches: string[] = this.props.initialNotification?.description.match( - `Throughput update for (.*) ${throughputUnit}` - ); - - const throughput = this.props.throughputBaseline; - const targetThroughput: number = matches.length > 1 && Number(matches[1]); - if (targetThroughput) { - return getThroughputApplyLongDelayMessage( - this.props.wasAutopilotOriginallySet, - throughput, - throughputUnit, - this.props.collection.databaseId, - this.props.collection.id(), - targetThroughput - ); - } - return <>; - }; - private getThroughputInputComponent = (): JSX.Element => ( { throughputBaseline={this.props.throughputBaseline} onThroughputChange={this.props.onThroughputChange} minimum={getMinRUs(this.props.collection, this.props.container)} - maximum={this.getMaxRUThroughputInputLimit()} isEnabled={!hasDatabaseSharedThroughput(this.props.collection)} - canExceedMaximumValue={this.canThroughputExceedMaximumValue()} label={this.getThroughputTitle()} isEmulator={this.isEmulator} isFixed={this.props.isFixedContainer} @@ -199,7 +129,6 @@ export class ScaleComponent extends React.Component { spendAckChecked={false} onScaleSaveableChange={this.props.onScaleSaveableChange} onScaleDiscardableChange={this.props.onScaleDiscardableChange} - getThroughputWarningMessage={this.getThroughputWarningMessage} /> ); diff --git a/src/Explorer/Controls/Settings/SettingsSubComponents/ThroughputInputComponents/ThroughputInputAutoPilotV3Component.test.tsx b/src/Explorer/Controls/Settings/SettingsSubComponents/ThroughputInputComponents/ThroughputInputAutoPilotV3Component.test.tsx index ab56c7d73..cf74e3304 100644 --- a/src/Explorer/Controls/Settings/SettingsSubComponents/ThroughputInputComponents/ThroughputInputAutoPilotV3Component.test.tsx +++ b/src/Explorer/Controls/Settings/SettingsSubComponents/ThroughputInputComponents/ThroughputInputAutoPilotV3Component.test.tsx @@ -15,7 +15,6 @@ describe("ThroughputInputAutoPilotV3Component", () => { throughputBaseline: 100, onThroughputChange: undefined, minimum: 10000, - maximum: 400, step: 100, isEnabled: true, isEmulator: false, @@ -38,8 +37,7 @@ describe("ThroughputInputAutoPilotV3Component", () => { }, onScaleDiscardableChange: () => { return; - }, - getThroughputWarningMessage: () => undefined + } }; it("throughput input visible", () => { diff --git a/src/Explorer/Controls/Settings/SettingsSubComponents/ThroughputInputComponents/ThroughputInputAutoPilotV3Component.tsx b/src/Explorer/Controls/Settings/SettingsSubComponents/ThroughputInputComponents/ThroughputInputAutoPilotV3Component.tsx index 3dce4dddd..47b2df513 100644 --- a/src/Explorer/Controls/Settings/SettingsSubComponents/ThroughputInputComponents/ThroughputInputAutoPilotV3Component.tsx +++ b/src/Explorer/Controls/Settings/SettingsSubComponents/ThroughputInputComponents/ThroughputInputAutoPilotV3Component.tsx @@ -1,35 +1,33 @@ -import React from "react"; -import * as AutoPilotUtils from "../../../../../Utils/AutoPilotUtils"; import { - getTextFieldStyles, - getToolTipContainer, - noLeftPaddingCheckBoxStyle, - titleAndInputStackProps, - checkBoxAndInputStackProps, - getChoiceGroupStyles, - messageBarStyles, - getEstimatedSpendElement, - getEstimatedAutoscaleSpendElement, - getAutoPilotV3SpendElement, - manualToAutoscaleDisclaimerElement -} from "../../SettingsRenderUtils"; -import { - Text, - TextField, + Checkbox, ChoiceGroup, IChoiceGroupOption, - Checkbox, - Stack, Label, Link, MessageBar, - MessageBarType + MessageBarType, + Stack, + Text, + TextField } from "office-ui-fabric-react"; -import { ToolTipLabelComponent } from "../ToolTipLabelComponent"; -import { getSanitizedInputValue, IsComponentDirtyResult, isDirty } from "../../SettingsUtils"; -import * as SharedConstants from "../../../../../Shared/Constants"; +import React from "react"; import * as DataModels from "../../../../../Contracts/DataModels"; -import { Int32 } from "../../../../Panes/Tables/Validators/EntityPropertyValidationCommon"; +import * as AutoPilotUtils from "../../../../../Utils/AutoPilotUtils"; +import { + checkBoxAndInputStackProps, + getAutoPilotV3SpendElement, + getChoiceGroupStyles, + getEstimatedAutoscaleSpendElement, + getEstimatedSpendElement, + getTextFieldStyles, + getToolTipContainer, + manualToAutoscaleDisclaimerElement, + messageBarStyles, + noLeftPaddingCheckBoxStyle, + titleAndInputStackProps +} from "../../SettingsRenderUtils"; +import { getSanitizedInputValue, IsComponentDirtyResult, isDirty } from "../../SettingsUtils"; +import { ToolTipLabelComponent } from "../ToolTipLabelComponent"; export interface ThroughputInputAutoPilotV3Props { databaseAccount: DataModels.DatabaseAccount; @@ -38,7 +36,6 @@ export interface ThroughputInputAutoPilotV3Props { throughputBaseline: number; onThroughputChange: (newThroughput: number) => void; minimum: number; - maximum: number; step?: number; isEnabled?: boolean; spendAckChecked?: boolean; @@ -59,7 +56,6 @@ export interface ThroughputInputAutoPilotV3Props { onMaxAutoPilotThroughputChange: (newThroughput: number) => void; onScaleSaveableChange: (isScaleSaveable: boolean) => void; onScaleDiscardableChange: (isScaleDiscardable: boolean) => void; - getThroughputWarningMessage: () => JSX.Element; } interface ThroughputInputAutoPilotV3State { @@ -119,13 +115,7 @@ export class ThroughputInputAutoPilotV3Component extends React.Component< if (isDirty(this.props.throughput, this.props.throughputBaseline)) { isDiscardable = true; isSaveable = true; - if ( - !this.props.throughput || - this.props.throughput < this.props.minimum || - (this.props.throughput > this.props.maximum && (this.props.isEmulator || this.props.isFixed)) || - (this.props.throughput > SharedConstants.CollectionCreation.DefaultCollectionRUs1Million && - !this.props.canExceedMaximumValue) - ) { + if (!this.props.throughput || this.props.throughput < this.props.minimum) { isSaveable = false; } } @@ -141,8 +131,8 @@ export class ThroughputInputAutoPilotV3Component extends React.Component< }; this.step = this.props.step ?? ThroughputInputAutoPilotV3Component.defaultStep; - this.throughputInputMaxValue = this.props.canExceedMaximumValue ? Int32.Max : this.props.maximum; - this.autoPilotInputMaxValue = this.props.isFixed ? this.props.maximum : Int32.Max; + this.throughputInputMaxValue = Number.MAX_SAFE_INTEGER; + this.autoPilotInputMaxValue = Number.MAX_SAFE_INTEGER; } public hasProvisioningTypeChanged = (): boolean => @@ -306,12 +296,6 @@ export class ThroughputInputAutoPilotV3Component extends React.Component< onChange={this.onThroughputChange} /> - {this.props.getThroughputWarningMessage() && ( - - {this.props.getThroughputWarningMessage()} - - )} - {!this.props.isEmulator && this.getRequestUnitsUsageCost()} {this.props.spendAckVisible && ( diff --git a/src/Explorer/Controls/Settings/SettingsSubComponents/__snapshots__/ScaleComponent.test.tsx.snap b/src/Explorer/Controls/Settings/SettingsSubComponents/__snapshots__/ScaleComponent.test.tsx.snap index 0b6aaa749..f69224492 100644 --- a/src/Explorer/Controls/Settings/SettingsSubComponents/__snapshots__/ScaleComponent.test.tsx.snap +++ b/src/Explorer/Controls/Settings/SettingsSubComponents/__snapshots__/ScaleComponent.test.tsx.snap @@ -8,29 +8,6 @@ exports[`ScaleComponent renders with correct intiial notification 1`] = ` } } > - - - A request to increase the throughput is currently in progress. This operation will take 1-3 business days to complete. View the latest status in Notifications. -
- Database: - test - , Container: - test - - , Current autoscale throughput: 100 - 1000 RU/s, Target autoscale throughput: 600 - 6000 RU/s -
-
{ - it("getMaxRUs", () => { - expect(collection.offer().content.collectionThroughputInfo.numPhysicalPartitions).toEqual(4); - expect(getMaxRUs(collection, container)).toEqual(40000); - }); - it("getMinRUs", () => { expect(collection.offer().content.collectionThroughputInfo.numPhysicalPartitions).toEqual(4); expect(getMinRUs(collection, container)).toEqual(6000); diff --git a/src/Explorer/Controls/Settings/SettingsUtils.tsx b/src/Explorer/Controls/Settings/SettingsUtils.tsx index 9e29b73fe..6c32b3eb5 100644 --- a/src/Explorer/Controls/Settings/SettingsUtils.tsx +++ b/src/Explorer/Controls/Settings/SettingsUtils.tsx @@ -1,11 +1,9 @@ -import * as ViewModels from "../../../Contracts/ViewModels"; -import * as DataModels from "../../../Contracts/DataModels"; import * as Constants from "../../../Common/Constants"; +import * as DataModels from "../../../Contracts/DataModels"; +import * as ViewModels from "../../../Contracts/ViewModels"; import * as SharedConstants from "../../../Shared/Constants"; -import * as PricingUtils from "../../../Utils/PricingUtils"; - -import Explorer from "../../Explorer"; import { MongoIndex } from "../../../Utils/arm/generatedClients/2020-04-01/types"; +import Explorer from "../../Explorer"; const zeroValue = 0; export type isDirtyTypes = boolean | string | number | DataModels.IndexingPolicy; @@ -71,22 +69,6 @@ export const hasDatabaseSharedThroughput = (collection: ViewModels.Collection): return database?.isDatabaseShared() && !collection.offer(); }; -export const getMaxRUs = (collection: ViewModels.Collection, container: Explorer): number => { - const isTryCosmosDBSubscription = container?.isTryCosmosDBSubscription() || false; - if (isTryCosmosDBSubscription) { - return Constants.TryCosmosExperience.maxRU; - } - - const numPartitionsFromOffer: number = - collection?.offer && collection.offer()?.content?.collectionThroughputInfo?.numPhysicalPartitions; - - const numPartitionsFromQuotaInfo: number = collection?.quotaInfo()?.numPartitions; - - const numPartitions = numPartitionsFromOffer ?? numPartitionsFromQuotaInfo ?? 1; - - return SharedConstants.CollectionCreation.MaxRUPerPartition * numPartitions; -}; - export const getMinRUs = (collection: ViewModels.Collection, container: Explorer): number => { const isTryCosmosDBSubscription = container?.isTryCosmosDBSubscription(); if (isTryCosmosDBSubscription) { @@ -105,21 +87,7 @@ export const getMinRUs = (collection: ViewModels.Collection, container: Explorer return collectionThroughputInfo.minimumRUForCollection; } - const numPartitions = collectionThroughputInfo?.numPhysicalPartitions ?? collection.quotaInfo()?.numPartitions; - - if (!numPartitions || numPartitions === 1) { - return SharedConstants.CollectionCreation.DefaultCollectionRUs400; - } - - const baseRU = SharedConstants.CollectionCreation.DefaultCollectionRUs400; - - const quotaInKb = collection.quotaInfo().collectionSize; - const quotaInGb = PricingUtils.usageInGB(quotaInKb); - - const perPartitionGBQuota: number = Math.max(10, quotaInGb / numPartitions); - const baseRUbyPartitions: number = ((numPartitions * perPartitionGBQuota) / 10) * 100; - - return Math.max(baseRU, baseRUbyPartitions); + return SharedConstants.CollectionCreation.DefaultCollectionRUs400; }; export const parseConflictResolutionMode = (modeFromBackend: string): DataModels.ConflictResolutionMode => { diff --git a/src/Explorer/Controls/Settings/TestUtils.tsx b/src/Explorer/Controls/Settings/TestUtils.tsx index 92db0174c..cff3c4e3d 100644 --- a/src/Explorer/Controls/Settings/TestUtils.tsx +++ b/src/Explorer/Controls/Settings/TestUtils.tsx @@ -18,7 +18,6 @@ export const collection = ({ excludedPaths: [] }), uniqueKeyPolicy: {} as DataModels.UniqueKeyPolicy, - quotaInfo: ko.observable({} as DataModels.CollectionQuotaInfo), offer: ko.observable({ content: { offerThroughput: 10000, diff --git a/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap b/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap index db28fa5a8..9c20bfbc8 100644 --- a/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap +++ b/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap @@ -43,7 +43,6 @@ exports[`SettingsComponent renders 1`] = ` "autoPilotUsageCost": [Function], "canConfigureThroughput": [Function], "canExceedMaximumValue": [Function], - "canRequestSupport": [Function], "container": [Circular], "costsVisible": [Function], "databaseCreateNewShared": [Function], @@ -86,7 +85,6 @@ exports[`SettingsComponent renders 1`] = ` "autoPilotUsageCost": [Function], "canConfigureThroughput": [Function], "canExceedMaximumValue": [Function], - "canRequestSupport": [Function], "collectionId": [Function], "collectionIdTitle": [Function], "collectionWithThroughputInShared": [Function], @@ -349,7 +347,6 @@ exports[`SettingsComponent renders 1`] = ` "autoPilotUsageCost": [Function], "canConfigureThroughput": [Function], "canExceedMaximumValue": [Function], - "canRequestSupport": [Function], "container": [Circular], "costsVisible": [Function], "createTableQuery": [Function], @@ -575,7 +572,6 @@ exports[`SettingsComponent renders 1`] = ` "autoPilotUsageCost": [Function], "canConfigureThroughput": [Function], "canExceedMaximumValue": [Function], - "canRequestSupport": [Function], "collectionId": [Function], "collectionIdTitle": [Function], "collectionWithThroughputInShared": [Function], @@ -657,7 +653,6 @@ exports[`SettingsComponent renders 1`] = ` "autoPilotUsageCost": [Function], "canConfigureThroughput": [Function], "canExceedMaximumValue": [Function], - "canRequestSupport": [Function], "container": [Circular], "costsVisible": [Function], "databaseCreateNewShared": [Function], @@ -760,7 +755,6 @@ exports[`SettingsComponent renders 1`] = ` "autoPilotUsageCost": [Function], "canConfigureThroughput": [Function], "canExceedMaximumValue": [Function], - "canRequestSupport": [Function], "container": [Circular], "costsVisible": [Function], "createTableQuery": [Function], @@ -1301,7 +1295,6 @@ exports[`SettingsComponent renders 1`] = ` "version": 2, }, "partitionKeyProperty": "partitionKey", - "quotaInfo": [Function], "readSettings": [Function], "uniqueKeyPolicy": Object {}, } @@ -1323,7 +1316,6 @@ exports[`SettingsComponent renders 1`] = ` "autoPilotUsageCost": [Function], "canConfigureThroughput": [Function], "canExceedMaximumValue": [Function], - "canRequestSupport": [Function], "container": [Circular], "costsVisible": [Function], "databaseCreateNewShared": [Function], @@ -1366,7 +1358,6 @@ exports[`SettingsComponent renders 1`] = ` "autoPilotUsageCost": [Function], "canConfigureThroughput": [Function], "canExceedMaximumValue": [Function], - "canRequestSupport": [Function], "collectionId": [Function], "collectionIdTitle": [Function], "collectionWithThroughputInShared": [Function], @@ -1629,7 +1620,6 @@ exports[`SettingsComponent renders 1`] = ` "autoPilotUsageCost": [Function], "canConfigureThroughput": [Function], "canExceedMaximumValue": [Function], - "canRequestSupport": [Function], "container": [Circular], "costsVisible": [Function], "createTableQuery": [Function], @@ -1855,7 +1845,6 @@ exports[`SettingsComponent renders 1`] = ` "autoPilotUsageCost": [Function], "canConfigureThroughput": [Function], "canExceedMaximumValue": [Function], - "canRequestSupport": [Function], "collectionId": [Function], "collectionIdTitle": [Function], "collectionWithThroughputInShared": [Function], @@ -1937,7 +1926,6 @@ exports[`SettingsComponent renders 1`] = ` "autoPilotUsageCost": [Function], "canConfigureThroughput": [Function], "canExceedMaximumValue": [Function], - "canRequestSupport": [Function], "container": [Circular], "costsVisible": [Function], "databaseCreateNewShared": [Function], @@ -2040,7 +2028,6 @@ exports[`SettingsComponent renders 1`] = ` "autoPilotUsageCost": [Function], "canConfigureThroughput": [Function], "canExceedMaximumValue": [Function], - "canRequestSupport": [Function], "container": [Circular], "costsVisible": [Function], "createTableQuery": [Function], @@ -2616,7 +2603,6 @@ exports[`SettingsComponent renders 1`] = ` "autoPilotUsageCost": [Function], "canConfigureThroughput": [Function], "canExceedMaximumValue": [Function], - "canRequestSupport": [Function], "container": [Circular], "costsVisible": [Function], "databaseCreateNewShared": [Function], @@ -2659,7 +2645,6 @@ exports[`SettingsComponent renders 1`] = ` "autoPilotUsageCost": [Function], "canConfigureThroughput": [Function], "canExceedMaximumValue": [Function], - "canRequestSupport": [Function], "collectionId": [Function], "collectionIdTitle": [Function], "collectionWithThroughputInShared": [Function], @@ -2922,7 +2907,6 @@ exports[`SettingsComponent renders 1`] = ` "autoPilotUsageCost": [Function], "canConfigureThroughput": [Function], "canExceedMaximumValue": [Function], - "canRequestSupport": [Function], "container": [Circular], "costsVisible": [Function], "createTableQuery": [Function], @@ -3148,7 +3132,6 @@ exports[`SettingsComponent renders 1`] = ` "autoPilotUsageCost": [Function], "canConfigureThroughput": [Function], "canExceedMaximumValue": [Function], - "canRequestSupport": [Function], "collectionId": [Function], "collectionIdTitle": [Function], "collectionWithThroughputInShared": [Function], @@ -3230,7 +3213,6 @@ exports[`SettingsComponent renders 1`] = ` "autoPilotUsageCost": [Function], "canConfigureThroughput": [Function], "canExceedMaximumValue": [Function], - "canRequestSupport": [Function], "container": [Circular], "costsVisible": [Function], "databaseCreateNewShared": [Function], @@ -3333,7 +3315,6 @@ exports[`SettingsComponent renders 1`] = ` "autoPilotUsageCost": [Function], "canConfigureThroughput": [Function], "canExceedMaximumValue": [Function], - "canRequestSupport": [Function], "container": [Circular], "costsVisible": [Function], "createTableQuery": [Function], @@ -3874,7 +3855,6 @@ exports[`SettingsComponent renders 1`] = ` "version": 2, }, "partitionKeyProperty": "partitionKey", - "quotaInfo": [Function], "readSettings": [Function], "uniqueKeyPolicy": Object {}, } @@ -3896,7 +3876,6 @@ exports[`SettingsComponent renders 1`] = ` "autoPilotUsageCost": [Function], "canConfigureThroughput": [Function], "canExceedMaximumValue": [Function], - "canRequestSupport": [Function], "container": [Circular], "costsVisible": [Function], "databaseCreateNewShared": [Function], @@ -3939,7 +3918,6 @@ exports[`SettingsComponent renders 1`] = ` "autoPilotUsageCost": [Function], "canConfigureThroughput": [Function], "canExceedMaximumValue": [Function], - "canRequestSupport": [Function], "collectionId": [Function], "collectionIdTitle": [Function], "collectionWithThroughputInShared": [Function], @@ -4202,7 +4180,6 @@ exports[`SettingsComponent renders 1`] = ` "autoPilotUsageCost": [Function], "canConfigureThroughput": [Function], "canExceedMaximumValue": [Function], - "canRequestSupport": [Function], "container": [Circular], "costsVisible": [Function], "createTableQuery": [Function], @@ -4428,7 +4405,6 @@ exports[`SettingsComponent renders 1`] = ` "autoPilotUsageCost": [Function], "canConfigureThroughput": [Function], "canExceedMaximumValue": [Function], - "canRequestSupport": [Function], "collectionId": [Function], "collectionIdTitle": [Function], "collectionWithThroughputInShared": [Function], @@ -4510,7 +4486,6 @@ exports[`SettingsComponent renders 1`] = ` "autoPilotUsageCost": [Function], "canConfigureThroughput": [Function], "canExceedMaximumValue": [Function], - "canRequestSupport": [Function], "container": [Circular], "costsVisible": [Function], "databaseCreateNewShared": [Function], @@ -4613,7 +4588,6 @@ exports[`SettingsComponent renders 1`] = ` "autoPilotUsageCost": [Function], "canConfigureThroughput": [Function], "canExceedMaximumValue": [Function], - "canRequestSupport": [Function], "container": [Circular], "costsVisible": [Function], "createTableQuery": [Function], diff --git a/src/Explorer/Panes/AddCollectionPane.ts b/src/Explorer/Panes/AddCollectionPane.ts index 204435904..1db435ac9 100644 --- a/src/Explorer/Panes/AddCollectionPane.ts +++ b/src/Explorer/Panes/AddCollectionPane.ts @@ -61,7 +61,6 @@ export default class AddCollectionPane extends ContextualPaneBase { public maxCollectionsReachedMessage: ko.Observable; public requestUnitsUsageCost: ko.Computed; public dedicatedRequestUnitsUsageCost: ko.Computed; - public canRequestSupport: ko.PureComputed; public largePartitionKey: ko.Observable = ko.observable(false); public useIndexingForSharedThroughput: ko.Observable = ko.observable(true); public costsVisible: ko.PureComputed; @@ -314,19 +313,6 @@ export default class AddCollectionPane extends ContextualPaneBase { } }); - this.canRequestSupport = ko.pureComputed(() => { - if ( - configContext.platform !== Platform.Emulator && - !this.container.isTryCosmosDBSubscription() && - configContext.platform !== Platform.Portal - ) { - const offerThroughput: number = this._getThroughput(); - return offerThroughput <= 100000; - } - - return false; - }); - this.costsVisible = ko.pureComputed(() => { return configContext.platform !== Platform.Emulator; }); diff --git a/src/Explorer/Panes/AddDatabasePane.html b/src/Explorer/Panes/AddDatabasePane.html index e93da1ec0..9ea150a44 100644 --- a/src/Explorer/Panes/AddDatabasePane.html +++ b/src/Explorer/Panes/AddDatabasePane.html @@ -117,10 +117,6 @@ showAutoPilot: !isFreeTierAccount() }"> -

- Contact - support for more than RU/s.

diff --git a/src/Explorer/Panes/AddDatabasePane.ts b/src/Explorer/Panes/AddDatabasePane.ts index c47b36e7e..2ccf1c58a 100644 --- a/src/Explorer/Panes/AddDatabasePane.ts +++ b/src/Explorer/Panes/AddDatabasePane.ts @@ -31,7 +31,6 @@ export default class AddDatabasePane extends ContextualPaneBase { public throughputSpendAck: ko.Observable; public throughputSpendAckVisible: ko.Computed; public requestUnitsUsageCost: ko.Computed; - public canRequestSupport: ko.PureComputed; public costsVisible: ko.PureComputed; public upsellMessage: ko.PureComputed; public upsellMessageAriaLabel: ko.PureComputed; @@ -168,19 +167,6 @@ export default class AddDatabasePane extends ContextualPaneBase { return estimatedSpend; }); - this.canRequestSupport = ko.pureComputed(() => { - if ( - configContext.platform !== Platform.Emulator && - !this.container.isTryCosmosDBSubscription() && - configContext.platform !== Platform.Portal - ) { - const offerThroughput: number = this.throughput(); - return offerThroughput <= 100000; - } - - return false; - }); - this.isFreeTierAccount = ko.computed(() => { const databaseAccount = this.container && this.container.databaseAccount && this.container.databaseAccount(); const isFreeTierAccount = diff --git a/src/Explorer/Panes/CassandraAddCollectionPane.ts b/src/Explorer/Panes/CassandraAddCollectionPane.ts index 1fa823a75..148831e35 100644 --- a/src/Explorer/Panes/CassandraAddCollectionPane.ts +++ b/src/Explorer/Panes/CassandraAddCollectionPane.ts @@ -33,7 +33,6 @@ export default class CassandraAddCollectionPane extends ContextualPaneBase { public keyspaceThroughput: ko.Observable; public keyspaceCreateNew: ko.Observable; public dedicateTableThroughput: ko.Observable; - public canRequestSupport: ko.PureComputed; public throughputSpendAckText: ko.Observable; public throughputSpendAck: ko.Observable; public sharedThroughputSpendAck: ko.Observable; @@ -228,15 +227,6 @@ export default class CassandraAddCollectionPane extends ContextualPaneBase { return configContext.platform !== Platform.Emulator; }); - this.canRequestSupport = ko.pureComputed(() => { - if (configContext.platform !== Platform.Emulator && !this.container.isTryCosmosDBSubscription()) { - const offerThroughput: number = this.throughput(); - return offerThroughput <= 100000; - } - - return false; - }); - this.sharedThroughputSpendAckVisible = ko.computed(() => { const autoscaleThroughput = this.sharedAutoPilotThroughput() * 1; if (this.isSharedAutoPilotSelected()) { diff --git a/src/Explorer/Panes/Tables/Validators/EntityPropertyValidationCommon.ts b/src/Explorer/Panes/Tables/Validators/EntityPropertyValidationCommon.ts index 8872b16fb..06e61c795 100644 --- a/src/Explorer/Panes/Tables/Validators/EntityPropertyValidationCommon.ts +++ b/src/Explorer/Panes/Tables/Validators/EntityPropertyValidationCommon.ts @@ -3,11 +3,6 @@ export var Int32 = { Max: 2147483647 }; -export var Int64 = { - Min: -9223372036854775808, - Max: 9223372036854775807 -}; - var yearMonthDay = "\\d{4}[- ][01]\\d[- ][0-3]\\d"; var timeOfDay = "T[0-2]\\d:[0-5]\\d(:[0-5]\\d(\\.\\d+)?)?"; var timeZone = "Z|[+-][0-2]\\d:[0-5]\\d"; diff --git a/src/Explorer/Tabs/DatabaseSettingsTab.html b/src/Explorer/Tabs/DatabaseSettingsTab.html index d3f01198a..866f7eaae 100644 --- a/src/Explorer/Tabs/DatabaseSettingsTab.html +++ b/src/Explorer/Tabs/DatabaseSettingsTab.html @@ -30,7 +30,6 @@ class: 'scaleForm dirty', value: throughput, minimum: minRUs, - maximum: maxRUThroughputInputLimit, canExceedMaximumValue: canThroughputExceedMaximumValue, step: throughputIncreaseFactor, label: throughputTitle, diff --git a/src/Explorer/Tabs/DatabaseSettingsTab.ts b/src/Explorer/Tabs/DatabaseSettingsTab.ts index 085d7d3be..16426986c 100644 --- a/src/Explorer/Tabs/DatabaseSettingsTab.ts +++ b/src/Explorer/Tabs/DatabaseSettingsTab.ts @@ -17,7 +17,6 @@ import Explorer from "../Explorer"; import { updateOffer } from "../../Common/dataAccess/updateOffer"; import { CommandButtonComponentProps } from "../Controls/CommandButton/CommandButtonComponent"; import { userContext } from "../../UserContext"; -import { updateOfferThroughputBeyondLimit } from "../../Common/dataAccess/updateOfferThroughputBeyondLimit"; import { configContext, Platform } from "../../ConfigContext"; import { getErrorMessage, getErrorStack } from "../../Common/ErrorHandlingUtils"; @@ -59,9 +58,6 @@ export default class DatabaseSettingsTab extends TabsBase implements ViewModels. public saveSettingsButton: ViewModels.Button; public discardSettingsChangesButton: ViewModels.Button; - - public canRequestSupport: ko.PureComputed; - public canThroughputExceedMaximumValue: ko.Computed; public costsVisible: ko.Computed; public displayedError: ko.Observable; public isTemplateReady: ko.Observable; @@ -69,13 +65,11 @@ export default class DatabaseSettingsTab extends TabsBase implements ViewModels. public minRUs: ko.Computed; public maxRUs: ko.Computed; public maxRUsText: ko.PureComputed; - public maxRUThroughputInputLimit: ko.Computed; public notificationStatusInfo: ko.Observable; public pendingNotification: ko.Observable; public requestUnitsUsageCost: ko.PureComputed; public autoscaleCost: ko.PureComputed; public shouldShowNotificationStatusPrompt: ko.Computed; - public shouldDisplayPortalUsePrompt: ko.Computed; public shouldShowStatusBar: ko.Computed; public throughputTitle: ko.PureComputed; public throughputAriaLabel: ko.PureComputed; @@ -181,22 +175,6 @@ export default class DatabaseSettingsTab extends TabsBase implements ViewModels. return configContext.platform !== Platform.Emulator; }); - this.shouldDisplayPortalUsePrompt = ko.pureComputed(() => configContext.platform === Platform.Hosted); - this.canThroughputExceedMaximumValue = ko.pureComputed( - () => configContext.platform === Platform.Portal && !this.container.isRunningOnNationalCloud() - ); - this.canRequestSupport = ko.pureComputed(() => { - if ( - configContext.platform === Platform.Emulator || - configContext.platform === Platform.Hosted || - this.canThroughputExceedMaximumValue() - ) { - return false; - } - - return true; - }); - this.overrideWithAutoPilotSettings = ko.pureComputed(() => { return this._hasProvisioningTypeChanged() && this._wasAutopilotOriginallySet(); }); @@ -245,14 +223,6 @@ export default class DatabaseSettingsTab extends TabsBase implements ViewModels. return throughputDefaults.unlimitedmax; }); - this.maxRUThroughputInputLimit = ko.pureComputed(() => { - if (configContext.platform === Platform.Hosted) { - return SharedConstants.CollectionCreation.DefaultCollectionRUs1Million; - } - - return this.maxRUs(); - }); - this.maxRUsText = ko.pureComputed(() => { return SharedConstants.CollectionCreation.DefaultCollectionRUs1Million.toLocaleString(); }); @@ -300,8 +270,7 @@ export default class DatabaseSettingsTab extends TabsBase implements ViewModels. if ( this.maxRUs() <= SharedConstants.CollectionCreation.DefaultCollectionRUs1Million && - this.throughput() > SharedConstants.CollectionCreation.DefaultCollectionRUs1Million && - this.canThroughputExceedMaximumValue() + this.throughput() > SharedConstants.CollectionCreation.DefaultCollectionRUs1Million ) { return updateThroughputBeyondLimitWarningMessage; } @@ -368,13 +337,6 @@ export default class DatabaseSettingsTab extends TabsBase implements ViewModels. return false; } - if ( - !this.canThroughputExceedMaximumValue() && - this.throughput() > SharedConstants.CollectionCreation.DefaultCollectionRUs1Million - ) { - return false; - } - if (this.throughput.editableIsDirty()) { return true; } @@ -450,40 +412,18 @@ export default class DatabaseSettingsTab extends TabsBase implements ViewModels. const originalThroughputValue = this.throughput.getEditableOriginalValue(); const newThroughput = this.throughput(); - if ( - this.canThroughputExceedMaximumValue() && - this.maxRUs() <= SharedConstants.CollectionCreation.DefaultCollectionRUs1Million && - this.throughput() > SharedConstants.CollectionCreation.DefaultCollectionRUs1Million - ) { - const requestPayload = { - subscriptionId: userContext.subscriptionId, - databaseAccountName: userContext.databaseAccount.name, - resourceGroup: userContext.resourceGroup, - databaseName: this.database.id(), - throughput: newThroughput, - offerIsRUPerMinuteThroughputEnabled: false - }; - await updateOfferThroughputBeyondLimit(requestPayload); - 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 - } else { - const updateOfferParams: DataModels.UpdateOfferParams = { - databaseId: this.database.id(), - currentOffer: this.database.offer(), - autopilotThroughput: undefined, - manualThroughput: newThroughput, - migrateToManual: this._hasProvisioningTypeChanged() - }; + const updateOfferParams: DataModels.UpdateOfferParams = { + databaseId: this.database.id(), + currentOffer: this.database.offer(), + autopilotThroughput: undefined, + manualThroughput: newThroughput, + migrateToManual: this._hasProvisioningTypeChanged() + }; - const updatedOffer = await updateOffer(updateOfferParams); - this._wasAutopilotOriginallySet(this.isAutoPilotSelected()); - this.database.offer(updatedOffer); - this.database.offer.valueHasMutated(); - } + const updatedOffer = await updateOffer(updateOfferParams); + this._wasAutopilotOriginallySet(this.isAutoPilotSelected()); + this.database.offer(updatedOffer); + this.database.offer.valueHasMutated(); } } } catch (error) { diff --git a/src/Explorer/Tabs/SettingsTab.html b/src/Explorer/Tabs/SettingsTab.html index 6c4e1bc99..83606717e 100644 --- a/src/Explorer/Tabs/SettingsTab.html +++ b/src/Explorer/Tabs/SettingsTab.html @@ -57,9 +57,7 @@ class: 'scaleForm dirty', value: throughput, minimum: minRUs, - maximum: maxRUThroughputInputLimit, isEnabled: !hasDatabaseSharedThroughput(), - canExceedMaximumValue: canThroughputExceedMaximumValue, label: throughputTitle, ariaLabel: throughputAriaLabel, costsVisible: costsVisible, diff --git a/src/Explorer/Tabs/SettingsTab.test.ts b/src/Explorer/Tabs/SettingsTab.test.ts index 990d5a8ee..93a1b56b8 100644 --- a/src/Explorer/Tabs/SettingsTab.test.ts +++ b/src/Explorer/Tabs/SettingsTab.test.ts @@ -34,17 +34,6 @@ describe("Settings tab", () => { collections: [baseCollection] }; - const quotaInfo: DataModels.CollectionQuotaInfo = { - storedProcedures: 0, - triggers: 0, - functions: 0, - documentsSize: 0, - documentsCount: 0, - collectionSize: 0, - usageSizeInKB: 0, - numPartitions: 0 - }; - describe("Conflict Resolution", () => { describe("should show conflict resolution", () => { let explorer: Explorer; @@ -70,7 +59,6 @@ describe("Settings tab", () => { explorer, "mydb", conflictResolution ? baseCollection : baseCollectionWithoutConflict, - quotaInfo, null ), onUpdateTabsButtons: undefined @@ -186,7 +174,7 @@ describe("Settings tab", () => { tabPath: "", hashLocation: "", isActive: ko.observable(false), - collection: new Collection(explorer, "mydb", baseCollection, quotaInfo, null), + collection: new Collection(explorer, "mydb", baseCollection, null), onUpdateTabsButtons: (buttons: CommandButtonComponentProps[]): void => {} }); @@ -207,7 +195,7 @@ describe("Settings tab", () => { tabPath: "", hashLocation: "", isActive: ko.observable(false), - collection: new Collection(explorer, "mydb", baseCollection, quotaInfo, null), + collection: new Collection(explorer, "mydb", baseCollection, null), onUpdateTabsButtons: (buttons: CommandButtonComponentProps[]): void => {} }); @@ -223,7 +211,7 @@ describe("Settings tab", () => { tabPath: "", hashLocation: "", isActive: ko.observable(false), - collection: new Collection(explorer, "mydb", baseCollection, quotaInfo, null), + collection: new Collection(explorer, "mydb", baseCollection, null), onUpdateTabsButtons: (buttons: CommandButtonComponentProps[]): void => {} }); @@ -258,7 +246,7 @@ describe("Settings tab", () => { tabPath: "", hashLocation: "", isActive: ko.observable(false), - collection: new Collection(explorer, "mydb", baseCollection, quotaInfo, null), + collection: new Collection(explorer, "mydb", baseCollection, null), onUpdateTabsButtons: (buttons: CommandButtonComponentProps[]): void => {} }); @@ -272,7 +260,7 @@ describe("Settings tab", () => { tabPath: "", hashLocation: "", isActive: ko.observable(false), - collection: new Collection(explorer, "mydb", baseCollection, quotaInfo, null), + collection: new Collection(explorer, "mydb", baseCollection, null), onUpdateTabsButtons: (buttons: CommandButtonComponentProps[]): void => {} }); @@ -295,7 +283,7 @@ describe("Settings tab", () => { tabPath: "", hashLocation: "", isActive: ko.observable(false), - collection: new Collection(explorer, "mydb", baseCollection, quotaInfo, null), + collection: new Collection(explorer, "mydb", baseCollection, null), onUpdateTabsButtons: (buttons: CommandButtonComponentProps[]): void => {} }); @@ -354,7 +342,6 @@ describe("Settings tab", () => { _ts: 0, id: "mycoll" }, - quotaInfo, offer ); } diff --git a/src/Explorer/Tabs/SettingsTab.ts b/src/Explorer/Tabs/SettingsTab.ts index 95088879b..d1dc67bd8 100644 --- a/src/Explorer/Tabs/SettingsTab.ts +++ b/src/Explorer/Tabs/SettingsTab.ts @@ -20,7 +20,6 @@ import { updateOffer } from "../../Common/dataAccess/updateOffer"; import { updateCollection } from "../../Common/dataAccess/updateCollection"; import { CommandButtonComponentProps } from "../Controls/CommandButton/CommandButtonComponent"; import { userContext } from "../../UserContext"; -import { updateOfferThroughputBeyondLimit } from "../../Common/dataAccess/updateOfferThroughputBeyondLimit"; import { configContext, Platform } from "../../ConfigContext"; import { getErrorMessage, getErrorStack } from "../../Common/ErrorHandlingUtils"; @@ -151,9 +150,6 @@ export default class SettingsTab extends TabsBase implements ViewModels.WaitsFor public saveSettingsButton: ViewModels.Button; public discardSettingsChangesButton: ViewModels.Button; - - public canRequestSupport: ko.Computed; - public canThroughputExceedMaximumValue: ko.Computed; public changeFeedPolicyOffId: string; public changeFeedPolicyOnId: string; public changeFeedPolicyToggled: ViewModels.Editable; @@ -174,8 +170,6 @@ export default class SettingsTab extends TabsBase implements ViewModels.WaitsFor public indexingPolicyElementFocused: ko.Observable; public minRUs: ko.Computed; public minRUAnotationVisible: ko.Computed; - public maxRUs: ko.Computed; - public maxRUThroughputInputLimit: ko.Computed; public maxRUsText: ko.PureComputed; public notificationStatusInfo: ko.Observable; public partitionKeyName: ko.Computed; @@ -188,7 +182,6 @@ export default class SettingsTab extends TabsBase implements ViewModels.WaitsFor public rupmVisible: ko.Computed; public scaleExpanded: ko.Observable; public settingsExpanded: ko.Observable; - public shouldDisplayPortalUsePrompt: ko.Computed; public shouldShowIndexingPolicyEditor: ko.Computed; public shouldShowNotificationStatusPrompt: ko.Computed; public shouldShowStatusBar: ko.Computed; @@ -461,43 +454,6 @@ export default class SettingsTab extends TabsBase implements ViewModels.WaitsFor return (this.container && this.container.isTryCosmosDBSubscription()) || false; }); - this.canThroughputExceedMaximumValue = ko.pureComputed(() => { - return ( - this._isFixedContainer() && - configContext.platform === Platform.Portal && - !this.container.isRunningOnNationalCloud() - ); - }); - - this.canRequestSupport = ko.pureComputed(() => { - if (configContext.platform === Platform.Emulator) { - return false; - } - - if (this.isTryCosmosDBSubscription()) { - return false; - } - - if (this.canThroughputExceedMaximumValue()) { - return false; - } - - if (configContext.platform === Platform.Hosted) { - return false; - } - - if (this.container.isServerlessEnabled()) { - return false; - } - - const numPartitions = this.collection.quotaInfo().numPartitions; - return !!this.collection.partitionKeyProperty || numPartitions > 1; - }); - - this.shouldDisplayPortalUsePrompt = ko.pureComputed( - () => configContext.platform === Platform.Hosted && !!this.collection.partitionKey - ); - this.minRUs = ko.computed(() => { if (this.isTryCosmosDBSubscription() || this.container.isServerlessEnabled()) { return SharedConstants.CollectionCreation.DefaultCollectionRUs400; @@ -507,7 +463,7 @@ export default class SettingsTab extends TabsBase implements ViewModels.WaitsFor this.collection && this.collection.offer && this.collection.offer() && this.collection.offer().content; if (offerContent && offerContent.offerAutopilotSettings) { - return 400; + SharedConstants.CollectionCreation.DefaultCollectionRUs400; } const collectionThroughputInfo: DataModels.OfferThroughputInfo = @@ -521,58 +477,14 @@ export default class SettingsTab extends TabsBase implements ViewModels.WaitsFor return collectionThroughputInfo.minimumRUForCollection; } - const numPartitions = - (collectionThroughputInfo && collectionThroughputInfo.numPhysicalPartitions) || - this.collection.quotaInfo().numPartitions; - - if (!numPartitions || numPartitions === 1) { - return SharedConstants.CollectionCreation.DefaultCollectionRUs400; - } - - let baseRU = SharedConstants.CollectionCreation.DefaultCollectionRUs400; - - const quotaInKb = this.collection.quotaInfo().collectionSize; - const quotaInGb = PricingUtils.usageInGB(quotaInKb); - - const perPartitionGBQuota: number = Math.max(10, quotaInGb / numPartitions); - const baseRUbyPartitions: number = ((numPartitions * perPartitionGBQuota) / 10) * 100; - - return Math.max(baseRU, baseRUbyPartitions); + // minimumRUForCollection should always be present, but just in case return a default + return SharedConstants.CollectionCreation.DefaultCollectionRUs400; }); this.minRUAnotationVisible = ko.computed(() => { return PricingUtils.isLargerThanDefaultMinRU(this.minRUs()); }); - this.maxRUs = ko.computed(() => { - const isTryCosmosDBSubscription = this.isTryCosmosDBSubscription(); - if (isTryCosmosDBSubscription || this.container.isServerlessEnabled()) { - return Constants.TryCosmosExperience.maxRU; - } - - const numPartitionsFromOffer: number = - this.collection && - this.collection.offer && - this.collection.offer() && - this.collection.offer().content && - this.collection.offer().content.collectionThroughputInfo && - this.collection.offer().content.collectionThroughputInfo.numPhysicalPartitions; - - const numPartitionsFromQuotaInfo: number = this.collection && this.collection.quotaInfo().numPartitions; - - const numPartitions = numPartitionsFromOffer || numPartitionsFromQuotaInfo || 1; - - return SharedConstants.CollectionCreation.MaxRUPerPartition * numPartitions; - }); - - this.maxRUThroughputInputLimit = ko.pureComputed(() => { - if (configContext.platform === Platform.Hosted && this.collection.partitionKey) { - return SharedConstants.CollectionCreation.DefaultCollectionRUs1Million; - } - - return this.maxRUs(); - }); - this.maxRUsText = ko.pureComputed(() => { return SharedConstants.CollectionCreation.DefaultCollectionRUs1Million.toLocaleString(); }); @@ -583,10 +495,7 @@ export default class SettingsTab extends TabsBase implements ViewModels.WaitsFor } const minThroughput: string = this.minRUs().toLocaleString(); - const maxThroughput: string = - this.canThroughputExceedMaximumValue() && !this._isFixedContainer() - ? "unlimited" - : this.maxRUs().toLocaleString(); + const maxThroughput: string = !this._isFixedContainer() ? "unlimited" : "10000"; return `Throughput (${minThroughput} - ${maxThroughput} RU/s)`; }); @@ -675,22 +584,6 @@ export default class SettingsTab extends TabsBase implements ViewModels.WaitsFor return false; } - const isThroughputGreaterThanMaxRus = this.throughput() > this.maxRUs(); - const isEmulator = configContext.platform === Platform.Emulator; - if (isThroughputGreaterThanMaxRus && isEmulator) { - return false; - } - - if (isThroughputGreaterThanMaxRus && this._isFixedContainer()) { - return false; - } - - const isThroughputMoreThan1Million = - this.throughput() > SharedConstants.CollectionCreation.DefaultCollectionRUs1Million; - if (!this.canThroughputExceedMaximumValue() && isThroughputMoreThan1Million) { - return false; - } - if (this.throughput.editableIsDirty()) { return true; } @@ -714,14 +607,6 @@ export default class SettingsTab extends TabsBase implements ViewModels.WaitsFor return false; } - if ( - this.rupm() === Constants.RUPMStates.on && - this.throughput() > - SharedConstants.CollectionCreation.MaxRUPMPerPartition * this.collection.quotaInfo()?.numPartitions - ) { - return false; - } - if (this.timeToLive.editableIsDirty()) { return true; } @@ -841,14 +726,6 @@ export default class SettingsTab extends TabsBase implements ViewModels.WaitsFor this.shouldShowNotificationStatusPrompt = ko.computed(() => this.notificationStatusInfo().length > 0); this.warningMessage = ko.computed(() => { - const throughputExceedsBackendLimits: boolean = - this.canThroughputExceedMaximumValue() && - this.maxRUs() <= SharedConstants.CollectionCreation.DefaultCollectionRUs1Million && - this.throughput() > SharedConstants.CollectionCreation.DefaultCollectionRUs1Million; - - const throughputExceedsMaxValue: boolean = - configContext.platform !== Platform.Emulator && this.throughput() > this.maxRUs(); - const ttlOptionDirty: boolean = this.timeToLive.editableIsDirty(); const ttlOrIndexingPolicyFieldsDirty: boolean = this.timeToLive.editableIsDirty() || @@ -890,26 +767,6 @@ export default class SettingsTab extends TabsBase implements ViewModels.WaitsFor return AutoPilotUtils.manualToAutoscaleDisclaimer; } - if ( - throughputExceedsBackendLimits && - !!this.collection.partitionKey && - !this._isFixedContainer() && - !ttlFieldFocused && - !this.indexingPolicyElementFocused() - ) { - return updateThroughputBeyondLimitWarningMessage; - } - - if ( - throughputExceedsMaxValue && - !!this.collection.partitionKey && - !this._isFixedContainer() && - !ttlFieldFocused && - !this.indexingPolicyElementFocused() - ) { - return updateThroughputDelayedApplyWarningMessage; - } - if (this.pendingNotification()) { const throughputUnit: string = this._getThroughputUnit(); const matches: string[] = this.pendingNotification().description.match( @@ -1099,54 +956,23 @@ export default class SettingsTab extends TabsBase implements ViewModels.WaitsFor } } - if ( - this.maxRUs() <= SharedConstants.CollectionCreation.DefaultCollectionRUs1Million && - newThroughput > SharedConstants.CollectionCreation.DefaultCollectionRUs1Million && - this.container != null - ) { - const requestPayload = { - subscriptionId: userContext.subscriptionId, - databaseAccountName: userContext.databaseAccount.name, - resourceGroup: userContext.resourceGroup, - databaseName: this.collection.databaseId, - collectionName: this.collection.id(), - throughput: newThroughput, - offerIsRUPerMinuteThroughputEnabled: isRUPerMinuteThroughputEnabled - }; - - await updateOfferThroughputBeyondLimit(requestPayload); - 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 - } else { - const updateOfferParams: DataModels.UpdateOfferParams = { - databaseId: this.collection.databaseId, - collectionId: this.collection.id(), - currentOffer: this.collection.offer(), - autopilotThroughput: this.isAutoPilotSelected() ? this.autoPilotThroughput() : undefined, - manualThroughput: this.isAutoPilotSelected() ? undefined : newThroughput - }; - if (this._hasProvisioningTypeChanged()) { - if (this.isAutoPilotSelected()) { - updateOfferParams.migrateToAutoPilot = true; - } else { - updateOfferParams.migrateToManual = true; - } + const updateOfferParams: DataModels.UpdateOfferParams = { + databaseId: this.collection.databaseId, + collectionId: this.collection.id(), + currentOffer: this.collection.offer(), + autopilotThroughput: this.isAutoPilotSelected() ? this.autoPilotThroughput() : undefined, + manualThroughput: this.isAutoPilotSelected() ? undefined : newThroughput + }; + if (this._hasProvisioningTypeChanged()) { + if (this.isAutoPilotSelected()) { + updateOfferParams.migrateToAutoPilot = true; + } else { + updateOfferParams.migrateToManual = true; } - const updatedOffer: DataModels.Offer = await updateOffer(updateOfferParams); - this.collection.offer(updatedOffer); - this.collection.offer.valueHasMutated(); } + const updatedOffer: DataModels.Offer = await updateOffer(updateOfferParams); + this.collection.offer(updatedOffer); + this.collection.offer.valueHasMutated(); } this.container.isRefreshingExplorer(false); diff --git a/src/Explorer/Tree/Collection.test.ts b/src/Explorer/Tree/Collection.test.ts index c95d41e94..7dc48f366 100644 --- a/src/Explorer/Tree/Collection.test.ts +++ b/src/Explorer/Tree/Collection.test.ts @@ -10,10 +10,9 @@ describe("Collection", () => { container: Explorer, databaseId: string, data: DataModels.Collection, - quotaInfo: DataModels.CollectionQuotaInfo, offer: DataModels.Offer ): Collection { - return new Collection(container, databaseId, data, quotaInfo, offer); + return new Collection(container, databaseId, data, offer); } function generateMockCollectionsDataModelWithPartitionKey( @@ -50,7 +49,7 @@ describe("Collection", () => { }); mockContainer.deleteCollectionText = ko.observable("delete collection"); - return generateCollection(mockContainer, "abc", data, {} as DataModels.CollectionQuotaInfo, {} as DataModels.Offer); + return generateCollection(mockContainer, "abc", data, {} as DataModels.Offer); } describe("Partition key path parsing", () => { diff --git a/src/Explorer/Tree/Collection.ts b/src/Explorer/Tree/Collection.ts index c5db74aeb..fb091b285 100644 --- a/src/Explorer/Tree/Collection.ts +++ b/src/Explorer/Tree/Collection.ts @@ -10,7 +10,6 @@ import { readTriggers } from "../../Common/dataAccess/readTriggers"; import { readUserDefinedFunctions } from "../../Common/dataAccess/readUserDefinedFunctions"; import { createDocument } from "../../Common/DocumentClientUtilityBase"; import { readCollectionOffer } from "../../Common/dataAccess/readCollectionOffer"; -import { readCollectionQuotaInfo } from "../../Common/dataAccess/readCollectionQuotaInfo"; import * as Logger from "../../Common/Logger"; import * as DataModels from "../../Contracts/DataModels"; import * as ViewModels from "../../Contracts/ViewModels"; @@ -55,7 +54,6 @@ export default class Collection implements ViewModels.Collection { public defaultTtl: ko.Observable; public indexingPolicy: ko.Observable; public uniqueKeyPolicy: DataModels.UniqueKeyPolicy; - public quotaInfo: ko.Observable; public offer: ko.Observable; public conflictResolutionPolicy: ko.Observable; public changeFeedPolicy: ko.Observable; @@ -94,13 +92,7 @@ export default class Collection implements ViewModels.Collection { public userDefinedFunctionsFocused: ko.Observable; public triggersFocused: ko.Observable; - constructor( - container: Explorer, - databaseId: string, - data: DataModels.Collection, - quotaInfo: DataModels.CollectionQuotaInfo, - offer: DataModels.Offer - ) { + constructor(container: Explorer, databaseId: string, data: DataModels.Collection, offer: DataModels.Offer) { this.nodeKind = "Collection"; this.container = container; this.self = data._self; @@ -112,7 +104,6 @@ export default class Collection implements ViewModels.Collection { this.id = ko.observable(data.id); this.defaultTtl = ko.observable(data.defaultTtl); this.indexingPolicy = ko.observable(data.indexingPolicy); - this.quotaInfo = ko.observable(quotaInfo); this.offer = ko.observable(offer); this.conflictResolutionPolicy = ko.observable(data.conflictResolutionPolicy); this.changeFeedPolicy = ko.observable(data.changeFeedPolicy); @@ -669,14 +660,6 @@ export default class Collection implements ViewModels.Collection { } }; - private async loadCollectionQuotaInfo(): Promise { - // TODO: Use the collection entity cache to get quota info - const quotaInfoWithUniqueKeyPolicy = await readCollectionQuotaInfo(this); - this.uniqueKeyPolicy = quotaInfoWithUniqueKeyPolicy.uniqueKeyPolicy; - const quotaInfo = _.omit(quotaInfoWithUniqueKeyPolicy, "uniqueKeyPolicy"); - this.quotaInfo(quotaInfo); - } - public onNewQueryClick(source: any, event: MouseEvent, queryText?: string) { const collection: ViewModels.Collection = source.collection || source; const id = this.container.tabsManager.getTabs(ViewModels.CollectionTabKind.Query).length + 1; @@ -1349,7 +1332,6 @@ export default class Collection implements ViewModels.Collection { try { this.offer(await readCollectionOffer(params)); - await this.loadCollectionQuotaInfo(); TelemetryProcessor.traceSuccess( Action.LoadOffers, diff --git a/src/Explorer/Tree/Database.ts b/src/Explorer/Tree/Database.ts index 304774bfd..8cc6c347c 100644 --- a/src/Explorer/Tree/Database.ts +++ b/src/Explorer/Tree/Database.ts @@ -185,7 +185,7 @@ export default class Database implements ViewModels.Database { const deltaCollections = this.getDeltaCollections(collections); deltaCollections.toAdd.forEach((collection: DataModels.Collection) => { - const collectionVM: Collection = new Collection(this.container, this.id(), collection, null, null); + const collectionVM: Collection = new Collection(this.container, this.id(), collection, null); collectionVMs.push(collectionVM); });