import { css } from '@emotion/css'; import React, { useState } from 'react'; import { GrafanaTheme2 } from '@grafana/data'; import { getBackendSrv, config } from '@grafana/runtime'; import { Button, CodeEditor, Modal, useTheme2 } from '@grafana/ui'; export const CrawlerStartButton = () => { const styles = getStyles(useTheme2()); const [open, setOpen] = useState(false); const [body, setBody] = useState({ mode: 'thumbs', theme: config.theme2.isLight ? 'light' : 'dark', }); const onDismiss = () => setOpen(false); const doStart = () => { getBackendSrv() .post('/api/admin/crawler/start', body) .then((v) => { console.log('GOT', v); onDismiss(); }); }; return ( <> { setBody(JSON.parse(text)); // force JSON? }} /> Start Cancel setOpen(true)} variant="primary"> Start > ); }; const getStyles = (theme: GrafanaTheme2) => { return { wrap: css` border: 2px solid #111; `, }; };