2017-04-08 08:25:38 -04:00
|
|
|
import React from 'react';
|
|
|
|
import lbry from '../lbry.js';
|
2017-04-18 15:14:42 -04:00
|
|
|
import lbryuri from '../lbryuri.js';
|
2017-04-08 08:25:38 -04:00
|
|
|
import {Icon} from './common.js';
|
|
|
|
|
2017-04-11 22:01:45 -04:00
|
|
|
const UriIndicator = React.createClass({
|
2017-04-08 08:25:38 -04:00
|
|
|
propTypes: {
|
|
|
|
uri: React.PropTypes.string.isRequired,
|
2017-04-10 21:24:35 -04:00
|
|
|
hasSignature: React.PropTypes.bool.isRequired,
|
|
|
|
signatureIsValid: React.PropTypes.bool,
|
2017-04-08 08:25:38 -04:00
|
|
|
},
|
|
|
|
render: function() {
|
|
|
|
|
2017-04-18 15:14:42 -04:00
|
|
|
const uriObj = lbryuri.parse(this.props.uri);
|
2017-04-11 22:01:45 -04:00
|
|
|
|
|
|
|
if (!this.props.hasSignature || !uriObj.isChannel) {
|
|
|
|
return <span className="empty">Anonymous</span>;
|
2017-04-08 08:25:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
const channelUriObj = Object.assign({}, uriObj);
|
|
|
|
delete channelUriObj.path;
|
2017-04-19 13:56:17 -04:00
|
|
|
delete channelUriObj.contentName;
|
2017-04-18 15:14:42 -04:00
|
|
|
const channelUri = lbryuri.build(channelUriObj, false);
|
2017-04-08 08:25:38 -04:00
|
|
|
|
|
|
|
let icon, modifier;
|
2017-04-10 21:24:35 -04:00
|
|
|
if (this.props.signatureIsValid) {
|
2017-04-08 08:25:38 -04:00
|
|
|
modifier = 'valid';
|
|
|
|
} else {
|
|
|
|
icon = 'icon-times-circle';
|
|
|
|
modifier = 'invalid';
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
<span>
|
2017-04-11 22:01:45 -04:00
|
|
|
{channelUri} {' '}
|
|
|
|
{ !this.props.signatureIsValid ?
|
|
|
|
<Icon icon={icon} className={`channel-indicator__icon channel-indicator__icon--${modifier}`} /> :
|
|
|
|
'' }
|
2017-04-08 08:25:38 -04:00
|
|
|
</span>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-04-11 22:01:45 -04:00
|
|
|
export default UriIndicator;
|