1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-04 16:31:13 +00:00

improve repo-model define, order repo list to show (#2820)

This commit is contained in:
杨顺强
2019-01-13 21:11:13 +08:00
committed by Daniel Pan
parent 1900993ea2
commit 18ff433546
2 changed files with 10 additions and 6 deletions

View File

@@ -4,6 +4,8 @@ import { gettext, siteRoot } from '../../utils/constants';
import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap'; import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
import { seafileAPI } from '../../utils/seafile-api'; import { seafileAPI } from '../../utils/seafile-api';
import moment from 'moment'; import moment from 'moment';
import Repo from '../../models/repo';
import { Utils } from '../../utils/utils';
const propTypes = { const propTypes = {
toggleCancel: PropTypes.func.isRequired, toggleCancel: PropTypes.func.isRequired,
@@ -24,9 +26,12 @@ class WikiSelectDialog extends React.Component {
componentDidMount() { componentDidMount() {
seafileAPI.listRepos().then(res => { seafileAPI.listRepos().then(res => {
this.setState({ let repoList = res.data.repos.map(item => {
repos: res.data.repos, let repo = new Repo(item);
}); return repo;
});
repoList = Utils.sortRepos(repoList, 'name', 'asc');
this.setState({repos: repoList});
}); });
} }
@@ -66,7 +71,7 @@ class WikiSelectDialog extends React.Component {
return ( return (
<tr key={index}> <tr key={index}>
<td className="text-center"><input type="radio" className="vam" name="repo" value={repo.repo_id} onChange={this.onChange.bind(this, repo)} /></td> <td className="text-center"><input type="radio" className="vam" name="repo" value={repo.repo_id} onChange={this.onChange.bind(this, repo)} /></td>
<td className="text-center"><img src={siteRoot + 'media/img/lib/48/lib.png'} alt={gettext('icon')} /></td> <td className="text-center"><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>

View File

@@ -9,13 +9,12 @@ class Repo {
this.owner_name = object.owner_name; this.owner_name = object.owner_name;
this.owner_email = object.owner_email; this.owner_email = object.owner_email;
this.owner_contact_email = object.owner_contact_email; this.owner_contact_email = object.owner_contact_email;
this.is_admin = object.is_admin;
this.encrypted = object.encrypted; this.encrypted = object.encrypted;
this.last_modified = object.last_modified; this.last_modified = object.last_modified;
this.modifier_contact_email = object.modifier_contact_email; this.modifier_contact_email = object.modifier_contact_email;
this.modifier_email = object.modifier_email; this.modifier_email = object.modifier_email;
this.modifier_name = object.modifier_name; this.modifier_name = object.modifier_name;
this.mtime = object.mtime; this.type = object.type;
} }
} }