Commit 8f8234cb authored by Florent Chehab's avatar Florent Chehab

linting(front): activated react/jsx-indent-props

* Activated react/jsx-indent-props
* Reformatted code accordingly
Not that many changes were required actualy :)

Fixes #102
parent 12217100
Pipeline #38707 passed with stages
in 3 minutes and 19 seconds
...@@ -42,7 +42,7 @@ module.exports = { ...@@ -42,7 +42,7 @@ module.exports = {
"always" "always"
], ],
"react/no-unescaped-entities": "off", // that one doesn't improve code readability "react/no-unescaped-entities": "off", // that one doesn't improve code readability
// "react/jsx-indent-props": [2, "first"], "react/jsx-indent-props": [2, "first"],
"react/jsx-indent": [2, 2], "react/jsx-indent": [2, 2],
"react/prop-types": "error", "react/prop-types": "error",
"react/no-deprecated": "error", "react/no-deprecated": "error",
......
...@@ -17,7 +17,7 @@ import TextField from "./fields/TextField"; ...@@ -17,7 +17,7 @@ import TextField from "./fields/TextField";
import MultiSelectField from "./fields/MultiSelectField"; import MultiSelectField from "./fields/MultiSelectField";
import NumberField from "./fields/NumberField"; import NumberField from "./fields/NumberField";
import { getLatestReadDataFromStore } from "../../redux/api/utils"; import {getLatestReadDataFromStore} from "../../redux/api/utils";
export default { export default {
/** /**
...@@ -27,7 +27,7 @@ export default { ...@@ -27,7 +27,7 @@ export default {
* @returns * @returns
*/ */
customizeProps(props) { customizeProps(props) {
return Object.assign(props, { ...this.getReferenceAndValue(props.fieldMapping) }); return Object.assign(props, {...this.getReferenceAndValue(props.fieldMapping)});
}, },
renderObjModerationLevelField() { renderObjModerationLevelField() {
...@@ -39,34 +39,34 @@ export default { ...@@ -39,34 +39,34 @@ export default {
<> <>
<Typography variant='caption'>Niveau de modération supplémentaire souhaité</Typography> <Typography variant='caption'>Niveau de modération supplémentaire souhaité</Typography>
<SelectField label={"Niveau de modération pour ce module"} <SelectField label={"Niveau de modération pour ce module"}
{...this.getReferenceAndValue("obj_moderation_level")} {...this.getReferenceAndValue("obj_moderation_level")}
required={true} required={true}
options={possibleObjModeration} options={possibleObjModeration} />
/>
</> </>
); );
} else { } else {
return ( return (
<Typography variant='caption'>Votre statut ne vous permet pas modifier le niveau local de modération pour ce module.</Typography> <Typography variant='caption'>
Votre statut ne vous permet pas modifier le niveau local de modération pour ce module.
</Typography>
); );
} }
}, },
renderImportanceLevelField() { renderImportanceLevelField() {
const options = [ const options = [
{ "label": "Normal", "value": "-" }, {"label": "Normal", "value": "-"},
{ "label": "Important", "value": "+" }, {"label": "Important", "value": "+"},
{ "label": "Très important", "value": "++" }, {"label": "Très important", "value": "++"},
]; ];
return ( return (
<> <>
<Typography variant='caption'>Qualification de l'importance de l'information présentée</Typography> <Typography variant='caption'>Qualification de l'importance de l'information présentée</Typography>
<SelectField label={"Niveau d'importance"} <SelectField label={"Niveau d'importance"}
{...this.getReferenceAndValue("importance_level")} {...this.getReferenceAndValue("importance_level")}
required={true} required={true}
options={options} options={options} />
/>
</> </>
); );
}, },
...@@ -74,8 +74,7 @@ export default { ...@@ -74,8 +74,7 @@ export default {
renderUsefulLinksField() { renderUsefulLinksField() {
return ( return (
<UsefulLinksField label={"Lien(s) utile(s) (ex : vers ces informations)"} <UsefulLinksField label={"Lien(s) utile(s) (ex : vers ces informations)"}
{...this.getReferenceAndValue("useful_links")} {...this.getReferenceAndValue("useful_links")} />
/>
); );
}, },
...@@ -113,32 +112,34 @@ export default { ...@@ -113,32 +112,34 @@ export default {
}, },
renderUniversitiesField() { renderUniversitiesField() {
const { outsideData } = this.props, const {outsideData} = this.props,
universities = outsideData.universities.map( universities = outsideData.universities.map(
(univ) => { return { label: univ.name, value: univ.id, disabled: false }; } (univ) => {
return {label: univ.name, value: univ.id, disabled: false};
}
); );
return ( return (
<MultiSelectField label={"Universités concernées"} <MultiSelectField label={"Universités concernées"}
{...this.getReferenceAndValue("universities")} {...this.getReferenceAndValue("universities")}
required={true} required={true}
options={universities} options={universities} />
/>
); );
}, },
renderCountriesField() { renderCountriesField() {
const { outsideData } = this.props, const {outsideData} = this.props,
countries = outsideData.countries.map( countries = outsideData.countries.map(
(country) => { return { label: country.name, value: country.id, disabled: false }; } (country) => {
return {label: country.name, value: country.id, disabled: false};
}
); );
return ( return (
<MultiSelectField label={"Pays concernés"} <MultiSelectField label={"Pays concernés"}
{...this.getReferenceAndValue("countries")} {...this.getReferenceAndValue("countries")}
required={true} required={true}
options={countries} options={countries} />
/>
); );
}, },
...@@ -151,9 +152,11 @@ export default { ...@@ -151,9 +152,11 @@ export default {
}, },
renderCurrencyField(props) { renderCurrencyField(props) {
const { outsideData } = this.props; const {outsideData} = this.props;
const currencies = outsideData.currencies.map( const currencies = outsideData.currencies.map(
(c) => { return { label: c.code, value: c.code, disabled: false }; } (c) => {
return {label: c.code, value: c.code, disabled: false};
}
); );
return this.renderSelectField({ return this.renderSelectField({
......
...@@ -2,17 +2,16 @@ import React from "react"; ...@@ -2,17 +2,16 @@ import React from "react";
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import withStyles from "@material-ui/core/styles/withStyles"; import withStyles from "@material-ui/core/styles/withStyles";
import { Paper } from "@material-ui/core"; import {Paper} from "@material-ui/core";
import Button from "@material-ui/core/Button"; import Button from "@material-ui/core/Button";
import AddIcon from "@material-ui/icons/Add"; import AddIcon from "@material-ui/icons/Add";
// import {compose} from "redux";
// import getActions from "../../redux/api/getActions";
// import {connect} from "react-redux";
import TextBlock from "../recommendation/TextBlock"; import TextBlock from "../recommendation/TextBlock";
import UnivBlock from "../recommendation/UnivBlock"; import UnivBlock from "../recommendation/UnivBlock";
import RecommendationEditor from "../recommendation/RecommendationEditor"; import RecommendationEditor from "../recommendation/RecommendationEditor";
import CustomComponentForAPI from "../common/CustomComponentForAPI"; import CustomComponentForAPI from "../common/CustomComponentForAPI";
// import {compose} from "redux";
// import getActions from "../../redux/api/getActions";
// import {connect} from "react-redux";
// import editorStyle from "../university/editors/common/editorStyle.js"; // import editorStyle from "../university/editors/common/editorStyle.js";
...@@ -69,7 +68,7 @@ class Recommendation extends CustomComponentForAPI { ...@@ -69,7 +68,7 @@ class Recommendation extends CustomComponentForAPI {
recommendationModelData = list; recommendationModelData = list;
return ( return (
<Paper style={{ color: "white", margin: "1em", padding: "1em" }}> <Paper style={{color: "white", margin: "1em", padding: "1em"}}>
<h2> <h2>
{list.name} {list.name}
</h2> </h2>
...@@ -77,17 +76,17 @@ class Recommendation extends CustomComponentForAPI { ...@@ -77,17 +76,17 @@ class Recommendation extends CustomComponentForAPI {
{list.public ? "Liste publique" : "liste privée"} créée par : {list.user} {list.public ? "Liste publique" : "liste privée"} créée par : {list.user}
</p> </p>
<div id="Descriptive"> <div id="Descriptive">
<TextBlock id={list.descriptive.id} type={list.descriptive.type} text={list.descriptive.text} /> <TextBlock id={list.descriptive.id} type={list.descriptive.type} text={list.descriptive.text}/>
</div> </div>
{list.content.map((el, idx) => <div key={idx}> <UnivBlock univ={el} /> </div>)} {list.content.map((el, idx) => <div key={idx}><UnivBlock univ={el}/></div>)}
<Button variant={"contained"} <Button variant={"contained"}
color={"secondary"} color={"secondary"}
onClick={() => this.openEditorPanel()}> onClick={() => this.openEditorPanel()}>
<AddIcon className={classes.rightIcon}/> <AddIcon className={classes.rightIcon}/>
</Button> </Button>
<RecommendationEditor open={this.state.editorOpen} <RecommendationEditor open={this.state.editorOpen}
closeEditorPanel={() => this.closeEditorPanel()} closeEditorPanel={() => this.closeEditorPanel()}
rawModelData={recommendationModelData}/> rawModelData={recommendationModelData}/>
</Paper> </Paper>
); );
} }
...@@ -98,9 +97,7 @@ Recommendation.propTypes = { ...@@ -98,9 +97,7 @@ Recommendation.propTypes = {
list: PropTypes.object.isRequired, list: PropTypes.object.isRequired,
}; };
Recommendation.defaultProps = { Recommendation.defaultProps = {};
};
const styles = theme => ({ const styles = theme => ({
root: { root: {
...@@ -119,4 +116,4 @@ const styles = theme => ({ ...@@ -119,4 +116,4 @@ const styles = theme => ({
}, },
}); });
export default withStyles(styles, { withTheme: true })(Recommendation); export default withStyles(styles, {withTheme: true})(Recommendation);
import React from "react"; import React from "react";
import withStyles from "@material-ui/core/styles/withStyles"; import withStyles from "@material-ui/core/styles/withStyles";
import compose from "recompose/compose"; import compose from "recompose/compose";
import { connect } from "react-redux"; import {connect} from "react-redux";
import Editor from "../../editor/Editor"; import Editor from "../../editor/Editor";
import Form from "../../form/Form"; import Form from "../../form/Form";
...@@ -9,7 +9,7 @@ import editorStyle from "../../editor/editorStyle"; ...@@ -9,7 +9,7 @@ import editorStyle from "../../editor/editorStyle";
import getMapStateToPropsForEditor from "../../editor/getMapStateToPropsForEditor"; import getMapStateToPropsForEditor from "../../editor/getMapStateToPropsForEditor";
import getMapDispatchToPropsForEditor from "../../editor/getMapDispatchToPropsForEditor"; import getMapDispatchToPropsForEditor from "../../editor/getMapDispatchToPropsForEditor";
import { withSnackbar } from "notistack"; import {withSnackbar} from "notistack";
import TextField from "../../form/fields/TextField"; import TextField from "../../form/fields/TextField";
...@@ -23,25 +23,24 @@ class UniversityGeneralForm extends Form { ...@@ -23,25 +23,24 @@ class UniversityGeneralForm extends Form {
return ( return (
<> <>
<TextField label={"Nom de l'université"} <TextField label={"Nom de l'université"}
{...this.getReferenceAndValue("name")} {...this.getReferenceAndValue("name")}
required={true} required={true}
maxLength={200} maxLength={200}/>
/>
<TextField label={"Acronyme de l'université"} <TextField label={"Acronyme de l'université"}
{...this.getReferenceAndValue("acronym")} {...this.getReferenceAndValue("acronym")}
maxLength={20} maxLength={20}/>
/>
<TextField label={"Site internet de l'université"} <TextField label={"Site internet de l'université"}
{...this.getReferenceAndValue("website")} {...this.getReferenceAndValue("website")}
maxLength={300} maxLength={300}
isUrl={true} isUrl={true}/>
/>
<TextField label={"Logo de l'université"} <TextField label={"Logo de l'université"}
{...this.getReferenceAndValue("logo")} {...this.getReferenceAndValue("logo")}
maxLength={300} maxLength={300}
isUrl={true} isUrl={true}
urlExtensions={["jpg", "png", "svg"]} urlExtensions={["jpg", "png", "svg"]}/>
/>
</> </>
); );
} }
...@@ -60,7 +59,7 @@ class UniversityGeneralEditor extends Editor { ...@@ -60,7 +59,7 @@ class UniversityGeneralEditor extends Editor {
export default compose( export default compose(
withSnackbar, withSnackbar,
withStyles(styles, { withTheme: true }), withStyles(styles, {withTheme: true}),
connect( connect(
getMapStateToPropsForEditor("universities"), getMapStateToPropsForEditor("universities"),
getMapDispatchToPropsForEditor("universities") getMapDispatchToPropsForEditor("universities")
......
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