for #989, files cannot be renamed to empty string

This commit is contained in:
Rachel Lim 2019-06-30 19:41:27 -04:00 committed by Cassie Tarakajian
parent cdf1585b72
commit 4861c03e36

View file

@ -67,6 +67,7 @@ export class FileNode extends React.Component {
validateFileName() {
const oldFileExtension = this.originalFileName.match(/\.[0-9a-z]+$/i);
const newFileExtension = this.props.name.match(/\.[0-9a-z]+$/i);
const newFileName = this.props.name;
if (oldFileExtension && !newFileExtension) {
this.props.updateFileName(this.props.id, this.originalFileName);
}
@ -77,6 +78,12 @@ export class FileNode extends React.Component {
) {
this.props.updateFileName(this.props.id, this.originalFileName);
}
if (newFileName === '') {
this.props.updateFileName(this.props.id, this.originalFileName);
}
if (newFileName === newFileExtension[0]) {
this.props.updateFileName(this.props.id, this.originalFileName);
}
}
toggleFileOptions(e) {