mirror of
https://github.com/apache/superset.git
synced 2024-09-14 09:39:47 -04:00
fix: Check if annotation type is supported by the given chart type (#11876)
* Check if annotation type is supported by this kind of chart * Check if annotation type exists
This commit is contained in:
parent
53017e5a35
commit
38d21acff6
@ -118,6 +118,7 @@ export default class AnnotationLayer extends React.PureComponent {
|
||||
descriptionColumns,
|
||||
timeColumn,
|
||||
intervalEndColumn,
|
||||
vizType,
|
||||
} = props;
|
||||
|
||||
// Only allow override whole time_range
|
||||
@ -127,10 +128,19 @@ export default class AnnotationLayer extends React.PureComponent {
|
||||
delete overrides.until;
|
||||
}
|
||||
|
||||
// Check if annotationType is supported by this chart
|
||||
const metadata = getChartMetadataRegistry().get(vizType);
|
||||
const supportedAnnotationTypes = metadata?.supportedAnnotationTypes || [];
|
||||
const validAnnotationType = supportedAnnotationTypes.includes(
|
||||
annotationType,
|
||||
)
|
||||
? annotationType
|
||||
: supportedAnnotationTypes[0];
|
||||
|
||||
this.state = {
|
||||
// base
|
||||
name,
|
||||
annotationType,
|
||||
annotationType: validAnnotationType,
|
||||
sourceType,
|
||||
value,
|
||||
overrides,
|
||||
@ -187,7 +197,7 @@ export default class AnnotationLayer extends React.PureComponent {
|
||||
label: chartMetadata.name,
|
||||
}));
|
||||
// Prepend native source if applicable
|
||||
if (ANNOTATION_TYPES_METADATA[annotationType].supportNativeSource) {
|
||||
if (ANNOTATION_TYPES_METADATA[annotationType]?.supportNativeSource) {
|
||||
sources.unshift(ANNOTATION_SOURCE_TYPES_METADATA.NATIVE);
|
||||
}
|
||||
return sources;
|
||||
@ -724,6 +734,7 @@ export default class AnnotationLayer extends React.PureComponent {
|
||||
options={supportedSourceTypes}
|
||||
value={sourceType}
|
||||
onChange={this.handleAnnotationSourceType}
|
||||
validationErrors={!sourceType ? [t('Mandatory')] : []}
|
||||
/>
|
||||
)}
|
||||
{this.renderValueConfiguration()}
|
||||
|
Loading…
Reference in New Issue
Block a user