diff --git a/src/Explorer/Controls/Settings/SettingsComponent.tsx b/src/Explorer/Controls/Settings/SettingsComponent.tsx index ee3393ee9..d38ce0b22 100644 --- a/src/Explorer/Controls/Settings/SettingsComponent.tsx +++ b/src/Explorer/Controls/Settings/SettingsComponent.tsx @@ -5,18 +5,18 @@ import DiscardIcon from "../../../../images/discard.svg"; import SaveIcon from "../../../../images/save-cosmos.svg"; import { AuthType } from "../../../AuthType"; import * as Constants from "../../../Common/Constants"; +import { getErrorMessage, getErrorStack } from "../../../Common/ErrorHandlingUtils"; import { getIndexTransformationProgress } from "../../../Common/dataAccess/getIndexTransformationProgress"; import { readMongoDBCollectionThroughRP } from "../../../Common/dataAccess/readMongoDBCollection"; import { updateCollection } 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 { userContext } from "../../../UserContext"; -import { MongoDBCollectionResource, MongoIndex } from "../../../Utils/arm/generatedClients/cosmos/types"; import * as AutoPilotUtils from "../../../Utils/AutoPilotUtils"; +import { MongoDBCollectionResource, MongoIndex } from "../../../Utils/arm/generatedClients/cosmos/types"; import { CommandButtonComponentProps } from "../../Controls/CommandButton/CommandButtonComponent"; import { useCommandBar } from "../../Menus/CommandBar/CommandBarComponentAdapter"; import { SettingsTabV2 } from "../../Tabs/SettingsTabV2"; @@ -37,15 +37,15 @@ import { AddMongoIndexProps, ChangeFeedPolicyState, GeospatialConfigType, + MongoIndexTypes, + SettingsV2TabTypes, + TtlType, getMongoNotification, getTabTitle, hasDatabaseSharedThroughput, isDirty, - MongoIndexTypes, parseConflictResolutionMode, parseConflictResolutionProcedure, - SettingsV2TabTypes, - TtlType, } from "./SettingsUtils"; interface SettingsV2TabInfo { @@ -78,6 +78,8 @@ export interface SettingsComponentState { timeToLiveBaseline: TtlType; timeToLiveSeconds: number; timeToLiveSecondsBaseline: number; + displayedTtlSeconds: string; + displayedTtlSecondsBaseline: string; geospatialConfigType: GeospatialConfigType; geospatialConfigTypeBaseline: GeospatialConfigType; analyticalStorageTtlSelection: TtlType; @@ -164,6 +166,8 @@ export class SettingsComponent extends React.Component this.setState({ timeToLiveSeconds: newTimeToLiveSeconds }); + private onDisplayedTtlChange = (newDisplayedTtlSeconds: string): void => + this.setState({ displayedTtlSeconds: newDisplayedTtlSeconds }); + private onGeoSpatialConfigTypeChange = (newGeoSpatialConfigType: GeospatialConfigType): void => this.setState({ geospatialConfigType: newGeoSpatialConfigType }); @@ -608,6 +616,8 @@ export class SettingsComponent extends React.Component { onTimeToLiveSecondsChange: () => { return; }, + displayedTtlSeconds: "1000", + onDisplayedTtlSecondsChange: () => { + return; + }, geospatialConfigType: GeospatialConfigType.Geography, geospatialConfigTypeBaseline: GeospatialConfigType.Geography, diff --git a/src/Explorer/Controls/Settings/SettingsSubComponents/SubSettingsComponent.tsx b/src/Explorer/Controls/Settings/SettingsSubComponents/SubSettingsComponent.tsx index f3d82a17a..ffebfcc55 100644 --- a/src/Explorer/Controls/Settings/SettingsSubComponents/SubSettingsComponent.tsx +++ b/src/Explorer/Controls/Settings/SettingsSubComponents/SubSettingsComponent.tsx @@ -15,13 +15,13 @@ import { import { ChangeFeedPolicyState, GeospatialConfigType, - getSanitizedInputValue, IsComponentDirtyResult, - isDirty, TtlOff, TtlOn, TtlOnNoDefault, TtlType, + getSanitizedInputValue, + isDirty, } from "../SettingsUtils"; import { ToolTipLabelComponent } from "./ToolTipLabelComponent"; @@ -34,6 +34,8 @@ export interface SubSettingsComponentProps { timeToLiveSeconds: number; timeToLiveSecondsBaseline: number; onTimeToLiveSecondsChange: (newTimeToLiveSeconds: number) => void; + displayedTtlSeconds: string; + onDisplayedTtlSecondsChange: (newDisplayedTtlSeconds: string) => void; geospatialConfigType: GeospatialConfigType; geospatialConfigTypeBaseline: GeospatialConfigType; @@ -73,7 +75,14 @@ export class SubSettingsComponent extends React.Component { if ( (this.props.timeToLive === TtlType.On && !this.props.timeToLiveSeconds) || - (this.props.analyticalStorageTtlSelection === TtlType.On && !this.props.analyticalStorageTtlSeconds) + (this.props.analyticalStorageTtlSelection === TtlType.On && !this.props.analyticalStorageTtlSeconds) || + (this.props.timeToLive === TtlType.On && this.props.displayedTtlSeconds === "") ) { return { isSaveable: false, isDiscardable: true }; } else if ( @@ -138,6 +148,7 @@ export class SubSettingsComponent extends React.Component { const newTimeToLiveSeconds = getSanitizedInputValue(newValue, Int32.Max); + this.props.onDisplayedTtlSecondsChange(newTimeToLiveSeconds.toString()); this.props.onTimeToLiveSecondsChange(newTimeToLiveSeconds); }; @@ -204,7 +215,7 @@ export class SubSettingsComponent extends React.Component diff --git a/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap b/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap index bdad7d1f7..5e905e786 100644 --- a/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap +++ b/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap @@ -150,12 +150,14 @@ exports[`SettingsComponent renders 1`] = ` "usageSizeInKB": [Function], } } + displayedTtlSeconds="5" geospatialConfigType="Geometry" geospatialConfigTypeBaseline="Geometry" isAnalyticalStorageEnabled={false} onAnalyticalStorageTtlSecondsChange={[Function]} onAnalyticalStorageTtlSelectionChange={[Function]} onChangeFeedPolicyChange={[Function]} + onDisplayedTtlSecondsChange={[Function]} onGeoSpatialConfigTypeChange={[Function]} onSubSettingsDiscardableChange={[Function]} onSubSettingsSaveableChange={[Function]}