mirror of
https://github.com/strapi/strapi.git
synced 2025-12-12 07:27:46 +00:00
Remove sage from Marketplace
Signed-off-by: soupette <cyril.lpz@gmail.com>
This commit is contained in:
parent
a5cfe98c70
commit
b7c09a816d
@ -80,7 +80,7 @@ class PluginCard extends React.Component {
|
||||
} else if (currentEnvironment !== 'development') {
|
||||
this.setState({ showModalEnv: true });
|
||||
} else if (!isAlreadyInstalled) {
|
||||
downloadPlugin(e);
|
||||
downloadPlugin(id);
|
||||
} else {
|
||||
push('/list-plugins');
|
||||
}
|
||||
@ -152,6 +152,7 @@ class PluginCard extends React.Component {
|
||||
<Button
|
||||
className={`${buttonClass} button`}
|
||||
label={buttonLabel}
|
||||
type="button"
|
||||
onClick={this.handleDownloadPlugin}
|
||||
/>
|
||||
<a
|
||||
|
||||
@ -28,7 +28,8 @@ import LeftMenu from '../LeftMenu';
|
||||
import ListPluginsPage from '../ListPluginsPage';
|
||||
import LocaleToggle from '../LocaleToggle';
|
||||
import HomePage from '../HomePage';
|
||||
import Marketplace from '../Marketplace';
|
||||
// import Marketplace from '../Marketplace';
|
||||
import Marketplace from '../MarketplacePage';
|
||||
import NotFoundPage from '../NotFoundPage';
|
||||
import OnboardingVideos from '../Onboarding';
|
||||
import SettingsPage from '../SettingsPage';
|
||||
@ -135,7 +136,7 @@ export class Admin extends React.Component {
|
||||
disableGlobalOverlayBlocker,
|
||||
emitEvent,
|
||||
enableGlobalOverlayBlocker,
|
||||
intl: { formatMessage },
|
||||
intl: { formatMessage, locale },
|
||||
updatePlugin,
|
||||
} = this.props;
|
||||
|
||||
@ -154,6 +155,7 @@ export class Admin extends React.Component {
|
||||
autoReload={autoReload}
|
||||
emitEvent={emitEvent}
|
||||
currentEnvironment={currentEnvironment}
|
||||
currentLocale={locale}
|
||||
disableGlobalOverlayBlocker={disableGlobalOverlayBlocker}
|
||||
enableGlobalOverlayBlocker={enableGlobalOverlayBlocker}
|
||||
formatMessage={formatMessage}
|
||||
@ -219,6 +221,7 @@ export class Admin extends React.Component {
|
||||
Admin.defaultProps = {
|
||||
intl: {
|
||||
formatMessage: () => {},
|
||||
locale: 'en',
|
||||
},
|
||||
};
|
||||
|
||||
@ -240,6 +243,7 @@ Admin.propTypes = {
|
||||
}).isRequired,
|
||||
intl: PropTypes.shape({
|
||||
formatMessage: PropTypes.func,
|
||||
locale: PropTypes.string,
|
||||
}),
|
||||
location: PropTypes.object.isRequired,
|
||||
setAppError: PropTypes.func.isRequired,
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
import styled from 'styled-components';
|
||||
|
||||
const Wrapper = styled.div`
|
||||
padding: 18px 30px !important;
|
||||
> div:first-child {
|
||||
margin-bottom: 11px;
|
||||
}
|
||||
`;
|
||||
|
||||
export default Wrapper;
|
||||
@ -0,0 +1,106 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import {
|
||||
LoadingIndicatorPage,
|
||||
useGlobalContext,
|
||||
request,
|
||||
} from 'strapi-helper-plugin';
|
||||
import { Header } from '@buffetjs/custom';
|
||||
|
||||
import PageTitle from '../../components/PageTitle';
|
||||
import PluginCard from '../../components/PluginCard';
|
||||
import Wrapper from './Wrapper';
|
||||
import useFetch from './useFetch';
|
||||
|
||||
const MarketPlacePage = ({ history }) => {
|
||||
const {
|
||||
autoReload,
|
||||
currentEnvironment,
|
||||
formatMessage,
|
||||
plugins,
|
||||
} = useGlobalContext();
|
||||
const { isLoading, data } = useFetch();
|
||||
|
||||
if (isLoading) {
|
||||
return <LoadingIndicatorPage />;
|
||||
}
|
||||
|
||||
const handleDownloadPlugin = async 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);
|
||||
|
||||
try {
|
||||
const opts = {
|
||||
method: 'POST',
|
||||
body: {
|
||||
plugin: pluginId,
|
||||
port: window.location.port,
|
||||
},
|
||||
};
|
||||
const response = await request(
|
||||
'/admin/plugins/install',
|
||||
opts,
|
||||
overlayblockerParams
|
||||
);
|
||||
|
||||
if (response.ok) {
|
||||
// Reload the app
|
||||
window.location.reload();
|
||||
}
|
||||
} catch (err) {
|
||||
strapi.unlockApp();
|
||||
strapi.notification.error('notification.error');
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<PageTitle
|
||||
title={formatMessage({
|
||||
id: 'app.components.InstallPluginPage.helmet',
|
||||
})}
|
||||
/>
|
||||
<Wrapper className="container-fluid">
|
||||
<Header
|
||||
title={{
|
||||
label: formatMessage({
|
||||
id: 'app.components.InstallPluginPage.title',
|
||||
}),
|
||||
}}
|
||||
content={formatMessage({
|
||||
id: 'app.components.InstallPluginPage.description',
|
||||
})}
|
||||
actions={[]}
|
||||
/>
|
||||
<div className="row" style={{ paddingTop: '4.1rem' }}>
|
||||
{data.map(plugin => {
|
||||
return (
|
||||
<PluginCard
|
||||
autoReload={autoReload}
|
||||
currentEnvironment={currentEnvironment}
|
||||
downloadPlugin={handleDownloadPlugin}
|
||||
key={plugin.id}
|
||||
history={history}
|
||||
plugin={plugin}
|
||||
showSupportUsButton={false}
|
||||
isAlreadyInstalled={plugins[plugin.id] !== undefined}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</Wrapper>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
MarketPlacePage.propTypes = {
|
||||
history: PropTypes.object.isRequired,
|
||||
};
|
||||
|
||||
export default MarketPlacePage;
|
||||
@ -0,0 +1,52 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import axios from 'axios';
|
||||
import { useGlobalContext } from 'strapi-helper-plugin';
|
||||
|
||||
const useFetch = () => {
|
||||
const { currentLocale } = useGlobalContext();
|
||||
const [state, setState] = useState({
|
||||
error: false,
|
||||
isLoading: true,
|
||||
data: null,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
const CancelToken = axios.CancelToken;
|
||||
const source = CancelToken.source();
|
||||
|
||||
const getData = async () => {
|
||||
try {
|
||||
const { data } = await axios.get(
|
||||
'https://marketplace.strapi.io/plugins',
|
||||
{
|
||||
cancelToken: source.token,
|
||||
params: { lang: currentLocale },
|
||||
}
|
||||
);
|
||||
|
||||
setState({
|
||||
isLoading: false,
|
||||
data,
|
||||
error: false,
|
||||
});
|
||||
} catch (err) {
|
||||
if (axios.isCancel(err)) {
|
||||
// Silent
|
||||
} else {
|
||||
// handle error
|
||||
setState(prev => ({ ...prev, isLoading: false, error: true }));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
getData();
|
||||
|
||||
return () => {
|
||||
source.cancel();
|
||||
};
|
||||
}, [currentLocale]);
|
||||
|
||||
return state;
|
||||
};
|
||||
|
||||
export default useFetch;
|
||||
Loading…
x
Reference in New Issue
Block a user