2017-07-26 18:41:28 -04:00
|
|
|
// Package imports //
|
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
2019-09-09 10:41:41 -04:00
|
|
|
import Icon from 'flavours/glitch/components/icon';
|
2017-07-26 18:41:28 -04:00
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
public: { id: 'privacy.public.short', defaultMessage: 'Public' },
|
|
|
|
unlisted: { id: 'privacy.unlisted.short', defaultMessage: 'Unlisted' },
|
|
|
|
private: { id: 'privacy.private.short', defaultMessage: 'Followers-only' },
|
|
|
|
direct: { id: 'privacy.direct.short', defaultMessage: 'Direct' },
|
|
|
|
});
|
|
|
|
|
2019-09-09 09:16:08 -04:00
|
|
|
export default @injectIntl
|
|
|
|
class VisibilityIcon extends ImmutablePureComponent {
|
2017-07-26 18:41:28 -04:00
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
visibility: PropTypes.string,
|
|
|
|
intl: PropTypes.object.isRequired,
|
|
|
|
withLabel: PropTypes.bool,
|
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const { withLabel, visibility, intl } = this.props;
|
|
|
|
|
2019-09-09 10:41:41 -04:00
|
|
|
const visibilityIcon = {
|
2017-07-26 18:41:28 -04:00
|
|
|
public: 'globe',
|
2019-02-01 10:15:44 -05:00
|
|
|
unlisted: 'unlock',
|
2017-07-26 18:41:28 -04:00
|
|
|
private: 'lock',
|
|
|
|
direct: 'envelope',
|
|
|
|
}[visibility];
|
|
|
|
|
|
|
|
const label = intl.formatMessage(messages[visibility]);
|
|
|
|
|
2019-09-09 10:41:41 -04:00
|
|
|
const icon = (<Icon
|
|
|
|
className='status__visibility-icon'
|
|
|
|
fixedWidth
|
|
|
|
id={visibilityIcon}
|
2017-07-26 18:41:28 -04:00
|
|
|
title={label}
|
|
|
|
aria-hidden='true'
|
|
|
|
/>);
|
|
|
|
|
|
|
|
if (withLabel) {
|
|
|
|
return (<span style={{ whiteSpace: 'nowrap' }}>{icon} {label}</span>);
|
|
|
|
} else {
|
|
|
|
return icon;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|