mirror of
https://github.com/strapi/strapi.git
synced 2025-11-13 16:52:18 +00:00
Fix PR feedback
This commit is contained in:
parent
98560758e3
commit
15f3a83f34
@ -6,7 +6,7 @@ import ComponentInfosWrapper from './ComponentInfosWrapper';
|
|||||||
const ComponentInfos = ({ category, name }) => {
|
const ComponentInfos = ({ category, name }) => {
|
||||||
return (
|
return (
|
||||||
<ComponentInfosWrapper>
|
<ComponentInfosWrapper>
|
||||||
(<UpperFirst content={category} />) —
|
(<UpperFirst content={category} /> —
|
||||||
<UpperFirst content={name} />)
|
<UpperFirst content={name} />)
|
||||||
</ComponentInfosWrapper>
|
</ComponentInfosWrapper>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { AttributeIcon } from '@buffetjs/core';
|
|
||||||
import UpperFirst from '../UpperFirst';
|
import UpperFirst from '../UpperFirst';
|
||||||
|
import Icon from './Icon';
|
||||||
import Item from './Item';
|
import Item from './Item';
|
||||||
import Menu from './Menu';
|
import Menu from './Menu';
|
||||||
import Toggle from './Toggle';
|
import Toggle from './Toggle';
|
||||||
@ -12,11 +12,7 @@ const DropdownInfos = ({ headers, shouldDisplaySecondHeader }) => {
|
|||||||
|
|
||||||
const toggle = () => setDropdownOpen(prevState => !prevState);
|
const toggle = () => setDropdownOpen(prevState => !prevState);
|
||||||
return (
|
return (
|
||||||
<Wrapper
|
<Wrapper isOpen={dropdownOpen} toggle={toggle} style={{ margin: 'auto 0' }}>
|
||||||
isOpen={dropdownOpen}
|
|
||||||
toggle={toggle}
|
|
||||||
style={{ margin: 'auto 0px auto 0' }}
|
|
||||||
>
|
|
||||||
<Toggle>...</Toggle>
|
<Toggle>...</Toggle>
|
||||||
<Menu style={{ top: '8px' }}>
|
<Menu style={{ top: '8px' }}>
|
||||||
{headers.map((header, index) => {
|
{headers.map((header, index) => {
|
||||||
@ -26,10 +22,7 @@ const DropdownInfos = ({ headers, shouldDisplaySecondHeader }) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Item key={index}>
|
<Item key={index}>
|
||||||
<AttributeIcon
|
<Icon type={header.icon.name} />
|
||||||
type={header.icon.name}
|
|
||||||
style={{ margin: 'auto 20px auto 0' }}
|
|
||||||
/>
|
|
||||||
<span>
|
<span>
|
||||||
<UpperFirst content={header.label} />
|
<UpperFirst content={header.label} />
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@ -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;
|
||||||
@ -2,27 +2,24 @@ import React, { Fragment } from 'react';
|
|||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { HeaderModalTitle } from 'strapi-helper-plugin';
|
import { HeaderModalTitle } from 'strapi-helper-plugin';
|
||||||
import { get } from 'lodash';
|
import { get } from 'lodash';
|
||||||
import { AttributeIcon } from '@buffetjs/core';
|
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
import ComponentIcon from './ComponentIcon';
|
import ComponentIcon from './ComponentIcon';
|
||||||
import ComponentInfos from './ComponentInfos';
|
import ComponentInfos from './ComponentInfos';
|
||||||
|
import Icon from './Icon';
|
||||||
import IconWrapper from './IconWrapper';
|
import IconWrapper from './IconWrapper';
|
||||||
import UpperFirst from '../UpperFirst';
|
import UpperFirst from '../UpperFirst';
|
||||||
import DropdownInfos from './DropdownInfos';
|
import DropdownInfos from './DropdownInfos';
|
||||||
|
|
||||||
const ModalHeader = ({ headerId, headers }) => {
|
const ModalHeader = ({ headerId, headers }) => {
|
||||||
const shouldDisplayDrodDrown = headers.length > 3;
|
const shouldDisplayDrodDown = headers.length > 3;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section>
|
<section>
|
||||||
<HeaderModalTitle style={{ textTransform: 'none' }}>
|
<HeaderModalTitle style={{ textTransform: 'none' }}>
|
||||||
{headerId && (
|
{headerId && (
|
||||||
<>
|
<>
|
||||||
<AttributeIcon
|
<Icon type={get(headers, [0, 'icon', 'name'], '')} />
|
||||||
type={get(headers, [0, 'icon', 'name'], '')}
|
|
||||||
style={{ margin: 'auto 20px auto 0' }}
|
|
||||||
/>
|
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
id={headerId}
|
id={headerId}
|
||||||
values={{ name: get(headers, [0, 'label'], '') }}
|
values={{ name: get(headers, [0, 'label'], '') }}
|
||||||
@ -38,13 +35,10 @@ const ModalHeader = ({ headerId, headers }) => {
|
|||||||
<FontAwesomeIcon icon={iconType} />
|
<FontAwesomeIcon icon={iconType} />
|
||||||
</ComponentIcon>
|
</ComponentIcon>
|
||||||
) : (
|
) : (
|
||||||
<AttributeIcon
|
<Icon type={iconType} />
|
||||||
type={iconType}
|
|
||||||
style={{ margin: 'auto 20px auto 0' }}
|
|
||||||
/>
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (shouldDisplayDrodDrown && index === 1) {
|
if (shouldDisplayDrodDown && index === 1) {
|
||||||
return (
|
return (
|
||||||
<Fragment key={index}>
|
<Fragment key={index}>
|
||||||
<IconWrapper>
|
<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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -175,9 +175,7 @@ const reducer = (state, action) => {
|
|||||||
)
|
)
|
||||||
.updateIn(['modifiedData', 'components'], old => {
|
.updateIn(['modifiedData', 'components'], old => {
|
||||||
const componentsSchema = newComponents.reduce((acc, current) => {
|
const componentsSchema = newComponents.reduce((acc, current) => {
|
||||||
let newAcc = addComponentsToState(state, current, acc);
|
return addComponentsToState(state, current, acc);
|
||||||
|
|
||||||
return newAcc;
|
|
||||||
}, old);
|
}, old);
|
||||||
|
|
||||||
return componentsSchema;
|
return componentsSchema;
|
||||||
|
|||||||
@ -34,7 +34,7 @@ describe('FormModal | utils | createHeadersArray', () => {
|
|||||||
expect(createHeadersArray(data)).toEqual([]);
|
expect(createHeadersArray(data)).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return an array containing an header object', () => {
|
it('should return an array containing a header object', () => {
|
||||||
const data = {
|
const data = {
|
||||||
actionType: 'something',
|
actionType: 'something',
|
||||||
attributeName: null,
|
attributeName: null,
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import createHeadersObjectFromArray from '../createHeadersObjectFromArray';
|
import createHeadersObjectFromArray from '../createHeadersObjectFromArray';
|
||||||
|
|
||||||
describe('FormModal | utils | createHeadersArray', () => {
|
describe('FormModal | utils | createHeadersArray', () => {
|
||||||
it('should return an headers object', () => {
|
it('should return a header object', () => {
|
||||||
const data = [
|
const data = [
|
||||||
{
|
{
|
||||||
label: 'test',
|
label: 'test',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user