mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-03 16:10:26 +00:00
fix list wiki department permission (#6301)
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Button, Modal, ModalHeader, ModalBody, ModalFooter, Input, Label } from 'reactstrap';
|
||||
import { gettext } from '../../utils/constants';
|
||||
import { gettext, isPro } from '../../utils/constants';
|
||||
import wikiAPI from '../../utils/wiki-api';
|
||||
import { Utils } from '../../utils/utils';
|
||||
import toaster from '../toast';
|
||||
import { SeahubSelect } from '../common/select';
|
||||
|
||||
const { multiTenancy, cloudMode } = window.app.pageOptions;
|
||||
|
||||
const propTypes = {
|
||||
toggleCancel: PropTypes.func.isRequired,
|
||||
addWiki: PropTypes.func.isRequired,
|
||||
@@ -23,9 +25,11 @@ class AddWikiDialog extends React.Component {
|
||||
selectedOption: null,
|
||||
options: [],
|
||||
};
|
||||
this.isDepartment = isPro && multiTenancy && cloudMode;
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
if (!this.isDepartment) return;
|
||||
wikiAPI.listWikiDepartments().then(res => {
|
||||
const departments = res.data.sort((a, b) => {
|
||||
return a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1;
|
||||
@@ -84,6 +88,8 @@ class AddWikiDialog extends React.Component {
|
||||
<ModalBody>
|
||||
<Label>{gettext('Name')}</Label>
|
||||
<Input onKeyDown={this.handleKeyDown} autoFocus={true} value={this.state.name} onChange={this.inputNewName}/>
|
||||
{this.isDepartment &&
|
||||
<>
|
||||
<Label className='mt-4'>{gettext('Wiki owner')} ({gettext('Optional')})</Label>
|
||||
<SeahubSelect
|
||||
onChange={this.handleSelectChange}
|
||||
@@ -97,6 +103,8 @@ class AddWikiDialog extends React.Component {
|
||||
) }}
|
||||
noOptionsMessage={() => {return gettext('No options available');}}
|
||||
/>
|
||||
</>
|
||||
}
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button color="secondary" onClick={this.toggle}>{gettext('Cancel')}</Button>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { gettext, username, canPublishRepo } from '../../utils/constants';
|
||||
import { gettext, username, canPublishRepo, isPro } from '../../utils/constants';
|
||||
import WikiCardGroup from './wiki-card-group';
|
||||
import wikiAPI from '../../utils/wiki-api';
|
||||
import { Utils } from '../../utils/utils';
|
||||
@@ -8,6 +8,8 @@ import toaster from '../toast';
|
||||
|
||||
import './wiki-card-view.css';
|
||||
|
||||
const { multiTenancy, cloudMode } = window.app.pageOptions;
|
||||
|
||||
const propTypes = {
|
||||
data: PropTypes.object.isRequired,
|
||||
deleteWiki: PropTypes.func.isRequired,
|
||||
@@ -22,10 +24,11 @@ class WikiCardView extends Component {
|
||||
this.state = {
|
||||
departmentMap: {},
|
||||
};
|
||||
this.isDepartment = isPro && multiTenancy && cloudMode;
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
if (!canPublishRepo) return;
|
||||
if (!canPublishRepo || !this.isDepartment) return;
|
||||
let departmentMap = {};
|
||||
wikiAPI.listWikiDepartments().then(res => {
|
||||
res.data.forEach(item => departmentMap[item.id] = true);
|
||||
|
@@ -67,6 +67,8 @@
|
||||
canAddRepo: {% if user.permissions.can_add_repo %} true {% else %} false {% endif %},
|
||||
canShareRepo: {% if user.permissions.can_share_repo %} true {% else %} false {% endif %},
|
||||
canAddGroup: {% if user.permissions.can_add_group %} true {% else %} false {% endif %},
|
||||
multiTenancy: {% if multi_tenancy %} true {% else %} false {% endif %},
|
||||
cloudMode: {% if cloud_mode %} true {% else %} false {% endif %},
|
||||
groupImportMembersExtraMsg: "{{group_import_members_extra_msg}}",
|
||||
canGenerateShareLink: {% if user.permissions.can_generate_share_link %} true {% else %} false {% endif %},
|
||||
canGenerateUploadLink: {% if user.permissions.can_generate_upload_link %} true {% else %} false {% endif %},
|
||||
|
Reference in New Issue
Block a user