Skip to content

Commit

Permalink
[Fix]: selected time in right container to be used in query-range (#4842
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Rajat Dabade authored Apr 9, 2024
1 parent 6815a96 commit 25b74b4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions frontend/src/container/NewWidget/LeftContainer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function LeftContainer({
selectedTracesFields,
setSelectedTracesFields,
selectedWidget,
selectedTime,
}: WidgetGraphProps): JSX.Element {
const { stagedQuery, redirectWithQueryBuilderData } = useQueryBuilder();
const { selectedDashboard } = useDashboard();
Expand All @@ -50,7 +51,7 @@ function LeftContainer({
return {
query: updatedQuery,
graphType: PANEL_TYPES.LIST,
selectedTime: 'GLOBAL_TIME',
selectedTime: selectedTime.enum || 'GLOBAL_TIME',
globalSelectedInterval,
tableParams: {
pagination: {
Expand All @@ -65,12 +66,13 @@ function LeftContainer({
if (stagedQuery) {
setRequestData((prev) => ({
...prev,
selectedTime: selectedTime.enum || prev.selectedTime,
graphType: getGraphType(selectedGraph || selectedWidget.panelTypes),
query: stagedQuery,
}));
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [stagedQuery]);
}, [stagedQuery, selectedTime]);

const queryResponse = useGetQueryRange(
requestData,
Expand Down
1 change: 1 addition & 0 deletions frontend/src/container/NewWidget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ function NewWidget({ selectedGraph }: NewWidgetProps): JSX.Element {
selectedTracesFields={selectedTracesFields}
setSelectedTracesFields={setSelectedTracesFields}
selectedWidget={selectedWidget}
selectedTime={selectedTime}
/>
)}
</LeftContainerWrapper>
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/container/NewWidget/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { SuccessResponse } from 'types/api';
import { Widgets } from 'types/api/dashboard/getAll';
import { MetricRangePayloadProps } from 'types/api/metrics/getQueryRange';

import { timePreferance } from './RightContainer/timeItems';

export interface NewWidgetProps {
selectedGraph: PANEL_TYPES;
yAxisUnit: Widgets['yAxisUnit'];
Expand All @@ -21,6 +23,7 @@ export interface WidgetGraphProps {
>;
selectedWidget: Widgets;
selectedGraph: PANEL_TYPES;
selectedTime: timePreferance;
}

export type WidgetGraphContainerProps = {
Expand Down

0 comments on commit 25b74b4

Please sign in to comment.