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

MM-15452 - Add ability to override LHS icon for bot accounts #3026

Merged
merged 6 commits into from
Jul 9, 2019

Conversation

alifarooq0
Copy link
Contributor

@alifarooq0 alifarooq0 commented Jun 27, 2019

Summary

Add ability to override LHS icon for bot accounts

  • Added a util func iconImageURLForUser to get user icon image
  • Added react-inlinesvg package to support showing SVGs inline
  • Updated SidebarChannelButtonOrLinkIcon component to show user icon if available, otherwise fallback to default bot icon

Ticket Link

Fixes: https://mattermost.atlassian.net/browse/MM-15452

Related Pull Requests

Preview

Default Icon

Screen Shot 2019-06-27 at 10 15 00 AM

Invision Icon

Screen Shot 2019-06-27 at 10 16 45 AM

Github Icon

Screen Shot 2019-06-27 at 10 17 10 AM

Default Icon

Screen Shot 2019-06-27 at 10 14 41 AM

Invision Icon

Screen Shot 2019-06-27 at 10 01 18 AM

Github Icon

Screen Shot 2019-06-27 at 9 58 15 AM

Updating live (gif)

2019-06-27 at 4 46 PM

@alifarooq0 alifarooq0 added the 2: Dev Review Requires review by a core commiter label Jun 27, 2019
Copy link
Member

@marianunez marianunez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@lieut-data lieut-data left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Just a few comments below.

utils/utils.jsx Outdated
@@ -1339,6 +1340,17 @@ export function imageURLForUser(userIdOrObject) {
return Client4.getUsersRoute() + '/' + userIdOrObject.id + '/image?_=' + (userIdOrObject.last_picture_update || 0);
}

export function iconImageURLForUser(userIdOrObject) {
if (typeof userIdOrObject == 'string') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: It's not an issue here, but can we use === for consistency?

utils/utils.jsx Outdated
@@ -1339,6 +1340,17 @@ export function imageURLForUser(userIdOrObject) {
return Client4.getUsersRoute() + '/' + userIdOrObject.id + '/image?_=' + (userIdOrObject.last_picture_update || 0);
}

export function iconImageURLForUser(userIdOrObject) {
if (typeof userIdOrObject == 'string') {
const profile = getUser(store.getState(), userIdOrObject);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's still a lot of code that uses the global store, but this is considered deprecated as it introduces potential re-rendering issues (the connector won't trigger a re-render for any state queries that occur here).

Can we refactor this to accept the state object directly? Also, unless this has strong reuse, I might suggest just defining this function in the connector for the one component that uses it. Easy to refactor out later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ripped getting user through getUser out from here since i really didn't to pass in a botId, but rather always a botuser.

if ((this.props.channelIconUrl && !this.state.svgError) ||
this.props.channelIconUrl !== this.state.channelIconUrl) {
icon = (
<Svg
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the experience on load? Will the icon be empty until we fetch it? Is it feasible to render the default icon until it's loaded?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I actually had the default bot showing while loading the image, but the experience was a bit jittery, so it left it as blank for now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you elaborate on what jittery means in this context? As in, are we flashing between the icons, or flashing no icon at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jittery in the sense that you momentarily see the default icon which is immediately replaced with the custom icon. Happens really fast. As opposed to No icon and then you see the custom icon appear.

@hanzei hanzei added this to the v5.14.0 milestone Jul 6, 2019
Copy link
Member

@lieut-data lieut-data left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@lieut-data
Copy link
Member

@ali-farooq0, one other request to wrap this up: I think the demo plugin uses a bot. Can you update to reflect the override?

@alifarooq0
Copy link
Contributor Author

@ali-farooq0, one other request to wrap this up: I think the demo plugin uses a bot. Can you update to reflect the override?

Good idea. Will do.

@alifarooq0 alifarooq0 merged commit c74f4ca into master Jul 9, 2019
@lieut-data lieut-data added 4: Reviews Complete All reviewers have approved the pull request and removed 2: Dev Review Requires review by a core commiter labels Jul 9, 2019
@lieut-data lieut-data deleted the MM-15452 branch July 9, 2019 16:28
@amyblais amyblais added Changelog/Not Needed Does not require a changelog entry Docs/Not Needed Does not require documentation labels Jul 16, 2019
alifarooq0 added a commit that referenced this pull request Jul 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
4: Reviews Complete All reviewers have approved the pull request Changelog/Not Needed Does not require a changelog entry Docs/Not Needed Does not require documentation
Projects
None yet
5 participants