Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ interface MetricsGraphSectionProps {
selectQuery: (query: QuerySelection) => void;
setProfileSelection: (mergeFrom: bigint, mergeTo: bigint, query: Query) => void;
query: Query;
setNewQueryExpression: (queryExpression: string, commit?: boolean) => void;
setNewQueryExpression: (queryExpression: string) => void;
setQueryExpression: (updateTs?: boolean) => void;
commitDraft: (
refreshedTimeRange?: {from: number; to: number; timeSelection: string},
expression?: string
) => void;
}

export function MetricsGraphSection({
Expand All @@ -57,6 +61,7 @@ export function MetricsGraphSection({
setProfileSelection,
query,
setNewQueryExpression,
commitDraft,
}: MetricsGraphSectionProps): JSX.Element {
const resetStateOnSeriesChange = useResetStateOnSeriesChange();
const batchUpdates = useURLStateBatch();
Expand Down Expand Up @@ -106,9 +111,11 @@ export function MetricsGraphSection({
}

if (hasChanged) {
// TODO: Change this to store the query object
// Pass commit: true to immediately apply the filter when clicking on metrics graph labels
setNewQueryExpression(newQuery.toString(), true);
// Immediately apply the filter when adding label matchers from the graph
batchUpdates(() => {
setNewQueryExpression(newQuery.toString());
commitDraft(undefined, newQuery.toString());
});
}
};

Expand Down
1 change: 1 addition & 0 deletions ui/packages/shared/profile/src/ProfileSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ const ProfileSelector = ({
query={query}
setQueryExpression={setQueryExpression}
setNewQueryExpression={setDraftExpression}
commitDraft={commitDraft}
/>
</>
);
Expand Down
2 changes: 1 addition & 1 deletion ui/packages/shared/profile/src/hooks/useQueryState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ interface UseQueryStateReturn {
draftSelection: QuerySelection;

// Draft setters (update local state only)
setDraftExpression: (expression: string, commit?: boolean) => void;
setDraftExpression: (expression: string) => void;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we never use this commit boolean anywhere so removing it

setDraftTimeRange: (from: number, to: number, timeSelection: string) => void;
setDraftSumBy: (sumBy: string[] | undefined) => void;
setDraftProfileName: (profileName: string) => void;
Expand Down
Loading