annotations editor menu should not appear if annotations are disabled (#42068)

This commit is contained in:
Victor Marin 2021-11-23 14:16:11 +02:00 committed by GitHub
parent 035e676cad
commit 410044fa05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -71,39 +71,45 @@ export const TimeSeriesPanel: React.FC<TimeSeriesPanelProps> = ({
<AnnotationsPlugin annotations={data.annotations} config={config} timeZone={timeZone} /> <AnnotationsPlugin annotations={data.annotations} config={config} timeZone={timeZone} />
)} )}
{/* Enables annotations creation*/} {/* Enables annotations creation*/}
<AnnotationEditorPlugin data={alignedDataFrame} timeZone={timeZone} config={config}> {enableAnnotationCreation ? (
{({ startAnnotating }) => { <AnnotationEditorPlugin data={alignedDataFrame} timeZone={timeZone} config={config}>
return ( {({ startAnnotating }) => {
<ContextMenuPlugin return (
data={alignedDataFrame} <ContextMenuPlugin
config={config} data={alignedDataFrame}
timeZone={timeZone} config={config}
replaceVariables={replaceVariables} timeZone={timeZone}
defaultItems={ replaceVariables={replaceVariables}
enableAnnotationCreation defaultItems={[
? [ {
items: [
{ {
items: [ label: 'Add annotation',
{ ariaLabel: 'Add annotation',
label: 'Add annotation', icon: 'comment-alt',
ariaLabel: 'Add annotation', onClick: (e, p) => {
icon: 'comment-alt', if (!p) {
onClick: (e, p) => { return;
if (!p) { }
return; startAnnotating({ coords: p.coords });
} },
startAnnotating({ coords: p.coords });
},
},
],
}, },
] ],
: [] },
} ]}
/> />
); );
}} }}
</AnnotationEditorPlugin> </AnnotationEditorPlugin>
) : (
<ContextMenuPlugin
data={alignedDataFrame}
config={config}
timeZone={timeZone}
replaceVariables={replaceVariables}
defaultItems={[]}
/>
)}
{data.annotations && ( {data.annotations && (
<ExemplarsPlugin <ExemplarsPlugin
config={config} config={config}