From 1441f6ff5ae4fdae81bfc1cf0ce7f6fbb8b6ee13 Mon Sep 17 00:00:00 2001 From: Aleksandr Gumroian Date: Wed, 19 Feb 2025 16:15:15 +0100 Subject: [PATCH] Enhance SubmitButton component to accept a custom label prop and update copyright year --- src/form/components/SubmitButton.js | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/form/components/SubmitButton.js b/src/form/components/SubmitButton.js index 45d406c..f567569 100644 --- a/src/form/components/SubmitButton.js +++ b/src/form/components/SubmitButton.js @@ -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. * See /LICENSE for more information. @@ -20,22 +20,25 @@ export const STATES = { SubmitButton.propTypes = { disabled: PropTypes.bool, 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 loadingSubmitButton = state !== STATES.READY; - let labelSubmitButton; - switch (state) { - case STATES.SAVING: - labelSubmitButton = _("Updating"); - break; - case STATES.LOAD: - labelSubmitButton = _("Load settings"); - break; - default: - labelSubmitButton = _("Save"); + let labelSubmitButton = label; + if (!labelSubmitButton) { + switch (state) { + case STATES.SAVING: + labelSubmitButton = _("Updating"); + break; + case STATES.LOAD: + labelSubmitButton = _("Load settings"); + break; + default: + labelSubmitButton = _("Save"); + } } return (