mirror of https://github.com/grafana/grafana
AzureMonitor: Create read-only React view for Insights Analytics (#33719)
* AzureMonitor: Create read-only React view for Insights Analytics * Fix spacingpull/33433/head
parent
e58aca2d20
commit
8333c55bee
@ -0,0 +1,49 @@ |
||||
import { Alert, CodeEditor, Select } from '@grafana/ui'; |
||||
import React from 'react'; |
||||
import { AzureMonitorOption, AzureMonitorQuery, AzureResultFormat } from '../../types'; |
||||
import { findOption } from '../../utils/common'; |
||||
import { Field } from '../Field'; |
||||
import { Space } from '../Space'; |
||||
|
||||
interface InsightsAnalyticsEditorProps { |
||||
query: AzureMonitorQuery; |
||||
} |
||||
|
||||
const FORMAT_OPTIONS: Array<AzureMonitorOption<AzureResultFormat>> = [ |
||||
{ label: 'Time series', value: 'time_series' }, |
||||
{ label: 'Table', value: 'table' }, |
||||
]; |
||||
|
||||
const InsightsAnalyticsEditor: React.FC<InsightsAnalyticsEditorProps> = ({ query }) => { |
||||
return ( |
||||
<div data-testid="azure-monitor-insights-analytics-query-editor"> |
||||
<CodeEditor |
||||
language="kusto" |
||||
value={query.insightsAnalytics.query} |
||||
height={200} |
||||
width="100%" |
||||
readOnly={true} |
||||
showMiniMap={false} |
||||
/> |
||||
|
||||
<Field label="Format as"> |
||||
<Select |
||||
inputId="azure-monitor-logs-workspaces-field" |
||||
value={findOption(FORMAT_OPTIONS, query.insightsAnalytics.resultFormat)} |
||||
disabled={true} |
||||
options={FORMAT_OPTIONS} |
||||
onChange={() => {}} |
||||
width={38} |
||||
/> |
||||
</Field> |
||||
|
||||
<Space v={2} /> |
||||
|
||||
<Alert severity="info" title="Deprecated"> |
||||
Insights Analytics is deprecated and is now read only. Migrate your queries to Logs to make changes. |
||||
</Alert> |
||||
</div> |
||||
); |
||||
}; |
||||
|
||||
export default InsightsAnalyticsEditor; |
@ -0,0 +1,38 @@ |
||||
import React from 'react'; |
||||
import { css, cx } from '@emotion/css'; |
||||
import { GrafanaTheme2 } from '@grafana/data'; |
||||
import { stylesFactory, useTheme2 } from '@grafana/ui'; |
||||
|
||||
export interface SpaceProps { |
||||
v?: number; |
||||
h?: number; |
||||
layout?: 'block' | 'inline'; |
||||
} |
||||
|
||||
export const Space = (props: SpaceProps) => { |
||||
const theme = useTheme2(); |
||||
const styles = getStyles(theme, props); |
||||
|
||||
return <span className={cx(styles.wrapper)} />; |
||||
}; |
||||
|
||||
Space.defaultProps = { |
||||
v: 0, |
||||
h: 0, |
||||
layout: 'block', |
||||
}; |
||||
|
||||
const getStyles = stylesFactory((theme: GrafanaTheme2, props: SpaceProps) => ({ |
||||
wrapper: css([ |
||||
{ |
||||
paddingRight: theme.spacing(props.h ?? 0), |
||||
paddingBottom: theme.spacing(props.v ?? 0), |
||||
}, |
||||
props.layout === 'inline' && { |
||||
display: 'inline-block', |
||||
}, |
||||
props.layout === 'block' && { |
||||
display: 'block', |
||||
}, |
||||
]), |
||||
})); |
Loading…
Reference in new issue