updated publish redirects and channel nav buttons
This commit is contained in:
parent
b60fbab744
commit
6073935732
5 changed files with 31 additions and 21 deletions
|
@ -127,7 +127,7 @@ AssetDisplay.propTypes = {
|
||||||
src : PropTypes.string.isRequired,
|
src : PropTypes.string.isRequired,
|
||||||
contentType: PropTypes.string.isRequired,
|
contentType: PropTypes.string.isRequired,
|
||||||
fileExt : PropTypes.string.isRequired,
|
fileExt : PropTypes.string.isRequired,
|
||||||
thumbnail : PropTypes.string.isRequired,
|
thumbnail : PropTypes.string,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default AssetDisplay;
|
export default AssetDisplay;
|
||||||
|
|
|
@ -13,6 +13,8 @@ class ChannelClaimsDisplay extends React.Component {
|
||||||
totalClaims: null,
|
totalClaims: null,
|
||||||
};
|
};
|
||||||
this.updateClaimsData = this.updateClaimsData.bind(this);
|
this.updateClaimsData = this.updateClaimsData.bind(this);
|
||||||
|
this.showPreviousResultsPage = this.showPreviousResultsPage.bind(this);
|
||||||
|
this.showNextResultsPage = this.showNextResultsPage.bind(this);
|
||||||
}
|
}
|
||||||
componentDidMount () {
|
componentDidMount () {
|
||||||
this.updateClaimsData(1);
|
this.updateClaimsData(1);
|
||||||
|
@ -39,6 +41,14 @@ class ChannelClaimsDisplay extends React.Component {
|
||||||
that.setState({error: error.message});
|
that.setState({error: error.message});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
showPreviousResultsPage () {
|
||||||
|
const previousPage = parseInt(this.state.currentPage) - 1;
|
||||||
|
this.updateClaimsData(previousPage);
|
||||||
|
}
|
||||||
|
showNextResultsPage () {
|
||||||
|
const nextPage = parseInt(this.state.currentPage) + 1;
|
||||||
|
this.updateClaimsData(nextPage);
|
||||||
|
}
|
||||||
render () {
|
render () {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
@ -50,8 +60,6 @@ class ChannelClaimsDisplay extends React.Component {
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="row row--tall">
|
<div className="row row--tall">
|
||||||
<p>total pages: {this.state.totalPages}</p>
|
|
||||||
<p>total claims: {this.state.totalClaims}</p>
|
|
||||||
{this.state.claims &&
|
{this.state.claims &&
|
||||||
<div>
|
<div>
|
||||||
{this.state.claims.map((claim, index) => <AssetPreview
|
{this.state.claims.map((claim, index) => <AssetPreview
|
||||||
|
@ -59,11 +67,12 @@ class ChannelClaimsDisplay extends React.Component {
|
||||||
claimId={claim.claimId}
|
claimId={claim.claimId}
|
||||||
fileExt={claim.fileExt}
|
fileExt={claim.fileExt}
|
||||||
contentType={claim.contentType}
|
contentType={claim.contentType}
|
||||||
key={index}
|
key={`${claim.name}-${index}`}
|
||||||
/>)}
|
/>)}
|
||||||
{(this.state.currentPage > 1) && <button onClick={this.updateClaimsData(this.state.currentPage - 1)}>Previous Page</button>}
|
<div>
|
||||||
<p>current page: {this.state.currentPage}</p>
|
{(this.state.currentPage > 1) && <button onClick={this.showPreviousResultsPage}>Previous Page</button>}
|
||||||
{(this.state.currentPage < this.state.totalPages) && <button onClick={this.updateClaimsData(this.state.currentPage + 1)}>Next Page</button>}
|
{(this.state.currentPage < this.state.totalPages) && <button onClick={this.showNextResultsPage}>Next Page</button>}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -30,7 +30,7 @@ function PublishStatus ({ status, message }) {
|
||||||
{(status === publishStates.SUCCESS) &&
|
{(status === publishStates.SUCCESS) &&
|
||||||
<div className="row align-content-center">
|
<div className="row align-content-center">
|
||||||
<p>Your publish is complete! You are being redirected to it now.</p>
|
<p>Your publish is complete! You are being redirected to it now.</p>
|
||||||
<p>If you are not automatically redirected, <a class="link--primary" target="_blank" href={message}>click here.</a></p>
|
<p>If you are not automatically redirected, <a className="link--primary" target="_blank" href={message}>click here.</a></p>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
{(status === publishStates.FAILED) &&
|
{(status === publishStates.FAILED) &&
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { withRouter } from 'react-router-dom';
|
||||||
import Dropzone from 'containers/Dropzone';
|
import Dropzone from 'containers/Dropzone';
|
||||||
import PublishTitleInput from 'containers/PublishTitleInput';
|
import PublishTitleInput from 'containers/PublishTitleInput';
|
||||||
import PublishUrlInput from 'containers/PublishUrlInput';
|
import PublishUrlInput from 'containers/PublishUrlInput';
|
||||||
|
@ -70,16 +71,14 @@ class PublishForm extends React.Component {
|
||||||
xhr.open('POST', uri, true);
|
xhr.open('POST', uri, true);
|
||||||
xhr.onreadystatechange = function () {
|
xhr.onreadystatechange = function () {
|
||||||
if (xhr.readyState === 4) {
|
if (xhr.readyState === 4) {
|
||||||
console.log('publish response:', xhr.response);
|
const response = JSON.parse(xhr.response);
|
||||||
if (xhr.status === 200) {
|
console.log('publish response:', response);
|
||||||
console.log('publish complete!');
|
if ((xhr.status === 200) && response.success) {
|
||||||
const url = JSON.parse(xhr.response).message.url;
|
that.props.onPublishStatusChange(publishStates.SUCCESS, response.data.url);
|
||||||
that.props.onPublishStatusChange(publishStates.SUCCESS, url);
|
// redirect to the published asset's show page
|
||||||
window.location = url;
|
that.props.history.push(`/${response.data.claimId}/${response.data.name}`);
|
||||||
} else if (xhr.status === 502) {
|
|
||||||
that.props.onPublishStatusChange(publishStates.FAILED, 'Spee.ch was not able to get a response from the LBRY network.');
|
|
||||||
} else {
|
} else {
|
||||||
that.props.onPublishStatusChange(publishStates.FAILED, JSON.parse(xhr.response).message);
|
that.props.onPublishStatusChange(publishStates.FAILED, response.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -176,4 +175,4 @@ class PublishForm extends React.Component {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export default PublishForm;
|
export default withRouter(PublishForm);
|
||||||
|
|
|
@ -151,8 +151,10 @@ module.exports = (app) => {
|
||||||
.then(result => {
|
.then(result => {
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
success: true,
|
success: true,
|
||||||
message: {
|
message: 'publish completed successfully',
|
||||||
|
data : {
|
||||||
name,
|
name,
|
||||||
|
claimId: result.claim_id,
|
||||||
url : `${site.host}/${result.claim_id}/${name}`,
|
url : `${site.host}/${result.claim_id}/${name}`,
|
||||||
lbryTx : result,
|
lbryTx : result,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue