From db86dd4a0a0f1c293242fcfcebcb1fe05a866771 Mon Sep 17 00:00:00 2001 From: geido Date: Fri, 5 Nov 2021 16:18:06 +0000 Subject: [PATCH] Make color scheme optional --- .../dashboard/components/PropertiesModal_spec.jsx | 9 +++++++++ .../src/dashboard/components/PropertiesModal/index.jsx | 3 ++- 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 efd33802f057b..e22bce70e76fd 100644 --- a/superset-frontend/spec/javascripts/dashboard/components/PropertiesModal_spec.jsx +++ b/superset-frontend/spec/javascripts/dashboard/components/PropertiesModal_spec.jsx @@ -148,6 +148,15 @@ describe('PropertiesModal', () => { expect(spy).toHaveBeenCalled(); }); }); + describe('with an empty color scheme as an arg', () => { + const wrapper = setup(); + const modalInstance = wrapper.find('PropertiesModal').instance(); + it('will not raise an error', () => { + const spy = jest.spyOn(Modal, 'error'); + modalInstance.onColorSchemeChange(''); + expect(spy).not.toHaveBeenCalled(); + }); + }); }); describe('onOwnersChange', () => { it('should update the state with the value passed', () => { diff --git a/superset-frontend/src/dashboard/components/PropertiesModal/index.jsx b/superset-frontend/src/dashboard/components/PropertiesModal/index.jsx index aa9bef7efd50b..9597ccfccd3c6 100644 --- a/superset-frontend/src/dashboard/components/PropertiesModal/index.jsx +++ b/superset-frontend/src/dashboard/components/PropertiesModal/index.jsx @@ -147,7 +147,8 @@ class PropertiesModal extends React.PureComponent { ? JSON.parse(jsonMetadata) : {}; - if (!colorScheme || !colorChoices.includes(colorScheme)) { + // only fire if the color_scheme is present and invalid + if (colorScheme && !colorChoices.includes(colorScheme)) { Modal.error({ title: 'Error', content: t('A valid color scheme is required'),