superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maximebeauche...@apache.org
Subject [incubator-superset] branch master updated: Fix click on now in DateFilterControl (#4265)
Date Wed, 24 Jan 2018 21:15:47 GMT
This is an automated email from the ASF dual-hosted git repository.

maximebeauchemin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 9cf16a4  Fix click on now in DateFilterControl (#4265)
9cf16a4 is described below

commit 9cf16a4ff2749a4c33e002dd7d96d7fff6708d13
Author: Maxime Beauchemin <maximebeauchemin@gmail.com>
AuthorDate: Wed Jan 24 13:15:44 2018 -0800

    Fix click on now in DateFilterControl (#4265)
    
    When clicking on `now` or the infinity sign, the popover closes but the
    value doesn't show in the label as expected.
---
 .../explore/components/controls/DateFilterControl.jsx         | 11 ++++++-----
 .../javascripts/explore/components/DateFilterControl_spec.jsx |  8 ++++++++
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/superset/assets/javascripts/explore/components/controls/DateFilterControl.jsx
b/superset/assets/javascripts/explore/components/controls/DateFilterControl.jsx
index 98db93a..3669c9f 100644
--- a/superset/assets/javascripts/explore/components/controls/DateFilterControl.jsx
+++ b/superset/assets/javascripts/explore/components/controls/DateFilterControl.jsx
@@ -69,9 +69,8 @@ export default class DateFilterControl extends React.Component {
   setType(type) {
     this.setState({ type });
   }
-  setValue(val) {
-    this.setState({ type: 'free', free: val });
-    this.close();
+  setValueAndClose(val) {
+    this.setState({ type: 'free', free: val }, this.close);
   }
   setDatetime(dttm) {
     this.setState({ dttm: dttm.format().substring(0, 19) });
@@ -175,13 +174,15 @@ export default class DateFilterControl extends React.Component {
             >
               <Button
                 bsSize="small"
-                onClick={this.setValue.bind(this, 'now')}
+                className="now"
+                onClick={this.setValueAndClose.bind(this, 'now')}
               >
                 now
               </Button>
               <Button
                 bsSize="small"
-                onClick={this.setValue.bind(this, '')}
+                className="clear"
+                onClick={this.setValueAndClose.bind(this, '')}
               >
                 clear
               </Button>
diff --git a/superset/assets/spec/javascripts/explore/components/DateFilterControl_spec.jsx
b/superset/assets/spec/javascripts/explore/components/DateFilterControl_spec.jsx
index e15356e..54db5c9 100644
--- a/superset/assets/spec/javascripts/explore/components/DateFilterControl_spec.jsx
+++ b/superset/assets/spec/javascripts/explore/components/DateFilterControl_spec.jsx
@@ -42,6 +42,14 @@ describe('DateFilterControl', () => {
       expect(wrapper.state().num).to.equal('90');
     }, 10);
   });
+  it('sets now and closes', () => {
+    const label = wrapper.find('.now').first();
+    label.simulate('click');
+    setTimeout(() => {
+      expect(wrapper.state().free).to.equal('now');
+      expect(wrapper.find('.popover')).to.have.length(0);
+    }, 10);
+  });
   it('renders 2 dimmed sections', () => {
     const label = wrapper.find('.label').first();
     label.simulate('click');

-- 
To stop receiving notification emails like this one, please contact
maximebeauchemin@apache.org.

Mime
View raw message