Skip to content

Commit

Permalink
Merge #66321
Browse files Browse the repository at this point in the history
66321: ui: drag-to-select time range on custom charts page r=elkmaster a=elkmaster

provide missing props to make custom chart drag-to-select
feature work the same as on the main metrics page

Resolves: #64792

Release note(ui): add drag-to-select timescale feature to
custom charts page

Co-authored-by: Vlad Los <[email protected]>
  • Loading branch information
craig[bot] and vladlos committed Jun 24, 2021
2 parents 663a44a + a451751 commit f661758
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/ui/src/views/cluster/components/linegraph/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ export class LineGraph extends React.Component<LineGraphProps, {}> {
// TODO(davidh): figure out why the timescale doesn't get more granular
// automatically when a narrower time frame is selected.
setNewTimeRange(startMillis: number, endMillis: number) {
if (startMillis === endMillis) return;
const start = MilliToSeconds(startMillis);
const end = MilliToSeconds(endMillis);
this.props.setTimeRange({
Expand Down
18 changes: 17 additions & 1 deletion pkg/ui/src/views/reports/containers/customChart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,22 @@ import { INodeStatus } from "src/util/proto";
import { CustomChartState, CustomChartTable } from "./customMetric";
import "./customChart.styl";
import { queryByName } from "src/util/query";
import { PayloadAction } from "src/interfaces/action";
import {
TimeWindow,
TimeScale,
setTimeRange,
setTimeScale,
} from "src/redux/timewindow";

export interface CustomChartProps {
refreshNodes: typeof refreshNodes;
nodesQueryValid: boolean;
nodesSummary: NodesSummary;
refreshMetricMetadata: typeof refreshMetricMetadata;
metricsMetadata: MetricsMetadata;
setTimeRange: (tw: TimeWindow) => PayloadAction<TimeWindow>;
setTimeScale: (ts: TimeScale) => PayloadAction<TimeScale>;
}

interface UrlState {
Expand Down Expand Up @@ -193,7 +202,12 @@ export class CustomChart extends React.Component<
const { nodesSummary } = this.props;

return (
<MetricsDataProvider id={`debug-custom-chart.${index}`} key={index}>
<MetricsDataProvider
id={`debug-custom-chart.${index}`}
key={index}
setTimeRange={this.props.setTimeRange}
setTimeScale={this.props.setTimeScale}
>
<LineGraph>
<Axis units={units}>
{metrics.map((m, i) => {
Expand Down Expand Up @@ -313,6 +327,8 @@ const mapStateToProps = (state: AdminUIState) => ({
const mapDispatchToProps = {
refreshNodes,
refreshMetricMetadata,
setTimeRange,
setTimeScale,
};

export default withRouter(
Expand Down

0 comments on commit f661758

Please sign in to comment.