feat(settings): add loading state to save buttons (#11639)

Introduce a loading state to SaveButton and SaveAndCancelButtons
components to enhance user feedback during save operations. Update
SettingsNewObject to manage the loading state while submitting the form.

Fix https://github.com/twentyhq/core-team-issues/issues/572

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
Antoine Moreaux
2025-06-23 22:49:38 +02:00
committed by GitHub
parent d248e536f3
commit 4eb859256c
6 changed files with 45 additions and 27 deletions

View File

@ -11,6 +11,7 @@ const StyledContainer = styled.div`
type SaveAndCancelButtonsProps = {
onSave?: () => void;
isLoading?: boolean;
onCancel?: () => void;
isSaveDisabled?: boolean;
isCancelDisabled?: boolean;
@ -18,6 +19,7 @@ type SaveAndCancelButtonsProps = {
export const SaveAndCancelButtons = ({
onSave,
isLoading,
onCancel,
isSaveDisabled,
isCancelDisabled,
@ -25,7 +27,11 @@ export const SaveAndCancelButtons = ({
return (
<StyledContainer>
<CancelButton onCancel={onCancel} disabled={isCancelDisabled} />
<SaveButton onSave={onSave} disabled={isSaveDisabled} />
<SaveButton
onSave={onSave}
disabled={isSaveDisabled}
isLoading={isLoading}
/>
</StyledContainer>
);
};

View File

@ -1,13 +1,18 @@
import { t } from '@lingui/core/macro';
import { Button } from 'twenty-ui/input';
import { IconDeviceFloppy } from 'twenty-ui/display';
import { Button } from 'twenty-ui/input';
type SaveButtonProps = {
onSave?: () => void;
disabled?: boolean;
isLoading?: boolean;
};
export const SaveButton = ({ onSave, disabled }: SaveButtonProps) => {
export const SaveButton = ({
onSave,
disabled,
isLoading,
}: SaveButtonProps) => {
return (
<Button
title={t`Save`}
@ -18,6 +23,7 @@ export const SaveButton = ({ onSave, disabled }: SaveButtonProps) => {
onClick={onSave}
type="submit"
Icon={IconDeviceFloppy}
isLoading={isLoading}
/>
);
};