1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-26 07:22:34 +00:00

Wiki bug repair (#2492)

This commit is contained in:
杨顺强
2018-11-01 18:40:18 +08:00
committed by Daniel Pan
parent 4cc735cf1f
commit c93e8aa603
10 changed files with 60 additions and 28 deletions

View File

@@ -1,14 +1,14 @@
import React from 'react';
import PropTypes from 'prop-types';
import { seafileAPI } from '../../utils/seafile-api';
import { repoID, isPro, enableFileComment, fileAuditEnabled, folderPermEnabled} from '../../utils/constants';
import Repo from '../../models/repo';
import { isPro, enableFileComment, fileAuditEnabled, folderPermEnabled} from '../../utils/constants';
import DirentMenuItem from './dirent-menu-item';
const propTypes = {
dirent: PropTypes.object.isRequired,
menuPosition: PropTypes.object.isRequired,
onMenuItemClick: PropTypes.func.isRequired,
currentRepo: PropTypes.object.isRequired,
isRepoOwner: PropTypes.bool.isRequired,
};
class DirentMenu extends React.Component {
@@ -16,32 +16,25 @@ class DirentMenu extends React.Component {
constructor(props) {
super(props);
this.state = {
repo: null,
menuList: [],
};
this.is_repo_owner = false;
}
componentDidMount() {
seafileAPI.getRepoInfo(repoID).then(res => {
let repo = new Repo(res.data);
seafileAPI.getAccountInfo().then(res => {
let user_email = res.data.email;
this.is_repo_owner = repo.owner_email === user_email;
let menuList = this.calculateMenuList(repo);
this.setState({
repo: repo,
menuList: menuList
});
});
let repo = this.props.currentRepo;
let menuList = this.calculateMenuList(repo);
this.setState({
menuList: menuList
});
}
calculateMenuList(repoInfo) {
let dirent = this.props.dirent;
let isRepoOwner = this.props.isRepoOwner;
let type = dirent.type;
let permission = dirent.permission;
let can_set_folder_perm = folderPermEnabled && ((this.is_repo_owner && repoInfo.has_been_shared_out) || repoInfo.is_admin);
let can_set_folder_perm = folderPermEnabled && ((isRepoOwner && repoInfo.has_been_shared_out) || repoInfo.is_admin);
if (type === 'dir' && permission === 'rw') {
let menuList = [];
if (can_set_folder_perm) {