move edit link from AssetTitle to AssetInfo

This commit is contained in:
Travis Eden 2018-09-25 10:58:19 -04:00
parent 4c9608a964
commit 5d3f66d201
4 changed files with 18 additions and 13 deletions

View file

@ -6,9 +6,11 @@ const mapStateToProps = (props) => {
const {show} = props;
// select asset
const asset = selectAsset(show);
const editable = Boolean(props.channel.loggedInChannel.name === asset.claimData.channelName);
// return props
return {
asset,
editable,
};
};

View file

@ -13,10 +13,11 @@ import createCanonicalLink from '../../../../utils/createCanonicalLink';
class AssetInfo extends React.Component {
render () {
const { asset } = this.props;
const { claimViews, claimData: { channelName, channelShortId, description, name, fileExt, contentType, thumbnail, host } } = asset;
const { editable, asset } = this.props;
const { claimViews, claimData } = asset;
const { channelName, claimId, channelShortId, description, name, fileExt, contentType, host } = claimData;
const canonicalUrl = createCanonicalLink({ asset: { ...asset.claimData, shortId: asset.shortId }});
const canonicalUrl = createCanonicalLink({ asset: { ...claimData, shortId: asset.shortId }});
const assetCanonicalUrl = `${host}${canonicalUrl}`;
let channelCanonicalUrl;
@ -29,6 +30,15 @@ class AssetInfo extends React.Component {
}
return (
<div>
{editable && (
<Row>
<RowLabeled
label={<Label value={'Edit:'} />}
content={<Link to={`/edit/${claimId}/${name}`}>{name}</Link>}
/>
</Row>
)}
{channelName && (
<Row>
<RowLabeled

View file

@ -3,13 +3,9 @@ import View from './view';
import { selectAsset } from '../../selectors/show';
const mapStateToProps = (props) => {
const { claimData: { title, claimId, name, channelName } } = selectAsset(props.show);
const editable = Boolean(props.channel.loggedInChannel.name === channelName);
const { claimData: { title } } = selectAsset(props.show);
return {
title,
claimId,
name,
editable,
};
};

View file

@ -2,13 +2,10 @@ import React from 'react';
import { Link } from 'react-router-dom';
import Row from '@components/Row';
const AssetTitle = ({ title, editable, claimId, name }) => {
const AssetTitle = ({ title }) => {
return (
<Row>
<h3>
{title}
{editable && (<span> (<Link to={`/edit/${claimId}/${name}`}>edit</Link>)</span>)}
</h3>
<h3>{title}</h3>
</Row>
);
};