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

Lock on adding element

parent ef8f4ee4
......@@ -76,6 +76,7 @@ class UniversityDri extends MyComponent {
return (
<GenericGroupModule
groupTitle={"Informations émanant de la DRI"}
endPoint={"universityDri"}
editor={UniversityDriEditor}
invalidateGroup={this.props.invalidateData}
propsForEditor={{
......
......@@ -58,9 +58,11 @@ class GenericGroupModule extends MyComponent {
}
};
render() {
myRender() {
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 (
<Paper className={classes.root}>
<this.props.editor
......@@ -76,14 +78,14 @@ class GenericGroupModule extends MyComponent {
</Grid>
<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! */}
<Button
variant='fab'
mini
aria-label="Ajouter un élément"
disabled={false}
style={{ backgroundColor: green.A700 }}
disabled={disabled}
style={disabled ? {} : { backgroundColor: green.A700 }}
className={classes.button}
onClick={this.handleOpenEditor}
>
......@@ -103,6 +105,7 @@ class GenericGroupModule extends MyComponent {
GenericGroupModule.propTypes = {
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