refactor: Replace react-bootstrap tabs with Antd tabs (#11090)

* Replace tabs in profile

* Replace tabs in SouthPane

* Replace tabs in TabbedSqlEditors

* Add typing for dropdown

* Add license

* Remove isSelected

* Fixes

* Add data-test

* Fix test

* Remove unnecessary style

* Remove unnecessary style

* Tests fix

* Tests fix

* Update superset-frontend/src/common/components/Dropdown.tsx

Co-authored-by: Evan Rusackas <evan@preset.io>

* Update superset-frontend/src/common/components/Dropdown.tsx

Co-authored-by: Evan Rusackas <evan@preset.io>

* Update superset-frontend/src/common/components/Dropdown.tsx

Co-authored-by: Evan Rusackas <evan@preset.io>

* Update superset-frontend/src/common/components/Dropdown.tsx

Co-authored-by: Evan Rusackas <evan@preset.io>

* Update superset-frontend/src/common/components/Tabs.tsx

Co-authored-by: Evan Rusackas <evan@preset.io>

* Update superset-frontend/src/common/components/Dropdown.tsx

Co-authored-by: Evan Rusackas <evan@preset.io>

* Update superset-frontend/src/common/components/Dropdown.tsx

Co-authored-by: Evan Rusackas <evan@preset.io>

* Remove inModal prop

* Remove inModal from storybook

* Move inline style to styled component

Co-authored-by: Evan Rusackas <evan@preset.io>
This commit is contained in:
Kamil Gabryjelski
2020-10-02 22:07:52 +02:00
committed by GitHub
parent 53cd05d74a
commit 4fd993c4e0
10 changed files with 369 additions and 179 deletions

View File

@@ -20,10 +20,10 @@ import React from 'react';
import configureStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import URI from 'urijs';
import { Tab } from 'react-bootstrap';
import { shallow, mount } from 'enzyme';
import sinon from 'sinon';
import { supersetTheme, ThemeProvider } from '@superset-ui/core';
import { EditableTabs } from 'src/common/components/Tabs';
import TabbedSqlEditors from 'src/SqlLab/components/TabbedSqlEditors';
import SqlEditor from 'src/SqlLab/components/SqlEditor';
@@ -206,36 +206,36 @@ describe('TabbedSqlEditors', () => {
},
};
wrapper = getWrapper();
sinon.spy(wrapper.instance(), 'newQueryEditor');
sinon.stub(wrapper.instance().props.actions, 'switchQueryEditor');
wrapper.instance().handleSelect('add_tab', mockEvent);
expect(wrapper.instance().newQueryEditor.callCount).toBe(1);
// cannot switch to current tab, switchQueryEditor never gets called
wrapper.instance().handleSelect('dfsadfs', mockEvent);
expect(
wrapper.instance().props.actions.switchQueryEditor.callCount,
).toEqual(0);
});
it('should handle add tab', () => {
wrapper = getWrapper();
sinon.spy(wrapper.instance(), 'newQueryEditor');
wrapper.instance().handleEdit('1', 'add');
expect(wrapper.instance().newQueryEditor.callCount).toBe(1);
wrapper.instance().newQueryEditor.restore();
});
it('should render', () => {
wrapper = getWrapper();
wrapper.setState({ hideLeftBar: true });
const firstTab = wrapper.find(Tab).first();
expect(firstTab.props().eventKey).toContain(
const firstTab = wrapper.find(EditableTabs.TabPane).first();
expect(firstTab.props()['data-key']).toContain(
initialState.sqlLab.queryEditors[0].id,
);
expect(firstTab.find(SqlEditor)).toHaveLength(1);
const lastTab = wrapper.find(Tab).last();
expect(lastTab.props().eventKey).toContain('add_tab');
});
it('should disable new tab when offline', () => {
wrapper = getWrapper();
expect(wrapper.find(Tab).last().props().disabled).toBe(false);
expect(wrapper.find(EditableTabs).props().hideAdd).toBe(false);
wrapper.setProps({ offline: true });
expect(wrapper.find(Tab).last().props().disabled).toBe(true);
expect(wrapper.find(EditableTabs).props().hideAdd).toBe(true);
});
});