This is an automated email from the ASF dual-hosted git repository.
beto pushed a commit to branch lyftga
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/lyftga by this push:
new 7c80cf5 Fix refresh frequency (#7248)
7c80cf5 is described below
commit 7c80cf58ebed008e17cb1a9e69142c4d43f11d31
Author: Beto Dealmeida <[email protected]>
AuthorDate: Tue Apr 9 11:22:28 2019 -0700
Fix refresh frequency (#7248)
* Fix refresh frequency
* Fix unit tests
---
.../dashboard/components/HeaderActionsDropdown_spec.jsx | 8 ++++----
superset/assets/src/dashboard/components/Header.jsx | 2 ++
.../src/dashboard/components/HeaderActionsDropdown.jsx | 12 +++++++-----
superset/assets/src/dashboard/reducers/dashboardState.js | 6 +++++-
4 files changed, 18 insertions(+), 10 deletions(-)
diff --git
a/superset/assets/spec/javascripts/dashboard/components/HeaderActionsDropdown_spec.jsx
b/superset/assets/spec/javascripts/dashboard/components/HeaderActionsDropdown_spec.jsx
index cd1c015..f89c9ed 100644
---
a/superset/assets/spec/javascripts/dashboard/components/HeaderActionsDropdown_spec.jsx
+++
b/superset/assets/spec/javascripts/dashboard/components/HeaderActionsDropdown_spec.jsx
@@ -71,9 +71,9 @@ describe('HeaderActionsDropdown', () => {
expect(wrapper.find(MenuItem)).toHaveLength(1);
});
- it('should render the RefreshIntervalModal', () => {
+ it('should not render the RefreshIntervalModal', () => {
const wrapper = setup(overrideProps);
- expect(wrapper.find(RefreshIntervalModal)).toHaveLength(1);
+ expect(wrapper.find(RefreshIntervalModal)).toHaveLength(0);
});
it('should render the URLShortLinkModal', () => {
@@ -105,9 +105,9 @@ describe('HeaderActionsDropdown', () => {
expect(wrapper.find(MenuItem)).toHaveLength(2);
});
- it('should render the RefreshIntervalModal', () => {
+ it('should not render the RefreshIntervalModal', () => {
const wrapper = setup(overrideProps);
- expect(wrapper.find(RefreshIntervalModal)).toHaveLength(1);
+ expect(wrapper.find(RefreshIntervalModal)).toHaveLength(0);
});
it('should render the URLShortLinkModal', () => {
diff --git a/superset/assets/src/dashboard/components/Header.jsx
b/superset/assets/src/dashboard/components/Header.jsx
index 366efbe..92d3b1d 100644
--- a/superset/assets/src/dashboard/components/Header.jsx
+++ b/superset/assets/src/dashboard/components/Header.jsx
@@ -215,6 +215,7 @@ class Header extends React.PureComponent {
colorScheme,
filters,
dashboardInfo,
+ refreshFrequency,
} = this.props;
const scale = CategoricalColorNamespace.getScale(
@@ -231,6 +232,7 @@ class Header extends React.PureComponent {
label_colors: labelColors,
dashboard_title: dashboardTitle,
default_filters: safeStringify(filters),
+ refresh_frequency: refreshFrequency,
};
// make sure positions data less than DB storage limitation:
diff --git a/superset/assets/src/dashboard/components/HeaderActionsDropdown.jsx
b/superset/assets/src/dashboard/components/HeaderActionsDropdown.jsx
index 5fc9d0e..5aa468b 100644
--- a/superset/assets/src/dashboard/components/HeaderActionsDropdown.jsx
+++ b/superset/assets/src/dashboard/components/HeaderActionsDropdown.jsx
@@ -177,11 +177,13 @@ class HeaderActionsDropdown extends React.PureComponent {
<MenuItem onClick={forceRefreshAllCharts} disabled={isLoading}>
{t('Force refresh dashboard')}
</MenuItem>
- <RefreshIntervalModal
- refreshFrequency={refreshFrequency}
- onChange={this.changeRefreshInterval}
- triggerNode={<span>{t('Set auto-refresh interval')}</span>}
- />
+ {editMode && (
+ <RefreshIntervalModal
+ refreshFrequency={refreshFrequency}
+ onChange={this.changeRefreshInterval}
+ triggerNode={<span>{t('Set auto-refresh interval')}</span>}
+ />
+ )}
{editMode && (
<MenuItem target="_blank" href={`/dashboard/edit/${dashboardId}`}>
{t('Edit dashboard metadata')}
diff --git a/superset/assets/src/dashboard/reducers/dashboardState.js
b/superset/assets/src/dashboard/reducers/dashboardState.js
index 007f63a..830e2a7 100644
--- a/superset/assets/src/dashboard/reducers/dashboardState.js
+++ b/superset/assets/src/dashboard/reducers/dashboardState.js
@@ -162,7 +162,11 @@ export default function dashboardStateReducer(state = {},
action) {
return { ...state, hasUnsavedChanges };
},
[SET_REFRESH_FREQUENCY]() {
- return { ...state, refreshFrequency: action.refreshFrequency };
+ return {
+ ...state,
+ refreshFrequency: action.refreshFrequency,
+ hasUnsavedChanges: true,
+ };
},
};