mirror of
https://github.com/strapi/strapi.git
synced 2025-11-03 03:17:11 +00:00
track marketplace activity (#10495)
This commit is contained in:
parent
4e125cd5fe
commit
a83c8239e9
@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import React, { useEffect, useRef } from 'react';
|
||||||
import { LoadingIndicatorPage, useGlobalContext, request } from 'strapi-helper-plugin';
|
import { LoadingIndicatorPage, useGlobalContext, request } from 'strapi-helper-plugin';
|
||||||
import { Header } from '@buffetjs/custom';
|
import { Header } from '@buffetjs/custom';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
@ -10,20 +10,28 @@ import Wrapper from './Wrapper';
|
|||||||
|
|
||||||
const MarketPlacePage = () => {
|
const MarketPlacePage = () => {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const { autoReload, currentEnvironment, formatMessage, plugins } = useGlobalContext();
|
const { autoReload, emitEvent, currentEnvironment, formatMessage, plugins } = useGlobalContext();
|
||||||
const { error, isLoading, data } = useFetchPluginsFromMarketPlace();
|
const { error, isLoading, data } = useFetchPluginsFromMarketPlace();
|
||||||
|
const emitEventRef = useRef(emitEvent);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
emitEventRef.current('didGotToMarketplace');
|
||||||
|
}, []);
|
||||||
|
|
||||||
if (isLoading || error) {
|
if (isLoading || error) {
|
||||||
return <LoadingIndicatorPage />;
|
return <LoadingIndicatorPage />;
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleDownloadPlugin = async pluginId => {
|
const handleDownloadPlugin = async pluginId => {
|
||||||
|
emitEvent('willInstallPlugin', { plugin: pluginId });
|
||||||
|
|
||||||
// Force the Overlayblocker to be displayed
|
// Force the Overlayblocker to be displayed
|
||||||
const overlayblockerParams = {
|
const overlayblockerParams = {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
title: 'app.components.InstallPluginPage.Download.title',
|
title: 'app.components.InstallPluginPage.Download.title',
|
||||||
description: 'app.components.InstallPluginPage.Download.description',
|
description: 'app.components.InstallPluginPage.Download.description',
|
||||||
};
|
};
|
||||||
|
|
||||||
// Lock the app
|
// Lock the app
|
||||||
strapi.lockApp(overlayblockerParams);
|
strapi.lockApp(overlayblockerParams);
|
||||||
|
|
||||||
@ -38,6 +46,7 @@ const MarketPlacePage = () => {
|
|||||||
const response = await request('/admin/plugins/install', opts, overlayblockerParams);
|
const response = await request('/admin/plugins/install', opts, overlayblockerParams);
|
||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
|
emitEvent('didInstallPlugin', { plugin: pluginId });
|
||||||
// Reload the app
|
// Reload the app
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user