You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by mi...@apache.org on 2021/08/06 11:00:11 UTC

[superset] branch master updated: chore: Changes the RefreshIntervalModal component to use the new select component (#16048)

This is an automated email from the ASF dual-hosted git repository.

michaelsmolina 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 e59f318  chore: Changes the RefreshIntervalModal component to use the new select component (#16048)
e59f318 is described below

commit e59f318ef938d3ee8ffb77a2936a00d68e1c9829
Author: Michael S. Molina <70...@users.noreply.github.com>
AuthorDate: Fri Aug 6 07:58:53 2021 -0300

    chore: Changes the RefreshIntervalModal component to use the new select component (#16048)
---
 .../dashboard/components/RefreshIntervalModal_spec.jsx      |  6 +++---
 superset-frontend/src/components/Select/Select.tsx          |  2 +-
 .../src/dashboard/components/RefreshIntervalModal.tsx       | 13 ++++++-------
 3 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/superset-frontend/spec/javascripts/dashboard/components/RefreshIntervalModal_spec.jsx b/superset-frontend/spec/javascripts/dashboard/components/RefreshIntervalModal_spec.jsx
index fd6952b..711dc45 100644
--- a/superset-frontend/spec/javascripts/dashboard/components/RefreshIntervalModal_spec.jsx
+++ b/superset-frontend/spec/javascripts/dashboard/components/RefreshIntervalModal_spec.jsx
@@ -54,7 +54,7 @@ describe('RefreshIntervalModal', () => {
   });
   it('should change refreshFrequency with edit mode', () => {
     const wrapper = getMountWrapper(mockedProps);
-    wrapper.instance().handleFrequencyChange({ value: 30 });
+    wrapper.instance().handleFrequencyChange(30);
     wrapper.instance().onSave();
     expect(mockedProps.onChange).toHaveBeenCalled();
     expect(mockedProps.onChange).toHaveBeenCalledWith(30, mockedProps.editMode);
@@ -69,11 +69,11 @@ describe('RefreshIntervalModal', () => {
     const wrapper = getMountWrapper(props);
     wrapper.find('span[role="button"]').simulate('click');
 
-    wrapper.instance().handleFrequencyChange({ value: 30 });
+    wrapper.instance().handleFrequencyChange(30);
     wrapper.update();
     expect(wrapper.find(ModalTrigger).find(Alert)).toExist();
 
-    wrapper.instance().handleFrequencyChange({ value: 3601 });
+    wrapper.instance().handleFrequencyChange(3601);
     wrapper.update();
     expect(wrapper.find(ModalTrigger).find(Alert)).not.toExist();
   });
diff --git a/superset-frontend/src/components/Select/Select.tsx b/superset-frontend/src/components/Select/Select.tsx
index fcdbdfc..9e0929b 100644
--- a/superset-frontend/src/components/Select/Select.tsx
+++ b/superset-frontend/src/components/Select/Select.tsx
@@ -217,7 +217,7 @@ const Select = ({
   const handleTopOptions = useCallback(
     (selectedValue: AntdSelectValue | undefined) => {
       // bringing selected options to the top of the list
-      if (selectedValue) {
+      if (selectedValue !== undefined && selectedValue !== null) {
         const topOptions: OptionsType = [];
         const otherOptions: OptionsType = [];
 
diff --git a/superset-frontend/src/dashboard/components/RefreshIntervalModal.tsx b/superset-frontend/src/dashboard/components/RefreshIntervalModal.tsx
index aa97ff8..731572b 100644
--- a/superset-frontend/src/dashboard/components/RefreshIntervalModal.tsx
+++ b/superset-frontend/src/dashboard/components/RefreshIntervalModal.tsx
@@ -17,7 +17,7 @@
  * under the License.
  */
 import React, { RefObject } from 'react';
-import Select from 'src/components/Select';
+import { Select } from 'src/components';
 import { t, styled } from '@superset-ui/core';
 import Alert from 'src/components/Alert';
 import Button from 'src/components/Button';
@@ -36,7 +36,7 @@ export const options = [
   [21600, t('6 hours')],
   [43200, t('12 hours')],
   [86400, t('24 hours')],
-].map(o => ({ value: o[0], label: o[1] }));
+].map(o => ({ value: o[0] as number, label: o[1] }));
 
 const StyledModalTrigger = styled(ModalTrigger)`
   .ant-modal-body {
@@ -95,10 +95,9 @@ class RefreshIntervalModal extends React.PureComponent<
     this.modalRef.current?.close();
   }
 
-  handleFrequencyChange(opt: Record<string, any>) {
-    const value = opt ? opt.value : options[0].value;
+  handleFrequencyChange(value: number) {
     this.setState({
-      refreshFrequency: value,
+      refreshFrequency: value || options[0].value,
     });
   }
 
@@ -117,10 +116,10 @@ class RefreshIntervalModal extends React.PureComponent<
           <div>
             <FormLabel>{t('Refresh frequency')}</FormLabel>
             <Select
+              ariaLabel={t('Refresh interval')}
               options={options}
-              value={{ value: refreshFrequency }}
+              value={refreshFrequency}
               onChange={this.handleFrequencyChange}
-              forceOverflow
             />
             {showRefreshWarning && (
               <RefreshWarningContainer>