Skip to content

Commit

Permalink
Do not display info for dashboard query filter in aggregation builder…
Browse files Browse the repository at this point in the history
…, when dashboard query is empty (#18241)

* Do not display info for dashboard query filter in aggregation builder, when dashboard query is empty.

* Add changelog.

* Adding test
  • Loading branch information
linuspahl authored Feb 26, 2024
1 parent 4aabd3e commit 3f4e197
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions changelog/unreleased/pr-18241.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
type = "f"
message = "Do not display info for dashboard query filter in aggregation builder, when dashboard query is empty"

pulls = ["18241"]
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,14 @@ describe('WidgetQueryControls', () => {
renderSUT();

expect(screen.queryByRole('button', { name: resetTimeRangeButtonTitle })).toBeNull();
expect(screen.queryByRole('button', { name: resetTimeRangeButtonTitle })).toBeNull();
expect(screen.queryByRole('button', { name: resetQueryButtonTitle })).toBeNull();
});

it('does not show global override query indicator if global override query is an object with an empty query string', async () => {
asMock(useGlobalOverride).mockReturnValue(GlobalOverride.create(undefined, { type: 'elasticsearch', query_string: '' }));
renderSUT();

expect(screen.queryByRole('button', { name: resetQueryButtonTitle })).toBeNull();
});

it('triggers resetting global override when reset time range override button is clicked', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ const WidgetQueryControls = ({ availableStreams }: Props) => {
const pluggableSearchBarControls = usePluginEntities('views.components.searchBar');
const limitDuration = moment.duration(config?.query_time_range_limit).asSeconds() ?? 0;
const hasTimeRangeOverride = globalOverride?.timerange !== undefined;
const hasQueryOverride = globalOverride?.query !== undefined;
const hasQueryOverride = !!globalOverride?.query?.query_string;
const formRef = useRef(null);
const { parameters } = useParameters();
const handlerContext = useHandlerContext();
Expand Down

0 comments on commit 3f4e197

Please sign in to comment.