2022-10-05 01:47:56 +00:00
import PropTypes from 'prop-types' ;
2022-10-09 01:49:51 +00:00
import React from 'react' ;
import { FormattedMessage , defineMessages , injectIntl } from 'react-intl' ;
2022-10-05 01:47:56 +00:00
import { connect } from 'react-redux' ;
2022-10-09 01:49:51 +00:00
import { fetchServer } from 'flavours/glitch/actions/server' ;
2022-10-05 01:47:56 +00:00
import ShortNumber from 'flavours/glitch/components/short_number' ;
import Skeleton from 'flavours/glitch/components/skeleton' ;
2022-10-09 01:49:51 +00:00
import Account from 'flavours/glitch/containers/account_container' ;
import { domain } from 'flavours/glitch/initial_state' ;
2022-10-13 12:42:37 +00:00
import Image from 'flavours/glitch/components/image' ;
import { Link } from 'react-router-dom' ;
2022-10-05 01:47:56 +00:00
const messages = defineMessages ( {
aboutActiveUsers : { id : 'server_banner.about_active_users' , defaultMessage : 'People using this server during the last 30 days (Monthly Active Users)' } ,
} ) ;
const mapStateToProps = state => ( {
2022-10-13 12:42:37 +00:00
server : state . getIn ( [ 'server' , 'server' ] ) ,
2022-10-05 01:47:56 +00:00
} ) ;
export default @ connect ( mapStateToProps )
@ injectIntl
class ServerBanner extends React . PureComponent {
static propTypes = {
server : PropTypes . object ,
dispatch : PropTypes . func ,
intl : PropTypes . object ,
} ;
componentDidMount ( ) {
const { dispatch } = this . props ;
dispatch ( fetchServer ( ) ) ;
}
render ( ) {
const { server , intl } = this . props ;
const isLoading = server . get ( 'isLoading' ) ;
return (
< div className = 'server-banner' >
< div className = 'server-banner__introduction' >
< FormattedMessage id = 'server_banner.introduction' defaultMessage = '{domain} is part of the decentralized social network powered by {mastodon}.' values = { { domain : < strong > { domain } < /strong>, mastodon: <a href='https:/ / joinmastodon . org ' target=' _blank ' > Mastodon < /a> }} / >
< / d i v >
2022-10-13 12:42:37 +00:00
< Image blurhash = { server . getIn ( [ 'thumbnail' , 'blurhash' ] ) } src = { server . getIn ( [ 'thumbnail' , 'url' ] ) } className = 'server-banner__hero' / >
2022-10-05 01:47:56 +00:00
< div className = 'server-banner__description' >
{ isLoading ? (
< >
< Skeleton width = '100%' / >
< br / >
< Skeleton width = '100%' / >
< br / >
< Skeleton width = '70%' / >
< / >
) : server . get ( 'description' ) }
< / d i v >
< div className = 'server-banner__meta' >
< div className = 'server-banner__meta__column' >
< h4 > < FormattedMessage id = 'server_banner.administered_by' defaultMessage = 'Administered by:' / > < / h 4 >
< Account id = { server . getIn ( [ 'contact' , 'account' , 'id' ] ) } / >
< / d i v >
< div className = 'server-banner__meta__column' >
< h4 > < FormattedMessage id = 'server_banner.server_stats' defaultMessage = 'Server stats:' / > < / h 4 >
{ isLoading ? (
< >
< strong className = 'server-banner__number' > < Skeleton width = '10ch' / > < / s t r o n g >
< br / >
< span className = 'server-banner__number-label' > < Skeleton width = '5ch' / > < / s p a n >
< / >
) : (
< >
< strong className = 'server-banner__number' > < ShortNumber value = { server . getIn ( [ 'usage' , 'users' , 'active_month' ] ) } / > < / s t r o n g >
< br / >
< span className = 'server-banner__number-label' title = { intl . formatMessage ( messages . aboutActiveUsers ) } > < FormattedMessage id = 'server_banner.active_users' defaultMessage = 'active users' / > < / s p a n >
< / >
) }
< / d i v >
< / d i v >
< hr className = 'spacer' / >
2022-10-13 12:42:37 +00:00
< Link className = 'button button--block button-secondary' to = '/about' > < FormattedMessage id = 'server_banner.learn_more' defaultMessage = 'Learn more' / > < / L i n k >
2022-10-05 01:47:56 +00:00
< / d i v >
) ;
}
}