diff --git a/pkg/ui/src/redux/timewindow.ts b/pkg/ui/src/redux/timewindow.ts index dfdc59a4f182..d22511f7f94c 100644 --- a/pkg/ui/src/redux/timewindow.ts +++ b/pkg/ui/src/redux/timewindow.ts @@ -136,10 +136,10 @@ export class TimeWindowState { currentWindow: TimeWindow; // True if scale has changed since currentWindow was generated. scaleChanged: boolean; - useTimeRage: boolean; + useTimeRange: boolean; constructor() { this.scale = availableTimeScales["Past 10 Minutes"]; - this.useTimeRage = false; + this.useTimeRange = false; this.scaleChanged = false; } } @@ -156,16 +156,16 @@ export function timeWindowReducer(state = new TimeWindowState(), action: Action) const { payload: data } = action as PayloadAction; state = _.clone(state); state.currentWindow = data; - state.useTimeRage = true; + state.useTimeRange = true; state.scaleChanged = false; return state; case SET_SCALE: const { payload: scale } = action as PayloadAction; state = _.clone(state); if (scale.key === "Custom") { - state.useTimeRage = true; + state.useTimeRange = true; } else { - state.useTimeRage = false; + state.useTimeRange = false; } state.scale = scale; state.scaleChanged = true; diff --git a/pkg/ui/src/views/app/containers/timewindow/index.tsx b/pkg/ui/src/views/app/containers/timewindow/index.tsx index e81229897fba..0a8ac529d697 100644 --- a/pkg/ui/src/views/app/containers/timewindow/index.tsx +++ b/pkg/ui/src/views/app/containers/timewindow/index.tsx @@ -89,7 +89,7 @@ class TimeWindowManager extends React.Component s.localSettings, false, -); - interface TimeScaleDropdownProps extends RouteComponentProps { currentScale: timewindow.TimeScale; currentWindow: timewindow.TimeWindow; @@ -43,8 +35,6 @@ interface TimeScaleDropdownProps extends RouteComponentProps { nodeStatuses: INodeStatus[]; nodeStatusesValid: boolean; // Track whether the default has been set. - setDefaultSet: typeof timescaleDefaultSet.set; - defaultTimescaleSet: boolean; useTimeRange: boolean; } @@ -143,27 +133,8 @@ class TimeScaleDropdown extends React.Component { return timescaleOptions; } - // Sets the default timescale based on the start time of the oldest node. - setDefaultTime(props: TimeScaleDropdownProps = this.props) { - if (props.nodeStatusesValid && !props.defaultTimescaleSet) { - const oldestNode = _.minBy(props.nodeStatuses, (nodeStatus: INodeStatus) => nodeStatus.started_at); - const clusterStarted = LongToMoment(oldestNode.started_at); - // TODO (maxlang): This uses the longest uptime, not the oldest - const clusterDurationHrs = moment.utc().diff(clusterStarted, "hours"); - if (clusterDurationHrs > 1) { - if (clusterDurationHrs < 6) { - props.setTimeScale(props.availableScales["Past 1 Hour"]); - } else if (clusterDurationHrs < 12) { - props.setTimeScale(props.availableScales["Past 6 Hours"]); - } - } - props.setDefaultSet(true); - } - } - componentDidMount() { this.props.refreshNodes(); - this.setDefaultTime(); this.getQueryParams(); } @@ -191,8 +162,6 @@ class TimeScaleDropdown extends React.Component { componentDidUpdate() { if (!this.props.nodeStatusesValid) { this.props.refreshNodes(); - } else if (!this.props.useTimeRange) { - this.setDefaultTime(this.props); } } @@ -326,14 +295,12 @@ export default withRouter(connect( currentScale: (state.timewindow as timewindow.TimeWindowState).scale, currentWindow: (state.timewindow as timewindow.TimeWindowState).currentWindow, availableScales: timewindow.availableTimeScales, - useTimeRange: state.timewindow.useTimeRage, - defaultTimescaleSet: timescaleDefaultSet.selector(state), + useTimeRange: state.timewindow.useTimeRange, }; }, { setTimeScale: timewindow.setTimeScale, setTimeRange: timewindow.setTimeRange, refreshNodes: refreshNodes, - setDefaultSet: timescaleDefaultSet.set, }, )(TimeScaleDropdown));