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