Skip to content

Commit

Permalink
MM-28501: add badge to bot users (mattermost#6672)
Browse files Browse the repository at this point in the history
* MM-28501: add badge to bot users
  • Loading branch information
catalintomai committed Oct 27, 2020
1 parent 94f4ed1 commit 8d81dd0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {FormattedMessage} from 'react-intl';
import EmailIcon from 'components/widgets/icons/mail_icon';
import AlertIcon from 'components/widgets/icons/alert_icon';
import GuestBadge from 'components/widgets/badges/guest_badge';
import BotBadge from 'components/widgets/badges/bot_badge';
import Avatar from 'components/widgets/users/avatar';

import {imageURLForUser, isGuest, getLongDisplayName} from 'utils/utils.jsx';
Expand All @@ -26,6 +27,8 @@ export default class InvitationModalConfirmStepRow extends React.PureComponent {
let username;
let className;
let guestBadge;
let botBadge;

if (invitation.user) {
className = 'name';
const profileImg = imageURLForUser(invitation.user.id, invitation.user.last_picture_update);
Expand All @@ -37,6 +40,9 @@ export default class InvitationModalConfirmStepRow extends React.PureComponent {
/>
);
username = getLongDisplayName(invitation.user);
if (invitation.user.is_bot) {
botBadge = <BotBadge/>;
}
if (isGuest(invitation.user)) {
guestBadge = <GuestBadge/>;
}
Expand Down Expand Up @@ -67,6 +73,7 @@ export default class InvitationModalConfirmStepRow extends React.PureComponent {
{icon}
<span className={className}>
{username}
{botBadge}
{guestBadge}
</span>
</div>
Expand Down
9 changes: 9 additions & 0 deletions components/widgets/inputs/users_emails_input.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import MailIcon from 'components/widgets/icons/mail_icon';
import MailPlusIcon from 'components/widgets/icons/mail_plus_icon';
import CloseCircleSolidIcon from 'components/widgets/icons/close_circle_solid_icon';
import GuestBadge from 'components/widgets/badges/guest_badge';
import BotBadge from 'components/widgets/badges/bot_badge';
import LoadingSpinner from 'components/widgets/loading/loading_spinner';
import Avatar from 'components/widgets/users/avatar';
import {imageURLForUser, getDisplayName, getLongDisplayNameParts} from 'utils/utils.jsx';
Expand Down Expand Up @@ -102,6 +103,12 @@ export default class UsersEmailsInput extends React.PureComponent {
formatOptionLabel = (user, options) => {
const profileImg = imageURLForUser(user.id, user.last_picture_update);
let guestBadge = null;
let botBadge = null;

if (user.is_bot) {
botBadge = <BotBadge/>;
}

if (!isEmail(user.value) && isGuest(user)) {
guestBadge = <GuestBadge/>;
}
Expand All @@ -118,6 +125,7 @@ export default class UsersEmailsInput extends React.PureComponent {
url={profileImg}
/>
{this.renderUserName(user)}
{botBadge}
{guestBadge}
</React.Fragment>
);
Expand All @@ -140,6 +148,7 @@ export default class UsersEmailsInput extends React.PureComponent {
url={profileImg}
/>
{getDisplayName(user)}
{botBadge}
{guestBadge}
</React.Fragment>
);
Expand Down

0 comments on commit 8d81dd0

Please sign in to comment.