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

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 = { ...@@ -35,8 +35,8 @@ module.exports = {
"error", "error",
"always" "always"
], ],
"react/no-unescaped-entities": "warn", "react/no-unescaped-entities": "off", // that one doesn't improve code readability
"react/prop-types": "warn", "react/prop-types": "error",
"react/no-deprecated": "warn" "react/no-deprecated": "warn"
} }
}; };
import React, { Component } from "react"; import React, { Component } from "react";
import Loading from "./other/Loading"; import Loading from "./other/Loading";
import PropTypes from "prop-types";
// Stores the name of the reducers/actions that result in read data // Stores the name of the reducers/actions that result in read data
const successActionsWithReads = ["readSucceeded", "createSucceeded", "updateSucceeded"]; const successActionsWithReads = ["readSucceeded", "createSucceeded", "updateSucceeded"];
...@@ -254,4 +256,8 @@ class CustomComponentForAPI extends Component { ...@@ -254,4 +256,8 @@ class CustomComponentForAPI extends Component {
} }
} }
CustomComponentForAPI.propTypes = {
api: PropTypes.object
};
export default CustomComponentForAPI; export default CustomComponentForAPI;
...@@ -84,10 +84,10 @@ class DownshiftMultiple extends React.Component { ...@@ -84,10 +84,10 @@ class DownshiftMultiple extends React.Component {
const { selectedItems } = this.state; const { selectedItems } = this.state;
let possible = __difference(options, selectedItems); let possible = __difference(options, selectedItems);
const filter = fuzzysort.go(value, possible, { limit: 5, key: "label" }); const filter = fuzzysort.go(value, possible, { limit: 5, key: "label" });
if (filter.length > 0){ if (filter.length > 0) {
return __map(filter, (item) => item.obj); return __map(filter, (item) => item.obj);
} else { } else {
return possible.slice(0,4); return possible.slice(0, 4);
} }
} }
...@@ -142,51 +142,54 @@ class DownshiftMultiple extends React.Component { ...@@ -142,51 +142,54 @@ class DownshiftMultiple extends React.Component {
onChange={this.handleChange} onChange={this.handleChange}
selectedItem={selectedItems} selectedItem={selectedItems}
> >
{({ {
getInputProps, ({
getItemProps, getInputProps,
isOpen, getItemProps,
inputValue: inputValue2, isOpen,
selectedItem: selectedItem2, inputValue: inputValue2,
highlightedIndex, selectedItem: selectedItem2,
}) => ( highlightedIndex,
<div className={classes.container}> }) =>
{renderInput({ (
fullWidth: true, <div className={classes.container}>
classes, {renderInput({
InputProps: getInputProps({ fullWidth: true,
startAdornment: selectedItems.map(item => ( classes,
<Chip InputProps: getInputProps({
key={item.id} startAdornment: selectedItems.map(item => (
tabIndex={-1} <Chip
label={item.label} key={item.id}
className={classes.chip} tabIndex={-1}
onDelete={this.handleDelete(item.id)} label={item.label}
variant="outlined" className={classes.chip}
color="primary" onDelete={this.handleDelete(item.id)}
/> variant="outlined"
)), color="primary"
onChange: this.handleInputChange, />
onKeyDown: this.handleKeyDown, )),
placeholder: field_placeholder, onChange: this.handleInputChange,
}), onKeyDown: this.handleKeyDown,
label: field_label, placeholder: field_placeholder,
})}
{isOpen ? (
<Paper className={classes.paper} square>
{this.getSuggestions(inputValue2).map((suggestion, index) =>
renderSuggestion({
suggestion,
index,
itemProps: getItemProps({ item: suggestion.id }),
highlightedIndex,
selectedItem: selectedItem2,
}), }),
)} label: field_label,
</Paper> })}
) : null} {isOpen ? (
</div> <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> </Downshift>
</div> </div>
...@@ -196,6 +199,12 @@ class DownshiftMultiple extends React.Component { ...@@ -196,6 +199,12 @@ class DownshiftMultiple extends React.Component {
DownshiftMultiple.propTypes = { DownshiftMultiple.propTypes = {
classes: PropTypes.object.isRequired, 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 = { DownshiftMultiple.defaultProps = {
......
import React, { Component } from "react"; import React, { Component } from "react";
import PropTypes from "prop-types";
import CardMedia from "@material-ui/core/CardMedia"; import CardMedia from "@material-ui/core/CardMedia";
class MyCardMedia extends Component { class MyCardMedia extends Component {
...@@ -6,7 +7,7 @@ class MyCardMedia extends Component { ...@@ -6,7 +7,7 @@ class MyCardMedia extends Component {
render() { render() {
const { title, height, url } = this.props; const { title, height, url } = this.props;
if (url == "") { if (url == "") {
return (<div/>); return (<div />);
} }
return ( return (
<CardMedia <CardMedia
...@@ -20,5 +21,10 @@ class MyCardMedia extends Component { ...@@ -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; export default MyCardMedia;
\ No newline at end of file
...@@ -74,6 +74,12 @@ class UnivPopupContent extends Component { ...@@ -74,6 +74,12 @@ class UnivPopupContent extends Component {
UnivPopupContent.propTypes = { UnivPopupContent.propTypes = {
classes: PropTypes.object.isRequired, 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)); export default withLeaflet(withStyles(styles)(UnivPopupContent));
\ No newline at end of file
...@@ -87,7 +87,7 @@ class UnivList extends React.Component { ...@@ -87,7 +87,7 @@ class UnivList extends React.Component {
<Divider /> <Divider />
{__map(__range((page) * itemsPerPage, Math.min((page + 1) * itemsPerPage, numberOfItems)), {__map(__range((page) * itemsPerPage, Math.min((page + 1) * itemsPerPage, numberOfItems)),
univ_ind => ( 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}> <ListItem button divider={true} key={univ_ind}>
<ListItemText primary={universitiesToList[univ_ind].name} /> <ListItemText primary={universitiesToList[univ_ind].name} />
</ListItem> </ListItem>
...@@ -126,6 +126,8 @@ class UnivList extends React.Component { ...@@ -126,6 +126,8 @@ class UnivList extends React.Component {
UnivList.propTypes = { UnivList.propTypes = {
classes: PropTypes.object.isRequired, classes: PropTypes.object.isRequired,
theme: 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 = { UnivList.defaultProps = {
......
/* eslint-disable react/prop-types */
/* eslint-disable react/display-name */ /* 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 // 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) { ...@@ -42,6 +42,7 @@ function TabContainer(props) {
TabContainer.propTypes = { TabContainer.propTypes = {
children: PropTypes.node.isRequired, children: PropTypes.node.isRequired,
visible: PropTypes.bool.isRequired
}; };
const styles = theme => ({ const styles = theme => ({
...@@ -110,6 +111,7 @@ class UniversityTemplate extends React.Component { ...@@ -110,6 +111,7 @@ class UniversityTemplate extends React.Component {
UniversityTemplate.propTypes = { UniversityTemplate.propTypes = {
classes: PropTypes.object.isRequired, classes: PropTypes.object.isRequired,
width: PropTypes.string.isRequired,
}; };
export default compose( export default compose(
......
...@@ -99,6 +99,7 @@ Alert.propTypes = { ...@@ -99,6 +99,7 @@ Alert.propTypes = {
handleClose: PropTypes.func.isRequired, handleClose: PropTypes.func.isRequired,
handleResponse: PropTypes.func.isRequired, handleResponse: PropTypes.func.isRequired,
multilineButtons: PropTypes.bool.isRequired, multilineButtons: PropTypes.bool.isRequired,
classes: PropTypes.object.isRequired
}; };
......
...@@ -68,6 +68,7 @@ class History extends React.Component { ...@@ -68,6 +68,7 @@ class History extends React.Component {
} }
getContentTypeAndId() { getContentTypeAndId() {
// eslint-disable-next-line react/prop-types
const { rawModelData } = this.props.factory.props; const { rawModelData } = this.props.factory.props;
const { content_type_id, id } = rawModelData; const { content_type_id, id } = rawModelData;
return { content_type_id, id }; return { content_type_id, id };
...@@ -199,6 +200,11 @@ History.propTypes = { ...@@ -199,6 +200,11 @@ History.propTypes = {
classes: PropTypes.object.isRequired, classes: PropTypes.object.isRequired,
factory: PropTypes.object.isRequired, factory: PropTypes.object.isRequired,
handleRestoreVersion: PropTypes.func.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 = { History.defaultProps = {
......
...@@ -119,6 +119,9 @@ PendingModeration.propTypes = { ...@@ -119,6 +119,9 @@ PendingModeration.propTypes = {
classes: PropTypes.object.isRequired, classes: PropTypes.object.isRequired,
factory: PropTypes.object.isRequired, factory: PropTypes.object.isRequired,
handleEditPendingModeration: PropTypes.func.isRequired, handleEditPendingModeration: PropTypes.func.isRequired,
handleClosePendingModeration: PropTypes.func.isRequired,
handleApproveModeration: PropTypes.func.isRequired,
open: PropTypes.bool.isRequired,
userCanModerate: PropTypes.bool.isRequired, userCanModerate: PropTypes.bool.isRequired,
}; };
......
...@@ -153,6 +153,7 @@ Scholarship.propTypes = { ...@@ -153,6 +153,7 @@ Scholarship.propTypes = {
otherAdvantages: PropTypes.string, otherAdvantages: PropTypes.string,
amountMin: PropTypes.string, amountMin: PropTypes.string,
amountMax: PropTypes.string, amountMax: PropTypes.string,
currencies: PropTypes.object.isRequired,
}; };
export default withStyles(styles, { withTheme: true })(Scholarship); export default withStyles(styles, { withTheme: true })(Scholarship);
...@@ -58,7 +58,8 @@ Field.propTypes = { ...@@ -58,7 +58,8 @@ Field.propTypes = {
required: PropTypes.bool.isRequired, required: PropTypes.bool.isRequired,
label: PropTypes.string, label: PropTypes.string,
formManager: PropTypes.object.isRequired, formManager: PropTypes.object.isRequired,
fieldMapping: PropTypes.string.isRequired fieldMapping: PropTypes.string.isRequired,
value: PropTypes.isRequired
}; };
export default Field; 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