fix: fix bid help text uri and allow metadata only edits

This commit is contained in:
Sean Yesmunt 2018-04-06 02:22:35 -04:00
parent 05e6fbed12
commit 88b2fcc057
3 changed files with 19 additions and 16 deletions

View file

@ -7,7 +7,7 @@ type Props = {
editingURI: ?string, editingURI: ?string,
isResolvingUri: boolean, isResolvingUri: boolean,
winningBidForClaimUri: ?number, winningBidForClaimUri: ?number,
claimIsMine: ?boolean, myClaimForUri: ?{},
onEditMyClaim: any => void, onEditMyClaim: any => void,
}; };
@ -18,7 +18,7 @@ class BidHelpText extends React.PureComponent<Props> {
editingURI, editingURI,
isResolvingUri, isResolvingUri,
winningBidForClaimUri, winningBidForClaimUri,
claimIsMine, myClaimForUri,
onEditMyClaim, onEditMyClaim,
} = this.props; } = this.props;
@ -34,12 +34,12 @@ class BidHelpText extends React.PureComponent<Props> {
return __('Checking the winning claim amount...'); return __('Checking the winning claim amount...');
} }
if (claimIsMine) { if (myClaimForUri) {
return ( return (
<React.Fragment> <React.Fragment>
{__('You already have a claim at')} {__('You already have a claim at')}
{` ${uri} `} {` ${uri} `}
<Button button="link" label="Edit it" onClick={onEditMyClaim} /> <Button button="link" label="Edit it" onClick={() => onEditMyClaim(myClaimForUri, uri)} />
<br /> <br />
{__('Publishing will update your existing claim.')} {__('Publishing will update your existing claim.')}
</React.Fragment> </React.Fragment>

View file

@ -55,7 +55,7 @@ type Props = {
clearPublish: () => void, clearPublish: () => void,
resolveUri: string => void, resolveUri: string => void,
scrollToTop: () => void, scrollToTop: () => void,
prepareEdit: ({}) => void, prepareEdit: ({}, uri) => void,
}; };
class PublishForm extends React.PureComponent<Props> { class PublishForm extends React.PureComponent<Props> {
@ -159,10 +159,10 @@ class PublishForm extends React.PureComponent<Props> {
updatePublishForm({ bid, bidError }); updatePublishForm({ bid, bidError });
} }
editExistingClaim() { editExistingClaim(myClaimForUri: ?{}, uri: string) {
const { myClaimForUri, prepareEdit, scrollToTop } = this.props; const { prepareEdit, scrollToTop } = this.props;
if (myClaimForUri) { if (myClaimForUri) {
prepareEdit(myClaimForUri); prepareEdit(myClaimForUri, uri);
scrollToTop(); scrollToTop();
} }
} }
@ -300,7 +300,8 @@ class PublishForm extends React.PureComponent<Props> {
const formDisabled = (!filePath && !editingURI) || publishing; const formDisabled = (!filePath && !editingURI) || publishing;
const formValid = this.checkIsFormValid(); const formValid = this.checkIsFormValid();
const isStillEditing = editingURI === uri; const simpleUri = uri && uri.split('#')[0];
const isStillEditing = editingURI === simpleUri;
let submitLabel; let submitLabel;
if (isStillEditing) { if (isStillEditing) {
submitLabel = !publishing ? __('Edit') : __('Editing...'); submitLabel = !publishing ? __('Edit') : __('Editing...');
@ -446,11 +447,11 @@ class PublishForm extends React.PureComponent<Props> {
error={nameError} error={nameError}
helper={ helper={
<BidHelpText <BidHelpText
uri={uri} uri={simpleUri}
editingURI={editingURI} editingURI={editingURI}
isResolvingUri={isResolvingUri} isResolvingUri={isResolvingUri}
winningBidForClaimUri={winningBidForClaimUri} winningBidForClaimUri={winningBidForClaimUri}
claimIsMine={!!myClaimForUri} myClaimForUri={myClaimForUri}
onEditMyClaim={this.editExistingClaim} onEditMyClaim={this.editExistingClaim}
/> />
} }

View file

@ -1,15 +1,17 @@
import React from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doNavigate } from 'redux/actions/navigation'; import { doNavigate } from 'redux/actions/navigation';
import { doClaimRewardType } from 'redux/actions/rewards';
import { selectMyClaims, selectClaimsByUri } from 'redux/selectors/claims'; import { selectMyClaims, selectClaimsByUri } from 'redux/selectors/claims';
import { selectResolvingUris } from 'redux/selectors/content'; import { selectResolvingUris } from 'redux/selectors/content';
import { selectPublishFormValues } from 'redux/selectors/publish'; import { selectPublishFormValues } from 'redux/selectors/publish';
import { doResolveUri } from 'redux/actions/content'; import { doResolveUri } from 'redux/actions/content';
import { selectBalance } from 'redux/selectors/wallet'; import { selectBalance } from 'redux/selectors/wallet';
import { doClearPublish, doUpdatePublishForm, doPublish } from 'redux/actions/publish'; import {
doClearPublish,
doUpdatePublishForm,
doPublish,
doPrepareEdit,
} from 'redux/actions/publish';
import { makeSelectCostInfoForUri } from 'redux/selectors/cost_info'; import { makeSelectCostInfoForUri } from 'redux/selectors/cost_info';
import { doPrepareEdit } from 'redux/actions/publish';
import PublishPage from './view'; import PublishPage from './view';
const select = (state, props) => { const select = (state, props) => {
@ -50,7 +52,7 @@ const perform = dispatch => ({
resolveUri: uri => dispatch(doResolveUri(uri)), resolveUri: uri => dispatch(doResolveUri(uri)),
publish: params => dispatch(doPublish(params)), publish: params => dispatch(doPublish(params)),
navigate: path => dispatch(doNavigate(path)), navigate: path => dispatch(doNavigate(path)),
prepareEdit: claim => dispatch(doPrepareEdit(claim)), prepareEdit: (claim, uri) => dispatch(doPrepareEdit(claim, uri)),
}); });
export default connect(select, perform)(PublishPage); export default connect(select, perform)(PublishPage);