Skip to content

Commit

Permalink
track marketplace activity (#10495)
Browse files Browse the repository at this point in the history
  • Loading branch information
markkaylor committed Jun 21, 2021
1 parent 4e125cd commit a83c823
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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);

Expand All @@ -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();
}
Expand Down

0 comments on commit a83c823

Please sign in to comment.