2019-01-17 09:27:43 +01:00
|
|
|
import React, { FC } from 'react';
|
2019-12-09 00:14:25 -08:00
|
|
|
import { e2e } from '@grafana/e2e';
|
|
|
|
|
|
2019-03-05 07:35:45 +01:00
|
|
|
import config from 'app/core/config';
|
2018-10-31 13:23:05 +01:00
|
|
|
|
|
|
|
|
export interface Props {
|
|
|
|
|
isReadOnly: boolean;
|
2018-10-31 14:28:16 +01:00
|
|
|
onDelete: () => void;
|
2019-05-02 21:26:30 -07:00
|
|
|
onSubmit: (event: any) => void;
|
|
|
|
|
onTest: (event: any) => void;
|
2018-10-31 13:23:05 +01:00
|
|
|
}
|
|
|
|
|
|
2019-02-12 08:45:21 +01:00
|
|
|
const ButtonRow: FC<Props> = ({ isReadOnly, onDelete, onSubmit, onTest }) => {
|
2018-10-31 13:23:05 +01:00
|
|
|
return (
|
|
|
|
|
<div className="gf-form-button-row">
|
2019-02-12 12:49:40 +01:00
|
|
|
{!isReadOnly && (
|
2019-05-08 16:50:21 +02:00
|
|
|
<button
|
|
|
|
|
type="submit"
|
|
|
|
|
className="btn btn-primary"
|
|
|
|
|
disabled={isReadOnly}
|
|
|
|
|
onClick={event => onSubmit(event)}
|
2019-12-09 00:14:25 -08:00
|
|
|
aria-label={e2e.pages.DataSource.selectors.saveAndTest}
|
2019-05-08 16:50:21 +02:00
|
|
|
>
|
2019-02-12 12:49:40 +01:00
|
|
|
Save & Test
|
|
|
|
|
</button>
|
|
|
|
|
)}
|
2019-02-12 08:45:21 +01:00
|
|
|
{isReadOnly && (
|
|
|
|
|
<button type="submit" className="btn btn-success" onClick={onTest}>
|
|
|
|
|
Test
|
|
|
|
|
</button>
|
|
|
|
|
)}
|
2019-11-08 09:48:33 +01:00
|
|
|
<button
|
2020-01-07 16:48:46 +08:00
|
|
|
type="button"
|
2019-11-08 09:48:33 +01:00
|
|
|
className="btn btn-danger"
|
|
|
|
|
disabled={isReadOnly}
|
|
|
|
|
onClick={onDelete}
|
2019-12-09 00:14:25 -08:00
|
|
|
aria-label={e2e.pages.DataSource.selectors.delete}
|
2019-11-08 09:48:33 +01:00
|
|
|
>
|
2018-10-31 13:23:05 +01:00
|
|
|
Delete
|
|
|
|
|
</button>
|
2019-03-05 07:35:45 +01:00
|
|
|
<a className="btn btn-inverse" href={`${config.appSubUrl}/datasources`}>
|
2018-10-31 13:23:05 +01:00
|
|
|
Back
|
|
|
|
|
</a>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default ButtonRow;
|