Fix PR feedback

This commit is contained in:
soupette 2019-09-17 16:04:38 +02:00
parent 6c8a446e0c
commit 6e425923ba
7 changed files with 3 additions and 418 deletions

View File

@ -1,200 +0,0 @@
/*
*
* InstallPluginPopup
*
*/
import React from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
import { Modal, ModalHeader, ModalBody } from 'reactstrap';
import { map } from 'lodash';
import cn from 'classnames';
import { MarketPlaceContext } from '../../contexts/MarketPlace';
import Official from '../Official';
// import StarsContainer from 'components/StarsContainer';
import styles from './styles.scss';
class InstallPluginPopup extends React.Component {
static contextType = MarketPlaceContext;
handleClick = () => {
this.props.history.push({ pathname: this.props.history.location.pathname });
if (!this.props.isAlreadyInstalled) {
this.context.downloadPlugin(this.props.plugin.id);
}
};
toggle = () => {
this.props.history.push({
pathname: this.props.history.location.pathname,
});
};
navLinks = [
{
content: 'app.components.InstallPluginPopup.navLink.description',
name: 'description',
},
{
content: 'app.components.InstallPluginPopup.navLink.screenshots',
name: 'screenshots',
},
{
content: 'app.components.InstallPluginPopup.navLink.avis',
name: 'avis',
},
{
content: 'app.components.InstallPluginPopup.navLink.faq',
name: 'faq',
},
{
content: 'app.components.InstallPluginPopup.navLink.changelog',
name: 'changelog',
},
];
render() {
const descriptions = {
short:
this.props.plugin.id === 'support-us' ? (
<FormattedMessage id={this.props.plugin.description.short} />
) : (
this.props.plugin.description.short
),
long:
this.props.plugin.id === 'support-us' ? (
<FormattedMessage
id={
this.props.plugin.description.long ||
this.props.plugin.description.short
}
/>
) : (
this.props.plugin.description.long ||
this.props.plugin.description.short
),
};
const buttonName = this.props.isAlreadyInstalled
? 'app.components.PluginCard.Button.label.install'
: 'app.components.InstallPluginPopup.downloads';
return (
<Modal
isOpen={this.props.isOpen}
toggle={this.toggle}
className={styles.modalPosition}
>
<ModalHeader toggle={this.toggle} className={styles.modalHeader} />
<ModalBody className={styles.modalBody}>
<div className={styles.wrapper}>
<div className={styles.headerWrapper}>
<div className={styles.logo}>
<img src={`${this.props.plugin.logo}`} alt="icon" />
</div>
<div className={styles.headerInfo}>
<div className={styles.name}>{this.props.plugin.name}</div>
<div className={styles.ratings}>
{/*}
<StarsContainer ratings={this.props.plugin.ratings} />
<div>
<span style={{ fontWeight: '600', color: '#333740', fontSize: '12px'}}>{this.props.plugin.ratings}</span>
<span style={{ fontWeight: '500', color: '#666666', fontSize: '11px' }}>/5</span>
</div>
*/}
<Official style={{ marginTop: '0' }} />
</div>
<div className={styles.headerDescription}>
{descriptions.short}
</div>
<div className={styles.headerButtonContainer}>
<div>
<i
className={`fa fa-${
this.props.plugin.isCompatible ? 'check' : 'times'
}`}
/>
<FormattedMessage
id={`app.components.PluginCard.compatible${
this.props.plugin.id === 'support-us' ? 'Community' : ''
}`}
/>
</div>
<div>
<div>
{/*}
<span style={{ fontWeight: '600' }}>+{this.props.plugin.downloads_nb}k&nbsp;</span><FormattedMessage id="app.components.InstallPluginPopup.downloads" />
*/}
</div>
<div
className={styles.buttonWrapper}
onClick={this.handleClick}
>
<div>
<FormattedMessage id={buttonName} />
</div>
{/* Uncomment whebn prices are running}
<div>{this.props.plugin.price}&nbsp;</div>
*/}
</div>
</div>
</div>
</div>
</div>
</div>
<div className={styles.navContainer}>
{map(this.navLinks, link => {
const isActive =
this.props.history.location.hash.split('::')[1] === link.name;
return (
<div
key={link.name}
className={cn(
isActive ? styles.navLink : '',
link.name !== 'description' ? styles.notAllowed : ''
)}
onClick={() => {
if (link.name === 'description') {
this.props.history.push({
pathname: this.props.history.location.pathname,
hash: `${this.props.plugin.id}::${link.name}`,
});
}
}}
style={
isActive ? { paddingTop: '4px' } : { paddingTop: '6px' }
}
>
<FormattedMessage id={link.content} />
</div>
);
})}
</div>
<div className={styles.pluginDescription}>{descriptions.long}</div>
</ModalBody>
</Modal>
);
}
}
InstallPluginPopup.defaultProps = {
description: {
short: 'app.Components.InstallPluginPopup.noDescription',
},
};
InstallPluginPopup.propTypes = {
description: PropTypes.shape({
long: PropTypes.string,
short: PropTypes.string,
}),
history: PropTypes.object.isRequired,
isAlreadyInstalled: PropTypes.bool.isRequired,
isOpen: PropTypes.bool.isRequired,
plugin: PropTypes.object.isRequired,
};
export default InstallPluginPopup;

View File

@ -1,199 +0,0 @@
.buttonWrapper {
display: flex;
justify-content: space-between;
min-width: 136px;
height: 30px;
margin-left: 20px;
border-radius: 0.3rem;
background: linear-gradient(315deg, #0097F6 0%, #005EEA 100%);
color: white;
font-size: 13px;
font-style: normal;
font-weight: 600;
cursor: pointer;
&:focus {
outline: 0;
}
> div {
text-align: center;
text-transform: capitalize;
&:first-child {
flex-grow: 2;
}
}
}
.headerButtonContainer {
display: flex;
justify-content: space-between;
padding-top: 13px;
line-height: 29px;
> div {
font-size: 13px;
font-style: italic;
}
> div:first-child {
> i {
margin-right: 10px;
}
color: #5A9E06;
}
> div:nth-child(2) {
display: flex;
> span:nth-child(2) {
font-style: normal;
}
}
}
.headerDescription {
height: 48px;
padding-top: 12px;
font-size: 13px;
}
.headerInfo {
flex-grow: 1;
padding-top: 7px;
padding-left: 30px;
}
.headerWrapper {
display: flex;
}
.logo {
flex-shrink: 0;
width: 144px;
height: 144px;
background: #FAFAFB;
border: 1px solid #F3F3F7;
border-radius: 3px;
background-size: contain;
line-height: 144px;
text-align: center;
> img {
min-width: 72px;
// max-height: 72px;
}
}
.modalHeader {
margin: 0 1.4rem !important;
padding: 1.4rem 0 0 0 !important;
border-bottom: 0 !important;
> button {
margin-right: -1rem !important;
color: #C3C5C8;
opacity: 1;
font-size: 1.8rem;
font-weight: 100;
z-index: 999;
&:hover, &:focus {
color: #C3C5C8;
opacity: 1;
outline: 0!important;
cursor: pointer;
}
> span {
display: none;
}
&:before {
-webkit-font-smoothing: antialiased;
content: '\F00d';
font-family: 'FontAwesome';
font-weight: 400;
font-size: 1.2rem;
margin-right: 10px;
}
}
}
.modalBody {
padding: 5px 0px !important;
}
.modalPosition {
> div {
border:none;
border-radius: 2px;
width: 74.5rem;
padding-left: 0;
padding-right: 0;
}
}
.name {
padding-bottom: 1px;
font-size: 16px;
font-weight: 700;
text-transform: uppercase;
}
.navContainer {
display: flex;
justify-content: space-between;
height: 36px;
margin-top: 38px;
padding: 0 30px;
background-color: #FAFAFB;
font-size: 13px;
font-weight: 600;
text-transform: capitalize;
> div {
flex-grow: 2;
text-align: center;
line-height: 23px;
cursor: pointer;
}
}
.navLink {
border-top: 2px solid #1C5DE7;
}
.notAllowed {
opacity: .3;
cursor: not-allowed !important;
}
.pluginDescription {
padding: 24px 30px;
font-size: 13px;
line-height: 18px;
}
.ratings {
display: flex;
line-height: 18px;
> div:last-child {
padding-top: 1px;
font-style: italic;
}
}
.starsContainer {
display: flex;
> div {
color: #EED348;
> i {
margin-right: 2px;
}
}
> div:last-child {
color: #B3B5B9;
}
}
.wrapper {
padding: 0 30px;
}

View File

@ -11,7 +11,6 @@ import { isEmpty, replace } from 'lodash';
import { FormattedMessage } from 'react-intl';
import { Button, PopUpWarning } from 'strapi-helper-plugin';
import InstallPluginPopup from '../InstallPluginPopup';
import styles from './styles.scss';
@ -193,19 +192,7 @@ class PluginCard extends React.Component {
)}
</div>
</div>
<InstallPluginPopup
history={this.props.history}
isAlreadyInstalled={this.props.isAlreadyInstalled}
isOpen={
!isEmpty(this.props.history.location.hash) &&
replace(
this.props.history.location.hash.split('::')[0],
'#',
''
) === this.props.plugin.id
}
plugin={this.props.plugin}
/>
<PopUpWarning
content={{
message:

View File

@ -13,8 +13,6 @@ const MarketPlaceContextProvider = ({ children, ...rest }) => {
const useMarketPlaceContext = () => useContext(MarketPlaceContext);
MarketPlaceContextProvider.defaultProps = {};
MarketPlaceContextProvider.propTypes = {
children: PropTypes.node.isRequired,
downloadPlugin: PropTypes.func.isRequired,

View File

@ -26,6 +26,8 @@ GlobalContextProvider.propTypes = {
disableGlobalOverlayBlocker: PropTypes.func,
emitEvent: PropTypes.func,
enableGlobalOverlayBlocker: PropTypes.func,
plugins: PropTypes.object,
updatePlugin: PropTypes.func,
};
export { GlobalContext, GlobalContextProvider, useGlobalContext };

View File

@ -52,7 +52,6 @@ const renderComponent = (props = {}) => {
</GlobalContextProvider>
</BrowserRouter>,
messages
// appContext
);
};

View File

@ -11,8 +11,6 @@ const HomePageContextProvider = ({ children, ...rest }) => {
const useHomePageContext = () => useContext(HomePageContext);
HomePageContextProvider.defaultProps = {};
HomePageContextProvider.propTypes = {
children: PropTypes.node.isRequired,
deleteData: PropTypes.func.isRequired,