PLT-3518/PLT-3519 Custom emoji followup (#3507)
* Fixed emoji list filter when full name or nickname are enabled * Changed custom emoji list to only be visible if the user can create custom emoji
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
fd880ad047
Коммит
1a3f952c56
@@ -5,7 +5,6 @@ import React from 'react';
|
||||
|
||||
import * as AsyncClient from 'utils/async_client.jsx';
|
||||
import EmojiStore from 'stores/emoji_store.jsx';
|
||||
import TeamStore from 'stores/team_store.jsx';
|
||||
import * as Utils from 'utils/utils.jsx';
|
||||
|
||||
import {FormattedMessage} from 'react-intl';
|
||||
@@ -24,8 +23,6 @@ export default class EmojiList extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.canCreateEmojis = this.canCreateEmojis.bind(this);
|
||||
|
||||
this.handleEmojiChange = this.handleEmojiChange.bind(this);
|
||||
|
||||
this.deleteEmoji = this.deleteEmoji.bind(this);
|
||||
@@ -68,31 +65,6 @@ export default class EmojiList extends React.Component {
|
||||
AsyncClient.deleteEmoji(emoji.id);
|
||||
}
|
||||
|
||||
canCreateEmojis() {
|
||||
if (global.window.mm_license.IsLicensed !== 'true') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Utils.isSystemAdmin(this.props.user.roles)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (window.mm_config.RestrictCustomEmojiCreation === 'all') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (window.mm_config.RestrictCustomEmojiCreation === 'admin') {
|
||||
// check whether the user is an admin on any of their teams
|
||||
for (const member of TeamStore.getTeamMembers()) {
|
||||
if (Utils.isAdmin(member.roles)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
render() {
|
||||
const filter = this.state.filter.toLowerCase();
|
||||
const isSystemAdmin = Utils.isSystemAdmin(this.props.user.roles);
|
||||
@@ -131,26 +103,6 @@ export default class EmojiList extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
let addLink = null;
|
||||
if (this.canCreateEmojis()) {
|
||||
addLink = (
|
||||
<Link
|
||||
className='add-link'
|
||||
to={'/' + this.props.team.name + '/emoji/add'}
|
||||
>
|
||||
<button
|
||||
type='button'
|
||||
className='btn btn-primary'
|
||||
>
|
||||
<FormattedMessage
|
||||
id='emoji_list.add'
|
||||
defaultMessage='Add Custom Emoji'
|
||||
/>
|
||||
</button>
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className='backstage-content emoji-list'>
|
||||
<div className='backstage-header'>
|
||||
@@ -160,7 +112,20 @@ export default class EmojiList extends React.Component {
|
||||
defaultMessage='Custom Emoji'
|
||||
/>
|
||||
</h1>
|
||||
{addLink}
|
||||
<Link
|
||||
className='add-link'
|
||||
to={'/' + this.props.team.name + '/emoji/add'}
|
||||
>
|
||||
<button
|
||||
type='button'
|
||||
className='btn btn-primary'
|
||||
>
|
||||
<FormattedMessage
|
||||
id='emoji_list.add'
|
||||
defaultMessage='Add Custom Emoji'
|
||||
/>
|
||||
</button>
|
||||
</Link>
|
||||
</div>
|
||||
<div className='backstage-filters'>
|
||||
<div className='backstage-filter__search'>
|
||||
|
||||
@@ -45,9 +45,9 @@ export default class EmojiListItem extends React.Component {
|
||||
|
||||
if (creator) {
|
||||
if (creator.username.toLowerCase().indexOf(filter) !== -1 ||
|
||||
(creator.first_name && creator.first_name.toLowerCase().indexOf(filter)) ||
|
||||
(creator.last_name && creator.last_name.toLowerCase().indexOf(filter)) ||
|
||||
(creator.nickname && creator.nickname.toLowerCase().indexOf(filter))) {
|
||||
(creator.first_name && creator.first_name.toLowerCase().indexOf(filter) !== -1) ||
|
||||
(creator.last_name && creator.last_name.toLowerCase().indexOf(filter) !== -1) ||
|
||||
(creator.nickname && creator.nickname.toLowerCase().indexOf(filter) !== -1)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user