lbry-desktop/ui/js/component/channel-indicator.js

42 lines
1.1 KiB
JavaScript
Raw Normal View History

2017-04-08 14:25:38 +02:00
import React from 'react';
import lbry from '../lbry.js';
import uri from '../uri.js';
import {Icon} from './common.js';
2017-04-12 04:01:45 +02:00
const UriIndicator = React.createClass({
2017-04-08 14:25:38 +02:00
propTypes: {
uri: React.PropTypes.string.isRequired,
hasSignature: React.PropTypes.bool.isRequired,
signatureIsValid: React.PropTypes.bool,
2017-04-08 14:25:38 +02:00
},
render: function() {
const uriObj = uri.parseLbryUri(this.props.uri);
2017-04-12 04:01:45 +02:00
if (!this.props.hasSignature || !uriObj.isChannel) {
return <span className="empty">Anonymous</span>;
2017-04-08 14:25:38 +02:00
}
const channelUriObj = Object.assign({}, uriObj);
delete channelUriObj.path;
const channelUri = uri.buildLbryUri(channelUriObj, false);
let icon, modifier;
if (this.props.signatureIsValid) {
2017-04-08 14:25:38 +02:00
modifier = 'valid';
} else {
icon = 'icon-times-circle';
modifier = 'invalid';
}
return (
<span>
2017-04-12 04:01:45 +02:00
{channelUri} {' '}
{ !this.props.signatureIsValid ?
<Icon icon={icon} className={`channel-indicator__icon channel-indicator__icon--${modifier}`} /> :
'' }
2017-04-08 14:25:38 +02:00
</span>
);
}
});
2017-04-12 04:01:45 +02:00
export default UriIndicator;