Merge pull request #1529 from matrix-org/luke/fix-can-edit-editable-item-lists
Only show editing UI for aliases/related_groups for users /w power
This commit is contained in:
commit
8ed3474b64
4 changed files with 17 additions and 12 deletions
|
@ -84,7 +84,9 @@ module.exports = React.createClass({
|
||||||
onNewItemChanged: PropTypes.func,
|
onNewItemChanged: PropTypes.func,
|
||||||
onItemAdded: PropTypes.func,
|
onItemAdded: PropTypes.func,
|
||||||
onItemEdited: PropTypes.func,
|
onItemEdited: PropTypes.func,
|
||||||
onItemRemoved: PropTypes. func,
|
onItemRemoved: PropTypes.func,
|
||||||
|
|
||||||
|
canEdit: PropTypes.bool,
|
||||||
},
|
},
|
||||||
|
|
||||||
getDefaultProps: function() {
|
getDefaultProps: function() {
|
||||||
|
@ -136,14 +138,16 @@ module.exports = React.createClass({
|
||||||
{ label }
|
{ label }
|
||||||
</div>
|
</div>
|
||||||
{ editableItems }
|
{ editableItems }
|
||||||
<EditableItem
|
{ this.props.canEdit ?
|
||||||
key={-1}
|
<EditableItem
|
||||||
initialValue={this.props.newItem}
|
key={-1}
|
||||||
onAdd={this.onItemAdded}
|
initialValue={this.props.newItem}
|
||||||
onChange={this.onNewItemChanged}
|
onAdd={this.onItemAdded}
|
||||||
addOnChange={true}
|
onChange={this.onNewItemChanged}
|
||||||
placeholder={this.props.placeholder}
|
addOnChange={true}
|
||||||
/>
|
placeholder={this.props.placeholder}
|
||||||
|
/> : <div />
|
||||||
|
}
|
||||||
</div>);
|
</div>);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -262,6 +262,7 @@ module.exports = React.createClass({
|
||||||
items={this.state.domainToAliases[localDomain] || []}
|
items={this.state.domainToAliases[localDomain] || []}
|
||||||
newItem={this.state.newAlias}
|
newItem={this.state.newAlias}
|
||||||
onNewItemChanged={this.onNewAliasChanged}
|
onNewItemChanged={this.onNewAliasChanged}
|
||||||
|
canEdit={this.props.canSetAliases}
|
||||||
onItemAdded={this.onLocalAliasAdded}
|
onItemAdded={this.onLocalAliasAdded}
|
||||||
onItemEdited={this.onLocalAliasChanged}
|
onItemEdited={this.onLocalAliasChanged}
|
||||||
onItemRemoved={this.onLocalAliasDeleted}
|
onItemRemoved={this.onLocalAliasDeleted}
|
||||||
|
|
|
@ -27,7 +27,7 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
propTypes: {
|
propTypes: {
|
||||||
roomId: React.PropTypes.string.isRequired,
|
roomId: React.PropTypes.string.isRequired,
|
||||||
canSetRelatedRooms: React.PropTypes.bool.isRequired,
|
canSetRelatedGroups: React.PropTypes.bool.isRequired,
|
||||||
relatedGroupsEvent: React.PropTypes.instanceOf(MatrixEvent),
|
relatedGroupsEvent: React.PropTypes.instanceOf(MatrixEvent),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
getDefaultProps: function() {
|
getDefaultProps: function() {
|
||||||
return {
|
return {
|
||||||
canSetRelatedRooms: false,
|
canSetRelatedGroups: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -110,6 +110,7 @@ module.exports = React.createClass({
|
||||||
items={this.state.newGroupsList}
|
items={this.state.newGroupsList}
|
||||||
className={"mx_RelatedGroupSettings"}
|
className={"mx_RelatedGroupSettings"}
|
||||||
newItem={this.state.newGroupId}
|
newItem={this.state.newGroupId}
|
||||||
|
canEdit={this.props.canSetRelatedGroups}
|
||||||
onNewItemChanged={this.onNewGroupChanged}
|
onNewItemChanged={this.onNewGroupChanged}
|
||||||
onItemAdded={this.onGroupAdded}
|
onItemAdded={this.onGroupAdded}
|
||||||
onItemEdited={this.onGroupEdited}
|
onItemEdited={this.onGroupEdited}
|
||||||
|
|
|
@ -19,7 +19,6 @@ import Promise from 'bluebird';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { _t, _tJsx, _td } from '../../../languageHandler';
|
import { _t, _tJsx, _td } from '../../../languageHandler';
|
||||||
import MatrixClientPeg from '../../../MatrixClientPeg';
|
import MatrixClientPeg from '../../../MatrixClientPeg';
|
||||||
import SdkConfig from '../../../SdkConfig';
|
|
||||||
import sdk from '../../../index';
|
import sdk from '../../../index';
|
||||||
import Modal from '../../../Modal';
|
import Modal from '../../../Modal';
|
||||||
import ObjectUtils from '../../../ObjectUtils';
|
import ObjectUtils from '../../../ObjectUtils';
|
||||||
|
|
Loading…
Reference in a new issue