From 38d96f7fe930db85d5aac93479b4bb671b3cb576 Mon Sep 17 00:00:00 2001 From: ashrithapradeep <46500357+ashrithapradeep@users.noreply.github.com> Date: Tue, 29 Nov 2022 21:20:09 +0530 Subject: [PATCH] Disabling cards while WooCommerce plugin is unavailable (#43) * Disabling cards while WooCommerce plugin is unavailable * Added disabled property to button and pseudo class * Fixed typo Co-authored-by: Ashritha --- src/components/AdvancedFeatures.js | 5 +- src/components/Card.js | 3 +- src/components/CustomizeStore.js | 7 +- src/components/Dashboard.js | 5 +- src/components/ExtendedCard.js | 1 + src/components/GeneralSettings.js | 11 ++- src/components/ManageProducts.js | 4 +- src/components/MinimalCard.js | 8 +- src/components/SiteStatus.js | 12 ++- src/components/StandardCard.js | 1 + src/configs/AdvancedFeatures.config.js | 6 ++ src/configs/GeneralSettings.config.js | 12 ++- src/configs/ManageProducts.config.js | 9 +- src/sections/SiteStatus.scss | 4 + src/sections/StoreAnalytics.scss | 22 +++++ src/sections/WooCommerceUnavailable.scss | 75 +++++++++++++++ styles.scss | 117 +++-------------------- 17 files changed, 174 insertions(+), 128 deletions(-) create mode 100644 src/sections/StoreAnalytics.scss create mode 100644 src/sections/WooCommerceUnavailable.scss diff --git a/src/components/AdvancedFeatures.js b/src/components/AdvancedFeatures.js index 3ec9780e..88ead2cd 100644 --- a/src/components/AdvancedFeatures.js +++ b/src/components/AdvancedFeatures.js @@ -9,8 +9,9 @@ export function AdvancedFeatures(props) { const isLoading = !(cards ?? []).every( (cardConfig) => cardConfig.isLoading == false ); - - if (isLoading) + let WCUnavailable = plugins?.status?.woocommerce !== "Active"; + + if (isLoading && !WCUnavailable) return (
diff --git a/src/components/Card.js b/src/components/Card.js index 453c4fef..c3d9b54a 100644 --- a/src/components/Card.js +++ b/src/components/Card.js @@ -7,6 +7,7 @@ export function Card({ action, href, variant, + disable, status = "ready", ...props }) { @@ -19,7 +20,7 @@ export function Card({ className="nfd-ecommerce-card" data-variant={variant} type="button" - disabled={status !== "ready"} + disabled={status !== "ready" || disable} onClick={() => { let [page, qs] = href.split("?"); let query = new URLSearchParams(qs); diff --git a/src/components/CustomizeStore.js b/src/components/CustomizeStore.js index 9b1d357d..4b0d5f38 100644 --- a/src/components/CustomizeStore.js +++ b/src/components/CustomizeStore.js @@ -30,8 +30,9 @@ export function CustomizeStore({ plugins }) { let pagesByName = Object.fromEntries( pages?.map((_) => [_["meta_value"], _["ID"]]) ?? [] ); + let WCUnavailable = plugins?.status?.woocommerce !== "Active"; - if (status === undefined) { + if (status === undefined && !WCUnavailable) { return (
{error ? ( @@ -62,6 +63,7 @@ export function CustomizeStore({ plugins }) { key={title} variant="standard" title={title} + disable = {WCUnavailable} status={status === undefined ? "inprogress" : "ready"} action={__("Setup", "wp-module-ecommerce")} href={`post.php?action=edit&post=${pagesByName[dcpage]}`} @@ -73,6 +75,7 @@ export function CustomizeStore({ plugins }) { @@ -81,6 +84,7 @@ export function CustomizeStore({ plugins }) { +
{isLargeViewport ? (