Commit 364be4d4 authored by Florent Chehab's avatar Florent Chehab

Fixes #47

All proptypes have been added when possible
parent 91cf918f
Pipeline #35286 passed with stages
in 3 minutes and 23 seconds
......@@ -35,8 +35,8 @@ module.exports = {
"error",
"always"
],
"react/no-unescaped-entities": "warn",
"react/prop-types": "warn",
"react/no-unescaped-entities": "off", // that one doesn't improve code readability
"react/prop-types": "error",
"react/no-deprecated": "warn"
}
};
import React, { Component } from "react";
import Loading from "./other/Loading";
import PropTypes from "prop-types";
// Stores the name of the reducers/actions that result in read data
const successActionsWithReads = ["readSucceeded", "createSucceeded", "updateSucceeded"];
......@@ -254,4 +256,8 @@ class CustomComponentForAPI extends Component {
}
}
CustomComponentForAPI.propTypes = {
api: PropTypes.object
};
export default CustomComponentForAPI;
......@@ -84,10 +84,10 @@ class DownshiftMultiple extends React.Component {
const { selectedItems } = this.state;
let possible = __difference(options, selectedItems);
const filter = fuzzysort.go(value, possible, { limit: 5, key: "label" });
if (filter.length > 0){
if (filter.length > 0) {
return __map(filter, (item) => item.obj);
} else {
return possible.slice(0,4);
return possible.slice(0, 4);
}
}
......@@ -142,51 +142,54 @@ class DownshiftMultiple extends React.Component {
onChange={this.handleChange}
selectedItem={selectedItems}
>
{({
getInputProps,
getItemProps,
isOpen,
inputValue: inputValue2,
selectedItem: selectedItem2,
highlightedIndex,
}) => (
<div className={classes.container}>
{renderInput({
fullWidth: true,
classes,
InputProps: getInputProps({
startAdornment: selectedItems.map(item => (
<Chip
key={item.id}
tabIndex={-1}
label={item.label}
className={classes.chip}
onDelete={this.handleDelete(item.id)}
variant="outlined"
color="primary"
/>
)),
onChange: this.handleInputChange,
onKeyDown: this.handleKeyDown,
placeholder: field_placeholder,
}),
label: field_label,
})}
{isOpen ? (
<Paper className={classes.paper} square>
{this.getSuggestions(inputValue2).map((suggestion, index) =>
renderSuggestion({
suggestion,
index,
itemProps: getItemProps({ item: suggestion.id }),
highlightedIndex,
selectedItem: selectedItem2,
{
({
getInputProps,
getItemProps,
isOpen,
inputValue: inputValue2,
selectedItem: selectedItem2,
highlightedIndex,
}) =>
(
<div className={classes.container}>
{renderInput({
fullWidth: true,
classes,
InputProps: getInputProps({
startAdornment: selectedItems.map(item => (
<Chip
key={item.id}
tabIndex={-1}
label={item.label}
className={classes.chip}
onDelete={this.handleDelete(item.id)}
variant="outlined"
color="primary"
/>
)),
onChange: this.handleInputChange,
onKeyDown: this.handleKeyDown,
placeholder: field_placeholder,
}),
)}
</Paper>
) : null}
</div>
)}
label: field_label,
})}
{isOpen ? (
<Paper className={classes.paper} square>
{this.getSuggestions(inputValue2).map((suggestion, index) =>
renderSuggestion({
suggestion,
index,
itemProps: getItemProps({ item: suggestion.id }),
highlightedIndex,
selectedItem: selectedItem2,
}),
)}
</Paper>
) : null}
</div>
)
}
</Downshift>
</div>
......@@ -196,6 +199,12 @@ class DownshiftMultiple extends React.Component {
DownshiftMultiple.propTypes = {
classes: PropTypes.object.isRequired,
onComponentUnmount: PropTypes.func.isRequired,
onChange: PropTypes.func.isRequired,
config: PropTypes.object.isRequired,
field_label: PropTypes.string.isRequired,
field_placeholder: PropTypes.string.isRequired,
options: PropTypes.array.isRequired,
};
DownshiftMultiple.defaultProps = {
......
import React, { Component } from "react";
import PropTypes from "prop-types";
import CardMedia from "@material-ui/core/CardMedia";
class MyCardMedia extends Component {
......@@ -6,7 +7,7 @@ class MyCardMedia extends Component {
render() {
const { title, height, url } = this.props;
if (url == "") {
return (<div/>);
return (<div />);
}
return (
<CardMedia
......@@ -20,5 +21,10 @@ class MyCardMedia extends Component {
}
}
MyCardMedia.propTypes = {
title: PropTypes.string.isRequired,
height: PropTypes.string.isRequired,
url: PropTypes.string.isRequired,
};
export default MyCardMedia;
\ No newline at end of file
export default MyCardMedia;
......@@ -74,6 +74,12 @@ class UnivPopupContent extends Component {
UnivPopupContent.propTypes = {
classes: PropTypes.object.isRequired,
logo: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
city: PropTypes.string.isRequired,
country: PropTypes.string.isRequired,
univId: PropTypes.number.isRequired,
leaflet: PropTypes.object.isRequired,
};
export default withLeaflet(withStyles(styles)(UnivPopupContent));
\ No newline at end of file
export default withLeaflet(withStyles(styles)(UnivPopupContent));
......@@ -87,7 +87,7 @@ class UnivList extends React.Component {
<Divider />
{__map(__range((page) * itemsPerPage, Math.min((page + 1) * itemsPerPage, numberOfItems)),
univ_ind => (
<Link to={"/app/university/"+universitiesToList[univ_ind].id}>
<Link to={"/app/university/"+universitiesToList[univ_ind].id} key={univ_ind}>
<ListItem button divider={true} key={univ_ind}>
<ListItemText primary={universitiesToList[univ_ind].name} />
</ListItem>
......@@ -126,6 +126,8 @@ class UnivList extends React.Component {
UnivList.propTypes = {
classes: PropTypes.object.isRequired,
theme: PropTypes.object.isRequired,
universitiesToList: PropTypes.object.isRequired, // TODO fix type issue, sometimes is array, sometimes is object
itemsPerPage: PropTypes.number.isRequired,
};
UnivList.defaultProps = {
......
/* eslint-disable react/prop-types */
/* eslint-disable react/display-name */
// Inspired by : https://github.com/mui-org/material-ui/blob/master/docs/src/pages/page-layout-examples/blog/Markdown.js
......
......@@ -42,6 +42,7 @@ function TabContainer(props) {
TabContainer.propTypes = {
children: PropTypes.node.isRequired,
visible: PropTypes.bool.isRequired
};
const styles = theme => ({
......@@ -110,6 +111,7 @@ class UniversityTemplate extends React.Component {
UniversityTemplate.propTypes = {
classes: PropTypes.object.isRequired,
width: PropTypes.string.isRequired,
};
export default compose(
......
......@@ -99,6 +99,7 @@ Alert.propTypes = {
handleClose: PropTypes.func.isRequired,
handleResponse: PropTypes.func.isRequired,
multilineButtons: PropTypes.bool.isRequired,
classes: PropTypes.object.isRequired
};
......
......@@ -68,6 +68,7 @@ class History extends React.Component {
}
getContentTypeAndId() {
// eslint-disable-next-line react/prop-types
const { rawModelData } = this.props.factory.props;
const { content_type_id, id } = rawModelData;
return { content_type_id, id };
......@@ -199,6 +200,11 @@ History.propTypes = {
classes: PropTypes.object.isRequired,
factory: PropTypes.object.isRequired,
handleRestoreVersion: PropTypes.func.isRequired,
readVersions: PropTypes.func.isRequired,
handleCloseHistory: PropTypes.func.isRequired,
resetVersions: PropTypes.func.isRequired,
open: PropTypes.bool.isRequired,
versions: PropTypes.object.isRequired
};
History.defaultProps = {
......
......@@ -119,6 +119,9 @@ PendingModeration.propTypes = {
classes: PropTypes.object.isRequired,
factory: PropTypes.object.isRequired,
handleEditPendingModeration: PropTypes.func.isRequired,
handleClosePendingModeration: PropTypes.func.isRequired,
handleApproveModeration: PropTypes.func.isRequired,
open: PropTypes.bool.isRequired,
userCanModerate: PropTypes.bool.isRequired,
};
......
......@@ -153,6 +153,7 @@ Scholarship.propTypes = {
otherAdvantages: PropTypes.string,
amountMin: PropTypes.string,
amountMax: PropTypes.string,
currencies: PropTypes.object.isRequired,
};
export default withStyles(styles, { withTheme: true })(Scholarship);
......@@ -58,7 +58,8 @@ Field.propTypes = {
required: PropTypes.bool.isRequired,
label: PropTypes.string,
formManager: PropTypes.object.isRequired,
fieldMapping: PropTypes.string.isRequired
fieldMapping: PropTypes.string.isRequired,
value: PropTypes.isRequired
};
export default Field;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment