mirror of
https://gitlab.nic.cz/turris/reforis/foris-js.git
synced 2025-06-16 13:46:16 +02:00
Set babel.
This commit is contained in:
49
src/form/components/SubmitButton.js
Normal file
49
src/form/components/SubmitButton.js
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/)
|
||||
*
|
||||
* This is free software, licensed under the GNU General Public License v3.
|
||||
* See /LICENSE for more information.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import Button from 'bootstrap/components/Button';
|
||||
|
||||
export const STATES = {
|
||||
READY: 1,
|
||||
SAVING: 2,
|
||||
LOAD: 3,
|
||||
};
|
||||
|
||||
SubmitButton.propTypes = {
|
||||
disabled: PropTypes.bool,
|
||||
state: PropTypes.oneOf(Object.keys(STATES).map(key => STATES[key]))
|
||||
};
|
||||
|
||||
export default 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');
|
||||
}
|
||||
|
||||
return <Button
|
||||
loading={loadingSubmitButton}
|
||||
disabled={disableSubmitButton}
|
||||
forisFormSize
|
||||
|
||||
{...props}
|
||||
>
|
||||
{labelSubmitButton}
|
||||
</Button>;
|
||||
}
|
Reference in New Issue
Block a user