fix(ENTESB-11697): Render data testid property in text buttons
Adds data testid to add another item button on form arrays.
Fixes
@@ -2,40 +2,20 @@ import * as React from 'react';
import './TextButton.css';
-export interface ITextButtonProps {
- className?: string;
+export interface ITextButtonProps extends React.HTMLAttributes<HTMLElement> {
linkText?: string;
- onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
- children?: React.ReactNode;
enable?: boolean;
}
-export class TextButton extends React.Component<ITextButtonProps> {
- public render() {
- const enable =
- typeof this.props.enable !== 'undefined' ? this.props.enable : true;
- const className = this.props.className || '';
+export const TextButton: React.FunctionComponent<ITextButtonProps> = ({ className = '', enable = true, linkText, ...props }) => {
+ const innerHtml = linkText ? { __html: linkText } : undefined;
return (
- <>
- {this.props.linkText ? (
<button
type="button"
- onClick={this.props.onClick}
className={`btn btn-link ${className}`}
- dangerouslySetInnerHTML={{ __html: this.props.linkText! }}
+ dangerouslySetInnerHTML={innerHtml}
disabled={!enable}
+ {...props}
/>
- ) : (
- <button
- type="button"
- onClick={this.props.onClick}
- className={`btn btn-link ${className}`}
- disabled={!enable}
- >
- {this.props.children && this.props.children}
- </button>
- )}
- </>
);
}
-}
