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