chore: add missing react prop types (#1651)

This commit is contained in:
Caleb 2018-08-27 10:23:21 -06:00 committed by Shawn Erquhart
parent e215f6889c
commit 922b1846cb
39 changed files with 245 additions and 8 deletions

View File

@ -12,6 +12,9 @@ export default class BitbucketAuthenticationPage extends React.Component {
static propTypes = {
onLogin: PropTypes.func.isRequired,
inProgress: PropTypes.bool,
base_url: PropTypes.string,
siteId: PropTypes.string,
authEndpoint: PropTypes.string,
};
state = {};

View File

@ -99,6 +99,7 @@ export default class GitGatewayAuthenticationPage extends React.Component {
static propTypes = {
onLogin: PropTypes.func.isRequired,
inProgress: PropTypes.bool.isRequired,
error: PropTypes.node,
};
state = { email: '', password: '', errors: {} };

View File

@ -1,5 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
import styled from 'react-emotion';
import { NetlifyAuthenticator } from 'netlify-cms-lib-auth';
import { AuthenticationPage, Icon } from 'netlify-cms-ui-default';
@ -15,6 +16,8 @@ export default class GitHubAuthenticationPage extends React.Component {
base_url: PropTypes.string,
siteId: PropTypes.string,
authEndpoint: PropTypes.string,
config: ImmutablePropTypes.map,
clearHash: PropTypes.function,
};
state = {};

View File

@ -1,5 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
import styled from 'react-emotion';
import { NetlifyAuthenticator, ImplicitAuthenticator } from 'netlify-cms-lib-auth';
import { AuthenticationPage, Icon } from 'netlify-cms-ui-default';
@ -12,6 +13,11 @@ export default class GitLabAuthenticationPage extends React.Component {
static propTypes = {
onLogin: PropTypes.func.isRequired,
inProgress: PropTypes.bool,
base_url: PropTypes.string,
siteId: PropTypes.string,
authEndpoint: PropTypes.string,
config: ImmutablePropTypes.map,
clearHash: PropTypes.function,
};
state = {};

View File

@ -59,6 +59,7 @@ class App extends React.Component {
isFetching: PropTypes.bool.isRequired,
publishMode: PropTypes.oneOf([SIMPLE, EDITORIAL_WORKFLOW]),
siteId: PropTypes.string,
openMediaLibrary: PropTypes.func.isRequired,
};
static configError(config) {

View File

@ -105,6 +105,8 @@ export default class Header extends React.Component {
collections: ImmutablePropTypes.orderedMap.isRequired,
onCreateEntryClick: PropTypes.func.isRequired,
onLogoutClick: PropTypes.func.isRequired,
openMediaLibrary: PropTypes.func.isRequired,
hasWorkflow: PropTypes.bool.isRequired,
displayUrl: PropTypes.string,
};

View File

@ -1,4 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
import styled from 'react-emotion';
import { connect } from 'react-redux';
@ -20,6 +21,9 @@ const CollectionMain = styled.main`
class Collection extends React.Component {
static propTypes = {
searchTerm: PropTypes.string,
collectionName: PropTypes.string,
isSearchResults: PropTypes.bool,
collection: ImmutablePropTypes.map.isRequired,
collections: ImmutablePropTypes.orderedMap.isRequired,
};

View File

@ -105,7 +105,10 @@ const CollectionTop = ({
CollectionTop.propTypes = {
collectionLabel: PropTypes.string.isRequired,
collectionLabelSingular: PropTypes.string,
collectionDescription: PropTypes.string,
viewStyle: PropTypes.oneOf([VIEW_STYLE_LIST, VIEW_STYLE_GRID]).isRequired,
onChangeViewStyle: PropTypes.func.isRequired,
newEntryUrl: PropTypes.string,
};

View File

@ -18,10 +18,11 @@ const CardsGrid = styled.ul`
export default class EntryListing extends React.Component {
static propTypes = {
publicFolder: PropTypes.string.isRequired,
collections: PropTypes.oneOfType([ImmutablePropTypes.map, ImmutablePropTypes.iterable])
.isRequired,
collections: ImmutablePropTypes.iterable.isRequired,
entries: ImmutablePropTypes.list,
viewStyle: PropTypes.string,
cursor: PropTypes.any.isRequired,
handleCursorActions: PropTypes.func.isRequired,
};
handleLoadMore = () => {

View File

@ -1,4 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
import styled, { css } from 'react-emotion';
import { NavLink } from 'react-router-dom';
@ -89,9 +90,14 @@ const SidebarNavLink = styled(NavLink)`
export default class Sidebar extends React.Component {
static propTypes = {
collections: ImmutablePropTypes.orderedMap.isRequired,
searchTerm: PropTypes.string,
};
state = { query: this.props.searchTerm || '' };
static defaultProps = {
searchTerm: '',
};
state = { query: this.props.searchTerm };
renderLink = collection => {
const collectionName = collection.get('name');

View File

@ -61,8 +61,14 @@ class Editor extends React.Component {
updateUnpublishedEntryStatus: PropTypes.func.isRequired,
publishUnpublishedEntry: PropTypes.func.isRequired,
deleteUnpublishedEntry: PropTypes.func.isRequired,
currentStatus: PropTypes.string,
logoutUser: PropTypes.func.isRequired,
loadEntries: PropTypes.func.isRequired,
currentStatus: PropTypes.string,
user: ImmutablePropTypes.map.isRequired,
location: PropTypes.shape({
pathname: PropTypes.string,
}),
hasChanged: PropTypes.bool,
};
componentDidMount() {

View File

@ -1,4 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
import styled, { css, cx } from 'react-emotion';
import { partial, uniqueId } from 'lodash';
import { connect } from 'react-redux';
@ -113,6 +115,30 @@ export const ControlHint = styled.p`
`;
class EditorControl extends React.Component {
static propTypes = {
value: PropTypes.oneOfType([
PropTypes.node,
PropTypes.object,
PropTypes.string,
PropTypes.bool,
]),
field: ImmutablePropTypes.map.isRequired,
fieldsMetaData: ImmutablePropTypes.map,
fieldsErrors: ImmutablePropTypes.map,
mediaPaths: ImmutablePropTypes.map.isRequired,
boundGetAsset: PropTypes.func.isRequired,
onChange: PropTypes.func.isRequired,
openMediaLibrary: PropTypes.func.isRequired,
addAsset: PropTypes.func.isRequired,
removeInsertedMedia: PropTypes.func.isRequired,
onValidate: PropTypes.func,
processControlRef: PropTypes.func,
query: PropTypes.func.isRequired,
queryHits: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
isFetching: PropTypes.bool,
clearSearch: PropTypes.func.isRequired,
};
state = {
activeLabel: false,
};

View File

@ -44,6 +44,8 @@ export default class Widget extends Component {
query: PropTypes.func.isRequired,
clearSearch: PropTypes.func.isRequired,
queryHits: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
editorControl: PropTypes.func.isRequired,
uniqueFieldId: PropTypes.string.isRequired,
};
shouldComponentUpdate(nextProps) {

View File

@ -281,7 +281,7 @@ EditorInterface.propTypes = {
onDeleteUnpublishedChanges: PropTypes.func.isRequired,
onPublish: PropTypes.func.isRequired,
onChangeStatus: PropTypes.func.isRequired,
user: ImmutablePropTypes.map,
user: ImmutablePropTypes.map.isRequired,
hasChanged: PropTypes.bool,
displayUrl: PropTypes.string,
hasWorkflow: PropTypes.bool,

View File

@ -25,4 +25,9 @@ PreviewContent.contextTypes = {
document: PropTypes.any,
};
PreviewContent.propTypes = {
previewComponent: PropTypes.func.isRequired,
previewProps: PropTypes.object,
};
export default PreviewContent;

View File

@ -1,4 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
class PreviewHOC extends React.Component {
/**
@ -17,4 +19,10 @@ class PreviewHOC extends React.Component {
}
}
PreviewHOC.propTypes = {
previewComponent: PropTypes.func.isRequired,
field: ImmutablePropTypes.map.isRequired,
value: PropTypes.oneOfType([PropTypes.node, PropTypes.object, PropTypes.string, PropTypes.bool]),
};
export default PreviewHOC;

View File

@ -180,7 +180,7 @@ export default class EditorToolbar extends React.Component {
onChangeStatus: PropTypes.func.isRequired,
onPublish: PropTypes.func.isRequired,
onPublishAndNew: PropTypes.func.isRequired,
user: ImmutablePropTypes.map,
user: ImmutablePropTypes.map.isRequired,
hasChanged: PropTypes.bool,
displayUrl: PropTypes.string,
collection: ImmutablePropTypes.map.isRequired,

View File

@ -1,4 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
import { connect } from 'react-redux';
import { orderBy, map } from 'lodash';
import { Map } from 'immutable';
@ -21,7 +23,41 @@ import MediaLibraryModal from './MediaLibraryModal';
const IMAGE_EXTENSIONS_VIEWABLE = ['jpg', 'jpeg', 'webp', 'gif', 'png', 'bmp', 'tiff', 'svg'];
const IMAGE_EXTENSIONS = [...IMAGE_EXTENSIONS_VIEWABLE];
const fileShape = {
key: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
size: PropTypes.number.isRequired,
queryOrder: PropTypes.number,
url: PropTypes.string.isRequired,
urlIsPublicPath: PropTypes.bool,
};
class MediaLibrary extends React.Component {
static propTypes = {
isVisible: PropTypes.bool,
loadMediaDisplayURL: PropTypes.func,
displayURLs: ImmutablePropTypes.map,
canInsert: PropTypes.bool,
files: PropTypes.arrayOf(PropTypes.shape(fileShape)).isRequired,
dynamicSearch: PropTypes.bool,
dynamicSearchActive: PropTypes.bool,
forImage: PropTypes.bool,
isLoading: PropTypes.bool,
isPersisting: PropTypes.bool,
isDeleting: PropTypes.bool,
hasNextPage: PropTypes.bool,
isPaginating: PropTypes.bool,
privateUpload: PropTypes.bool,
loadMedia: PropTypes.func.isRequired,
dynamicSearchQuery: PropTypes.string,
page: PropTypes.number,
persistMedia: PropTypes.func.isRequired,
deleteMedia: PropTypes.func.isRequired,
insertMedia: PropTypes.func.isRequired,
publicFolder: PropTypes.string,
closeMediaLibrary: PropTypes.func.isRequired,
};
/**
* The currently selected file and query are tracked in component state as
* they do not impact the rest of the application.

View File

@ -25,6 +25,7 @@ export const DragSource = ({ namespace, ...props }) => {
return React.createElement(DragComponent, props, props.children);
};
DragSource.propTypes = {
namespace: PropTypes.any.isRequired,
children: PropTypes.func.isRequired,
};
@ -46,6 +47,7 @@ export const DropTarget = ({ onDrop, namespace, ...props }) => {
};
DropTarget.propTypes = {
onDrop: PropTypes.func.isRequired,
namespace: PropTypes.any.isRequired,
children: PropTypes.func.isRequired,
};

View File

@ -1,4 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import { css } from 'react-emotion';
import { colors } from 'netlify-cms-ui-default';
@ -14,6 +15,10 @@ const styles = {
};
export class ErrorBoundary extends React.Component {
static propTypes = {
children: PropTypes.node,
};
state = {
hasError: false,
errorMessage: '',

View File

@ -14,6 +14,7 @@ export const FileUploadButton = ({ label, imagesOnly, onChange, disabled, classN
);
FileUploadButton.propTypes = {
className: PropTypes.string,
label: PropTypes.string.isRequired,
imagesOnly: PropTypes.bool,
onChange: PropTypes.func.isRequired,

View File

@ -1,4 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import styled, { css } from 'react-emotion';
import { Icon, Dropdown, DropdownItem, DropdownButton, colors } from 'netlify-cms-ui-default';
import { stripProtocol } from 'Lib/urlHelper';
@ -42,6 +43,10 @@ const Avatar = ({ imageUrl }) => (
</AppHeaderAvatar>
);
Avatar.propTypes = {
imageUrl: PropTypes.string,
};
const SettingsDropdown = ({ displayUrl, imageUrl, onLogoutClick }) => (
<React.Fragment>
{displayUrl ? (
@ -64,4 +69,10 @@ const SettingsDropdown = ({ displayUrl, imageUrl, onLogoutClick }) => (
</React.Fragment>
);
SettingsDropdown.propTypes = {
displayUrl: PropTypes.string,
imageUrl: PropTypes.string,
onLogoutClick: PropTypes.func.isRequired,
};
export default SettingsDropdown;

View File

@ -1,4 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import styled, { css } from 'react-emotion';
import { Link } from 'react-router-dom';
import { components, colors, colorsRaw, transitions, buttons } from 'netlify-cms-ui-default';
@ -127,4 +128,17 @@ const WorkflowCard = ({
</WorkflowCardContainer>
);
WorkflowCard.propTypes = {
collectionName: PropTypes.string.isRequired,
title: PropTypes.string.isRequired,
authorLastChange: PropTypes.string.isRequired,
body: PropTypes.string.isRequired,
isModification: PropTypes.bool,
editLink: PropTypes.string.isRequired,
timestamp: PropTypes.string.isRequired,
onDelete: PropTypes.func.isRequired,
canPublish: PropTypes.bool.isRequired,
onPublish: PropTypes.func.isRequired,
};
export default WorkflowCard;

View File

@ -1,4 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import styled from 'react-emotion';
import Icon from './Icon';
import { buttons, shadows } from './styles';
@ -50,4 +51,12 @@ const AuthenticationPage = ({
);
};
AuthenticationPage.propTypes = {
onLogin: PropTypes.func,
loginDisabled: PropTypes.bool,
loginErrorMessage: PropTypes.node,
renderButtonContent: PropTypes.func,
renderPageContent: PropTypes.func,
};
export default AuthenticationPage;

View File

@ -1,4 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import styled, { css } from 'react-emotion';
import { Wrapper, Button as DropdownButton, Menu, MenuItem } from 'react-aria-menubutton';
import { buttons, components } from './styles';
@ -76,6 +77,15 @@ const Dropdown = ({
);
};
Dropdown.propTypes = {
renderButton: PropTypes.func.isRequired,
dropdownWidth: PropTypes.string,
dropdownPosition: PropTypes.string,
dropdownTopOverlap: PropTypes.string,
className: PropTypes.string,
children: PropTypes.node,
};
const DropdownItem = ({ label, icon, iconDirection, onClick, className }) => (
<StyledMenuItem value={onClick} className={className}>
<span>{label}</span>
@ -87,4 +97,12 @@ const DropdownItem = ({ label, icon, iconDirection, onClick, className }) => (
</StyledMenuItem>
);
DropdownItem.propTypes = {
label: PropTypes.string,
icon: PropTypes.string,
iconDirection: PropTypes.string,
onClick: PropTypes.func,
className: PropTypes.string,
};
export { Dropdown as default, DropdownItem, DropdownButton, StyledDropdownButton };

View File

@ -1,4 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import styled from 'react-emotion';
import icons from './Icon/icons';
@ -59,4 +60,11 @@ const Icon = ({ type, direction, size = 'medium', className }) => (
/>
);
Icon.propTypes = {
type: PropTypes.string.isRequired,
direction: PropTypes.oneOf(['right', 'down', 'left', 'up']),
size: PropTypes.string,
className: PropTypes.string,
};
export default styled(Icon)``;

View File

@ -1,4 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import styled from 'react-emotion';
import Icon from './Icon';
import { colors, lengths, buttons } from './styles';
@ -58,6 +59,13 @@ const ListItemTopBar = ({ className, collapsed, onCollapseToggle, onRemove, drag
</TopBar>
);
ListItemTopBar.propTypes = {
className: PropTypes.string,
collapsed: PropTypes.bool,
onCollapseToggle: PropTypes.func,
onRemove: PropTypes.func,
};
const StyledListItemTopBar = styled(ListItemTopBar)`
display: flex;
justify-content: space-between;

View File

@ -1,4 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import styled, { css, keyframes } from 'react-emotion';
import CSSTransition from 'react-transition-group/CSSTransition';
import { colors } from './styles';
@ -54,6 +55,11 @@ const LoaderItem = styled.div`
`;
export class Loader extends React.Component {
static propTypes = {
children: PropTypes.node,
className: PropTypes.string,
};
state = {
currentItem: 0,
};

View File

@ -1,4 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import styled, { css } from 'react-emotion';
import Icon from './Icon';
import { colors, buttons } from './styles';
@ -73,4 +74,13 @@ const ObjectWidgetTopBar = ({
</TopBarContainer>
);
ObjectWidgetTopBar.propTypes = {
allowAdd: PropTypes.bool,
onAdd: PropTypes.func,
onCollapseToggle: PropTypes.func,
collapsed: PropTypes.bool,
heading: PropTypes.node,
label: PropTypes.string,
};
export default ObjectWidgetTopBar;

View File

@ -1,4 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import styled, { css } from 'react-emotion';
import ReactToggled from 'react-toggled';
import { colors, colorsRaw, shadows, transitions } from './styles';
@ -65,6 +66,17 @@ const Toggle = ({
</ReactToggled>
);
Toggle.propTypes = {
active: PropTypes.bool,
onChange: PropTypes.func,
onFocus: PropTypes.func,
onBlur: PropTypes.func,
className: PropTypes.string,
Container: PropTypes.func,
Background: PropTypes.func,
Handle: PropTypes.func,
};
const StyledToggle = styled(Toggle)``;
export { StyledToggle as default, ToggleContainer, ToggleBackground, ToggleHandle };

View File

@ -61,6 +61,7 @@ const valueTypes = {
export default class ListControl extends React.Component {
static propTypes = {
metadata: ImmutablePropTypes.map,
onChange: PropTypes.func.isRequired,
onChangeObject: PropTypes.func.isRequired,
value: ImmutablePropTypes.list,
@ -74,6 +75,8 @@ export default class ListControl extends React.Component {
classNameWrapper: PropTypes.string.isRequired,
setActiveStyle: PropTypes.func.isRequired,
setInactiveStyle: PropTypes.func.isRequired,
editorControl: PropTypes.func.isRequired,
resolveWidget: PropTypes.func.isRequired,
};
static defaultProps = {

View File

@ -99,5 +99,5 @@ RawEditor.propTypes = {
onMode: PropTypes.func.isRequired,
className: PropTypes.string.isRequired,
value: PropTypes.string,
field: ImmutablePropTypes.map,
field: ImmutablePropTypes.map.isRequired,
};

View File

@ -1,3 +1,5 @@
/* eslint-disable react/prop-types */
import React from 'react';
import { Map } from 'immutable';
import styled, { css } from 'react-emotion';

View File

@ -64,6 +64,12 @@ export default class Toolbar extends React.Component {
onAddAsset: PropTypes.func,
getAsset: PropTypes.func,
disabled: PropTypes.bool,
onMarkClick: PropTypes.func,
onBlockClick: PropTypes.func,
onLinkClick: PropTypes.func,
selectionHasMark: PropTypes.func,
selectionHasBlock: PropTypes.func,
selectionHasLink: PropTypes.func,
};
isHidden = button => {

View File

@ -46,6 +46,7 @@ ToolbarButton.propTypes = {
icon: PropTypes.string,
onClick: PropTypes.func,
isActive: PropTypes.func,
isHidden: PropTypes.bool,
disabled: PropTypes.bool,
};

View File

@ -40,7 +40,8 @@ export default class Editor extends React.Component {
onMode: PropTypes.func.isRequired,
className: PropTypes.string.isRequired,
value: PropTypes.string,
field: ImmutablePropTypes.map,
field: ImmutablePropTypes.map.isRequired,
getEditorComponents: PropTypes.func.isRequired,
};
constructor(props) {

View File

@ -1,5 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
import RawEditor from './RawEditor';
import VisualEditor from './VisualEditor';
@ -19,6 +20,8 @@ export default class MarkdownControl extends React.Component {
classNameWrapper: PropTypes.string.isRequired,
editorControl: PropTypes.func.isRequired,
value: PropTypes.string,
field: ImmutablePropTypes.map.isRequired,
getEditorComponents: PropTypes.func,
};
static defaultProps = {

View File

@ -1,3 +1,5 @@
/* eslint-disable react/prop-types */
import React from 'react';
import Shortcode from './Shortcode';

View File

@ -1,8 +1,10 @@
import React from 'react';
import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
export default class NumberControl extends React.Component {
static propTypes = {
field: ImmutablePropTypes.map.isRequired,
onChange: PropTypes.func.isRequired,
classNameWrapper: PropTypes.string.isRequired,
setActiveStyle: PropTypes.func.isRequired,