You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2021/06/01 15:58:14 UTC

[GitHub] [superset] kgabryje opened a new pull request #14933: feat(dashboard/native-filters): Hide filters out of scope of current tab

kgabryje opened a new pull request #14933:
URL: https://github.com/apache/superset/pull/14933


   ### SUMMARY
   On dashboards with tabs, native filters that are out of scope of currently focused tab should be hidden.
   When user opens a dashboard with top level tabs, the active top level tab is used as an initially focused tab. For dashboards without top level tabs, initially every filter is considered to be in scope, until the user clicks on a tab.
   Hidden filters are moved to a new collapsible section in the native filters panel. In order to prevent expensive rerendering of native filters when they are moved in and out of collapsible, I used `react-reverse-portal` library, which utilizes React portals to perform reparenting without unmounting and remounting the child. In our case, it was essential, as each native filter sends a request to backend on mount - if a user had many native filters with narrow scopes, we'd risk having lots of redundant API calls on each tab change.
   Moreover, I optimized finding charts and tabs in scope for each native filter. Before, functions that traverse the whole component tree in search for charts and tabs were called every time a native filter was focused. Now, they are called once for each filter when the filters are initialized (and then again when filter's scope or dashboard layout changes).
   
   Potential improvements:
   1. Show currently focused tab's name. I'd love some **design input** on that, as I'm not sure where to put tab's name on the filter panel and how to make it consistent with the rest of the design. I believe that would improve user experience a lot, as it might be confusing for the user why some filters are marked as "out of scope".
   2. Currently for dashboards without top level tabs, we start with every filter being considered to be in scope. After a user focuses on some tab, there is no way to return to the initial state. It might be problematic in cases when there are charts not attached to any tab group - after some tab has been focused, we can never return to the state where a chart outside of any tab group is "in scope".
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   https://user-images.githubusercontent.com/15073128/120353413-f0f67780-c301-11eb-8f5f-e4b0b9fd2167.mov
   
   ### TESTING INSTRUCTIONS
   0. Set `DASHBOARD_NATIVE_FILTERS` feature flag to True.
   1. Create a dashboard with tabs (try both top level tabs + grid level tabs and only grid level tabs) and add some native filters with different scopes.
   2. Verify that when you change tabs, filters that are out of scope of current tab are moved to collapsed section.
   3. Verify that native filters are not rerendered - when you switch tabs, there shouldn't be any new api calls related to native filters.
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   
   CC: @junlincc @villebro 


-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] codecov[bot] commented on pull request #14933: feat(dashboard/native-filters): Hide filters out of scope of current tab

Posted by GitBox <gi...@apache.org>.
codecov[bot] commented on pull request #14933:
URL: https://github.com/apache/superset/pull/14933#issuecomment-853051550


   # [Codecov](https://codecov.io/gh/apache/superset/pull/14933?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#14933](https://codecov.io/gh/apache/superset/pull/14933?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (28e8c40) into [master](https://codecov.io/gh/apache/superset/commit/66282c331363887c0da486bc68976a6c350e8645?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (66282c3) will **decrease** coverage by `0.00%`.
   > The diff coverage is `75.65%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/superset/pull/14933/graphs/tree.svg?width=650&height=150&src=pr&token=KsB0fHcx6l&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/superset/pull/14933?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #14933      +/-   ##
   ==========================================
   - Coverage   77.62%   77.62%   -0.01%     
   ==========================================
     Files         963      965       +2     
     Lines       49316    49497     +181     
     Branches     6228     6261      +33     
   ==========================================
   + Hits        38284    38423     +139     
   - Misses      10833    10873      +40     
   - Partials      199      201       +2     
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | javascript | `72.50% <75.65%> (+0.03%)` | :arrow_up: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/superset/pull/14933?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [superset-frontend/src/dashboard/actions/hydrate.js](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9hY3Rpb25zL2h5ZHJhdGUuanM=) | `1.72% <ø> (ø)` | |
   | [...nd/src/dashboard/containers/DashboardComponent.jsx](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb250YWluZXJzL0Rhc2hib2FyZENvbXBvbmVudC5qc3g=) | `92.30% <ø> (+7.45%)` | :arrow_up: |
   | [...-frontend/src/dashboard/reducers/dashboardState.js](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9yZWR1Y2Vycy9kYXNoYm9hcmRTdGF0ZS5qcw==) | `73.33% <0.00%> (-2.53%)` | :arrow_down: |
   | [...t-frontend/src/dashboard/actions/dashboardState.js](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9hY3Rpb25zL2Rhc2hib2FyZFN0YXRlLmpz) | `28.65% <33.33%> (+0.08%)` | :arrow_up: |
   | [...ashboard/components/gridComponents/ChartHolder.jsx](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL2dyaWRDb21wb25lbnRzL0NoYXJ0SG9sZGVyLmpzeA==) | `74.71% <33.33%> (-3.07%)` | :arrow_down: |
   | [...ilters/FilterBar/FilterControls/FilterControls.tsx](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL25hdGl2ZUZpbHRlcnMvRmlsdGVyQmFyL0ZpbHRlckNvbnRyb2xzL0ZpbHRlckNvbnRyb2xzLnRzeA==) | `76.78% <67.50%> (-17.96%)` | :arrow_down: |
   | [...d/src/dashboard/components/gridComponents/Tabs.jsx](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL2dyaWRDb21wb25lbnRzL1RhYnMuanN4) | `87.37% <87.50%> (+11.06%)` | :arrow_up: |
   | [...nd/src/dashboard/components/nativeFilters/utils.ts](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL25hdGl2ZUZpbHRlcnMvdXRpbHMudHM=) | `86.25% <93.54%> (+4.61%)` | :arrow_up: |
   | [...components/DashboardBuilder/DashboardContainer.tsx](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL0Rhc2hib2FyZEJ1aWxkZXIvRGFzaGJvYXJkQ29udGFpbmVyLnRzeA==) | `100.00% <100.00%> (ø)` | |
   | [...nd/src/dashboard/components/nativeFilters/state.ts](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL25hdGl2ZUZpbHRlcnMvc3RhdGUudHM=) | `100.00% <100.00%> (ø)` | |
   | ... and [18 more](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/superset/pull/14933?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/superset/pull/14933?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [66282c3...28e8c40](https://codecov.io/gh/apache/superset/pull/14933?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] kgabryje commented on pull request #14933: feat(dashboard/native-filters): Hide filters out of scope of current tab

Posted by GitBox <gi...@apache.org>.
kgabryje commented on pull request #14933:
URL: https://github.com/apache/superset/pull/14933#issuecomment-852934496


   > Shouldn’t the initial state be the filters applicable to the standalone charts and the filters applicable to the selected tab since we always select a tab by default? When we have a tab group the first tab always starts selected, so the filters should be the same as when the user manually selects it.
   
   I think that our intention was to hide the filters as a reaction to user manually setting focus on some tab by clicking it. I see your point however and that makes sense to me. Let's wait for product input (CC @junlincc) and come back to that matter in the second iteration of the feature.


-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] junlincc commented on pull request #14933: feat(dashboard/native-filters): Hide filters out of scope of current tab

Posted by GitBox <gi...@apache.org>.
junlincc commented on pull request #14933:
URL: https://github.com/apache/superset/pull/14933#issuecomment-852581369


   @kgabryje Thank you Kamil for implementing this(more ideal) solution. 
   question, out of scope filters are not disabled, correct? also if we disabled them, do you know how much improvement on performance we can get? 


-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] villebro commented on a change in pull request #14933: feat(dashboard/native-filters): Hide filters out of scope of current tab

Posted by GitBox <gi...@apache.org>.
villebro commented on a change in pull request #14933:
URL: https://github.com/apache/superset/pull/14933#discussion_r643855899



##########
File path: superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterControls.tsx
##########
@@ -54,21 +73,86 @@ const FilterControls: FC<FilterControlsProps> = ({
     return buildCascadeFiltersTree(filtersWithValue);
   }, [filterValues, dataMaskSelected]);
 
+  let filtersInScope: CascadeFilter[] = [];
+  const filtersOutOfScope: CascadeFilter[] = [];
+  const dashboardHasTabs = Object.values(dashboardLayout).some(
+    element => element.type === TAB_TYPE,
+  );
+  const showCollapsePanel = dashboardHasTabs && cascadeFilters.length > 0;
+  if (!lastFocusedTabId || !dashboardHasTabs) {
+    filtersInScope = cascadeFilters;
+  } else {
+    cascadeFilters.forEach((filter, index) => {
+      if (cascadeFilters[index].tabsInScope?.includes(lastFocusedTabId)) {
+        filtersInScope.push(filter);
+      } else {
+        filtersOutOfScope.push(filter);
+      }
+    });
+  }
+
   return (
     <Wrapper>
-      {cascadeFilters.map(filter => (
-        <CascadePopover
-          data-test="cascade-filters-control"
-          key={filter.id}
-          visible={visiblePopoverId === filter.id}
-          onVisibleChange={visible =>
-            setVisiblePopoverId(visible ? filter.id : null)
-          }
-          filter={filter}
-          onFilterSelectionChange={onFilterSelectionChange}
-          directPathToChild={directPathToChild}
-        />
+      {portalNodes.map((node, index) => (
+        <portals.InPortal node={node}>
+          <CascadePopover
+            data-test="cascade-filters-control"
+            key={cascadeFilters[index].id}
+            visible={visiblePopoverId === cascadeFilters[index].id}
+            onVisibleChange={visible =>
+              setVisiblePopoverId(visible ? cascadeFilters[index].id : null)
+            }
+            filter={cascadeFilters[index]}
+            onFilterSelectionChange={onFilterSelectionChange}
+            directPathToChild={directPathToChild}
+          />
+        </portals.InPortal>
       ))}
+      {filtersInScope.map(filter => {
+        const index = cascadeFilters.findIndex(f => f.id === filter.id);
+        return <portals.OutPortal node={portalNodes[index]} />;
+      })}
+      {showCollapsePanel && (
+        <Collapse
+          ghost
+          bordered
+          expandIconPosition="right"
+          collapsible={filtersOutOfScope.length === 0 ? 'disabled' : undefined}
+          css={theme => css`
+            &.ant-collapse {
+              margin-top: ${filtersInScope.length > 0
+                ? theme.gridUnit * 6
+                : 0}px;
+              & > .ant-collapse-item {
+                & > .ant-collapse-header {
+                  padding-left: 0;
+                  padding-bottom: ${theme.gridUnit * 2}px;
+
+                  & > .ant-collapse-arrow {
+                    right: ${theme.gridUnit}px;
+                  }
+                }
+
+                & .ant-collapse-content-box {
+                  padding: ${theme.gridUnit * 4}px 0 0;
+                }
+              }
+            }
+          `}
+        >
+          <Collapse.Panel
+            header={`${t('Filters out of scope')} (${
+              filtersOutOfScope.length
+            })`}
+            key="1"
+          >
+            {filtersOutOfScope.map(filter => {
+              const index = cascadeFilters.findIndex(f => f.id === filter.id);
+              return <portals.OutPortal node={portalNodes[index]} />;
+            })}
+          </Collapse.Panel>
+        </Collapse>

Review comment:
       I think you misunderstood what I was getting at. What I meant was that as long as the "Out of scope" collapsible is collapsed, the requests for those filters would not go out. So in this case:
   ![image](https://user-images.githubusercontent.com/33317356/120469829-89950200-c3ab-11eb-93db-ef44dbcc0a91.png)
   
   the request for that last filter would not yet have gone out, but once it's expanded
   
   ![image](https://user-images.githubusercontent.com/33317356/120469915-a16c8600-c3ab-11eb-92ba-bf37d4cc2452.png)
   
   The charts would render for the first time, triggering the requests. If the user moved to one of the tabs that are in scope for that filter, it would also trigger that query, but of course only once (the next time it goes out and in scope, it would already have been loaded hence no need to retrigger the query).
   
   But yes, this was more a thought for future improvement, no need to delay this PR with this now.




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] kgabryje commented on a change in pull request #14933: feat(dashboard/native-filters): Hide filters out of scope of current tab

Posted by GitBox <gi...@apache.org>.
kgabryje commented on a change in pull request #14933:
URL: https://github.com/apache/superset/pull/14933#discussion_r643882897



##########
File path: superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterControls.tsx
##########
@@ -54,21 +73,86 @@ const FilterControls: FC<FilterControlsProps> = ({
     return buildCascadeFiltersTree(filtersWithValue);
   }, [filterValues, dataMaskSelected]);
 
+  let filtersInScope: CascadeFilter[] = [];
+  const filtersOutOfScope: CascadeFilter[] = [];
+  const dashboardHasTabs = Object.values(dashboardLayout).some(
+    element => element.type === TAB_TYPE,
+  );
+  const showCollapsePanel = dashboardHasTabs && cascadeFilters.length > 0;
+  if (!lastFocusedTabId || !dashboardHasTabs) {
+    filtersInScope = cascadeFilters;
+  } else {
+    cascadeFilters.forEach((filter, index) => {
+      if (cascadeFilters[index].tabsInScope?.includes(lastFocusedTabId)) {
+        filtersInScope.push(filter);
+      } else {
+        filtersOutOfScope.push(filter);
+      }
+    });
+  }
+
   return (
     <Wrapper>
-      {cascadeFilters.map(filter => (
-        <CascadePopover
-          data-test="cascade-filters-control"
-          key={filter.id}
-          visible={visiblePopoverId === filter.id}
-          onVisibleChange={visible =>
-            setVisiblePopoverId(visible ? filter.id : null)
-          }
-          filter={filter}
-          onFilterSelectionChange={onFilterSelectionChange}
-          directPathToChild={directPathToChild}
-        />
+      {portalNodes.map((node, index) => (
+        <portals.InPortal node={node}>
+          <CascadePopover
+            data-test="cascade-filters-control"
+            key={cascadeFilters[index].id}
+            visible={visiblePopoverId === cascadeFilters[index].id}
+            onVisibleChange={visible =>
+              setVisiblePopoverId(visible ? cascadeFilters[index].id : null)
+            }
+            filter={cascadeFilters[index]}
+            onFilterSelectionChange={onFilterSelectionChange}
+            directPathToChild={directPathToChild}
+          />
+        </portals.InPortal>
       ))}
+      {filtersInScope.map(filter => {
+        const index = cascadeFilters.findIndex(f => f.id === filter.id);
+        return <portals.OutPortal node={portalNodes[index]} />;
+      })}
+      {showCollapsePanel && (
+        <Collapse
+          ghost
+          bordered
+          expandIconPosition="right"
+          collapsible={filtersOutOfScope.length === 0 ? 'disabled' : undefined}
+          css={theme => css`
+            &.ant-collapse {
+              margin-top: ${filtersInScope.length > 0
+                ? theme.gridUnit * 6
+                : 0}px;
+              & > .ant-collapse-item {
+                & > .ant-collapse-header {
+                  padding-left: 0;
+                  padding-bottom: ${theme.gridUnit * 2}px;
+
+                  & > .ant-collapse-arrow {
+                    right: ${theme.gridUnit}px;
+                  }
+                }
+
+                & .ant-collapse-content-box {
+                  padding: ${theme.gridUnit * 4}px 0 0;
+                }
+              }
+            }
+          `}
+        >
+          <Collapse.Panel
+            header={`${t('Filters out of scope')} (${
+              filtersOutOfScope.length
+            })`}
+            key="1"
+          >
+            {filtersOutOfScope.map(filter => {
+              const index = cascadeFilters.findIndex(f => f.id === filter.id);
+              return <portals.OutPortal node={portalNodes[index]} />;
+            })}
+          </Collapse.Panel>
+        </Collapse>

Review comment:
       Ahh, I understand now, thanks for explanation. Let's implement it in the next iteration!




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] graceguo-supercat commented on pull request #14933: feat(dashboard/native-filters): Hide filters out of scope of current tab

Posted by GitBox <gi...@apache.org>.
graceguo-supercat commented on pull request #14933:
URL: https://github.com/apache/superset/pull/14933#issuecomment-860168672


   In airbnb we didn't enable dashboard native filters feature flag, but because of this PR, all the recent visited dashboard were set 
   ```
   "show_native_filters": true, 
   "native_filter_configuration": [],
   ```
   This is not the right state. 
   
   - For dashboard doesn't enable native filters, it should not have above properties in the json_metadata. 
   - When dashboard native filter feature is enabled, `"native_filter_configuration": []` means dashboard didn't have any filter component.
   This difference is critical for dashboard filter_box migration work. Please check [ SIP-64](https://github.com/apache/superset/issues/14383) "airbnb users" section.
   


-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] michael-s-molina commented on pull request #14933: feat(dashboard/native-filters): Hide filters out of scope of current tab

Posted by GitBox <gi...@apache.org>.
michael-s-molina commented on pull request #14933:
URL: https://github.com/apache/superset/pull/14933#issuecomment-852920437


   > 2- Currently for dashboards without top level tabs, we start with every filter being considered to be in scope. After a user focuses on some tab, there is no way to return to the initial state. It might be problematic in cases when there are charts not attached to any tab group - after some tab has been focused, we can never return to the state where a chart outside of any tab group is "in scope".
   
   Shouldn’t the initial state be the filters applicable to the standalone charts and the filters applicable to the selected tab since we always select a tab by default? When we have a tab group the first tab always starts selected, so the filters should be the same as when the user manually selects it.


-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] kgabryje commented on a change in pull request #14933: feat(dashboard/native-filters): Hide filters out of scope of current tab

Posted by GitBox <gi...@apache.org>.
kgabryje commented on a change in pull request #14933:
URL: https://github.com/apache/superset/pull/14933#discussion_r643848242



##########
File path: superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterControls.tsx
##########
@@ -54,21 +73,86 @@ const FilterControls: FC<FilterControlsProps> = ({
     return buildCascadeFiltersTree(filtersWithValue);
   }, [filterValues, dataMaskSelected]);
 
+  let filtersInScope: CascadeFilter[] = [];
+  const filtersOutOfScope: CascadeFilter[] = [];
+  const dashboardHasTabs = Object.values(dashboardLayout).some(
+    element => element.type === TAB_TYPE,
+  );
+  const showCollapsePanel = dashboardHasTabs && cascadeFilters.length > 0;
+  if (!lastFocusedTabId || !dashboardHasTabs) {
+    filtersInScope = cascadeFilters;
+  } else {
+    cascadeFilters.forEach((filter, index) => {
+      if (cascadeFilters[index].tabsInScope?.includes(lastFocusedTabId)) {
+        filtersInScope.push(filter);
+      } else {
+        filtersOutOfScope.push(filter);
+      }
+    });
+  }
+
   return (
     <Wrapper>
-      {cascadeFilters.map(filter => (
-        <CascadePopover
-          data-test="cascade-filters-control"
-          key={filter.id}
-          visible={visiblePopoverId === filter.id}
-          onVisibleChange={visible =>
-            setVisiblePopoverId(visible ? filter.id : null)
-          }
-          filter={filter}
-          onFilterSelectionChange={onFilterSelectionChange}
-          directPathToChild={directPathToChild}
-        />
+      {portalNodes.map((node, index) => (
+        <portals.InPortal node={node}>
+          <CascadePopover
+            data-test="cascade-filters-control"
+            key={cascadeFilters[index].id}
+            visible={visiblePopoverId === cascadeFilters[index].id}
+            onVisibleChange={visible =>
+              setVisiblePopoverId(visible ? cascadeFilters[index].id : null)
+            }
+            filter={cascadeFilters[index]}
+            onFilterSelectionChange={onFilterSelectionChange}
+            directPathToChild={directPathToChild}
+          />
+        </portals.InPortal>
       ))}
+      {filtersInScope.map(filter => {
+        const index = cascadeFilters.findIndex(f => f.id === filter.id);
+        return <portals.OutPortal node={portalNodes[index]} />;
+      })}
+      {showCollapsePanel && (
+        <Collapse
+          ghost
+          bordered
+          expandIconPosition="right"
+          collapsible={filtersOutOfScope.length === 0 ? 'disabled' : undefined}
+          css={theme => css`
+            &.ant-collapse {
+              margin-top: ${filtersInScope.length > 0
+                ? theme.gridUnit * 6
+                : 0}px;
+              & > .ant-collapse-item {
+                & > .ant-collapse-header {
+                  padding-left: 0;
+                  padding-bottom: ${theme.gridUnit * 2}px;
+
+                  & > .ant-collapse-arrow {
+                    right: ${theme.gridUnit}px;
+                  }
+                }
+
+                & .ant-collapse-content-box {
+                  padding: ${theme.gridUnit * 4}px 0 0;
+                }
+              }
+            }
+          `}
+        >
+          <Collapse.Panel
+            header={`${t('Filters out of scope')} (${
+              filtersOutOfScope.length
+            })`}
+            key="1"
+          >
+            {filtersOutOfScope.map(filter => {
+              const index = cascadeFilters.findIndex(f => f.id === filter.id);
+              return <portals.OutPortal node={portalNodes[index]} />;
+            })}
+          </Collapse.Panel>
+        </Collapse>

Review comment:
       Hmm, besides more convoluted logic, I wonder if it would be confusing for the user. Imagine that you add a filter to a dashboard scoped to 1 tab, you come back to that dashboard later and your filter is nowhere to be found, until you click on that tab. I can see the potential benefits and I'm all for implementing that, but I think we should think this through first so that it not only performs optimally, but also looks good 🙂 
   




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] kgabryje commented on pull request #14933: feat(dashboard/native-filters): Hide filters out of scope of current tab

Posted by GitBox <gi...@apache.org>.
kgabryje commented on pull request #14933:
URL: https://github.com/apache/superset/pull/14933#issuecomment-853160481


   > when user add value to filters in out of scope section, does apply button get enabled?
   
   Yes, we only change how the filters are displayed


-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] codecov[bot] edited a comment on pull request #14933: feat(dashboard/native-filters): Hide filters out of scope of current tab

Posted by GitBox <gi...@apache.org>.
codecov[bot] edited a comment on pull request #14933:
URL: https://github.com/apache/superset/pull/14933#issuecomment-853051550


   # [Codecov](https://codecov.io/gh/apache/superset/pull/14933?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#14933](https://codecov.io/gh/apache/superset/pull/14933?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (28e8c40) into [master](https://codecov.io/gh/apache/superset/commit/66282c331363887c0da486bc68976a6c350e8645?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (66282c3) will **decrease** coverage by `0.00%`.
   > The diff coverage is `75.65%`.
   
   > :exclamation: Current head 28e8c40 differs from pull request most recent head c2bd1f5. Consider uploading reports for the commit c2bd1f5 to get more accurate results
   [![Impacted file tree graph](https://codecov.io/gh/apache/superset/pull/14933/graphs/tree.svg?width=650&height=150&src=pr&token=KsB0fHcx6l&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/superset/pull/14933?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #14933      +/-   ##
   ==========================================
   - Coverage   77.62%   77.62%   -0.01%     
   ==========================================
     Files         963      965       +2     
     Lines       49316    49497     +181     
     Branches     6228     6261      +33     
   ==========================================
   + Hits        38284    38423     +139     
   - Misses      10833    10873      +40     
   - Partials      199      201       +2     
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | javascript | `72.50% <75.65%> (+0.03%)` | :arrow_up: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/superset/pull/14933?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [superset-frontend/src/dashboard/actions/hydrate.js](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9hY3Rpb25zL2h5ZHJhdGUuanM=) | `1.72% <ø> (ø)` | |
   | [...nd/src/dashboard/containers/DashboardComponent.jsx](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb250YWluZXJzL0Rhc2hib2FyZENvbXBvbmVudC5qc3g=) | `92.30% <ø> (+7.45%)` | :arrow_up: |
   | [...-frontend/src/dashboard/reducers/dashboardState.js](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9yZWR1Y2Vycy9kYXNoYm9hcmRTdGF0ZS5qcw==) | `73.33% <0.00%> (-2.53%)` | :arrow_down: |
   | [...t-frontend/src/dashboard/actions/dashboardState.js](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9hY3Rpb25zL2Rhc2hib2FyZFN0YXRlLmpz) | `28.65% <33.33%> (+0.08%)` | :arrow_up: |
   | [...ashboard/components/gridComponents/ChartHolder.jsx](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL2dyaWRDb21wb25lbnRzL0NoYXJ0SG9sZGVyLmpzeA==) | `74.71% <33.33%> (-3.07%)` | :arrow_down: |
   | [...ilters/FilterBar/FilterControls/FilterControls.tsx](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL25hdGl2ZUZpbHRlcnMvRmlsdGVyQmFyL0ZpbHRlckNvbnRyb2xzL0ZpbHRlckNvbnRyb2xzLnRzeA==) | `76.78% <67.50%> (-17.96%)` | :arrow_down: |
   | [...d/src/dashboard/components/gridComponents/Tabs.jsx](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL2dyaWRDb21wb25lbnRzL1RhYnMuanN4) | `87.37% <87.50%> (+11.06%)` | :arrow_up: |
   | [...nd/src/dashboard/components/nativeFilters/utils.ts](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL25hdGl2ZUZpbHRlcnMvdXRpbHMudHM=) | `86.25% <93.54%> (+4.61%)` | :arrow_up: |
   | [...components/DashboardBuilder/DashboardContainer.tsx](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL0Rhc2hib2FyZEJ1aWxkZXIvRGFzaGJvYXJkQ29udGFpbmVyLnRzeA==) | `100.00% <100.00%> (ø)` | |
   | [...nd/src/dashboard/components/nativeFilters/state.ts](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL25hdGl2ZUZpbHRlcnMvc3RhdGUudHM=) | `100.00% <100.00%> (ø)` | |
   | ... and [18 more](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/superset/pull/14933?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/superset/pull/14933?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [66282c3...c2bd1f5](https://codecov.io/gh/apache/superset/pull/14933?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] villebro commented on a change in pull request #14933: feat(dashboard/native-filters): Hide filters out of scope of current tab

Posted by GitBox <gi...@apache.org>.
villebro commented on a change in pull request #14933:
URL: https://github.com/apache/superset/pull/14933#discussion_r644120402



##########
File path: superset-frontend/cypress-base/cypress/integration/dashboard_list/filter.test.ts
##########
@@ -107,13 +106,12 @@ describe('dashboard filters list view', () => {
     cy.get('[data-test="table-row"]').should('not.exist');
   });
 
-  xit('should filter by published correctly', () => {
+  it('should filter by published correctly', () => {

Review comment:
       wow, this was unexpected, bycatch fixing and re-enabling a flaky test 😄 




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] kgabryje commented on pull request #14933: feat(dashboard/native-filters): Hide filters out of scope of current tab

Posted by GitBox <gi...@apache.org>.
kgabryje commented on pull request #14933:
URL: https://github.com/apache/superset/pull/14933#issuecomment-860579891


   @graceguo-supercat Thank you for raising those issues. PR https://github.com/apache/superset/pull/15146 solves part of the problem, another part will be fixed in a separate PR by @villebro 


-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] kgabryje merged pull request #14933: feat(dashboard/native-filters): Hide filters out of scope of current tab

Posted by GitBox <gi...@apache.org>.
kgabryje merged pull request #14933:
URL: https://github.com/apache/superset/pull/14933


   


-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] codecov[bot] edited a comment on pull request #14933: feat(dashboard/native-filters): Hide filters out of scope of current tab

Posted by GitBox <gi...@apache.org>.
codecov[bot] edited a comment on pull request #14933:
URL: https://github.com/apache/superset/pull/14933#issuecomment-853051550


   # [Codecov](https://codecov.io/gh/apache/superset/pull/14933?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#14933](https://codecov.io/gh/apache/superset/pull/14933?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (28e8c40) into [master](https://codecov.io/gh/apache/superset/commit/66282c331363887c0da486bc68976a6c350e8645?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (66282c3) will **decrease** coverage by `0.00%`.
   > The diff coverage is `75.65%`.
   
   > :exclamation: Current head 28e8c40 differs from pull request most recent head 1de1426. Consider uploading reports for the commit 1de1426 to get more accurate results
   [![Impacted file tree graph](https://codecov.io/gh/apache/superset/pull/14933/graphs/tree.svg?width=650&height=150&src=pr&token=KsB0fHcx6l&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/superset/pull/14933?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #14933      +/-   ##
   ==========================================
   - Coverage   77.62%   77.62%   -0.01%     
   ==========================================
     Files         963      965       +2     
     Lines       49316    49497     +181     
     Branches     6228     6261      +33     
   ==========================================
   + Hits        38284    38423     +139     
   - Misses      10833    10873      +40     
   - Partials      199      201       +2     
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | javascript | `72.50% <75.65%> (+0.03%)` | :arrow_up: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/superset/pull/14933?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [superset-frontend/src/dashboard/actions/hydrate.js](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9hY3Rpb25zL2h5ZHJhdGUuanM=) | `1.72% <ø> (ø)` | |
   | [...nd/src/dashboard/containers/DashboardComponent.jsx](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb250YWluZXJzL0Rhc2hib2FyZENvbXBvbmVudC5qc3g=) | `92.30% <ø> (+7.45%)` | :arrow_up: |
   | [...-frontend/src/dashboard/reducers/dashboardState.js](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9yZWR1Y2Vycy9kYXNoYm9hcmRTdGF0ZS5qcw==) | `73.33% <0.00%> (-2.53%)` | :arrow_down: |
   | [...t-frontend/src/dashboard/actions/dashboardState.js](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9hY3Rpb25zL2Rhc2hib2FyZFN0YXRlLmpz) | `28.65% <33.33%> (+0.08%)` | :arrow_up: |
   | [...ashboard/components/gridComponents/ChartHolder.jsx](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL2dyaWRDb21wb25lbnRzL0NoYXJ0SG9sZGVyLmpzeA==) | `74.71% <33.33%> (-3.07%)` | :arrow_down: |
   | [...ilters/FilterBar/FilterControls/FilterControls.tsx](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL25hdGl2ZUZpbHRlcnMvRmlsdGVyQmFyL0ZpbHRlckNvbnRyb2xzL0ZpbHRlckNvbnRyb2xzLnRzeA==) | `76.78% <67.50%> (-17.96%)` | :arrow_down: |
   | [...d/src/dashboard/components/gridComponents/Tabs.jsx](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL2dyaWRDb21wb25lbnRzL1RhYnMuanN4) | `87.37% <87.50%> (+11.06%)` | :arrow_up: |
   | [...nd/src/dashboard/components/nativeFilters/utils.ts](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL25hdGl2ZUZpbHRlcnMvdXRpbHMudHM=) | `86.25% <93.54%> (+4.61%)` | :arrow_up: |
   | [...components/DashboardBuilder/DashboardContainer.tsx](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL0Rhc2hib2FyZEJ1aWxkZXIvRGFzaGJvYXJkQ29udGFpbmVyLnRzeA==) | `100.00% <100.00%> (ø)` | |
   | [...nd/src/dashboard/components/nativeFilters/state.ts](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL25hdGl2ZUZpbHRlcnMvc3RhdGUudHM=) | `100.00% <100.00%> (ø)` | |
   | ... and [18 more](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/superset/pull/14933?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/superset/pull/14933?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [66282c3...1de1426](https://codecov.io/gh/apache/superset/pull/14933?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] codecov[bot] edited a comment on pull request #14933: feat(dashboard/native-filters): Hide filters out of scope of current tab

Posted by GitBox <gi...@apache.org>.
codecov[bot] edited a comment on pull request #14933:
URL: https://github.com/apache/superset/pull/14933#issuecomment-853051550


   # [Codecov](https://codecov.io/gh/apache/superset/pull/14933?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#14933](https://codecov.io/gh/apache/superset/pull/14933?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (c2bd1f5) into [master](https://codecov.io/gh/apache/superset/commit/66282c331363887c0da486bc68976a6c350e8645?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (66282c3) will **decrease** coverage by `0.00%`.
   > The diff coverage is `75.65%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/superset/pull/14933/graphs/tree.svg?width=650&height=150&src=pr&token=KsB0fHcx6l&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/superset/pull/14933?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #14933      +/-   ##
   ==========================================
   - Coverage   77.62%   77.62%   -0.01%     
   ==========================================
     Files         963      965       +2     
     Lines       49316    49497     +181     
     Branches     6228     6261      +33     
   ==========================================
   + Hits        38284    38423     +139     
   - Misses      10833    10873      +40     
   - Partials      199      201       +2     
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | javascript | `72.50% <75.65%> (+0.03%)` | :arrow_up: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/superset/pull/14933?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [superset-frontend/src/dashboard/actions/hydrate.js](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9hY3Rpb25zL2h5ZHJhdGUuanM=) | `1.72% <ø> (ø)` | |
   | [...nd/src/dashboard/containers/DashboardComponent.jsx](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb250YWluZXJzL0Rhc2hib2FyZENvbXBvbmVudC5qc3g=) | `92.30% <ø> (+7.45%)` | :arrow_up: |
   | [...-frontend/src/dashboard/reducers/dashboardState.js](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9yZWR1Y2Vycy9kYXNoYm9hcmRTdGF0ZS5qcw==) | `73.33% <0.00%> (-2.53%)` | :arrow_down: |
   | [...t-frontend/src/dashboard/actions/dashboardState.js](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9hY3Rpb25zL2Rhc2hib2FyZFN0YXRlLmpz) | `28.65% <33.33%> (+0.08%)` | :arrow_up: |
   | [...ashboard/components/gridComponents/ChartHolder.jsx](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL2dyaWRDb21wb25lbnRzL0NoYXJ0SG9sZGVyLmpzeA==) | `74.71% <33.33%> (-3.07%)` | :arrow_down: |
   | [...ilters/FilterBar/FilterControls/FilterControls.tsx](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL25hdGl2ZUZpbHRlcnMvRmlsdGVyQmFyL0ZpbHRlckNvbnRyb2xzL0ZpbHRlckNvbnRyb2xzLnRzeA==) | `76.78% <67.50%> (-17.96%)` | :arrow_down: |
   | [...d/src/dashboard/components/gridComponents/Tabs.jsx](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL2dyaWRDb21wb25lbnRzL1RhYnMuanN4) | `87.37% <87.50%> (+11.06%)` | :arrow_up: |
   | [...nd/src/dashboard/components/nativeFilters/utils.ts](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL25hdGl2ZUZpbHRlcnMvdXRpbHMudHM=) | `86.25% <93.54%> (+4.61%)` | :arrow_up: |
   | [...components/DashboardBuilder/DashboardContainer.tsx](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL0Rhc2hib2FyZEJ1aWxkZXIvRGFzaGJvYXJkQ29udGFpbmVyLnRzeA==) | `100.00% <100.00%> (ø)` | |
   | [...nd/src/dashboard/components/nativeFilters/state.ts](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL25hdGl2ZUZpbHRlcnMvc3RhdGUudHM=) | `100.00% <100.00%> (ø)` | |
   | ... and [18 more](https://codecov.io/gh/apache/superset/pull/14933/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/superset/pull/14933?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/superset/pull/14933?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [66282c3...c2bd1f5](https://codecov.io/gh/apache/superset/pull/14933?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] villebro commented on a change in pull request #14933: feat(dashboard/native-filters): Hide filters out of scope of current tab

Posted by GitBox <gi...@apache.org>.
villebro commented on a change in pull request #14933:
URL: https://github.com/apache/superset/pull/14933#discussion_r643721227



##########
File path: superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterControls.tsx
##########
@@ -54,21 +73,86 @@ const FilterControls: FC<FilterControlsProps> = ({
     return buildCascadeFiltersTree(filtersWithValue);
   }, [filterValues, dataMaskSelected]);
 
+  let filtersInScope: CascadeFilter[] = [];
+  const filtersOutOfScope: CascadeFilter[] = [];
+  const dashboardHasTabs = Object.values(dashboardLayout).some(
+    element => element.type === TAB_TYPE,
+  );
+  const showCollapsePanel = dashboardHasTabs && cascadeFilters.length > 0;
+  if (!lastFocusedTabId || !dashboardHasTabs) {
+    filtersInScope = cascadeFilters;
+  } else {
+    cascadeFilters.forEach((filter, index) => {
+      if (cascadeFilters[index].tabsInScope?.includes(lastFocusedTabId)) {
+        filtersInScope.push(filter);
+      } else {
+        filtersOutOfScope.push(filter);
+      }
+    });
+  }
+
   return (
     <Wrapper>
-      {cascadeFilters.map(filter => (
-        <CascadePopover
-          data-test="cascade-filters-control"
-          key={filter.id}
-          visible={visiblePopoverId === filter.id}
-          onVisibleChange={visible =>
-            setVisiblePopoverId(visible ? filter.id : null)
-          }
-          filter={filter}
-          onFilterSelectionChange={onFilterSelectionChange}
-          directPathToChild={directPathToChild}
-        />
+      {portalNodes.map((node, index) => (
+        <portals.InPortal node={node}>
+          <CascadePopover
+            data-test="cascade-filters-control"
+            key={cascadeFilters[index].id}
+            visible={visiblePopoverId === cascadeFilters[index].id}
+            onVisibleChange={visible =>
+              setVisiblePopoverId(visible ? cascadeFilters[index].id : null)
+            }
+            filter={cascadeFilters[index]}
+            onFilterSelectionChange={onFilterSelectionChange}
+            directPathToChild={directPathToChild}
+          />
+        </portals.InPortal>
       ))}
+      {filtersInScope.map(filter => {
+        const index = cascadeFilters.findIndex(f => f.id === filter.id);
+        return <portals.OutPortal node={portalNodes[index]} />;
+      })}
+      {showCollapsePanel && (
+        <Collapse
+          ghost
+          bordered
+          expandIconPosition="right"
+          collapsible={filtersOutOfScope.length === 0 ? 'disabled' : undefined}
+          css={theme => css`
+            &.ant-collapse {
+              margin-top: ${filtersInScope.length > 0
+                ? theme.gridUnit * 6
+                : 0}px;
+              & > .ant-collapse-item {
+                & > .ant-collapse-header {
+                  padding-left: 0;
+                  padding-bottom: ${theme.gridUnit * 2}px;
+
+                  & > .ant-collapse-arrow {
+                    right: ${theme.gridUnit}px;
+                  }
+                }
+
+                & .ant-collapse-content-box {
+                  padding: ${theme.gridUnit * 4}px 0 0;
+                }
+              }
+            }
+          `}
+        >
+          <Collapse.Panel
+            header={`${t('Filters out of scope')} (${
+              filtersOutOfScope.length
+            })`}
+            key="1"
+          >
+            {filtersOutOfScope.map(filter => {
+              const index = cascadeFilters.findIndex(f => f.id === filter.id);
+              return <portals.OutPortal node={portalNodes[index]} />;
+            })}
+          </Collapse.Panel>
+        </Collapse>

Review comment:
       I wonder if it would be possible to postpone rendering of the out of scope components to the time they become visible for the first time, similar to how charts in tabs only load up when switching tabs? Especially with dashboards with lots of filters and tabs that only have a few filters in scope per tab, this could have a performance boost as we would only need to render the filters as they are needed.
   
   I checked that it's possible to pass default props in the `InPortal` and can then be changed/added to in the `OutPortal`, but it seems this may add quite a bit of additional logic that might obfuscate the original code, so this additional feature probably shouldn't be in scope for this PR..




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] junlincc commented on pull request #14933: feat(dashboard/native-filters): Hide filters out of scope of current tab

Posted by GitBox <gi...@apache.org>.
junlincc commented on pull request #14933:
URL: https://github.com/apache/superset/pull/14933#issuecomment-853139733


   when user add value to filters in out of scope section, does apply button get enabled? 


-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] graceguo-supercat edited a comment on pull request #14933: feat(dashboard/native-filters): Hide filters out of scope of current tab

Posted by GitBox <gi...@apache.org>.
graceguo-supercat edited a comment on pull request #14933:
URL: https://github.com/apache/superset/pull/14933#issuecomment-860168672






-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] graceguo-supercat commented on a change in pull request #14933: feat(dashboard/native-filters): Hide filters out of scope of current tab

Posted by GitBox <gi...@apache.org>.
graceguo-supercat commented on a change in pull request #14933:
URL: https://github.com/apache/superset/pull/14933#discussion_r650331375



##########
File path: superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx
##########
@@ -39,17 +43,47 @@ const DashboardContainer: FC<DashboardContainerProps> = ({ topLevelTabs }) => {
   const dashboardLayout = useSelector<RootState, DashboardLayout>(
     state => state.dashboardLayout.present,
   );
+  const nativeFilters = useSelector<RootState, Filters>(
+    state => state.nativeFilters.filters,
+  );
   const directPathToChild = useSelector<RootState, string[]>(
     state => state.dashboardState.directPathToChild,
   );
   const [tabIndex, setTabIndex] = useState(
     getRootLevelTabIndex(dashboardLayout, directPathToChild),
   );
 
+  const dispatch = useDispatch();
+
   useEffect(() => {
     setTabIndex(getRootLevelTabIndex(dashboardLayout, directPathToChild));
   }, [getLeafComponentIdFromPath(directPathToChild)]);
 
+  // recalculate charts and tabs in scopes of native filters only when a scope or dashboard layout changes
+  const nativeFiltersValues = Object.values(nativeFilters);
+  const scopes = nativeFiltersValues.map(filter => filter.scope);
+  useEffect(() => {
+    nativeFiltersValues.forEach(filter => {
+      const filterScope = filter.scope;
+      const chartsInScope = getChartIdsInFilterScope({
+        filterScope: {
+          scope: filterScope.rootPath,
+          // @ts-ignore
+          immune: filterScope.excluded,
+        },
+      });
+      const tabsInScope = findTabsWithChartsInScope(
+        dashboardLayout,
+        chartsInScope,
+      );
+      Object.assign(filter, {
+        chartsInScope,
+        tabsInScope: Array.from(tabsInScope),
+      });
+    });
+    dispatch(setFilterConfiguration(nativeFiltersValues));

Review comment:
       @kgabryje This update function is called every time user **_open_** a dashboard without any change. This is not a correct behavior. cc @junlincc 

##########
File path: superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx
##########
@@ -39,17 +43,47 @@ const DashboardContainer: FC<DashboardContainerProps> = ({ topLevelTabs }) => {
   const dashboardLayout = useSelector<RootState, DashboardLayout>(
     state => state.dashboardLayout.present,
   );
+  const nativeFilters = useSelector<RootState, Filters>(
+    state => state.nativeFilters.filters,
+  );
   const directPathToChild = useSelector<RootState, string[]>(
     state => state.dashboardState.directPathToChild,
   );
   const [tabIndex, setTabIndex] = useState(
     getRootLevelTabIndex(dashboardLayout, directPathToChild),
   );
 
+  const dispatch = useDispatch();
+
   useEffect(() => {
     setTabIndex(getRootLevelTabIndex(dashboardLayout, directPathToChild));
   }, [getLeafComponentIdFromPath(directPathToChild)]);
 
+  // recalculate charts and tabs in scopes of native filters only when a scope or dashboard layout changes
+  const nativeFiltersValues = Object.values(nativeFilters);
+  const scopes = nativeFiltersValues.map(filter => filter.scope);
+  useEffect(() => {
+    nativeFiltersValues.forEach(filter => {
+      const filterScope = filter.scope;
+      const chartsInScope = getChartIdsInFilterScope({
+        filterScope: {
+          scope: filterScope.rootPath,
+          // @ts-ignore
+          immune: filterScope.excluded,
+        },
+      });
+      const tabsInScope = findTabsWithChartsInScope(
+        dashboardLayout,
+        chartsInScope,
+      );
+      Object.assign(filter, {
+        chartsInScope,
+        tabsInScope: Array.from(tabsInScope),
+      });
+    });
+    dispatch(setFilterConfiguration(nativeFiltersValues));

Review comment:
       @kgabryje This update function is **_called every time_** user **_open_** a dashboard without any change. This is not a correct behavior. cc @junlincc 

##########
File path: superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx
##########
@@ -39,17 +43,47 @@ const DashboardContainer: FC<DashboardContainerProps> = ({ topLevelTabs }) => {
   const dashboardLayout = useSelector<RootState, DashboardLayout>(
     state => state.dashboardLayout.present,
   );
+  const nativeFilters = useSelector<RootState, Filters>(
+    state => state.nativeFilters.filters,
+  );
   const directPathToChild = useSelector<RootState, string[]>(
     state => state.dashboardState.directPathToChild,
   );
   const [tabIndex, setTabIndex] = useState(
     getRootLevelTabIndex(dashboardLayout, directPathToChild),
   );
 
+  const dispatch = useDispatch();
+
   useEffect(() => {
     setTabIndex(getRootLevelTabIndex(dashboardLayout, directPathToChild));
   }, [getLeafComponentIdFromPath(directPathToChild)]);
 
+  // recalculate charts and tabs in scopes of native filters only when a scope or dashboard layout changes
+  const nativeFiltersValues = Object.values(nativeFilters);
+  const scopes = nativeFiltersValues.map(filter => filter.scope);
+  useEffect(() => {
+    nativeFiltersValues.forEach(filter => {
+      const filterScope = filter.scope;
+      const chartsInScope = getChartIdsInFilterScope({
+        filterScope: {
+          scope: filterScope.rootPath,
+          // @ts-ignore
+          immune: filterScope.excluded,
+        },
+      });
+      const tabsInScope = findTabsWithChartsInScope(
+        dashboardLayout,
+        chartsInScope,
+      );
+      Object.assign(filter, {
+        chartsInScope,
+        tabsInScope: Array.from(tabsInScope),
+      });
+    });
+    dispatch(setFilterConfiguration(nativeFiltersValues));

Review comment:
       @kgabryje This update function is **_called every time_** a user **_opens_** a dashboard without any change. This is not a correct behavior. cc @junlincc 

##########
File path: superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx
##########
@@ -39,17 +43,47 @@ const DashboardContainer: FC<DashboardContainerProps> = ({ topLevelTabs }) => {
   const dashboardLayout = useSelector<RootState, DashboardLayout>(
     state => state.dashboardLayout.present,
   );
+  const nativeFilters = useSelector<RootState, Filters>(
+    state => state.nativeFilters.filters,
+  );
   const directPathToChild = useSelector<RootState, string[]>(
     state => state.dashboardState.directPathToChild,
   );
   const [tabIndex, setTabIndex] = useState(
     getRootLevelTabIndex(dashboardLayout, directPathToChild),
   );
 
+  const dispatch = useDispatch();
+
   useEffect(() => {
     setTabIndex(getRootLevelTabIndex(dashboardLayout, directPathToChild));
   }, [getLeafComponentIdFromPath(directPathToChild)]);
 
+  // recalculate charts and tabs in scopes of native filters only when a scope or dashboard layout changes
+  const nativeFiltersValues = Object.values(nativeFilters);
+  const scopes = nativeFiltersValues.map(filter => filter.scope);
+  useEffect(() => {
+    nativeFiltersValues.forEach(filter => {
+      const filterScope = filter.scope;
+      const chartsInScope = getChartIdsInFilterScope({
+        filterScope: {
+          scope: filterScope.rootPath,
+          // @ts-ignore
+          immune: filterScope.excluded,
+        },
+      });
+      const tabsInScope = findTabsWithChartsInScope(
+        dashboardLayout,
+        chartsInScope,
+      );
+      Object.assign(filter, {
+        chartsInScope,
+        tabsInScope: Array.from(tabsInScope),
+      });
+    });
+    dispatch(setFilterConfiguration(nativeFiltersValues));

Review comment:
       @kgabryje This update function is **_called every time_** a user **_opens_** a dashboard, even without any change. This is not a correct behavior. cc @junlincc 

##########
File path: superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx
##########
@@ -39,17 +43,47 @@ const DashboardContainer: FC<DashboardContainerProps> = ({ topLevelTabs }) => {
   const dashboardLayout = useSelector<RootState, DashboardLayout>(
     state => state.dashboardLayout.present,
   );
+  const nativeFilters = useSelector<RootState, Filters>(
+    state => state.nativeFilters.filters,
+  );
   const directPathToChild = useSelector<RootState, string[]>(
     state => state.dashboardState.directPathToChild,
   );
   const [tabIndex, setTabIndex] = useState(
     getRootLevelTabIndex(dashboardLayout, directPathToChild),
   );
 
+  const dispatch = useDispatch();
+
   useEffect(() => {
     setTabIndex(getRootLevelTabIndex(dashboardLayout, directPathToChild));
   }, [getLeafComponentIdFromPath(directPathToChild)]);
 
+  // recalculate charts and tabs in scopes of native filters only when a scope or dashboard layout changes
+  const nativeFiltersValues = Object.values(nativeFilters);
+  const scopes = nativeFiltersValues.map(filter => filter.scope);
+  useEffect(() => {
+    nativeFiltersValues.forEach(filter => {
+      const filterScope = filter.scope;
+      const chartsInScope = getChartIdsInFilterScope({
+        filterScope: {
+          scope: filterScope.rootPath,
+          // @ts-ignore
+          immune: filterScope.excluded,
+        },
+      });
+      const tabsInScope = findTabsWithChartsInScope(
+        dashboardLayout,
+        chartsInScope,
+      );
+      Object.assign(filter, {
+        chartsInScope,
+        tabsInScope: Array.from(tabsInScope),
+      });
+    });
+    dispatch(setFilterConfiguration(nativeFiltersValues));

Review comment:
       @kgabryje This update function is **_called every time_** a user **_opens_** a dashboard, even without any change. This is not a correct behavior. 
   And, update dashboard should check user permission and get user confirm. This call is secretly updated dashboard json_metadata without user confirm. This will cause serious issue. Please fix asap. Otherwise this PR should be reverted.
   cc @junlincc 

##########
File path: superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx
##########
@@ -39,17 +43,47 @@ const DashboardContainer: FC<DashboardContainerProps> = ({ topLevelTabs }) => {
   const dashboardLayout = useSelector<RootState, DashboardLayout>(
     state => state.dashboardLayout.present,
   );
+  const nativeFilters = useSelector<RootState, Filters>(
+    state => state.nativeFilters.filters,
+  );
   const directPathToChild = useSelector<RootState, string[]>(
     state => state.dashboardState.directPathToChild,
   );
   const [tabIndex, setTabIndex] = useState(
     getRootLevelTabIndex(dashboardLayout, directPathToChild),
   );
 
+  const dispatch = useDispatch();
+
   useEffect(() => {
     setTabIndex(getRootLevelTabIndex(dashboardLayout, directPathToChild));
   }, [getLeafComponentIdFromPath(directPathToChild)]);
 
+  // recalculate charts and tabs in scopes of native filters only when a scope or dashboard layout changes
+  const nativeFiltersValues = Object.values(nativeFilters);
+  const scopes = nativeFiltersValues.map(filter => filter.scope);
+  useEffect(() => {
+    nativeFiltersValues.forEach(filter => {
+      const filterScope = filter.scope;
+      const chartsInScope = getChartIdsInFilterScope({
+        filterScope: {
+          scope: filterScope.rootPath,
+          // @ts-ignore
+          immune: filterScope.excluded,
+        },
+      });
+      const tabsInScope = findTabsWithChartsInScope(
+        dashboardLayout,
+        chartsInScope,
+      );
+      Object.assign(filter, {
+        chartsInScope,
+        tabsInScope: Array.from(tabsInScope),
+      });
+    });
+    dispatch(setFilterConfiguration(nativeFiltersValues));

Review comment:
       @kgabryje This update function is **_called every time_** a user **_opens_** a dashboard, even without any change. This is not a correct behavior. 
   And, update dashboard should check user permission and get user confirm. This call is secretly changed dashboard json_metadata without user confirm. This will cause serious issue. Please fix asap. Otherwise this PR should be reverted.
   cc @junlincc 




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] kgabryje edited a comment on pull request #14933: feat(dashboard/native-filters): Hide filters out of scope of current tab

Posted by GitBox <gi...@apache.org>.
kgabryje edited a comment on pull request #14933:
URL: https://github.com/apache/superset/pull/14933#issuecomment-860579891


   @graceguo-supercat Thank you for raising those issues and providing context. PR https://github.com/apache/superset/pull/15146 solves part of the problem, another part will be fixed in a separate PR by @villebro 


-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org