mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-09 10:50:24 +00:00
[publish a library] improved optional library list (#4591)
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { gettext, siteRoot } from '../../utils/constants';
|
import { gettext } 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';
|
||||||
@@ -9,7 +9,7 @@ import { Utils } from '../../utils/utils';
|
|||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
toggleCancel: PropTypes.func.isRequired,
|
toggleCancel: PropTypes.func.isRequired,
|
||||||
addWiki: PropTypes.func.isRequired,
|
addWiki: PropTypes.func.isRequired
|
||||||
};
|
};
|
||||||
|
|
||||||
class WikiSelectDialog extends React.Component {
|
class WikiSelectDialog extends React.Component {
|
||||||
@@ -24,7 +24,23 @@ class WikiSelectDialog extends React.Component {
|
|||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
seafileAPI.listRepos().then(res => {
|
seafileAPI.listRepos().then(res => {
|
||||||
let repoList = res.data.repos.map(item => {
|
let repoList = res.data.repos
|
||||||
|
.filter(item => {
|
||||||
|
switch (item.type) {
|
||||||
|
case 'mine': // my libraries
|
||||||
|
return !item.encrypted;
|
||||||
|
case 'shared': // libraries shared with me
|
||||||
|
// 'is_admin': the library is shared with 'admin' permission
|
||||||
|
return !item.encrypted && item.is_admin;
|
||||||
|
case 'group':
|
||||||
|
default:
|
||||||
|
return !item.encrypted && !res.data.repos.some(repo => {
|
||||||
|
// just remove the duplicated libraries
|
||||||
|
return repo.type != item.type && repo.repo_id == item.repo_id;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.map(item => {
|
||||||
let repo = new Repo(item);
|
let repo = new Repo(item);
|
||||||
return repo;
|
return repo;
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user