-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Install and activate Ecomdash plugin on Sales Channel page
- Loading branch information
Showing
5 changed files
with
120 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<?php return array('dependencies' => array('lodash', 'moment', 'react', 'react-dom', 'wp-api-fetch', 'wp-data', 'wp-date', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => '2efef9d141f6285fbfaa'); | ||
<?php return array('dependencies' => array('lodash', 'moment', 'react', 'react-dom', 'wp-api-fetch', 'wp-data', 'wp-date', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => '40b3f3a630c03b873aa1'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { __ } from "@wordpress/i18n"; | ||
import useSWRMutation from "swr/mutation"; | ||
import { PluginsSdk } from "../sdk/plugins"; | ||
import { RuntimeSdk } from "../sdk/runtime"; | ||
import { sleep } from "../sdk/sleep"; | ||
|
||
/** @todo Can be made generic as useInstallPlugin */ | ||
|
||
export function useInstallEcomdash({ wpModules }) { | ||
let { notify } = wpModules; | ||
let installEcomdash = useSWRMutation("install-nfd_slug_ecomdash_wordpress_plugin", async () => { | ||
let response = await PluginsSdk.actions.installSync("nfd_slug_ecomdash_wordpress_plugin"); | ||
if (response !== "failed") { | ||
notify.push("nfd_slug_ecomdash_wordpress_plugin-install-status", { | ||
title: "Installed successfully", | ||
variant: "success", | ||
}); | ||
await sleep(1000); | ||
window.location.href = "admin.php?page=bluehost#/store/sales_channel" | ||
window.location.reload(); | ||
} else { | ||
notify.push("nfd_slug_ecomdash_wordpress_plugin-install-status", { | ||
title: "Failed to install", | ||
description: ( | ||
<span> | ||
{__("Please try again, or ", "wp-module-ecommerce")} | ||
<a href={RuntimeSdk.brandSettings.support} target="_blank"> | ||
{__("contact support", "wp-module-ecommerce")} | ||
</a> | ||
</span> | ||
), | ||
variant: "error", | ||
}); | ||
} | ||
}); | ||
let isInstalling = installEcomdash.isMutating; | ||
return [installEcomdash.trigger, isInstalling]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters