Skip to content

Commit

Permalink
MM-12503: Show Mute/Unmute menu item for GMs too. (mattermost#1847)
Browse files Browse the repository at this point in the history
  • Loading branch information
grundleborg authored Oct 9, 2018
1 parent db15a07 commit 99283d6
Showing 1 changed file with 47 additions and 41 deletions.
88 changes: 47 additions & 41 deletions components/channel_header/channel_header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,50 @@ export default class ChannelHeader extends React.Component {
actions.openModal(inviteModalData);
};

renderMute = () => {
const channelMuted = isChannelMuted(this.props.channelMember);

if (channelMuted) {
return (
<li
key='dropdown_unmute'
role='presentation'
>
<button
className='style--none'
id='channelUnmute'
role='menuitem'
onClick={this.unmute}
>
<FormattedMessage
id='channel_header.unmute'
defaultMessage='Unmute Channel'
/>
</button>
</li>
);
}

return (
<li
key='dropdown_mute'
role='presentation'
>
<button
className='style--none'
id='channelMute'
role='menuitem'
onClick={this.mute}
>
<FormattedMessage
id='channel_header.mute'
defaultMessage='Mute Channel'
/>
</button>
</li>
);
};

render() {
const channelIsArchived = this.props.channel.delete_at !== 0;
if (Utils.isEmptyObject(this.props.channel) ||
Expand Down Expand Up @@ -528,6 +572,8 @@ export default class ChannelHeader extends React.Component {
</li>
);

dropdownContents.push(this.renderMute());

dropdownContents.push(
<li
key='add_members'
Expand Down Expand Up @@ -610,47 +656,7 @@ export default class ChannelHeader extends React.Component {
);
}

if (!isDirect) {
if (channelMuted) {
dropdownContents.push(
<li
key='dropdown_unmute'
role='presentation'
>
<button
className='style--none'
id='channelUnmute'
role='menuitem'
onClick={this.unmute}
>
<FormattedMessage
id='channel_header.unmute'
defaultMessage='Unmute Channel'
/>
</button>
</li>
);
} else {
dropdownContents.push(
<li
key='dropdown_mute'
role='presentation'
>
<button
className='style--none'
id='channelMute'
role='menuitem'
onClick={this.mute}
>
<FormattedMessage
id='channel_header.mute'
defaultMessage='Mute Channel'
/>
</button>
</li>
);
}
}
dropdownContents.push(this.renderMute());

if (!this.props.isDefault) {
dropdownContents.push(
Expand Down

0 comments on commit 99283d6

Please sign in to comment.