chore: Changes the RefreshIntervalModal component to use the new select component (#16048)
This commit is contained in:
parent
423ff50768
commit
e59f318ef9
|
|
@ -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();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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 = [];
|
||||
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
Loading…
Reference in New Issue