mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-04 00:20:07 +00:00
optimized code style
This commit is contained in:
@@ -14,8 +14,8 @@ class NewWikiDialog extends React.Component {
|
||||
super(props);
|
||||
this.state = {
|
||||
isExist: false,
|
||||
name: "",
|
||||
repoID: "",
|
||||
name: '',
|
||||
repoID: '',
|
||||
};
|
||||
this.newName = React.createRef();
|
||||
}
|
||||
@@ -53,7 +53,7 @@ class NewWikiDialog extends React.Component {
|
||||
<ModalHeader toggle={this.toggle}>{gettext('New Wiki')}</ModalHeader>
|
||||
<ModalBody>
|
||||
<label className="form-label">{gettext('Name')}</label>
|
||||
<Input onKeyPress={this.handleKeyPress} innerRef={input => {this.newName = input}} value={this.state.name} onChange={this.inputNewName}/>
|
||||
<Input onKeyPress={this.handleKeyPress} innerRef={input => {this.newName = input;}} value={this.state.name} onChange={this.inputNewName}/>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button color="secondary" onClick={this.toggle}>{gettext('Cancel')}</Button>
|
||||
|
@@ -17,9 +17,9 @@ class WikiSelectDialog extends React.Component {
|
||||
this.state = {
|
||||
repos: [],
|
||||
isExist: true,
|
||||
name: "",
|
||||
repoID: "",
|
||||
}
|
||||
name: '',
|
||||
repoID: '',
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
@@ -27,7 +27,7 @@ class WikiSelectDialog extends React.Component {
|
||||
this.setState({
|
||||
repos: res.data.repos,
|
||||
});
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
onChange = (repo) => {
|
||||
@@ -66,7 +66,7 @@ class WikiSelectDialog extends React.Component {
|
||||
return (
|
||||
<tr key={index}>
|
||||
<td className="select"><input type="radio" className="vam" name="repo" value={repo.repo_id} onChange={this.onChange.bind(this, repo)} /></td>
|
||||
<td><img src={siteRoot + 'media/img/lib/48/lib.png'} width="24" /></td>
|
||||
<td><img src={siteRoot + 'media/img/lib/48/lib.png'} width="24" alt={gettext('icon')} /></td>
|
||||
<td>{gettext(repo.repo_name)}</td>
|
||||
<td>{moment(repo.last_modified).fromNow()}</td>
|
||||
</tr>
|
||||
|
@@ -15,7 +15,7 @@ class WikiListView extends Component {
|
||||
super(props);
|
||||
this.state = {
|
||||
isItemFreezed: false,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
onFreezedItem = () => {
|
||||
@@ -27,7 +27,7 @@ class WikiListView extends Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
let {loading, errorMsg, wikis} = this.props.data;
|
||||
let { loading, errorMsg, wikis } = this.props.data;
|
||||
|
||||
if (loading) {
|
||||
return <span className="loading-icon loading-tip"></span>;
|
||||
|
@@ -1,5 +1,4 @@
|
||||
import React, { Component, Fragment } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Dropdown, DropdownToggle, DropdownMenu, DropdownItem } from 'reactstrap';
|
||||
import { seafileAPI } from '../../utils/seafile-api';
|
||||
import { gettext, loginUrl } from '../../utils/constants';
|
||||
@@ -17,8 +16,7 @@ class Wikis extends Component {
|
||||
loading: true,
|
||||
errorMsg: '',
|
||||
wikis: [],
|
||||
isShowWikiAdd: false,
|
||||
position: {top:'', left: ''},
|
||||
isShowAddWikiMenu: false,
|
||||
isShowSelectDialog: false,
|
||||
isShowCreateDialog: false,
|
||||
};
|
||||
@@ -63,27 +61,21 @@ class Wikis extends Component {
|
||||
}
|
||||
|
||||
onMenuToggle = () => {
|
||||
this.setState({isShowWikiAdd: !this.state.isShowWikiAdd})
|
||||
this.setState({isShowAddWikiMenu: !this.state.isShowAddWikiMenu});
|
||||
}
|
||||
|
||||
onSelectToggle = () => {
|
||||
this.setState({
|
||||
isShowSelectDialog: !this.state.isShowSelectDialog,
|
||||
});
|
||||
this.setState({isShowSelectDialog: !this.state.isShowSelectDialog});
|
||||
}
|
||||
|
||||
onCreateToggle = () => {
|
||||
this.setState({
|
||||
isShowCreateDialog: !this.state.isShowCreateDialog,
|
||||
});
|
||||
this.setState({isShowCreateDialog: !this.state.isShowCreateDialog});
|
||||
}
|
||||
|
||||
addWiki = (isExist, name, repoID) => {
|
||||
seafileAPI.addWiki(isExist, name, repoID).then((res) => {
|
||||
this.state.wikis.push(res.data);
|
||||
this.setState({
|
||||
wikis: this.state.wikis
|
||||
});
|
||||
this.setState({wikis: this.state.wikis});
|
||||
}).catch((error) => {
|
||||
if(error.response) {
|
||||
let errorMsg = error.response.data.error_msg;
|
||||
@@ -133,13 +125,13 @@ class Wikis extends Component {
|
||||
<h3 className="sf-heading">{gettext('Wikis')}</h3>
|
||||
</div>
|
||||
<div className="path-toolbar">
|
||||
<Dropdown tag="div" className="btn btn-secondary operation-item" style={{marginTop: '-0.25rem'}} isOpen={this.state.isShowWikiAdd} toggle={this.onMenuToggle}>
|
||||
<Dropdown tag="div" className="btn btn-secondary operation-item" style={{marginTop: '-0.25rem'}} isOpen={this.state.isShowAddWikiMenu} toggle={this.onMenuToggle}>
|
||||
<DropdownToggle
|
||||
tag="i"
|
||||
className="fa fa-plus-square op-icon"
|
||||
title={gettext('More Operations')}
|
||||
data-toggle="dropdown"
|
||||
aria-expanded={this.state.isShowWikiAdd}
|
||||
aria-expanded={this.state.isShowAddWikiMenu}
|
||||
onClick={this.clickMenuToggle}
|
||||
>
|
||||
{gettext(' Add Wiki')}
|
||||
@@ -168,22 +160,22 @@ class Wikis extends Component {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{this.state.isShowCreateDialog &&
|
||||
{this.state.isShowCreateDialog && (
|
||||
<ModalPortal>
|
||||
<NewWikiDialog
|
||||
toggleCancel={this.onCreateToggle}
|
||||
addWiki={this.addWiki}
|
||||
/>
|
||||
</ModalPortal>
|
||||
}
|
||||
{this.state.isShowSelectDialog &&
|
||||
)}
|
||||
{this.state.isShowSelectDialog && (
|
||||
<ModalPortal>
|
||||
<WikiSelectDialog
|
||||
toggleCancel={this.onSelectToggle}
|
||||
addWiki={this.addWiki}
|
||||
/>
|
||||
</ModalPortal>
|
||||
}
|
||||
)}
|
||||
</Fragment>
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user