Only show editing UI for aliases/related_groups for users /w power

pull/21833/head
Luke Barnard 2017-10-24 16:19:09 +01:00
parent ba46faf1b1
commit ee7ebc425c
4 changed files with 16 additions and 11 deletions

View File

@ -80,11 +80,13 @@ module.exports = React.createClass({
displayName: 'EditableItemList', displayName: 'EditableItemList',
propTypes: { propTypes: {
items: PropTypes.arrayOf(PropTypes.string).isRequired, items: PropTypes.arrayOf(PropTypes. string).isRequired,
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,6 +138,7 @@ module.exports = React.createClass({
{ label } { label }
</div> </div>
{ editableItems } { editableItems }
{ this.props.canEdit ?
<EditableItem <EditableItem
key={-1} key={-1}
initialValue={this.props.newItem} initialValue={this.props.newItem}
@ -143,7 +146,8 @@ module.exports = React.createClass({
onChange={this.onNewItemChanged} onChange={this.onNewItemChanged}
addOnChange={true} addOnChange={true}
placeholder={this.props.placeholder} placeholder={this.props.placeholder}
/> /> : <div />
}
</div>); </div>);
}, },
}); });

View File

@ -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}

View File

@ -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.canSetRelatedRooms}
onNewItemChanged={this.onNewGroupChanged} onNewItemChanged={this.onNewGroupChanged}
onItemAdded={this.onGroupAdded} onItemAdded={this.onGroupAdded}
onItemEdited={this.onGroupEdited} onItemEdited={this.onGroupEdited}

View File

@ -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';