-
Notifications
You must be signed in to change notification settings - Fork 3.6k
feat(settings): add loading state to save buttons #11639
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8ddc0f4
d640277
c0dd216
9958294
cacda51
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,12 +19,13 @@ import { useNavigateSettings } from '~/hooks/useNavigateSettings'; | |
import { getSettingsPath } from '~/utils/navigation/getSettingsPath'; | ||
import { H2Title } from 'twenty-ui/display'; | ||
import { Section } from 'twenty-ui/layout'; | ||
import { useState } from 'react'; | ||
|
||
export const SettingsNewObject = () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want this for Field creation as well? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @AMoreaux seems the ticket says Object & Field 🙂 twentyhq/core-team-issues#572 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My bad There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is unnecessary to include it during field creation, as there is no loading time; the experience is immediate. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Field takes time to appear after redirect, maybe we prefer to have a similar experience than object creation and wait for creation completion before redirection. Wdyt @charlesBochet ? |
||
const { t } = useLingui(); | ||
const navigate = useNavigateSettings(); | ||
const { enqueueSnackBar } = useSnackBar(); | ||
|
||
const [isLoading, setIsLoading] = useState(false); | ||
const { createOneObjectMetadataItem } = useCreateOneObjectMetadataItem(); | ||
|
||
const formConfig = useForm<SettingsDataModelObjectAboutFormValues>({ | ||
|
@@ -43,6 +44,7 @@ export const SettingsNewObject = () => { | |
formValues: SettingsDataModelObjectAboutFormValues, | ||
) => { | ||
try { | ||
setIsLoading(true); | ||
const { data: response } = await createOneObjectMetadataItem(formValues); | ||
|
||
navigate( | ||
|
@@ -57,6 +59,8 @@ export const SettingsNewObject = () => { | |
enqueueSnackBar((error as Error).message, { | ||
variant: SnackBarVariant.Error, | ||
}); | ||
} finally { | ||
setIsLoading(false); | ||
} | ||
}; | ||
|
||
|
@@ -79,6 +83,7 @@ export const SettingsNewObject = () => { | |
actionButton={ | ||
<SaveAndCancelButtons | ||
isSaveDisabled={!canSave} | ||
isLoading={isLoading} | ||
isCancelDisabled={isSubmitting} | ||
onCancel={() => navigate(SettingsPath.Objects)} | ||
onSave={formConfig.handleSubmit(handleSave)} | ||
|
Uh oh!
There was an error while loading. Please reload this page.