Re-enable rule line-between-class-members (#10862)

This commit is contained in:
Kamil Gabryjelski
2020-09-15 00:41:32 +02:00
committed by GitHub
parent 91b8c8afc9
commit e28f3d6220
53 changed files with 277 additions and 3 deletions

View File

@@ -83,11 +83,13 @@ class AceEditorWrapper extends React.PureComponent<Props, State> {
};
this.onChange = this.onChange.bind(this);
}
componentDidMount() {
// Making sure no text is selected from previous mount
this.props.actions.queryEditorSetSelectedText(this.props.queryEditor, null);
this.setAutoCompleter(this.props);
}
UNSAFE_componentWillReceiveProps(nextProps: Props) {
if (
!areArraysShallowEqual(this.props.tables, nextProps.tables) ||
@@ -103,12 +105,15 @@ class AceEditorWrapper extends React.PureComponent<Props, State> {
this.setState({ sql: nextProps.sql });
}
}
onBlur() {
this.props.onBlur(this.state.sql);
}
onAltEnter() {
this.props.onBlur(this.state.sql);
}
onEditorLoad(editor: any) {
editor.commands.addCommand({
name: 'runQuery',
@@ -140,10 +145,12 @@ class AceEditorWrapper extends React.PureComponent<Props, State> {
}
});
}
onChange(text: string) {
this.setState({ sql: text });
this.props.onChange(text);
}
getCompletions(
aceEditor: any,
session: any,
@@ -180,6 +187,7 @@ class AceEditorWrapper extends React.PureComponent<Props, State> {
});
callback(null, words);
}
setAutoCompleter(props: Props) {
// Loading schema, table and column names as auto-completable words
const schemas = props.schemas || [];
@@ -236,6 +244,7 @@ class AceEditorWrapper extends React.PureComponent<Props, State> {
}
});
}
getAceAnnotations() {
const { validationResult } = this.props.queryEditor;
const resultIsReady = validationResult && validationResult.completed;
@@ -250,6 +259,7 @@ class AceEditorWrapper extends React.PureComponent<Props, State> {
}
return [];
}
render() {
return (
<AceEditor

View File

@@ -48,12 +48,14 @@ class App extends React.PureComponent {
{ trailing: false },
);
}
componentDidMount() {
/* eslint-disable react/no-did-mount-set-state */
this.setState({ contentHeight: this.getHeight() });
window.addEventListener('hashchange', this.onHashChanged.bind(this));
window.addEventListener('resize', this.handleResize.bind(this));
}
componentDidUpdate() {
if (
this.props.localStorageUsageInKilobytes >=
@@ -64,13 +66,16 @@ class App extends React.PureComponent {
);
}
}
componentWillUnmount() {
window.removeEventListener('hashchange', this.onHashChanged.bind(this));
window.removeEventListener('resize', this.handleResize.bind(this));
}
onHashChanged() {
this.setState({ hash: window.location.hash });
}
getHeight() {
const warningEl = $('#navbar-warning');
const tabsEl = $('.nav-tabs');
@@ -96,6 +101,7 @@ class App extends React.PureComponent {
alertHeight
}px`;
}
showLocalStorageUsageWarning(currentUsage) {
this.props.actions.addDangerToast(
t(
@@ -109,9 +115,11 @@ class App extends React.PureComponent {
),
);
}
handleResize() {
this.setState({ contentHeight: this.getHeight() });
}
render() {
let content;
if (this.state.hash) {

View File

@@ -47,6 +47,7 @@ class ExploreCtasResultsButton extends React.PureComponent {
this.visualize = this.visualize.bind(this);
this.onClick = this.onClick.bind(this);
}
onClick() {
this.visualize();
}
@@ -59,6 +60,7 @@ class ExploreCtasResultsButton extends React.PureComponent {
templateParams: this.props.templateParams,
};
}
visualize() {
this.props.actions
.createCtasDatasource(this.buildVizOptions())
@@ -85,6 +87,7 @@ class ExploreCtasResultsButton extends React.PureComponent {
);
});
}
render() {
return (
<>

View File

@@ -52,6 +52,7 @@ class ExploreResultsButton extends React.PureComponent {
this,
);
}
onClick() {
const { timeout } = this.props;
const msg = this.renderInvalidColumnMessage();
@@ -85,6 +86,7 @@ class ExploreResultsButton extends React.PureComponent {
this.visualize();
}
}
getColumns() {
const { props } = this;
if (
@@ -96,11 +98,13 @@ class ExploreResultsButton extends React.PureComponent {
}
return [];
}
getQueryDuration() {
return moment
.duration(this.props.query.endDttm - this.props.query.startDttm)
.asSeconds();
}
getInvalidColumns() {
const re1 = /__\d+$/; // duplicate column name pattern
const re2 = /^__timestamp/i; // reserved temporal column alias
@@ -109,6 +113,7 @@ class ExploreResultsButton extends React.PureComponent {
.map(col => col.name)
.filter(col => re1.test(col) || re2.test(col));
}
datasourceName() {
const { query } = this.props;
const uniqueId = shortid.generate();
@@ -119,6 +124,7 @@ class ExploreResultsButton extends React.PureComponent {
}
return datasourceName;
}
buildVizOptions() {
const { schema, sql, dbId, templateParams } = this.props.query;
return {
@@ -130,6 +136,7 @@ class ExploreResultsButton extends React.PureComponent {
columns: this.getColumns(),
};
}
visualize() {
this.props.actions
.createDatasource(this.buildVizOptions())
@@ -158,6 +165,7 @@ class ExploreResultsButton extends React.PureComponent {
);
});
}
renderTimeoutWarning() {
return (
<Alert bsStyle="warning">
@@ -181,6 +189,7 @@ class ExploreResultsButton extends React.PureComponent {
</Alert>
);
}
renderInvalidColumnMessage() {
const invalidColumns = this.getInvalidColumns();
if (invalidColumns.length === 0) {
@@ -200,6 +209,7 @@ class ExploreResultsButton extends React.PureComponent {
</div>
);
}
render() {
const allowsSubquery =
this.props.database && this.props.database.allows_subquery;

View File

@@ -50,6 +50,7 @@ class HighlightedSql extends React.Component {
modalBody: null,
};
}
shrinkSql() {
const ssql = this.props.sql || '';
let lines = ssql.split('\n');
@@ -66,6 +67,7 @@ class HighlightedSql extends React.Component {
})
.join('\n');
}
triggerNode() {
const shownSql = this.props.shrink
? this.shrinkSql(this.props.sql)
@@ -76,6 +78,7 @@ class HighlightedSql extends React.Component {
</SyntaxHighlighter>
);
}
generateModal() {
let rawSql;
if (this.props.rawSql && this.props.rawSql !== this.props.sql) {
@@ -100,6 +103,7 @@ class HighlightedSql extends React.Component {
),
});
}
render() {
return (
<ModalTrigger

View File

@@ -36,17 +36,21 @@ class QueryAutoRefresh extends React.PureComponent {
offline: props.offline,
};
}
UNSAFE_componentWillMount() {
this.startTimer();
}
componentDidUpdate(prevProps) {
if (prevProps.offline !== this.state.offline) {
this.props.actions.setUserOffline(this.state.offline);
}
}
componentWillUnmount() {
this.stopTimer();
}
shouldCheckForQueries() {
// if there are started or running queries, this method should return true
const { queries } = this.props;
@@ -58,15 +62,18 @@ class QueryAutoRefresh extends React.PureComponent {
q => isQueryRunning(q) && now - q.startDttm < MAX_QUERY_AGE_TO_POLL,
);
}
startTimer() {
if (!this.timer) {
this.timer = setInterval(this.stopwatch.bind(this), QUERY_UPDATE_FREQ);
}
}
stopTimer() {
clearInterval(this.timer);
this.timer = null;
}
stopwatch() {
// only poll /superset/queries/ if there are started or running queries
if (this.shouldCheckForQueries()) {
@@ -89,6 +96,7 @@ class QueryAutoRefresh extends React.PureComponent {
this.setState({ offline: false });
}
}
render() {
return null;
}

View File

@@ -60,15 +60,19 @@ class QueryTable extends React.PureComponent {
openQueryInNewTab(query) {
this.props.actions.cloneQueryToNewTab(query, true);
}
openAsyncResults(query, displayLimit) {
this.props.actions.fetchQueryResults(query, displayLimit);
}
clearQueryResults(query) {
this.props.actions.clearQueryResults(query);
}
removeQuery(query) {
this.props.actions.removeQuery(query);
}
render() {
const data = this.props.queries
.map(query => {

View File

@@ -86,10 +86,12 @@ export default class ResultSet extends React.PureComponent<
this,
);
}
componentDidMount() {
// only do this the first time the component is rendered/mounted
this.reRunQueryIfSessionTimeoutErrorOnMount();
}
UNSAFE_componentWillReceiveProps(nextProps: ResultSetProps) {
// when new results comes in, save them locally and clear in store
if (
@@ -110,9 +112,11 @@ export default class ResultSet extends React.PureComponent<
this.fetchResults(nextProps.query);
}
}
clearQueryResults(query: Query) {
this.props.actions.clearQueryResults(query);
}
popSelectStar(tempSchema: string | null, tempTable: string) {
const qe = {
id: shortid.generate(),
@@ -123,20 +127,25 @@ export default class ResultSet extends React.PureComponent<
};
this.props.actions.addQueryEditor(qe);
}
toggleExploreResultsButton() {
this.setState({
showExploreResultsButton: !this.state.showExploreResultsButton,
});
}
changeSearch(event: React.ChangeEvent<HTMLInputElement>) {
this.setState({ searchText: event.target.value });
}
fetchResults(query: Query) {
this.props.actions.fetchQueryResults(query, this.props.displayLimit);
}
reFetchQueryResults(query: Query) {
this.props.actions.reFetchQueryResults(query);
}
reRunQueryIfSessionTimeoutErrorOnMount() {
const { query } = this.props;
if (
@@ -146,6 +155,7 @@ export default class ResultSet extends React.PureComponent<
this.props.actions.runQuery(query, true);
}
}
renderControls() {
if (this.props.search || this.props.visualize || this.props.csv) {
let { data } = this.props.query.results;
@@ -198,6 +208,7 @@ export default class ResultSet extends React.PureComponent<
}
return <div className="noControls" />;
}
render() {
const { query } = this.props;
const height = Math.max(

View File

@@ -55,23 +55,29 @@ class SaveQuery extends React.PureComponent {
this.onLabelChange = this.onLabelChange.bind(this);
this.onDescriptionChange = this.onDescriptionChange.bind(this);
}
onSave() {
this.props.onSave(this.queryPayload());
this.close();
}
onUpdate() {
this.props.onUpdate(this.queryPayload());
this.close();
}
onCancel() {
this.close();
}
onLabelChange(e) {
this.setState({ label: e.target.value });
}
onDescriptionChange(e) {
this.setState({ description: e.target.value });
}
queryPayload() {
return {
...this.props.query,
@@ -79,12 +85,15 @@ class SaveQuery extends React.PureComponent {
description: this.state.description,
};
}
close() {
if (this.saveModal) this.saveModal.close();
}
toggleSave() {
this.setState({ showSave: !this.state.showSave });
}
renderModalBody() {
const isSaved = !!this.props.query.remoteId;
return (
@@ -157,6 +166,7 @@ class SaveQuery extends React.PureComponent {
</FormGroup>
);
}
render() {
return (
<span className="SaveQuery">

View File

@@ -106,6 +106,7 @@ class ScheduleQueryButton extends React.PureComponent {
this.onLabelChange = this.onLabelChange.bind(this);
this.onDescriptionChange = this.onDescriptionChange.bind(this);
}
onSchedule({ formData }) {
const query = {
label: this.state.label,
@@ -118,18 +119,23 @@ class ScheduleQueryButton extends React.PureComponent {
this.props.onSchedule(query);
this.saveModal.close();
}
onCancel() {
this.saveModal.close();
}
onLabelChange(e) {
this.setState({ label: e.target.value });
}
onDescriptionChange(e) {
this.setState({ description: e.target.value });
}
toggleSchedule() {
this.setState({ showSchedule: !this.state.showSchedule });
}
renderModalBody() {
return (
<FormGroup>
@@ -181,6 +187,7 @@ class ScheduleQueryButton extends React.PureComponent {
</FormGroup>
);
}
render() {
return (
<span className="ScheduleQueryButton">

View File

@@ -68,19 +68,23 @@ export class SouthPane extends React.PureComponent {
this.getSouthPaneHeight = this.getSouthPaneHeight.bind(this);
this.switchTab = this.switchTab.bind(this);
}
UNSAFE_componentWillReceiveProps() {
// south pane expands the entire height of the tab content on mount
this.setState({ height: this.getSouthPaneHeight() });
}
// One layer of abstraction for easy spying in unit tests
getSouthPaneHeight() {
return this.southPaneRef.current
? this.southPaneRef.current.clientHeight
: 0;
}
switchTab(id) {
this.props.actions.setActiveSouthPaneTab(id);
}
render() {
if (this.props.offline) {
return (

View File

@@ -128,6 +128,7 @@ class SqlEditor extends React.PureComponent {
WINDOW_RESIZE_THROTTLE_MS,
);
}
UNSAFE_componentWillMount() {
if (this.state.autorun) {
this.setState({ autorun: false });
@@ -135,6 +136,7 @@ class SqlEditor extends React.PureComponent {
this.startQuery();
}
}
componentDidMount() {
// We need to measure the height of the sql editor post render to figure the height of
// the south pane so it gets rendered properly
@@ -143,14 +145,17 @@ class SqlEditor extends React.PureComponent {
window.addEventListener('resize', this.handleWindowResize);
}
componentWillUnmount() {
window.removeEventListener('resize', this.handleWindowResize);
}
onResizeStart() {
// Set the heights on the ace editor and the ace content area after drag starts
// to smooth out the visual transition to the new heights when drag ends
document.getElementsByClassName('ace_content')[0].style.height = '100%';
}
onResizeEnd([northPercent, southPercent]) {
this.setState({ northPercent, southPercent });
@@ -162,6 +167,7 @@ class SqlEditor extends React.PureComponent {
);
}
}
onSqlChanged(sql) {
this.setState({ sql });
this.setQueryEditorSqlWithDebounce(sql);
@@ -171,12 +177,14 @@ class SqlEditor extends React.PureComponent {
this.requestValidation();
}
}
// One layer of abstraction for easy spying in unit tests
getSqlEditorHeight() {
return this.sqlEditorRef.current
? this.sqlEditorRef.current.clientHeight - SQL_EDITOR_PADDING * 2
: 0;
}
// Return the heights for the ace editor and the south pane as an object
// given the height of the sql editor, north pane percent and south pane percent.
getAceEditorAndSouthPaneHeights(height, northPercent, southPercent) {
@@ -190,6 +198,7 @@ class SqlEditor extends React.PureComponent {
(SQL_EDITOR_GUTTER_HEIGHT / 2 + SQL_EDITOR_GUTTER_MARGIN),
};
}
getHotkeyConfig() {
return [
{
@@ -224,15 +233,18 @@ class SqlEditor extends React.PureComponent {
},
];
}
setQueryEditorSql(sql) {
this.props.actions.queryEditorSetSql(this.props.queryEditor, sql);
}
setQueryLimit(queryLimit) {
this.props.actions.queryEditorSetQueryLimit(
this.props.queryEditor,
queryLimit,
);
}
getQueryCostEstimate() {
if (this.props.database) {
const qe = this.props.queryEditor;
@@ -246,12 +258,15 @@ class SqlEditor extends React.PureComponent {
this.props.actions.estimateQueryCost(query);
}
}
handleToggleAutocompleteEnabled = () => {
this.setState({ autocompleteEnabled: !this.state.autocompleteEnabled });
};
handleWindowResize() {
this.setState({ height: this.getSqlEditorHeight() });
}
elementStyle(dimension, elementSize, gutterSize) {
return {
[dimension]: `calc(${elementSize}% - ${
@@ -259,6 +274,7 @@ class SqlEditor extends React.PureComponent {
}px)`,
};
}
requestValidation() {
if (this.props.database) {
const qe = this.props.queryEditor;
@@ -272,6 +288,7 @@ class SqlEditor extends React.PureComponent {
this.props.actions.validateQuery(query);
}
}
canValidateQuery() {
// Check whether or not we can validate the current query based on whether
// or not the backend has a validator configured for it.
@@ -281,11 +298,13 @@ class SqlEditor extends React.PureComponent {
}
return false;
}
runQuery() {
if (this.props.database) {
this.startQuery();
}
}
startQuery(ctas = false, ctas_method = CtasEnum.TABLE) {
const qe = this.props.queryEditor;
const query = {
@@ -307,6 +326,7 @@ class SqlEditor extends React.PureComponent {
this.props.actions.runQuery(query);
this.props.actions.setActiveSouthPaneTab('Results');
}
stopQuery() {
if (
this.props.latestQuery &&
@@ -315,15 +335,19 @@ class SqlEditor extends React.PureComponent {
this.props.actions.postStopQuery(this.props.latestQuery);
}
}
createTableAs() {
this.startQuery(true, CtasEnum.TABLE);
}
createViewAs() {
this.startQuery(true, CtasEnum.VIEW);
}
ctasChanged(event) {
this.setState({ ctas: event.target.value });
}
queryPane() {
const hotkeys = this.getHotkeyConfig();
const {
@@ -376,6 +400,7 @@ class SqlEditor extends React.PureComponent {
</Split>
);
}
renderEditorBottomBar(hotkeys) {
let ctasControls;
if (
@@ -560,6 +585,7 @@ class SqlEditor extends React.PureComponent {
</div>
);
}
render() {
return (
<div ref={this.sqlEditorRef} className="SqlEditor">

View File

@@ -50,27 +50,33 @@ export default class SqlEditorLeftBar extends React.PureComponent {
this.getDbList = this.getDbList.bind(this);
this.onTableChange = this.onTableChange.bind(this);
}
onSchemaChange(schema) {
this.props.actions.queryEditorSetSchema(this.props.queryEditor, schema);
}
onSchemasLoad(schemas) {
this.props.actions.queryEditorSetSchemaOptions(
this.props.queryEditor,
schemas,
);
}
onTablesLoad(tables) {
this.props.actions.queryEditorSetTableOptions(
this.props.queryEditor,
tables,
);
}
onDbChange(db) {
this.props.actions.queryEditorSetDb(this.props.queryEditor, db.id);
}
onTableChange(tableName, schemaName) {
this.props.actions.addTable(this.props.queryEditor, tableName, schemaName);
}
getDbList(dbs) {
this.props.actions.setDatabases(dbs);
}
@@ -92,6 +98,7 @@ export default class SqlEditorLeftBar extends React.PureComponent {
resetState() {
this.props.actions.resetState();
}
changeTable(tableOpt) {
if (!tableOpt) {
return;
@@ -105,6 +112,7 @@ export default class SqlEditorLeftBar extends React.PureComponent {
closePopover(ref) {
this.refs[ref].hide();
}
render() {
const shouldShowReset = window.location.search === '?reset=1';
const tableMetaDataHeight = this.props.height - 130; // 130 is the height of the selects above

View File

@@ -75,6 +75,7 @@ class TabbedSqlEditors extends React.PureComponent {
);
this.duplicateQueryEditor = this.duplicateQueryEditor.bind(this);
}
componentDidMount() {
// migrate query editor and associated tables state to server
if (isFeatureEnabled(FeatureFlag.SQLLAB_BACKEND_PERSISTENCE)) {
@@ -168,6 +169,7 @@ class TabbedSqlEditors extends React.PureComponent {
}
}
}
UNSAFE_componentWillReceiveProps(nextProps) {
const nextActiveQeId =
nextProps.tabHistory[nextProps.tabHistory.length - 1];
@@ -201,11 +203,13 @@ class TabbedSqlEditors extends React.PureComponent {
this.setState({ dataPreviewQueries });
}
}
popNewTab() {
queryCount += 1;
// Clean the url in browser history
window.history.replaceState({}, document.title, this.state.sqlLabUrl);
}
renameTab(qe) {
/* eslint no-alert: 0 */
const newTitle = prompt(t('Enter a new title for the tab'));
@@ -213,6 +217,7 @@ class TabbedSqlEditors extends React.PureComponent {
this.props.actions.queryEditorSetTitle(qe, newTitle);
}
}
activeQueryEditor() {
if (this.props.tabHistory.length === 0) {
return this.props.queryEditors[0];
@@ -220,6 +225,7 @@ class TabbedSqlEditors extends React.PureComponent {
const qeid = this.props.tabHistory[this.props.tabHistory.length - 1];
return this.props.queryEditors.find(qe => qe.id === qeid) || null;
}
newQueryEditor() {
queryCount += 1;
const activeQueryEditor = this.activeQueryEditor();
@@ -244,6 +250,7 @@ class TabbedSqlEditors extends React.PureComponent {
};
this.props.actions.addQueryEditor(qe);
}
handleSelect(key) {
if (key === 'add_tab') {
this.newQueryEditor();
@@ -258,20 +265,25 @@ class TabbedSqlEditors extends React.PureComponent {
}
}
}
removeQueryEditor(qe) {
this.props.actions.removeQueryEditor(qe);
}
removeAllOtherQueryEditors(cqe) {
this.props.queryEditors.forEach(
qe => qe !== cqe && this.removeQueryEditor(qe),
);
}
duplicateQueryEditor(qe) {
this.props.actions.cloneQueryToNewTab(qe, false);
}
toggleLeftBar() {
this.setState({ hideLeftBar: !this.state.hideLeftBar });
}
render() {
const editors = this.props.queryEditors.map((qe, i) => {
const isSelected =

View File

@@ -83,6 +83,7 @@ class TableElement extends React.PureComponent {
this.setState({ expanded: false });
this.props.actions.removeDataPreview(this.props.table);
}
toggleSortColumns() {
this.setState({ sortColumns: !this.state.sortColumns });
}
@@ -127,6 +128,7 @@ class TableElement extends React.PureComponent {
}
return header;
}
renderControls() {
let keyLink;
const { table } = this.props;
@@ -190,6 +192,7 @@ class TableElement extends React.PureComponent {
</ButtonGroup>
);
}
renderHeader() {
const { table } = this.props;
return (
@@ -228,6 +231,7 @@ class TableElement extends React.PureComponent {
</div>
);
}
renderBody() {
const { table } = this.props;
let cols;

View File

@@ -56,9 +56,11 @@ export default class TemplateParamsEditor extends React.Component {
};
this.onChange = this.onChange.bind(this);
}
componentDidMount() {
this.onChange(this.state.codeText);
}
onChange(value) {
const codeText = value;
let isValid;
@@ -75,6 +77,7 @@ export default class TemplateParamsEditor extends React.Component {
this.props.onChange(newValue);
}
}
renderDoc() {
return (
<p>
@@ -96,6 +99,7 @@ export default class TemplateParamsEditor extends React.Component {
</p>
);
}
renderModalBody() {
return (
<div>
@@ -115,6 +119,7 @@ export default class TemplateParamsEditor extends React.Component {
</div>
);
}
render() {
const paramCount = this.state.parsedJSON
? Object.keys(this.state.parsedJSON).length