Skip to content

Commit

Permalink
PLT-6201 Removed ability to pin system messages
Browse files Browse the repository at this point in the history
  • Loading branch information
hmhealey committed Apr 6, 2017
1 parent 92fc1cf commit c198658
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 125 deletions.
66 changes: 33 additions & 33 deletions webapp/components/post_view/components/post_info.jsx
Expand Up @@ -152,42 +152,42 @@ export default class PostInfo extends React.Component {
</a>
</li>
);
}

if (this.props.post.is_pinned) {
dropdownContents.push(
<li
key='unpinLink'
role='presentation'
>
<a
href='#'
onClick={this.unpinPost}
if (this.props.post.is_pinned) {
dropdownContents.push(
<li
key='unpinLink'
role='presentation'
>
<FormattedMessage
id='post_info.unpin'
defaultMessage='Un-pin from channel'
/>
</a>
</li>
);
} else {
dropdownContents.push(
<li
key='pinLink'
role='presentation'
>
<a
href='#'
onClick={this.pinPost}
<a
href='#'
onClick={this.unpinPost}
>
<FormattedMessage
id='post_info.unpin'
defaultMessage='Un-pin from channel'
/>
</a>
</li>
);
} else {
dropdownContents.push(
<li
key='pinLink'
role='presentation'
>
<FormattedMessage
id='post_info.pin'
defaultMessage='Pin to channel'
/>
</a>
</li>
);
<a
href='#'
onClick={this.pinPost}
>
<FormattedMessage
id='post_info.pin'
defaultMessage='Pin to channel'
/>
</a>
</li>
);
}
}

if (this.canDelete) {
Expand Down
105 changes: 51 additions & 54 deletions webapp/components/rhs_comment.jsx
Expand Up @@ -151,7 +151,7 @@ export default class RhsComment extends React.Component {
unpinPost(this.props.post.channel_id, this.props.post.id);
}

createDropdown() {
createDropdown(isSystemMessage) {
const post = this.props.post;

if (post.state === Constants.POST_FAILED || post.state === Constants.POST_LOADING) {
Expand Down Expand Up @@ -201,57 +201,59 @@ export default class RhsComment extends React.Component {
}
}

dropdownContents.push(
<li
key='rhs-root-permalink'
role='presentation'
>
<a
href='#'
onClick={this.handlePermalink}
>
<FormattedMessage
id='rhs_comment.permalink'
defaultMessage='Permalink'
/>
</a>
</li>
);

if (post.is_pinned) {
if (!isSystemMessage) {
dropdownContents.push(
<li
key='rhs-comment-unpin'
key='rhs-root-permalink'
role='presentation'
>
<a
href='#'
onClick={this.unpinPost}
onClick={this.handlePermalink}
>
<FormattedMessage
id='rhs_root.unpin'
defaultMessage='Un-pin from channel'
id='rhs_comment.permalink'
defaultMessage='Permalink'
/>
</a>
</li>
);
} else {
dropdownContents.push(
<li
key='rhs-comment-pin'
role='presentation'
>
<a
href='#'
onClick={this.pinPost}

if (post.is_pinned) {
dropdownContents.push(
<li
key='rhs-comment-unpin'
role='presentation'
>
<FormattedMessage
id='rhs_root.pin'
defaultMessage='Pin to channel'
/>
</a>
</li>
);
<a
href='#'
onClick={this.unpinPost}
>
<FormattedMessage
id='rhs_root.unpin'
defaultMessage='Un-pin from channel'
/>
</a>
</li>
);
} else {
dropdownContents.push(
<li
key='rhs-comment-pin'
role='presentation'
>
<a
href='#'
onClick={this.pinPost}
>
<FormattedMessage
id='rhs_root.pin'
defaultMessage='Pin to channel'
/>
</a>
</li>
);
}
}

if (this.canDelete) {
Expand Down Expand Up @@ -362,15 +364,10 @@ export default class RhsComment extends React.Component {
const post = this.props.post;
const flagIcon = Constants.FLAG_ICON_SVG;
const mattermostLogo = Constants.MATTERMOST_ICON_SVG;
const isSystemMessage = PostUtils.isSystemMessage(post);
let canReact = false;

if (post.state !== Constants.POST_FAILED &&
post.state !== Constants.POST_LOADING &&
!Utils.isPostEphemeral(post) &&
Utils.isFeatureEnabled(Constants.PRE_RELEASE_FEATURES.EMOJI_PICKER_PREVIEW)) {
canReact = true;
}
const isEphemeral = Utils.isPostEphemeral(post);
const isPending = post.state === Constants.POST_FAILED || post.state === Constants.POST_LOADING;
const isSystemMessage = PostUtils.isSystemMessage(post);

var currentUserCss = '';
if (this.props.currentUser.id === post.user_id) {
Expand Down Expand Up @@ -412,7 +409,7 @@ export default class RhsComment extends React.Component {
}

botIndicator = <li className='col col__name bot-indicator'>{'BOT'}</li>;
} else if (PostUtils.isSystemMessage(post)) {
} else if (isSystemMessage) {
userProfile = (
<UserProfile
user={{}}
Expand Down Expand Up @@ -474,7 +471,7 @@ export default class RhsComment extends React.Component {
);
}

if (PostUtils.isSystemMessage(post)) {
if (isSystemMessage) {
profilePic = (
<span
className='icon'
Expand Down Expand Up @@ -556,7 +553,7 @@ export default class RhsComment extends React.Component {
}

let flagTrigger;
if (!Utils.isPostEphemeral(post)) {
if (isEphemeral) {
flagTrigger = (
<OverlayTrigger
key={'commentflagtooltipkey' + flagVisible}
Expand All @@ -578,7 +575,7 @@ export default class RhsComment extends React.Component {
let react;
let reactOverlay;

if (canReact) {
if (!isEphemeral && !isPending && !isSystemMessage && Utils.isFeatureEnabled(Constants.PRE_RELEASE_FEATURES.EMOJI_PICKER_PREVIEW)) {
react = (
<span>
<a
Expand Down Expand Up @@ -612,17 +609,17 @@ export default class RhsComment extends React.Component {
}

let options;
if (Utils.isPostEphemeral(post)) {
if (isEphemeral) {
options = (
<li className='col col__remove'>
{this.createRemovePostButton()}
</li>
);
} else if (!PostUtils.isSystemMessage(post)) {
} else if (!isSystemMessage) {
options = (
<li className='col col__reply'>
{reactOverlay}
{this.createDropdown()}
{this.createDropdown(isSystemMessage)}
{react}
</li>
);
Expand Down
78 changes: 40 additions & 38 deletions webapp/components/rhs_root_post.jsx
Expand Up @@ -295,57 +295,59 @@ export default class RhsRootPost extends React.Component {
}
}

dropdownContents.push(
<li
key='rhs-root-permalink'
role='presentation'
>
<a
href='#'
onClick={this.handlePermalink}
>
<FormattedMessage
id='rhs_root.permalink'
defaultMessage='Permalink'
/>
</a>
</li>
);

if (post.is_pinned) {
if (!isSystemMessage) {
dropdownContents.push(
<li
key='rhs-root-unpin'
key='rhs-root-permalink'
role='presentation'
>
<a
href='#'
onClick={this.unpinPost}
onClick={this.handlePermalink}
>
<FormattedMessage
id='rhs_root.unpin'
defaultMessage='Un-pin from channel'
id='rhs_root.permalink'
defaultMessage='Permalink'
/>
</a>
</li>
);
} else {
dropdownContents.push(
<li
key='rhs-root-pin'
role='presentation'
>
<a
href='#'
onClick={this.pinPost}

if (post.is_pinned) {
dropdownContents.push(
<li
key='rhs-root-unpin'
role='presentation'
>
<FormattedMessage
id='rhs_root.pin'
defaultMessage='Pin to channel'
/>
</a>
</li>
);
<a
href='#'
onClick={this.unpinPost}
>
<FormattedMessage
id='rhs_root.unpin'
defaultMessage='Un-pin from channel'
/>
</a>
</li>
);
} else {
dropdownContents.push(
<li
key='rhs-root-pin'
role='presentation'
>
<a
href='#'
onClick={this.pinPost}
>
<FormattedMessage
id='rhs_root.pin'
defaultMessage='Pin to channel'
/>
</a>
</li>
);
}
}

if (this.canDelete) {
Expand Down

0 comments on commit c198658

Please sign in to comment.