From 4603229ddfe649fb4debb0f7a03036290810901b Mon Sep 17 00:00:00 2001 From: Mike Murray Date: Fri, 6 Mar 2020 13:58:37 -0800 Subject: [PATCH 01/28] feat: highlight active tree item Signed-off-by: Mike Murray --- .../client/blocks/VariantList.js | 41 ++++++++++++++----- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/imports/plugins/included/product-admin/client/blocks/VariantList.js b/imports/plugins/included/product-admin/client/blocks/VariantList.js index 6c73c11113..254f446872 100644 --- a/imports/plugins/included/product-admin/client/blocks/VariantList.js +++ b/imports/plugins/included/product-admin/client/blocks/VariantList.js @@ -22,14 +22,26 @@ const useStyles = makeStyles((theme) => ({ } }, listItem: { - paddingLeft: theme.spacing(7) + "paddingLeft": theme.spacing(7), + "&$focusVisible": { + backgroundColor: "red" + }, + "&$selected, &$selected:hover": { + backgroundColor: "white", + boxShadow: theme.shadows[2], + borderRadius: theme.shape.borderRadius + } }, nested: { - paddingLeft: theme.spacing(8) + paddingLeft: theme.spacing(4) }, listItemAction: { display: "none" - } + }, + /* Pseudo-class applied to the `component`'s `focusVisibleClassName` prop if `button={true}`. */ + focusVisible: {}, + /* Pseudo-class applied to the root element if `selected={true}`. */ + selected: {} })); /** @@ -51,13 +63,14 @@ function getItemSecondaryLabel({ isVisible }) { */ export default function VariantList() { const { + currentVariant, onArchiveProductVariants, onCreateVariant, onToggleVariantVisibility, onCloneProductVariants, onRestoreProduct, product, - variant: currentVariant + variant: variantProp } = useProduct(); const classes = useStyles(); const history = useHistory(); @@ -65,11 +78,11 @@ export default function VariantList() { useEffect(() => { - if (currentVariant) { - setExpandedIds((prevState) => [...prevState, currentVariant._id]); + if (variantProp) { + setExpandedIds((prevState) => [...prevState, variantProp._id]); } }, [ - currentVariant + variantProp ]); const renderVariantTree = useCallback((variants, parentVariant) => { @@ -95,17 +108,24 @@ export default function VariantList() { toggleExpand(variant._id) }} ContainerComponent={VariantListItemContainer} + classes={{ + root: classes.listItem, + selected: classes.selected + }} className={clsx({ - [classes.listItem]: true, - [classes.nested]: Boolean(parentVariant) + // [classes.nested]: Boolean(parentVariant) })} button + selected={currentVariant && (currentVariant._id === variant._id)} onClick={() => { const url = getPDPUrl(product._id, variant._id, parentVariant && parentVariant._id); history.push(url); @@ -153,6 +173,7 @@ export default function VariantList() { }, [ expandedIds, classes, + currentVariant, product, onArchiveProductVariants, onCreateVariant, From 3dc222a2a9a6e629b8d90816cdd59ce50f729137 Mon Sep 17 00:00:00 2001 From: Mike Murray Date: Fri, 6 Mar 2020 13:59:01 -0800 Subject: [PATCH 02/28] feat: add left spacing Signed-off-by: Mike Murray --- .../client/components/VariantListItemContainer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/imports/plugins/included/product-admin/client/components/VariantListItemContainer.js b/imports/plugins/included/product-admin/client/components/VariantListItemContainer.js index cc7eb46f06..0ed04a4036 100644 --- a/imports/plugins/included/product-admin/client/components/VariantListItemContainer.js +++ b/imports/plugins/included/product-admin/client/components/VariantListItemContainer.js @@ -9,10 +9,10 @@ import { import ChevronDown from "mdi-material-ui/ChevronDown"; import ChevronRight from "mdi-material-ui/ChevronRight"; -const useStyles = makeStyles(() => ({ +const useStyles = makeStyles((theme) => ({ expandButton: { position: "absolute", - left: 0, + left: theme.spacing(1), top: "50%", transform: "translateY(-50%)", zIndex: 1 From d212e7e3deb236d59222032436c21d77361cac82 Mon Sep 17 00:00:00 2001 From: Mike Murray Date: Fri, 6 Mar 2020 14:10:37 -0800 Subject: [PATCH 03/28] fix: use notistack snackbars Signed-off-by: Mike Murray --- .../included/product-admin/client/hooks/useProduct.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/imports/plugins/included/product-admin/client/hooks/useProduct.js b/imports/plugins/included/product-admin/client/hooks/useProduct.js index 55590dff32..213ed50df4 100644 --- a/imports/plugins/included/product-admin/client/hooks/useProduct.js +++ b/imports/plugins/included/product-admin/client/hooks/useProduct.js @@ -181,12 +181,13 @@ function useProduct(args = {}) { const onArchiveProduct = useCallback(async (productLocal, redirectUrl) => { try { await archiveProducts({ variables: { input: { shopId, productIds: [productLocal] } } }); - Alerts.toast(i18next.t("productDetailEdit.archiveProductsSuccess"), "success"); + enqueueSnackbar(i18next.t("productDetailEdit.archiveProductsSuccess"), { variant: "success" }); history.push(redirectUrl); } catch (error) { - Alerts.toast(i18next.t("productDetailEdit.archiveProductsFail", { err: error }), "error"); + enqueueSnackbar(i18next.t("productDetailEdit.archiveProductsFail"), { variant: "success" }); } }, [ + enqueueSnackbar, history, archiveProducts, shopId @@ -255,11 +256,12 @@ function useProduct(args = {}) { } }); - Alerts.toast(i18next.t("productDetailEdit.updateProductFieldSuccess"), "success"); + enqueueSnackbar(i18next.t("productDetailEdit.updateProductFieldSuccess"), { variant: "success" }); } catch (error) { - Alerts.toast(i18next.t("productDetailEdit.updateProductFieldFail", { err: error }), "error"); + enqueueSnackbar(i18next.t("productDetailEdit.updateProductFieldFail"), { variant: "error" }); } }, [ + enqueueSnackbar, product, shopId, updateProduct From 25dc649f942064ff1291a51fabdb3a2e7f7d1503 Mon Sep 17 00:00:00 2001 From: Mike Murray Date: Tue, 10 Mar 2020 09:33:06 -0700 Subject: [PATCH 04/28] feat: add product variant GQL fragment Signed-off-by: Mike Murray --- .../graphql/fragments/productVariant.js | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 imports/plugins/included/product-admin/client/graphql/fragments/productVariant.js diff --git a/imports/plugins/included/product-admin/client/graphql/fragments/productVariant.js b/imports/plugins/included/product-admin/client/graphql/fragments/productVariant.js new file mode 100644 index 0000000000..1befe41c37 --- /dev/null +++ b/imports/plugins/included/product-admin/client/graphql/fragments/productVariant.js @@ -0,0 +1,33 @@ +import gql from "graphql-tag"; + +export default gql` + fragment ProductVariant on ProductVariant { + _id + attributeLabel + barcode + height + index + isDeleted + isVisible + length + metafields { + key + value + } + minOrderQuantity + optionTitle + originCountry + shop { + _id + } + sku + title + updatedAt + weight + width + isTaxable + taxCode + taxDescription + } +`; + From 40363ba1c634a48a0a3139608d227edb0746b717 Mon Sep 17 00:00:00 2001 From: Mike Murray Date: Tue, 10 Mar 2020 09:33:24 -0700 Subject: [PATCH 05/28] feat: add product with variants and options GQL fragment Signed-off-by: Mike Murray --- .../graphql/fragments/productWithVariants.js | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 imports/plugins/included/product-admin/client/graphql/fragments/productWithVariants.js diff --git a/imports/plugins/included/product-admin/client/graphql/fragments/productWithVariants.js b/imports/plugins/included/product-admin/client/graphql/fragments/productWithVariants.js new file mode 100644 index 0000000000..f1cdb2c846 --- /dev/null +++ b/imports/plugins/included/product-admin/client/graphql/fragments/productWithVariants.js @@ -0,0 +1,48 @@ +import gql from "graphql-tag"; +import ProductVariant from "./productVariant"; + +export default gql` + fragment Product on Product { + _id + currentProductHash + description + isDeleted + isVisible + metaDescription + metafields { + key + value + } + originCountry + pageTitle + productType + publishedAt + publishedProductHash + shop { + _id + } + slug + socialMetadata { + message + service + } + supportedFulfillmentTypes + tagIds + tags { + nodes { + _id + name + } + } + title + updatedAt + vendor + variants { + ...ProductVariant + options { + ...ProductVariant + } + } + } + ${ProductVariant} +`; From 8b415489dbf0adb6cfbb46a3cdc1da72c90bf86b Mon Sep 17 00:00:00 2001 From: Mike Murray Date: Tue, 10 Mar 2020 09:42:13 -0700 Subject: [PATCH 06/28] feat: add archive product variants mutation definition Signed-off-by: Mike Murray --- .../graphql/mutations/archiveProductVariants.js | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 imports/plugins/included/product-admin/client/graphql/mutations/archiveProductVariants.js diff --git a/imports/plugins/included/product-admin/client/graphql/mutations/archiveProductVariants.js b/imports/plugins/included/product-admin/client/graphql/mutations/archiveProductVariants.js new file mode 100644 index 0000000000..fb8f65ba17 --- /dev/null +++ b/imports/plugins/included/product-admin/client/graphql/mutations/archiveProductVariants.js @@ -0,0 +1,11 @@ +import gql from "graphql-tag"; + +export default gql` + mutation archiveProductVariants($input: ArchiveProductVariantsInput!) { + archiveProductVariants(input: $input) { + variants { + _id + } + } + } +`; From 51f18c6963bf89c147ec9f07eb794814db7216a4 Mon Sep 17 00:00:00 2001 From: Mike Murray Date: Tue, 10 Mar 2020 09:44:40 -0700 Subject: [PATCH 07/28] feat: add clone product variants mutation definition Signed-off-by: Mike Murray --- .../client/graphql/mutations/cloneProductVariants.js | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 imports/plugins/included/product-admin/client/graphql/mutations/cloneProductVariants.js diff --git a/imports/plugins/included/product-admin/client/graphql/mutations/cloneProductVariants.js b/imports/plugins/included/product-admin/client/graphql/mutations/cloneProductVariants.js new file mode 100644 index 0000000000..779e9ed407 --- /dev/null +++ b/imports/plugins/included/product-admin/client/graphql/mutations/cloneProductVariants.js @@ -0,0 +1,11 @@ +import gql from "graphql-tag"; + +export default gql` + mutation cloneProductVariants($input: CloneProductVariantsInput!) { + cloneProductVariants(input: $input) { + variants { + _id + } + } + } +`; From 0b8407ae79102d67e0bba26c2bdcb4e29ad1948b Mon Sep 17 00:00:00 2001 From: Mike Murray Date: Tue, 10 Mar 2020 09:49:43 -0700 Subject: [PATCH 08/28] feat: add create product variant mutation definition Signed-off-by: Mike Murray --- .../graphql/mutations/createProductVariant.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 imports/plugins/included/product-admin/client/graphql/mutations/createProductVariant.js diff --git a/imports/plugins/included/product-admin/client/graphql/mutations/createProductVariant.js b/imports/plugins/included/product-admin/client/graphql/mutations/createProductVariant.js new file mode 100644 index 0000000000..7394ce705d --- /dev/null +++ b/imports/plugins/included/product-admin/client/graphql/mutations/createProductVariant.js @@ -0,0 +1,13 @@ +import gql from "graphql-tag"; +import Product from "../fragments/productWithVariants"; + +export default gql` + mutation createProductVariant($input: CreateProductVariantInput!) { + createProductVariant(input: $input) { + product { + ...Product + } + } + } + ${Product} +`; From 68c8d4cd3e1d7caea5361475bddd0901db4cd09c Mon Sep 17 00:00:00 2001 From: Mike Murray Date: Tue, 10 Mar 2020 10:05:43 -0700 Subject: [PATCH 09/28] feat: add update product variant mutation definition Signed-off-by: Mike Murray --- .../graphql/mutations/updateProductVariant.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 imports/plugins/included/product-admin/client/graphql/mutations/updateProductVariant.js diff --git a/imports/plugins/included/product-admin/client/graphql/mutations/updateProductVariant.js b/imports/plugins/included/product-admin/client/graphql/mutations/updateProductVariant.js new file mode 100644 index 0000000000..59fe090c0f --- /dev/null +++ b/imports/plugins/included/product-admin/client/graphql/mutations/updateProductVariant.js @@ -0,0 +1,13 @@ +import gql from "graphql-tag"; +import ProductVariant from "../fragments/productVariant"; + +export default gql` + mutation updateProductVariant($input: UpdateProductVariantInput!) { + updateProductVariant(input: $input) { + variant { + ...ProductVariant + } + } + } + ${ProductVariant} +`; From 7747e9e1e98bf34798354b82a6434637c94bfcf4 Mon Sep 17 00:00:00 2001 From: Mike Murray Date: Tue, 10 Mar 2020 10:06:04 -0700 Subject: [PATCH 10/28] feat: add update product variant prices mutation definition Signed-off-by: Mike Murray --- .../graphql/mutations/updateProductVariantPrices.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 imports/plugins/included/product-admin/client/graphql/mutations/updateProductVariantPrices.js diff --git a/imports/plugins/included/product-admin/client/graphql/mutations/updateProductVariantPrices.js b/imports/plugins/included/product-admin/client/graphql/mutations/updateProductVariantPrices.js new file mode 100644 index 0000000000..04249abe6a --- /dev/null +++ b/imports/plugins/included/product-admin/client/graphql/mutations/updateProductVariantPrices.js @@ -0,0 +1,13 @@ +import gql from "graphql-tag"; + +export default gql` + mutation updateProductVariantPrices($input: UpdateProductVariantPricesInput!) { + updateProductVariantPrices(input: $input) { + variant { + _id + price + compareAtPrice + } + } + } +`; From 7dd281a4f41beca05fbb84b038747ec8e8474709 Mon Sep 17 00:00:00 2001 From: Mike Murray Date: Tue, 10 Mar 2020 10:06:47 -0700 Subject: [PATCH 11/28] feat: add product query definition Signed-off-by: Mike Murray --- .../product-admin/client/graphql/queries/product.js | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 imports/plugins/included/product-admin/client/graphql/queries/product.js diff --git a/imports/plugins/included/product-admin/client/graphql/queries/product.js b/imports/plugins/included/product-admin/client/graphql/queries/product.js new file mode 100644 index 0000000000..17f619fdd2 --- /dev/null +++ b/imports/plugins/included/product-admin/client/graphql/queries/product.js @@ -0,0 +1,11 @@ +import gql from "graphql-tag"; +import Product from "../fragments/productWithVariants"; + +export default gql` + query product($productId: ID!, $shopId: ID!) { + product(productId: $productId, shopId: $shopId) { + ...Product + } + } + ${Product} +`; From b1686e612287ddf4e3bd0622d4d6381f0cc67949 Mon Sep 17 00:00:00 2001 From: Mike Murray Date: Tue, 10 Mar 2020 10:07:23 -0700 Subject: [PATCH 12/28] refactor: import queries and mutations Signed-off-by: Mike Murray --- .../product-admin/client/hooks/useProduct.js | 116 +++--------------- 1 file changed, 20 insertions(+), 96 deletions(-) diff --git a/imports/plugins/included/product-admin/client/hooks/useProduct.js b/imports/plugins/included/product-admin/client/hooks/useProduct.js index 213ed50df4..6f38e54ddf 100644 --- a/imports/plugins/included/product-admin/client/hooks/useProduct.js +++ b/imports/plugins/included/product-admin/client/hooks/useProduct.js @@ -1,98 +1,22 @@ import { useState, useCallback } from "react"; -import gql from "graphql-tag"; import { useHistory, useParams } from "react-router-dom"; import { useMutation, useQuery } from "@apollo/react-hooks"; import { Meteor } from "meteor/meteor"; import i18next from "i18next"; import useCurrentShopId from "/imports/client/ui/hooks/useCurrentShopId"; import { useSnackbar } from "notistack"; -import PRODUCT_QUERY from "./ProductQuery"; -import UPDATE_PRODUCT from "./UpdateProductMutation"; -import UpdateProductVariantMutation from "./UpdateProductVariantMutation"; - -const ARCHIVE_PRODUCTS = gql` - mutation archiveProducts($input: ArchiveProductsInput!) { - archiveProducts(input: $input) { - products { - _id - } - } - } -`; - -const CLONE_PRODUCTS = gql` - mutation cloneProducts($input: CloneProductsInput!) { - cloneProducts(input: $input) { - products { - _id - } - } - } -`; -const CREATE_VARIANT = gql` -mutation createProductVariant($input: CreateProductVariantInput!) { - createProductVariant(input: $input) { - variant { - _id - } - } -} -`; - -const CLONE_PRODUCT_VARIANTS = gql` - mutation cloneProducts($input: CloneProductVariantsInput!) { - cloneProductVariants(input: $input) { - variants { - _id - } - } - } -`; - - -const ARCHIVE_PRODUCT_VARIANTS = gql` - mutation cloneProducts($input: ArchiveProductVariantsInput!) { - archiveProductVariants(input: $input) { - variants { - _id - } - } - } -`; - -const PUBLISH_TO_CATALOG = gql` - mutation ($productIds: [ID]!) { - publishProductsToCatalog(productIds: $productIds) { - product { - productId - title - isDeleted - supportedFulfillmentTypes - variants { - _id - title - options { - _id - title - } - } - } - } - } -`; - -const updateProductVariantPricesMutation = gql` - mutation updateProductVariantPrices($input: UpdateProductVariantPricesInput!) { - updateProductVariantPrices(input: $input) { - variant { - _id - price - compareAtPrice - } - } - } -`; +// GraphQL Queries / Mutations +import ArchiveProductsMutation from "../graphql/mutations/archiveProducts"; +import ArchiveProductVariantsMutation from "../graphql/mutations/archiveProductVariants"; +import CloneProductsMutation from "../graphql/mutations/cloneProducts"; +import CloneProductVariantsMutation from "../graphql/mutations/cloneProductVariants"; +import CreateProductVariantMutation from "../graphql/mutations/createProductVariant"; +import ProductQuery from "../graphql/queries/product"; +import PublishProductsToCatalogMutation from "../graphql/mutations/publishProductsToCatalog"; +import UpdateProductMutation from "../graphql/mutations/updateProduct"; +import UpdateProductVariantMutation from "../graphql/mutations/updateProductVariant"; +import UpdateProductVariantPricesMutation from "../graphql/mutations/updateProductVariantPrices"; /** * Restore an archived product @@ -123,15 +47,15 @@ function useProduct(args = {}) { const [newMetaField, setNewMetaField] = useState({ key: "", value: "" }); const history = useHistory(); const routeParams = useParams(); - const [updateProduct] = useMutation(UPDATE_PRODUCT); - const [archiveProducts] = useMutation(ARCHIVE_PRODUCTS); - const [cloneProducts] = useMutation(CLONE_PRODUCTS); - const [createProductVariant] = useMutation(CREATE_VARIANT); + const [updateProduct] = useMutation(UpdateProductMutation); + const [archiveProducts] = useMutation(ArchiveProductsMutation); + const [cloneProducts] = useMutation(CloneProductsMutation); + const [createProductVariant] = useMutation(CreateProductVariantMutation); const [updateProductVariant] = useMutation(UpdateProductVariantMutation); - const [cloneProductVariants] = useMutation(CLONE_PRODUCT_VARIANTS); - const [archiveProductVariants] = useMutation(ARCHIVE_PRODUCT_VARIANTS); - const [publishProductsToCatalog] = useMutation(PUBLISH_TO_CATALOG); - const [updateProductVariantPrices] = useMutation(updateProductVariantPricesMutation); + const [cloneProductVariants] = useMutation(CloneProductVariantsMutation); + const [archiveProductVariants] = useMutation(ArchiveProductVariantsMutation); + const [publishProductsToCatalog] = useMutation(PublishProductsToCatalogMutation); + const [updateProductVariantPrices] = useMutation(UpdateProductVariantPricesMutation); const [currentShopId] = useCurrentShopId(); @@ -140,7 +64,7 @@ function useProduct(args = {}) { const optionId = routeParams.optionId || optionIdProp; const shopId = routeParams.shopId || currentShopId; - const { data: productQueryResult, isLoading, refetch: refetchProduct } = useQuery(PRODUCT_QUERY, { + const { data: productQueryResult, isLoading, refetch: refetchProduct } = useQuery(ProductQuery, { variables: { productId, shopId From 9ebd0b21725f67237b242e43595c2b71af217735 Mon Sep 17 00:00:00 2001 From: Mike Murray Date: Tue, 10 Mar 2020 10:07:44 -0700 Subject: [PATCH 13/28] feat: use product with variants fragment Signed-off-by: Mike Murray --- .../product-admin/client/graphql/mutations/updateProduct.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/imports/plugins/included/product-admin/client/graphql/mutations/updateProduct.js b/imports/plugins/included/product-admin/client/graphql/mutations/updateProduct.js index 5916d8d19b..a2010ab6a3 100644 --- a/imports/plugins/included/product-admin/client/graphql/mutations/updateProduct.js +++ b/imports/plugins/included/product-admin/client/graphql/mutations/updateProduct.js @@ -1,11 +1,13 @@ import gql from "graphql-tag"; +import Product from "../fragments/productWithVariants"; export default gql` mutation updateProduct($input: UpdateProductInput!){ updateProduct(input: $input){ product { - isVisible + ...Product } } -} + } + ${Product} `; From ec8dd1c38fa6aa0fd8add0d4393c1af71566db4f Mon Sep 17 00:00:00 2001 From: Mike Murray Date: Tue, 10 Mar 2020 10:08:03 -0700 Subject: [PATCH 14/28] chore: remove unused file Signed-off-by: Mike Murray --- .../hooks/CreateProductVariantMutation.js | 100 ------------------ 1 file changed, 100 deletions(-) delete mode 100644 imports/plugins/included/product-admin/client/hooks/CreateProductVariantMutation.js diff --git a/imports/plugins/included/product-admin/client/hooks/CreateProductVariantMutation.js b/imports/plugins/included/product-admin/client/hooks/CreateProductVariantMutation.js deleted file mode 100644 index 0b93ac6305..0000000000 --- a/imports/plugins/included/product-admin/client/hooks/CreateProductVariantMutation.js +++ /dev/null @@ -1,100 +0,0 @@ -import gql from "graphql-tag"; - -export default gql` - mutation createProductVariant($input: CreateProductVariantInput!) { - createProductVariant(input: $input) { - product { - _id - currentProductHash - description - isDeleted - isVisible - metaDescription - metafields { - key - value - } - originCountry - pageTitle - productType - publishedAt - publishedProductHash - shop { - _id - } - slug - socialMetadata { - message - service - } - supportedFulfillmentTypes - tagIds - tags { - nodes { - _id - name - } - } - title - updatedAt - vendor - variants { - _id - attributeLabel - barcode - height - index - isDeleted - isVisible - length - metafields { - key - value - } - minOrderQuantity - optionTitle - originCountry - shop { - _id - } - sku - title - updatedAt - weight - width - isTaxable - taxCode - taxDescription - options { - _id - attributeLabel - barcode - height - index - isDeleted - isVisible - length - metafields { - key - value - } - minOrderQuantity - optionTitle - originCountry - shop { - _id - } - sku - title - updatedAt - weight - width - isTaxable - taxCode - taxDescription - } - } - } - } - } -`; From cd27437944c4dca15852e49dcb4be1288e1b0446 Mon Sep 17 00:00:00 2001 From: Mike Murray Date: Tue, 10 Mar 2020 10:08:07 -0700 Subject: [PATCH 15/28] chore: remove unused file Signed-off-by: Mike Murray --- .../client/hooks/ProductQuery.js | 133 ------------------ 1 file changed, 133 deletions(-) delete mode 100644 imports/plugins/included/product-admin/client/hooks/ProductQuery.js diff --git a/imports/plugins/included/product-admin/client/hooks/ProductQuery.js b/imports/plugins/included/product-admin/client/hooks/ProductQuery.js deleted file mode 100644 index 919510adc9..0000000000 --- a/imports/plugins/included/product-admin/client/hooks/ProductQuery.js +++ /dev/null @@ -1,133 +0,0 @@ -import gql from "graphql-tag"; - -export default gql` - query product($productId: ID!, $shopId: ID!) { - product(productId: $productId, shopId: $shopId) { - _id - currentProductHash - description - isDeleted - isVisible - media { - _id - URLs { - small - medium - large - original - thumbnail - } - } - metaDescription - metafields { - key - value - } - originCountry - pageTitle - productType - publishedAt - publishedProductHash - shop { - _id - } - shouldAppearInSitemap - slug - socialMetadata { - message - service - } - supportedFulfillmentTypes - tagIds - tags { - nodes { - _id - name - } - } - title - updatedAt - vendor - variants { - _id - attributeLabel - barcode - compareAtPrice - height - index - isDeleted - isVisible - length - media { - _id - URLs { - small - medium - large - original - thumbnail - } - } - metafields { - key - value - } - minOrderQuantity - optionTitle - originCountry - price - shop { - _id - } - sku - title - updatedAt - weight - width - isTaxable - taxCode - taxDescription - options { - _id - attributeLabel - barcode - compareAtPrice - height - index - isDeleted - isVisible - length - media { - _id - URLs { - small - medium - large - original - thumbnail - } - } - metafields { - key - value - } - minOrderQuantity - optionTitle - originCountry - price - shop { - _id - } - sku - title - updatedAt - weight - width - isTaxable - taxCode - taxDescription - } - } - } - } -`; From 3b8646e31030c0a3017dc1366c73285a34c4327c Mon Sep 17 00:00:00 2001 From: Mike Murray Date: Tue, 10 Mar 2020 10:08:11 -0700 Subject: [PATCH 16/28] chore: remove unused file Signed-off-by: Mike Murray --- .../client/hooks/UpdateProductMutation.js | 101 ------------------ 1 file changed, 101 deletions(-) delete mode 100644 imports/plugins/included/product-admin/client/hooks/UpdateProductMutation.js diff --git a/imports/plugins/included/product-admin/client/hooks/UpdateProductMutation.js b/imports/plugins/included/product-admin/client/hooks/UpdateProductMutation.js deleted file mode 100644 index 00d7a74be0..0000000000 --- a/imports/plugins/included/product-admin/client/hooks/UpdateProductMutation.js +++ /dev/null @@ -1,101 +0,0 @@ -import gql from "graphql-tag"; - -export default gql` - mutation updateProduct($input: UpdateProductInput!) { - updateProduct(input: $input) { - product { - _id - currentProductHash - description - isDeleted - isVisible - metaDescription - metafields { - key - value - } - originCountry - pageTitle - productType - publishedAt - publishedProductHash - shop { - _id - } - shouldAppearInSitemap - slug - socialMetadata { - message - service - } - supportedFulfillmentTypes - tagIds - tags { - nodes { - _id - name - } - } - title - updatedAt - vendor - variants { - _id - attributeLabel - barcode - height - index - isDeleted - isVisible - length - metafields { - key - value - } - minOrderQuantity - optionTitle - originCountry - shop { - _id - } - sku - title - updatedAt - weight - width - isTaxable - taxCode - taxDescription - options { - _id - attributeLabel - barcode - height - index - isDeleted - isVisible - length - metafields { - key - value - } - minOrderQuantity - optionTitle - originCountry - shop { - _id - } - sku - title - updatedAt - weight - width - isTaxable - taxCode - taxDescription - } - } - } - } - } -`; From bd102d5d88ea48f016e72a842bfcb3254e3277fd Mon Sep 17 00:00:00 2001 From: Mike Murray Date: Tue, 10 Mar 2020 10:08:15 -0700 Subject: [PATCH 17/28] chore: remove unused file Signed-off-by: Mike Murray --- .../hooks/UpdateProductVariantMutation.js | 36 ------------------- 1 file changed, 36 deletions(-) delete mode 100644 imports/plugins/included/product-admin/client/hooks/UpdateProductVariantMutation.js diff --git a/imports/plugins/included/product-admin/client/hooks/UpdateProductVariantMutation.js b/imports/plugins/included/product-admin/client/hooks/UpdateProductVariantMutation.js deleted file mode 100644 index 2e6383c76a..0000000000 --- a/imports/plugins/included/product-admin/client/hooks/UpdateProductVariantMutation.js +++ /dev/null @@ -1,36 +0,0 @@ -import gql from "graphql-tag"; - -export default gql` - mutation updateProductVariant($input: UpdateProductVariantInput!) { - updateProductVariant(input: $input) { - variant { - _id - attributeLabel - barcode - height - index - isDeleted - isVisible - length - metafields { - key - value - } - minOrderQuantity - optionTitle - originCountry - shop { - _id - } - sku - title - updatedAt - weight - width - isTaxable - taxCode - taxDescription - } - } - } -`; From 7d2c64208c8b50f7dadabb48e3a3902c750529d9 Mon Sep 17 00:00:00 2001 From: Mike Murray Date: Tue, 10 Mar 2020 10:35:59 -0700 Subject: [PATCH 18/28] fix: skip query when `shopId` is undefined Signed-off-by: Mike Murray --- .../plugins/included/product-admin/client/hooks/useProduct.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/imports/plugins/included/product-admin/client/hooks/useProduct.js b/imports/plugins/included/product-admin/client/hooks/useProduct.js index 6f38e54ddf..cee19d11ff 100644 --- a/imports/plugins/included/product-admin/client/hooks/useProduct.js +++ b/imports/plugins/included/product-admin/client/hooks/useProduct.js @@ -68,7 +68,8 @@ function useProduct(args = {}) { variables: { productId, shopId - } + }, + skip: !shopId }); const { product } = productQueryResult || {}; From 6cd0407d5fe1ba80503dcb5bd367b67554ae18b8 Mon Sep 17 00:00:00 2001 From: Mike Murray Date: Tue, 10 Mar 2020 10:36:09 -0700 Subject: [PATCH 19/28] fix: skip queries when `shopId` is undefined Signed-off-by: Mike Murray --- .../included/simple-inventory/client/useVariantInventory.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/imports/plugins/included/simple-inventory/client/useVariantInventory.js b/imports/plugins/included/simple-inventory/client/useVariantInventory.js index 1a4764999b..bffe449364 100644 --- a/imports/plugins/included/simple-inventory/client/useVariantInventory.js +++ b/imports/plugins/included/simple-inventory/client/useVariantInventory.js @@ -148,14 +148,16 @@ function useVariantInventory(args = {}) { }, [enqueueSnackbar, productId, productVariantId, recalculateReservedSimpleInventory, shopId]); const { data: inventoryQueryResult, isLoading: isLoadingInventory, refetch: refetchInventory } = useQuery(getInventoryInfo, { - variables: getInventoryInfoVariables + variables: getInventoryInfoVariables, + skip: !shopId }); const { data: productQueryResult, isLoading: isLoadingProduct, refetch: refetchProduct } = useQuery(productQuery, { variables: { productId, shopId - } + }, + skip: !shopId }); const { product } = productQueryResult || {}; From b457733343226059bd6cff17550e245a19c6ccb9 Mon Sep 17 00:00:00 2001 From: Mike Murray Date: Tue, 10 Mar 2020 10:36:28 -0700 Subject: [PATCH 20/28] chore: remove commented code Signed-off-by: Mike Murray --- .../plugins/included/product-admin/client/hooks/useProduct.js | 1 - 1 file changed, 1 deletion(-) diff --git a/imports/plugins/included/product-admin/client/hooks/useProduct.js b/imports/plugins/included/product-admin/client/hooks/useProduct.js index cee19d11ff..781ea3a2fe 100644 --- a/imports/plugins/included/product-admin/client/hooks/useProduct.js +++ b/imports/plugins/included/product-admin/client/hooks/useProduct.js @@ -76,7 +76,6 @@ function useProduct(args = {}) { let variant; let option; - // let parentVariant; if (product && variantId) { variant = product.variants.find(({ _id }) => _id === variantId); From fdb84e006aece30532b489006e9fd0d38bc657eb Mon Sep 17 00:00:00 2001 From: Mike Murray Date: Wed, 11 Mar 2020 09:47:12 -0700 Subject: [PATCH 21/28] feat: adjust padding Signed-off-by: Mike Murray --- .../included/product-admin/client/layouts/ProductDetail.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/imports/plugins/included/product-admin/client/layouts/ProductDetail.js b/imports/plugins/included/product-admin/client/layouts/ProductDetail.js index 6e1796bb32..f7b43be35a 100644 --- a/imports/plugins/included/product-admin/client/layouts/ProductDetail.js +++ b/imports/plugins/included/product-admin/client/layouts/ProductDetail.js @@ -43,11 +43,14 @@ function ProductDetail(props) { AppBarComponent={} PrimaryComponent={ <> - + - + From f897134821e28c45ae86599136fa2a0a89f91d63 Mon Sep 17 00:00:00 2001 From: Mike Murray Date: Wed, 11 Mar 2020 09:47:27 -0700 Subject: [PATCH 22/28] feat: adjust padding Signed-off-by: Mike Murray --- .../product-admin/client/components/VariantListItemContainer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imports/plugins/included/product-admin/client/components/VariantListItemContainer.js b/imports/plugins/included/product-admin/client/components/VariantListItemContainer.js index 0ed04a4036..2bda63e46f 100644 --- a/imports/plugins/included/product-admin/client/components/VariantListItemContainer.js +++ b/imports/plugins/included/product-admin/client/components/VariantListItemContainer.js @@ -12,7 +12,7 @@ import ChevronRight from "mdi-material-ui/ChevronRight"; const useStyles = makeStyles((theme) => ({ expandButton: { position: "absolute", - left: theme.spacing(1), + left: theme.spacing(2), top: "50%", transform: "translateY(-50%)", zIndex: 1 From a7426e077c07b5b43dc00086af3d833a9aea9d59 Mon Sep 17 00:00:00 2001 From: Mike Murray Date: Wed, 11 Mar 2020 09:54:41 -0700 Subject: [PATCH 23/28] feat: update list item selected styles Signed-off-by: Mike Murray --- .../client/blocks/VariantList.js | 45 ++++++++++++++++--- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/imports/plugins/included/product-admin/client/blocks/VariantList.js b/imports/plugins/included/product-admin/client/blocks/VariantList.js index 254f446872..d9e230797d 100644 --- a/imports/plugins/included/product-admin/client/blocks/VariantList.js +++ b/imports/plugins/included/product-admin/client/blocks/VariantList.js @@ -19,27 +19,54 @@ const useStyles = makeStyles((theme) => ({ listItemContainer: { "&:hover $listItemAction": { display: "block" + }, + [theme.breakpoints.up("md")]: { + paddingLeft: theme.spacing(2), + paddingRight: theme.spacing(2) } }, listItem: { "paddingLeft": theme.spacing(7), - "&$focusVisible": { - backgroundColor: "red" + "&$selected $listItemPrimaryText, &$selected:hover $listItemPrimaryText": { + fontWeight: theme.typography.fontWeightBold + }, + [theme.breakpoints.down("sm")]: { + paddingLeft: theme.spacing(8) }, - "&$selected, &$selected:hover": { - backgroundColor: "white", - boxShadow: theme.shadows[2], - borderRadius: theme.shape.borderRadius + [theme.breakpoints.up("md")]: { + "&$selected, &$selected:hover": { + backgroundColor: "transparent" + } + } + }, + listItemButton: { + "transition": theme.transitions.create("background-color", { + duration: theme.transitions.duration.shortest + }), + "&:hover": { + "textDecoration": "none", + "backgroundColor": "white", + "boxShadow": theme.shadows[2], + "borderRadius": theme.shape.borderRadius, + "@media (hover: none)": { + backgroundColor: "transparent", + boxShadow: "none", + borderRadius: 0 + } } }, nested: { - paddingLeft: theme.spacing(4) + [theme.breakpoints.up("md")]: { + paddingLeft: theme.spacing(6) + } }, listItemAction: { display: "none" }, /* Pseudo-class applied to the `component`'s `focusVisibleClassName` prop if `button={true}`. */ focusVisible: {}, + /* Pseudo-class applied to the `ListItemText`'s `primary label` when `selected`. */ + listItemPrimaryText: {}, /* Pseudo-class applied to the root element if `selected={true}`. */ selected: {} })); @@ -119,6 +146,7 @@ export default function VariantList() { ContainerComponent={VariantListItemContainer} classes={{ root: classes.listItem, + button: classes.listItemButton, selected: classes.selected }} className={clsx({ @@ -136,6 +164,9 @@ export default function VariantList() { }} > From 41812953ee7ef7928b37deea00028fae34a59f9f Mon Sep 17 00:00:00 2001 From: Mike Murray Date: Wed, 11 Mar 2020 09:57:06 -0700 Subject: [PATCH 24/28] feat: remove padding Signed-off-by: Mike Murray --- .../product-admin/client/blocks/ProductHeader.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/imports/plugins/included/product-admin/client/blocks/ProductHeader.js b/imports/plugins/included/product-admin/client/blocks/ProductHeader.js index 336680229a..c0b1ce33d3 100644 --- a/imports/plugins/included/product-admin/client/blocks/ProductHeader.js +++ b/imports/plugins/included/product-admin/client/blocks/ProductHeader.js @@ -13,10 +13,6 @@ import { makeStyles, Box, Divider } from "@material-ui/core"; import useProduct from "../hooks/useProduct"; const useStyles = makeStyles((theme) => ({ - root: { - paddingTop: theme.spacing(2), - paddingBottom: theme.spacing(2) - }, breadcrumbs: { display: "flex", alignItems: "center", @@ -104,12 +100,10 @@ function ProductHeader({ shouldDisplayStatus }) { } return ( -
+ <> -
+ ); } From 1a91d6886bceaa63e4e16b9b284c97d12830e1af Mon Sep 17 00:00:00 2001 From: Mike Murray Date: Wed, 11 Mar 2020 10:57:33 -0700 Subject: [PATCH 25/28] fix: use variant fragment Signed-off-by: Mike Murray --- .../client/graphql/mutations/createProductVariant.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/imports/plugins/included/product-admin/client/graphql/mutations/createProductVariant.js b/imports/plugins/included/product-admin/client/graphql/mutations/createProductVariant.js index 7394ce705d..a196687d6d 100644 --- a/imports/plugins/included/product-admin/client/graphql/mutations/createProductVariant.js +++ b/imports/plugins/included/product-admin/client/graphql/mutations/createProductVariant.js @@ -1,13 +1,13 @@ import gql from "graphql-tag"; -import Product from "../fragments/productWithVariants"; +import ProductVariant from "../fragments/productVariant"; export default gql` mutation createProductVariant($input: CreateProductVariantInput!) { createProductVariant(input: $input) { - product { - ...Product + variant { + ...ProductVariant } } } - ${Product} + ${ProductVariant} `; From 2904f3ae6dd399346e153f13d3977e458db07ba0 Mon Sep 17 00:00:00 2001 From: Mike Murray Date: Wed, 11 Mar 2020 10:57:49 -0700 Subject: [PATCH 26/28] chore: update lockfile Signed-off-by: Mike Murray --- package-lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index dcf5a3d9c7..9fc405186c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3914,7 +3914,7 @@ "dependencies": { "buffer": { "version": "4.9.1", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz", + "resolved": "http://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz", "integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg=", "requires": { "base64-js": "^1.0.2", From 4f70af9868f584c910d9efd1f78337b64eb8fbf2 Mon Sep 17 00:00:00 2001 From: Mike Murray Date: Wed, 11 Mar 2020 17:39:28 -0700 Subject: [PATCH 27/28] fix: padding Signed-off-by: Mike Murray --- .../included/product-admin/client/layouts/ProductDetail.js | 1 + 1 file changed, 1 insertion(+) diff --git a/imports/plugins/included/product-admin/client/layouts/ProductDetail.js b/imports/plugins/included/product-admin/client/layouts/ProductDetail.js index f7b43be35a..61bfa220e3 100644 --- a/imports/plugins/included/product-admin/client/layouts/ProductDetail.js +++ b/imports/plugins/included/product-admin/client/layouts/ProductDetail.js @@ -46,6 +46,7 @@ function ProductDetail(props) { From 0663feb1d76e6e6de42d26cdd8acedfae84d1d50 Mon Sep 17 00:00:00 2001 From: Mike Murray Date: Wed, 11 Mar 2020 17:39:40 -0700 Subject: [PATCH 28/28] fix: styles Signed-off-by: Mike Murray --- .../product-admin/client/blocks/VariantList.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/imports/plugins/included/product-admin/client/blocks/VariantList.js b/imports/plugins/included/product-admin/client/blocks/VariantList.js index d9e230797d..705cf1691f 100644 --- a/imports/plugins/included/product-admin/client/blocks/VariantList.js +++ b/imports/plugins/included/product-admin/client/blocks/VariantList.js @@ -26,16 +26,19 @@ const useStyles = makeStyles((theme) => ({ } }, listItem: { - "paddingLeft": theme.spacing(7), "&$selected $listItemPrimaryText, &$selected:hover $listItemPrimaryText": { fontWeight: theme.typography.fontWeightBold }, - [theme.breakpoints.down("sm")]: { + [theme.breakpoints.up("xs")]: { paddingLeft: theme.spacing(8) }, [theme.breakpoints.up("md")]: { - "&$selected, &$selected:hover": { + "paddingLeft": theme.spacing(7), + "&$selected": { backgroundColor: "transparent" + }, + "&$selected:hover": { + backgroundColor: "white" } } }, @@ -58,10 +61,15 @@ const useStyles = makeStyles((theme) => ({ nested: { [theme.breakpoints.up("md")]: { paddingLeft: theme.spacing(6) + }, + [theme.breakpoints.up("xs")]: { + paddingLeft: theme.spacing(4) } }, listItemAction: { - display: "none" + [theme.breakpoints.up("md")]: { + display: "none" + } }, /* Pseudo-class applied to the `component`'s `focusVisibleClassName` prop if `button={true}`. */ focusVisible: {},