mirror of https://github.com/apache/superset.git
Re-enable rule no-else-return (#10861)
This commit is contained in:
parent
76275ec410
commit
2d8f4e3aaf
|
@ -89,7 +89,6 @@ module.exports = {
|
||||||
'new-cap': 0,
|
'new-cap': 0,
|
||||||
'no-bitwise': 0,
|
'no-bitwise': 0,
|
||||||
'no-continue': 0,
|
'no-continue': 0,
|
||||||
'no-else-return': 0, // disabled temporarily
|
|
||||||
'no-mixed-operators': 0,
|
'no-mixed-operators': 0,
|
||||||
'no-multi-assign': 0,
|
'no-multi-assign': 0,
|
||||||
'no-multi-spaces': 0,
|
'no-multi-spaces': 0,
|
||||||
|
@ -203,7 +202,6 @@ module.exports = {
|
||||||
'jsx-a11y/mouse-events-have-key-events': 0, // re-enable up for discussion
|
'jsx-a11y/mouse-events-have-key-events': 0, // re-enable up for discussion
|
||||||
'lines-between-class-members': 0, // disabled temporarily
|
'lines-between-class-members': 0, // disabled temporarily
|
||||||
'new-cap': 0,
|
'new-cap': 0,
|
||||||
'no-else-return': 0, // disabled temporarily
|
|
||||||
'no-bitwise': 0,
|
'no-bitwise': 0,
|
||||||
'no-continue': 0,
|
'no-continue': 0,
|
||||||
'no-mixed-operators': 0,
|
'no-mixed-operators': 0,
|
||||||
|
|
|
@ -61,7 +61,8 @@ class EstimateQueryCostButton extends React.PureComponent {
|
||||||
{this.props.queryCostEstimate.error}
|
{this.props.queryCostEstimate.error}
|
||||||
</Alert>
|
</Alert>
|
||||||
);
|
);
|
||||||
} else if (this.props.queryCostEstimate.completed) {
|
}
|
||||||
|
if (this.props.queryCostEstimate.completed) {
|
||||||
return (
|
return (
|
||||||
<Table
|
<Table
|
||||||
className="table cost-estimate"
|
className="table cost-estimate"
|
||||||
|
|
|
@ -216,7 +216,8 @@ export default class ResultSet extends React.PureComponent<
|
||||||
|
|
||||||
if (query.state === 'stopped') {
|
if (query.state === 'stopped') {
|
||||||
return <Alert bsStyle="warning">Query was stopped</Alert>;
|
return <Alert bsStyle="warning">Query was stopped</Alert>;
|
||||||
} else if (query.state === 'failed') {
|
}
|
||||||
|
if (query.state === 'failed') {
|
||||||
return (
|
return (
|
||||||
<div className="result-set-error-message">
|
<div className="result-set-error-message">
|
||||||
<ErrorMessageWithStackTrace
|
<ErrorMessageWithStackTrace
|
||||||
|
@ -227,7 +228,8 @@ export default class ResultSet extends React.PureComponent<
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
} else if (query.state === 'success' && query.ctas) {
|
}
|
||||||
|
if (query.state === 'success' && query.ctas) {
|
||||||
const { tempSchema, tempTable } = query;
|
const { tempSchema, tempTable } = query;
|
||||||
let object = 'Table';
|
let object = 'Table';
|
||||||
if (query.ctas_method === CtasEnum.VIEW) {
|
if (query.ctas_method === CtasEnum.VIEW) {
|
||||||
|
@ -262,7 +264,8 @@ export default class ResultSet extends React.PureComponent<
|
||||||
</Alert>
|
</Alert>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
} else if (query.state === 'success' && query.results) {
|
}
|
||||||
|
if (query.state === 'success' && query.results) {
|
||||||
const { results } = query;
|
const { results } = query;
|
||||||
let data;
|
let data;
|
||||||
if (this.props.cache && query.cached) {
|
if (this.props.cache && query.cached) {
|
||||||
|
@ -287,7 +290,8 @@ export default class ResultSet extends React.PureComponent<
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
} else if (data && data.length === 0) {
|
}
|
||||||
|
if (data && data.length === 0) {
|
||||||
return (
|
return (
|
||||||
<Alert bsStyle="warning">{t('The query returned no data')}</Alert>
|
<Alert bsStyle="warning">{t('The query returned no data')}</Alert>
|
||||||
);
|
);
|
||||||
|
@ -310,7 +314,8 @@ export default class ResultSet extends React.PureComponent<
|
||||||
{t('Fetch data preview')}
|
{t('Fetch data preview')}
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
} else if (query.resultsKey) {
|
}
|
||||||
|
if (query.resultsKey) {
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
buttonSize="sm"
|
buttonSize="sm"
|
||||||
|
|
|
@ -59,7 +59,8 @@ const RunQueryActionButton = ({
|
||||||
<i className="fa fa-stop" /> {t('Stop')}
|
<i className="fa fa-stop" /> {t('Stop')}
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
} else if (allowAsync) {
|
}
|
||||||
|
if (allowAsync) {
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
{...commonBtnProps}
|
{...commonBtnProps}
|
||||||
|
|
|
@ -238,7 +238,8 @@ class TableElement extends React.PureComponent {
|
||||||
const colB = b.name.toUpperCase();
|
const colB = b.name.toUpperCase();
|
||||||
if (colA < colB) {
|
if (colA < colB) {
|
||||||
return -1;
|
return -1;
|
||||||
} else if (colA > colB) {
|
}
|
||||||
|
if (colA > colB) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -168,7 +168,8 @@ export default function chartReducer(charts = {}, action) {
|
||||||
if (action.type === actions.REMOVE_CHART) {
|
if (action.type === actions.REMOVE_CHART) {
|
||||||
delete charts[action.key];
|
delete charts[action.key];
|
||||||
return charts;
|
return charts;
|
||||||
} else if (action.type === actions.UPDATE_CHART_ID) {
|
}
|
||||||
|
if (action.type === actions.UPDATE_CHART_ID) {
|
||||||
const { newId, key } = action;
|
const { newId, key } = action;
|
||||||
charts[newId] = {
|
charts[newId] = {
|
||||||
...charts[key],
|
...charts[key],
|
||||||
|
|
|
@ -36,7 +36,8 @@ function alterForComparison(value) {
|
||||||
// for this purpose
|
// for this purpose
|
||||||
if (value === undefined || value === null || value === '') {
|
if (value === undefined || value === null || value === '') {
|
||||||
return null;
|
return null;
|
||||||
} else if (typeof value === 'object') {
|
}
|
||||||
|
if (typeof value === 'object') {
|
||||||
if (Array.isArray(value) && value.length === 0) {
|
if (Array.isArray(value) && value.length === 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -100,9 +101,11 @@ export default class AlteredSliceTag extends React.Component {
|
||||||
// or the value type
|
// or the value type
|
||||||
if (value === undefined) {
|
if (value === undefined) {
|
||||||
return 'N/A';
|
return 'N/A';
|
||||||
} else if (value === null) {
|
}
|
||||||
|
if (value === null) {
|
||||||
return 'null';
|
return 'null';
|
||||||
} else if (
|
}
|
||||||
|
if (
|
||||||
this.state.controlsMap[key] &&
|
this.state.controlsMap[key] &&
|
||||||
this.state.controlsMap[key].type === 'AdhocFilterControl'
|
this.state.controlsMap[key].type === 'AdhocFilterControl'
|
||||||
) {
|
) {
|
||||||
|
@ -118,21 +121,26 @@ export default class AlteredSliceTag extends React.Component {
|
||||||
return `${v.subject} ${v.operator} ${filterVal}`;
|
return `${v.subject} ${v.operator} ${filterVal}`;
|
||||||
})
|
})
|
||||||
.join(', ');
|
.join(', ');
|
||||||
} else if (
|
}
|
||||||
|
if (
|
||||||
this.state.controlsMap[key] &&
|
this.state.controlsMap[key] &&
|
||||||
this.state.controlsMap[key].type === 'BoundsControl'
|
this.state.controlsMap[key].type === 'BoundsControl'
|
||||||
) {
|
) {
|
||||||
return `Min: ${value[0]}, Max: ${value[1]}`;
|
return `Min: ${value[0]}, Max: ${value[1]}`;
|
||||||
} else if (
|
}
|
||||||
|
if (
|
||||||
this.state.controlsMap[key] &&
|
this.state.controlsMap[key] &&
|
||||||
this.state.controlsMap[key].type === 'CollectionControl'
|
this.state.controlsMap[key].type === 'CollectionControl'
|
||||||
) {
|
) {
|
||||||
return value.map(v => safeStringify(v)).join(', ');
|
return value.map(v => safeStringify(v)).join(', ');
|
||||||
} else if (typeof value === 'boolean') {
|
}
|
||||||
|
if (typeof value === 'boolean') {
|
||||||
return value ? 'true' : 'false';
|
return value ? 'true' : 'false';
|
||||||
} else if (value.constructor === Array) {
|
}
|
||||||
|
if (value.constructor === Array) {
|
||||||
return value.length ? value.join(', ') : '[]';
|
return value.length ? value.join(', ') : '[]';
|
||||||
} else if (typeof value === 'string' || typeof value === 'number') {
|
}
|
||||||
|
if (typeof value === 'string' || typeof value === 'number') {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
return safeStringify(value);
|
return safeStringify(value);
|
||||||
|
|
|
@ -323,12 +323,15 @@ export default class FilterableTable extends PureComponent<
|
||||||
if (aValue === bValue) {
|
if (aValue === bValue) {
|
||||||
// equal items sort equally
|
// equal items sort equally
|
||||||
return 0;
|
return 0;
|
||||||
} else if (aValue === null) {
|
}
|
||||||
|
if (aValue === null) {
|
||||||
// nulls sort after anything else
|
// nulls sort after anything else
|
||||||
return 1;
|
return 1;
|
||||||
} else if (bValue === null) {
|
}
|
||||||
|
if (bValue === null) {
|
||||||
return -1;
|
return -1;
|
||||||
} else if (descending) {
|
}
|
||||||
|
if (descending) {
|
||||||
return aValue < bValue ? 1 : -1;
|
return aValue < bValue ? 1 : -1;
|
||||||
}
|
}
|
||||||
return aValue < bValue ? -1 : 1;
|
return aValue < bValue ? -1 : 1;
|
||||||
|
|
|
@ -199,7 +199,8 @@ export function Menu({
|
||||||
className="settings-divider"
|
className="settings-divider"
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
} else if (section.isHeader) {
|
}
|
||||||
|
if (section.isHeader) {
|
||||||
return (
|
return (
|
||||||
<MenuItem key={`${section.label}`} disabled>
|
<MenuItem key={`${section.label}`} disabled>
|
||||||
{section.label}
|
{section.label}
|
||||||
|
|
|
@ -57,7 +57,8 @@ export default function MenuObject({
|
||||||
{childs?.map((child: MenuObjectChildProps | string, index1: number) => {
|
{childs?.map((child: MenuObjectChildProps | string, index1: number) => {
|
||||||
if (typeof child === 'string' && child === '-') {
|
if (typeof child === 'string' && child === '-') {
|
||||||
return <MenuItem key={`$${index1}`} divider />;
|
return <MenuItem key={`$${index1}`} divider />;
|
||||||
} else if (typeof child !== 'string') {
|
}
|
||||||
|
if (typeof child !== 'string') {
|
||||||
return (
|
return (
|
||||||
<MenuItem
|
<MenuItem
|
||||||
key={`${child.label}`}
|
key={`${child.label}`}
|
||||||
|
|
|
@ -108,7 +108,8 @@ export default class ModalTrigger extends React.Component {
|
||||||
{this.renderModal()}
|
{this.renderModal()}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
} else if (this.props.isMenuItem) {
|
}
|
||||||
|
if (this.props.isMenuItem) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<MenuItem onClick={this.open}>{this.props.triggerNode}</MenuItem>
|
<MenuItem onClick={this.open}>{this.props.triggerNode}</MenuItem>
|
||||||
|
|
|
@ -54,7 +54,8 @@ function sortByIndicatorLabel(indicator1, indicator2) {
|
||||||
const s2 = (indicator2.label || indicator2.name).toLowerCase();
|
const s2 = (indicator2.label || indicator2.name).toLowerCase();
|
||||||
if (s1 < s2) {
|
if (s1 < s2) {
|
||||||
return -1;
|
return -1;
|
||||||
} else if (s1 > s2) {
|
}
|
||||||
|
if (s1 > s2) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -86,7 +86,7 @@ export default class PublishedStatus extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show the published badge for the owner of the dashboard to toggle
|
// Show the published badge for the owner of the dashboard to toggle
|
||||||
else if (this.props.canEdit && this.props.canSave) {
|
if (this.props.canEdit && this.props.canSave) {
|
||||||
return (
|
return (
|
||||||
<TooltipWrapper
|
<TooltipWrapper
|
||||||
label="Published Dashboard"
|
label="Published Dashboard"
|
||||||
|
|
|
@ -71,7 +71,8 @@ class SliceAdder extends React.Component {
|
||||||
return (a, b) => {
|
return (a, b) => {
|
||||||
if (a[attr] < b[attr]) {
|
if (a[attr] < b[attr]) {
|
||||||
return -1 * desc;
|
return -1 * desc;
|
||||||
} else if (a[attr] > b[attr]) {
|
}
|
||||||
|
if (a[attr] > b[attr]) {
|
||||||
return 1 * desc;
|
return 1 * desc;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -137,7 +137,8 @@ class Markdown extends React.PureComponent {
|
||||||
markdownSource: nextComponent.meta.code,
|
markdownSource: nextComponent.meta.code,
|
||||||
hasError: false,
|
hasError: false,
|
||||||
};
|
};
|
||||||
} else if (
|
}
|
||||||
|
if (
|
||||||
!hasError &&
|
!hasError &&
|
||||||
editorMode === 'preview' &&
|
editorMode === 'preview' &&
|
||||||
nextComponent.meta.code !== markdownSource
|
nextComponent.meta.code !== markdownSource
|
||||||
|
|
|
@ -126,7 +126,8 @@ export default function dashboardFiltersReducer(dashboardFilters = {}, action) {
|
||||||
components: action.components,
|
components: action.components,
|
||||||
});
|
});
|
||||||
return dashboardFilters;
|
return dashboardFilters;
|
||||||
} else if (action.type === UPDATE_DASHBOARD_FILTERS_SCOPE) {
|
}
|
||||||
|
if (action.type === UPDATE_DASHBOARD_FILTERS_SCOPE) {
|
||||||
const allDashboardFiltersScope = action.scopes;
|
const allDashboardFiltersScope = action.scopes;
|
||||||
// update filter scope for each filter field
|
// update filter scope for each filter field
|
||||||
const updatedFilters = Object.entries(allDashboardFiltersScope).reduce(
|
const updatedFilters = Object.entries(allDashboardFiltersScope).reduce(
|
||||||
|
@ -153,14 +154,16 @@ export default function dashboardFiltersReducer(dashboardFilters = {}, action) {
|
||||||
|
|
||||||
buildActiveFilters({ dashboardFilters: updatedFilters });
|
buildActiveFilters({ dashboardFilters: updatedFilters });
|
||||||
return updatedFilters;
|
return updatedFilters;
|
||||||
} else if (action.type === REMOVE_FILTER) {
|
}
|
||||||
|
if (action.type === REMOVE_FILTER) {
|
||||||
const { chartId } = action;
|
const { chartId } = action;
|
||||||
const { [chartId]: deletedFilter, ...updatedFilters } = dashboardFilters;
|
const { [chartId]: deletedFilter, ...updatedFilters } = dashboardFilters;
|
||||||
buildActiveFilters({ dashboardFilters: updatedFilters });
|
buildActiveFilters({ dashboardFilters: updatedFilters });
|
||||||
buildFilterColorMap(updatedFilters);
|
buildFilterColorMap(updatedFilters);
|
||||||
|
|
||||||
return updatedFilters;
|
return updatedFilters;
|
||||||
} else if (action.type in actionHandlers) {
|
}
|
||||||
|
if (action.type in actionHandlers) {
|
||||||
const updatedFilters = {
|
const updatedFilters = {
|
||||||
...dashboardFilters,
|
...dashboardFilters,
|
||||||
[action.chartId]: actionHandlers[action.type](
|
[action.chartId]: actionHandlers[action.type](
|
||||||
|
|
|
@ -65,9 +65,11 @@ export default function getComponentWidthFromDrop({
|
||||||
|
|
||||||
if (Number.isNaN(destinationCapacity) || Number.isNaN(draggingWidth.width)) {
|
if (Number.isNaN(destinationCapacity) || Number.isNaN(draggingWidth.width)) {
|
||||||
return draggingWidth.width;
|
return draggingWidth.width;
|
||||||
} else if (destinationCapacity >= draggingWidth.width) {
|
}
|
||||||
|
if (destinationCapacity >= draggingWidth.width) {
|
||||||
return draggingWidth.width;
|
return draggingWidth.width;
|
||||||
} else if (destinationCapacity >= draggingWidth.minimumWidth) {
|
}
|
||||||
|
if (destinationCapacity >= draggingWidth.minimumWidth) {
|
||||||
return destinationCapacity;
|
return destinationCapacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,8 @@ let cachedIdsLookup = {};
|
||||||
export default function findNonTabChildChartIdsWithCache({ id, layout }) {
|
export default function findNonTabChildChartIdsWithCache({ id, layout }) {
|
||||||
if (cachedLayout === layout && cachedIdsLookup[id]) {
|
if (cachedLayout === layout && cachedIdsLookup[id]) {
|
||||||
return cachedIdsLookup[id];
|
return cachedIdsLookup[id];
|
||||||
} else if (layout !== cachedLayout) {
|
}
|
||||||
|
if (layout !== cachedLayout) {
|
||||||
cachedLayout = layout;
|
cachedLayout = layout;
|
||||||
cachedIdsLookup = {};
|
cachedIdsLookup = {};
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,8 @@ function translateToSql(adhocMetric, { useSimple } = {}) {
|
||||||
return `${subject} ${operator} ${isMulti ? "('" : ''}${comparator}${
|
return `${subject} ${operator} ${isMulti ? "('" : ''}${comparator}${
|
||||||
isMulti ? "')" : ''
|
isMulti ? "')" : ''
|
||||||
}`;
|
}`;
|
||||||
} else if (adhocMetric.expressionType === EXPRESSION_TYPES.SQL) {
|
}
|
||||||
|
if (adhocMetric.expressionType === EXPRESSION_TYPES.SQL) {
|
||||||
return adhocMetric.sqlExpression;
|
return adhocMetric.sqlExpression;
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
|
|
|
@ -95,7 +95,8 @@ export default class AdhocMetric {
|
||||||
return `${this.aggregate || ''}(${
|
return `${this.aggregate || ''}(${
|
||||||
(this.column && this.column.column_name) || ''
|
(this.column && this.column.column_name) || ''
|
||||||
})`;
|
})`;
|
||||||
} else if (this.expressionType === EXPRESSION_TYPES.SQL) {
|
}
|
||||||
|
if (this.expressionType === EXPRESSION_TYPES.SQL) {
|
||||||
return this.sqlExpression;
|
return this.sqlExpression;
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
|
@ -125,7 +126,8 @@ export default class AdhocMetric {
|
||||||
isValid() {
|
isValid() {
|
||||||
if (this.expressionType === EXPRESSION_TYPES.SIMPLE) {
|
if (this.expressionType === EXPRESSION_TYPES.SIMPLE) {
|
||||||
return !!(this.column && this.aggregate);
|
return !!(this.column && this.aggregate);
|
||||||
} else if (this.expressionType === EXPRESSION_TYPES.SQL) {
|
}
|
||||||
|
if (this.expressionType === EXPRESSION_TYPES.SQL) {
|
||||||
return !!this.sqlExpression;
|
return !!this.sqlExpression;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -60,11 +60,14 @@ const defaultProps = {
|
||||||
function translateOperator(operator) {
|
function translateOperator(operator) {
|
||||||
if (operator === OPERATORS['==']) {
|
if (operator === OPERATORS['==']) {
|
||||||
return 'equals';
|
return 'equals';
|
||||||
} else if (operator === OPERATORS['!=']) {
|
}
|
||||||
|
if (operator === OPERATORS['!=']) {
|
||||||
return 'not equal to';
|
return 'not equal to';
|
||||||
} else if (operator === OPERATORS.LIKE) {
|
}
|
||||||
|
if (operator === OPERATORS.LIKE) {
|
||||||
return 'like';
|
return 'like';
|
||||||
} else if (operator === OPERATORS['LATEST PARTITION']) {
|
}
|
||||||
|
if (operator === OPERATORS['LATEST PARTITION']) {
|
||||||
return 'use latest_partition template';
|
return 'use latest_partition template';
|
||||||
}
|
}
|
||||||
return operator;
|
return operator;
|
||||||
|
|
|
@ -142,10 +142,12 @@ class ControlPanelsContainer extends React.Component {
|
||||||
if (!controlItem) {
|
if (!controlItem) {
|
||||||
// When the item is invalid
|
// When the item is invalid
|
||||||
return null;
|
return null;
|
||||||
} else if (React.isValidElement(controlItem)) {
|
}
|
||||||
|
if (React.isValidElement(controlItem)) {
|
||||||
// When the item is a React element
|
// When the item is a React element
|
||||||
return controlItem;
|
return controlItem;
|
||||||
} else if (controlItem.name && controlItem.config) {
|
}
|
||||||
|
if (controlItem.name && controlItem.config) {
|
||||||
return this.renderControl(controlItem);
|
return this.renderControl(controlItem);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -133,9 +133,11 @@ export class DisplayQueryButton extends React.PureComponent {
|
||||||
renderQueryModalBody() {
|
renderQueryModalBody() {
|
||||||
if (this.state.isLoading) {
|
if (this.state.isLoading) {
|
||||||
return <Loading />;
|
return <Loading />;
|
||||||
} else if (this.state.error) {
|
}
|
||||||
|
if (this.state.error) {
|
||||||
return <pre>{this.state.error}</pre>;
|
return <pre>{this.state.error}</pre>;
|
||||||
} else if (this.state.query) {
|
}
|
||||||
|
if (this.state.query) {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<CopyToClipboard
|
<CopyToClipboard
|
||||||
|
@ -158,9 +160,11 @@ export class DisplayQueryButton extends React.PureComponent {
|
||||||
renderResultsModalBody() {
|
renderResultsModalBody() {
|
||||||
if (this.state.isLoading) {
|
if (this.state.isLoading) {
|
||||||
return <Loading />;
|
return <Loading />;
|
||||||
} else if (this.state.error) {
|
}
|
||||||
|
if (this.state.error) {
|
||||||
return <pre>{this.state.error}</pre>;
|
return <pre>{this.state.error}</pre>;
|
||||||
} else if (this.state.data) {
|
}
|
||||||
|
if (this.state.data) {
|
||||||
if (this.state.data.length === 0) {
|
if (this.state.data.length === 0) {
|
||||||
return 'No data';
|
return 'No data';
|
||||||
}
|
}
|
||||||
|
@ -212,9 +216,11 @@ export class DisplayQueryButton extends React.PureComponent {
|
||||||
renderSamplesModalBody() {
|
renderSamplesModalBody() {
|
||||||
if (this.state.isLoading) {
|
if (this.state.isLoading) {
|
||||||
return <Loading />;
|
return <Loading />;
|
||||||
} else if (this.state.error) {
|
}
|
||||||
|
if (this.state.error) {
|
||||||
return <pre>{this.state.error}</pre>;
|
return <pre>{this.state.error}</pre>;
|
||||||
} else if (this.state.data) {
|
}
|
||||||
|
if (this.state.data) {
|
||||||
return this.renderDataTable(this.state.data);
|
return this.renderDataTable(this.state.data);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -40,9 +40,11 @@ export default function FilterDefinitionOption({ option }) {
|
||||||
<span className="option-label">{option.saved_metric_name}</span>
|
<span className="option-label">{option.saved_metric_name}</span>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
} else if (option.column_name) {
|
}
|
||||||
|
if (option.column_name) {
|
||||||
return <ColumnOption column={option} showType />;
|
return <ColumnOption column={option} showType />;
|
||||||
} else if (option.label) {
|
}
|
||||||
|
if (option.label) {
|
||||||
return <AdhocMetricStaticOption adhocMetric={option} showType />;
|
return <AdhocMetricStaticOption adhocMetric={option} showType />;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,9 +38,11 @@ const propTypes = {
|
||||||
function MetricDefinitionOption({ option, addWarningToast }) {
|
function MetricDefinitionOption({ option, addWarningToast }) {
|
||||||
if (option.metric_name) {
|
if (option.metric_name) {
|
||||||
return <MetricOption metric={option} showType />;
|
return <MetricOption metric={option} showType />;
|
||||||
} else if (option.column_name) {
|
}
|
||||||
|
if (option.column_name) {
|
||||||
return <ColumnOption column={option} showType />;
|
return <ColumnOption column={option} showType />;
|
||||||
} else if (option.aggregate_name) {
|
}
|
||||||
|
if (option.aggregate_name) {
|
||||||
return <AggregateOption aggregate={option} showType />;
|
return <AggregateOption aggregate={option} showType />;
|
||||||
}
|
}
|
||||||
addWarningToast(
|
addWarningToast(
|
||||||
|
|
|
@ -107,26 +107,32 @@ function getDefaultAggregateForColumn(column) {
|
||||||
const { type } = column;
|
const { type } = column;
|
||||||
if (typeof type !== 'string') {
|
if (typeof type !== 'string') {
|
||||||
return AGGREGATES.COUNT;
|
return AGGREGATES.COUNT;
|
||||||
} else if (type === '' || type === 'expression') {
|
}
|
||||||
|
if (type === '' || type === 'expression') {
|
||||||
return AGGREGATES.SUM;
|
return AGGREGATES.SUM;
|
||||||
} else if (
|
}
|
||||||
|
if (
|
||||||
type.match(/.*char.*/i) ||
|
type.match(/.*char.*/i) ||
|
||||||
type.match(/string.*/i) ||
|
type.match(/string.*/i) ||
|
||||||
type.match(/.*text.*/i)
|
type.match(/.*text.*/i)
|
||||||
) {
|
) {
|
||||||
return AGGREGATES.COUNT_DISTINCT;
|
return AGGREGATES.COUNT_DISTINCT;
|
||||||
} else if (
|
}
|
||||||
|
if (
|
||||||
type.match(/.*int.*/i) ||
|
type.match(/.*int.*/i) ||
|
||||||
type === 'LONG' ||
|
type === 'LONG' ||
|
||||||
type === 'DOUBLE' ||
|
type === 'DOUBLE' ||
|
||||||
type === 'FLOAT'
|
type === 'FLOAT'
|
||||||
) {
|
) {
|
||||||
return AGGREGATES.SUM;
|
return AGGREGATES.SUM;
|
||||||
} else if (type.match(/.*bool.*/i)) {
|
}
|
||||||
|
if (type.match(/.*bool.*/i)) {
|
||||||
return AGGREGATES.MAX;
|
return AGGREGATES.MAX;
|
||||||
} else if (type.match(/.*time.*/i)) {
|
}
|
||||||
|
if (type.match(/.*time.*/i)) {
|
||||||
return AGGREGATES.COUNT;
|
return AGGREGATES.COUNT;
|
||||||
} else if (type.match(/unknown/i)) {
|
}
|
||||||
|
if (type.match(/unknown/i)) {
|
||||||
return AGGREGATES.COUNT;
|
return AGGREGATES.COUNT;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -119,9 +119,11 @@ export default class SpatialControl extends React.Component {
|
||||||
}
|
}
|
||||||
if (this.state.type === spatialTypes.latlong) {
|
if (this.state.type === spatialTypes.latlong) {
|
||||||
return `${this.state.lonCol} | ${this.state.latCol}`;
|
return `${this.state.lonCol} | ${this.state.latCol}`;
|
||||||
} else if (this.state.type === spatialTypes.delimited) {
|
}
|
||||||
|
if (this.state.type === spatialTypes.delimited) {
|
||||||
return `${this.state.lonlatCol}`;
|
return `${this.state.lonlatCol}`;
|
||||||
} else if (this.state.type === spatialTypes.geohash) {
|
}
|
||||||
|
if (this.state.type === spatialTypes.geohash) {
|
||||||
return `${this.state.geohashCol}`;
|
return `${this.state.geohashCol}`;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -100,7 +100,8 @@ function handleMissingChoice(control) {
|
||||||
if (control.multi && value.length > 0) {
|
if (control.multi && value.length > 0) {
|
||||||
alteredControl.value = value.filter(el => choiceValues.indexOf(el) > -1);
|
alteredControl.value = value.filter(el => choiceValues.indexOf(el) > -1);
|
||||||
return alteredControl;
|
return alteredControl;
|
||||||
} else if (!control.multi && choiceValues.indexOf(value) < 0) {
|
}
|
||||||
|
if (!control.multi && choiceValues.indexOf(value) < 0) {
|
||||||
alteredControl.value = null;
|
alteredControl.value = null;
|
||||||
return alteredControl;
|
return alteredControl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,13 +93,17 @@ export function supersetURL(rootUrl, getParams = {}) {
|
||||||
export function optionLabel(opt) {
|
export function optionLabel(opt) {
|
||||||
if (opt === null) {
|
if (opt === null) {
|
||||||
return NULL_STRING;
|
return NULL_STRING;
|
||||||
} else if (opt === '') {
|
}
|
||||||
|
if (opt === '') {
|
||||||
return '<empty string>';
|
return '<empty string>';
|
||||||
} else if (opt === true) {
|
}
|
||||||
|
if (opt === true) {
|
||||||
return '<true>';
|
return '<true>';
|
||||||
} else if (opt === false) {
|
}
|
||||||
|
if (opt === false) {
|
||||||
return '<false>';
|
return '<false>';
|
||||||
} else if (typeof opt !== 'string' && opt.toString) {
|
}
|
||||||
|
if (typeof opt !== 'string' && opt.toString) {
|
||||||
return opt.toString();
|
return opt.toString();
|
||||||
}
|
}
|
||||||
return opt;
|
return opt;
|
||||||
|
|
|
@ -539,13 +539,15 @@ const DatasetList: FunctionComponent<DatasetListProps> = ({
|
||||||
|
|
||||||
if (!selected.length) {
|
if (!selected.length) {
|
||||||
return t('0 Selected');
|
return t('0 Selected');
|
||||||
} else if (virtualCount && !physicalCount) {
|
}
|
||||||
|
if (virtualCount && !physicalCount) {
|
||||||
return t(
|
return t(
|
||||||
'%s Selected (Virtual)',
|
'%s Selected (Virtual)',
|
||||||
selected.length,
|
selected.length,
|
||||||
virtualCount,
|
virtualCount,
|
||||||
);
|
);
|
||||||
} else if (physicalCount && !virtualCount) {
|
}
|
||||||
|
if (physicalCount && !virtualCount) {
|
||||||
return t(
|
return t(
|
||||||
'%s Selected (Physical)',
|
'%s Selected (Physical)',
|
||||||
selected.length,
|
selected.length,
|
||||||
|
|
|
@ -43,9 +43,11 @@ function colorFromBounds(value, bounds, colorBounds = ACCESSIBLE_COLOR_BOUNDS) {
|
||||||
.domain([min, (max + min) / 2, max])
|
.domain([min, (max + min) / 2, max])
|
||||||
.range([minColor, 'grey', maxColor]);
|
.range([minColor, 'grey', maxColor]);
|
||||||
return colorScale(value);
|
return colorScale(value);
|
||||||
} else if (min !== null) {
|
}
|
||||||
|
if (min !== null) {
|
||||||
return value >= min ? maxColor : minColor;
|
return value >= min ? maxColor : minColor;
|
||||||
} else if (max !== null) {
|
}
|
||||||
|
if (max !== null) {
|
||||||
return value < max ? maxColor : minColor;
|
return value < max ? maxColor : minColor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue