mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 17:05:43 +01:00
Added tests, fixed edit/add users
This commit is contained in:
11
scm-ui/src/components/AddButton.js
Normal file
11
scm-ui/src/components/AddButton.js
Normal file
@@ -0,0 +1,11 @@
|
||||
//@flow
|
||||
import React from "react";
|
||||
import Button, { type ButtonProps } from "./Button";
|
||||
|
||||
class AddButton extends React.Component<ButtonProps> {
|
||||
render() {
|
||||
return <Button type="default" {...this.props} />;
|
||||
}
|
||||
}
|
||||
|
||||
export default AddButton;
|
||||
@@ -1,12 +1,15 @@
|
||||
//@flow
|
||||
import React from "react";
|
||||
import classNames from "classnames";
|
||||
import { Link } from "react-router-dom";
|
||||
|
||||
export type ButtonProps = {
|
||||
label: string,
|
||||
loading?: boolean,
|
||||
disabled?: boolean,
|
||||
action: () => void
|
||||
action?: () => void,
|
||||
link?: string,
|
||||
fullWidth?: boolean
|
||||
};
|
||||
|
||||
type Props = ButtonProps & {
|
||||
@@ -14,18 +17,33 @@ type Props = ButtonProps & {
|
||||
};
|
||||
|
||||
class Button extends React.Component<Props> {
|
||||
render() {
|
||||
const { label, loading, disabled, type, action } = this.props;
|
||||
renderButton = () => {
|
||||
const { label, loading, disabled, type, action, fullWidth } = this.props;
|
||||
const loadingClass = loading ? "is-loading" : "";
|
||||
const fullWidthClass = fullWidth ? "is-fullwidth" : "";
|
||||
return (
|
||||
<button
|
||||
disabled={disabled}
|
||||
onClick={action}
|
||||
className={classNames("button", "is-" + type, loadingClass)}
|
||||
onClick={action ? action : () => {}}
|
||||
className={classNames(
|
||||
"button",
|
||||
"is-" + type,
|
||||
loadingClass,
|
||||
fullWidthClass
|
||||
)}
|
||||
>
|
||||
{label}
|
||||
</button>
|
||||
);
|
||||
};
|
||||
|
||||
render() {
|
||||
const { link } = this.props;
|
||||
if (link) {
|
||||
return <Link to={link}>{this.renderButton()}</Link>;
|
||||
} else {
|
||||
return this.renderButton();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,41 +1,10 @@
|
||||
//@flow
|
||||
import React from "react";
|
||||
import classNames from "classnames";
|
||||
import Button, { type ButtonProps } from "./Button";
|
||||
|
||||
type Props = {
|
||||
value: string,
|
||||
disabled?: boolean,
|
||||
isLoading?: boolean,
|
||||
large?: boolean,
|
||||
fullWidth?: boolean
|
||||
};
|
||||
|
||||
class SubmitButton extends React.Component<Props> {
|
||||
class SubmitButton extends React.Component<ButtonProps> {
|
||||
render() {
|
||||
const { value, large, fullWidth, isLoading, disabled } = this.props;
|
||||
|
||||
const largeClass = large ? "is-large" : "";
|
||||
const fullWidthClass = fullWidth ? "is-fullwidth" : "";
|
||||
const loadingClass = isLoading ? "is-loading" : "";
|
||||
|
||||
return (
|
||||
<div className="field">
|
||||
<div className="control">
|
||||
<button
|
||||
disabled={disabled}
|
||||
className={classNames(
|
||||
"button",
|
||||
"is-link",
|
||||
largeClass,
|
||||
fullWidthClass,
|
||||
loadingClass
|
||||
)}
|
||||
>
|
||||
{value}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
return <Button type="primary" {...this.props} />;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user