From d19a07f319bc40e66fa8c6638da35f5dbc66da02 Mon Sep 17 00:00:00 2001 From: dominik-zeglen Date: Wed, 25 Sep 2019 13:40:10 +0200 Subject: [PATCH] Hide variants and attributes if none --- .../ProductCreatePage/ProductCreatePage.tsx | 15 +- .../ProductUpdatePage/ProductUpdatePage.tsx | 17 +- .../ProductVariants/ProductVariants.tsx | 99 +- src/products/views/ProductCreate.tsx | 2 - .../views/ProductUpdate/ProductUpdate.tsx | 6 - .../__snapshots__/Stories.test.ts.snap | 3515 +++++++++++++++-- .../stories/products/ProductCreatePage.tsx | 3 - .../stories/products/ProductUpdatePage.tsx | 19 +- 8 files changed, 3305 insertions(+), 371 deletions(-) diff --git a/src/products/components/ProductCreatePage/ProductCreatePage.tsx b/src/products/components/ProductCreatePage/ProductCreatePage.tsx index 97cbb189a..3874ae966 100644 --- a/src/products/components/ProductCreatePage/ProductCreatePage.tsx +++ b/src/products/components/ProductCreatePage/ProductCreatePage.tsx @@ -78,7 +78,6 @@ interface ProductCreatePageProps { fetchCategories: (data: string) => void; fetchCollections: (data: string) => void; fetchProductTypes: (data: string) => void; - onAttributesEdit: () => void; onBack?(); onSubmit?(data: ProductCreatePageSubmitData); } @@ -220,12 +219,14 @@ export const ProductCreatePage: React.StatelessComponent< onChange={change} /> - + {attributes.length > 0 && ( + + )} void; onVariantShow: (id: string) => () => void; onImageDelete: (id: string) => () => void; - onAttributesEdit: () => void; onBack?(); onDelete(); onImageEdit?(id: string); @@ -92,7 +91,6 @@ export const ProductUpdatePage: React.FC = ({ product, saveButtonBarState, variants, - onAttributesEdit, onBack, onDelete, onImageDelete, @@ -215,12 +213,14 @@ export const ProductUpdatePage: React.FC = ({ onImageUpload={onImageUpload} /> - + {attributes.length > 0 && ( + + )} = ({ disabled={disabled} variants={variants} fallbackPrice={product ? product.basePrice : undefined} - onAttributesEdit={onAttributesEdit} onRowClick={onVariantShow} onVariantAdd={onVariantAdd} toolbar={toolbar} diff --git a/src/products/components/ProductVariants/ProductVariants.tsx b/src/products/components/ProductVariants/ProductVariants.tsx index 803b46e7f..bf6332396 100644 --- a/src/products/components/ProductVariants/ProductVariants.tsx +++ b/src/products/components/ProductVariants/ProductVariants.tsx @@ -67,7 +67,6 @@ interface ProductVariantsProps extends ListActions, WithStyles { disabled: boolean; variants: ProductDetails_product_variants[]; fallbackPrice?: ProductVariant_costPrice; - onAttributesEdit: () => void; onRowClick: (id: string) => () => void; onVariantAdd?(); } @@ -80,7 +79,6 @@ export const ProductVariants = withStyles(styles, { name: "ProductVariants" })( disabled, variants, fallbackPrice, - onAttributesEdit, onRowClick, onVariantAdd, isChecked, @@ -90,6 +88,8 @@ export const ProductVariants = withStyles(styles, { name: "ProductVariants" })( toolbar }: ProductVariantsProps) => { const intl = useIntl(); + const hasVariants = maybe(() => variants.length > 0, true); + return ( - - - -
@@ -83483,71 +83418,6 @@ Ctrl + K"
-
-
- - Attributes - -
-
-
-
-
-
-
- - 0 Attributes - -
- -
-
-
@@ -84577,71 +84447,6 @@ Ctrl + K"
-
-
- - Attributes - -
-
-
-
-
-
-
- - 0 Attributes - -
- -
-
-
@@ -87189,6 +86994,3237 @@ exports[`Storyshots Views / Products / Create product variant with errors 1`] =
`; +exports[`Storyshots Views / Products / Product edit no product attributes 1`] = ` +
+
+
+
+
+ Ergonomic Plastic Bacon +
+
+
+
+
+
+
+
+
+ + General Informations + +
+
+
+
+
+
+ +
+ + +
+
+
+
+
+ + Description + +
+ +
+
+
+
+
+
+ + + bold + + +
+
+
+
+ + + italic + + +
+
+
+
+ + + strikethrough + + +
+
+

+
+ + + h1 + + +
+

+

+
+ + + h2 + + +
+

+

+
+ + + h3 + + +
+

+
+
+ + + blockquote + + +
+
+
    +
  • +
    + + + ul + + +
    +
  • +
+
    +
  1. +
    + + + ol + + +
    +
  2. +
+
+
+ + + link + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + Images + +
+ + +
+
+
+
+
+
+
+ + +

+ Drop here to upload +

+
+
+
+
+
+
+
+
+ Id sit dolores adipisci +
+
+
+
+
+ Id sit dolores adipisci +
+
+
+
+
+ Id sit dolores adipisci +
+
+
+
+
+ Id sit dolores adipisci +
+
+
+
+
+ Id sit dolores adipisci +
+
+
+
+
+
+
+
+
+ + Pricing + +
+
+
+ +
+
+
+
+
+ +
+ + +
+

+ NZD +

+
+
+
+
+
+
+
+
+
+ + Variants + +
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+ + + Name + + Status + + SKU +
+
+
+
+
+ + Search Engine Preview + +
+ +
+
+
+
+
+

+ Add search engine title and description to make this product easier to find +

+
+
+
+
+
+
+ + Organize Product + +
+
+
+
+
+ + Product Type + +

+ Versatile +

+
+ + Product Type + +

+ Configurable +

+
+
+
+
+
+ + +
+
+
+
+
+
+
+ + +

+ *Optional. Adding product to collection helps users find it. +

+
+
+
+
+
+

+ Winter sale +

+ +
+
+
+
+
+
+
+
+ + Visibility + +
+
+
+
+
+
+
+ + +
+
+
+
+
+
+
+
+ +
+`; + +exports[`Storyshots Views / Products / Product edit no variants 1`] = ` +
+
+
+
+
+ Ergonomic Plastic Bacon +
+
+
+
+
+
+
+
+
+ + General Informations + +
+
+
+
+
+
+ +
+ + +
+
+
+
+
+ + Description + +
+ +
+
+
+
+
+
+ + + bold + + +
+
+
+
+ + + italic + + +
+
+
+
+ + + strikethrough + + +
+
+

+
+ + + h1 + + +
+

+

+
+ + + h2 + + +
+

+

+
+ + + h3 + + +
+

+
+
+ + + blockquote + + +
+
+
    +
  • +
    + + + ul + + +
    +
  • +
+
    +
  1. +
    + + + ol + + +
    +
  2. +
+
+
+ + + link + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + Images + +
+ + +
+
+
+
+
+
+
+ + +

+ Drop here to upload +

+
+
+
+
+
+
+
+
+ Id sit dolores adipisci +
+
+
+
+
+ Id sit dolores adipisci +
+
+
+
+
+ Id sit dolores adipisci +
+
+
+
+
+ Id sit dolores adipisci +
+
+
+
+
+ Id sit dolores adipisci +
+
+
+
+
+
+
+
+ + Attributes + +
+
+
+
+
+
+
+ + 2 Attributes + +
+ +
+
+
+
+

+ Borders +

+
+
+
+
+ + +
+
+
+
+
+
+
+

+ Legacy +

+
+
+
+
+ + +
+
+
+
+
+

+ Auto Loan Account +

+ +
+
+
+
+
+
+
+
+
+
+ + Pricing + +
+
+
+ +
+
+
+
+
+ +
+ + +
+

+ NZD +

+
+
+
+
+
+
+
+
+
+ + Variants + +
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+ + + Name + + Status + + SKU +
+
+
+
+
+ + Search Engine Preview + +
+ +
+
+
+
+
+

+ Add search engine title and description to make this product easier to find +

+
+
+
+
+
+
+ + Organize Product + +
+
+
+
+
+ + Product Type + +

+ Versatile +

+
+ + Product Type + +

+ Configurable +

+
+
+
+
+
+ + +
+
+
+
+
+
+
+ + +

+ *Optional. Adding product to collection helps users find it. +

+
+
+
+
+
+

+ Winter sale +

+ +
+
+
+
+
+
+
+
+ + Visibility + +
+
+
+
+
+
+
+ + +
+
+
+
+
+
+
+
+ +
+`; + exports[`Storyshots Views / Products / Product edit when data is fully loaded 1`] = `
- -
-
-
@@ -91174,18 +94133,6 @@ Ctrl + K"
-