Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add form leave confirmation prompts

dominik-zeglenf4baa92f1bb3
diff --git a/saleor/static/dashboard-next/categories/components/CategoryCreatePage/CategoryCreatePage.tsx b/saleor/static/dashboard-next/categories/components/CategoryCreatePage/CategoryCreatePage.tsx
index 68810d1232..d5c3befecf 100644
--- a/saleor/static/dashboard-next/categories/components/CategoryCreatePage/CategoryCreatePage.tsx
+++ b/saleor/static/dashboard-next/categories/components/CategoryCreatePage/CategoryCreatePage.tsx
@@ -43,7 +43,12 @@ export const CategoryCreatePage: React.StatelessComponent<
errors: userErrors,
saveButtonBarState
}) => (
- <Form onSubmit={onSubmit} initial={initialData} errors={userErrors}>
+ <Form
+ onSubmit={onSubmit}
+ initial={initialData}
+ errors={userErrors}
+ confirmLeave
+ >
{({ data, change, errors, submit, hasChanged }) => (
<Container width="md">
<PageHeader title={i18n.t("Add Category")} onBack={onBack} />
diff --git a/saleor/static/dashboard-next/categories/components/CategoryUpdatePage/CategoryUpdatePage.tsx b/saleor/static/dashboard-next/categories/components/CategoryUpdatePage/CategoryUpdatePage.tsx
index 48d8bfc5da..f8f89f4e8b 100644
--- a/saleor/static/dashboard-next/categories/components/CategoryUpdatePage/CategoryUpdatePage.tsx
+++ b/saleor/static/dashboard-next/categories/components/CategoryUpdatePage/CategoryUpdatePage.tsx
@@ -96,7 +96,12 @@ export const CategoryUpdatePage = withStyles(styles, {
seoTitle: ""
};
return (
- <Form onSubmit={onSubmit} initial={initialData} errors={userErrors}>
+ <Form
+ onSubmit={onSubmit}
+ initial={initialData}
+ errors={userErrors}
+ confirmLeave
+ >
{({ data, change, errors, submit, hasChanged }) => (
<Container width="md">
<PageHeader
diff --git a/saleor/static/dashboard-next/collections/components/CollectionDetailsPage/CollectionDetailsPage.tsx b/saleor/static/dashboard-next/collections/components/CollectionDetailsPage/CollectionDetailsPage.tsx
index 1a11c3231a..f9a9cff243 100644
--- a/saleor/static/dashboard-next/collections/components/CollectionDetailsPage/CollectionDetailsPage.tsx
+++ b/saleor/static/dashboard-next/collections/components/CollectionDetailsPage/CollectionDetailsPage.tsx
@@ -78,6 +78,7 @@ const CollectionDetailsPage = withStyles(styles, {
seoTitle: maybe(() => collection.seoTitle)
}}
onSubmit={onSubmit}
+ confirmLeave
>
{({ change, data, errors: formErrors, hasChanged, submit }) => (
<Container width="md">
diff --git a/saleor/static/dashboard-next/customers/components/CustomerCreatePage/CustomerCreatePage.tsx b/saleor/static/dashboard-next/customers/components/CustomerCreatePage/CustomerCreatePage.tsx
index da33a94121..9fbd6099bf 100644
--- a/saleor/static/dashboard-next/customers/components/CustomerCreatePage/CustomerCreatePage.tsx
+++ b/saleor/static/dashboard-next/customers/components/CustomerCreatePage/CustomerCreatePage.tsx
@@ -69,7 +69,12 @@ const CustomerCreatePage = withStyles(styles, { name: "CustomerCreatePage" })(
onBack,
onSubmit
}: CustomerCreatePageProps) => (
- <Form initial={initialForm} onSubmit={onSubmit} errors={errors}>
+ <Form
+ initial={initialForm}
+ onSubmit={onSubmit}
+ errors={errors}
+ confirmLeave
+ >
{({ change, data, errors: formErrors, hasChanged, submit }) => (
<Container width="md">
<PageHeader title={i18n.t("Add customer")} onBack={onBack} />
diff --git a/saleor/static/dashboard-next/customers/components/CustomerDetailsPage/CustomerDetailsPage.tsx b/saleor/static/dashboard-next/customers/components/CustomerDetailsPage/CustomerDetailsPage.tsx
index 929c9781bd..8838cdff77 100644
--- a/saleor/static/dashboard-next/customers/components/CustomerDetailsPage/CustomerDetailsPage.tsx
+++ b/saleor/static/dashboard-next/customers/components/CustomerDetailsPage/CustomerDetailsPage.tsx
@@ -70,6 +70,7 @@ const CustomerDetailsPage = withStyles(styles, { name: "CustomerDetailsPage" })(
note: maybe(() => customer.note)
}}
onSubmit={onSubmit}
+ confirmLeave
>
{({ change, data, errors: formErrors, hasChanged, submit }) => (
<Container width="md">
diff --git a/saleor/static/dashboard-next/productTypes/components/ProductTypeCreatePage/ProductTypeCreatePage.tsx b/saleor/static/dashboard-next/productTypes/components/ProductTypeCreatePage/ProductTypeCreatePage.tsx
index 971a598a18..42b8151d40 100644
--- a/saleor/static/dashboard-next/productTypes/components/ProductTypeCreatePage/ProductTypeCreatePage.tsx
+++ b/saleor/static/dashboard-next/productTypes/components/ProductTypeCreatePage/ProductTypeCreatePage.tsx
@@ -70,7 +70,12 @@ const ProductTypeCreatePage = withStyles(styles, {
weight: 0
};
return (
- <Form errors={errors} initial={formInitialData} onSubmit={onSubmit}>
+ <Form
+ errors={errors}
+ initial={formInitialData}
+ onSubmit={onSubmit}
+ confirmLeave
+ >
{({ change, data, hasChanged, submit }) => (
<Container width="md">
<PageHeader title={pageTitle} onBack={onBack} />
diff --git a/saleor/static/dashboard-next/productTypes/components/ProductTypeDetailsPage/ProductTypeDetailsPage.tsx b/saleor/static/dashboard-next/productTypes/components/ProductTypeDetailsPage/ProductTypeDetailsPage.tsx
index 157462a1e4..c882ed7669 100644
--- a/saleor/static/dashboard-next/productTypes/components/ProductTypeDetailsPage/ProductTypeDetailsPage.tsx
+++ b/saleor/static/dashboard-next/productTypes/components/ProductTypeDetailsPage/ProductTypeDetailsPage.tsx
@@ -119,7 +119,12 @@ const ProductTypeDetailsPage = withStyles(styles, {
weight: maybe(() => productType.weight.value)
};
return (
- <Form errors={errors} initial={formInitialData} onSubmit={onSubmit}>
+ <Form
+ errors={errors}
+ initial={formInitialData}
+ onSubmit={onSubmit}
+ confirmLeave
+ >
{({ change, data, hasChanged, submit }) => (
<Container width="md">
<PageHeader title={pageTitle} onBack={onBack} />
diff --git a/saleor/static/dashboard-next/products/components/ProductCreatePage/ProductCreatePage.tsx b/saleor/static/dashboard-next/products/components/ProductCreatePage/ProductCreatePage.tsx
index 1eb4dfeec3..67feacb2ea 100644
--- a/saleor/static/dashboard-next/products/components/ProductCreatePage/ProductCreatePage.tsx
+++ b/saleor/static/dashboard-next/products/components/ProductCreatePage/ProductCreatePage.tsx
@@ -135,7 +135,12 @@ export const ProductCreatePage = withStyles(styles, {
stockQuantity: null
};
return (
- <Form onSubmit={onSubmit} errors={userErrors} initial={initialData}>
+ <Form
+ onSubmit={onSubmit}
+ errors={userErrors}
+ initial={initialData}
+ confirmLeave
+ >
{({ change, data, errors, hasChanged, submit }) => (
<Container width="md">
<PageHeader title={header} onBack={onBack} />
diff --git a/saleor/static/dashboard-next/products/components/ProductImagePage/ProductImagePage.tsx b/saleor/static/dashboard-next/products/components/ProductImagePage/ProductImagePage.tsx
index 718f140afb..ef9307d070 100644
--- a/saleor/static/dashboard-next/products/components/ProductImagePage/ProductImagePage.tsx
+++ b/saleor/static/dashboard-next/products/components/ProductImagePage/ProductImagePage.tsx
@@ -74,7 +74,7 @@ const ProductImagePage = withStyles(styles, { name: "ProductImagePage" })(
<Form
initial={{ description: image ? image.alt : "" }}
onSubmit={onSubmit}
- key={image ? image.alt : "loading"}
+ confirmLeave
>
{({ change, data, hasChanged, submit }) => {
return (
diff --git a/saleor/static/dashboard-next/products/components/ProductUpdatePage/ProductUpdatePage.tsx b/saleor/static/dashboard-next/products/components/ProductUpdatePage/ProductUpdatePage.tsx
index 640d68b176..fe7e770b4e 100644
--- a/saleor/static/dashboard-next/products/components/ProductUpdatePage/ProductUpdatePage.tsx
+++ b/saleor/static/dashboard-next/products/components/ProductUpdatePage/ProductUpdatePage.tsx
@@ -191,7 +191,12 @@ export const ProductUpdate = withStyles(styles, { name: "ProductUpdate" })(
product && product.productType && product.productType.hasVariants;
return (
- <Form onSubmit={onSubmit} errors={userErrors} initial={initialData}>
+ <Form
+ onSubmit={onSubmit}
+ errors={userErrors}
+ initial={initialData}
+ confirmLeave
+ >
{({ change, data, errors, hasChanged, submit }) => (
<>
<Container width="md">
diff --git a/saleor/static/dashboard-next/products/components/ProductVariantPage/ProductVariantPage.tsx b/saleor/static/dashboard-next/products/components/ProductVariantPage/ProductVariantPage.tsx
index 1c50d565ff..6ccd7c3147 100644
--- a/saleor/static/dashboard-next/products/components/ProductVariantPage/ProductVariantPage.tsx
+++ b/saleor/static/dashboard-next/products/components/ProductVariantPage/ProductVariantPage.tsx
@@ -103,7 +103,7 @@ const ProductVariantPage = withStyles(styles, { name: "ProductVariantPage" })(
}}
errors={formErrors}
onSubmit={onSubmit}
- key={variant ? JSON.stringify(variant) : "novariant"}
+ confirmLeave
>
{({ change, data, errors, hasChanged, submit }) => (
<>
diff --git a/saleor/static/dashboard-next/siteSettings/components/SiteSettingsPage/SiteSettingsPage.tsx b/saleor/static/dashboard-next/siteSettings/components/SiteSettingsPage/SiteSettingsPage.tsx
index e477dc3fce..1edb96926c 100644
--- a/saleor/static/dashboard-next/siteSettings/components/SiteSettingsPage/SiteSettingsPage.tsx
+++ b/saleor/static/dashboard-next/siteSettings/components/SiteSettingsPage/SiteSettingsPage.tsx
@@ -67,7 +67,12 @@ const SiteSettingsPage = withStyles(styles, { name: "SiteSettingsPage" })(
name: maybe(() => shop.name, "")
};
return (
- <Form errors={errors} initial={initialForm} onSubmit={onSubmit}>
+ <Form
+ errors={errors}
+ initial={initialForm}
+ onSubmit={onSubmit}
+ confirmLeave
+ >
{({ change, data, errors: formErrors, hasChanged, submit }) => (
<Container width="md">
<PageHeader
diff --git a/saleor/static/dashboard-next/staff/components/StaffDetailsPage/StaffDetailsPage.tsx b/saleor/static/dashboard-next/staff/components/StaffDetailsPage/StaffDetailsPage.tsx
index 1b3b8395b3..58ff5e4c14 100644
--- a/saleor/static/dashboard-next/staff/components/StaffDetailsPage/StaffDetailsPage.tsx
+++ b/saleor/static/dashboard-next/staff/components/StaffDetailsPage/StaffDetailsPage.tsx
@@ -76,7 +76,7 @@ const StaffDetailsPage = withStyles(styles, { name: "StaffDetailsPage" })(
)
};
return (
- <Form initial={initialForm} onSubmit={onSubmit}>
+ <Form initial={initialForm} onSubmit={onSubmit} confirmLeave>
{({ data, change, hasChanged, submit }) => (
<Container width="md">
<PageHeader