From 2bccb7885f9dd81c96f1610006af8ad2f1b6223b Mon Sep 17 00:00:00 2001 From: victor-meng <56978073+victor-meng@users.noreply.github.com> Date: Thu, 15 Apr 2021 16:51:59 -0700 Subject: [PATCH] Hide TTL in settings tab for Mongo API (#677) * Hide ttl for mongo * Fix typo * Refine info message --- .../SubSettingsComponent.tsx | 93 +++++++++++-------- 1 file changed, 56 insertions(+), 37 deletions(-) diff --git a/src/Explorer/Controls/Settings/SettingsSubComponents/SubSettingsComponent.tsx b/src/Explorer/Controls/Settings/SettingsSubComponents/SubSettingsComponent.tsx index 124dcbbd2..fd0cb538e 100644 --- a/src/Explorer/Controls/Settings/SettingsSubComponents/SubSettingsComponent.tsx +++ b/src/Explorer/Controls/Settings/SettingsSubComponents/SubSettingsComponent.tsx @@ -1,4 +1,13 @@ -import { ChoiceGroup, IChoiceGroupOption, Label, MessageBar, Stack, Text, TextField } from "office-ui-fabric-react"; +import { + ChoiceGroup, + IChoiceGroupOption, + Label, + Link, + MessageBar, + Stack, + Text, + TextField, +} from "office-ui-fabric-react"; import * as React from "react"; import * as ViewModels from "../../../../Contracts/ViewModels"; import { userContext } from "../../../../UserContext"; @@ -61,17 +70,15 @@ export interface SubSettingsComponentProps { export class SubSettingsComponent extends React.Component { private shouldCheckComponentIsDirty = true; - private ttlVisible: boolean; private geospatialVisible: boolean; private partitionKeyValue: string; private partitionKeyName: string; constructor(props: SubSettingsComponentProps) { super(props); - this.ttlVisible = (this.props.container && !this.props.container.isPreferredApiCassandra()) || false; this.geospatialVisible = userContext.apiType === "SQL"; this.partitionKeyValue = "/" + this.props.collection.partitionKeyProperty; - this.partitionKeyName = this.props.container.isPreferredApiMongoDB() ? "Shard key" : "Partition key"; + this.partitionKeyName = userContext.apiType === "Mongo" ? "Shard key" : "Partition key"; } componentDidMount(): void { @@ -171,39 +178,51 @@ export class SubSettingsComponent extends React.Component this.props.onChangeFeedPolicyChange(ChangeFeedPolicyState[option.key as keyof typeof ChangeFeedPolicyState]); - private getTtlComponent = (): JSX.Element => ( - - - {isDirty(this.props.timeToLive, this.props.timeToLiveBaseline) && this.props.timeToLive === TtlType.On && ( - - {ttlWarning} - - )} - {this.props.timeToLive === TtlType.On && ( - + userContext.apiType === "Mongo" ? ( + + To enable time-to-live (TTL) for your collection/documents, + + create a TTL index + + . + + ) : ( + + - )} - - ); + {isDirty(this.props.timeToLive, this.props.timeToLiveBaseline) && this.props.timeToLive === TtlType.On && ( + + {ttlWarning} + + )} + {this.props.timeToLive === TtlType.On && ( + + )} + + ); private analyticalTtlChoiceGroupOptions: IChoiceGroupOption[] = [ { key: TtlType.Off, text: "Off", disabled: true }, @@ -316,7 +335,7 @@ export class SubSettingsComponent extends React.Component - {this.ttlVisible && this.getTtlComponent()} + {userContext.apiType !== "Cassandra" && this.getTtlComponent()} {this.geospatialVisible && this.getGeoSpatialComponent()}