diff --git a/packages/strapi-admin/admin/src/containers/MarketplacePage/index.js b/packages/strapi-admin/admin/src/containers/MarketplacePage/index.js index 5301a99021..23fbb65de0 100644 --- a/packages/strapi-admin/admin/src/containers/MarketplacePage/index.js +++ b/packages/strapi-admin/admin/src/containers/MarketplacePage/index.js @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useEffect, useRef } from 'react'; import { LoadingIndicatorPage, useGlobalContext, request } from 'strapi-helper-plugin'; import { Header } from '@buffetjs/custom'; import { useHistory } from 'react-router-dom'; @@ -10,20 +10,28 @@ import Wrapper from './Wrapper'; const MarketPlacePage = () => { const history = useHistory(); - const { autoReload, currentEnvironment, formatMessage, plugins } = useGlobalContext(); + const { autoReload, emitEvent, currentEnvironment, formatMessage, plugins } = useGlobalContext(); const { error, isLoading, data } = useFetchPluginsFromMarketPlace(); + const emitEventRef = useRef(emitEvent); + + useEffect(() => { + emitEventRef.current('didGotToMarketplace'); + }, []); if (isLoading || error) { return ; } const handleDownloadPlugin = async pluginId => { + emitEvent('willInstallPlugin', { plugin: pluginId }); + // Force the Overlayblocker to be displayed const overlayblockerParams = { enabled: true, title: 'app.components.InstallPluginPage.Download.title', description: 'app.components.InstallPluginPage.Download.description', }; + // Lock the app strapi.lockApp(overlayblockerParams); @@ -38,6 +46,7 @@ const MarketPlacePage = () => { const response = await request('/admin/plugins/install', opts, overlayblockerParams); if (response.ok) { + emitEvent('didInstallPlugin', { plugin: pluginId }); // Reload the app window.location.reload(); }