feat(explore): support show annotation label [ID-8] (#17307)

* feat(explore): support always show annotation label

* fix: lint

* fix: lint

* Hopefully appeasing the linter

* fix: lint

* Update superset-frontend/src/explore/components/controls/AnnotationLayerControl/AnnotationLayer.jsx

Co-authored-by: Geido <60598000+geido@users.noreply.github.com>

* change to allow none

* lint

Co-authored-by: Evan Rusackas <evan@preset.io>
Co-authored-by: Geido <60598000+geido@users.noreply.github.com>
This commit is contained in:
Stephen Liu
2021-12-02 15:26:32 +08:00
committed by GitHub
parent 72f3215ffc
commit a3cce5705d
4 changed files with 25 additions and 1 deletions

View File

@@ -58,6 +58,7 @@ const propTypes = {
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
overrides: PropTypes.object,
show: PropTypes.bool,
showLabel: PropTypes.bool,
titleColumn: PropTypes.string,
descriptionColumns: PropTypes.arrayOf(PropTypes.string),
timeColumn: PropTypes.string,
@@ -85,6 +86,7 @@ const defaultProps = {
overrides: {},
colorScheme: 'd3Category10',
show: true,
showLabel: false,
titleColumn: '',
descriptionColumns: [],
timeColumn: '',
@@ -111,6 +113,7 @@ export default class AnnotationLayer extends React.PureComponent {
value,
overrides,
show,
showLabel,
titleColumn,
descriptionColumns,
timeColumn,
@@ -142,6 +145,7 @@ export default class AnnotationLayer extends React.PureComponent {
value,
overrides,
show,
showLabel,
// slice
titleColumn,
descriptionColumns,
@@ -323,6 +327,7 @@ export default class AnnotationLayer extends React.PureComponent {
'value',
'overrides',
'show',
'showLabel',
'titleColumn',
'descriptionColumns',
'timeColumn',
@@ -689,7 +694,8 @@ export default class AnnotationLayer extends React.PureComponent {
}
render() {
const { isNew, name, annotationType, sourceType, show } = this.state;
const { isNew, name, annotationType, sourceType, show, showLabel } =
this.state;
const isValid = this.isValidForm();
const metadata = getChartMetadataRegistry().get(this.props.vizType);
const supportedAnnotationTypes = metadata
@@ -725,6 +731,14 @@ export default class AnnotationLayer extends React.PureComponent {
value={!show}
onChange={v => this.setState({ show: !v })}
/>
<CheckboxControl
name="annotation-label-show"
label={t('Show label')}
value={showLabel}
hovered
description={t('Whether to always show the annotation label')}
onChange={v => this.setState({ showLabel: v })}
/>
<SelectControl
ariaLabel={t('Annotation layer type')}
hovered