Merge branch 'v16-edit' into v16
This commit is contained in:
commit
f2116b21bb
5 changed files with 98 additions and 83 deletions
|
@ -24,7 +24,7 @@ const perform = dispatch => ({
|
||||||
openModal: (modal, props) => dispatch(doOpenModal(modal, props)),
|
openModal: (modal, props) => dispatch(doOpenModal(modal, props)),
|
||||||
startDownload: uri => dispatch(doPurchaseUri(uri)),
|
startDownload: uri => dispatch(doPurchaseUri(uri)),
|
||||||
restartDownload: (uri, outpoint) => dispatch(doStartDownload(uri, outpoint)),
|
restartDownload: (uri, outpoint) => dispatch(doStartDownload(uri, outpoint)),
|
||||||
editClaim: fileInfo => dispatch(doNavigate("/publish", fileInfo)),
|
editClaim: claimId => dispatch(doNavigate("/publish", { id: claimId })),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(select, perform)(FileActions);
|
export default connect(select, perform)(FileActions);
|
||||||
|
|
|
@ -9,12 +9,17 @@ class FileActions extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { fileInfo, uri, openModal, claimIsMine, editClaim } = this.props;
|
const {
|
||||||
|
fileInfo,
|
||||||
|
uri,
|
||||||
|
openModal,
|
||||||
|
claimIsMine,
|
||||||
|
editClaim,
|
||||||
|
checkAvailability,
|
||||||
|
} = this.props;
|
||||||
|
|
||||||
const name = fileInfo ? fileInfo.name : null;
|
const claimId = fileInfo ? fileInfo.claim_id : null,
|
||||||
const channel = fileInfo ? fileInfo.channel_name : null;
|
metadata = fileInfo ? fileInfo.metadata : null,
|
||||||
|
|
||||||
const metadata = fileInfo ? fileInfo.metadata : null,
|
|
||||||
showMenu = fileInfo && Object.keys(fileInfo).length > 0,
|
showMenu = fileInfo && Object.keys(fileInfo).length > 0,
|
||||||
title = metadata ? metadata.title : uri;
|
title = metadata ? metadata.title : uri;
|
||||||
|
|
||||||
|
@ -25,7 +30,7 @@ class FileActions extends React.PureComponent {
|
||||||
button="text"
|
button="text"
|
||||||
icon="icon-edit"
|
icon="icon-edit"
|
||||||
label={__("Edit")}
|
label={__("Edit")}
|
||||||
onClick={() => editClaim({ name, channel })}
|
onClick={() => editClaim(claimId)}
|
||||||
/>}
|
/>}
|
||||||
<FileDownloadLink uri={uri} />
|
<FileDownloadLink uri={uri} />
|
||||||
<Link
|
<Link
|
||||||
|
|
|
@ -19,6 +19,7 @@ class PublishForm extends React.PureComponent {
|
||||||
this._defaultPaidPrice = 0.01;
|
this._defaultPaidPrice = 0.01;
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
|
id: null,
|
||||||
rawName: "",
|
rawName: "",
|
||||||
name: "",
|
name: "",
|
||||||
bid: 10,
|
bid: 10,
|
||||||
|
@ -189,10 +190,10 @@ class PublishForm extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
handleEditClaim() {
|
handleEditClaim() {
|
||||||
const isMine = this.myClaimExists();
|
const claimInfo = this.claim() || this.myClaimInfo();
|
||||||
|
|
||||||
if (isMine) {
|
if (claimInfo) {
|
||||||
this.handlePrefillClicked();
|
this.handlePrefillClaim(claimInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,10 +213,10 @@ class PublishForm extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
myClaimInfo() {
|
myClaimInfo() {
|
||||||
const { name } = this.state;
|
const { id } = this.state;
|
||||||
|
|
||||||
return Object.values(this.props.myClaims).find(
|
return Object.values(this.props.myClaims).find(
|
||||||
claim => claim.name === name
|
claim => claim.claim_id === id
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,9 +273,10 @@ class PublishForm extends React.PureComponent {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
handlePrefillClicked() {
|
handlePrefillClaim(claimInfo) {
|
||||||
const claimInfo = this.myClaimInfo();
|
const { claim_id, name, channel_name, amount } = claimInfo;
|
||||||
const { source } = claimInfo.value.stream;
|
const { source, metadata } = claimInfo.value.stream;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
license,
|
license,
|
||||||
licenseUrl,
|
licenseUrl,
|
||||||
|
@ -283,17 +285,21 @@ class PublishForm extends React.PureComponent {
|
||||||
description,
|
description,
|
||||||
language,
|
language,
|
||||||
nsfw,
|
nsfw,
|
||||||
} = claimInfo.value.stream.metadata;
|
} = metadata;
|
||||||
|
|
||||||
let newState = {
|
let newState = {
|
||||||
mode: "edit",
|
id: claim_id,
|
||||||
|
channel: channel_name || "anonymous",
|
||||||
|
bid: amount,
|
||||||
meta_title: title,
|
meta_title: title,
|
||||||
meta_thumbnail: thumbnail,
|
meta_thumbnail: thumbnail,
|
||||||
meta_description: description,
|
meta_description: description,
|
||||||
meta_language: language,
|
meta_language: language,
|
||||||
meta_nsfw: nsfw,
|
meta_nsfw: nsfw,
|
||||||
|
mode: "edit",
|
||||||
prefillDone: true,
|
prefillDone: true,
|
||||||
bid: claimInfo.amount,
|
rawName: name,
|
||||||
|
name,
|
||||||
source,
|
source,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -423,16 +429,11 @@ class PublishForm extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillMount() {
|
componentWillMount() {
|
||||||
let { name, channel } = this.props.params;
|
|
||||||
|
|
||||||
channel = channel || this.state.channel;
|
|
||||||
|
|
||||||
this.props.fetchClaimListMine();
|
this.props.fetchClaimListMine();
|
||||||
this._updateChannelList();
|
this._updateChannelList();
|
||||||
|
|
||||||
if (name) {
|
const { id } = this.props.params;
|
||||||
this.setState({ name, rawName: name, channel });
|
this.setState({ id });
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
@ -461,37 +462,38 @@ class PublishForm extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
getNameBidHelpText() {
|
getNameBidHelpText() {
|
||||||
if (this.state.prefillDone) {
|
const { prefillDone, name, uri } = this.state;
|
||||||
|
const { resolvingUris } = this.props;
|
||||||
|
const claim = this.claim();
|
||||||
|
|
||||||
|
if (prefillDone) {
|
||||||
return __("Existing claim data was prefilled");
|
return __("Existing claim data was prefilled");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (uri && resolvingUris.indexOf(uri) !== -1 && claim === undefined) {
|
||||||
this.state.uri &&
|
|
||||||
this.props.resolvingUris.indexOf(this.state.uri) !== -1 &&
|
|
||||||
this.claim() === undefined
|
|
||||||
) {
|
|
||||||
return __("Checking...");
|
return __("Checking...");
|
||||||
} else if (!this.state.name) {
|
} else if (!name) {
|
||||||
return __("Select a URL for this publish.");
|
return __("Select a URL for this publish.");
|
||||||
} else if (!this.claim()) {
|
} else if (!claim) {
|
||||||
return __("This URL is unused.");
|
return __("This URL is unused.");
|
||||||
} else if (this.myClaimExists() && !this.state.prefillDone) {
|
} else if (this.myClaimExists() && !prefillDone) {
|
||||||
return (
|
return (
|
||||||
<span>
|
<span>
|
||||||
{__("You already have a claim with this name.")}{" "}
|
{__("You already have a claim with this name.")}{" "}
|
||||||
<Link
|
<Link
|
||||||
label={__("Edit existing claim")}
|
label={__("Edit existing claim")}
|
||||||
onClick={() => this.handlePrefillClicked()}
|
onClick={() => this.handleEditClaim()}
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
} else if (this.claim()) {
|
} else if (claim) {
|
||||||
if (this.topClaimValue() === 1) {
|
const topClaimValue = this.topClaimValue();
|
||||||
|
if (topClaimValue === 1) {
|
||||||
return (
|
return (
|
||||||
<span>
|
<span>
|
||||||
{__(
|
{__(
|
||||||
'A deposit of at least one credit is required to win "%s". However, you can still get a permanent URL for any amount.',
|
'A deposit of at least one credit is required to win "%s". However, you can still get a permanent URL for any amount.',
|
||||||
this.state.name
|
name
|
||||||
)}
|
)}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
|
@ -500,8 +502,8 @@ class PublishForm extends React.PureComponent {
|
||||||
<span>
|
<span>
|
||||||
{__(
|
{__(
|
||||||
'A deposit of at least "%s" credits is required to win "%s". However, you can still get a permanent URL for any amount.',
|
'A deposit of at least "%s" credits is required to win "%s". However, you can still get a permanent URL for any amount.',
|
||||||
this.topClaimValue(),
|
topClaimValue,
|
||||||
this.state.name
|
name
|
||||||
)}
|
)}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
|
|
|
@ -87,7 +87,7 @@ export const selectPageTitle = createSelector(
|
||||||
case "start":
|
case "start":
|
||||||
return __("Start");
|
return __("Start");
|
||||||
case "publish":
|
case "publish":
|
||||||
return __("Publish");
|
return params.id ? __("Edit") : __("Publish");
|
||||||
case "help":
|
case "help":
|
||||||
return __("Help");
|
return __("Help");
|
||||||
case "developer":
|
case "developer":
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
import { createSelector } from "reselect";
|
import { createSelector } from "reselect";
|
||||||
import { selectPageTitle, selectCurrentPage } from "selectors/navigation";
|
import {
|
||||||
|
selectPageTitle,
|
||||||
|
selectCurrentPage,
|
||||||
|
selectCurrentParams,
|
||||||
|
} from "selectors/navigation";
|
||||||
|
|
||||||
export const _selectState = state => state.search || {};
|
export const _selectState = state => state.search || {};
|
||||||
|
|
||||||
|
@ -36,45 +40,49 @@ export const selectWunderBarAddress = createSelector(
|
||||||
(page, title, query) => (page != "search" ? title : query ? query : title)
|
(page, title, query) => (page != "search" ? title : query ? query : title)
|
||||||
);
|
);
|
||||||
|
|
||||||
export const selectWunderBarIcon = createSelector(selectCurrentPage, page => {
|
export const selectWunderBarIcon = createSelector(
|
||||||
switch (page) {
|
selectCurrentPage,
|
||||||
case "auth":
|
selectCurrentParams,
|
||||||
return "icon-user";
|
(page, params) => {
|
||||||
case "search":
|
switch (page) {
|
||||||
return "icon-search";
|
case "auth":
|
||||||
case "settings":
|
return "icon-user";
|
||||||
return "icon-gear";
|
case "search":
|
||||||
case "help":
|
return "icon-search";
|
||||||
return "icon-question";
|
case "settings":
|
||||||
case "report":
|
return "icon-gear";
|
||||||
return "icon-file";
|
case "help":
|
||||||
case "downloaded":
|
return "icon-question";
|
||||||
return "icon-folder";
|
case "report":
|
||||||
case "published":
|
return "icon-file";
|
||||||
return "icon-folder";
|
case "downloaded":
|
||||||
case "history":
|
return "icon-folder";
|
||||||
return "icon-history";
|
case "published":
|
||||||
case "send":
|
return "icon-folder";
|
||||||
return "icon-send";
|
case "history":
|
||||||
case "rewards":
|
return "icon-history";
|
||||||
return "icon-rocket";
|
case "send":
|
||||||
case "invite":
|
return "icon-send";
|
||||||
return "icon-envelope-open";
|
case "rewards":
|
||||||
case "address":
|
return "icon-rocket";
|
||||||
case "receive":
|
case "invite":
|
||||||
return "icon-address-book";
|
return "icon-envelope-open";
|
||||||
case "wallet":
|
case "address":
|
||||||
case "backup":
|
case "receive":
|
||||||
return "icon-bank";
|
return "icon-address-book";
|
||||||
case "show":
|
case "wallet":
|
||||||
return "icon-file";
|
case "backup":
|
||||||
case "publish":
|
return "icon-bank";
|
||||||
return "icon-upload";
|
case "show":
|
||||||
case "developer":
|
return "icon-file";
|
||||||
return "icon-code";
|
case "publish":
|
||||||
case "discover":
|
return params.id ? __("icon-pencil") : __("icon-upload");
|
||||||
return "icon-home";
|
case "developer":
|
||||||
default:
|
return "icon-code";
|
||||||
return "icon-file";
|
case "discover":
|
||||||
|
return "icon-home";
|
||||||
|
default:
|
||||||
|
return "icon-file";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue