1
0
mirror of https://gitlab.nic.cz/turris/reforis/foris-js.git synced 2025-02-22 09:44:18 +01:00

Enhance SubmitButton component to accept a custom label prop and update copyright year

This commit is contained in:
Aleksandr Gumroian 2025-02-19 16:15:15 +01:00
parent c7d0655771
commit 1441f6ff5a
No known key found for this signature in database
GPG Key ID: 9E77849C64F0A733

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/) * Copyright (C) 2019-2025 CZ.NIC z.s.p.o. (https://www.nic.cz/)
* *
* This is free software, licensed under the GNU General Public License v3. * This is free software, licensed under the GNU General Public License v3.
* See /LICENSE for more information. * See /LICENSE for more information.
@ -20,22 +20,25 @@ export const STATES = {
SubmitButton.propTypes = { SubmitButton.propTypes = {
disabled: PropTypes.bool, disabled: PropTypes.bool,
state: PropTypes.oneOf(Object.keys(STATES).map((key) => STATES[key])), state: PropTypes.oneOf(Object.keys(STATES).map((key) => STATES[key])),
label: PropTypes.string,
}; };
export function SubmitButton({ disabled, state, ...props }) { export function SubmitButton({ disabled, state, label, ...props }) {
const disableSubmitButton = disabled || state !== STATES.READY; const disableSubmitButton = disabled || state !== STATES.READY;
const loadingSubmitButton = state !== STATES.READY; const loadingSubmitButton = state !== STATES.READY;
let labelSubmitButton; let labelSubmitButton = label;
switch (state) { if (!labelSubmitButton) {
case STATES.SAVING: switch (state) {
labelSubmitButton = _("Updating"); case STATES.SAVING:
break; labelSubmitButton = _("Updating");
case STATES.LOAD: break;
labelSubmitButton = _("Load settings"); case STATES.LOAD:
break; labelSubmitButton = _("Load settings");
default: break;
labelSubmitButton = _("Save"); default:
labelSubmitButton = _("Save");
}
} }
return ( return (