mirror of
https://github.com/apache/superset.git
synced 2026-04-17 15:15:20 +00:00
[explorev2] adding support for client side validators on controls (#1920)
* Adding support for client side validators on controls * Applying validators to more fields * Addressing comments
This commit is contained in:
committed by
GitHub
parent
fc74fbeeaa
commit
470a6e9d76
@@ -0,0 +1,48 @@
|
||||
import React, { PropTypes } from 'react';
|
||||
import { ControlLabel, OverlayTrigger, Tooltip } from 'react-bootstrap';
|
||||
import InfoTooltipWithTrigger from '../../components/InfoTooltipWithTrigger';
|
||||
|
||||
const propTypes = {
|
||||
label: PropTypes.string.isRequired,
|
||||
description: PropTypes.string,
|
||||
validationErrors: PropTypes.array,
|
||||
};
|
||||
|
||||
const defaultProps = {
|
||||
description: null,
|
||||
validationErrors: [],
|
||||
};
|
||||
|
||||
export default function ControlHeader({ label, description, validationErrors }) {
|
||||
const hasError = (validationErrors.length > 0);
|
||||
return (
|
||||
<ControlLabel>
|
||||
{hasError ?
|
||||
<strong className="text-danger">{label}</strong> :
|
||||
<span>{label}</span>
|
||||
}
|
||||
{' '}
|
||||
{(validationErrors.length > 0) &&
|
||||
<span>
|
||||
<OverlayTrigger
|
||||
placement="right"
|
||||
overlay={
|
||||
<Tooltip id={'error-tooltip'}>
|
||||
{validationErrors.join(' ')}
|
||||
</Tooltip>
|
||||
}
|
||||
>
|
||||
<i className="fa fa-exclamation-circle text-danger" />
|
||||
</OverlayTrigger>
|
||||
{' '}
|
||||
</span>
|
||||
}
|
||||
{description &&
|
||||
<InfoTooltipWithTrigger label={label} tooltip={description} />
|
||||
}
|
||||
</ControlLabel>
|
||||
);
|
||||
}
|
||||
|
||||
ControlHeader.propTypes = propTypes;
|
||||
ControlHeader.defaultProps = defaultProps;
|
||||
Reference in New Issue
Block a user