mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-22 11:57:34 +00:00
[eslint] updated eslintrc and improved the code (#4702)
This commit is contained in:
@@ -44,7 +44,7 @@ class CreateFile extends React.Component {
|
||||
}
|
||||
|
||||
this.setState({
|
||||
childName: e.target.value,
|
||||
childName: e.target.value,
|
||||
}) ;
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ class CreateFile extends React.Component {
|
||||
|
||||
let isDuplicated = this.checkDuplicatedName();
|
||||
let newName = this.state.childName;
|
||||
|
||||
|
||||
if (isDuplicated) {
|
||||
let errMessage = gettext('The name "{name}" is already taken. Please choose a different name.');
|
||||
errMessage = errMessage.replace('{name}', Utils.HTMLescape(newName));
|
||||
@@ -65,7 +65,7 @@ class CreateFile extends React.Component {
|
||||
let isDraft = this.state.isDraft;
|
||||
this.props.onAddFile(path, isDraft);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
handleKeyPress = (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
@@ -76,7 +76,7 @@ class CreateFile extends React.Component {
|
||||
|
||||
handleCheck = () => {
|
||||
let pos = this.state.childName.lastIndexOf('.');
|
||||
|
||||
|
||||
if (this.state.isDraft) {
|
||||
// from draft to not draft
|
||||
// case 1, normally, the file name is ended with `(draft)`, like `test(draft).md`
|
||||
@@ -87,7 +87,7 @@ class CreateFile extends React.Component {
|
||||
if (p === '(draft)') {
|
||||
// remove `(draft)` from file name
|
||||
this.setState({
|
||||
childName: fileName + fileType,
|
||||
childName: fileName + fileType,
|
||||
isDraft: !this.state.isDraft
|
||||
});
|
||||
} else {
|
||||
@@ -97,7 +97,7 @@ class CreateFile extends React.Component {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!this.state.isDraft) {
|
||||
// from not draft to draft
|
||||
// case 1, test.md ===> test(draft).md
|
||||
@@ -112,14 +112,14 @@ class CreateFile extends React.Component {
|
||||
});
|
||||
} else if (pos === 0 ) {
|
||||
this.setState({
|
||||
childName: '(draft)' + this.state.childName,
|
||||
childName: '(draft)' + this.state.childName,
|
||||
isDraft: !this.state.isdraft
|
||||
});
|
||||
} else {
|
||||
this.setState({
|
||||
isDraft: !this.state.isdraft
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,11 +140,11 @@ class CreateFile extends React.Component {
|
||||
<Form>
|
||||
<FormGroup>
|
||||
<Label for="fileName">{gettext('Name')}</Label>
|
||||
<Input
|
||||
id="fileName"
|
||||
onKeyPress={this.handleKeyPress}
|
||||
innerRef={input => {this.newInput = input;}}
|
||||
value={this.state.childName}
|
||||
<Input
|
||||
id="fileName"
|
||||
onKeyPress={this.handleKeyPress}
|
||||
innerRef={input => {this.newInput = input;}}
|
||||
value={this.state.childName}
|
||||
onChange={this.handleChange}
|
||||
/>
|
||||
</FormGroup>
|
||||
|
Reference in New Issue
Block a user