Skip to content

Commit

Permalink
fix: Clear native filters state (apache#16893)
Browse files Browse the repository at this point in the history
* fix:fix get permission function

* fix: clear native filters state
  • Loading branch information
simcha90 committed Sep 29, 2021
1 parent e71f5cb commit 707011f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions superset-frontend/src/dashboard/components/Dashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const propTypes = {
removeSliceFromDashboard: PropTypes.func.isRequired,
triggerQuery: PropTypes.func.isRequired,
logEvent: PropTypes.func.isRequired,
clearDataMaskState: PropTypes.func.isRequired,
}).isRequired,
dashboardInfo: dashboardInfoPropShape.isRequired,
dashboardState: dashboardStatePropShape.isRequired,
Expand Down Expand Up @@ -194,6 +195,7 @@ class Dashboard extends React.PureComponent {

componentWillUnmount() {
window.removeEventListener('visibilitychange', this.onVisibilityChange);
this.props.actions.clearDataMaskState();
}

onVisibilityChange() {
Expand Down
2 changes: 2 additions & 0 deletions superset-frontend/src/dashboard/containers/Dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
getAllActiveFilters,
getRelevantDataMask,
} from 'src/dashboard/util/activeAllDashboardFilters';
import { clearDataMaskState } from '../../dataMask/actions';

function mapStateToProps(state: RootState) {
const {
Expand Down Expand Up @@ -83,6 +84,7 @@ function mapDispatchToProps(dispatch: Dispatch) {
actions: bindActionCreators(
{
setDatasources,
clearDataMaskState,
addSliceToDashboard,
removeSliceFromDashboard,
triggerQuery,
Expand Down
12 changes: 12 additions & 0 deletions superset-frontend/src/dataMask/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ import { FeatureFlag, isFeatureEnabled } from '../featureFlags';
import { Filters } from '../dashboard/reducers/types';
import { getInitialDataMask } from './reducer';

export const CLEAR_DATA_MASK_STATE = 'CLEAR_DATA_MASK_STATE';
export interface ClearDataMaskState {
type: typeof CLEAR_DATA_MASK_STATE;
}

export const UPDATE_DATA_MASK = 'UPDATE_DATA_MASK';
export interface UpdateDataMask {
type: typeof UPDATE_DATA_MASK;
Expand Down Expand Up @@ -74,7 +79,14 @@ export function clearDataMask(filterId: string | number) {
return updateDataMask(filterId, getInitialDataMask(filterId));
}

export function clearDataMaskState(): ClearDataMaskState {
return {
type: CLEAR_DATA_MASK_STATE,
};
}

export type AnyDataMaskAction =
| ClearDataMaskState
| UpdateDataMask
| SetDataMaskForFilterConfigFail
| SetDataMaskForFilterConfigComplete;
3 changes: 3 additions & 0 deletions superset-frontend/src/dataMask/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { URL_PARAMS } from 'src/constants';
import { DataMaskStateWithId, DataMaskWithId } from './types';
import {
AnyDataMaskAction,
CLEAR_DATA_MASK_STATE,
SET_DATA_MASK_FOR_FILTER_CONFIG_COMPLETE,
UPDATE_DATA_MASK,
} from './actions';
Expand Down Expand Up @@ -102,6 +103,8 @@ const dataMaskReducer = produce(
(draft: DataMaskStateWithId, action: AnyDataMaskAction) => {
const cleanState = {};
switch (action.type) {
case CLEAR_DATA_MASK_STATE:
return cleanState;
case UPDATE_DATA_MASK:
draft[action.filterId] = {
...getInitialDataMask(action.filterId),
Expand Down

0 comments on commit 707011f

Please sign in to comment.