hotfix for invalid names

This commit is contained in:
Sean Yesmunt 2019-07-24 14:21:34 -04:00
parent fcd71e0b79
commit 91f28d7be1
3 changed files with 8 additions and 6 deletions

View file

@ -1,7 +1,7 @@
// @flow
import React, { useEffect, Fragment } from 'react';
import { CHANNEL_NEW, CHANNEL_ANONYMOUS } from 'constants/claim';
import { buildURI, isURIValid, THUMBNAIL_STATUSES } from 'lbry-redux';
import { buildURI, isURIValid, isNameValid, THUMBNAIL_STATUSES } from 'lbry-redux';
import Button from 'component/button';
import ChannelSection from 'component/selectChannel';
import classnames from 'classnames';
@ -77,7 +77,8 @@ function PublishForm(props: Props) {
} = props;
const formDisabled = (!filePath && !editingURI) || publishing;
// If they are editing, they don't need a new file chosen
const formValidLessFile = name && title && bid && !(uploadThumbnailStatus === THUMBNAIL_STATUSES.IN_PROGRESS);
const formValidLessFile =
name && isNameValid(name, false) && title && bid && !(uploadThumbnailStatus === THUMBNAIL_STATUSES.IN_PROGRESS);
const formValid = editingURI && !filePath ? isStillEditing && formValidLessFile : formValidLessFile;
let submitLabel;

View file

@ -1,6 +1,6 @@
// @flow
import React from 'react';
import { THUMBNAIL_STATUSES } from 'lbry-redux';
import { THUMBNAIL_STATUSES, isNameValid } from 'lbry-redux';
type Props = {
title: ?string,
@ -21,6 +21,7 @@ function PublishFormErrors(props: Props) {
<div className="error-text">
{!title && <div>{__('A title is required')}</div>}
{!name && <div>{__('A URL is required')}</div>}
{!isNameValid(name, false) && __('LBRY names cannot contain spaces or reserved symbols ($#@;/"<>%{}|^~[]`)')}
{!bid && <div>{__('A deposit amount is required')}</div>}
{uploadThumbnailStatus === THUMBNAIL_STATUSES.IN_PROGRESS && (
<div>{__('Please wait for thumbnail to finish uploading')}</div>

View file

@ -76,8 +76,8 @@ class ChannelSection extends React.PureComponent<Props, State> {
}
let newChannelNameError;
if (newChannelName.length > 1 && !isNameValid(newChannelName.substr(1), false)) {
newChannelNameError = __('LBRY channel names must contain only letters, numbers and dashes.');
if (newChannelName.length > 0 && !isNameValid(newChannelName, false)) {
newChannelNameError = __('LBRY names cannot contain spaces or reserved symbols ($#@;/"<>%{}|^~[]`)');
}
this.setState({
@ -107,7 +107,7 @@ class ChannelSection extends React.PureComponent<Props, State> {
const { balance, createChannel, onChannelChange } = this.props;
const { newChannelBid, newChannelName } = this.state;
const channelName = `@${newChannelName}`;
const channelName = `@${newChannelName.trim()}`;
if (newChannelBid > balance) {
return;