mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-02 15:38:15 +00:00
Update wiki (#2313)
* [wiki] show all files * [wiki]update choose repo as wiki
This commit is contained in:
@@ -100,8 +100,6 @@ class TreeNodeView extends React.Component {
|
||||
paddingLeft: this.props.paddingLeft
|
||||
};
|
||||
var l = node.children.sort(sortByType);
|
||||
l = l.filter((node) => { return node.type == "dir" || node.isMarkdown(); })
|
||||
|
||||
/*
|
||||
the `key` property is needed. Otherwise there is a warning in the console
|
||||
*/
|
||||
|
@@ -122,6 +122,10 @@ class Wiki extends Component {
|
||||
onFileClick = (e, node) => {
|
||||
if (node.isMarkdown()) {
|
||||
this.loadFile(node.path);
|
||||
} else {
|
||||
const w=window.open('about:blank');
|
||||
const url = serviceUrl + '/lib/' + repoID + '/file' + node.path;
|
||||
w.location.href = url;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -22,6 +22,7 @@ from seahub.wiki.models import Wiki, DuplicateWikiNameError
|
||||
from seahub.wiki.utils import is_valid_wiki_name, slugfy_wiki_name
|
||||
from seahub.utils import is_org_context, get_user_repos
|
||||
from seahub.views import check_folder_permission
|
||||
from seahub.share.utils import is_repo_admin
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -126,10 +127,18 @@ class WikisView(APIView):
|
||||
return api_error(status.HTTP_400_BAD_REQUEST, msg)
|
||||
|
||||
repo = seafile_api.get_repo(repo_id)
|
||||
if not repo:
|
||||
error_msg = 'Library %s not found.' % repo_id
|
||||
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
|
||||
|
||||
if check_folder_permission(request, repo_id, '/') != 'rw':
|
||||
is_owner = seafile_api.is_repo_owner(username, repo_id)
|
||||
is_admin = is_repo_admin(username, repo_id)
|
||||
|
||||
if not is_owner:
|
||||
if not is_admin:
|
||||
error_msg = _('Permission denied.')
|
||||
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
|
||||
|
||||
try:
|
||||
wiki = Wiki.objects.add(wiki_name=repo.repo_name, username=username,
|
||||
repo_id=repo.repo_id, org_id=org_id)
|
||||
|
@@ -464,12 +464,17 @@ var NewWikiController = {
|
||||
clickToNewWikiByOwnlib: function(event) {
|
||||
var _this = this;
|
||||
$.ajax({
|
||||
url: "{{SITE_ROOT}}api2/repos/?type=mine",
|
||||
url: "{{SITE_ROOT}}api2/repos/",
|
||||
cache: false,
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
if (data && data.length) {
|
||||
_this.chooseEl.append($(_this.chooseWikiTmpl(data)));
|
||||
var repos = data.filter(function(i) {
|
||||
return i['encrypted'] !== true;
|
||||
}
|
||||
)
|
||||
|
||||
if (repos && repos.length) {
|
||||
_this.chooseEl.append($(_this.chooseWikiTmpl(repos)));
|
||||
$('#new-wiki-by-existing-form').modal();
|
||||
$('#simplemodal-container').css({'width':'auto', 'height':'auto'})
|
||||
}
|
||||
|
Reference in New Issue
Block a user