chore: Remove actions prop and refactor code in SQL Lab (#22231)

This commit is contained in:
EugeneTorap
2022-12-05 14:12:52 +03:00
committed by GitHub
parent b2d909f529
commit f3bf3ec2ed
15 changed files with 127 additions and 247 deletions

View File

@@ -30,14 +30,9 @@ import {
SQL_TOOLBAR_HEIGHT,
} from 'src/SqlLab/constants';
import AceEditorWrapper from 'src/SqlLab/components/AceEditorWrapper';
import ConnectedSouthPane from 'src/SqlLab/components/SouthPane/state';
import SouthPane from 'src/SqlLab/components/SouthPane';
import SqlEditor from 'src/SqlLab/components/SqlEditor';
import QueryProvider from 'src/views/QueryProvider';
import {
queryEditorSetFunctionNames,
queryEditorSetSelectedText,
queryEditorSetSchemaOptions,
} from 'src/SqlLab/actions/sqlLab';
import waitForComponentToPaint from 'spec/helpers/waitForComponentToPaint';
import {
initialState,
@@ -97,13 +92,6 @@ const setup = (props = {}, store) =>
describe('SqlEditor', () => {
const mockedProps = {
actions: {
queryEditorSetFunctionNames,
queryEditorSetSelectedText,
queryEditorSetSchemaOptions,
addDangerToast: jest.fn(),
removeDataPreview: jest.fn(),
},
queryEditor: initialState.sqlLab.queryEditors[0],
latestQuery: queries[0],
tables: [table],
@@ -238,7 +226,7 @@ describe('SqlEditor', () => {
await waitForComponentToPaint(wrapper);
const totalSize =
parseFloat(wrapper.find(AceEditorWrapper).props().height) +
wrapper.find(ConnectedSouthPane).props().height +
wrapper.find(SouthPane).props().height +
SQL_TOOLBAR_HEIGHT +
SQL_EDITOR_GUTTER_MARGIN * 2 +
SQL_EDITOR_GUTTER_HEIGHT;
@@ -252,7 +240,7 @@ describe('SqlEditor', () => {
await waitForComponentToPaint(wrapper);
const totalSize =
parseFloat(wrapper.find(AceEditorWrapper).props().height) +
wrapper.find(ConnectedSouthPane).props().height +
wrapper.find(SouthPane).props().height +
SQL_TOOLBAR_HEIGHT +
SQL_EDITOR_GUTTER_MARGIN * 2 +
SQL_EDITOR_GUTTER_HEIGHT;

View File

@@ -76,7 +76,7 @@ import { FeatureFlag, isFeatureEnabled } from 'src/featureFlags';
import { EmptyStateBig } from 'src/components/EmptyState';
import { isEmpty } from 'lodash';
import TemplateParamsEditor from '../TemplateParamsEditor';
import ConnectedSouthPane from '../SouthPane/state';
import SouthPane from '../SouthPane';
import SaveQuery from '../SaveQuery';
import ScheduleQueryButton from '../ScheduleQueryButton';
import EstimateQueryCostButton from '../EstimateQueryCostButton';
@@ -135,7 +135,6 @@ const StyledSidebar = styled.div`
`;
const propTypes = {
actions: PropTypes.object.isRequired,
tables: PropTypes.array.isRequired,
queryEditor: PropTypes.object.isRequired,
defaultQueryLimit: PropTypes.number.isRequired,
@@ -146,7 +145,6 @@ const propTypes = {
};
const SqlEditor = ({
actions,
tables,
queryEditor,
defaultQueryLimit,
@@ -617,10 +615,9 @@ const SqlEditor = ({
/>
{renderEditorBottomBar(hotkeys)}
</div>
<ConnectedSouthPane
<SouthPane
queryEditorId={queryEditor.id}
latestQueryId={latestQuery?.id}
actions={actions}
height={southPaneHeight}
displayLimit={displayLimit}
defaultQueryLimit={defaultQueryLimit}