From 5778428067250d569516fd6635dd136af3a036f8 Mon Sep 17 00:00:00 2001 From: Aaron Carlino Date: Fri, 14 Sep 2018 13:19:10 +1200 Subject: [PATCH] All proptypes replaced with external lib --- .../components/AssetDropzone/AssetDropzone.js | 49 ++++++++++--------- client/src/components/AssetDropzone/README.md | 5 +- .../src/components/BackButton/BackButton.js | 3 +- .../GalleryItem/GalleryItemDragLayer.js | 3 +- .../src/components/GalleryItem/draggable.js | 3 +- .../src/components/GalleryItem/droppable.js | 3 +- .../tests/SelectGalleryItemTracker.js | 3 +- .../GalleryToolbar/Buttons/AddFolderButton.js | 3 +- .../GalleryToolbar/Buttons/BackButton.js | 3 +- .../GalleryToolbar/GalleryToolbar.js | 3 +- .../ProportionConstraintField.js | 3 +- .../components/UploadField/UploadFieldItem.js | 11 +++-- .../containers/AssetAdmin/AssetAdminRouter.js | 3 +- .../src/containers/AssetAdmin/stateRouter.js | 3 +- client/src/containers/Gallery/Gallery.js | 15 +++--- client/src/containers/Gallery/GalleryDND.js | 7 +-- .../src/containers/HistoryList/HistoryItem.js | 3 +- .../src/containers/HistoryList/HistoryList.js | 17 ++++--- client/src/containers/MoveModal/MoveModal.js | 27 +++++----- client/src/containers/TableView/TableView.js | 3 +- client/src/lib/configShape.js | 2 +- client/src/lib/fileShape.js | 2 +- 22 files changed, 97 insertions(+), 77 deletions(-) diff --git a/client/src/components/AssetDropzone/AssetDropzone.js b/client/src/components/AssetDropzone/AssetDropzone.js index f4790f9cc..77c74a794 100644 --- a/client/src/components/AssetDropzone/AssetDropzone.js +++ b/client/src/components/AssetDropzone/AssetDropzone.js @@ -5,6 +5,7 @@ import i18n from 'i18n'; import DropzoneLib from 'dropzone'; import $ from 'jquery'; import { getFileExtension } from 'lib/DataFormat'; +import PropTypes from 'prop-types'; let idCounter = 0; @@ -527,32 +528,32 @@ class AssetDropzone extends Component { } AssetDropzone.propTypes = { - folderId: React.PropTypes.number.isRequired, - onAccept: React.PropTypes.func, - onAddedFile: React.PropTypes.func.isRequired, - onDragEnter: React.PropTypes.func, - onDragLeave: React.PropTypes.func, - onDrop: React.PropTypes.func, - onError: React.PropTypes.func.isRequired, - onPreviewLoaded: React.PropTypes.func, - onSending: React.PropTypes.func, - onSuccess: React.PropTypes.func.isRequired, - onMaxFilesExceeded: React.PropTypes.func, - updateFormData: React.PropTypes.func, - canFileUpload: React.PropTypes.func, - options: React.PropTypes.shape({ - url: React.PropTypes.string.isRequired, + folderId: PropTypes.number.isRequired, + onAccept: PropTypes.func, + onAddedFile: PropTypes.func.isRequired, + onDragEnter: PropTypes.func, + onDragLeave: PropTypes.func, + onDrop: PropTypes.func, + onError: PropTypes.func.isRequired, + onPreviewLoaded: PropTypes.func, + onSending: PropTypes.func, + onSuccess: PropTypes.func.isRequired, + onMaxFilesExceeded: PropTypes.func, + updateFormData: PropTypes.func, + canFileUpload: PropTypes.func, + options: PropTypes.shape({ + url: PropTypes.string.isRequired, }), - promptOnRemove: React.PropTypes.string, - securityID: React.PropTypes.string.isRequired, - uploadButton: React.PropTypes.bool, - uploadSelector: React.PropTypes.string, - canUpload: React.PropTypes.bool.isRequired, - preview: React.PropTypes.shape({ - width: React.PropTypes.number, - height: React.PropTypes.number, + promptOnRemove: PropTypes.string, + securityID: PropTypes.string.isRequired, + uploadButton: PropTypes.bool, + uploadSelector: PropTypes.string, + canUpload: PropTypes.bool.isRequired, + preview: PropTypes.shape({ + width: PropTypes.number, + height: PropTypes.number, }), - className: React.PropTypes.string, + className: PropTypes.string, }; AssetDropzone.defaultProps = { diff --git a/client/src/components/AssetDropzone/README.md b/client/src/components/AssetDropzone/README.md index 9a6f54d0b..ca2dab847 100644 --- a/client/src/components/AssetDropzone/README.md +++ b/client/src/components/AssetDropzone/README.md @@ -28,6 +28,7 @@ __container.js__ ```js import React from 'react'; +import PropTypes from 'prop-types'; import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; import SilverStripeComponent from 'lib/SilverStripeComponent'; @@ -62,8 +63,8 @@ class Container extends SilverStripeComponent { } Container.propTypes = { - actions: React.PropTypes.object.isRequired, - files: React.PropTypes.array.isRequired + actions: PropTypes.object.isRequired, + files: PropTypes.array.isRequired }; function mapStateToProps(state) { diff --git a/client/src/components/BackButton/BackButton.js b/client/src/components/BackButton/BackButton.js index 39cb9a247..447750b4c 100644 --- a/client/src/components/BackButton/BackButton.js +++ b/client/src/components/BackButton/BackButton.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react'; +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; import droppable from 'components/GalleryItem/droppable'; import Badge from 'components/Badge/Badge'; import i18n from 'i18n'; diff --git a/client/src/components/GalleryItem/GalleryItemDragLayer.js b/client/src/components/GalleryItem/GalleryItemDragLayer.js index 99e8fb28a..8e111c7d1 100644 --- a/client/src/components/GalleryItem/GalleryItemDragLayer.js +++ b/client/src/components/GalleryItem/GalleryItemDragLayer.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react'; +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; import { DragLayer } from 'react-dnd'; import GalleryItem from './GalleryItem'; import Badge from 'components/Badge/Badge'; diff --git a/client/src/components/GalleryItem/draggable.js b/client/src/components/GalleryItem/draggable.js index 03b85d320..720d909f1 100644 --- a/client/src/components/GalleryItem/draggable.js +++ b/client/src/components/GalleryItem/draggable.js @@ -1,4 +1,5 @@ -import React, { Component, PropTypes } from 'react'; +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; import { DragSource } from 'react-dnd'; import { getEmptyImage } from 'react-dnd-html5-backend'; diff --git a/client/src/components/GalleryItem/droppable.js b/client/src/components/GalleryItem/droppable.js index 9fd2ec82d..ee84302d9 100644 --- a/client/src/components/GalleryItem/droppable.js +++ b/client/src/components/GalleryItem/droppable.js @@ -1,4 +1,5 @@ -import React, { Component, PropTypes } from 'react'; +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; import { DropTarget } from 'react-dnd'; export default function droppable(types) { diff --git a/client/src/components/GalleryItem/tests/SelectGalleryItemTracker.js b/client/src/components/GalleryItem/tests/SelectGalleryItemTracker.js index 6a3805e89..043178cab 100644 --- a/client/src/components/GalleryItem/tests/SelectGalleryItemTracker.js +++ b/client/src/components/GalleryItem/tests/SelectGalleryItemTracker.js @@ -1,4 +1,5 @@ -import React, { Component, PropTypes } from 'react'; +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; // eslint-disable-next-line import/no-extraneous-dependencies import { action } from '@storybook/addon-actions'; diff --git a/client/src/components/GalleryToolbar/Buttons/AddFolderButton.js b/client/src/components/GalleryToolbar/Buttons/AddFolderButton.js index 94315de6d..a355be1d6 100644 --- a/client/src/components/GalleryToolbar/Buttons/AddFolderButton.js +++ b/client/src/components/GalleryToolbar/Buttons/AddFolderButton.js @@ -1,4 +1,5 @@ -import React, { Component, PropTypes } from 'react'; +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; import i18n from 'i18n'; /** diff --git a/client/src/components/GalleryToolbar/Buttons/BackButton.js b/client/src/components/GalleryToolbar/Buttons/BackButton.js index 5e7ebca62..deddb6df9 100644 --- a/client/src/components/GalleryToolbar/Buttons/BackButton.js +++ b/client/src/components/GalleryToolbar/Buttons/BackButton.js @@ -1,4 +1,5 @@ -import React, { Component, PropTypes } from 'react'; +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; import Back from 'components/BackButton/BackButton'; /** diff --git a/client/src/components/GalleryToolbar/GalleryToolbar.js b/client/src/components/GalleryToolbar/GalleryToolbar.js index 682ac0b11..d63c85a62 100644 --- a/client/src/components/GalleryToolbar/GalleryToolbar.js +++ b/client/src/components/GalleryToolbar/GalleryToolbar.js @@ -1,4 +1,5 @@ -import React, { Component, PropTypes } from 'react'; +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; import { connect } from 'react-redux'; import BackButtonDefault from './Buttons/BackButton'; import UploadButtonDefault from './Buttons/UploadButton'; diff --git a/client/src/components/ProportionConstraintField/ProportionConstraintField.js b/client/src/components/ProportionConstraintField/ProportionConstraintField.js index d5f3e6521..9b51fd7a2 100644 --- a/client/src/components/ProportionConstraintField/ProportionConstraintField.js +++ b/client/src/components/ProportionConstraintField/ProportionConstraintField.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component, Children, cloneElement } from 'react'; +import React, { Component, Children, cloneElement } from 'react'; +import PropTypes from 'prop-types'; import { inject } from 'lib/Injector'; class ProportionConstraintField extends Component { diff --git a/client/src/components/UploadField/UploadFieldItem.js b/client/src/components/UploadField/UploadFieldItem.js index c0d8141eb..3519f6b92 100644 --- a/client/src/components/UploadField/UploadFieldItem.js +++ b/client/src/components/UploadField/UploadFieldItem.js @@ -3,6 +3,7 @@ import React, { Component } from 'react'; import CONSTANTS from 'constants'; import fileShape from 'lib/fileShape'; import { fileSize } from 'lib/DataFormat'; +import PropTypes from 'prop-types'; class UploadFieldItem extends Component { constructor(props) { @@ -374,12 +375,12 @@ class UploadFieldItem extends Component { } UploadFieldItem.propTypes = { - canEdit: React.PropTypes.bool, - name: React.PropTypes.string.isRequired, + canEdit: PropTypes.bool, + name: PropTypes.string.isRequired, item: fileShape, - onRemove: React.PropTypes.func, - onItemClick: React.PropTypes.func, - onView: React.PropTypes.func, + onRemove: PropTypes.func, + onItemClick: PropTypes.func, + onView: PropTypes.func, }; export default UploadFieldItem; diff --git a/client/src/containers/AssetAdmin/AssetAdminRouter.js b/client/src/containers/AssetAdmin/AssetAdminRouter.js index 1240cfabc..893ba422c 100644 --- a/client/src/containers/AssetAdmin/AssetAdminRouter.js +++ b/client/src/containers/AssetAdmin/AssetAdminRouter.js @@ -1,4 +1,5 @@ -import React, { Component, PropTypes } from 'react'; +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; import { connect } from 'react-redux'; import { withRouter } from 'react-router'; import AssetAdmin from 'containers/AssetAdmin/AssetAdmin'; diff --git a/client/src/containers/AssetAdmin/stateRouter.js b/client/src/containers/AssetAdmin/stateRouter.js index 5ce239739..1cd77a9ed 100644 --- a/client/src/containers/AssetAdmin/stateRouter.js +++ b/client/src/containers/AssetAdmin/stateRouter.js @@ -1,4 +1,5 @@ -import React, { Component, PropTypes } from 'react'; +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; import { connect } from 'react-redux'; import { buildUrl } from 'containers/AssetAdmin/AssetAdminRouter'; import CONSTANTS from 'constants/index'; diff --git a/client/src/containers/Gallery/Gallery.js b/client/src/containers/Gallery/Gallery.js index 0cea341d3..d068a317d 100644 --- a/client/src/containers/Gallery/Gallery.js +++ b/client/src/containers/Gallery/Gallery.js @@ -22,6 +22,7 @@ import GalleryDND from './GalleryDND'; import configShape from 'lib/configShape'; import MoveModal from '../MoveModal/MoveModal'; import { inject } from 'lib/Injector'; +import PropTypes from 'prop-types'; class Gallery extends Component { constructor(props) { @@ -1002,7 +1003,7 @@ const galleryViewPropTypes = Object.assign({}, sharedPropTypes, { selectableFolders: PropTypes.bool, onSelect: PropTypes.func, onCancelUpload: PropTypes.func, - onDelete: React.PropTypes.func, + onDelete: PropTypes.func, onRemoveErroredUpload: PropTypes.func, onEnableDropzone: PropTypes.func, }); @@ -1014,12 +1015,12 @@ Gallery.defaultProps = Object.assign({}, sharedDefaultProps, { }); Gallery.propTypes = Object.assign({}, sharedPropTypes, { - onUploadSuccess: React.PropTypes.func, - onCreateFolder: React.PropTypes.func, - onMoveFilesSuccess: React.PropTypes.func, - onDelete: React.PropTypes.func, - onPublish: React.PropTypes.func, - onUnpublish: React.PropTypes.func, + onUploadSuccess: PropTypes.func, + onCreateFolder: PropTypes.func, + onMoveFilesSuccess: PropTypes.func, + onDelete: PropTypes.func, + onPublish: PropTypes.func, + onUnpublish: PropTypes.func, type: PropTypes.oneOf(['insert-media', 'insert-link', 'select', 'admin']), view: PropTypes.oneOf(['tile', 'table']), lastSelected: PropTypes.number, diff --git a/client/src/containers/Gallery/GalleryDND.js b/client/src/containers/Gallery/GalleryDND.js index b76aa0865..35c5afa9d 100644 --- a/client/src/containers/Gallery/GalleryDND.js +++ b/client/src/containers/Gallery/GalleryDND.js @@ -4,6 +4,7 @@ import { DragDropContext } from 'react-dnd'; import HTML5Backend from 'react-dnd-html5-backend'; import classnames from 'classnames'; import GalleryItemDragLayer from 'components/GalleryItem/GalleryItemDragLayer'; +import PropTypes from 'prop-types'; // add middleware to capture the manager that is to be used // eslint-disable-next-line new-cap @@ -75,9 +76,9 @@ GalleryDND.contextTypes = { GalleryDND.propTypes = { className: PropTypes.string, - children: React.PropTypes.oneOfType([ - React.PropTypes.arrayOf(React.PropTypes.node), - React.PropTypes.node, + children: PropTypes.oneOfType([ + PropTypes.arrayOf(PropTypes.node), + PropTypes.node, ]), }; diff --git a/client/src/containers/HistoryList/HistoryItem.js b/client/src/containers/HistoryList/HistoryItem.js index e3f535acf..34bda81db 100644 --- a/client/src/containers/HistoryList/HistoryItem.js +++ b/client/src/containers/HistoryList/HistoryItem.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react'; +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; class HistoryItem extends Component { constructor(props) { diff --git a/client/src/containers/HistoryList/HistoryList.js b/client/src/containers/HistoryList/HistoryList.js index 6b14e8a47..50644a8d6 100644 --- a/client/src/containers/HistoryList/HistoryList.js +++ b/client/src/containers/HistoryList/HistoryList.js @@ -4,6 +4,7 @@ import backend from 'lib/Backend'; import Config from 'lib/Config'; import HistoryItem from 'containers/HistoryList/HistoryItem'; import FormBuilderLoader from 'containers/FormBuilderLoader/FormBuilderLoader'; +import PropTypes from 'prop-types'; const sectionConfigKey = 'SilverStripe\\AssetAdmin\\Controller\\AssetAdmin'; @@ -163,16 +164,16 @@ class HistoryList extends Component { } HistoryList.propTypes = { - sectionConfig: React.PropTypes.shape({ - form: React.PropTypes.object, - historyEndpoint: React.PropTypes.shape({ - url: React.PropTypes.string, - method: React.PropTypes.string, - responseFormat: React.PropTypes.string, + sectionConfig: PropTypes.shape({ + form: PropTypes.object, + historyEndpoint: PropTypes.shape({ + url: PropTypes.string, + method: PropTypes.string, + responseFormat: PropTypes.string, }), }), - historySchemaUrl: React.PropTypes.string, - data: React.PropTypes.object, + historySchemaUrl: PropTypes.string, + data: PropTypes.object, }; HistoryList.defaultProps = { diff --git a/client/src/containers/MoveModal/MoveModal.js b/client/src/containers/MoveModal/MoveModal.js index f03ef84a7..51da95a72 100644 --- a/client/src/containers/MoveModal/MoveModal.js +++ b/client/src/containers/MoveModal/MoveModal.js @@ -4,6 +4,7 @@ import { compose } from 'redux'; import i18n from 'i18n'; import CONSTANTS from 'constants/index'; import { +import PropTypes from 'prop-types'; deactivateModal, setNoticeMessage, setErrorMessage, @@ -74,19 +75,19 @@ class MoveModal extends React.Component { MoveModal.propTypes = { sectionConfig: configShape, - folderId: React.PropTypes.number.isRequired, - isOpen: React.PropTypes.bool, - onClosed: React.PropTypes.func, - setNotice: React.PropTypes.func, - setBadge: React.PropTypes.func, - setError: React.PropTypes.func, - title: React.PropTypes.string, - onSuccess: React.PropTypes.func, - onOpenFolder: React.PropTypes.func.isRequired, - selectedFiles: React.PropTypes.array.isRequired, - actions: React.PropTypes.shape({ - files: React.PropTypes.shape({ - moveFiles: React.PropTypes.func, + folderId: PropTypes.number.isRequired, + isOpen: PropTypes.bool, + onClosed: PropTypes.func, + setNotice: PropTypes.func, + setBadge: PropTypes.func, + setError: PropTypes.func, + title: PropTypes.string, + onSuccess: PropTypes.func, + onOpenFolder: PropTypes.func.isRequired, + selectedFiles: PropTypes.array.isRequired, + actions: PropTypes.shape({ + files: PropTypes.shape({ + moveFiles: PropTypes.func, }), }).isRequired, }; diff --git a/client/src/containers/TableView/TableView.js b/client/src/containers/TableView/TableView.js index f4f5dba59..0acf3e993 100644 --- a/client/src/containers/TableView/TableView.js +++ b/client/src/containers/TableView/TableView.js @@ -1,4 +1,5 @@ -import React, { Component, PropTypes } from 'react'; +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; import Griddle from 'griddle-react'; import i18n from 'i18n'; import { galleryViewPropTypes, galleryViewDefaultProps } from 'containers/Gallery/Gallery'; diff --git a/client/src/lib/configShape.js b/client/src/lib/configShape.js index 1dad0f5a0..f5d67f309 100644 --- a/client/src/lib/configShape.js +++ b/client/src/lib/configShape.js @@ -1,4 +1,4 @@ -import { PropTypes } from 'react'; +import PropTypes from 'prop-types'; const configShape = PropTypes.shape({ url: PropTypes.string, diff --git a/client/src/lib/fileShape.js b/client/src/lib/fileShape.js index 0e87b070e..80f6245cc 100644 --- a/client/src/lib/fileShape.js +++ b/client/src/lib/fileShape.js @@ -1,4 +1,4 @@ -import { PropTypes } from 'react'; +import PropTypes from 'prop-types'; const fileShape = PropTypes.shape({ canEdit: PropTypes.bool,