This is an automated email from the ASF dual-hosted git repository.
amitmiran pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new e062906 fix(colors): fix color schemes (#13945)
e062906 is described below
commit e06290663a23740e9cd3f50f2913b016bd7f205f
Author: simcha90 <[email protected]>
AuthorDate: Sun Apr 4 15:53:21 2021 +0300
fix(colors): fix color schemes (#13945)
* fix: fix color schemes
* fix: tests case
---
.../javascripts/dashboard/components/PropertiesModal_spec.jsx | 2 +-
superset-frontend/src/dashboard/components/PropertiesModal.jsx | 10 ++++++++++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git
a/superset-frontend/spec/javascripts/dashboard/components/PropertiesModal_spec.jsx
b/superset-frontend/spec/javascripts/dashboard/components/PropertiesModal_spec.jsx
index 5387c5e..20edc28 100644
---
a/superset-frontend/spec/javascripts/dashboard/components/PropertiesModal_spec.jsx
+++
b/superset-frontend/spec/javascripts/dashboard/components/PropertiesModal_spec.jsx
@@ -113,7 +113,7 @@ describe('PropertiesModal', () => {
const spy = jest.spyOn(modalInstance, 'onMetadataChange');
modalInstance.onColorSchemeChange('SUPERSET_DEFAULT');
expect(spy).toHaveBeenCalledWith(
- '{"color_scheme": "SUPERSET_DEFAULT"}',
+ '{"color_scheme": "SUPERSET_DEFAULT", "label_colors": {}}',
);
});
});
diff --git a/superset-frontend/src/dashboard/components/PropertiesModal.jsx
b/superset-frontend/src/dashboard/components/PropertiesModal.jsx
index 481893f..170d787 100644
--- a/superset-frontend/src/dashboard/components/PropertiesModal.jsx
+++ b/superset-frontend/src/dashboard/components/PropertiesModal.jsx
@@ -28,6 +28,7 @@ import {
t,
SupersetClient,
getCategoricalSchemeRegistry,
+ CategoricalColorNamespace,
} from '@superset-ui/core';
import Modal from 'src/common/components/Modal';
@@ -158,6 +159,15 @@ class PropertiesModal extends React.PureComponent {
Object.keys(jsonMetadataObj).includes('color_scheme')
) {
jsonMetadataObj.color_scheme = value;
+ jsonMetadataObj.label_colors = Object.keys(
+ jsonMetadataObj.label_colors ?? {},
+ ).reduce(
+ (prev, next) => ({
+ ...prev,
+ [next]: CategoricalColorNamespace.getScale(value)(next),
+ }),
+ {},
+ );
this.onMetadataChange(jsonStringify(jsonMetadataObj));
}