Skip to content

Commit

Permalink
All proptypes replaced with external lib
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Carlino committed Sep 14, 2018
1 parent 61a4ebb commit 5778428
Show file tree
Hide file tree
Showing 22 changed files with 97 additions and 77 deletions.
49 changes: 25 additions & 24 deletions client/src/components/AssetDropzone/AssetDropzone.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 = {
Expand Down
5 changes: 3 additions & 2 deletions client/src/components/AssetDropzone/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/BackButton/BackButton.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/GalleryItem/GalleryItemDragLayer.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/GalleryItem/draggable.js
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
3 changes: 2 additions & 1 deletion client/src/components/GalleryItem/droppable.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { Component, PropTypes } from 'react';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import i18n from 'i18n';

/**
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/GalleryToolbar/Buttons/BackButton.js
Original file line number Diff line number Diff line change
@@ -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';

/**
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/GalleryToolbar/GalleryToolbar.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
11 changes: 6 additions & 5 deletions client/src/components/UploadField/UploadFieldItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
3 changes: 2 additions & 1 deletion client/src/containers/AssetAdmin/AssetAdminRouter.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
3 changes: 2 additions & 1 deletion client/src/containers/AssetAdmin/stateRouter.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
15 changes: 8 additions & 7 deletions client/src/containers/Gallery/Gallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
});
Expand All @@ -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,
Expand Down
7 changes: 4 additions & 3 deletions client/src/containers/Gallery/GalleryDND.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
]),
};

Expand Down
3 changes: 2 additions & 1 deletion client/src/containers/HistoryList/HistoryItem.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
17 changes: 9 additions & 8 deletions client/src/containers/HistoryList/HistoryList.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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 = {
Expand Down
27 changes: 14 additions & 13 deletions client/src/containers/MoveModal/MoveModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
};
Expand Down
3 changes: 2 additions & 1 deletion client/src/containers/TableView/TableView.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion client/src/lib/configShape.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PropTypes } from 'react';
import PropTypes from 'prop-types';

const configShape = PropTypes.shape({
url: PropTypes.string,
Expand Down
2 changes: 1 addition & 1 deletion client/src/lib/fileShape.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PropTypes } from 'react';
import PropTypes from 'prop-types';

const fileShape = PropTypes.shape({
canEdit: PropTypes.bool,
Expand Down

0 comments on commit 5778428

Please sign in to comment.