Skip to content

Commit d74648f

Browse files
committed
ui: improve timeperiod display
Previously, the period being shown on SQL Activity page could be confusing, since we no longer refresh the page automatically. This could result in a scenario where a query is executed, the user click on Apply on the Search Criteria on X:05, but the page shows that the results goes up to X:59, but then if you executed new statements they won't show until Apply is clicked again, but because we still show the message that the results are up to X:59 this is misleading. This commit updates the value being displayed to use the time the request was made, so we know the end window value, and even if the user changes page and go back, the value is still the X:05, making more obvious they need to click on Apply again if they want to see newer results. Epic: none Release note: None
1 parent 658aa0d commit d74648f

5 files changed

Lines changed: 25 additions & 4 deletions

File tree

pkg/ui/workspaces/cluster-ui/src/statementDetails/statementDetails.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,9 @@ export class StatementDetails extends React.Component<
247247
this.props.diagnosticsReports.length > 0;
248248

249249
changeTimeScale = (ts: TimeScale): void => {
250+
if (ts.key !== "Custom") {
251+
ts.fixedWindowEnd = moment();
252+
}
250253
if (this.props.onTimeScaleChange) {
251254
this.props.onTimeScaleChange(ts);
252255
}
@@ -491,7 +494,7 @@ export class StatementDetails extends React.Component<
491494
<TimeScaleDropdown
492495
options={timeScale1hMinOptions}
493496
currentScale={this.props.timeScale}
494-
setTimeScale={this.props.onTimeScaleChange}
497+
setTimeScale={this.changeTimeScale}
495498
/>
496499
</PageConfigItem>
497500
</PageConfig>
@@ -510,7 +513,7 @@ export class StatementDetails extends React.Component<
510513
<TimeScaleDropdown
511514
options={timeScale1hMinOptions}
512515
currentScale={this.props.timeScale}
513-
setTimeScale={this.props.onTimeScaleChange}
516+
setTimeScale={this.changeTimeScale}
514517
/>
515518
</PageConfigItem>
516519
</PageConfig>
@@ -944,7 +947,7 @@ export class StatementDetails extends React.Component<
944947
}
945948
onSortingChange={this.props.onSortingChange}
946949
currentScale={this.props.timeScale}
947-
onChangeTimeScale={this.props.onTimeScaleChange}
950+
onChangeTimeScale={this.changeTimeScale}
948951
/>
949952
);
950953
};

pkg/ui/workspaces/cluster-ui/src/statementsPage/statementsPage.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,9 @@ export class StatementsPage extends React.Component<
262262
};
263263

264264
changeTimeScale = (ts: TimeScale): void => {
265+
if (ts.key !== "Custom") {
266+
ts.fixedWindowEnd = moment();
267+
}
265268
this.setState(prevState => ({
266269
...prevState,
267270
timeScale: ts,
@@ -277,6 +280,8 @@ export class StatementsPage extends React.Component<
277280
this.props.onChangeReqSort(this.state.reqSortSetting);
278281
}
279282

283+
// Force an update on TimeScale to update the fixedWindowEnd
284+
this.changeTimeScale(this.state.timeScale);
280285
if (this.props.timeScale !== this.state.timeScale) {
281286
this.props.onTimeScaleChange(this.state.timeScale);
282287
}

pkg/ui/workspaces/cluster-ui/src/timeScaleDropdown/formattedTimeScale.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ export const FormattedTimescale = (props: { ts: TimeScale }) => {
2929
const dateEnd =
3030
omitDayFormat || startEndOnSameDay ? "" : endTz.format(dateFormat);
3131
const timeStart = startTz.format(timeFormat);
32-
const timeEnd = endTz.format(timeFormat);
32+
const timeEnd =
33+
props.ts.key !== "Custom" && props.ts.fixedWindowEnd
34+
? props.ts.fixedWindowEnd.tz(timezone).format(timeFormat)
35+
: endTz.format(timeFormat);
3336

3437
return (
3538
<>

pkg/ui/workspaces/cluster-ui/src/transactionDetails/transactionDetails.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import classNames from "classnames/bind";
1414
import _ from "lodash";
1515
import { RouteComponentProps } from "react-router-dom";
1616
import { Helmet } from "react-helmet";
17+
import moment from "moment-timezone";
1718

1819
import statementsStyles from "../statementsPage/statementsPage.module.scss";
1920
import {
@@ -223,6 +224,9 @@ export class TransactionDetails extends React.Component<
223224
};
224225

225226
changeTimeScale = (ts: TimeScale): void => {
227+
if (ts.key !== "Custom") {
228+
ts.fixedWindowEnd = moment();
229+
}
226230
if (this.props.onTimeScaleChange) {
227231
this.props.onTimeScaleChange(ts);
228232
}

pkg/ui/workspaces/cluster-ui/src/transactionsPage/transactionsPage.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ import { SearchCriteria } from "src/searchCriteria/searchCriteria";
8484
import timeScaleStyles from "../timeScaleDropdown/timeScale.module.scss";
8585
import { FormattedTimescale } from "../timeScaleDropdown/formattedTimeScale";
8686
import { RequestState } from "../api";
87+
import moment from "moment-timezone";
8788

8889
const cx = classNames.bind(styles);
8990
const timeScaleStylesCx = classNames.bind(timeScaleStyles);
@@ -384,6 +385,9 @@ export class TransactionsPage extends React.Component<
384385
};
385386

386387
changeTimeScale = (ts: TimeScale): void => {
388+
if (ts.key !== "Custom") {
389+
ts.fixedWindowEnd = moment();
390+
}
387391
this.setState(prevState => ({ ...prevState, timeScale: ts }));
388392
};
389393

@@ -404,6 +408,8 @@ export class TransactionsPage extends React.Component<
404408
this.props.onChangeReqSort(this.state.reqSortSetting);
405409
}
406410

411+
// Force an update on TimeScale to update the fixedWindowEnd
412+
this.changeTimeScale(this.state.timeScale);
407413
if (this.props.timeScale !== this.state.timeScale) {
408414
this.props.onTimeScaleChange(this.state.timeScale);
409415
}

0 commit comments

Comments
 (0)