Skip to content

Commit

Permalink
add hidden option to AdHocFilters
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkancso committed Dec 20, 2024
1 parent fc15e94 commit 88e9d95
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
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

0 comments on commit 88e9d95

Please sign in to comment.