This is an automated email from the ASF dual-hosted git repository.
amitmiran pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new 3d8cc15 fix: Clear native filters state (#16893)
3d8cc15 is described below
commit 3d8cc15cba1d69e5d75b60405e4cf6282a7b5e0d
Author: simcha90 <[email protected]>
AuthorDate: Wed Sep 29 13:50:21 2021 +0300
fix: Clear native filters state (#16893)
* fix:fix get permission function
* fix: clear native filters state
---
superset-frontend/src/dashboard/components/Dashboard.jsx | 2 ++
superset-frontend/src/dashboard/containers/Dashboard.ts | 2 ++
superset-frontend/src/dataMask/actions.ts | 12 ++++++++++++
superset-frontend/src/dataMask/reducer.ts | 3 +++
4 files changed, 19 insertions(+)
diff --git a/superset-frontend/src/dashboard/components/Dashboard.jsx
b/superset-frontend/src/dashboard/components/Dashboard.jsx
index 8a5e037..7e67288 100644
--- a/superset-frontend/src/dashboard/components/Dashboard.jsx
+++ b/superset-frontend/src/dashboard/components/Dashboard.jsx
@@ -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,
@@ -194,6 +195,7 @@ class Dashboard extends React.PureComponent {
componentWillUnmount() {
window.removeEventListener('visibilitychange', this.onVisibilityChange);
+ this.props.actions.clearDataMaskState();
}
onVisibilityChange() {
diff --git a/superset-frontend/src/dashboard/containers/Dashboard.ts
b/superset-frontend/src/dashboard/containers/Dashboard.ts
index ccca038..60db7b4 100644
--- a/superset-frontend/src/dashboard/containers/Dashboard.ts
+++ b/superset-frontend/src/dashboard/containers/Dashboard.ts
@@ -33,6 +33,7 @@ import {
getAllActiveFilters,
getRelevantDataMask,
} from 'src/dashboard/util/activeAllDashboardFilters';
+import { clearDataMaskState } from '../../dataMask/actions';
function mapStateToProps(state: RootState) {
const {
@@ -83,6 +84,7 @@ function mapDispatchToProps(dispatch: Dispatch) {
actions: bindActionCreators(
{
setDatasources,
+ clearDataMaskState,
addSliceToDashboard,
removeSliceFromDashboard,
triggerQuery,
diff --git a/superset-frontend/src/dataMask/actions.ts
b/superset-frontend/src/dataMask/actions.ts
index aabaa5b..b2f8c58 100644
--- a/superset-frontend/src/dataMask/actions.ts
+++ b/superset-frontend/src/dataMask/actions.ts
@@ -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;
@@ -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;
diff --git a/superset-frontend/src/dataMask/reducer.ts
b/superset-frontend/src/dataMask/reducer.ts
index 6c2248d..7926775 100644
--- a/superset-frontend/src/dataMask/reducer.ts
+++ b/superset-frontend/src/dataMask/reducer.ts
@@ -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';
@@ -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),