The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/public/app/features/actions/ActionEditorModalContent.tsx

55 lines
1.5 KiB

import { useState } from 'react';
import { Action, DataFrame, VariableSuggestion } from '@grafana/data';
import { Trans } from '@grafana/i18n';
import { Button, Modal } from '@grafana/ui';
import { ActionEditor } from './ActionEditor';
interface ActionEditorModalContentProps {
action: Action;
index: number;
data: DataFrame[];
onSave: (index: number, action: Action) => void;
onCancel: (index: number) => void;
getSuggestions: () => VariableSuggestion[];
showOneClick: boolean;
}
export const ActionEditorModalContent = ({
action,
index,
onSave,
onCancel,
getSuggestions,
showOneClick,
}: ActionEditorModalContentProps) => {
const [dirtyAction, setDirtyAction] = useState(action);
return (
<>
<ActionEditor
value={dirtyAction}
index={index}
onChange={(index, action) => {
setDirtyAction(action);
}}
suggestions={getSuggestions()}
showOneClick={showOneClick}
/>
<Modal.ButtonRow>
<Button variant="secondary" onClick={() => onCancel(index)} fill="outline">
<Trans i18nKey="action-editor.modal.cancel-button">Cancel</Trans>
</Button>
<Button
onClick={() => {
onSave(index, dirtyAction);
}}
disabled={dirtyAction.title.trim() === '' || dirtyAction.fetch.url.trim() === ''}
>
<Trans i18nKey="action-editor.modal.save-button">Save</Trans>
</Button>
</Modal.ButtonRow>
</>
);
};