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

fix: Hide FilterBar for Reports #23543

Merged
merged 2 commits into from
Apr 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,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 @@ -655,18 +658,17 @@ const DashboardBuilder: FC<DashboardBuilderProps> = () => {
>
<StickyPanel ref={containerRef} width={filterBarWidth}>
<ErrorBoundary>
{!isReport && (
Copy link
Member

Choose a reason for hiding this comment

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

We have a few places where we set margins for dashboard so that filter bar fits nicely (such as lines 541 or 628). Should we set them to 0 for reports? Or are they not visible when filter bar is hidden?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think they should stay as it keeps the paddings that are also present in the right side

Screenshot 2023-03-31 at 18 37 19

<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;
`;
geido marked this conversation as resolved.
Show resolved Hide resolved

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