Commit 064c5099 authored by Florent Chehab's avatar Florent Chehab
Browse files

Lock on adding element

parent ef8f4ee4
...@@ -76,6 +76,7 @@ class UniversityDri extends MyComponent { ...@@ -76,6 +76,7 @@ class UniversityDri extends MyComponent {
return ( return (
<GenericGroupModule <GenericGroupModule
groupTitle={"Informations émanant de la DRI"} groupTitle={"Informations émanant de la DRI"}
endPoint={"universityDri"}
editor={UniversityDriEditor} editor={UniversityDriEditor}
invalidateGroup={this.props.invalidateData} invalidateGroup={this.props.invalidateData}
propsForEditor={{ propsForEditor={{
......
...@@ -58,9 +58,11 @@ class GenericGroupModule extends MyComponent { ...@@ -58,9 +58,11 @@ class GenericGroupModule extends MyComponent {
} }
}; };
render() { myRender() {
const { classes, theme, groupTitle } = this.props; const { classes, theme, groupTitle } = this.props;
const { endPoint } = this.props;
const userCanPostTo = this.getFetchedData('userDataEl').owner_can_post_to;
const disabled = userCanPostTo.indexOf(endPoint) < 0;
return ( return (
<Paper className={classes.root}> <Paper className={classes.root}>
<this.props.editor <this.props.editor
...@@ -76,14 +78,14 @@ class GenericGroupModule extends MyComponent { ...@@ -76,14 +78,14 @@ class GenericGroupModule extends MyComponent {
</Grid> </Grid>
<Grid item xs={2} style={{ textAlign: 'right' }}> <Grid item xs={2} style={{ textAlign: 'right' }}>
<Tooltip title="Ajouter un élément" placement="top"> <Tooltip title={disabled ? "Vous ne pouvez pas ajouter d'élément" : "Ajouter un élément"} placement="top">
<div style={{ display: 'inline-block' }}> {/* Needed to fire events for the tooltip when below is disabled! */} <div style={{ display: 'inline-block' }}> {/* Needed to fire events for the tooltip when below is disabled! */}
<Button <Button
variant='fab' variant='fab'
mini mini
aria-label="Ajouter un élément" aria-label="Ajouter un élément"
disabled={false} disabled={disabled}
style={{ backgroundColor: green.A700 }} style={disabled ? {} : { backgroundColor: green.A700 }}
className={classes.button} className={classes.button}
onClick={this.handleOpenEditor} onClick={this.handleOpenEditor}
> >
...@@ -103,6 +105,7 @@ class GenericGroupModule extends MyComponent { ...@@ -103,6 +105,7 @@ class GenericGroupModule extends MyComponent {
GenericGroupModule.propTypes = { GenericGroupModule.propTypes = {
groupTitle: PropTypes.string.isRequired, groupTitle: PropTypes.string.isRequired,
endPoint: PropTypes.string.isRequired,
}; };
......
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