Convert class to function component (#25769)
Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
@@ -15,47 +15,54 @@ type Props = {
|
|||||||
status?: 'warning' | 'error';
|
status?: 'warning' | 'error';
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class StatisticCount extends React.PureComponent<Props> {
|
const StatisticCount = ({
|
||||||
public render(): JSX.Element {
|
title,
|
||||||
const loading = (
|
icon,
|
||||||
<FormattedMessage
|
count,
|
||||||
id='analytics.chart.loading'
|
id,
|
||||||
defaultMessage='Loading...'
|
children,
|
||||||
/>
|
status,
|
||||||
);
|
}: Props) => {
|
||||||
|
const loading = (
|
||||||
|
<FormattedMessage
|
||||||
|
id='analytics.chart.loading'
|
||||||
|
defaultMessage='Loading...'
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='grid-statistics__card'>
|
<div className='grid-statistics__card'>
|
||||||
|
<div
|
||||||
|
className={classNames({
|
||||||
|
'total-count': true,
|
||||||
|
'total-count--has-message': Boolean(status),
|
||||||
|
})}
|
||||||
|
>
|
||||||
<div
|
<div
|
||||||
|
data-testid={`${id}Title`}
|
||||||
className={classNames({
|
className={classNames({
|
||||||
'total-count': true,
|
title: true,
|
||||||
'total-count--has-message': Boolean(this.props.status),
|
'team_statistics--warning': status === 'warning',
|
||||||
|
'team_statistics--error': status === 'error',
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<div
|
{title}
|
||||||
data-testid={`${this.props.id}Title`}
|
<i className={'fa ' + icon}/>
|
||||||
className={classNames({
|
</div>
|
||||||
title: true,
|
<div
|
||||||
'team_statistics--warning': this.props.status === 'warning',
|
data-testid={id}
|
||||||
'team_statistics--error': this.props.status === 'error',
|
className={classNames({
|
||||||
})}
|
content: true,
|
||||||
>
|
'team_statistics--warning': status === 'warning',
|
||||||
{this.props.title}
|
'team_statistics--error': status === 'error',
|
||||||
<i className={'fa ' + this.props.icon}/>
|
})}
|
||||||
</div>
|
>
|
||||||
<div
|
{typeof count === 'undefined' || isNaN(count) ? loading : count}
|
||||||
data-testid={this.props.id}
|
|
||||||
className={classNames({
|
|
||||||
content: true,
|
|
||||||
'team_statistics--warning': this.props.status === 'warning',
|
|
||||||
'team_statistics--error': this.props.status === 'error',
|
|
||||||
})}
|
|
||||||
>
|
|
||||||
{typeof this.props.count === 'undefined' || isNaN(this.props.count) ? loading : this.props.count}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
{this.props.children}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
{children}
|
||||||
}
|
</div>
|
||||||
}
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default React.memo(StatisticCount);
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user