Importing validators module from superset-ui (#9465)
* importing... this is going to break CI, but there it is. * adding validator package. * pluralization - maybe it should be plural, but whatevs * updating validators to match new exports * removing old validators * lintage ✨ * validateNumeric -> validateNumber * using legacyValidateInteger, legacyValidateNumber * linting ✨ * removing extraneous package lock file
This commit is contained in:
parent
c343c2ff1d
commit
6270f7dc24
|
|
@ -8609,6 +8609,11 @@
|
|||
"jed": "^1.1.1"
|
||||
}
|
||||
},
|
||||
"@superset-ui/validator": {
|
||||
"version": "0.12.13",
|
||||
"resolved": "https://registry.npmjs.org/@superset-ui/validator/-/validator-0.12.13.tgz",
|
||||
"integrity": "sha512-X6GyXP80uJOhHrSUfS5Zf+jhFCLgiil9Md3YuNwArQN2qDK7qBsgb7vfiAhxPfKQfNgvmFeO5SVPZqdcl53aTw=="
|
||||
},
|
||||
"@types/airbnb-prop-types": {
|
||||
"version": "2.13.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/airbnb-prop-types/-/airbnb-prop-types-2.13.1.tgz",
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@
|
|||
"@superset-ui/query": "^0.12.8",
|
||||
"@superset-ui/time-format": "^0.12.10",
|
||||
"@superset-ui/translation": "^0.12.8",
|
||||
"@superset-ui/validator": "^0.12.13",
|
||||
"@types/classnames": "^2.2.9",
|
||||
"@types/react-json-tree": "^0.6.11",
|
||||
"@types/react-select": "^1.2.1",
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import { t } from '@superset-ui/translation';
|
|||
import { SupersetClient } from '@superset-ui/connection';
|
||||
import { getCategoricalSchemeRegistry } from '@superset-ui/color';
|
||||
import { getChartMetadataRegistry } from '@superset-ui/chart';
|
||||
import { validateNonEmpty } from '@superset-ui/validator';
|
||||
|
||||
import SelectControl from './SelectControl';
|
||||
import TextControl from './TextControl';
|
||||
|
|
@ -40,7 +41,6 @@ import ANNOTATION_TYPES, {
|
|||
|
||||
import PopoverSection from '../../../components/PopoverSection';
|
||||
import ControlHeader from '../ControlHeader';
|
||||
import { nonEmpty } from '../../validators';
|
||||
import './AnnotationLayer.less';
|
||||
|
||||
const AUTOMATIC_COLOR = '';
|
||||
|
|
@ -215,14 +215,18 @@ export default class AnnotationLayer extends React.PureComponent {
|
|||
timeColumn,
|
||||
intervalEndColumn,
|
||||
} = this.state;
|
||||
const errors = [nonEmpty(name), nonEmpty(annotationType), nonEmpty(value)];
|
||||
const errors = [
|
||||
validateNonEmpty(name),
|
||||
validateNonEmpty(annotationType),
|
||||
validateNonEmpty(value),
|
||||
];
|
||||
if (sourceType !== ANNOTATION_SOURCE_TYPES.NATIVE) {
|
||||
if (annotationType === ANNOTATION_TYPES.EVENT) {
|
||||
errors.push(nonEmpty(timeColumn));
|
||||
errors.push(validateNonEmpty(timeColumn));
|
||||
}
|
||||
if (annotationType === ANNOTATION_TYPES.INTERVAL) {
|
||||
errors.push(nonEmpty(timeColumn));
|
||||
errors.push(nonEmpty(intervalEndColumn));
|
||||
errors.push(validateNonEmpty(timeColumn));
|
||||
errors.push(validateNonEmpty(intervalEndColumn));
|
||||
}
|
||||
}
|
||||
errors.push(this.isValidFormula(value, annotationType));
|
||||
|
|
|
|||
|
|
@ -19,7 +19,10 @@
|
|||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { FormGroup, FormControl } from 'react-bootstrap';
|
||||
import * as v from '../../validators';
|
||||
import {
|
||||
legacyValidateNumber,
|
||||
legacyValidateInteger,
|
||||
} from '@superset-ui/validator';
|
||||
import ControlHeader from '../ControlHeader';
|
||||
|
||||
const propTypes = {
|
||||
|
|
@ -51,7 +54,7 @@ export default class TextControl extends React.Component {
|
|||
// Validation & casting
|
||||
const errors = [];
|
||||
if (value !== '' && this.props.isFloat) {
|
||||
const error = v.numeric(value);
|
||||
const error = legacyValidateNumber(value);
|
||||
if (error) {
|
||||
errors.push(error);
|
||||
} else {
|
||||
|
|
@ -59,7 +62,7 @@ export default class TextControl extends React.Component {
|
|||
}
|
||||
}
|
||||
if (value !== '' && this.props.isInt) {
|
||||
const error = v.integer(value);
|
||||
const error = legacyValidateInteger(value);
|
||||
if (error) {
|
||||
errors.push(error);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -17,12 +17,12 @@
|
|||
* under the License.
|
||||
*/
|
||||
import { t } from '@superset-ui/translation';
|
||||
import { legacyValidateInteger } from '@superset-ui/validator';
|
||||
import {
|
||||
// formatSelectOptionsForRange,
|
||||
formatSelectOptions,
|
||||
// mainMetric,
|
||||
} from '../../modules/utils';
|
||||
import * as v from '.././validators';
|
||||
import { D3_TIME_FORMAT_OPTIONS, D3_FORMAT_DOCS } from '../controls';
|
||||
|
||||
export default {
|
||||
|
|
@ -85,7 +85,7 @@ export default {
|
|||
type: 'TextControl',
|
||||
isInt: true,
|
||||
default: 10,
|
||||
validators: [v.integer],
|
||||
validators: [legacyValidateInteger],
|
||||
renderTrigger: true,
|
||||
label: t('Cell Size'),
|
||||
description: t('The size of the square cell, in pixels'),
|
||||
|
|
@ -96,7 +96,7 @@ export default {
|
|||
config: {
|
||||
type: 'TextControl',
|
||||
isInt: true,
|
||||
validators: [v.integer],
|
||||
validators: [legacyValidateInteger],
|
||||
renderTrigger: true,
|
||||
default: 2,
|
||||
label: t('Cell Padding'),
|
||||
|
|
@ -110,7 +110,7 @@ export default {
|
|||
config: {
|
||||
type: 'TextControl',
|
||||
isInt: true,
|
||||
validators: [v.integer],
|
||||
validators: [legacyValidateInteger],
|
||||
renderTrigger: true,
|
||||
default: 0,
|
||||
label: t('Cell Radius'),
|
||||
|
|
@ -122,7 +122,7 @@ export default {
|
|||
config: {
|
||||
type: 'TextControl',
|
||||
isInt: true,
|
||||
validators: [v.integer],
|
||||
validators: [legacyValidateInteger],
|
||||
renderTrigger: true,
|
||||
default: 10,
|
||||
label: t('Color Steps'),
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
import { t } from '@superset-ui/translation';
|
||||
import { nonEmpty } from '../validators';
|
||||
import { validateNonEmpty } from '@superset-ui/validator';
|
||||
|
||||
export default {
|
||||
controlPanelSections: [
|
||||
|
|
@ -49,13 +49,13 @@ export default {
|
|||
groupby: {
|
||||
label: t('Source'),
|
||||
multi: false,
|
||||
validators: [nonEmpty],
|
||||
validators: [validateNonEmpty],
|
||||
description: t('Choose a source'),
|
||||
},
|
||||
columns: {
|
||||
label: t('Target'),
|
||||
multi: false,
|
||||
validators: [nonEmpty],
|
||||
validators: [validateNonEmpty],
|
||||
description: t('Choose a target'),
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -17,8 +17,11 @@
|
|||
* under the License.
|
||||
*/
|
||||
import { t } from '@superset-ui/translation';
|
||||
import {
|
||||
validateNonEmpty,
|
||||
legacyValidateInteger,
|
||||
} from '@superset-ui/validator';
|
||||
import timeGrainSqlaAnimationOverrides from './timeGrainSqlaAnimationOverrides';
|
||||
import { nonEmpty, integer } from '../validators';
|
||||
import { columnChoices, PRIMARY_COLOR } from '../controls';
|
||||
import { formatSelectOptions } from '../../modules/utils';
|
||||
import {
|
||||
|
|
@ -47,7 +50,7 @@ export default {
|
|||
config: {
|
||||
type: 'SpatialControl',
|
||||
label: t('Start Longitude & Latitude'),
|
||||
validators: [nonEmpty],
|
||||
validators: [validateNonEmpty],
|
||||
description: t('Point to your spatial columns'),
|
||||
mapStateToProps: state => ({
|
||||
choices: columnChoices(state.datasource),
|
||||
|
|
@ -59,7 +62,7 @@ export default {
|
|||
config: {
|
||||
type: 'SpatialControl',
|
||||
label: t('End Longitude & Latitude'),
|
||||
validators: [nonEmpty],
|
||||
validators: [validateNonEmpty],
|
||||
description: t('Point to your spatial columns'),
|
||||
mapStateToProps: state => ({
|
||||
choices: columnChoices(state.datasource),
|
||||
|
|
@ -112,7 +115,7 @@ export default {
|
|||
type: 'SelectControl',
|
||||
freeForm: true,
|
||||
label: t('Stroke Width'),
|
||||
validators: [integer],
|
||||
validators: [legacyValidateInteger],
|
||||
default: null,
|
||||
renderTrigger: true,
|
||||
choices: formatSelectOptions([1, 2, 3, 4, 5]),
|
||||
|
|
|
|||
|
|
@ -17,7 +17,10 @@
|
|||
* under the License.
|
||||
*/
|
||||
import { t } from '@superset-ui/translation';
|
||||
import { nonEmpty, integer } from '../validators';
|
||||
import {
|
||||
validateNonEmpty,
|
||||
legacyValidateInteger,
|
||||
} from '@superset-ui/validator';
|
||||
import { formatSelectOptions } from '../../modules/utils';
|
||||
import { columnChoices } from '../controls';
|
||||
import {
|
||||
|
|
@ -47,7 +50,7 @@ export default {
|
|||
config: {
|
||||
type: 'SelectControl',
|
||||
label: t('GeoJson Column'),
|
||||
validators: [nonEmpty],
|
||||
validators: [validateNonEmpty],
|
||||
description: t('Select the geojson column'),
|
||||
mapStateToProps: state => ({
|
||||
choices: columnChoices(state.datasource),
|
||||
|
|
@ -80,7 +83,7 @@ export default {
|
|||
type: 'SelectControl',
|
||||
freeForm: true,
|
||||
label: t('Point Radius Scale'),
|
||||
validators: [integer],
|
||||
validators: [legacyValidateInteger],
|
||||
default: null,
|
||||
choices: formatSelectOptions([0, 100, 200, 300, 500]),
|
||||
},
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
import { t } from '@superset-ui/translation';
|
||||
import { nonEmpty } from '../validators';
|
||||
import { validateNonEmpty } from '@superset-ui/validator';
|
||||
import {
|
||||
filterNulls,
|
||||
autozoom,
|
||||
|
|
@ -65,7 +65,7 @@ export default {
|
|||
size: {
|
||||
label: t('Height'),
|
||||
description: t('Metric used to control height'),
|
||||
validators: [nonEmpty],
|
||||
validators: [validateNonEmpty],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
import { t } from '@superset-ui/translation';
|
||||
import { nonEmpty } from '../validators';
|
||||
import { validateNonEmpty } from '@superset-ui/validator';
|
||||
import { viewport } from './Shared_DeckGL';
|
||||
|
||||
export default {
|
||||
|
|
@ -35,7 +35,7 @@ export default {
|
|||
type: 'SelectAsyncControl',
|
||||
multi: true,
|
||||
label: t('deck.gl charts'),
|
||||
validators: [nonEmpty],
|
||||
validators: [validateNonEmpty],
|
||||
default: [],
|
||||
description: t(
|
||||
'Pick a set of deck.gl charts to layer on top of one another',
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@
|
|||
* under the License.
|
||||
*/
|
||||
import { t } from '@superset-ui/translation';
|
||||
import { validateNonEmpty } from '@superset-ui/validator';
|
||||
import timeGrainSqlaAnimationOverrides from './timeGrainSqlaAnimationOverrides';
|
||||
import { nonEmpty } from '../validators';
|
||||
import {
|
||||
filterNulls,
|
||||
autozoom,
|
||||
|
|
@ -99,7 +99,7 @@ export default {
|
|||
type: 'TextControl',
|
||||
label: t('Minimum Radius'),
|
||||
isFloat: true,
|
||||
validators: [nonEmpty],
|
||||
validators: [validateNonEmpty],
|
||||
renderTrigger: true,
|
||||
default: 2,
|
||||
description: t(
|
||||
|
|
@ -114,7 +114,7 @@ export default {
|
|||
type: 'TextControl',
|
||||
label: t('Maximum Radius'),
|
||||
isFloat: true,
|
||||
validators: [nonEmpty],
|
||||
validators: [validateNonEmpty],
|
||||
renderTrigger: true,
|
||||
default: 250,
|
||||
description: t(
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
import { t } from '@superset-ui/translation';
|
||||
import { nonEmpty } from '../validators';
|
||||
import { validateNonEmpty } from '@superset-ui/validator';
|
||||
import timeGrainSqlaAnimationOverrides from './timeGrainSqlaAnimationOverrides';
|
||||
import {
|
||||
filterNulls,
|
||||
|
|
@ -69,7 +69,7 @@ export default {
|
|||
size: {
|
||||
label: t('Weight'),
|
||||
description: t("Metric used as a weight for the grid's coloring"),
|
||||
validators: [nonEmpty],
|
||||
validators: [validateNonEmpty],
|
||||
},
|
||||
time_grain_sqla: timeGrainSqlaAnimationOverrides,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
import { t } from '@superset-ui/translation';
|
||||
import { nonEmpty } from '../validators';
|
||||
import { validateNonEmpty } from '@superset-ui/validator';
|
||||
|
||||
export default {
|
||||
controlPanelSections: [
|
||||
|
|
@ -56,7 +56,7 @@ export default {
|
|||
controlOverrides: {
|
||||
groupby: {
|
||||
label: t('Series'),
|
||||
validators: [nonEmpty],
|
||||
validators: [validateNonEmpty],
|
||||
},
|
||||
columns: {
|
||||
label: t('Breakdowns'),
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
import { t } from '@superset-ui/translation';
|
||||
import { nonEmpty } from '../validators';
|
||||
import { validateNonEmpty } from '@superset-ui/validator';
|
||||
import { formatSelectOptionsForRange } from '../../modules/utils';
|
||||
|
||||
export default {
|
||||
|
|
@ -78,7 +78,7 @@ export default {
|
|||
},
|
||||
all_columns_x: {
|
||||
label: t('Column containing event names'),
|
||||
validators: [nonEmpty],
|
||||
validators: [validateNonEmpty],
|
||||
default: control =>
|
||||
control.choices && control.choices.length > 0
|
||||
? control.choices[0][0]
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
import { t } from '@superset-ui/translation';
|
||||
import { nonEmpty } from '../validators';
|
||||
import { validateNonEmpty } from '@superset-ui/validator';
|
||||
import { formatSelectOptionsForRange } from '../../modules/utils';
|
||||
|
||||
const sortAxisChoices = [
|
||||
|
|
@ -139,10 +139,10 @@ export default {
|
|||
],
|
||||
controlOverrides: {
|
||||
all_columns_x: {
|
||||
validators: [nonEmpty],
|
||||
validators: [validateNonEmpty],
|
||||
},
|
||||
all_columns_y: {
|
||||
validators: [nonEmpty],
|
||||
validators: [validateNonEmpty],
|
||||
},
|
||||
normalized: t(
|
||||
'Whether to apply a normal distribution based on rank on the color scale',
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
import { t } from '@superset-ui/translation';
|
||||
import { nonEmpty } from '../validators';
|
||||
import { validateNonEmpty } from '@superset-ui/validator';
|
||||
|
||||
export default {
|
||||
controlPanelSections: [
|
||||
|
|
@ -48,7 +48,7 @@ export default {
|
|||
label: t('Numeric Columns'),
|
||||
description: t('Select the numeric columns to draw the histogram'),
|
||||
multi: true,
|
||||
validators: [nonEmpty],
|
||||
validators: [validateNonEmpty],
|
||||
},
|
||||
link_length: {
|
||||
label: t('No of Bins'),
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@
|
|||
* under the License.
|
||||
*/
|
||||
import { t } from '@superset-ui/translation';
|
||||
import { validateNonEmpty } from '@superset-ui/validator';
|
||||
import { annotations } from './sections';
|
||||
import { D3_TIME_FORMAT_OPTIONS } from '../controls';
|
||||
import * as v from '../validators';
|
||||
|
||||
export default {
|
||||
requiresTime: true,
|
||||
|
|
@ -65,7 +65,7 @@ export default {
|
|||
type: 'SelectAsyncControl',
|
||||
multi: true,
|
||||
label: t('Left Axis chart(s)'),
|
||||
validators: [v.nonEmpty],
|
||||
validators: [validateNonEmpty],
|
||||
default: [],
|
||||
description: t('Choose one or more charts for left axis'),
|
||||
dataEndpoint:
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@
|
|||
*/
|
||||
import React from 'react';
|
||||
import { t } from '@superset-ui/translation';
|
||||
import { validateNonEmpty } from '@superset-ui/validator';
|
||||
import { NVD3TimeSeries } from './sections';
|
||||
import OptionDescription from '../../components/OptionDescription';
|
||||
import { nonEmpty } from '../validators';
|
||||
|
||||
export default {
|
||||
controlPanelSections: [
|
||||
|
|
@ -35,7 +35,7 @@ export default {
|
|||
config: {
|
||||
type: 'SelectControl',
|
||||
label: t('Options'),
|
||||
validators: [nonEmpty],
|
||||
validators: [validateNonEmpty],
|
||||
default: 'not_time',
|
||||
valueKey: 'value',
|
||||
options: [
|
||||
|
|
|
|||
|
|
@ -21,12 +21,11 @@
|
|||
|
||||
import React from 'react';
|
||||
import { t } from '@superset-ui/translation';
|
||||
import { validateNonEmpty } from '@superset-ui/validator';
|
||||
import ColumnOption from '../../components/ColumnOption';
|
||||
import { D3_FORMAT_OPTIONS, columnChoices, PRIMARY_COLOR } from '../controls';
|
||||
import { DEFAULT_VIEWPORT } from '../../explore/components/controls/ViewportControl';
|
||||
|
||||
import { nonEmpty } from '../validators';
|
||||
|
||||
const timeColumnOption = {
|
||||
verbose_name: 'Time',
|
||||
column_name: '__timestamp',
|
||||
|
|
@ -230,7 +229,7 @@ export const lineColumn = {
|
|||
mapStateToProps: state => ({
|
||||
choices: columnChoices(state.datasource),
|
||||
}),
|
||||
validators: [nonEmpty],
|
||||
validators: [validateNonEmpty],
|
||||
},
|
||||
};
|
||||
|
||||
|
|
@ -336,7 +335,7 @@ export const spatial = {
|
|||
config: {
|
||||
type: 'SpatialControl',
|
||||
label: t('Longitude & Latitude'),
|
||||
validators: [nonEmpty],
|
||||
validators: [validateNonEmpty],
|
||||
description: t('Point to your spatial columns'),
|
||||
mapStateToProps: state => ({
|
||||
choices: columnChoices(state.datasource),
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
import { t } from '@superset-ui/translation';
|
||||
import * as v from '../validators';
|
||||
import { validateNonEmpty } from '@superset-ui/validator';
|
||||
import { D3_TIME_FORMAT_OPTIONS } from '../controls';
|
||||
import { formatSelectOptions } from '../../modules/utils';
|
||||
|
||||
|
|
@ -114,7 +114,7 @@ export default {
|
|||
label: t('Table Timestamp Format'),
|
||||
default: '%Y-%m-%d %H:%M:%S',
|
||||
renderTrigger: true,
|
||||
validators: [v.nonEmpty],
|
||||
validators: [validateNonEmpty],
|
||||
clearable: false,
|
||||
choices: D3_TIME_FORMAT_OPTIONS,
|
||||
description: t('Timestamp Format'),
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
import { t } from '@superset-ui/translation';
|
||||
import { nonEmpty } from '../validators';
|
||||
import { validateNonEmpty } from '@superset-ui/validator';
|
||||
|
||||
export default {
|
||||
controlPanelSections: [
|
||||
|
|
@ -83,7 +83,7 @@ export default {
|
|||
],
|
||||
controlOverrides: {
|
||||
series: {
|
||||
validators: [nonEmpty],
|
||||
validators: [validateNonEmpty],
|
||||
clearable: false,
|
||||
},
|
||||
row_limit: {
|
||||
|
|
|
|||
|
|
@ -62,13 +62,16 @@ import {
|
|||
getCategoricalSchemeRegistry,
|
||||
getSequentialSchemeRegistry,
|
||||
} from '@superset-ui/color';
|
||||
import {
|
||||
legacyValidateInteger,
|
||||
validateNonEmpty,
|
||||
} from '@superset-ui/validator';
|
||||
|
||||
import {
|
||||
formatSelectOptionsForRange,
|
||||
formatSelectOptions,
|
||||
mainMetric,
|
||||
} from '../modules/utils';
|
||||
import * as v from './validators';
|
||||
import ColumnOption from '../components/ColumnOption';
|
||||
import { TIME_FILTER_LABELS } from './constants';
|
||||
|
||||
|
|
@ -153,7 +156,7 @@ const metrics = {
|
|||
type: 'MetricsControl',
|
||||
multi: true,
|
||||
label: t('Metrics'),
|
||||
validators: [v.nonEmpty],
|
||||
validators: [validateNonEmpty],
|
||||
default: c => {
|
||||
const metric = mainMetric(c.savedMetrics);
|
||||
return metric ? [metric] : null;
|
||||
|
|
@ -423,7 +426,7 @@ export const controls = {
|
|||
type: 'SelectControl',
|
||||
label: t('Longitude'),
|
||||
default: 1,
|
||||
validators: [v.nonEmpty],
|
||||
validators: [validateNonEmpty],
|
||||
description: t('Select the longitude column'),
|
||||
mapStateToProps: state => ({
|
||||
choices: columnChoices(state.datasource),
|
||||
|
|
@ -434,7 +437,7 @@ export const controls = {
|
|||
type: 'SelectControl',
|
||||
label: t('Latitude'),
|
||||
default: 1,
|
||||
validators: [v.nonEmpty],
|
||||
validators: [validateNonEmpty],
|
||||
description: t('Select the latitude column'),
|
||||
mapStateToProps: state => ({
|
||||
choices: columnChoices(state.datasource),
|
||||
|
|
@ -444,7 +447,7 @@ export const controls = {
|
|||
polygon: {
|
||||
type: 'SelectControl',
|
||||
label: t('Polygon Column'),
|
||||
validators: [v.nonEmpty],
|
||||
validators: [validateNonEmpty],
|
||||
description: t(
|
||||
'Select the polygon column. Each row should contain JSON.array(N) of [longitude, latitude] points',
|
||||
),
|
||||
|
|
@ -677,7 +680,7 @@ export const controls = {
|
|||
type: 'SelectControl',
|
||||
freeForm: true,
|
||||
label: t('Row limit'),
|
||||
validators: [v.integer],
|
||||
validators: [legacyValidateInteger],
|
||||
default: 10000,
|
||||
choices: formatSelectOptions(ROW_LIMIT_OPTIONS),
|
||||
},
|
||||
|
|
@ -686,7 +689,7 @@ export const controls = {
|
|||
type: 'SelectControl',
|
||||
freeForm: true,
|
||||
label: t('Series limit'),
|
||||
validators: [v.integer],
|
||||
validators: [legacyValidateInteger],
|
||||
choices: formatSelectOptions(SERIES_LIMITS),
|
||||
description: t(
|
||||
'Limits the number of time series that get displayed. A sub query ' +
|
||||
|
|
@ -766,7 +769,7 @@ export const controls = {
|
|||
label: t('Entity'),
|
||||
default: null,
|
||||
multi: false,
|
||||
validators: [v.nonEmpty],
|
||||
validators: [validateNonEmpty],
|
||||
description: t('This defines the element to be plotted on the chart'),
|
||||
},
|
||||
|
||||
|
|
@ -874,7 +877,7 @@ export const controls = {
|
|||
clearable: false,
|
||||
choices: formatSelectOptions(['markdown', 'html']),
|
||||
default: 'markdown',
|
||||
validators: [v.nonEmpty],
|
||||
validators: [validateNonEmpty],
|
||||
description: t('Pick your favorite markup language'),
|
||||
},
|
||||
|
||||
|
|
@ -1225,7 +1228,7 @@ export const controls = {
|
|||
column_collection: {
|
||||
type: 'CollectionControl',
|
||||
label: t('Time Series Columns'),
|
||||
validators: [v.nonEmpty],
|
||||
validators: [validateNonEmpty],
|
||||
controlName: 'TimeSeriesColumnControl',
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -1,51 +0,0 @@
|
|||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
/* Reusable validator functions used in controls definitions
|
||||
*
|
||||
* validator functions receive the v and the configuration of the control
|
||||
* as arguments and return something that evals to false if v is valid,
|
||||
* and an error message if not valid.
|
||||
* */
|
||||
import { t } from '@superset-ui/translation';
|
||||
|
||||
export function numeric(v) {
|
||||
if (v && isNaN(v)) {
|
||||
return t('is expected to be a number');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function integer(v) {
|
||||
if (v && (isNaN(v) || parseInt(v, 10) !== +v)) {
|
||||
return t('is expected to be an integer');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function nonEmpty(v) {
|
||||
if (
|
||||
v === null ||
|
||||
v === undefined ||
|
||||
v === '' ||
|
||||
(Array.isArray(v) && v.length === 0)
|
||||
) {
|
||||
return t('cannot be empty');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
Loading…
Reference in New Issue