Skip to content

Comments

[WIP][dashboard scoped filter] part 3: merge filter scope settings into dashboard redux state#8522

Merged
graceguo-supercat merged 7 commits intofeature--dashboard-scoped-filterfrom
scoped-filter-redux-v2
Nov 15, 2019
Merged

[WIP][dashboard scoped filter] part 3: merge filter scope settings into dashboard redux state#8522
graceguo-supercat merged 7 commits intofeature--dashboard-scoped-filterfrom
scoped-filter-redux-v2

Conversation

@graceguo-supercat
Copy link

@graceguo-supercat graceguo-supercat commented Nov 6, 2019

CATEGORY

Choose one

  • Bug Fix
  • Enhancement (new features, refinement)
  • Refactor
  • Add tests
  • Build / Development Environment
  • Documentation

SUMMARY

For each filter, add a scopes section into dashboard redux state:

{
  dashboardFilters: {
    '107': {
      chartId: 107,
      componentId: 'CHART-cb4a4fRA4_',
      filterName: 'Geo Filters',
      directPathToFilter: [
        'ROOT_ID',
        'TABS-zu0FcvKA_T',
        'TAB-BvXQux8j3p',
        'ROW-kAjhE4lwEU',
        'CHART-cb4a4fRA4_'
      ],
      isDateFilter: false,
      isInstantFilter: false,
      columns: {
        region: [
          'East Asia & Pacific'
        ]
      },
      labels: {
        country_name: 'country name'
      },
      scopes: {
        region: {
          scope: [
            'TAB-USeZvBtrV4'
          ],
          immune: []
        },
        country_name: {
          scope: [
            'TAB-hH18HAsBc'
          ],
          immune: []
        }
      }
    },
    '108': {
      chartId: 108,
      componentId: 'CHART-sC2TxRWldr',
      filterName: 'Time Filter',
      directPathToFilter: [
        'ROOT_ID',
        'TABS-zu0FcvKA_T',
        'TAB-6qz58YwIk',
        'ROW-9NyODqb45',
        'CHART-sC2TxRWldr'
      ],
      isDateFilter: true,
      isInstantFilter: true,
      columns: {},
      labels: {
        __time_range: 'Time range'
      },
      scopes: {
        __time_range: {
          scope: [
            'TAB-6qz58YwIk'
          ],
          immune: []
        }
      }
    }
  }
}

TEST PLAN

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

REVIEWERS

Copy link
Member

@etr2460 etr2460 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

first pass, i think i need to go through this again though

Comment on lines 147 to 148
const idSet = new Set(affectedChartIds);
this.refreshCharts([...idSet]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why build a set then make it an array again? just to dedupe? why not make affectedChartIds a Set from the getgo?

Copy link
Author

@graceguo-supercat graceguo-supercat Nov 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. convert to Set is to de-dupe. In the following loop, i need to keep adding array of values into affectedChartIds. I am not sure there is an easier way to add an array of values into Set?

);

this.props.updateDashboardFiltersScope(allFilterFieldScopes);
this.props.setUnsavedChanges(true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does passing true here mean? seems like setUnsavedChanges wouldn't require an argument

Copy link
Author

@graceguo-supercat graceguo-supercat Nov 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is signature ofsetUnsavedChanges function:

export function setUnsavedChanges(hasUnsavedChanges) {
  return { type: SET_UNSAVED_CHANGES, payload: { hasUnsavedChanges } };
}

i need to notify dashboard state that there is unsaved changes, since dashboardFilters state is updated.

slices: sliceEntities.slices,
layout: dashboardLayout.present,
impressionId,
loadStats: getLoadStatsPerTopLevelComponent({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we removing this?

Copy link
Author

@graceguo-supercat graceguo-supercat Nov 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is old dashboard perf logging. this prop loadStats is not used anywhere. getLoadStatsPerTopLevelComponent is kind of expensive and frequently being called.

md.pop("filter_immune_slice_fields", None)
md["filter_scopes"] = json.loads(data.get("filter_scopes", "{}"))
else:
if "filter_immune_slices" not in md:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have a migration plan for migrating filters over? when will this happen? will we migrate all the form data even if dashboards don't get visited?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, i think migration from backend is good idea. Users will update/add filter scopes for the active dashboards, but old dashboard will never got updated. I can make a migration once this feature got released and stabled.
For migration, the logic could be very simple: just convert all existed dashboard filters as global scope, and add immune charts if they had immune settings in dashboard metadata.

@graceguo-supercat graceguo-supercat force-pushed the convert-ids-to-tabs-v2 branch 2 times, most recently from 6f0d13b to 03b722e Compare November 11, 2019 08:49
@graceguo-supercat graceguo-supercat force-pushed the scoped-filter-redux-v2 branch 2 times, most recently from 3ee5354 to aa679e8 Compare November 11, 2019 10:07
@codecov-io
Copy link

codecov-io commented Nov 11, 2019

Codecov Report

Merging #8522 into feature--dashboard-scoped-filter will decrease coverage by <.01%.
The diff coverage is 69.01%.

Impacted file tree graph

@@                         Coverage Diff                         @@
##           feature--dashboard-scoped-filter   #8522      +/-   ##
===================================================================
- Coverage                                66%     66%   -0.01%     
===================================================================
  Files                                   470     474       +4     
  Lines                                 23127   23197      +70     
  Branches                               2485    2484       -1     
===================================================================
+ Hits                                  15265   15311      +46     
- Misses                                 7701    7728      +27     
+ Partials                                161     158       -3
Impacted Files Coverage Δ
...shboard/util/charts/getFormDataWithExtraFilters.js 89.47% <ø> (-1.44%) ⬇️
...et/assets/src/dashboard/components/SliceHeader.jsx 24% <ø> (ø) ⬆️
...src/dashboard/components/HeaderActionsDropdown.jsx 69.56% <ø> (ø) ⬆️
...uperset/assets/src/dashboard/components/Header.jsx 43.24% <ø> (ø) ⬆️
...shboard/components/filterscope/FilterScopeTree.jsx 50% <ø> (-4.55%) ⬇️
...ssets/src/dashboard/containers/DashboardHeader.jsx 100% <ø> (ø) ⬆️
...sets/src/dashboard/util/getFilterFieldNodesTree.js 0% <ø> (ø) ⬆️
...shboard/components/filterscope/FilterFieldTree.jsx 44.44% <ø> (-5.56%) ⬇️
...s/src/dashboard/components/SliceHeaderControls.jsx 11.62% <ø> (ø) ⬆️
...rset/assets/src/dashboard/components/SaveModal.jsx 43.9% <ø> (ø) ⬆️
... and 34 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b1aaa43...5f42413. Read the comment docs.

@graceguo-supercat
Copy link
Author

graceguo-supercat commented Nov 13, 2019

A few updates in the last commits, based on users and designer's feedack:

  1. Replace Select/deselect all filters to All filters. Replace Select/deselect all charts to All charts
  2. Click on Save button should update filter scopes setting to redux state, and close modal.
  3. Fix the bug: filter scopes settings are not saved to backend.

@graceguo-supercat graceguo-supercat force-pushed the convert-ids-to-tabs-v2 branch 2 times, most recently from eecf04f to 3e83142 Compare November 13, 2019 17:47

const NOOP = () => {};

const FILTER_SCOPE_CHECKBOX_TREE_ICONS = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the same with FILTER_FIELD_CHECKBOX_TREE_ICONS?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, they were not same at the very first version. now they are same. so i created a shared config.

@graceguo-supercat graceguo-supercat changed the base branch from convert-ids-to-tabs-v2 to feature--dashboard-scoped-filter November 13, 2019 22:23
...DASHBOARD_FILTER_SCOPE_GLOBAL,
...scopeSettings[column],
};
const immuneChartIds = new Set(filterImmuneSlices.slice());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you pass the array to Set, probably not need to make a copy.


// Build a list of fields the slice is immune to filters on
export default function getEffectiveExtraFilters(filters) {
const effectiveFilters = [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

export default function getEffectiveExtraFilters(filters) {
  return Object.entries(filters).map([column, values]) => ({
    col: column,
    op: 'in',
    val: values,
  });
}

Copy link
Contributor

@kristw kristw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a few minor, non-blocking comments.

@graceguo-supercat graceguo-supercat merged commit f869e19 into feature--dashboard-scoped-filter Nov 15, 2019
graceguo-supercat pushed a commit that referenced this pull request Nov 18, 2019
* [WIP][dashboard scoped filter] part 1: scope selector modal (#8557)

* filter scope selector modal

* add single-field-edit in multi-edit mode switch

* fix code review comments (round 1)

* refactory after design review

* fix a few props initial value

* [WIP][dashboard scoped filter] part 2: add algorithm to convert checked ids to scope object (#8564)

* convert ids to scope object

* use lodash helpers to make code readable

* [WIP][dashboard scoped filter] part 3: merge filter scope settings into dashboard redux state (#8522)

* merge filter scope settings into dashboard redux state

* fix/add unit tests

* minor bug fixes

* fix save filter Scopes behavior

* resolve review comments

* fix save filter scope settings

* minor comments

* [dashboard scoped filter] Improve scrollbar inside modal (#8553)

* improve scroll inside modal

* make left pane and right pane scroll separately

* fix review comments

* force show filter_box as unchecked (#8587)
@graceguo-supercat graceguo-supercat deleted the scoped-filter-redux-v2 branch November 25, 2019 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants