Skip to content

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

Don't allow user to change input type once created

dominik-zeglenebaa65436b0b
diff --git a/saleor/static/dashboard-next/attributes/components/AttributeDetails/AttributeDetails.tsx b/saleor/static/dashboard-next/attributes/components/AttributeDetails/AttributeDetails.tsx
index 311848106a..3036994128 100644
--- a/saleor/static/dashboard-next/attributes/components/AttributeDetails/AttributeDetails.tsx
+++ b/saleor/static/dashboard-next/attributes/components/AttributeDetails/AttributeDetails.tsx
@@ -12,6 +12,7 @@ import { AttributeInputTypeEnum } from "@saleor/types/globalTypes";
import { AttributePageFormData } from "../AttributePage";
export interface AttributeDetailsProps {
+ canChangeType: boolean;
data: AttributePageFormData;
disabled: boolean;
errors: FormErrors<"name" | "slug" | "inputType">;
@@ -30,6 +31,7 @@ const inputTypeChoices = [
];
const AttributeDetails: React.FC<AttributeDetailsProps> = ({
+ canChangeType,
data,
disabled,
errors,
@@ -67,7 +69,7 @@ const AttributeDetails: React.FC<AttributeDetailsProps> = ({
<FormSpacer />
<SingleSelectField
choices={inputTypeChoices}
- disabled={disabled}
+ disabled={disabled || !canChangeType}
error={!!errors.inputType}
hint={errors.inputType}
label={i18n.t("Catalog Input type for Store Owner", {
diff --git a/saleor/static/dashboard-next/attributes/components/AttributePage/AttributePage.tsx b/saleor/static/dashboard-next/attributes/components/AttributePage/AttributePage.tsx
index 5c001d36a7..b5449cd108 100644
--- a/saleor/static/dashboard-next/attributes/components/AttributePage/AttributePage.tsx
+++ b/saleor/static/dashboard-next/attributes/components/AttributePage/AttributePage.tsx
@@ -85,6 +85,7 @@ const AttributePage: React.FC<AttributePageProps> = ({
<Grid>
<div>
<AttributeDetails
+ canChangeType={attribute === null}
data={data}
disabled={disabled}
errors={formErrors}
diff --git a/saleor/static/dashboard-next/attributes/views/AttributeDetails/AttributeDetails.tsx b/saleor/static/dashboard-next/attributes/views/AttributeDetails/AttributeDetails.tsx
index cc249e2de1..6c8b8d045e 100644
--- a/saleor/static/dashboard-next/attributes/views/AttributeDetails/AttributeDetails.tsx
+++ b/saleor/static/dashboard-next/attributes/views/AttributeDetails/AttributeDetails.tsx
@@ -167,7 +167,10 @@ const AttributeDetails: React.FC<AttributeDetailsProps> = ({ id, params }) => {
attributeUpdate({
variables: {
id,
- input
+ input: {
+ name: input.name,
+ slug: input.slug
+ }
}
})
}