Skip to content

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

Connect all to API

dominik-zeglen22d3b46a5356
diff --git a/saleor/static/dashboard-next/attributes/components/AttributeValueDeleteDialog/AttributeValueDeleteDialog.tsx b/saleor/static/dashboard-next/attributes/components/AttributeValueDeleteDialog/AttributeValueDeleteDialog.tsx
index 09b8f1e0ab..295d7472bc 100644
--- a/saleor/static/dashboard-next/attributes/components/AttributeValueDeleteDialog/AttributeValueDeleteDialog.tsx
+++ b/saleor/static/dashboard-next/attributes/components/AttributeValueDeleteDialog/AttributeValueDeleteDialog.tsx
@@ -1,9 +1,45 @@
+import DialogContentText from "@material-ui/core/DialogContentText";
import * as React from "react";
+import ActionDialog from "@saleor/components/ActionDialog";
+import { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton";
+import i18n from "@saleor/i18n";
+
export interface AttributeValueDeleteDialogProps {
-
+ confirmButtonState: ConfirmButtonTransitionState;
+ open: boolean;
+ onConfirm: () => void;
+ onClose: () => void;
+ name: string;
}
-const AttributeValueDeleteDialog: React.StatelessComponent<AttributeValueDeleteDialogProps> = () => <div />;
+const AttributeValueDeleteDialog: React.FC<AttributeValueDeleteDialogProps> = ({
+ name,
+ confirmButtonState,
+ onClose,
+ onConfirm,
+ open
+}) => (
+ <ActionDialog
+ open={open}
+ onClose={onClose}
+ confirmButtonState={confirmButtonState}
+ onConfirm={onConfirm}
+ variant="delete"
+ title={i18n.t("Remove attribute value")}
+ >
+ <DialogContentText
+ dangerouslySetInnerHTML={{
+ __html: i18n.t(
+ "Are you sure you want to remove <strong>{{ name }}</strong>?",
+ {
+ name
+ }
+ )
+ }}
+ />
+ </ActionDialog>
+);
+
AttributeValueDeleteDialog.displayName = "AttributeValueDeleteDialog";
export default AttributeValueDeleteDialog;
diff --git a/saleor/static/dashboard-next/attributes/components/AttributeValueEditDialog/AttributeValueEditDialog.tsx b/saleor/static/dashboard-next/attributes/components/AttributeValueEditDialog/AttributeValueEditDialog.tsx
index b6efd4bec0..1555b725d4 100644
--- a/saleor/static/dashboard-next/attributes/components/AttributeValueEditDialog/AttributeValueEditDialog.tsx
+++ b/saleor/static/dashboard-next/attributes/components/AttributeValueEditDialog/AttributeValueEditDialog.tsx
@@ -1,9 +1,103 @@
+import Button from "@material-ui/core/Button";
+import Dialog from "@material-ui/core/Dialog";
+import DialogActions from "@material-ui/core/DialogActions";
+import DialogContent from "@material-ui/core/DialogContent";
+import DialogTitle from "@material-ui/core/DialogTitle";
+import TextField from "@material-ui/core/TextField";
import * as React from "react";
+import ConfirmButton, {
+ ConfirmButtonTransitionState
+} from "@saleor/components/ConfirmButton";
+import Form from "@saleor/components/Form";
+import FormSpacer from "@saleor/components/FormSpacer";
+import i18n from "@saleor/i18n";
+import { maybe } from "@saleor/misc";
+import { AttributeDetails_attribute_values } from "../../types/AttributeDetails";
+
+export interface AttributeValueEditDialogFormData {
+ name: string;
+ slug: string;
+}
export interface AttributeValueEditDialogProps {
-
+ attributeValue: AttributeDetails_attribute_values | null;
+ confirmButtonState: ConfirmButtonTransitionState;
+ disabled: boolean;
+ open: boolean;
+ onSubmit: (data: AttributeValueEditDialogFormData) => void;
+ onClose: () => void;
}
-const AttributeValueEditDialog: React.StatelessComponent<AttributeValueEditDialogProps> = () => <div />;
+const AttributeValueEditDialog: React.StatelessComponent<
+ AttributeValueEditDialogProps
+> = ({
+ attributeValue,
+ confirmButtonState,
+ disabled,
+ onClose,
+ onSubmit,
+ open
+}) => {
+ const initialForm = {
+ name: maybe(() => attributeValue.name, ""),
+ slug: maybe(() => attributeValue.slug, "")
+ };
+
+ return (
+ <Dialog onClose={onClose} open={open} fullWidth maxWidth="sm">
+ <DialogTitle>
+ {attributeValue === null
+ ? i18n.t("Add Value", {
+ context: "add attribute value"
+ })
+ : i18n.t("Edit Value", {
+ context: "edit attribute value"
+ })}
+ </DialogTitle>
+ <Form initial={initialForm} onSubmit={onSubmit}>
+ {({ change, data, submit }) => (
+ <>
+ <DialogContent>
+ <TextField
+ disabled={disabled}
+ fullWidth
+ name={"slug" as keyof AttributeValueEditDialogFormData}
+ label={i18n.t("Admin name", {
+ context: "attribute slug"
+ })}
+ value={data.slug}
+ onChange={change}
+ />
+ <FormSpacer />
+ <TextField
+ disabled={disabled}
+ fullWidth
+ name={"name" as keyof AttributeValueEditDialogFormData}
+ label={i18n.t("Default Storefront Name", {
+ context: "attribute name"
+ })}
+ value={data.name}
+ onChange={change}
+ />
+ </DialogContent>
+ <DialogActions>
+ <Button onClick={onClose}>
+ {i18n.t("Cancel", { context: "button" })}
+ </Button>
+ <ConfirmButton
+ transitionState={confirmButtonState}
+ color="primary"
+ variant="contained"
+ onClick={submit}
+ >
+ {i18n.t("Save")}
+ </ConfirmButton>
+ </DialogActions>
+ </>
+ )}
+ </Form>
+ </Dialog>
+ );
+};
AttributeValueEditDialog.displayName = "AttributeValueEditDialog";
export default AttributeValueEditDialog;
diff --git a/saleor/static/dashboard-next/attributes/mutations.ts b/saleor/static/dashboard-next/attributes/mutations.ts
index 1f323d3f9c..5d2197d618 100644
--- a/saleor/static/dashboard-next/attributes/mutations.ts
+++ b/saleor/static/dashboard-next/attributes/mutations.ts
@@ -1,10 +1,31 @@
import gql from "graphql-tag";
import { TypedMutation } from "@saleor/mutations";
+import { attributeDetailsFragment } from "./queries";
import {
AttributeBulkDelete,
AttributeBulkDeleteVariables
} from "./types/AttributeBulkDelete";
+import {
+ AttributeDelete,
+ AttributeDeleteVariables
+} from "./types/AttributeDelete";
+import {
+ AttributeUpdate,
+ AttributeUpdateVariables
+} from "./types/AttributeUpdate";
+import {
+ AttributeValueCreate,
+ AttributeValueCreateVariables
+} from "./types/AttributeValueCreate";
+import {
+ AttributeValueDelete,
+ AttributeValueDeleteVariables
+} from "./types/AttributeValueDelete";
+import {
+ AttributeValueUpdate,
+ AttributeValueUpdateVariables
+} from "./types/AttributeValueUpdate";
const attributeBulkDelete = gql`
mutation AttributeBulkDelete($ids: [ID!]!) {
@@ -20,3 +41,94 @@ export const AttributeBulkDeleteMutation = TypedMutation<
AttributeBulkDelete,
AttributeBulkDeleteVariables
>(attributeBulkDelete);
+
+const attributeDelete = gql`
+ mutation AttributeDelete($id: ID!) {
+ attributeDelete(id: $id) {
+ errors {
+ field
+ message
+ }
+ }
+ }
+`;
+export const AttributeDeleteMutation = TypedMutation<
+ AttributeDelete,
+ AttributeDeleteVariables
+>(attributeDelete);
+
+export const attributeUpdateMutation = gql`
+ ${attributeDetailsFragment}
+ mutation AttributeUpdate($id: ID!, $input: AttributeUpdateInput!) {
+ attributeUpdate(id: $id, input: $input) {
+ errors {
+ field
+ message
+ }
+ attribute {
+ ...AttributeDetailsFragment
+ }
+ }
+ }
+`;
+export const AttributeUpdateMutation = TypedMutation<
+ AttributeUpdate,
+ AttributeUpdateVariables
+>(attributeUpdateMutation);
+
+const attributeValueDelete = gql`
+ ${attributeDetailsFragment}
+ mutation AttributeValueDelete($id: ID!) {
+ attributeValueDelete(id: $id) {
+ errors {
+ field
+ message
+ }
+ attribute {
+ ...AttributeDetailsFragment
+ }
+ }
+ }
+`;
+export const AttributeValueDeleteMutation = TypedMutation<
+ AttributeValueDelete,
+ AttributeValueDeleteVariables
+>(attributeValueDelete);
+
+export const attributeValueUpdateMutation = gql`
+ ${attributeDetailsFragment}
+ mutation AttributeValueUpdate($id: ID!, $input: AttributeValueCreateInput!) {
+ attributeValueUpdate(id: $id, input: $input) {
+ errors {
+ field
+ message
+ }
+ attribute {
+ ...AttributeDetailsFragment
+ }
+ }
+ }
+`;
+export const AttributeValueUpdateMutation = TypedMutation<
+ AttributeValueUpdate,
+ AttributeValueUpdateVariables
+>(attributeValueUpdateMutation);
+
+export const attributeValueCreateMutation = gql`
+ ${attributeDetailsFragment}
+ mutation AttributeValueCreate($id: ID!, $input: AttributeValueCreateInput!) {
+ attributeValueCreate(attribute: $id, input: $input) {
+ errors {
+ field
+ message
+ }
+ attribute {
+ ...AttributeDetailsFragment
+ }
+ }
+ }
+`;
+export const AttributeValueCreateMutation = TypedMutation<
+ AttributeValueCreate,
+ AttributeValueCreateVariables
+>(attributeValueCreateMutation);
diff --git a/saleor/static/dashboard-next/attributes/types/AttributeDelete.ts b/saleor/static/dashboard-next/attributes/types/AttributeDelete.ts
new file mode 100644
index 0000000000..2cd44da904
--- /dev/null
+++ b/saleor/static/dashboard-next/attributes/types/AttributeDelete.ts
@@ -0,0 +1,26 @@
+/* tslint:disable */
+/* eslint-disable */
+// This file was automatically generated and should not be edited.
+
+// ====================================================
+// GraphQL mutation operation: AttributeDelete
+// ====================================================
+
+export interface AttributeDelete_attributeDelete_errors {
+ __typename: "Error";
+ field: string | null;
+ message: string | null;
+}
+
+export interface AttributeDelete_attributeDelete {
+ __typename: "AttributeDelete";
+ errors: AttributeDelete_attributeDelete_errors[] | null;
+}
+
+export interface AttributeDelete {
+ attributeDelete: AttributeDelete_attributeDelete | null;
+}
+
+export interface AttributeDeleteVariables {
+ id: string;
+}
diff --git a/saleor/static/dashboard-next/attributes/types/AttributeUpdate.ts b/saleor/static/dashboard-next/attributes/types/AttributeUpdate.ts
new file mode 100644
index 0000000000..d6b0eecc59
--- /dev/null
+++ b/saleor/static/dashboard-next/attributes/types/AttributeUpdate.ts
@@ -0,0 +1,48 @@
+/* tslint:disable */
+/* eslint-disable */
+// This file was automatically generated and should not be edited.
+
+import { AttributeUpdateInput, AttributeValueType } from "./../../types/globalTypes";
+
+// ====================================================
+// GraphQL mutation operation: AttributeUpdate
+// ====================================================
+
+export interface AttributeUpdate_attributeUpdate_errors {
+ __typename: "Error";
+ field: string | null;
+ message: string | null;
+}
+
+export interface AttributeUpdate_attributeUpdate_attribute_values {
+ __typename: "AttributeValue";
+ id: string;
+ name: string | null;
+ slug: string | null;
+ sortOrder: number | null;
+ type: AttributeValueType | null;
+ value: string | null;
+}
+
+export interface AttributeUpdate_attributeUpdate_attribute {
+ __typename: "Attribute";
+ id: string;
+ name: string | null;
+ slug: string | null;
+ values: (AttributeUpdate_attributeUpdate_attribute_values | null)[] | null;
+}
+
+export interface AttributeUpdate_attributeUpdate {
+ __typename: "AttributeUpdate";
+ errors: AttributeUpdate_attributeUpdate_errors[] | null;
+ attribute: AttributeUpdate_attributeUpdate_attribute | null;
+}
+
+export interface AttributeUpdate {
+ attributeUpdate: AttributeUpdate_attributeUpdate | null;
+}
+
+export interface AttributeUpdateVariables {
+ id: string;
+ input: AttributeUpdateInput;
+}
diff --git a/saleor/static/dashboard-next/attributes/types/AttributeValueCreate.ts b/saleor/static/dashboard-next/attributes/types/AttributeValueCreate.ts
new file mode 100644
index 0000000000..79c42a914b
--- /dev/null
+++ b/saleor/static/dashboard-next/attributes/types/AttributeValueCreate.ts
@@ -0,0 +1,48 @@
+/* tslint:disable */
+/* eslint-disable */
+// This file was automatically generated and should not be edited.
+
+import { AttributeValueCreateInput, AttributeValueType } from "./../../types/globalTypes";
+
+// ====================================================
+// GraphQL mutation operation: AttributeValueCreate
+// ====================================================
+
+export interface AttributeValueCreate_attributeValueCreate_errors {
+ __typename: "Error";
+ field: string | null;
+ message: string | null;
+}
+
+export interface AttributeValueCreate_attributeValueCreate_attribute_values {
+ __typename: "AttributeValue";
+ id: string;
+ name: string | null;
+ slug: string | null;
+ sortOrder: number | null;
+ type: AttributeValueType | null;
+ value: string | null;
+}
+
+export interface AttributeValueCreate_attributeValueCreate_attribute {
+ __typename: "Attribute";
+ id: string;
+ name: string | null;
+ slug: string | null;
+ values: (AttributeValueCreate_attributeValueCreate_attribute_values | null)[] | null;
+}
+
+export interface AttributeValueCreate_attributeValueCreate {
+ __typename: "AttributeValueCreate";
+ errors: AttributeValueCreate_attributeValueCreate_errors[] | null;
+ attribute: AttributeValueCreate_attributeValueCreate_attribute | null;
+}
+
+export interface AttributeValueCreate {
+ attributeValueCreate: AttributeValueCreate_attributeValueCreate | null;
+}
+
+export interface AttributeValueCreateVariables {
+ id: string;
+ input: AttributeValueCreateInput;
+}
diff --git a/saleor/static/dashboard-next/attributes/types/AttributeValueDelete.ts b/saleor/static/dashboard-next/attributes/types/AttributeValueDelete.ts
new file mode 100644
index 0000000000..3841344364
--- /dev/null
+++ b/saleor/static/dashboard-next/attributes/types/AttributeValueDelete.ts
@@ -0,0 +1,47 @@
+/* tslint:disable */
+/* eslint-disable */
+// This file was automatically generated and should not be edited.
+
+import { AttributeValueType } from "./../../types/globalTypes";
+
+// ====================================================
+// GraphQL mutation operation: AttributeValueDelete
+// ====================================================
+
+export interface AttributeValueDelete_attributeValueDelete_errors {
+ __typename: "Error";
+ field: string | null;
+ message: string | null;
+}
+
+export interface AttributeValueDelete_attributeValueDelete_attribute_values {
+ __typename: "AttributeValue";
+ id: string;
+ name: string | null;
+ slug: string | null;
+ sortOrder: number | null;
+ type: AttributeValueType | null;
+ value: string | null;
+}
+
+export interface AttributeValueDelete_attributeValueDelete_attribute {
+ __typename: "Attribute";
+ id: string;
+ name: string | null;
+ slug: string | null;
+ values: (AttributeValueDelete_attributeValueDelete_attribute_values | null)[] | null;
+}
+
+export interface AttributeValueDelete_attributeValueDelete {
+ __typename: "AttributeValueDelete";
+ errors: AttributeValueDelete_attributeValueDelete_errors[] | null;
+ attribute: AttributeValueDelete_attributeValueDelete_attribute | null;
+}
+
+export interface AttributeValueDelete {
+ attributeValueDelete: AttributeValueDelete_attributeValueDelete | null;
+}
+
+export interface AttributeValueDeleteVariables {
+ id: string;
+}
diff --git a/saleor/static/dashboard-next/attributes/types/AttributeValueUpdate.ts b/saleor/static/dashboard-next/attributes/types/AttributeValueUpdate.ts
new file mode 100644
index 0000000000..a223175d05
--- /dev/null
+++ b/saleor/static/dashboard-next/attributes/types/AttributeValueUpdate.ts
@@ -0,0 +1,48 @@
+/* tslint:disable */
+/* eslint-disable */
+// This file was automatically generated and should not be edited.
+
+import { AttributeValueCreateInput, AttributeValueType } from "./../../types/globalTypes";
+
+// ====================================================
+// GraphQL mutation operation: AttributeValueUpdate
+// ====================================================
+
+export interface AttributeValueUpdate_attributeValueUpdate_errors {
+ __typename: "Error";
+ field: string | null;
+ message: string | null;
+}
+
+export interface AttributeValueUpdate_attributeValueUpdate_attribute_values {
+ __typename: "AttributeValue";
+ id: string;
+ name: string | null;
+ slug: string | null;
+ sortOrder: number | null;
+ type: AttributeValueType | null;
+ value: string | null;
+}
+
+export interface AttributeValueUpdate_attributeValueUpdate_attribute {
+ __typename: "Attribute";
+ id: string;
+ name: string | null;
+ slug: string | null;
+ values: (AttributeValueUpdate_attributeValueUpdate_attribute_values | null)[] | null;
+}
+
+export interface AttributeValueUpdate_attributeValueUpdate {
+ __typename: "AttributeValueUpdate";
+ errors: AttributeValueUpdate_attributeValueUpdate_errors[] | null;
+ attribute: AttributeValueUpdate_attributeValueUpdate_attribute | null;
+}
+
+export interface AttributeValueUpdate {
+ attributeValueUpdate: AttributeValueUpdate_attributeValueUpdate | null;
+}
+
+export interface AttributeValueUpdateVariables {
+ id: string;
+ input: AttributeValueCreateInput;
+}
diff --git a/saleor/static/dashboard-next/attributes/urls.ts b/saleor/static/dashboard-next/attributes/urls.ts
index 361e7df6b3..4fb0364a07 100644
--- a/saleor/static/dashboard-next/attributes/urls.ts
+++ b/saleor/static/dashboard-next/attributes/urls.ts
@@ -1,7 +1,7 @@
import { stringify as stringifyQs } from "qs";
import * as urlJoin from "url-join";
-import { BulkAction, Dialog, Pagination } from "../types";
+import { BulkAction, Dialog, Pagination, SingleAction } from "../types";
export const attributeSection = "/attributes/";
@@ -29,7 +29,9 @@ export type AttributeUrlDialog =
| "remove"
| "remove-value"
| "remove-values";
-export type AttributeUrlQueryParams = BulkAction & Dialog<AttributeUrlDialog>;
+export type AttributeUrlQueryParams = BulkAction &
+ Dialog<AttributeUrlDialog> &
+ SingleAction;
export const attributePath = (id: string) => urlJoin(attributeSection, id);
export const attributeUrl = (id: string, params?: AttributeUrlQueryParams) =>
attributePath(encodeURIComponent(id)) + "?" + stringifyQs(params);
diff --git a/saleor/static/dashboard-next/attributes/views/AttributeDetails/AttributeDetails.tsx b/saleor/static/dashboard-next/attributes/views/AttributeDetails/AttributeDetails.tsx
index bbe877c728..bd2729955c 100644
--- a/saleor/static/dashboard-next/attributes/views/AttributeDetails/AttributeDetails.tsx
+++ b/saleor/static/dashboard-next/attributes/views/AttributeDetails/AttributeDetails.tsx
@@ -3,10 +3,24 @@ 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 "@saleor/misc";
+import { getMutationState, maybe } from "@saleor/misc";
import AttributeDeleteDialog from "../../components/AttributeDeleteDialog";
import AttributePage from "../../components/AttributePage";
+import AttributeValueDeleteDialog from "../../components/AttributeValueDeleteDialog";
+import AttributeValueEditDialog from "../../components/AttributeValueEditDialog";
+import {
+ AttributeDeleteMutation,
+ AttributeUpdateMutation,
+ AttributeValueCreateMutation,
+ AttributeValueDeleteMutation,
+ AttributeValueUpdateMutation
+} from "../../mutations";
import { AttributeDetailsQuery } from "../../queries";
+import { AttributeDelete } from "../../types/AttributeDelete";
+import { AttributeUpdate } from "../../types/AttributeUpdate";
+import { AttributeValueCreate } from "../../types/AttributeValueCreate";
+import { AttributeValueDelete } from "../../types/AttributeValueDelete";
+import { AttributeValueUpdate } from "../../types/AttributeValueUpdate";
import {
attributeListUrl,
attributeUrl,
@@ -27,49 +41,232 @@ const AttributeDetails: React.FC<AttributeDetailsProps> = ({ id, params }) => {
navigate(
attributeUrl(id, {
...params,
- action: undefined
+ action: undefined,
+ id: undefined,
+ ids: undefined
}),
true
);
- const openModal = (action: AttributeUrlDialog) =>
+ const openModal = (action: AttributeUrlDialog, valueId?: string) =>
navigate(
attributeUrl(id, {
...params,
- action
+ action,
+ id: valueId
})
);
- const handleDelete = () => {
- notify({ text: i18n.t("Product removed") });
- navigate(attributeListUrl());
+ const handleDelete = (data: AttributeDelete) => {
+ if (data.attributeDelete.errors.length === 0) {
+ notify({ text: i18n.t("Attribute removed") });
+ navigate(attributeListUrl());
+ }
+ };
+ const handleValueDelete = (data: AttributeValueDelete) => {
+ if (data.attributeValueDelete.errors.length === 0) {
+ notify({ text: i18n.t("Value removed") });
+ closeModal();
+ }
+ };
+ const handleUpdate = (data: AttributeUpdate) => {
+ if (data.attributeUpdate.errors.length === 0) {
+ notify({ text: i18n.t("Saved changes") });
+ }
+ };
+ const handleValueUpdate = (data: AttributeValueUpdate) => {
+ if (data.attributeValueUpdate.errors.length === 0) {
+ notify({ text: i18n.t("Saved changes") });
+ closeModal();
+ }
+ };
+ const handleValueCreate = (data: AttributeValueCreate) => {
+ if (data.attributeValueCreate.errors.length === 0) {
+ notify({ text: i18n.t("Added new value") });
+ closeModal();
+ }
};
- const handleUpdate = () => notify({ text: i18n.t("Saved changes") });
return (
<AttributeDetailsQuery variables={{ id }}>
{({ data, loading }) => (
- <>
- <AttributePage
- attribute={maybe(() => data.attribute)}
- disabled={loading}
- onBack={() => navigate(attributeListUrl())}
- onDelete={() => openModal("remove")}
- onSubmit={() => undefined}
- onValueAdd={() => openModal("add-value")}
- onValueDelete={() => openModal("remove-value")}
- onValueUpdate={() => openModal("edit-value")}
- saveButtonBarState={"default"}
- values={maybe(() => data.attribute.values)}
- />
- <AttributeDeleteDialog
- open={params.action === "remove"}
- name={maybe(() => data.attribute.name, "...")}
- confirmButtonState="default"
- onClose={closeModal}
- onConfirm={() => undefined}
- />
- </>
+ <AttributeDeleteMutation onCompleted={handleDelete}>
+ {(attributeDelete, attributeDeleteOpts) => (
+ <AttributeValueDeleteMutation onCompleted={handleValueDelete}>
+ {(attributeValueDelete, attributeValueDeleteOpts) => (
+ <AttributeUpdateMutation onCompleted={handleUpdate}>
+ {(attributeUpdate, attributeUpdateOpts) => (
+ <AttributeValueUpdateMutation
+ onCompleted={handleValueUpdate}
+ >
+ {(attributeValueUpdate, attributeValueUpdateOpts) => (
+ <AttributeValueCreateMutation
+ onCompleted={handleValueCreate}
+ >
+ {(attributeValueCreate, attributeValueCreateOpts) => {
+ const deleteTransitionState = getMutationState(
+ attributeDeleteOpts.called,
+ attributeDeleteOpts.loading,
+ maybe(
+ () =>
+ attributeDeleteOpts.data.attributeDelete
+ .errors
+ )
+ );
+ const deleteValueTransitionState = getMutationState(
+ attributeValueDeleteOpts.called,
+ attributeValueDeleteOpts.loading,
+ maybe(
+ () =>
+ attributeValueDeleteOpts.data
+ .attributeValueDelete.errors
+ )
+ );
+ const updateTransitionState = getMutationState(
+ attributeUpdateOpts.called,
+ attributeUpdateOpts.loading,
+ maybe(
+ () =>
+ attributeUpdateOpts.data.attributeUpdate
+ .errors
+ )
+ );
+ const updateValueTransitionState = getMutationState(
+ attributeValueUpdateOpts.called,
+ attributeValueUpdateOpts.loading,
+ maybe(
+ () =>
+ attributeValueUpdateOpts.data
+ .attributeValueUpdate.errors
+ )
+ );
+ const createValueTransitionState = getMutationState(
+ attributeValueCreateOpts.called,
+ attributeValueCreateOpts.loading,
+ maybe(
+ () =>
+ attributeValueCreateOpts.data
+ .attributeValueCreate.errors
+ )
+ );
+
+ return (
+ <>
+ <AttributePage
+ attribute={maybe(() => data.attribute)}
+ disabled={loading}
+ onBack={() => navigate(attributeListUrl())}
+ onDelete={() => openModal("remove")}
+ onSubmit={input =>
+ attributeUpdate({
+ variables: {
+ id,
+ input
+ }
+ })
+ }
+ onValueAdd={() => openModal("add-value")}
+ onValueDelete={id =>
+ openModal("remove-value", id)
+ }
+ onValueUpdate={id =>
+ openModal("edit-value", id)
+ }
+ saveButtonBarState={updateTransitionState}
+ values={maybe(() => data.attribute.values)}
+ />
+ <AttributeDeleteDialog
+ open={params.action === "remove"}
+ name={maybe(() => data.attribute.name, "...")}
+ confirmButtonState={deleteTransitionState}
+ onClose={closeModal}
+ onConfirm={() =>
+ attributeDelete({
+ variables: {
+ id
+ }
+ })
+ }
+ />
+ <AttributeValueDeleteDialog
+ open={params.action === "remove-value"}
+ name={maybe(
+ () =>
+ data.attribute.values.find(
+ value => params.id === value.id
+ ).name,
+ "..."
+ )}
+ confirmButtonState={
+ deleteValueTransitionState
+ }
+ onClose={closeModal}
+ onConfirm={() =>
+ attributeValueDelete({
+ variables: {
+ id: params.id
+ }
+ })
+ }
+ />
+ <AttributeValueEditDialog
+ attributeValue={null}
+ confirmButtonState={
+ createValueTransitionState
+ }
+ disabled={loading}
+ open={params.action === "add-value"}
+ onClose={closeModal}
+ onSubmit={input =>
+ attributeValueCreate({
+ variables: {
+ id,
+ input: {
+ name: input.name,
+ value: input.slug
+ }
+ }
+ })
+ }
+ />
+ <AttributeValueEditDialog
+ attributeValue={maybe(() =>
+ data.attribute.values.find(
+ value => params.id === value.id
+ )
+ )}
+ confirmButtonState={
+ updateValueTransitionState
+ }
+ disabled={loading}
+ open={params.action === "edit-value"}
+ onClose={closeModal}
+ onSubmit={input =>
+ attributeValueUpdate({
+ variables: {
+ id: data.attribute.values.find(
+ value => params.id === value.id
+ ).id,
+ input: {
+ name: input.name,
+ value: input.slug
+ }
+ }
+ })
+ }
+ />
+ </>
+ );
+ }}
+ </AttributeValueCreateMutation>
+ )}
+ </AttributeValueUpdateMutation>
+ )}
+ </AttributeUpdateMutation>
+ )}
+ </AttributeValueDeleteMutation>
+ )}
+ </AttributeDeleteMutation>
)}
</AttributeDetailsQuery>
);
diff --git a/saleor/static/dashboard-next/productTypes/mutations.ts b/saleor/static/dashboard-next/productTypes/mutations.ts
index c1259e28dc..22235ee361 100644
--- a/saleor/static/dashboard-next/productTypes/mutations.ts
+++ b/saleor/static/dashboard-next/productTypes/mutations.ts
@@ -107,37 +107,3 @@ export const TypedAttributeCreateMutation = TypedMutation<
AttributeCreate,
AttributeCreateVariables
>(attributeCreateMutation);
-
-export const attributeUpdateMutation = gql`
- ${attributeFragment}
- mutation AttributeUpdate($id: ID!, $input: AttributeUpdateInput!) {
- attributeUpdate(id: $id, input: $input) {
- errors {
- field
- message
- }
- attribute {
- ...AttributeFragment
- }
- }
- }
-`;
-export const TypedAttributeUpdateMutation = TypedMutation<
- AttributeUpdate,
- AttributeUpdateVariables
->(attributeUpdateMutation);
-
-export const attributeDeleteMutation = gql`
- mutation AttributeDelete($id: ID!) {
- attributeDelete(id: $id) {
- errors {
- field
- message
- }
- }
- }
-`;
-export const TypedAttributeDeleteMutation = TypedMutation<
- AttributeDelete,
- AttributeDeleteVariables
->(attributeDeleteMutation);