mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
[MM-56842] Convert ./components/status_icon.tsx
from Class Component to Function Component (#26257)
Co-authored-by: Mattermost Build <build@mattermost.com>
This commit is contained in:
parent
a19e999c11
commit
590b75e9fc
@ -76,9 +76,7 @@ exports[`components/ChannelHeader should match snapshot with last active display
|
||||
dir="auto"
|
||||
id="channelHeaderDescription"
|
||||
>
|
||||
<StatusIcon
|
||||
button={false}
|
||||
className=""
|
||||
<Memo(StatusIcon)
|
||||
status="offline"
|
||||
/>
|
||||
<span
|
||||
@ -372,9 +370,7 @@ exports[`components/ChannelHeader should match snapshot with no last active disp
|
||||
dir="auto"
|
||||
id="channelHeaderDescription"
|
||||
>
|
||||
<StatusIcon
|
||||
button={false}
|
||||
className=""
|
||||
<Memo(StatusIcon)
|
||||
status="offline"
|
||||
/>
|
||||
<span
|
||||
@ -2344,9 +2340,7 @@ exports[`components/ChannelHeader should render properly when custom status is e
|
||||
dir="auto"
|
||||
id="channelHeaderDescription"
|
||||
>
|
||||
<StatusIcon
|
||||
button={false}
|
||||
className=""
|
||||
<Memo(StatusIcon)
|
||||
status="offline"
|
||||
/>
|
||||
<span
|
||||
@ -2638,9 +2632,7 @@ exports[`components/ChannelHeader should render properly when custom status is s
|
||||
dir="auto"
|
||||
id="channelHeaderDescription"
|
||||
>
|
||||
<StatusIcon
|
||||
button={false}
|
||||
className=""
|
||||
<Memo(StatusIcon)
|
||||
status="offline"
|
||||
/>
|
||||
<span
|
||||
|
@ -151,9 +151,7 @@ exports[`components/drafts/panel/panel_body should have called handleFormattedTe
|
||||
</span>
|
||||
</button>
|
||||
</RoundButton>
|
||||
<StatusIcon
|
||||
button={false}
|
||||
className=""
|
||||
<Memo(StatusIcon)
|
||||
status="status"
|
||||
>
|
||||
<StatusOfflineIcon
|
||||
@ -184,7 +182,7 @@ exports[`components/drafts/panel/panel_body should have called handleFormattedTe
|
||||
</svg>
|
||||
</span>
|
||||
</StatusOfflineIcon>
|
||||
</StatusIcon>
|
||||
</Memo(StatusIcon)>
|
||||
</span>
|
||||
</OverlayTrigger>
|
||||
</OverlayTrigger>
|
||||
@ -422,9 +420,7 @@ exports[`components/drafts/panel/panel_body should match snapshot 1`] = `
|
||||
</span>
|
||||
</button>
|
||||
</RoundButton>
|
||||
<StatusIcon
|
||||
button={false}
|
||||
className=""
|
||||
<Memo(StatusIcon)
|
||||
status="status"
|
||||
>
|
||||
<StatusOfflineIcon
|
||||
@ -455,7 +451,7 @@ exports[`components/drafts/panel/panel_body should match snapshot 1`] = `
|
||||
</svg>
|
||||
</span>
|
||||
</StatusOfflineIcon>
|
||||
</StatusIcon>
|
||||
</Memo(StatusIcon)>
|
||||
</span>
|
||||
</OverlayTrigger>
|
||||
</OverlayTrigger>
|
||||
@ -699,9 +695,7 @@ exports[`components/drafts/panel/panel_body should match snapshot for priority 1
|
||||
</span>
|
||||
</button>
|
||||
</RoundButton>
|
||||
<StatusIcon
|
||||
button={false}
|
||||
className=""
|
||||
<Memo(StatusIcon)
|
||||
status="status"
|
||||
>
|
||||
<StatusOfflineIcon
|
||||
@ -732,7 +726,7 @@ exports[`components/drafts/panel/panel_body should match snapshot for priority 1
|
||||
</svg>
|
||||
</span>
|
||||
</StatusOfflineIcon>
|
||||
</StatusIcon>
|
||||
</Memo(StatusIcon)>
|
||||
</span>
|
||||
</OverlayTrigger>
|
||||
</OverlayTrigger>
|
||||
@ -1038,9 +1032,7 @@ exports[`components/drafts/panel/panel_body should match snapshot for requested_
|
||||
</span>
|
||||
</button>
|
||||
</RoundButton>
|
||||
<StatusIcon
|
||||
button={false}
|
||||
className=""
|
||||
<Memo(StatusIcon)
|
||||
status="status"
|
||||
>
|
||||
<StatusOfflineIcon
|
||||
@ -1071,7 +1063,7 @@ exports[`components/drafts/panel/panel_body should match snapshot for requested_
|
||||
</svg>
|
||||
</span>
|
||||
</StatusOfflineIcon>
|
||||
</StatusIcon>
|
||||
</Memo(StatusIcon)>
|
||||
</span>
|
||||
</OverlayTrigger>
|
||||
</OverlayTrigger>
|
||||
|
@ -12,9 +12,7 @@ exports[`components/ProfilePicture should match snapshot, no user specified, def
|
||||
url="http://example.com/image.png"
|
||||
/>
|
||||
</span>
|
||||
<StatusIcon
|
||||
button={false}
|
||||
className=""
|
||||
<Memo(StatusIcon)
|
||||
status="away"
|
||||
/>
|
||||
</span>
|
||||
@ -32,9 +30,7 @@ exports[`components/ProfilePicture should match snapshot, no user specified, ove
|
||||
url="http://example.com/image.png"
|
||||
/>
|
||||
</span>
|
||||
<StatusIcon
|
||||
button={false}
|
||||
className=""
|
||||
<Memo(StatusIcon)
|
||||
status="away"
|
||||
/>
|
||||
</span>
|
||||
@ -76,9 +72,7 @@ exports[`components/ProfilePicture should match snapshot, profile and src, defau
|
||||
/>
|
||||
</span>
|
||||
</RoundButton>
|
||||
<StatusIcon
|
||||
button={false}
|
||||
className=""
|
||||
<Memo(StatusIcon)
|
||||
status="away"
|
||||
/>
|
||||
</span>
|
||||
@ -97,9 +91,7 @@ exports[`components/ProfilePicture should match snapshot, user specified 1`] = `
|
||||
url="http://example.com/image.png"
|
||||
/>
|
||||
</span>
|
||||
<StatusIcon
|
||||
button={false}
|
||||
className=""
|
||||
<Memo(StatusIcon)
|
||||
status="away"
|
||||
/>
|
||||
</span>
|
||||
@ -117,9 +109,7 @@ exports[`components/ProfilePicture should match snapshot, user specified, overri
|
||||
url="http://example.com/image.png"
|
||||
/>
|
||||
</span>
|
||||
<StatusIcon
|
||||
button={false}
|
||||
className=""
|
||||
<Memo(StatusIcon)
|
||||
status="away"
|
||||
/>
|
||||
</span>
|
||||
|
@ -1,7 +1,7 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import React from 'react';
|
||||
import React, {memo} from 'react';
|
||||
|
||||
import StatusAwayAvatarIcon from 'components/widgets/icons/status_away_avatar_icon';
|
||||
import StatusAwayIcon from 'components/widgets/icons/status_away_icon';
|
||||
@ -19,47 +19,39 @@ type Props = {
|
||||
type?: string;
|
||||
}
|
||||
|
||||
export default class StatusIcon extends React.PureComponent<Props> {
|
||||
static defaultProps = {
|
||||
className: '',
|
||||
button: false,
|
||||
};
|
||||
|
||||
render() {
|
||||
const {button, status, type} = this.props;
|
||||
|
||||
if (!status) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let className = 'status ' + this.props.className;
|
||||
|
||||
if (button) {
|
||||
className = this.props.className || '';
|
||||
}
|
||||
|
||||
let IconComponent: React.ComponentType<{className?: string}> | string;
|
||||
const iconComponentProps = {className};
|
||||
if (type === 'avatar') {
|
||||
if (status === 'online') {
|
||||
IconComponent = StatusOnlineAvatarIcon;
|
||||
} else if (status === 'away') {
|
||||
IconComponent = StatusAwayAvatarIcon;
|
||||
} else if (status === 'dnd') {
|
||||
IconComponent = StatusDndAvatarIcon;
|
||||
} else {
|
||||
IconComponent = StatusOfflineAvatarIcon;
|
||||
}
|
||||
} else if (status === 'online') {
|
||||
IconComponent = StatusOnlineIcon;
|
||||
} else if (status === 'away') {
|
||||
IconComponent = StatusAwayIcon;
|
||||
} else if (status === 'dnd') {
|
||||
IconComponent = StatusDndIcon;
|
||||
} else {
|
||||
IconComponent = StatusOfflineIcon;
|
||||
}
|
||||
|
||||
return <IconComponent {...iconComponentProps}/>;
|
||||
const StatusIcon = ({
|
||||
className = '',
|
||||
button = false,
|
||||
status,
|
||||
type,
|
||||
}: Props) => {
|
||||
if (!status) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
let iconClassName = `status ${className}`;
|
||||
|
||||
if (button) {
|
||||
iconClassName = className || '';
|
||||
}
|
||||
|
||||
if (type === 'avatar') {
|
||||
if (status === 'online') {
|
||||
return <StatusOnlineAvatarIcon className={iconClassName}/>;
|
||||
} else if (status === 'away') {
|
||||
return <StatusAwayAvatarIcon className={iconClassName}/>;
|
||||
} else if (status === 'dnd') {
|
||||
return <StatusDndAvatarIcon className={iconClassName}/>;
|
||||
}
|
||||
return <StatusOfflineAvatarIcon className={iconClassName}/>;
|
||||
} else if (status === 'online') {
|
||||
return <StatusOnlineIcon className={iconClassName}/>;
|
||||
} else if (status === 'away') {
|
||||
return <StatusAwayIcon className={iconClassName}/>;
|
||||
} else if (status === 'dnd') {
|
||||
return <StatusDndIcon className={iconClassName}/>;
|
||||
}
|
||||
return <StatusOfflineIcon className={iconClassName}/>;
|
||||
};
|
||||
|
||||
export default memo(StatusIcon);
|
||||
|
@ -63,10 +63,7 @@ exports[`at mention suggestion Should display nick name of non signed in user 1`
|
||||
/>
|
||||
</Memo(Avatar)>
|
||||
</span>
|
||||
<StatusIcon
|
||||
button={false}
|
||||
className=""
|
||||
/>
|
||||
<Memo(StatusIcon) />
|
||||
</span>
|
||||
<span
|
||||
className="suggestion-list__ellipsis"
|
||||
@ -162,10 +159,7 @@ exports[`at mention suggestion Should not display nick name of the signed in use
|
||||
/>
|
||||
</Memo(Avatar)>
|
||||
</span>
|
||||
<StatusIcon
|
||||
button={false}
|
||||
className=""
|
||||
/>
|
||||
<Memo(StatusIcon) />
|
||||
</span>
|
||||
<span
|
||||
className="suggestion-list__ellipsis"
|
||||
|
Loading…
Reference in New Issue
Block a user