You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by di...@apache.org on 2022/07/01 14:37:42 UTC

[superset] branch chore/color-scheme-updates created (now b8a0837222)

This is an automated email from the ASF dual-hosted git repository.

diegopucci pushed a change to branch chore/color-scheme-updates
in repository https://gitbox.apache.org/repos/asf/superset.git


      at b8a0837222 Update dashboard colors

This branch includes the following new commits:

     new 853e707414 Merge branch 'feat/explore-v1' of https://github.com/kgabryje/incubator-superset into chore/color-scheme-updates
     new 64d99402a1 Fallback to default color scheme
     new 08ff8772b2 Merge branch 'feat/explore-v1' of https://github.com/kgabryje/incubator-superset into chore/color-scheme-updates
     new c2ddb1cc17 Merge
     new 2f9988b828 Fix hydrate action
     new b8a0837222 Update dashboard colors

The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[superset] 02/06: Fallback to default color scheme

Posted by di...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

diegopucci pushed a commit to branch chore/color-scheme-updates
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 64d99402a1e71e41159e3ca0c87cb2f03ac7a937
Author: geido <di...@gmail.com>
AuthorDate: Thu Jun 30 13:43:12 2022 +0300

    Fallback to default color scheme
---
 .../src/explore/actions/hydrateExplore.ts          | 39 +++++++++++++++++++---
 1 file changed, 35 insertions(+), 4 deletions(-)

diff --git a/superset-frontend/src/explore/actions/hydrateExplore.ts b/superset-frontend/src/explore/actions/hydrateExplore.ts
index e9e1507ca0..4ffb5beedb 100644
--- a/superset-frontend/src/explore/actions/hydrateExplore.ts
+++ b/superset-frontend/src/explore/actions/hydrateExplore.ts
@@ -26,7 +26,7 @@ import {
 import { getChartKey } from 'src/explore/exploreUtils';
 import { getControlsState } from 'src/explore/store';
 import { Dispatch } from 'redux';
-import { ensureIsArray } from '@superset-ui/core';
+import { ensureIsArray, getCategoricalSchemeRegistry, getSequentialSchemeRegistry } from '@superset-ui/core';
 import {
   getFormDataFromControls,
   applyMapStateToPropsToControl,
@@ -48,7 +48,6 @@ export const hydrateExplore =
     const initialFormData = form_data ?? initialSlice?.form_data;
     const initialDatasource =
       datasources?.[initialFormData.datasource] ?? dataset;
-
     const initialData = {
       form_data: initialFormData,
       slice: initialSlice,
@@ -58,6 +57,23 @@ export const hydrateExplore =
       initialData,
       initialFormData,
     ) as ControlStateMapping;
+    const colorSchemeKey = initialControls['color_scheme'] && 'color_scheme';
+    const linearColorSchemeKey = initialControls['linear_color_scheme'] && 'linear_color_scheme';
+    // verifies whether the current color scheme exists in the registry
+    // if not fallbacks to the default
+    const verifyColorScheme = (type: 'CATEGORICAL' | 'SEQUENTIAL') => {
+      const schemes = type === 'CATEGORICAL' ? getCategoricalSchemeRegistry() : getSequentialSchemeRegistry();
+      const key = type === 'CATEGORICAL' ? colorSchemeKey : linearColorSchemeKey;
+      if (!schemes.items[initialFormData[key]]) {
+        Object.assign(initialFormData, {
+          color_scheme: schemes.defaultKey,
+        })
+        initialControls[key].value = schemes.defaultKey
+      }
+    }
+
+    if (colorSchemeKey) verifyColorScheme('CATEGORICAL');
+    if (linearColorSchemeKey) verifyColorScheme('SEQUENTIAL');
 
     const exploreState = {
       // note this will add `form_data` to state,
@@ -95,6 +111,8 @@ export const hydrateExplore =
       ? getFormDataFromControls(initialControls)
       : null;
 
+    const latestQueryFormData = getFormDataFromControls(exploreState.controls);
+
     const chartKey: number = getChartKey(initialData);
     const chart: ChartState = {
       id: chartKey,
@@ -103,7 +121,7 @@ export const hydrateExplore =
       chartStackTrace: null,
       chartUpdateEndTime: null,
       chartUpdateStartTime: 0,
-      latestQueryFormData: getFormDataFromControls(exploreState.controls),
+      latestQueryFormData,
       sliceFormData,
       queryController: null,
       queriesResponse: null,
@@ -126,7 +144,20 @@ export const hydrateExplore =
           dashboards: [],
           saveModalAlert: null,
         },
-        explore: exploreState,
+        explore: {
+          ...exploreState,
+          form_data: {
+            ...exploreState.form_data,
+            color_scheme: 'bnbColors',
+          },
+          slice: {
+            ...exploreState.slice,
+            form_data: {
+              ...exploreState.slice.form_data,
+              color_scheme: 'bnbColors',
+            }
+          }
+        },
       },
     });
   };


[superset] 06/06: Update dashboard colors

Posted by di...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

diegopucci pushed a commit to branch chore/color-scheme-updates
in repository https://gitbox.apache.org/repos/asf/superset.git

commit b8a08372226b78dc83bf8a3e5df4813718486c25
Author: geido <di...@gmail.com>
AuthorDate: Fri Jul 1 17:37:26 2022 +0300

    Update dashboard colors
---
 .../src/dashboard/actions/dashboardState.js        |  1 +
 .../DashboardBuilder/DashboardContainer.tsx        | 70 ++++++++++++++++++++++
 .../dashboard/components/PropertiesModal/index.tsx | 14 ++++-
 .../src/explore/actions/hydrateExplore.ts          |  6 +-
 .../controls/ColorSchemeControl/index.jsx          |  2 +-
 superset/dashboards/dao.py                         |  2 +-
 superset/dashboards/schemas.py                     |  1 +
 7 files changed, 89 insertions(+), 7 deletions(-)

diff --git a/superset-frontend/src/dashboard/actions/dashboardState.js b/superset-frontend/src/dashboard/actions/dashboardState.js
index f96b3ebadf..204bd14e3a 100644
--- a/superset-frontend/src/dashboard/actions/dashboardState.js
+++ b/superset-frontend/src/dashboard/actions/dashboardState.js
@@ -240,6 +240,7 @@ export function saveDashboardRequest(data, id, saveType) {
         ...data.metadata,
         color_namespace: data.metadata?.color_namespace || undefined,
         color_scheme: data.metadata?.color_scheme || '',
+        color_scheme_domain: data.metadata?.color_scheme_domain || [],
         expanded_slices: data.metadata?.expanded_slices || {},
         label_colors: data.metadata?.label_colors || {},
         shared_label_colors: data.metadata?.shared_label_colors || {},
diff --git a/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx b/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx
index c763f07267..f7083b9046 100644
--- a/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx
+++ b/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx
@@ -24,7 +24,10 @@ import {
   FeatureFlag,
   Filter,
   Filters,
+  getCategoricalSchemeRegistry,
+  getSharedLabelColor,
   isFeatureEnabled,
+  SupersetClient,
 } from '@superset-ui/core';
 import { ParentSize } from '@vx/responsive';
 import pick from 'lodash/pick';
@@ -32,6 +35,7 @@ import Tabs from 'src/components/Tabs';
 import DashboardGrid from 'src/dashboard/containers/DashboardGrid';
 import {
   ChartsState,
+  DashboardInfo,
   DashboardLayout,
   LayoutItem,
   RootState,
@@ -46,6 +50,9 @@ import { setInScopeStatusOfFilters } from 'src/dashboard/actions/nativeFilters';
 import { getRootLevelTabIndex, getRootLevelTabsComponent } from './utils';
 import { findTabsWithChartsInScope } from '../nativeFilters/utils';
 import { NATIVE_FILTER_DIVIDER_PREFIX } from '../nativeFilters/FiltersConfigModal/utils';
+import { dashboardInfoChanged } from 'src/dashboard/actions/dashboardInfo';
+import { setColorScheme } from 'src/dashboard/actions/dashboardState';
+import jsonStringify from 'json-stringify-pretty-compact';
 
 type DashboardContainerProps = {
   topLevelTabs?: LayoutItem;
@@ -73,6 +80,9 @@ const DashboardContainer: FC<DashboardContainerProps> = ({ topLevelTabs }) => {
   const dashboardLayout = useSelector<RootState, DashboardLayout>(
     state => state.dashboardLayout.present,
   );
+  const dashboardInfo = useSelector<RootState, DashboardInfo>(
+    state => state.dashboardInfo,
+  );
   const directPathToChild = useSelector<RootState, string[]>(
     state => state.dashboardState.directPathToChild,
   );
@@ -122,6 +132,65 @@ const DashboardContainer: FC<DashboardContainerProps> = ({ topLevelTabs }) => {
     dispatch(setInScopeStatusOfFilters(scopes));
   }, [nativeFilterScopes, dashboardLayout, dispatch]);
 
+  useEffect(() => {
+    const currentMetadata = 
+      dashboardInfo.json_metadata?.length && JSON.parse(dashboardInfo.json_metadata);
+      if (currentMetadata?.color_scheme) {
+        const metadata = {...currentMetadata};
+        const colorScheme = metadata?.color_scheme;
+        const colorSchemeDomain = metadata?.color_scheme_domain || [];
+        const colorNamespace = metadata?.color_namespace || '';
+        const categoricalSchemes = getCategoricalSchemeRegistry();
+        const registryColorSchemeDomain = categoricalSchemes.get(colorScheme)?.colors || [];
+        const defaultColorScheme = categoricalSchemes.defaultKey;
+        const isColorSchemeExisting = !!categoricalSchemes.get(colorScheme);
+        const updateDashboard = () => {
+          SupersetClient.put({
+            endpoint: `/api/v1/dashboard/${dashboardInfo.id}`,
+            headers: { 'Content-Type': 'application/json' },
+            body: JSON.stringify({
+              json_metadata: jsonStringify(metadata),
+            }),
+          }).then(() => {
+            dispatch(dashboardInfoChanged({
+              metadata,
+            }));
+            dispatch(setColorScheme(defaultColorScheme))
+          })
+        }
+        const genColorMap = (scheme: string, update = false) => {
+          // TODO: to check why colorMap is always empty
+          const colorMap = getSharedLabelColor().getColorMap(
+            colorNamespace,
+            scheme,
+            update,
+          );
+          return colorMap;
+        }
+
+        // color scheme does not exist anymore
+        // must fallback to the available default one
+        if (colorScheme && !isColorSchemeExisting) {
+          const updatedScheme = defaultColorScheme?.toString() || 'supersetColors';
+          metadata.color_scheme = updatedScheme;
+          metadata.shared_label_colors = genColorMap(updatedScheme, true);
+          metadata.color_scheme_domain = categoricalSchemes.get(defaultColorScheme)?.colors;
+          updateDashboard();
+          return;
+        }
+
+        // if this dashboard does not have a color_scheme_domain saved must create one
+        // if the color_scheme_domain does not correspond to the registry must update
+        if (
+          colorScheme && 
+          ((!colorSchemeDomain.length) || (registryColorSchemeDomain.toString() !== colorSchemeDomain.toString()))) {
+          metadata.color_scheme_domain = registryColorSchemeDomain;
+          metadata.shared_label_colors = genColorMap(colorScheme, true);
+          updateDashboard();
+        }
+      }
+  }, [dashboardInfo.json_metadata, dispatch])
+
   const childIds: string[] = topLevelTabs
     ? topLevelTabs.children
     : [DASHBOARD_GRID_ID];
@@ -171,3 +240,4 @@ const DashboardContainer: FC<DashboardContainerProps> = ({ topLevelTabs }) => {
 };
 
 export default DashboardContainer;
+
diff --git a/superset-frontend/src/dashboard/components/PropertiesModal/index.tsx b/superset-frontend/src/dashboard/components/PropertiesModal/index.tsx
index effd18b3d0..dc554c4e22 100644
--- a/superset-frontend/src/dashboard/components/PropertiesModal/index.tsx
+++ b/superset-frontend/src/dashboard/components/PropertiesModal/index.tsx
@@ -173,10 +173,14 @@ const PropertiesModal = ({
       if (metadata?.positions) {
         delete metadata.positions;
       }
-      const metaDataCopy = { ...metadata };
+      const metaDataCopy = { ...metadata }; 
+      
       if (metaDataCopy?.shared_label_colors) {
         delete metaDataCopy.shared_label_colors;
       }
+      if (metaDataCopy?.color_scheme_domain) {
+        delete metaDataCopy.color_scheme_domain;
+      }
       setJsonMetadata(metaDataCopy ? jsonStringify(metaDataCopy) : '');
     },
     [form],
@@ -262,7 +266,8 @@ const PropertiesModal = ({
     { updateMetadata = true } = {},
   ) => {
     // check that color_scheme is valid
-    const colorChoices = getCategoricalSchemeRegistry().keys();
+    const categoricalSchemeRegistry = getCategoricalSchemeRegistry();
+    const colorChoices = categoricalSchemeRegistry.keys();
     const jsonMetadataObj = getJsonMetadata();
 
     // only fire if the color_scheme is present and invalid
@@ -279,6 +284,8 @@ const PropertiesModal = ({
     if (updateMetadata) {
       jsonMetadataObj.color_scheme = colorScheme;
       jsonMetadataObj.label_colors = jsonMetadataObj.label_colors || {};
+      jsonMetadataObj.color_scheme_domain = 
+        categoricalSchemeRegistry.get(colorScheme)?.colors || [];
 
       setJsonMetadata(jsonStringify(jsonMetadataObj));
     }
@@ -302,6 +309,9 @@ const PropertiesModal = ({
       if (metadata?.shared_label_colors) {
         delete metadata.shared_label_colors;
       }
+      if (metadata?.color_scheme_domain) {
+        delete metadata.color_scheme_domain;
+      }
       const colorMap = getSharedLabelColor().getColorMap(
         colorNamespace,
         currentColorScheme,
diff --git a/superset-frontend/src/explore/actions/hydrateExplore.ts b/superset-frontend/src/explore/actions/hydrateExplore.ts
index 454f1449d8..cf7e111d66 100644
--- a/superset-frontend/src/explore/actions/hydrateExplore.ts
+++ b/superset-frontend/src/explore/actions/hydrateExplore.ts
@@ -69,13 +69,13 @@ export const hydrateExplore =
     ) as ControlStateMapping;
     const colorSchemeKey = initialControls['color_scheme'] && 'color_scheme';
     const linearColorSchemeKey = initialControls['linear_color_scheme'] && 'linear_color_scheme';
-    // verifies whether the current color scheme exists in the registry
-    // if not fallbacks to the default color scheme key
+    // if the color scheme does not exist anymore
+    // fallbacks to the available default key
     const verifyColorScheme = (type: 'CATEGORICAL' | 'SEQUENTIAL') => {
       const schemes = type === 'CATEGORICAL' ? getCategoricalSchemeRegistry() : getSequentialSchemeRegistry();
       const key = type === 'CATEGORICAL' ? colorSchemeKey : linearColorSchemeKey;
       const currentScheme = initialFormData[key];
-      if (currentScheme && !schemes.items[currentScheme]) {
+      if (currentScheme && !schemes.get[currentScheme]) {
         initialControls[key].value = schemes.defaultKey
       }
     }
diff --git a/superset-frontend/src/explore/components/controls/ColorSchemeControl/index.jsx b/superset-frontend/src/explore/components/controls/ColorSchemeControl/index.jsx
index f0ccc12398..e12b258c28 100644
--- a/superset-frontend/src/explore/components/controls/ColorSchemeControl/index.jsx
+++ b/superset-frontend/src/explore/components/controls/ColorSchemeControl/index.jsx
@@ -192,7 +192,7 @@ export default class ColorSchemeControl extends React.PureComponent {
       onChange: this.onChange,
       options,
       placeholder: t('Select scheme'),
-      value: currentScheme,
+      value: currentScheme && currentScheme.toString(),
     };
 
     return (
diff --git a/superset/dashboards/dao.py b/superset/dashboards/dao.py
index 62b6843ce2..8e54ef1124 100644
--- a/superset/dashboards/dao.py
+++ b/superset/dashboards/dao.py
@@ -267,7 +267,7 @@ class DashboardDAO(BaseDAO):
         md["color_scheme"] = data.get("color_scheme", "")
         md["label_colors"] = data.get("label_colors", {})
         md["shared_label_colors"] = data.get("shared_label_colors", {})
-
+        md["color_scheme_domain"] = data.get("color_scheme_domain", [])
         dashboard.json_metadata = json.dumps(md)
 
         if commit:
diff --git a/superset/dashboards/schemas.py b/superset/dashboards/schemas.py
index d91879f0d8..a930d87d08 100644
--- a/superset/dashboards/schemas.py
+++ b/superset/dashboards/schemas.py
@@ -129,6 +129,7 @@ class DashboardJSONMetadataSchema(Schema):
     positions = fields.Dict(allow_none=True)
     label_colors = fields.Dict()
     shared_label_colors = fields.Dict()
+    color_scheme_domain = fields.List(fields.Str())
     # used for v0 import/export
     import_time = fields.Integer()
     remote_id = fields.Integer()


[superset] 03/06: Merge branch 'feat/explore-v1' of https://github.com/kgabryje/incubator-superset into chore/color-scheme-updates

Posted by di...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

diegopucci pushed a commit to branch chore/color-scheme-updates
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 08ff8772b26fc1b13198c274de7c821568a4411b
Merge: 64d99402a1 c3f151a660
Author: geido <di...@gmail.com>
AuthorDate: Thu Jun 30 13:43:33 2022 +0300

    Merge branch 'feat/explore-v1' of https://github.com/kgabryje/incubator-superset into chore/color-scheme-updates

 .../SqlLab/components/SaveDatasetModal/index.tsx   | 75 ++++++++++++++--------
 superset-frontend/src/SqlLab/types.ts              | 10 ++-
 .../exploreUtils/getParsedExploreURLParams.test.ts |  5 ++
 .../exploreUtils/getParsedExploreURLParams.ts      |  1 +
 .../src/explore/exploreUtils/index.js              |  3 +-
 5 files changed, 63 insertions(+), 31 deletions(-)


[superset] 04/06: Merge

Posted by di...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

diegopucci pushed a commit to branch chore/color-scheme-updates
in repository https://gitbox.apache.org/repos/asf/superset.git

commit c2ddb1cc1701f56874d93b473f52b366b9e94ca0
Merge: 08ff8772b2 99a1ebc4b8
Author: geido <di...@gmail.com>
AuthorDate: Thu Jun 30 15:26:22 2022 +0300

    Merge

 .../src/addSlice/AddSliceContainer.test.tsx        |  9 ++--
 .../src/addSlice/AddSliceContainer.tsx             | 31 ++++++------
 superset-frontend/src/constants.ts                 |  4 ++
 superset-frontend/src/explore/ExplorePage.tsx      | 56 ++++++++++------------
 .../src/explore/actions/hydrateExplore.ts          | 19 ++++++--
 .../exploreUtils/getParsedExploreURLParams.ts      |  6 +++
 6 files changed, 66 insertions(+), 59 deletions(-)

diff --cc superset-frontend/src/explore/actions/hydrateExplore.ts
index 4ffb5beedb,ec49c0cdd5..0c7491d161
--- a/superset-frontend/src/explore/actions/hydrateExplore.ts
+++ b/superset-frontend/src/explore/actions/hydrateExplore.ts
@@@ -54,26 -64,9 +64,26 @@@ export const hydrateExplore 
        datasource: initialDatasource,
      };
      const initialControls = getControlsState(
-       initialData,
+       initialExploreState,
        initialFormData,
      ) as ControlStateMapping;
 +    const colorSchemeKey = initialControls['color_scheme'] && 'color_scheme';
 +    const linearColorSchemeKey = initialControls['linear_color_scheme'] && 'linear_color_scheme';
 +    // verifies whether the current color scheme exists in the registry
 +    // if not fallbacks to the default
 +    const verifyColorScheme = (type: 'CATEGORICAL' | 'SEQUENTIAL') => {
 +      const schemes = type === 'CATEGORICAL' ? getCategoricalSchemeRegistry() : getSequentialSchemeRegistry();
 +      const key = type === 'CATEGORICAL' ? colorSchemeKey : linearColorSchemeKey;
 +      if (!schemes.items[initialFormData[key]]) {
 +        Object.assign(initialFormData, {
 +          color_scheme: schemes.defaultKey,
 +        })
 +        initialControls[key].value = schemes.defaultKey
 +      }
 +    }
 +
 +    if (colorSchemeKey) verifyColorScheme('CATEGORICAL');
 +    if (linearColorSchemeKey) verifyColorScheme('SEQUENTIAL');
  
      const exploreState = {
        // note this will add `form_data` to state,
@@@ -111,9 -104,7 +121,8 @@@
        ? getFormDataFromControls(initialControls)
        : null;
  
 +    const latestQueryFormData = getFormDataFromControls(exploreState.controls);
- 
-     const chartKey: number = getChartKey(initialData);
+     const chartKey: number = getChartKey(initialExploreState);
      const chart: ChartState = {
        id: chartKey,
        chartAlert: null,


[superset] 01/06: Merge branch 'feat/explore-v1' of https://github.com/kgabryje/incubator-superset into chore/color-scheme-updates

Posted by di...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

diegopucci pushed a commit to branch chore/color-scheme-updates
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 853e707414a946fe04c7cee5046b2939a8af108b
Merge: 932e304ffb 24bc86baa3
Author: geido <di...@gmail.com>
AuthorDate: Thu Jun 30 12:17:55 2022 +0300

    Merge branch 'feat/explore-v1' of https://github.com/kgabryje/incubator-superset into chore/color-scheme-updates

 .../cypress/integration/explore/chart.test.js      |   2 +-
 .../cypress/integration/explore/control.test.ts    |  10 +-
 .../integration/explore/explore.applitools.test.ts |   2 +-
 .../cypress/integration/explore/filter_box.test.js |   2 +-
 .../cypress/integration/explore/link.test.ts       |   2 +-
 .../explore/visualizations/area.test.js            |  34 +++--
 .../explore/visualizations/big_number.test.js      |   6 +-
 .../explore/visualizations/box_plot.test.js        |   2 +-
 .../explore/visualizations/bubble.test.js          |   8 +-
 .../explore/visualizations/compare.test.js         |   2 +-
 .../explore/visualizations/dist_bar.test.js        |   8 +-
 .../explore/visualizations/download_chart.test.js  |   2 +-
 .../explore/visualizations/dual_line.test.js       |   4 +-
 .../explore/visualizations/gauge.test.js           |   2 +-
 .../explore/visualizations/graph.test.ts           |   2 +-
 .../explore/visualizations/histogram.test.ts       |   2 +-
 .../explore/visualizations/line.test.ts            |  38 +++---
 .../integration/explore/visualizations/pie.test.js |   2 +-
 .../explore/visualizations/pivot_table.test.js     |   4 +-
 .../explore/visualizations/sankey.test.js          |   6 +-
 .../explore/visualizations/shared.helper.js        |   4 +-
 .../explore/visualizations/sunburst.test.js        |   2 +-
 .../explore/visualizations/table.test.ts           |   8 +-
 .../explore/visualizations/time_table.js           |  10 +-
 .../explore/visualizations/treemap.test.js         |   2 +-
 .../explore/visualizations/world_map.test.js       |   2 +-
 .../cypress-base/cypress/support/index.ts          |  46 ++++++-
 .../superset-ui-chart-controls/src/types.ts        |  10 ++
 .../src/components/Chart/chartReducer.ts           |   3 +-
 superset-frontend/src/explore/App.jsx              |   6 +-
 superset-frontend/src/explore/ExplorePage.tsx      |  76 +++++++++++
 .../src/explore/actions/datasourcesActions.ts      |   2 +-
 .../src/explore/actions/hydrateExplore.test.ts     |  92 +++++++++++++
 .../src/explore/actions/hydrateExplore.ts          | 137 +++++++++++++++++++
 .../explore/components/ControlPanelsContainer.tsx  |   3 +-
 .../DatasourcePanel/DatasourcePanel.test.tsx       |   4 +-
 .../components/ExploreViewContainer/index.jsx      |  16 +--
 .../controls/DatasourceControl/index.jsx           |   2 +-
 .../controls/VizTypeControl/FastVizSwitcher.tsx    |   2 +-
 .../exploreUtils/getParsedExploreURLParams.test.ts |  57 ++++++++
 .../exploreUtils/getParsedExploreURLParams.ts      | 110 ++++++++++++++++
 superset-frontend/src/explore/fixtures.tsx         |  59 ++++++++-
 superset-frontend/src/explore/index.jsx            |  22 +++-
 .../src/explore/reducers/datasourcesReducer.ts     |   6 +-
 .../src/explore/reducers/exploreReducer.js         |   7 +-
 .../src/explore/reducers/getInitialState.ts        | 146 ---------------------
 .../src/explore/reducers/saveModalReducer.js       |   4 +
 superset-frontend/src/explore/store.js             |   2 +-
 superset-frontend/src/explore/types.ts             |  47 ++++++-
 49 files changed, 753 insertions(+), 274 deletions(-)


[superset] 05/06: Fix hydrate action

Posted by di...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

diegopucci pushed a commit to branch chore/color-scheme-updates
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 2f9988b828e05b5a70ea4c52c78eb41269640658
Author: geido <di...@gmail.com>
AuthorDate: Thu Jun 30 15:51:16 2022 +0300

    Fix hydrate action
---
 .../src/explore/actions/hydrateExplore.ts          | 23 ++++------------------
 1 file changed, 4 insertions(+), 19 deletions(-)

diff --git a/superset-frontend/src/explore/actions/hydrateExplore.ts b/superset-frontend/src/explore/actions/hydrateExplore.ts
index 0c7491d161..454f1449d8 100644
--- a/superset-frontend/src/explore/actions/hydrateExplore.ts
+++ b/superset-frontend/src/explore/actions/hydrateExplore.ts
@@ -70,14 +70,12 @@ export const hydrateExplore =
     const colorSchemeKey = initialControls['color_scheme'] && 'color_scheme';
     const linearColorSchemeKey = initialControls['linear_color_scheme'] && 'linear_color_scheme';
     // verifies whether the current color scheme exists in the registry
-    // if not fallbacks to the default
+    // if not fallbacks to the default color scheme key
     const verifyColorScheme = (type: 'CATEGORICAL' | 'SEQUENTIAL') => {
       const schemes = type === 'CATEGORICAL' ? getCategoricalSchemeRegistry() : getSequentialSchemeRegistry();
       const key = type === 'CATEGORICAL' ? colorSchemeKey : linearColorSchemeKey;
-      if (!schemes.items[initialFormData[key]]) {
-        Object.assign(initialFormData, {
-          color_scheme: schemes.defaultKey,
-        })
+      const currentScheme = initialFormData[key];
+      if (currentScheme && !schemes.items[currentScheme]) {
         initialControls[key].value = schemes.defaultKey
       }
     }
@@ -153,20 +151,7 @@ export const hydrateExplore =
           dashboards: [],
           saveModalAlert: null,
         },
-        explore: {
-          ...exploreState,
-          form_data: {
-            ...exploreState.form_data,
-            color_scheme: 'bnbColors',
-          },
-          slice: {
-            ...exploreState.slice,
-            form_data: {
-              ...exploreState.slice.form_data,
-              color_scheme: 'bnbColors',
-            }
-          }
-        },
+        explore: exploreState,
       },
     });
   };