villebro commented on a change in pull request #13437:
URL: https://github.com/apache/superset/pull/13437#discussion_r587326487



##########
File path: superset-frontend/spec/fixtures/mockNativeFilters.ts
##########
@@ -72,33 +73,34 @@ export const nativeFilters: NativeFiltersState = {
       isInstant: true,
     },
   },
-  filtersState: {
-    crossFilters: {},
-    ownFilters: {},
-    nativeFilters: {
-      'NATIVE_FILTER-e7Q8zKixx': {
-        id: 'NATIVE_FILTER-e7Q8zKixx',
-        extraFormData: {
-          append_form_data: {
-            filters: [
-              {
-                col: 'region',
-                op: 'IN',
-                val: ['East Asia & Pacific'],
-              },
-            ],
-          },
-        },
-        currentState: {
-          value: ['East Asia & Pacific'],
+};
+
+export const datMask: MultipleDataMaskState = {

Review comment:
       typo: `datMask`

##########
File path: 
superset-frontend/src/dashboard/components/nativeFilters/FilterBar/CascadePopover.tsx
##########
@@ -80,7 +82,10 @@ const CascadePopover: React.FC<CascadePopoverProps> = ({
   directPathToChild,
 }) => {
   const [currentPathToChild, setCurrentPathToChild] = useState<string[]>();
-  const filterStateNative = useFilterStateNative(filter.id);
+  const filterStateNative = useSelector<any, MultipleMask>(
+    state =>
+      state.dataMask.nativeFilters[filter.id] ?? getInitialMask(filter.id),
+  );

Review comment:
       👍 

##########
File path: superset-frontend/src/dataMask/types.ts
##########
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { ExtraFormData, DataMaskCurrentState } from '@superset-ui/core';
+
+export enum DataMaskType {
+  NativeFilters = 'nativeFilters',
+  CrossFilters = 'crossFilters',
+  OwnFilters = 'ownFilters',
+}
+
+export type SingleMask = {
+  extraFormData?: ExtraFormData;
+  currentState: DataMaskCurrentState;
+};
+
+export type MultipleMask = SingleMask & { id: string };
+
+export type MultipleDataMask = { [filterId: string]: MultipleMask };
+export type MultipleDataMaskState = {
+  [DataMaskType.NativeFilters]: MultipleDataMask;
+  [DataMaskType.CrossFilters]: MultipleDataMask;
+  [DataMaskType.OwnFilters]: MultipleDataMask;
+};
+
+export type SingleDataMask = { [filterId: string]: SingleMask };
+export type SingleDataMaskState = {
+  [DataMaskType.NativeFilters]: SingleMask;
+  [DataMaskType.CrossFilters]: SingleMask;
+  [DataMaskType.OwnFilters]: SingleMask;
+};

Review comment:
       These feel slightly confusing. I think something like this could help 
clarify for the casual developer that stumbles into this area of the code:
   
   - Instead of `SingleMask` we would have `DataMask`
   - Instead of `MultipleDataMask` we would have `DataMaskWithId`
   - Instead of `MultipleDataMaskState` we would have `DataMaskStateWithId` 
(not thrilled about this name, but it's still slightly more descriptive IMO)
   - Instead of `SingleDataMaskState` we would then have `DataMaskState`




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to