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';
|
|
|
|
|
|
|
|
const ChannelIndicator = React.createClass({
|
|
|
|
propTypes: {
|
|
|
|
uri: React.PropTypes.string.isRequired,
|
2017-04-11 03:24:35 +02:00
|
|
|
hasSignature: React.PropTypes.bool.isRequired,
|
|
|
|
signatureIsValid: React.PropTypes.bool,
|
2017-04-08 14:25:38 +02:00
|
|
|
},
|
|
|
|
render: function() {
|
2017-04-11 03:24:35 +02:00
|
|
|
if (!this.props.hasSignature) {
|
2017-04-08 14:25:38 +02:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
const uriObj = uri.parseLbryUri(this.props.uri);
|
|
|
|
if (!uriObj.isChannel) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
const channelUriObj = Object.assign({}, uriObj);
|
|
|
|
delete channelUriObj.path;
|
|
|
|
const channelUri = uri.buildLbryUri(channelUriObj, false);
|
|
|
|
|
|
|
|
let icon, modifier;
|
2017-04-11 03:24:35 +02:00
|
|
|
if (this.props.signatureIsValid) {
|
2017-04-08 14:25:38 +02:00
|
|
|
icon = 'icon-check-circle';
|
|
|
|
modifier = 'valid';
|
|
|
|
} else {
|
|
|
|
icon = 'icon-times-circle';
|
|
|
|
modifier = 'invalid';
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
<span>
|
|
|
|
by <strong>{channelUri}</strong> {' '}
|
|
|
|
<Icon icon={icon} className={`channel-indicator__icon channel-indicator__icon--${modifier}`} />
|
|
|
|
</span>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
export default ChannelIndicator;
|