lbry-desktop/ui/js/component/uriIndicator/view.jsx

50 lines
1 KiB
React
Raw Normal View History

2017-05-02 07:25:31 +02:00
import React from 'react';
import lbry from 'lbry';
import lbryuri from 'lbryuri';
import {Icon} from 'component/common';
const UriIndicator = (props) => {
const {
uri,
2017-05-10 05:06:48 +02:00
claim
2017-05-02 07:25:31 +02:00
} = props
const uriObj = lbryuri.parse(uri);
2017-05-10 05:06:48 +02:00
if (!claim) {
return <span className="empty">Unused</span>
}
const {
has_signature: hasSignature,
signature_is_valid: signatureIsValid
} = claim
2017-05-02 07:25:31 +02:00
if (!hasSignature || !uriObj.isChannel) {
return <span className="empty">Anonymous</span>;
}
const channelUriObj = Object.assign({}, uriObj);
delete channelUriObj.path;
delete channelUriObj.contentName;
const channelUri = lbryuri.build(channelUriObj, false);
let icon, modifier;
if (signatureIsValid) {
modifier = 'valid';
} else {
icon = 'icon-times-circle';
modifier = 'invalid';
}
return (
<span>
{channelUri} {' '}
{ !signatureIsValid ?
<Icon icon={icon} className={`channel-indicator__icon channel-indicator__icon--${modifier}`} /> :
'' }
</span>
)
}
export default UriIndicator;