ButtonRow.tsx 888 B

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