ButtonRow.tsx 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import React, { FC } from 'react';
  2. import config from 'app/core/config';
  3. export interface Props {
  4. isReadOnly: boolean;
  5. onDelete: () => void;
  6. onSubmit: (event: any) => void;
  7. onTest: (event: any) => void;
  8. }
  9. const ButtonRow: FC<Props> = ({ isReadOnly, onDelete, onSubmit, onTest }) => {
  10. return (
  11. <div className="gf-form-button-row">
  12. {!isReadOnly && (
  13. <button
  14. type="submit"
  15. className="btn btn-primary"
  16. disabled={isReadOnly}
  17. onClick={event => onSubmit(event)}
  18. aria-label="Save and Test button"
  19. >
  20. Save &amp; Test
  21. </button>
  22. )}
  23. {isReadOnly && (
  24. <button type="submit" className="btn btn-success" onClick={onTest}>
  25. Test
  26. </button>
  27. )}
  28. <button type="submit" className="btn btn-danger" disabled={isReadOnly} onClick={onDelete}>
  29. Delete
  30. </button>
  31. <a className="btn btn-inverse" href={`${config.appSubUrl}/datasources`}>
  32. Back
  33. </a>
  34. </div>
  35. );
  36. };
  37. export default ButtonRow;