Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions superset-frontend/src/components/TimezoneSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

import React, { useEffect, useRef } from 'react';
import moment from 'moment-timezone';

import { NativeGraySelect as Select } from 'src/components/Select';
import { t } from '@superset-ui/core';
import { Select } from 'src/components';

const DEFAULT_TIMEZONE = 'GMT Standard Time';
const MIN_SELECT_WIDTH = '375px';
Expand Down Expand Up @@ -92,12 +92,6 @@ const TIMEZONE_OPTIONS = TIMEZONES.sort(
offsets: getOffsetKey(zone.name),
}));

const timezoneOptions = TIMEZONE_OPTIONS.map(option => (
<Select.Option key={option.value} value={option.value}>
{option.label}
</Select.Option>
));

const TimezoneSelector = ({ onTimezoneChange, timezone }: TimezoneProps) => {
const prevTimezone = useRef(timezone);
const matchTimezoneToOptions = (timezone: string) =>
Expand All @@ -120,12 +114,12 @@ const TimezoneSelector = ({ onTimezoneChange, timezone }: TimezoneProps) => {

return (
<Select
ariaLabel={t('Timezone')}
css={{ minWidth: MIN_SELECT_WIDTH }} // smallest size for current values
onChange={onTimezoneChange}
value={timezone || DEFAULT_TIMEZONE}
>
{timezoneOptions}
</Select>
options={TIMEZONE_OPTIONS}
/>
);
};

Expand Down
36 changes: 14 additions & 22 deletions superset-frontend/src/views/CRUD/alert/AlertReportModal.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import fetchMock from 'fetch-mock';
import { act } from 'react-dom/test-utils';
import AlertReportModal from 'src/views/CRUD/alert/AlertReportModal';
import Modal from 'src/components/Modal';
import { AsyncSelect, NativeGraySelect as Select } from 'src/components/Select';
import { Select } from 'src/components';
import { Switch } from 'src/components/Switch';
import { Radio } from 'src/components/Radio';
import TextAreaControl from 'src/explore/components/controls/TextAreaControl';
Expand Down Expand Up @@ -161,11 +161,15 @@ describe('AlertReportModal', () => {
};

const editWrapper = await mountAndWait(props);
expect(editWrapper.find(AsyncSelect).at(1).props().value).toEqual({
expect(
editWrapper.find('[aria-label="Database"]').at(0).props().value,
).toEqual({
value: 1,
label: 'test database',
});
expect(editWrapper.find(AsyncSelect).at(2).props().value).toEqual({
expect(
editWrapper.find('[aria-label="Chart"]').at(0).props().value,
).toEqual({
value: 1,
label: 'test chart',
});
Expand All @@ -176,21 +180,9 @@ describe('AlertReportModal', () => {
expect(wrapper.find('input[name="name"]')).toExist();
});

it('renders three async select elements when in report mode', () => {
expect(wrapper.find(AsyncSelect)).toExist();
expect(wrapper.find(AsyncSelect)).toHaveLength(3);
});

it('renders four async select elements when in alert mode', async () => {
const props = {
...mockedProps,
isReport: false,
};

const addWrapper = await mountAndWait(props);

expect(addWrapper.find(AsyncSelect)).toExist();
expect(addWrapper.find(AsyncSelect)).toHaveLength(4);
it('renders five select elements when in report mode', () => {
expect(wrapper.find(Select)).toExist();
expect(wrapper.find(Select)).toHaveLength(5);
});

it('renders Switch element', () => {
Expand Down Expand Up @@ -226,12 +218,12 @@ describe('AlertReportModal', () => {
expect(input.props().value).toEqual('SELECT NaN');
});

it('renders two select element when in report mode', () => {
it('renders five select element when in report mode', () => {
expect(wrapper.find(Select)).toExist();
expect(wrapper.find(Select)).toHaveLength(2);
expect(wrapper.find(Select)).toHaveLength(5);
});

it('renders three select elements when in alert mode', async () => {
it('renders seven select elements when in alert mode', async () => {
const props = {
...mockedProps,
isReport: false,
Expand All @@ -240,7 +232,7 @@ describe('AlertReportModal', () => {
const addWrapper = await mountAndWait(props);

expect(addWrapper.find(Select)).toExist();
expect(addWrapper.find(Select)).toHaveLength(3);
expect(addWrapper.find(Select)).toHaveLength(7);
});

it('renders value input element when in alert mode', async () => {
Expand Down
Loading