diff --git a/packages/strapi-helper-plugin/lib/internals/webpack/webpack.dev.babel.js b/packages/strapi-helper-plugin/lib/internals/webpack/webpack.dev.babel.js
index 30a6e6430d..4ebf9909f9 100755
--- a/packages/strapi-helper-plugin/lib/internals/webpack/webpack.dev.babel.js
+++ b/packages/strapi-helper-plugin/lib/internals/webpack/webpack.dev.babel.js
@@ -66,10 +66,10 @@ module.exports = require('./webpack.base.babel')({
path.join(appPath, 'admin', 'admin', 'src', 'app.js'),
],
}, plugins.src.reduce((acc, current) => {
- acc[current] = path.resolve(plugins.folders[current], 'app.js');
+ acc[current] = path.resolve(plugins.folders[current], 'app.js');
- return acc;
- }, {})
+ return acc;
+ }, {})
),
// Don't use hashes in dev mode for better performance
diff --git a/packages/strapi-helper-plugin/lib/src/components/BlockerComponent/index.js b/packages/strapi-helper-plugin/lib/src/components/BlockerComponent/index.js
index f7f5be7752..e0e450d54a 100644
--- a/packages/strapi-helper-plugin/lib/src/components/BlockerComponent/index.js
+++ b/packages/strapi-helper-plugin/lib/src/components/BlockerComponent/index.js
@@ -7,6 +7,8 @@
import React from 'react';
import { FormattedMessage } from 'react-intl';
import cn from 'classnames';
+import PropTypes from 'prop-types';
+
import styles from './styles.scss';
/* eslint-disable react/require-default-props */
@@ -85,4 +87,11 @@ const renderButton = () => (
);
+BlockerComponent.propTypes = {
+ blockerComponentContent: PropTypes.string.isRequired,
+ blockerComponentDescription: PropTypes.string.isRequired,
+ blockerComponentIcon: PropTypes.string.isRequired,
+ blockerComponentTitle: PropTypes.string.isRequired,
+};
+
export default BlockerComponent;
diff --git a/packages/strapi-helper-plugin/lib/src/components/ErrorBoundary/index.js b/packages/strapi-helper-plugin/lib/src/components/ErrorBoundary/index.js
index fa7219f81a..28e6e872cd 100644
--- a/packages/strapi-helper-plugin/lib/src/components/ErrorBoundary/index.js
+++ b/packages/strapi-helper-plugin/lib/src/components/ErrorBoundary/index.js
@@ -7,7 +7,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
-import styles from './styles.scss';
class ErrorBoundary extends React.Component { // eslint-disable-line react/prefer-stateless-function
constructor(props) {
diff --git a/packages/strapi-helper-plugin/lib/src/components/ErrorBoundary/styles.scss b/packages/strapi-helper-plugin/lib/src/components/ErrorBoundary/styles.scss
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/packages/strapi-helper-plugin/lib/src/components/ExtendComponent/index.js b/packages/strapi-helper-plugin/lib/src/components/ExtendComponent/index.js
index 045e5faadf..d745b282a2 100644
--- a/packages/strapi-helper-plugin/lib/src/components/ExtendComponent/index.js
+++ b/packages/strapi-helper-plugin/lib/src/components/ExtendComponent/index.js
@@ -40,12 +40,12 @@ ExtendComponent.contextTypes = {
plugins: PropTypes.object,
router: PropTypes.object,
updatePlugin: PropTypes.func,
-}
+};
ExtendComponent.propTypes = {
area: PropTypes.string.isRequired,
- container: PropTypes.string.isRequired,
children: PropTypes.node,
+ container: PropTypes.string.isRequired,
plugin: PropTypes.string.isRequired,
};
diff --git a/packages/strapi-helper-plugin/lib/src/components/GlobalPagination/index.js b/packages/strapi-helper-plugin/lib/src/components/GlobalPagination/index.js
index 22ec9f71de..2cfd89ef2a 100644
--- a/packages/strapi-helper-plugin/lib/src/components/GlobalPagination/index.js
+++ b/packages/strapi-helper-plugin/lib/src/components/GlobalPagination/index.js
@@ -10,6 +10,7 @@ import PropTypes from 'prop-types';
import styles from './styles.scss';
+/* eslint-disable jsx-a11y/anchor-is-valid */
class GlobalPagination extends React.Component {
getLastPageNumber = () => Math.ceil(this.props.count / this.props.params.limit);
@@ -163,6 +164,7 @@ class GlobalPagination extends React.Component {
}
GlobalPagination.defaultProps = {
+ count: 0,
onChangeParams: () => {},
params: {
page: 1,
diff --git a/packages/strapi-helper-plugin/lib/src/components/Ico/index.js b/packages/strapi-helper-plugin/lib/src/components/Ico/index.js
index 3aa590ab29..367d2f65f1 100644
--- a/packages/strapi-helper-plugin/lib/src/components/Ico/index.js
+++ b/packages/strapi-helper-plugin/lib/src/components/Ico/index.js
@@ -23,11 +23,13 @@ const handleClick = (e, onClick) => {
Ico.propTypes = {
icoType: PropTypes.string,
+ id: PropTypes.string,
onClick: PropTypes.func,
};
Ico.defaultProps = {
icoType: 'trash',
+ id: '',
onClick: () => {},
};
diff --git a/packages/strapi-helper-plugin/lib/src/components/ImgPreview/index.js b/packages/strapi-helper-plugin/lib/src/components/ImgPreview/index.js
index b753173b4f..42795bab53 100644
--- a/packages/strapi-helper-plugin/lib/src/components/ImgPreview/index.js
+++ b/packages/strapi-helper-plugin/lib/src/components/ImgPreview/index.js
@@ -30,8 +30,8 @@ class ImgPreview extends React.Component {
// We don't need the generateImgURL function here since the compo will
// always have an init value here
this.setState({
- imgURL: get(this.props.files, ['0', 'url'], '') || get(this.props.files, 'url', ''),
- isImg: this.isPictureType(get(this.props.files, ['0', 'name'], '')),
+ imgURL: get(this.props.files, ['0', 'url'], '') || get(this.props.files, 'url', ''),
+ isImg: this.isPictureType(get(this.props.files, ['0', 'name'], '')),
});
}
@@ -47,7 +47,7 @@ class ImgPreview extends React.Component {
// Update the preview or slide pictures or init the component
if (nextProps.didDeleteFile !== this.props.didDeleteFile || nextProps.position !== this.props.position || size(nextProps.files) !== size(this.props.files) && !this.state.isInitValue) {
const file = nextProps.files[nextProps.position] || nextProps.files || '';
- this.generateImgURL(file)
+ this.generateImgURL(file);
if (!this.state.isInitValue) {
this.setState({ isInitValue: true });
@@ -74,7 +74,7 @@ class ImgPreview extends React.Component {
imgURL: reader.result,
isImg: true,
});
- }
+ };
reader.readAsDataURL(file);
} else if (has(file, 'url')) {
@@ -89,7 +89,7 @@ class ImgPreview extends React.Component {
handleClick = (type) => {
const { files, position } = this.props;
- let file;
+ let file; // eslint-disable-line no-unused-vars
let nextPosition;
switch (type) {
@@ -134,12 +134,17 @@ class ImgPreview extends React.Component {
// TODO change logic to depend on the type
isPictureType = (fileName) => /\.(jpe?g|png|gif)$/i.test(fileName);
+ updateFilePosition = (newPosition) => {
+ // this.setState({ position: newPosition });
+ this.props.updateFilePosition(newPosition);
+ }
+
renderContent = () => {
const fileType = this.getFileType(this.state.imgURL);
if (this.state.isImg) {
return (
-
+
);
}
@@ -150,13 +155,8 @@ class ImgPreview extends React.Component {
);
}
- updateFilePosition = (newPosition) => {
- // this.setState({ position: newPosition });
- this.props.updateFilePosition(newPosition);
- }
-
render() {
- const { files, multiple, onBrowseClick } = this.props;
+ const { files, onBrowseClick } = this.props;
const { imgURL } = this.state;
const containerStyle = isEmpty(imgURL) ?
{
@@ -167,44 +167,43 @@ class ImgPreview extends React.Component {
} : {};
return (
+
-
-
- { !isEmpty(imgURL) && this.renderContent() }
-
1}
- onClick={this.handleClick}
- onMouseEnter={(e) => this.setState({ isOverArrow: true })}
- onMouseLeave={(e) => this.setState({ isOverArrow: false })}
- show={isArray(files) && size(files) > 1}
- type="right"
- />
- 1}
- onClick={this.handleClick}
- onMouseEnter={(e) => this.setState({ isOverArrow: true })}
- onMouseLeave={(e) => this.setState({ isOverArrow: false })}
- show={isArray(files) && size(files) > 1}
- />
-
-
+ onDrop={this.handleDrop}
+ />
+
+ { !isEmpty(imgURL) && this.renderContent() }
+
1}
+ onClick={this.handleClick}
+ onMouseEnter={() => this.setState({ isOverArrow: true })}
+ onMouseLeave={() => this.setState({ isOverArrow: false })}
+ show={isArray(files) && size(files) > 1}
+ type="right"
+ />
+ 1}
+ onClick={this.handleClick}
+ onMouseEnter={() => this.setState({ isOverArrow: true })}
+ onMouseLeave={() => this.setState({ isOverArrow: false })}
+ show={isArray(files) && size(files) > 1}
+ />
+
);
}
}
@@ -214,9 +213,7 @@ ImgPreview.defaultProps = {
files: [],
isUploading: false,
multiple: false,
- name: '',
onBrowseClick: () => {},
- onChange: () => {},
onDrop: () => {},
position: 0,
updateFilePosition: () => {},
@@ -230,9 +227,7 @@ ImgPreview.propTypes = {
]),
isUploading: PropTypes.bool,
multiple: PropTypes.bool,
- name: PropTypes.string,
onBrowseClick: PropTypes.func,
- onChange: PropTypes.func,
onDrop: PropTypes.func,
position: PropTypes.number,
updateFilePosition: PropTypes.func,
diff --git a/packages/strapi-helper-plugin/lib/src/components/InputAddon/index.js b/packages/strapi-helper-plugin/lib/src/components/InputAddon/index.js
index 8fc24b86d1..7d528a7354 100644
--- a/packages/strapi-helper-plugin/lib/src/components/InputAddon/index.js
+++ b/packages/strapi-helper-plugin/lib/src/components/InputAddon/index.js
@@ -11,6 +11,7 @@ import cn from 'classnames';
import styles from './styles.scss';
+/* eslint-disable jsx-a11y/no-autofocus */
class InputAddon extends React.Component {
state = { isFocused: false };
@@ -47,7 +48,8 @@ class InputAddon extends React.Component {
{(message) => (
- {
const target = {
@@ -84,7 +86,8 @@ class InputCheckbox extends React.Component {
);
}
return (
-
- {spacer}
+ {spacer}
);
}
@@ -132,7 +129,6 @@ InputCheckboxWithErrors.defaultProps = {
autoFocus: false,
className: '',
customBootstrapClass: 'col-md-3',
- deactivateErrorHighlight: false,
didCheckErrors: false,
disabled: false,
onBlur: () => {},
@@ -146,21 +142,17 @@ InputCheckboxWithErrors.defaultProps = {
inputDescriptionStyle: {},
inputStyle: {},
label: '',
- labelClassName: '',
- labelStyle: {},
noErrorsDescription: false,
placeholder: 'app.utils.placeholder.defaultMessage',
style: {},
tabIndex: '0',
title: '',
- validations: {},
value: false,
};
InputCheckboxWithErrors.propTypes = {
autoFocus: PropTypes.bool,
className: PropTypes.string,
customBootstrapClass: PropTypes.string,
- deactivateErrorHighlight: PropTypes.bool,
didCheckErrors: PropTypes.bool,
disabled: PropTypes.bool,
errors: PropTypes.array,
@@ -186,8 +178,6 @@ InputCheckboxWithErrors.propTypes = {
params: PropTypes.object,
}),
]),
- labelClassName: PropTypes.string,
- labelStyle: PropTypes.object,
name: PropTypes.string.isRequired,
noErrorsDescription: PropTypes.bool,
onBlur: PropTypes.oneOfType([
@@ -207,7 +197,6 @@ InputCheckboxWithErrors.propTypes = {
params: PropTypes.object,
}),
]),
- validations: PropTypes.object,
value: PropTypes.bool,
};
diff --git a/packages/strapi-helper-plugin/lib/src/components/InputDate/index.js b/packages/strapi-helper-plugin/lib/src/components/InputDate/index.js
index 83ddcf742f..ed9b3586ce 100644
--- a/packages/strapi-helper-plugin/lib/src/components/InputDate/index.js
+++ b/packages/strapi-helper-plugin/lib/src/components/InputDate/index.js
@@ -7,7 +7,7 @@
import React from 'react';
import moment from 'moment';
import PropTypes from 'prop-types';
-import DateTimeStyle from 'react-datetime/css/react-datetime.css';
+// import DateTimeStyle from 'react-datetime/css/react-datetime.css';
import DateTime from 'react-datetime';
import { FormattedMessage } from 'react-intl';
import { isEmpty, isObject } from 'lodash';
@@ -15,6 +15,7 @@ import cn from 'classnames';
import styles from './styles.scss';
+/* eslint-disable react/jsx-boolean-value */
function InputDate(props) {
const value = isObject(props.value) && props.value._isAMomentObject === true ? props.value : moment(props.value);
@@ -76,10 +77,10 @@ InputDate.propTypes = {
deactivateErrorHighlight: PropTypes.bool,
disabled: PropTypes.bool,
error: PropTypes.bool,
+ name: PropTypes.string.isRequired,
onBlur: PropTypes.func,
onChange: PropTypes.func.isRequired,
onFocus: PropTypes.func,
- name: PropTypes.string.isRequired,
placeholder: PropTypes.string,
style: PropTypes.object,
tabIndex: PropTypes.string,
diff --git a/packages/strapi-helper-plugin/lib/src/components/InputDateWithErrors/index.js b/packages/strapi-helper-plugin/lib/src/components/InputDateWithErrors/index.js
index fe246afe45..41296557c8 100644
--- a/packages/strapi-helper-plugin/lib/src/components/InputDateWithErrors/index.js
+++ b/packages/strapi-helper-plugin/lib/src/components/InputDateWithErrors/index.js
@@ -100,7 +100,8 @@ class InputDateWithErrors extends React.Component { // eslint-disable-line react
}
return (
- {},
- errors: [],
- errorsClassName: '',
- errorsStyle: {},
- inputClassName: '',
- inputDescription: '',
- inputDescriptionClassName: '',
- inputDescriptionStyle: {},
- inputStyle: {},
- label: '',
- labelClassName: '',
- labelStyle: {},
- noErrorsDescription: false,
- placeholder: 'app.utils.placeholder.defaultMessage',
- style: {},
- tabIndex: '0',
- validations: {},
+ autoFocus: false,
+ className: '',
+ customBootstrapClass: 'col-md-4',
+ deactivateErrorHighlight: false,
+ didCheckErrors: false,
+ disabled: false,
+ onBlur: false,
+ onFocus: () => {},
+ errors: [],
+ errorsClassName: '',
+ errorsStyle: {},
+ inputClassName: '',
+ inputDescription: '',
+ inputDescriptionClassName: '',
+ inputDescriptionStyle: {},
+ inputStyle: {},
+ label: '',
+ labelClassName: '',
+ labelStyle: {},
+ noErrorsDescription: false,
+ placeholder: 'app.utils.placeholder.defaultMessage',
+ style: {},
+ tabIndex: '0',
+ validations: {},
};
InputDateWithErrors.propTypes = {
- autoFocus: PropTypes.bool,
- className: PropTypes.string,
- customBootstrapClass: PropTypes.string,
- deactivateErrorHighlight: PropTypes.bool,
- didCheckErrors: PropTypes.bool,
- disabled: PropTypes.bool,
- errors: PropTypes.array,
- errorsClassName: PropTypes.string,
- errorsStyle: PropTypes.object,
- inputClassName: PropTypes.string,
- inputDescription: PropTypes.oneOfType([
- PropTypes.string,
- PropTypes.func,
- PropTypes.shape({
- id: PropTypes.string,
- params: PropTypes.object,
- }),
- ]),
- inputDescriptionClassName: PropTypes.string,
- inputDescriptionStyle: PropTypes.object,
- inputStyle: PropTypes.object,
- label: PropTypes.oneOfType([
- PropTypes.string,
- PropTypes.func,
- PropTypes.shape({
- id: PropTypes.string,
- params: PropTypes.object,
- }),
- ]),
- labelClassName: PropTypes.string,
- labelStyle: PropTypes.object,
- name: PropTypes.string.isRequired,
- noErrorsDescription: PropTypes.bool,
- onBlur: PropTypes.oneOfType([
- PropTypes.bool,
- PropTypes.func,
- ]),
- onChange: PropTypes.func.isRequired,
- onFocus: PropTypes.func,
- placeholder: PropTypes.string,
- style: PropTypes.object,
- tabIndex: PropTypes.string,
- validations: PropTypes.object,
- value: PropTypes.string.isRequired,
+ autoFocus: PropTypes.bool,
+ className: PropTypes.string,
+ customBootstrapClass: PropTypes.string,
+ deactivateErrorHighlight: PropTypes.bool,
+ didCheckErrors: PropTypes.bool,
+ disabled: PropTypes.bool,
+ errors: PropTypes.array,
+ errorsClassName: PropTypes.string,
+ errorsStyle: PropTypes.object,
+ inputClassName: PropTypes.string,
+ inputDescription: PropTypes.oneOfType([
+ PropTypes.string,
+ PropTypes.func,
+ PropTypes.shape({
+ id: PropTypes.string,
+ params: PropTypes.object,
+ }),
+ ]),
+ inputDescriptionClassName: PropTypes.string,
+ inputDescriptionStyle: PropTypes.object,
+ inputStyle: PropTypes.object,
+ label: PropTypes.oneOfType([
+ PropTypes.string,
+ PropTypes.func,
+ PropTypes.shape({
+ id: PropTypes.string,
+ params: PropTypes.object,
+ }),
+ ]),
+ labelClassName: PropTypes.string,
+ labelStyle: PropTypes.object,
+ name: PropTypes.string.isRequired,
+ noErrorsDescription: PropTypes.bool,
+ onBlur: PropTypes.oneOfType([
+ PropTypes.bool,
+ PropTypes.func,
+ ]),
+ onChange: PropTypes.func.isRequired,
+ onFocus: PropTypes.func,
+ placeholder: PropTypes.string,
+ style: PropTypes.object,
+ tabIndex: PropTypes.string,
+ validations: PropTypes.object,
+ value: PropTypes.string.isRequired,
};
export default InputDateWithErrors;
diff --git a/packages/strapi-helper-plugin/lib/src/components/InputDescription/index.js b/packages/strapi-helper-plugin/lib/src/components/InputDescription/index.js
index ec1db62a38..ac3fcb15c1 100644
--- a/packages/strapi-helper-plugin/lib/src/components/InputDescription/index.js
+++ b/packages/strapi-helper-plugin/lib/src/components/InputDescription/index.js
@@ -21,7 +21,8 @@ function InputDescription(props) {
content = props.message();
}
return (
-
-
: error;
return (
-
+ >
{displayError}
- )
+ );
})}
);
diff --git a/packages/strapi-helper-plugin/lib/src/components/InputFile/index.js b/packages/strapi-helper-plugin/lib/src/components/InputFile/index.js
index 24678bb3c6..a65ba6f048 100644
--- a/packages/strapi-helper-plugin/lib/src/components/InputFile/index.js
+++ b/packages/strapi-helper-plugin/lib/src/components/InputFile/index.js
@@ -8,14 +8,15 @@
import React from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
-import { cloneDeep, isArray, isObject, isEmpty, last } from 'lodash';
-import cn from 'classnames';
+import { cloneDeep } from 'lodash';
import ImgPreview from 'components/ImgPreview';
import InputFileDetails from 'components/InputFileDetails';
import styles from './styles.scss';
+/* eslint-disable react/jsx-handler-names */
+/* eslint-disable jsx-a11y/label-has-for */
class InputFile extends React.Component {
state = {
didDeleteFile: false,
@@ -23,6 +24,19 @@ class InputFile extends React.Component {
position: 0,
};
+ onDrop = (e) => {
+ e.preventDefault();
+ this.addFilesToProps(e.dataTransfer.files);
+ }
+
+ handleClick = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ this.inputFile.click();
+ }
+
+ handleChange = ({ target }) => this.addFilesToProps(target.files);
+
addFilesToProps = (files) => {
const initAcc = this.props.multiple ? cloneDeep(this.props.value) : {};
const value = Object.keys(files).reduce((acc, current) => {
@@ -34,7 +48,7 @@ class InputFile extends React.Component {
}
return acc;
- }, initAcc)
+ }, initAcc);
const target = {
name: this.props.name,
@@ -46,19 +60,6 @@ class InputFile extends React.Component {
this.props.onChange({ target });
}
- handleChange = ({ target }) => this.addFilesToProps(target.files);
-
- handleClick = (e) => {
- e.preventDefault();
- e.stopPropagation();
- this.inputFile.click();
- }
-
- onDrop = (e) => {
- e.preventDefault();
- this.addFilesToProps(e.dataTransfer.files);
- }
-
handleFileDelete = (e) => {
e.preventDefault();
e.stopPropagation();
diff --git a/packages/strapi-helper-plugin/lib/src/components/InputFileDetails/index.js b/packages/strapi-helper-plugin/lib/src/components/InputFileDetails/index.js
index c722feb69b..ce5310fd3d 100644
--- a/packages/strapi-helper-plugin/lib/src/components/InputFileDetails/index.js
+++ b/packages/strapi-helper-plugin/lib/src/components/InputFileDetails/index.js
@@ -8,7 +8,6 @@ import React from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
import { get, startsWith } from 'lodash';
-import cn from 'classnames';
import styles from './styles.scss';
@@ -19,7 +18,7 @@ function InputFileDetails(props) {
// TODO improve logic
if (!get(props.file, 'name') && !props.multiple) {
- return
+ return
;
}
const url = startsWith(props.file.url, '/') ? `${strapi.backendURL}${props.file.url}` : props.file.url;
diff --git a/packages/strapi-helper-plugin/lib/src/components/InputFileWithErrors/index.js b/packages/strapi-helper-plugin/lib/src/components/InputFileWithErrors/index.js
index 37badc65c8..6ca7ac1ff8 100644
--- a/packages/strapi-helper-plugin/lib/src/components/InputFileWithErrors/index.js
+++ b/packages/strapi-helper-plugin/lib/src/components/InputFileWithErrors/index.js
@@ -7,7 +7,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import cn from 'classnames';
-import { differenceBy, isEmpty, isObject } from 'lodash';
+import { differenceBy, isEmpty } from 'lodash';
// Design
import Label from 'components/Label';
diff --git a/packages/strapi-helper-plugin/lib/src/components/InputNumber/index.js b/packages/strapi-helper-plugin/lib/src/components/InputNumber/index.js
index 3aabcd65b6..aaa8e00eb4 100644
--- a/packages/strapi-helper-plugin/lib/src/components/InputNumber/index.js
+++ b/packages/strapi-helper-plugin/lib/src/components/InputNumber/index.js
@@ -6,6 +6,7 @@ import cn from 'classnames';
import styles from './styles.scss';
+/* eslint-disable jsx-a11y/no-autofocus */
function InputNumber(props) {
return (
@@ -32,7 +33,7 @@ function InputNumber(props) {
/>
)}
- )
+ );
}
InputNumber.defaultProps = {
@@ -54,10 +55,10 @@ InputNumber.propTypes = {
deactivateErrorHighlight: PropTypes.bool,
disabled: PropTypes.bool,
error: PropTypes.bool,
+ name: PropTypes.string.isRequired,
onBlur: PropTypes.func,
onChange: PropTypes.func.isRequired,
onFocus: PropTypes.func,
- name: PropTypes.string.isRequired,
placeholder: PropTypes.string,
style: PropTypes.object,
tabIndex: PropTypes.string,
diff --git a/packages/strapi-helper-plugin/lib/src/components/InputNumberWithErrors/index.js b/packages/strapi-helper-plugin/lib/src/components/InputNumberWithErrors/index.js
index 598b7ad27e..50037a613e 100644
--- a/packages/strapi-helper-plugin/lib/src/components/InputNumberWithErrors/index.js
+++ b/packages/strapi-helper-plugin/lib/src/components/InputNumberWithErrors/index.js
@@ -94,7 +94,8 @@ class InputNumberWithErrors extends React.Component { // eslint-disable-line rea
}
return (
-
-
{},
- onFocus: () => {},
- placeholder: 'app.utils.placeholder.defaultMessage',
- style: {},
- tabIndex: '0',
+ autoFocus: false,
+ className: '',
+ deactivateErrorHighlight: false,
+ disabled: false,
+ error: false,
+ onBlur: () => {},
+ onFocus: () => {},
+ placeholder: 'app.utils.placeholder.defaultMessage',
+ style: {},
+ tabIndex: '0',
};
InputSearch.propTypes = {
- autoFocus: PropTypes.bool,
- className: PropTypes.string,
- deactivateErrorHighlight: PropTypes.bool,
- disabled: PropTypes.bool,
- error: PropTypes.bool,
- onBlur: PropTypes.func,
- onChange: PropTypes.func.isRequired,
- onFocus: PropTypes.func,
- name: PropTypes.string.isRequired,
- placeholder: PropTypes.string,
- style: PropTypes.object,
- tabIndex: PropTypes.string,
- value: PropTypes.string.isRequired,
+ autoFocus: PropTypes.bool,
+ className: PropTypes.string,
+ deactivateErrorHighlight: PropTypes.bool,
+ disabled: PropTypes.bool,
+ error: PropTypes.bool,
+ name: PropTypes.string.isRequired,
+ onBlur: PropTypes.func,
+ onChange: PropTypes.func.isRequired,
+ onFocus: PropTypes.func,
+ placeholder: PropTypes.string,
+ style: PropTypes.object,
+ tabIndex: PropTypes.string,
+ value: PropTypes.string.isRequired,
};
export default InputSearch;
diff --git a/packages/strapi-helper-plugin/lib/src/components/InputSearchWithErrors/index.js b/packages/strapi-helper-plugin/lib/src/components/InputSearchWithErrors/index.js
index e5250e2db8..6ec5cf01c8 100644
--- a/packages/strapi-helper-plugin/lib/src/components/InputSearchWithErrors/index.js
+++ b/packages/strapi-helper-plugin/lib/src/components/InputSearchWithErrors/index.js
@@ -98,7 +98,8 @@ class InputSearchWithErrors extends React.Component { // eslint-disable-line rea
}
return (
- ;
}
- return
+ return ;
})}
);
diff --git a/packages/strapi-helper-plugin/lib/src/components/InputSelectWithErrors/index.js b/packages/strapi-helper-plugin/lib/src/components/InputSelectWithErrors/index.js
index eed8b921de..1fe21944c1 100644
--- a/packages/strapi-helper-plugin/lib/src/components/InputSelectWithErrors/index.js
+++ b/packages/strapi-helper-plugin/lib/src/components/InputSelectWithErrors/index.js
@@ -13,7 +13,7 @@ import cn from 'classnames';
import Label from 'components/Label';
import InputDescription from 'components/InputDescription';
import InputErrors from 'components/InputErrors';
-import InputSelect from 'components/InputSelect'
+import InputSelect from 'components/InputSelect';
import styles from './styles.scss';
@@ -59,7 +59,6 @@ class InputSelectWithErrors extends React.Component {
customBootstrapClass,
deactivateErrorHighlight,
disabled,
- errors,
errorsClassName,
errorsStyle,
inputClassName,
@@ -81,7 +80,8 @@ class InputSelectWithErrors extends React.Component {
} = this.props;
return (
-
{(message) => (
@@ -56,10 +57,10 @@ InputText.propTypes = {
deactivateErrorHighlight: PropTypes.bool,
disabled: PropTypes.bool,
error: PropTypes.bool,
+ name: PropTypes.string.isRequired,
onBlur: PropTypes.func,
onChange: PropTypes.func.isRequired,
onFocus: PropTypes.func,
- name: PropTypes.string.isRequired,
placeholder: PropTypes.string,
style: PropTypes.object,
tabIndex: PropTypes.string,
diff --git a/packages/strapi-helper-plugin/lib/src/components/InputTextArea/index.js b/packages/strapi-helper-plugin/lib/src/components/InputTextArea/index.js
index 1be2cebf84..8b957d82f8 100644
--- a/packages/strapi-helper-plugin/lib/src/components/InputTextArea/index.js
+++ b/packages/strapi-helper-plugin/lib/src/components/InputTextArea/index.js
@@ -4,6 +4,7 @@
*
*/
+/* eslint-disable jsx-a11y/no-autofocus */
import React from 'react';
import { FormattedMessage } from 'react-intl';
import { isEmpty } from 'lodash';
@@ -60,7 +61,9 @@ InputTextArea.propTypes = {
disabled: PropTypes.bool,
error: PropTypes.bool,
name: PropTypes.string.isRequired,
+ onBlur: PropTypes.func,
onChange: PropTypes.func.isRequired,
+ onFocus: PropTypes.func,
placeholder: PropTypes.string,
style: PropTypes.object,
tabIndex: PropTypes.string,
diff --git a/packages/strapi-helper-plugin/lib/src/components/InputTextAreaWithErrors/index.js b/packages/strapi-helper-plugin/lib/src/components/InputTextAreaWithErrors/index.js
index a2f59dcc5c..7ee2935a8a 100644
--- a/packages/strapi-helper-plugin/lib/src/components/InputTextAreaWithErrors/index.js
+++ b/packages/strapi-helper-plugin/lib/src/components/InputTextAreaWithErrors/index.js
@@ -94,7 +94,8 @@ class InputTextAreaWithErrors extends React.Component { // eslint-disable-line r
}
return (
-
{
const target = {
@@ -33,7 +34,8 @@ class InputToggle extends React.Component {
} = this.props;
return (
-
+ />
Your input type: {type} does not exist
+const DefaultInputError = ({ type }) => Your input type: {type} does not exist
;
const inputs = {
addon: InputAddonWithErrors,
@@ -50,7 +51,7 @@ function InputsIndex(props) {
inputValue = props.value || false;
break;
case 'number':
- inputValue = props.value === 0 ? props.values : props.value || '';
+ inputValue = props.value === 0 ? props.value : props.value || '';
break;
case 'file':
inputValue = props.value || [];
@@ -58,15 +59,19 @@ function InputsIndex(props) {
default:
inputValue = props.value || '';
}
-
+
const Input = inputs[type] ? inputs[type] : DefaultInputError;
return ;
}
+DefaultInputError.propTypes = {
+ type: PropTypes.string.isRequired,
+};
+
InputsIndex.defaultProps = {
addon: false,
-}
+};
InputsIndex.propTypes = {
addon: PropTypes.oneOfType([
@@ -74,6 +79,7 @@ InputsIndex.propTypes = {
PropTypes.string,
]),
type: PropTypes.string.isRequired,
+ value: PropTypes.any,
};
export default InputsIndex;
diff --git a/packages/strapi-helper-plugin/lib/src/components/Label/index.js b/packages/strapi-helper-plugin/lib/src/components/Label/index.js
index 0dbc702102..762f3bc04a 100644
--- a/packages/strapi-helper-plugin/lib/src/components/Label/index.js
+++ b/packages/strapi-helper-plugin/lib/src/components/Label/index.js
@@ -1,11 +1,12 @@
import React from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
-import { isFunction, isObject, upperFirst } from 'lodash';
+import { isFunction, isObject } from 'lodash';
import cn from 'classnames';
import styles from './styles.scss';
+/* eslint-disable jsx-a11y/label-has-for */
function Label(props) {
let content = props.children;
diff --git a/packages/strapi-helper-plugin/lib/src/components/Wysiwyg/index.js b/packages/strapi-helper-plugin/lib/src/components/Wysiwyg/index.js
index 871e09bd0c..fa44e87e7f 100644
--- a/packages/strapi-helper-plugin/lib/src/components/Wysiwyg/index.js
+++ b/packages/strapi-helper-plugin/lib/src/components/Wysiwyg/index.js
@@ -8,14 +8,13 @@ import React from 'react';
import {
ContentState,
convertFromHTML,
- Editor,
EditorState,
getDefaultKeyBinding,
Modifier,
RichUtils,
} from 'draft-js';
import PropTypes from 'prop-types';
-import { cloneDeep, isEmpty, replace, trimStart, trimEnd } from 'lodash';
+import { isEmpty, replace, trimStart, trimEnd } from 'lodash';
import cn from 'classnames';
import { FormattedMessage } from 'react-intl';
import Controls from 'components/WysiwygInlineControls';
@@ -77,52 +76,6 @@ class Wysiwyg extends React.Component {
}
}
- addEntity = (text, style) => {
- const editorState = this.state.editorState;
- const currentContent = editorState.getCurrentContent();
- // Get the selected text
- const selection = editorState.getSelection();
- const anchorKey = selection.getAnchorKey();
- const currentContentBlock = currentContent.getBlockForKey(anchorKey);
- // Range of the text we want to replace
- const { start, end } = getOffSets(selection);
- // Retrieve the selected text
- const selectedText = currentContentBlock.getText().slice(start, end);
- const innerText = selectedText === '' ? getInnerText(style) : replace(text, 'innerText', selectedText);
-
- const trimedStart = trimStart(innerText, START_REPLACER).length;
- const trimedEnd = trimEnd(innerText, END_REPLACER).length;
- // Set the correct offset
- const focusOffset = start === end ? trimedEnd : start + trimedEnd;
- const anchorOffset = start + innerText.length - trimedStart;
- // Merge the old selection with the new one so the editorState is updated
- const updateSelection = selection.merge({
- anchorOffset,
- focusOffset,
- });
-
- // Dynamically add some content to the one selected
- const textWithEntity = Modifier.replaceText(currentContent, selection, innerText);
-
- // Push the new content to the editorState
- const newEditorState = EditorState.push(editorState, textWithEntity, 'insert-characters');
-
- // SetState and force focus
- this.setState({
- editorState: EditorState.forceSelection(newEditorState, updateSelection),
- headerValue: '',
- }, () => {
- this.focus();
- });
- }
-
-
- handleChangeSelect = ({ target }) => {
- this.setState({ headerValue: target.value });
- const splitData = target.value.split('.');
- this.addEntity(splitData[0], splitData[1]);
- }
-
onChange = (editorState) => {
this.setState({ editorState });
this.props.onChange({ target: {
@@ -132,22 +85,6 @@ class Wysiwyg extends React.Component {
}});
}
- mapKeyToEditorCommand = (e) => {
- if (e.keyCode === 9 /* TAB */) {
- const newEditorState = RichUtils.onTab(
- e,
- this.state.editorState,
- 4, /* maxDepth */
- );
- if (newEditorState !== this.state.editorState) {
- this.onChange(newEditorState);
- }
- return;
- }
-
- return getDefaultKeyBinding(e);
- }
-
// NOTE: leave these function if we change to HTML instead of markdown
// toggleBlockType = (blockType) => {
// this.onChange(
@@ -167,15 +104,6 @@ class Wysiwyg extends React.Component {
// );
// }
- toggleFullScreen = (e) => {
- e.preventDefault();
- this.setState({
- toggleFullScreen: !this.state.toggleFullScreen,
- }, () => {
- this.focus();
- });
- }
-
/**
* Init the editor with data from
* @param {[type]} props [description]
@@ -190,6 +118,76 @@ class Wysiwyg extends React.Component {
this.setState({ editorState, hasInitialValue: true, initialValue: props.value });
}
+ handleChangeSelect = ({ target }) => {
+ this.setState({ headerValue: target.value });
+ const splitData = target.value.split('.');
+ this.addEntity(splitData[0], splitData[1]);
+ }
+
+ mapKeyToEditorCommand = (e) => {
+ if (e.keyCode === 9 /* TAB */) {
+ const newEditorState = RichUtils.onTab(
+ e,
+ this.state.editorState,
+ 4, /* maxDepth */
+ );
+ if (newEditorState !== this.state.editorState) {
+ this.onChange(newEditorState);
+ }
+ return;
+ }
+
+ return getDefaultKeyBinding(e);
+ }
+
+ addEntity = (text, style) => {
+ const editorState = this.state.editorState;
+ const currentContent = editorState.getCurrentContent();
+ // Get the selected text
+ const selection = editorState.getSelection();
+ const anchorKey = selection.getAnchorKey();
+ const currentContentBlock = currentContent.getBlockForKey(anchorKey);
+ // Range of the text we want to replace
+ const { start, end } = getOffSets(selection);
+ // Retrieve the selected text
+ const selectedText = currentContentBlock.getText().slice(start, end);
+ const innerText = selectedText === '' ? getInnerText(style) : replace(text, 'innerText', selectedText);
+
+ const trimedStart = trimStart(innerText, START_REPLACER).length;
+ const trimedEnd = trimEnd(innerText, END_REPLACER).length;
+ // Set the correct offset
+ const focusOffset = start === end ? trimedEnd : start + trimedEnd;
+ const anchorOffset = start + innerText.length - trimedStart;
+ // Merge the old selection with the new one so the editorState is updated
+ const updateSelection = selection.merge({
+ anchorOffset,
+ focusOffset,
+ });
+
+ // Dynamically add some content to the one selected
+ const textWithEntity = Modifier.replaceText(currentContent, selection, innerText);
+
+ // Push the new content to the editorState
+ const newEditorState = EditorState.push(editorState, textWithEntity, 'insert-characters');
+
+ // SetState and force focus
+ this.setState({
+ editorState: EditorState.forceSelection(newEditorState, updateSelection),
+ headerValue: '',
+ }, () => {
+ this.focus();
+ });
+ }
+
+ toggleFullScreen = (e) => {
+ e.preventDefault();
+ this.setState({
+ toggleFullScreen: !this.state.toggleFullScreen,
+ }, () => {
+ this.focus();
+ });
+ }
+
handleKeyCommand(command, editorState) {
const newState = RichUtils.handleKeyCommand(editorState, command);
if (newState) {
diff --git a/packages/strapi-helper-plugin/lib/src/components/WysiwygBottomControls/index.js b/packages/strapi-helper-plugin/lib/src/components/WysiwygBottomControls/index.js
index f5ef33b6f7..ce5a61f27b 100644
--- a/packages/strapi-helper-plugin/lib/src/components/WysiwygBottomControls/index.js
+++ b/packages/strapi-helper-plugin/lib/src/components/WysiwygBottomControls/index.js
@@ -6,7 +6,6 @@
import React from 'react';
import PropTypes from 'prop-types';
-import cn from 'classnames';
import { FormattedMessage } from 'react-intl';
import styles from './styles.scss';
@@ -20,7 +19,7 @@ const WysiwygBottomControls = ({ charactersNumber, onClick }) => {
);
-}
+};
WysiwygBottomControls.defaultProps = {
charactersNumber: 0,
diff --git a/packages/strapi-helper-plugin/lib/src/components/WysiwygEditor/index.js b/packages/strapi-helper-plugin/lib/src/components/WysiwygEditor/index.js
index 2ac5f93cd7..b612662639 100644
--- a/packages/strapi-helper-plugin/lib/src/components/WysiwygEditor/index.js
+++ b/packages/strapi-helper-plugin/lib/src/components/WysiwygEditor/index.js
@@ -6,13 +6,22 @@
import React from 'react';
import { Editor } from 'draft-js';
+import PropTypes from 'prop-types';
class WysiwygEditor extends React.Component {
render() {
return (
-
+
);
}
}
+WysiwygEditor.defaultProps = {
+ setRef: () => {},
+};
+
+WysiwygEditor.propTypes = {
+ setRef: PropTypes.func,
+};
+
export default WysiwygEditor;
diff --git a/packages/strapi-helper-plugin/lib/src/components/WysiwygInlineControls/index.js b/packages/strapi-helper-plugin/lib/src/components/WysiwygInlineControls/index.js
index 19f609bb54..99c22cc08e 100644
--- a/packages/strapi-helper-plugin/lib/src/components/WysiwygInlineControls/index.js
+++ b/packages/strapi-helper-plugin/lib/src/components/WysiwygInlineControls/index.js
@@ -70,6 +70,7 @@ StyleButton.defaultProps = {
onToggle: () => {},
onToggleBlock: () => {},
style: '',
+ text: '',
};
StyleButton.propTypes = {
@@ -82,6 +83,7 @@ StyleButton.propTypes = {
// onToggle: PropTypes.func,
// onToggleBlock: PropTypes.func,
style: PropTypes.string,
+ text: PropTypes.string,
};
WysiwygInlineControls.defaultProps = {
diff --git a/scripts/test.sh b/scripts/test.sh
index 51838f2985..4978f159ff 100755
--- a/scripts/test.sh
+++ b/scripts/test.sh
@@ -32,5 +32,5 @@ cd ../strapi-plugin-upload
npm run test
# Test `strapi-helper-plugin`
-# cd ../strapi-helper-plugin/lib
-# npm run test
+cd ../strapi-helper-plugin/lib
+npm run test