prevent name change while editing and more fixes

This commit is contained in:
btzr-io 2020-07-30 14:31:55 -05:00 committed by Sean Yesmunt
parent 8067793379
commit 80e1965e46
4 changed files with 15 additions and 11 deletions

View file

@ -74,7 +74,7 @@ function PostEditor(props: Props) {
updatePublishForm({ fileText: text }); updatePublishForm({ fileText: text });
} }
} catch (error) { } catch (error) {
// Handle error.. console.error(error);
} }
} }
@ -100,7 +100,7 @@ function PostEditor(props: Props) {
return ( return (
<FormField <FormField
type={!SIMPLE_SITE && advancedEditor ? 'markdown' : 'textarea'} type={'markdown'}
name="content_post" name="content_post"
label={label} label={label}
placeholder={__('My content for this post...')} placeholder={__('My content for this post...')}

View file

@ -277,10 +277,6 @@ function PublishForm(props: Props) {
} }
} }
function changePublishMode(modeName) {
setMode(modeName);
}
// Update mode on editing // Update mode on editing
useEffect(() => { useEffect(() => {
if (autoSwitchMode && editingURI && myClaimForUri) { if (autoSwitchMode && editingURI && myClaimForUri) {
@ -304,7 +300,7 @@ function PublishForm(props: Props) {
label={modeName} label={modeName}
button="alt" button="alt"
onClick={() => { onClick={() => {
changePublishMode(modeName); setPublishMode(modeName);
}} }}
className={classnames('button-toggle', { 'button-toggle--active': mode === modeName })} className={classnames('button-toggle', { 'button-toggle--active': mode === modeName })}
/> />
@ -363,9 +359,8 @@ function PublishForm(props: Props) {
</React.Fragment> </React.Fragment>
} }
/> />
<PublishName <PublishName
disabled={formDisabled} disabled={isStillEditing || formDisabled}
autoPopulateName={autoPopulateNameFromTitle} autoPopulateName={autoPopulateNameFromTitle}
setAutoPopulateName={setAutoPopulateNameFromTitle} setAutoPopulateName={setAutoPopulateNameFromTitle}
/> />

View file

@ -17,7 +17,7 @@ function NameHelpText(props: Props) {
let nameHelpText; let nameHelpText;
if (isStillEditing) { if (isStillEditing) {
nameHelpText = __('You are currently editing this claim. If you change the URL, you will need to reselect a file.'); nameHelpText = __('You are currently editing this claim.');
} else if (uri && myClaimForUri) { } else if (uri && myClaimForUri) {
const editUri = buildURI({ const editUri = buildURI({
streamName: myClaimForUri.name, streamName: myClaimForUri.name,

View file

@ -13,6 +13,7 @@ type Props = {
uri: string, uri: string,
bid: number, bid: number,
balance: number, balance: number,
disabled: boolean,
isStillEditing: boolean, isStillEditing: boolean,
myClaimForUri: ?StreamClaim, myClaimForUri: ?StreamClaim,
isResolvingUri: boolean, isResolvingUri: boolean,
@ -28,6 +29,7 @@ function PublishName(props: Props) {
name, name,
channel, channel,
uri, uri,
disabled,
isStillEditing, isStillEditing,
myClaimForUri, myClaimForUri,
bid, bid,
@ -105,7 +107,14 @@ function PublishName(props: Props) {
!channel || channel === CHANNEL_ANONYMOUS || channel === CHANNEL_NEW ? '' : `${channel}/` !channel || channel === CHANNEL_ANONYMOUS || channel === CHANNEL_NEW ? '' : `${channel}/`
}`}</div> }`}</div>
</fieldset-section> </fieldset-section>
<FormField type="text" name="content_name" value={name} error={nameError} onChange={handleNameChange} /> <FormField
type="text"
name="content_name"
value={name}
disabled={disabled}
error={nameError}
onChange={handleNameChange}
/>
</fieldset-group> </fieldset-group>
<div className="form-field__help"> <div className="form-field__help">
<NameHelpText <NameHelpText