Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Flair settings for rooms
Browse files Browse the repository at this point in the history
  • Loading branch information
turt2live committed Jan 28, 2019
1 parent 3021464 commit 87e6652
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/components/views/elements/EditableItemList.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ const EditableItem = React.createClass({
},
});

// TODO: Make this use the new Field element
module.exports = React.createClass({
displayName: 'EditableItemList',

Expand Down
1 change: 0 additions & 1 deletion src/components/views/room_settings/RelatedGroupSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ module.exports = React.createClass({
const localDomain = this.context.matrixClient.getDomain();
const EditableItemList = sdk.getComponent('elements.EditableItemList');
return <div>
<h3>{ _t('Flair') }</h3>
<EditableItemList
items={this.state.newGroupsList}
className={"mx_RelatedGroupSettings"}
Expand Down
31 changes: 31 additions & 0 deletions src/components/views/settings/tabs/GeneralRoomSettingsTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,38 @@ import RoomProfileSettings from "../../room_settings/RoomProfileSettings";
import MatrixClientPeg from "../../../../MatrixClientPeg";
import sdk from "../../../../index";
import AccessibleButton from "../../elements/AccessibleButton";
import {MatrixClient} from "matrix-js-sdk";

export default class GeneralRoomSettingsTab extends React.Component {
static childContextTypes = {
matrixClient: PropTypes.instanceOf(MatrixClient),
};

static propTypes = {
roomId: PropTypes.string.isRequired,
};

getChildContext() {
return {
matrixClient: MatrixClientPeg.get(),
};
}

_saveAliases = (e) => {
// TODO: Live modification of aliases?
if (!this.refs.aliasSettings) return;
this.refs.aliasSettings.saveSettings();
};

_saveGroups = (e) => {
// TODO: Live modification of aliases?
if (!this.refs.flairSettings) return;
this.refs.flairSettings.saveSettings();
};

render() {
const AliasSettings = sdk.getComponent("room_settings.AliasSettings");
const RelatedGroupSettings = sdk.getComponent("room_settings.RelatedGroupSettings");

const client = MatrixClientPeg.get();
const room = client.getRoom(this.props.roomId);
Expand All @@ -44,6 +62,9 @@ export default class GeneralRoomSettingsTab extends React.Component {
const canonicalAliasEv = room.currentState.getStateEvents("m.room.canonical_alias", '');
const aliasEvents = room.currentState.getStateEvents("m.room.aliases");

const canChangeGroups = room.currentState.mayClientSendStateEvent("m.room.related_groups", client);
const groupsEvent = room.currentState.getStateEvents("m.room.related_groups", "");

return (
<div className="mx_SettingsTab mx_GeneralRoomSettingsTab">
<div className="mx_SettingsTab_heading">{_t("General")}</div>
Expand All @@ -60,6 +81,16 @@ export default class GeneralRoomSettingsTab extends React.Component {
{_t("Save")}
</AccessibleButton>
</div>

<span className='mx_SettingsTab_subheading'>{_t("Flair")}</span>
<div className='mx_SettingsTab_section mx_SettingsTab_subsectionText'>
<RelatedGroupSettings ref="flairSettings" roomId={room.roomId}
canSetRelatedGroups={canChangeGroups}
relatedGroupsEvent={groupsEvent} />
<AccessibleButton onClick={this._saveGroups} kind='primary'>
{_t("Save")}
</AccessibleButton>
</div>
</div>
);
}
Expand Down

0 comments on commit 87e6652

Please sign in to comment.