|
|
|
@ -2,7 +2,17 @@ import { css } from '@emotion/css'; |
|
|
|
|
import { memo } from 'react'; |
|
|
|
|
|
|
|
|
|
import { Action, GrafanaTheme2, httpMethodOptions, HttpRequestMethod, VariableSuggestion } from '@grafana/data'; |
|
|
|
|
import { Switch, Field, InlineField, InlineFieldRow, RadioButtonGroup, JSONFormatter, useStyles2 } from '@grafana/ui'; |
|
|
|
|
import { |
|
|
|
|
Switch, |
|
|
|
|
Field, |
|
|
|
|
InlineField, |
|
|
|
|
InlineFieldRow, |
|
|
|
|
RadioButtonGroup, |
|
|
|
|
JSONFormatter, |
|
|
|
|
useStyles2, |
|
|
|
|
ColorPicker, |
|
|
|
|
useTheme2, |
|
|
|
|
} from '@grafana/ui'; |
|
|
|
|
import { t } from 'app/core/internationalization'; |
|
|
|
|
|
|
|
|
|
import { HTMLElementType, SuggestionsInput } from '../transformers/suggestionsInput/SuggestionsInput'; |
|
|
|
@ -21,6 +31,7 @@ const LABEL_WIDTH = 13; |
|
|
|
|
|
|
|
|
|
export const ActionEditor = memo(({ index, value, onChange, suggestions, showOneClick }: ActionEditorProps) => { |
|
|
|
|
const styles = useStyles2(getStyles); |
|
|
|
|
const theme = useTheme2(); |
|
|
|
|
|
|
|
|
|
const onTitleChange = (title: string) => { |
|
|
|
|
onChange(index, { ...value, title }); |
|
|
|
@ -84,6 +95,16 @@ export const ActionEditor = memo(({ index, value, onChange, suggestions, showOne |
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const onBackgroundColorChange = (backgroundColor: string) => { |
|
|
|
|
onChange(index, { |
|
|
|
|
...value, |
|
|
|
|
style: { |
|
|
|
|
...value.style, |
|
|
|
|
backgroundColor, |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const renderJSON = (data = '{}') => { |
|
|
|
|
try { |
|
|
|
|
const json = JSON.parse(data); |
|
|
|
@ -133,6 +154,19 @@ export const ActionEditor = memo(({ index, value, onChange, suggestions, showOne |
|
|
|
|
/> |
|
|
|
|
</Field> |
|
|
|
|
|
|
|
|
|
<Field label={t('grafana-ui.action-editor.button.style', 'Button style')}> |
|
|
|
|
<InlineField |
|
|
|
|
label={t('actions.action-editor.button.style.background-color', 'Color')} |
|
|
|
|
labelWidth={LABEL_WIDTH} |
|
|
|
|
className={styles.colorPicker} |
|
|
|
|
> |
|
|
|
|
<ColorPicker |
|
|
|
|
color={value?.style?.backgroundColor || theme.colors.secondary.main} |
|
|
|
|
onChange={onBackgroundColorChange} |
|
|
|
|
/> |
|
|
|
|
</InlineField> |
|
|
|
|
</Field> |
|
|
|
|
|
|
|
|
|
{showOneClick && ( |
|
|
|
|
<Field |
|
|
|
|
label={t('grafana-ui.data-link-inline-editor.one-click', 'One click')} |
|
|
|
@ -223,6 +257,10 @@ const getStyles = (theme: GrafanaTheme2) => ({ |
|
|
|
|
inputField: css({ |
|
|
|
|
marginRight: 4, |
|
|
|
|
}), |
|
|
|
|
colorPicker: css({ |
|
|
|
|
display: 'flex', |
|
|
|
|
alignItems: 'center', |
|
|
|
|
}), |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
ActionEditor.displayName = 'ActionEditor'; |
|
|
|
|