1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-22 11:57:34 +00:00

[draft] removed related code & files (#5993)

* [draft] removed related code & files

* [draft] removed related code & files
This commit is contained in:
llj
2024-03-25 17:22:01 +08:00
committed by GitHub
parent 43f66cbbca
commit 4375115548
43 changed files with 29 additions and 1405 deletions

View File

@@ -18,8 +18,6 @@ class CreateFile extends React.Component {
this.state = {
parentPath: '',
childName: props.fileType || '',
isMarkdownDraft: false,
isSdocDraft: false,
errMessage: '',
isSubmitBtnActive: props.fileType.slice(0, -5) ? true : false,
};
@@ -61,8 +59,7 @@ class CreateFile extends React.Component {
this.setState({errMessage: errMessage});
} else {
let path = this.state.parentPath + newName;
const { isMarkdownDraft, isSdocDraft } = this.state;
this.props.onAddFile(path, isMarkdownDraft, isSdocDraft);
this.props.onAddFile(path);
this.props.toggleDialog();
}
};
@@ -74,55 +71,6 @@ class CreateFile extends React.Component {
}
};
handleCheck = () => {
let pos = this.state.childName.lastIndexOf('.');
if (this.state.isMarkdownDraft) {
// from draft to not draft
// case 1, normally, the file name is ended with `(draft)`, like `test(draft).md`
// case 2, the file name is not ended with `(draft)`, the user has deleted some characters, like `test(dra.md`
let p = this.state.childName.substring(pos-7, pos);
let fileName = this.state.childName.substring(0, pos-7);
let fileType = this.state.childName.substring(pos);
if (p === '(draft)') {
// remove `(draft)` from file name
this.setState({
childName: fileName + fileType,
isMarkdownDraft: !this.state.isMarkdownDraft
});
} else {
// don't change file name
this.setState({
isMarkdownDraft: !this.state.isMarkdownDraft
});
}
}
if (!this.state.isMarkdownDraft) {
// from not draft to draft
// case 1, test.md ===> test(draft).md
// case 2, .md ===> (draft).md
// case 3, no '.' in the file name, don't change the file name
if (pos > 0) {
let fileName = this.state.childName.substring(0, pos);
let fileType = this.state.childName.substring(pos);
this.setState({
childName: fileName + '(draft)' + fileType,
isMarkdownDraft: !this.state.isMarkdownDraft
});
} else if (pos === 0 ) {
this.setState({
childName: '(draft)' + this.state.childName,
isMarkdownDraft: !this.state.isMarkdownDraft
});
} else {
this.setState({
isMarkdownDraft: !this.state.isMarkdownDraft
});
}
}
};
checkDuplicatedName = () => {
let isDuplicated = this.props.checkDuplicatedName(this.state.childName);
return isDuplicated;
@@ -134,12 +82,6 @@ class CreateFile extends React.Component {
this.newInput.current.setSelectionRange(0,0);
};
toggleMarkSdocDraft = (e) => {
this.setState({
isSdocDraft: e.target.checked
});
};
render() {
const { toggleDialog } = this.props;
return (
@@ -157,21 +99,6 @@ class CreateFile extends React.Component {
onChange={this.handleChange}
/>
</FormGroup>
{/*this.props.fileType == '.md' && isDocs && (
<FormGroup check>
<Label check>
<Input type="checkbox" onChange={this.handleCheck}/>{' '}{gettext('This is a draft')}
</Label>
</FormGroup>
)*/}
{/*this.props.fileType == '.sdoc' && (
<FormGroup check>
<Label check>
<Input type="checkbox" checked={isSdocDraft} onChange={this.toggleMarkSdocDraft}/>
<span>{gettext('Mark as draft')}</span>
</Label>
</FormGroup>
)*/}
</Form>
{this.state.errMessage && <Alert color="danger" className="mt-2">{this.state.errMessage}</Alert>}
</ModalBody>