codepic edited a comment on issue #11113:
URL: 
https://github.com/apache/incubator-superset/issues/11113#issuecomment-702054905


   @villebro kiitos ;)
   
   @suddjian  Actually, I already found out that the `FilterBoxItemControl` 
emits `filter_configs` array when added to `controlPanel` so I tried the 
following:
   
   in 
`incubator-superset/superset-frontend/src/dashboard/reducers/dashboardState.js`
   ```diff
   index d9ddc59cd..a0c5bb7d6 100644
   --- a/superset-frontend/src/dashboard/reducers/getInitialState.js
   +++ b/superset-frontend/src/dashboard/reducers/getInitialState.js
   @@ -169,7 +169,7 @@ export default function getInitialState(bootstrapData) {
        }
    
        // build DashboardFilters for interactive filter features
   -    if (slice.form_data.viz_type === 'filter_box') {
   +    if (slice.form_data.filter_configs && 
slice.form_data.filter_configs.length > 0) {
          const configs = getFilterConfigsFromFormdata(slice.form_data);
          let { columns } = configs;
          const { labels } = configs;
   ```
   and in 
`incubator-superset/superset-frontend/src/dashboard/actions/dashboardState.js` 
   ```diff
   index 593ca4d78..da793c938 100644
   --- a/superset-frontend/src/dashboard/actions/dashboardState.js
   +++ b/superset-frontend/src/dashboard/actions/dashboardState.js
   @@ -284,7 +284,7 @@ export function addSliceToDashboard(id, component) {
        ]).then(() => {
          dispatch(addSlice(selectedSlice));
    
   -      if (selectedSlice && selectedSlice.viz_type === 'filter_box') {
   +      if (selectedSlice && form_data.filter_configs && 
form_data.filter_configs.length > 0) {
            dispatch(addFilter(id, component, selectedSlice.form_data));
          }
        });
   @@ -294,7 +294,7 @@ export function addSliceToDashboard(id, component) {
    export function removeSliceFromDashboard(id) {
      return (dispatch, getState) => {
        const sliceEntity = getState().sliceEntities.slices[id];
   -    if (sliceEntity && sliceEntity.viz_type === 'filter_box') {
   +    if (sliceEntity && sliceEntity.form_data.filter_configs && 
sliceEntity.form_data.filter_configs.length > 0) {
          dispatch(removeFilter(id));
        }
   ```
   And for my surprise, I didn't break the FilterBox plugin and my plugin works 
:D
   
   In any case @villebro, I will drop by the Superset Slack workspace a little 
bit later as I have this to prepare for our visualization meeting and see what 
they think of 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:
[email protected]



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

Reply via email to