bugfixes around display of permanentURIs #814

Merged
jessopb merged 1 commit from permanentURIs into master 2018-12-07 03:57:25 +01:00
5 changed files with 36 additions and 14 deletions
Showing only changes of commit 20dc54ba05 - Show all commits

View file

@ -9,6 +9,8 @@ import HorizontalSplit from '@components/HorizontalSplit';
import siteConfig from '@config/siteConfig.json';
import createCanonicalLink from '../../../../utils/createCanonicalLink';
import AssetInfoFooter from '../../components/AssetInfoFooter/index';
import { createPermanentURI } from '@clientutils/createPermanentURI';
const { details: { host } } = siteConfig;
class AssetInfo extends React.Component {
@ -121,7 +123,7 @@ class AssetInfo extends React.Component {
content={
<ClickToCopy
id={'lbry-permanent-url'}
value={`${channelName}#${certificateId}/${name}`}
value={`${createPermanentURI(asset)}`}
/>
}
/>
@ -142,7 +144,7 @@ class AssetInfo extends React.Component {
</a>
<a
className={'link--primary'}
href={`https://open.lbry.io/${channelName}#${certificateId}/${name}`}
href={`https://open.lbry.io/${createPermanentURI(asset)}`}
download={name}
>
LBRY URL

View file

@ -1,14 +1,14 @@
import {connect} from 'react-redux';
import View from './view';
import {selectAsset} from '../../selectors/show';
import {buildURI} from '../../utils/buildURI';
import {createPermanentURI} from '@clientutils/createPermanentURI';
const mapStateToProps = props => {
const { show, publish } = props;
const asset = selectAsset(show);
let uri;
if (asset) {
uri = `lbry://${buildURI(asset)}`;
uri = `lbry://${createPermanentURI(asset)}`;
}
return {
disabled : publish.disabled,

View file

@ -1,10 +0,0 @@
export const buildURI = asset => {
let channelName, certificateId, name, claimId;
if (asset.claimData) {
({ channelName, certificateId, name, claimId } = asset.claimData);
}
if (channelName) {
return `${channelName}:${certificateId}/${name}`;
}
return `${claimId}/${name}`;
};

View file

@ -0,0 +1,24 @@
/*
{ channelName, certificateId, name, claimId } = { claimData } = asset
permanentUrl for a channel
@channelName#certificateId
permanentUrl for an asset in a channel
@channelName#certificateId/name
permanentUrl for an asset published anonymously
name#claimId
*/
export const createPermanentURI = asset => {
let channelName, certificateId, name, claimId;
if (asset.claimData) {
({ channelName, certificateId, name, claimId } = asset.claimData);
}
else return 'Error: unknown asset at createPermanentURI.js';
if (channelName) {
return `${channelName}#${certificateId}/${name}`;
}
return `${name}#${claimId}`;
};

View file

@ -34,6 +34,11 @@ module.exports = () => {
moduleAliases['@config'] = resolve('site/config');
moduleAliases['@private'] = resolve('site/private');
// aliases for utils
moduleAliases['@globalutils'] = resolve('utils');
skhameneh commented 2018-12-07 03:57:07 +01:00 (Migrated from github.com)
Review

I would suggest renaming to something like @rootUtils

I would suggest renaming to something like `@rootUtils`
moduleAliases['@clientutils'] = resolve(`${DEFAULT_ROOT}/utils`);
// moduleAliases['@serverutils'] = resolve('server/utils');
// create specific aliases for locally defined components in the following folders
moduleAliases = addAliasesForCustomComponentFolder('containers', moduleAliases);
moduleAliases = addAliasesForCustomComponentFolder('components', moduleAliases);
@ -48,6 +53,7 @@ module.exports = () => {
moduleAliases['@sagas'] = resolve(`${DEFAULT_ROOT}/sagas`);
moduleAliases['@app'] = resolve(`${DEFAULT_ROOT}/app.js`);
// return finished aliases
return moduleAliases;
};