Skip to content

Commit

Permalink
fix: Hide FilterBar for Reports (apache#23543)
Browse files Browse the repository at this point in the history
(cherry picked from commit a18e33b)
  • Loading branch information
geido authored and jinghua-qa committed Apr 10, 2023
1 parent 7c993ac commit 34bfd64
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,10 @@ const DashboardBuilder: FC<DashboardBuilderProps> = () => {
{!hideDashboardHeader && <DashboardHeader />}
{showFilterBar &&
filterBarOrientation === FilterBarOrientation.HORIZONTAL && (
<FilterBar orientation={FilterBarOrientation.HORIZONTAL} />
<FilterBar
orientation={FilterBarOrientation.HORIZONTAL}
hidden={isReport}
/>
)}
{dropIndicatorProps && <div {...dropIndicatorProps} />}
{!isReport && topLevelTabs && !uiConfig.hideNav && (
Expand Down Expand Up @@ -654,18 +657,17 @@ const DashboardBuilder: FC<DashboardBuilderProps> = () => {
>
<StickyPanel ref={containerRef} width={filterBarWidth}>
<ErrorBoundary>
{!isReport && (
<FilterBar
orientation={FilterBarOrientation.VERTICAL}
verticalConfig={{
filtersOpen: dashboardFiltersOpen,
toggleFiltersBar: toggleDashboardFiltersOpen,
width: filterBarWidth,
height: filterBarHeight,
offset: filterBarOffset,
}}
/>
)}
<FilterBar
orientation={FilterBarOrientation.VERTICAL}
verticalConfig={{
filtersOpen: dashboardFiltersOpen,
toggleFiltersBar: toggleDashboardFiltersOpen,
width: filterBarWidth,
height: filterBarHeight,
offset: filterBarOffset,
}}
hidden={isReport}
/>
</ErrorBoundary>
</StickyPanel>
</FiltersPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
SLOW_DEBOUNCE,
isNativeFilter,
usePrevious,
styled,
} from '@superset-ui/core';
import { useHistory } from 'react-router-dom';
import { updateDataMask, clearDataMask } from 'src/dataMask/actions';
Expand All @@ -51,6 +52,10 @@ import ActionButtons from './ActionButtons';
import Horizontal from './Horizontal';
import Vertical from './Vertical';

const HiddenFilterBar = styled.div`
display: none;
`;

const EXCLUDED_URL_PARAMS: string[] = [
URL_PARAMS.nativeFilters.name,
URL_PARAMS.permalinkKey.name,
Expand Down Expand Up @@ -113,6 +118,7 @@ export const FilterBarScrollContext = createContext(false);
const FilterBar: React.FC<FiltersBarProps> = ({
orientation = FilterBarOrientation.VERTICAL,
verticalConfig,
hidden = false,
}) => {
const history = useHistory();
const dataMaskApplied: DataMaskStateWithId = useNativeFiltersDataMask();
Expand Down Expand Up @@ -247,31 +253,38 @@ const FilterBar: React.FC<FiltersBarProps> = ({
/>
);

return orientation === FilterBarOrientation.HORIZONTAL ? (
<Horizontal
actions={actions}
canEdit={canEdit}
dashboardId={dashboardId}
dataMaskSelected={dataMaskSelected}
filterValues={filterValues}
isInitialized={isInitialized}
onSelectionChange={handleFilterSelectionChange}
/>
) : verticalConfig ? (
<Vertical
actions={actions}
canEdit={canEdit}
dataMaskSelected={dataMaskSelected}
filtersOpen={verticalConfig.filtersOpen}
filterValues={filterValues}
isInitialized={isInitialized}
isDisabled={isApplyDisabled}
height={verticalConfig.height}
offset={verticalConfig.offset}
onSelectionChange={handleFilterSelectionChange}
toggleFiltersBar={verticalConfig.toggleFiltersBar}
width={verticalConfig.width}
/>
) : null;
const filterBarComponent =
orientation === FilterBarOrientation.HORIZONTAL ? (
<Horizontal
actions={actions}
canEdit={canEdit}
dashboardId={dashboardId}
dataMaskSelected={dataMaskSelected}
filterValues={filterValues}
isInitialized={isInitialized}
onSelectionChange={handleFilterSelectionChange}
/>
) : verticalConfig ? (
<Vertical
actions={actions}
canEdit={canEdit}
dataMaskSelected={dataMaskSelected}
filtersOpen={verticalConfig.filtersOpen}
filterValues={filterValues}
isInitialized={isInitialized}
isDisabled={isApplyDisabled}
height={verticalConfig.height}
offset={verticalConfig.offset}
onSelectionChange={handleFilterSelectionChange}
toggleFiltersBar={verticalConfig.toggleFiltersBar}
width={verticalConfig.width}
/>
) : null;

return hidden ? (
<HiddenFilterBar>{filterBarComponent}</HiddenFilterBar>
) : (
filterBarComponent
);
};
export default React.memo(FilterBar);
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ interface VerticalBarConfig {
}

export interface FiltersBarProps {
hidden?: boolean;
orientation: FilterBarOrientation;
verticalConfig?: VerticalBarConfig;
}
Expand Down

0 comments on commit 34bfd64

Please sign in to comment.