Skip to content

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

Add attribute delete dialog

dominik-zeglene513655a8ebc
diff --git a/saleor/static/dashboard-next/attributes/components/AttributeDeleteDialog/AttributeDeleteDialog.tsx b/saleor/static/dashboard-next/attributes/components/AttributeDeleteDialog/AttributeDeleteDialog.tsx
index 105a74030c..ac5c27a922 100644
--- a/saleor/static/dashboard-next/attributes/components/AttributeDeleteDialog/AttributeDeleteDialog.tsx
+++ b/saleor/static/dashboard-next/attributes/components/AttributeDeleteDialog/AttributeDeleteDialog.tsx
@@ -10,24 +10,30 @@ export interface AttributeDeleteDialogProps {
open: boolean;
onConfirm: () => void;
onClose: () => void;
- attributeName: string;
+ name: string;
}
-const AttributeDeleteDialog: React.FC<AttributeDeleteDialogProps> = () => (
+const AttributeDeleteDialog: React.FC<AttributeDeleteDialogProps> = ({
+ name,
+ confirmButtonState,
+ onClose,
+ onConfirm,
+ open
+}) => (
<ActionDialog
- open={params.action === "remove"}
- onClose={() => navigate(productUrl(id), true)}
- confirmButtonState={deleteTransitionState}
- onConfirm={() => deleteProduct.mutate({ id })}
+ open={open}
+ onClose={onClose}
+ confirmButtonState={confirmButtonState}
+ onConfirm={onConfirm}
variant="delete"
- title={i18n.t("Remove product")}
+ title={i18n.t("Remove attribute")}
>
<DialogContentText
dangerouslySetInnerHTML={{
__html: i18n.t(
"Are you sure you want to remove <strong>{{ name }}</strong>?",
{
- name: product ? product.name : undefined
+ name
}
)
}}
diff --git a/saleor/static/dashboard-next/attributes/views/AttributeDetails/AttributeDetails.tsx b/saleor/static/dashboard-next/attributes/views/AttributeDetails/AttributeDetails.tsx
index e76bc50103..bbe877c728 100644
--- a/saleor/static/dashboard-next/attributes/views/AttributeDetails/AttributeDetails.tsx
+++ b/saleor/static/dashboard-next/attributes/views/AttributeDetails/AttributeDetails.tsx
@@ -3,7 +3,8 @@ import * as React from "react";
import useNavigator from "@saleor/hooks/useNavigator";
import useNotifier from "@saleor/hooks/useNotifier";
import i18n from "@saleor/i18n";
-import { maybe } from "../../../misc";
+import { maybe } from "@saleor/misc";
+import AttributeDeleteDialog from "../../components/AttributeDeleteDialog";
import AttributePage from "../../components/AttributePage";
import { AttributeDetailsQuery } from "../../queries";
import {
@@ -24,10 +25,9 @@ const AttributeDetails: React.FC<AttributeDetailsProps> = ({ id, params }) => {
const closeModal = () =>
navigate(
- attributeListUrl({
+ attributeUrl(id, {
...params,
- action: undefined,
- ids: undefined
+ action: undefined
}),
true
);
@@ -62,6 +62,13 @@ const AttributeDetails: React.FC<AttributeDetailsProps> = ({ id, params }) => {
saveButtonBarState={"default"}
values={maybe(() => data.attribute.values)}
/>
+ <AttributeDeleteDialog
+ open={params.action === "remove"}
+ name={maybe(() => data.attribute.name, "...")}
+ confirmButtonState="default"
+ onClose={closeModal}
+ onConfirm={() => undefined}
+ />
</>
)}
</AttributeDetailsQuery>