Skip to content

Commit

Permalink
Re-enable rule line-between-class-members
Browse files Browse the repository at this point in the history
  • Loading branch information
kgabryje committed Sep 14, 2020
1 parent d93b2b9 commit a6ca7b5
Show file tree
Hide file tree
Showing 53 changed files with 277 additions and 3 deletions.
2 changes: 0 additions & 2 deletions superset-frontend/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ module.exports = {
'jsx-a11y/click-events-have-key-events': 0, // re-enable up for discussion
'jsx-a11y/control-has-associated-label': 0, // disabled temporarily
'jsx-a11y/mouse-events-have-key-events': 0, // re-enable up for discussion
'lines-between-class-members': 0, // disabled temporarily
'new-cap': 0,
'no-bitwise': 0,
'no-continue': 0,
Expand Down Expand Up @@ -202,7 +201,6 @@ module.exports = {
'jsx-a11y/click-events-have-key-events': 0, // re-enable up for discussion
'jsx-a11y/control-has-associated-label': 0, // disabled temporarily
'jsx-a11y/mouse-events-have-key-events': 0, // re-enable up for discussion
'lines-between-class-members': 0, // disabled temporarily
'new-cap': 0,
'no-else-return': 0, // disabled temporarily
'no-bitwise': 0,
Expand Down
16 changes: 16 additions & 0 deletions superset-frontend/src/CRUD/CollectionTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,15 @@ export default class CRUDCollection extends React.PureComponent<
this.renderTableBody = this.renderTableBody.bind(this);
this.changeCollection = this.changeCollection.bind(this);
}

UNSAFE_componentWillReceiveProps(nextProps: CRUDCollectionProps) {
if (nextProps.collection !== this.props.collection) {
this.setState({
collection: createKeyedCollection(nextProps.collection),
});
}
}

onCellChange(id: number, col: string, val: boolean) {
this.changeCollection({
...this.state.collection,
Expand All @@ -94,6 +96,7 @@ export default class CRUDCollection extends React.PureComponent<
},
});
}

onAddItem() {
if (this.props.itemGenerator) {
let newItem = this.props.itemGenerator();
Expand All @@ -106,12 +109,14 @@ export default class CRUDCollection extends React.PureComponent<
});
}
}

onFieldsetChange(item: any) {
this.changeCollection({
...this.state.collection,
[item.id]: item,
});
}

getLabel(col: any) {
const { columnLabels } = this.props;
let label = columnLabels && columnLabels[col] ? columnLabels[col] : col;
Expand All @@ -121,24 +126,28 @@ export default class CRUDCollection extends React.PureComponent<
}
return label;
}

changeCollection(collection: any) {
this.setState({ collection });
if (this.props.onChange) {
this.props.onChange(Object.keys(collection).map(k => collection[k]));
}
}

deleteItem(id: number) {
const newColl = { ...this.state.collection };
delete newColl[id];
this.changeCollection(newColl);
}

effectiveTableColumns() {
const { tableColumns, allowDeletes, expandFieldset } = this.props;
const cols = allowDeletes
? tableColumns.concat(['__actions'])
: tableColumns;
return expandFieldset ? ['__expand'].concat(cols) : cols;
}

toggleExpand(id: any) {
this.onCellChange(id, '__expanded', false);
this.setState({
Expand All @@ -148,6 +157,7 @@ export default class CRUDCollection extends React.PureComponent<
},
});
}

renderHeaderRow() {
const cols = this.effectiveTableColumns();
const {
Expand Down Expand Up @@ -176,6 +186,7 @@ export default class CRUDCollection extends React.PureComponent<
</thead>
);
}

renderExpandableSection(item: any) {
const propsGenerator = () => ({ item, onChange: this.onFieldsetChange });
return recurseReactClone(
Expand All @@ -184,12 +195,14 @@ export default class CRUDCollection extends React.PureComponent<
propsGenerator,
);
}

renderCell(record: any, col: any) {
const renderer = this.props.itemRenderers && this.props.itemRenderers[col];
const val = record[col];
const onChange = this.onCellChange.bind(this, record.id, col);
return renderer ? renderer(val, onChange, this.getLabel(col), record) : val;
}

renderItem(record: any) {
const {
allowAddItem,
Expand Down Expand Up @@ -254,13 +267,15 @@ export default class CRUDCollection extends React.PureComponent<
}
return trs;
}

renderEmptyCell() {
return (
<tr>
<td className="empty-collection">{this.props.emptyMessage}</td>
</tr>
);
}

renderTableBody() {
const data = Object.keys(this.state.collection).map(
k => this.state.collection[k],
Expand All @@ -270,6 +285,7 @@ export default class CRUDCollection extends React.PureComponent<
: this.renderEmptyCell();
return <tbody>{content}</tbody>;
}

render() {
return (
<div className="CRUD">
Expand Down
2 changes: 2 additions & 0 deletions superset-frontend/src/CRUD/Field.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ export default class Field extends React.PureComponent {
super(props);
this.onChange = this.onChange.bind(this);
}

onChange(newValue) {
this.props.onChange(this.props.fieldKey, newValue);
}

render() {
const {
compact,
Expand Down
2 changes: 2 additions & 0 deletions superset-frontend/src/CRUD/Fieldset.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ export default class Fieldset extends React.PureComponent {
super(props);
this.onChange = this.onChange.bind(this);
}

onChange(fieldKey, val) {
return this.props.onChange({
...this.props.item,
[fieldKey]: val,
});
}

render() {
const { title } = this.props;
const propExtender = field => ({
Expand Down
10 changes: 10 additions & 0 deletions superset-frontend/src/SqlLab/components/AceEditorWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) ||
Expand All @@ -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',
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 || [];
Expand Down Expand Up @@ -236,6 +244,7 @@ class AceEditorWrapper extends React.PureComponent<Props, State> {
}
});
}

getAceAnnotations() {
const { validationResult } = this.props.queryEditor;
const resultIsReady = validationResult && validationResult.completed;
Expand All @@ -250,6 +259,7 @@ class AceEditorWrapper extends React.PureComponent<Props, State> {
}
return [];
}

render() {
return (
<AceEditor
Expand Down
8 changes: 8 additions & 0 deletions superset-frontend/src/SqlLab/components/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 >=
Expand All @@ -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');
Expand All @@ -96,6 +101,7 @@ class App extends React.PureComponent {
alertHeight
}px`;
}

showLocalStorageUsageWarning(currentUsage) {
this.props.actions.addDangerToast(
t(
Expand All @@ -109,9 +115,11 @@ class App extends React.PureComponent {
),
);
}

handleResize() {
this.setState({ contentHeight: this.getHeight() });
}

render() {
let content;
if (this.state.hash) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class ExploreCtasResultsButton extends React.PureComponent {
this.visualize = this.visualize.bind(this);
this.onClick = this.onClick.bind(this);
}

onClick() {
this.visualize();
}
Expand All @@ -59,6 +60,7 @@ class ExploreCtasResultsButton extends React.PureComponent {
templateParams: this.props.templateParams,
};
}

visualize() {
this.props.actions
.createCtasDatasource(this.buildVizOptions())
Expand All @@ -85,6 +87,7 @@ class ExploreCtasResultsButton extends React.PureComponent {
);
});
}

render() {
return (
<>
Expand Down
10 changes: 10 additions & 0 deletions superset-frontend/src/SqlLab/components/ExploreResultsButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class ExploreResultsButton extends React.PureComponent {
this,
);
}

onClick() {
const { timeout } = this.props;
const msg = this.renderInvalidColumnMessage();
Expand Down Expand Up @@ -85,6 +86,7 @@ class ExploreResultsButton extends React.PureComponent {
this.visualize();
}
}

getColumns() {
const { props } = this;
if (
Expand All @@ -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
Expand All @@ -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();
Expand All @@ -119,6 +124,7 @@ class ExploreResultsButton extends React.PureComponent {
}
return datasourceName;
}

buildVizOptions() {
const { schema, sql, dbId, templateParams } = this.props.query;
return {
Expand All @@ -130,6 +136,7 @@ class ExploreResultsButton extends React.PureComponent {
columns: this.getColumns(),
};
}

visualize() {
this.props.actions
.createDatasource(this.buildVizOptions())
Expand Down Expand Up @@ -158,6 +165,7 @@ class ExploreResultsButton extends React.PureComponent {
);
});
}

renderTimeoutWarning() {
return (
<Alert bsStyle="warning">
Expand All @@ -181,6 +189,7 @@ class ExploreResultsButton extends React.PureComponent {
</Alert>
);
}

renderInvalidColumnMessage() {
const invalidColumns = this.getInvalidColumns();
if (invalidColumns.length === 0) {
Expand All @@ -200,6 +209,7 @@ class ExploreResultsButton extends React.PureComponent {
</div>
);
}

render() {
const allowsSubquery =
this.props.database && this.props.database.allows_subquery;
Expand Down
Loading

0 comments on commit a6ca7b5

Please sign in to comment.