Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AdHocVariable: Edit injected filters #1062

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

mdvictor
Copy link
Collaborator

@mdvictor mdvictor commented Feb 26, 2025

Allows adhocs to show and edit base filters if they have an origin.

Holds base filters into url sync to allow for passing them over from one dashboard to another, alongside the source and original value of a injected filter.

📦 Published PR as canary version: 6.2.0--canary.1062.13673471910.0

✨ Test out this PR locally via:

npm install @grafana/[email protected]
npm install @grafana/[email protected]
# or 
yarn add @grafana/[email protected]
yarn add @grafana/[email protected]

@mdvictor mdvictor marked this pull request as draft February 26, 2025 13:29
@mdvictor mdvictor added minor Increment the minor version when merged release Create a release when this pr is merged labels Feb 26, 2025
Base automatically changed from mdvictor/show-base-filters-in-ui to main February 27, 2025 09:43
@mdvictor mdvictor requested a review from dprokop February 28, 2025 10:36
@mdvictor mdvictor marked this pull request as ready for review February 28, 2025 10:44
@mdvictor mdvictor marked this pull request as draft February 28, 2025 10:44
filtersVar._updateFilter(filtersVar.state.filters[0], { key: 'newKey', keyLabel: 'newKey' });
});

// injected filters stored in the following format: normal|adhoc|values\original|values\filterOrigin
Copy link
Member

Choose a reason for hiding this comment

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

I think the format is fine, question is if you sync them always? I think we should probably sync them only when they have changed, otherwise one will navigate to a dashboard in the same scope.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think you are right. I kept thinking about this and initially thought that both normal filters and baseFilters with an origin should be treated the same, thus having these baseFilters in the URL, same as your average filter, but I agree that there is no point in having both unmodified scope injected filter and the scope itself in there

Comment on lines 14 to 16
private getInjectedKey(): string {
return `var-injected-${this._variable.state.name}`;
}
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need to do this? I think we could sync the injected alongside the regular filters (keys that are injected can't be really overwritten by the user) and figure out which filters were scope-injected based on keys matching and origin. WDYT?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Indeed, no need for another key other than for verbosity, we can identify injected filters based on origin. Removing the extra key

@mdvictor mdvictor marked this pull request as ready for review March 5, 2025 10:08
@mdvictor mdvictor requested a review from Sergej-Vlasov March 5, 2025 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor Increment the minor version when merged release Create a release when this pr is merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants