Fix PR feedback

This commit is contained in:
soupette 2020-01-07 18:03:19 +01:00
parent 98560758e3
commit 15f3a83f34
7 changed files with 26 additions and 28 deletions

View File

@ -6,7 +6,7 @@ import ComponentInfosWrapper from './ComponentInfosWrapper';
const ComponentInfos = ({ category, name }) => {
return (
<ComponentInfosWrapper>
&nbsp; (<UpperFirst content={category} />) &nbsp;&nbsp;
&nbsp; (<UpperFirst content={category} /> &nbsp;&nbsp;
<UpperFirst content={name} />)
</ComponentInfosWrapper>
);

View File

@ -1,7 +1,7 @@
import React, { useState } from 'react';
import PropTypes from 'prop-types';
import { AttributeIcon } from '@buffetjs/core';
import UpperFirst from '../UpperFirst';
import Icon from './Icon';
import Item from './Item';
import Menu from './Menu';
import Toggle from './Toggle';
@ -12,11 +12,7 @@ const DropdownInfos = ({ headers, shouldDisplaySecondHeader }) => {
const toggle = () => setDropdownOpen(prevState => !prevState);
return (
<Wrapper
isOpen={dropdownOpen}
toggle={toggle}
style={{ margin: 'auto 0px auto 0' }}
>
<Wrapper isOpen={dropdownOpen} toggle={toggle} style={{ margin: 'auto 0' }}>
<Toggle>...</Toggle>
<Menu style={{ top: '8px' }}>
{headers.map((header, index) => {
@ -26,10 +22,7 @@ const DropdownInfos = ({ headers, shouldDisplaySecondHeader }) => {
return (
<Item key={index}>
<AttributeIcon
type={header.icon.name}
style={{ margin: 'auto 20px auto 0' }}
/>
<Icon type={header.icon.name} />
<span>
<UpperFirst content={header.label} />
</span>

View File

@ -0,0 +1,13 @@
import React from 'react';
import { AttributeIcon } from '@buffetjs/core';
import PropTypes from 'prop-types';
const Icon = ({ type }) => (
<AttributeIcon type={type} style={{ margin: 'auto 20px auto 0' }} />
);
Icon.propTypes = {
type: PropTypes.string.isRequired,
};
export default Icon;

View File

@ -2,27 +2,24 @@ import React, { Fragment } from 'react';
import PropTypes from 'prop-types';
import { HeaderModalTitle } from 'strapi-helper-plugin';
import { get } from 'lodash';
import { AttributeIcon } from '@buffetjs/core';
import { FormattedMessage } from 'react-intl';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import ComponentIcon from './ComponentIcon';
import ComponentInfos from './ComponentInfos';
import Icon from './Icon';
import IconWrapper from './IconWrapper';
import UpperFirst from '../UpperFirst';
import DropdownInfos from './DropdownInfos';
const ModalHeader = ({ headerId, headers }) => {
const shouldDisplayDrodDrown = headers.length > 3;
const shouldDisplayDrodDown = headers.length > 3;
return (
<section>
<HeaderModalTitle style={{ textTransform: 'none' }}>
{headerId && (
<>
<AttributeIcon
type={get(headers, [0, 'icon', 'name'], '')}
style={{ margin: 'auto 20px auto 0' }}
/>
<Icon type={get(headers, [0, 'icon', 'name'], '')} />
<FormattedMessage
id={headerId}
values={{ name: get(headers, [0, 'label'], '') }}
@ -38,13 +35,10 @@ const ModalHeader = ({ headerId, headers }) => {
<FontAwesomeIcon icon={iconType} />
</ComponentIcon>
) : (
<AttributeIcon
type={iconType}
style={{ margin: 'auto 20px auto 0' }}
/>
<Icon type={iconType} />
);
if (shouldDisplayDrodDrown && index === 1) {
if (shouldDisplayDrodDown && index === 1) {
return (
<Fragment key={index}>
<IconWrapper>
@ -58,7 +52,7 @@ const ModalHeader = ({ headerId, headers }) => {
);
}
if (shouldDisplayDrodDrown && index === 2 && headers.length > 4) {
if (shouldDisplayDrodDown && index === 2 && headers.length > 4) {
return null;
}

View File

@ -175,9 +175,7 @@ const reducer = (state, action) => {
)
.updateIn(['modifiedData', 'components'], old => {
const componentsSchema = newComponents.reduce((acc, current) => {
let newAcc = addComponentsToState(state, current, acc);
return newAcc;
return addComponentsToState(state, current, acc);
}, old);
return componentsSchema;

View File

@ -34,7 +34,7 @@ describe('FormModal | utils | createHeadersArray', () => {
expect(createHeadersArray(data)).toEqual([]);
});
it('should return an array containing an header object', () => {
it('should return an array containing a header object', () => {
const data = {
actionType: 'something',
attributeName: null,

View File

@ -1,7 +1,7 @@
import createHeadersObjectFromArray from '../createHeadersObjectFromArray';
describe('FormModal | utils | createHeadersArray', () => {
it('should return an headers object', () => {
it('should return a header object', () => {
const data = [
{
label: 'test',