1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-10 19:29:56 +00:00

Merge pull request #6002 from haiwen/fix-create-new-file-error

fix: optimize code
This commit is contained in:
杨顺强
2024-04-02 16:06:14 +08:00
committed by GitHub

View File

@@ -15,11 +15,12 @@ const propTypes = {
class CreateFile extends React.Component { class CreateFile extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
const { fileType = '' } = props;
this.state = { this.state = {
parentPath: '', parentPath: '',
childName: props.fileType || '', childName: fileType,
errMessage: '', errMessage: '',
isSubmitBtnActive: props.fileType.slice(0, -5) ? true : false, isSubmitBtnActive: this.isSdocSuffix(fileType) ? true : false,
}; };
this.newInput = React.createRef(); this.newInput = React.createRef();
} }
@@ -33,6 +34,10 @@ class CreateFile extends React.Component {
} }
} }
isSdocSuffix = (name) => {
return name.endsWith('.sdoc');
};
handleChange = (e) => { handleChange = (e) => {
if (!e.target.value.trim()) { if (!e.target.value.trim()) {
this.setState({isSubmitBtnActive: false}); this.setState({isSubmitBtnActive: false});