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

AdHocFilters: add hidden option #1012

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 9 additions & 5 deletions packages/scenes/src/variables/adhoc/AdHocFiltersVariable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export interface AdHocFilterWithLabels extends AdHocVariableFilter {
valueLabels?: string[];
// this is used to externally trigger edit mode in combobox filter UI
forceEdit?: boolean;
// hide the filter from AdHocFiltersVariableRenderer and the URL
hidden?: boolean;
}

export type AdHocControlsLayout = ControlsLayout | 'combobox';
Expand Down Expand Up @@ -402,11 +404,13 @@ export function AdHocFiltersVariableRenderer({ model }: SceneComponentProps<AdHo

return (
<div className={styles.wrapper}>
{filters.map((filter, index) => (
<React.Fragment key={index}>
<AdHocFilterRenderer filter={filter} model={model} />
</React.Fragment>
))}
{filters
.filter((filter) => !filter.hidden)
.map((filter, index) => (
<React.Fragment key={index}>
<AdHocFilterRenderer filter={filter} model={model} />
</React.Fragment>
))}

{!readOnly && <AdHocFilterBuilder model={model} key="'builder" addFilterButtonText={addFilterButtonText} />}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export class AdHocFiltersVariableUrlSyncHandler implements SceneObjectUrlSyncHan

const value = filters
.filter(isFilterComplete)
.filter((filter) => !filter.hidden)
.map((filter) => toArray(filter).map(escapeUrlPipeDelimiters).join('|'));
return { [this.getKey()]: value };
}
Expand Down
Loading