mirror of
https://gitlab.nic.cz/turris/reforis/foris-js.git
synced 2025-06-15 13:36:35 +02:00
Set tests.
This commit is contained in:
@ -5,10 +5,10 @@
|
||||
* See /LICENSE for more information.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import React from "react";
|
||||
import PropTypes from "prop-types";
|
||||
|
||||
import {Button} from 'bootstrap/Button';
|
||||
import { Button } from "bootstrap/Button";
|
||||
|
||||
export const STATES = {
|
||||
READY: 1,
|
||||
@ -18,32 +18,34 @@ export const STATES = {
|
||||
|
||||
SubmitButton.propTypes = {
|
||||
disabled: PropTypes.bool,
|
||||
state: PropTypes.oneOf(Object.keys(STATES).map(key => STATES[key]))
|
||||
state: PropTypes.oneOf(Object.keys(STATES).map((key) => STATES[key])),
|
||||
};
|
||||
|
||||
export function SubmitButton({disabled, state, ...props}) {
|
||||
export function SubmitButton({ disabled, state, ...props }) {
|
||||
const disableSubmitButton = disabled || state !== STATES.READY;
|
||||
const loadingSubmitButton = state !== STATES.READY;
|
||||
|
||||
let labelSubmitButton;
|
||||
switch (state) {
|
||||
case STATES.SAVING:
|
||||
labelSubmitButton = _('Updating');
|
||||
break;
|
||||
case STATES.LOAD:
|
||||
labelSubmitButton = _('Load settings');
|
||||
break;
|
||||
default:
|
||||
labelSubmitButton = _('Save');
|
||||
case STATES.SAVING:
|
||||
labelSubmitButton = _("Updating");
|
||||
break;
|
||||
case STATES.LOAD:
|
||||
labelSubmitButton = _("Load settings");
|
||||
break;
|
||||
default:
|
||||
labelSubmitButton = _("Save");
|
||||
}
|
||||
|
||||
return <Button
|
||||
loading={loadingSubmitButton}
|
||||
disabled={disableSubmitButton}
|
||||
forisFormSize
|
||||
return (
|
||||
<Button
|
||||
loading={loadingSubmitButton}
|
||||
disabled={disableSubmitButton}
|
||||
forisFormSize
|
||||
|
||||
{...props}
|
||||
>
|
||||
{labelSubmitButton}
|
||||
</Button>;
|
||||
{...props}
|
||||
>
|
||||
{labelSubmitButton}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user