mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-02 23:48:47 +00:00
update-dir-file-path-validation (#6958)
* update-dir-file-path-validation * Update utils.js
This commit is contained in:
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Button, Modal, ModalHeader, Input, ModalBody, ModalFooter, Form, FormGroup, Label, Alert } from 'reactstrap';
|
||||
import { gettext } from '../../utils/constants';
|
||||
import { Utils } from '../../utils/utils';
|
||||
import { Utils, validateName } from '../../utils/utils';
|
||||
|
||||
const propTypes = {
|
||||
fileType: PropTypes.string,
|
||||
@@ -54,9 +54,13 @@ class CreateFile extends React.Component {
|
||||
if (!this.state.isSubmitBtnActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
let isDuplicated = this.checkDuplicatedName();
|
||||
let newName = this.state.childName;
|
||||
let newName = this.state.childName.trim();
|
||||
let { isValid, errMessage } = validateName(newName);
|
||||
if (!isValid) {
|
||||
this.setState({ errMessage });
|
||||
return;
|
||||
}
|
||||
|
||||
if (isDuplicated) {
|
||||
let errMessage = gettext('The name "{name}" is already taken. Please choose a different name.');
|
||||
|
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Button, Modal, ModalHeader, Input, ModalBody, ModalFooter, Form, FormGroup, Label, Alert } from 'reactstrap';
|
||||
import { gettext } from '../../utils/constants';
|
||||
import { Utils } from '../../utils/utils';
|
||||
import { Utils, validateName } from '../../utils/utils';
|
||||
|
||||
const propTypes = {
|
||||
fileType: PropTypes.string,
|
||||
@@ -46,9 +46,13 @@ class CreateForder extends React.Component {
|
||||
if (!this.state.isSubmitBtnActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
let newName = this.state.childName;
|
||||
let isDuplicated = this.checkDuplicatedName();
|
||||
let newName = this.state.childName.trim();
|
||||
let { isValid, errMessage } = validateName(newName);
|
||||
if (!isValid) {
|
||||
this.setState({ errMessage });
|
||||
return;
|
||||
}
|
||||
|
||||
if (isDuplicated) {
|
||||
let errMessage = gettext('The name "{name}" is already taken. Please choose a different name.');
|
||||
|
Reference in New Issue
Block a user