track marketplace activity (#10495)

This commit is contained in:
markkaylor 2021-06-21 11:56:51 +02:00 committed by GitHub
parent 4e125cd5fe
commit a83c8239e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 <LoadingIndicatorPage />;
}
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();
}