[Lyft-GA] Enable color consistency in a dashboard (#7135)

* Enable color consistency in a dashboard

Moved actions, minor UI, allowed dashboard copy

Fix linting errors

Undo unintentional change

Updated and added unit tests

Fail quietly if package has not been updated

Fail quietly on dashboard copy if package is old

* Update packages

* Remove unnecessary code

* Addressed Grace's comments

* Small fix for item key

* Reset chart's color during exploration

* Do not reset chart form data when exploring chart
This commit is contained in:
Kim Truong
2019-03-29 06:35:22 -07:00
committed by Christine Chambers
parent f66b598d37
commit e974a23f90
28 changed files with 586 additions and 170 deletions

View File

@@ -191,17 +191,60 @@ class DashboardTests(SupersetTestCase):
data['dashboard_title'] = origin_title
self.get_resp(url, data=dict(data=json.dumps(data)))
def test_save_dash_with_colors(self, username='admin'):
self.login(username=username)
dash = (
db.session.query(models.Dashboard)
.filter_by(slug='births')
.first()
)
positions = self.get_mock_positions(dash)
new_label_colors = {
'data value': 'random color',
}
data = {
'css': '',
'expanded_slices': {},
'positions': positions,
'dashboard_title': dash.dashboard_title,
'color_namespace': 'Color Namespace Test',
'color_scheme': 'Color Scheme Test',
'label_colors': new_label_colors,
}
url = '/superset/save_dash/{}/'.format(dash.id)
self.get_resp(url, data=dict(data=json.dumps(data)))
updatedDash = (
db.session.query(models.Dashboard)
.filter_by(slug='births')
.first()
)
self.assertIn('color_namespace', updatedDash.json_metadata)
self.assertIn('color_scheme', updatedDash.json_metadata)
self.assertIn('label_colors', updatedDash.json_metadata)
# bring back original dashboard
del data['color_namespace']
del data['color_scheme']
del data['label_colors']
self.get_resp(url, data=dict(data=json.dumps(data)))
def test_copy_dash(self, username='admin'):
self.login(username=username)
dash = db.session.query(models.Dashboard).filter_by(
slug='births').first()
positions = self.get_mock_positions(dash)
new_label_colors = {
'data value': 'random color',
}
data = {
'css': '',
'duplicate_slices': False,
'expanded_slices': {},
'positions': positions,
'dashboard_title': 'Copy Of Births',
'color_namespace': 'Color Namespace Test',
'color_scheme': 'Color Scheme Test',
'label_colors': new_label_colors,
}
# Save changes to Births dashboard and retrieve updated dash