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"
|
dir="auto"
|
||||||
id="channelHeaderDescription"
|
id="channelHeaderDescription"
|
||||||
>
|
>
|
||||||
<StatusIcon
|
<Memo(StatusIcon)
|
||||||
button={false}
|
|
||||||
className=""
|
|
||||||
status="offline"
|
status="offline"
|
||||||
/>
|
/>
|
||||||
<span
|
<span
|
||||||
@ -372,9 +370,7 @@ exports[`components/ChannelHeader should match snapshot with no last active disp
|
|||||||
dir="auto"
|
dir="auto"
|
||||||
id="channelHeaderDescription"
|
id="channelHeaderDescription"
|
||||||
>
|
>
|
||||||
<StatusIcon
|
<Memo(StatusIcon)
|
||||||
button={false}
|
|
||||||
className=""
|
|
||||||
status="offline"
|
status="offline"
|
||||||
/>
|
/>
|
||||||
<span
|
<span
|
||||||
@ -2344,9 +2340,7 @@ exports[`components/ChannelHeader should render properly when custom status is e
|
|||||||
dir="auto"
|
dir="auto"
|
||||||
id="channelHeaderDescription"
|
id="channelHeaderDescription"
|
||||||
>
|
>
|
||||||
<StatusIcon
|
<Memo(StatusIcon)
|
||||||
button={false}
|
|
||||||
className=""
|
|
||||||
status="offline"
|
status="offline"
|
||||||
/>
|
/>
|
||||||
<span
|
<span
|
||||||
@ -2638,9 +2632,7 @@ exports[`components/ChannelHeader should render properly when custom status is s
|
|||||||
dir="auto"
|
dir="auto"
|
||||||
id="channelHeaderDescription"
|
id="channelHeaderDescription"
|
||||||
>
|
>
|
||||||
<StatusIcon
|
<Memo(StatusIcon)
|
||||||
button={false}
|
|
||||||
className=""
|
|
||||||
status="offline"
|
status="offline"
|
||||||
/>
|
/>
|
||||||
<span
|
<span
|
||||||
|
@ -151,9 +151,7 @@ exports[`components/drafts/panel/panel_body should have called handleFormattedTe
|
|||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
</RoundButton>
|
</RoundButton>
|
||||||
<StatusIcon
|
<Memo(StatusIcon)
|
||||||
button={false}
|
|
||||||
className=""
|
|
||||||
status="status"
|
status="status"
|
||||||
>
|
>
|
||||||
<StatusOfflineIcon
|
<StatusOfflineIcon
|
||||||
@ -184,7 +182,7 @@ exports[`components/drafts/panel/panel_body should have called handleFormattedTe
|
|||||||
</svg>
|
</svg>
|
||||||
</span>
|
</span>
|
||||||
</StatusOfflineIcon>
|
</StatusOfflineIcon>
|
||||||
</StatusIcon>
|
</Memo(StatusIcon)>
|
||||||
</span>
|
</span>
|
||||||
</OverlayTrigger>
|
</OverlayTrigger>
|
||||||
</OverlayTrigger>
|
</OverlayTrigger>
|
||||||
@ -422,9 +420,7 @@ exports[`components/drafts/panel/panel_body should match snapshot 1`] = `
|
|||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
</RoundButton>
|
</RoundButton>
|
||||||
<StatusIcon
|
<Memo(StatusIcon)
|
||||||
button={false}
|
|
||||||
className=""
|
|
||||||
status="status"
|
status="status"
|
||||||
>
|
>
|
||||||
<StatusOfflineIcon
|
<StatusOfflineIcon
|
||||||
@ -455,7 +451,7 @@ exports[`components/drafts/panel/panel_body should match snapshot 1`] = `
|
|||||||
</svg>
|
</svg>
|
||||||
</span>
|
</span>
|
||||||
</StatusOfflineIcon>
|
</StatusOfflineIcon>
|
||||||
</StatusIcon>
|
</Memo(StatusIcon)>
|
||||||
</span>
|
</span>
|
||||||
</OverlayTrigger>
|
</OverlayTrigger>
|
||||||
</OverlayTrigger>
|
</OverlayTrigger>
|
||||||
@ -699,9 +695,7 @@ exports[`components/drafts/panel/panel_body should match snapshot for priority 1
|
|||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
</RoundButton>
|
</RoundButton>
|
||||||
<StatusIcon
|
<Memo(StatusIcon)
|
||||||
button={false}
|
|
||||||
className=""
|
|
||||||
status="status"
|
status="status"
|
||||||
>
|
>
|
||||||
<StatusOfflineIcon
|
<StatusOfflineIcon
|
||||||
@ -732,7 +726,7 @@ exports[`components/drafts/panel/panel_body should match snapshot for priority 1
|
|||||||
</svg>
|
</svg>
|
||||||
</span>
|
</span>
|
||||||
</StatusOfflineIcon>
|
</StatusOfflineIcon>
|
||||||
</StatusIcon>
|
</Memo(StatusIcon)>
|
||||||
</span>
|
</span>
|
||||||
</OverlayTrigger>
|
</OverlayTrigger>
|
||||||
</OverlayTrigger>
|
</OverlayTrigger>
|
||||||
@ -1038,9 +1032,7 @@ exports[`components/drafts/panel/panel_body should match snapshot for requested_
|
|||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
</RoundButton>
|
</RoundButton>
|
||||||
<StatusIcon
|
<Memo(StatusIcon)
|
||||||
button={false}
|
|
||||||
className=""
|
|
||||||
status="status"
|
status="status"
|
||||||
>
|
>
|
||||||
<StatusOfflineIcon
|
<StatusOfflineIcon
|
||||||
@ -1071,7 +1063,7 @@ exports[`components/drafts/panel/panel_body should match snapshot for requested_
|
|||||||
</svg>
|
</svg>
|
||||||
</span>
|
</span>
|
||||||
</StatusOfflineIcon>
|
</StatusOfflineIcon>
|
||||||
</StatusIcon>
|
</Memo(StatusIcon)>
|
||||||
</span>
|
</span>
|
||||||
</OverlayTrigger>
|
</OverlayTrigger>
|
||||||
</OverlayTrigger>
|
</OverlayTrigger>
|
||||||
|
@ -12,9 +12,7 @@ exports[`components/ProfilePicture should match snapshot, no user specified, def
|
|||||||
url="http://example.com/image.png"
|
url="http://example.com/image.png"
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
<StatusIcon
|
<Memo(StatusIcon)
|
||||||
button={false}
|
|
||||||
className=""
|
|
||||||
status="away"
|
status="away"
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
@ -32,9 +30,7 @@ exports[`components/ProfilePicture should match snapshot, no user specified, ove
|
|||||||
url="http://example.com/image.png"
|
url="http://example.com/image.png"
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
<StatusIcon
|
<Memo(StatusIcon)
|
||||||
button={false}
|
|
||||||
className=""
|
|
||||||
status="away"
|
status="away"
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
@ -76,9 +72,7 @@ exports[`components/ProfilePicture should match snapshot, profile and src, defau
|
|||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
</RoundButton>
|
</RoundButton>
|
||||||
<StatusIcon
|
<Memo(StatusIcon)
|
||||||
button={false}
|
|
||||||
className=""
|
|
||||||
status="away"
|
status="away"
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
@ -97,9 +91,7 @@ exports[`components/ProfilePicture should match snapshot, user specified 1`] = `
|
|||||||
url="http://example.com/image.png"
|
url="http://example.com/image.png"
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
<StatusIcon
|
<Memo(StatusIcon)
|
||||||
button={false}
|
|
||||||
className=""
|
|
||||||
status="away"
|
status="away"
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
@ -117,9 +109,7 @@ exports[`components/ProfilePicture should match snapshot, user specified, overri
|
|||||||
url="http://example.com/image.png"
|
url="http://example.com/image.png"
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
<StatusIcon
|
<Memo(StatusIcon)
|
||||||
button={false}
|
|
||||||
className=""
|
|
||||||
status="away"
|
status="away"
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||||
// See LICENSE.txt for license information.
|
// 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 StatusAwayAvatarIcon from 'components/widgets/icons/status_away_avatar_icon';
|
||||||
import StatusAwayIcon from 'components/widgets/icons/status_away_icon';
|
import StatusAwayIcon from 'components/widgets/icons/status_away_icon';
|
||||||
@ -19,47 +19,39 @@ type Props = {
|
|||||||
type?: string;
|
type?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class StatusIcon extends React.PureComponent<Props> {
|
const StatusIcon = ({
|
||||||
static defaultProps = {
|
className = '',
|
||||||
className: '',
|
button = false,
|
||||||
button: false,
|
status,
|
||||||
};
|
type,
|
||||||
|
}: Props) => {
|
||||||
render() {
|
if (!status) {
|
||||||
const {button, status, type} = this.props;
|
return null;
|
||||||
|
|
||||||
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}/>;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
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)>
|
</Memo(Avatar)>
|
||||||
</span>
|
</span>
|
||||||
<StatusIcon
|
<Memo(StatusIcon) />
|
||||||
button={false}
|
|
||||||
className=""
|
|
||||||
/>
|
|
||||||
</span>
|
</span>
|
||||||
<span
|
<span
|
||||||
className="suggestion-list__ellipsis"
|
className="suggestion-list__ellipsis"
|
||||||
@ -162,10 +159,7 @@ exports[`at mention suggestion Should not display nick name of the signed in use
|
|||||||
/>
|
/>
|
||||||
</Memo(Avatar)>
|
</Memo(Avatar)>
|
||||||
</span>
|
</span>
|
||||||
<StatusIcon
|
<Memo(StatusIcon) />
|
||||||
button={false}
|
|
||||||
className=""
|
|
||||||
/>
|
|
||||||
</span>
|
</span>
|
||||||
<span
|
<span
|
||||||
className="suggestion-list__ellipsis"
|
className="suggestion-list__ellipsis"
|
||||||
|
Loading…
Reference in New Issue
Block a user