1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-04 08:28:11 +00:00

fix list wiki department permission (#6301)

This commit is contained in:
Michael An
2024-07-05 15:30:12 +08:00
committed by GitHub
parent 9916ac43e1
commit 6e45dfba13
3 changed files with 29 additions and 16 deletions

View File

@@ -1,12 +1,14 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { Button, Modal, ModalHeader, ModalBody, ModalFooter, Input, Label } from 'reactstrap'; 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 wikiAPI from '../../utils/wiki-api';
import { Utils } from '../../utils/utils'; import { Utils } from '../../utils/utils';
import toaster from '../toast'; import toaster from '../toast';
import { SeahubSelect } from '../common/select'; import { SeahubSelect } from '../common/select';
const { multiTenancy, cloudMode } = window.app.pageOptions;
const propTypes = { const propTypes = {
toggleCancel: PropTypes.func.isRequired, toggleCancel: PropTypes.func.isRequired,
addWiki: PropTypes.func.isRequired, addWiki: PropTypes.func.isRequired,
@@ -23,9 +25,11 @@ class AddWikiDialog extends React.Component {
selectedOption: null, selectedOption: null,
options: [], options: [],
}; };
this.isDepartment = isPro && multiTenancy && cloudMode;
} }
componentDidMount() { componentDidMount() {
if (!this.isDepartment) return;
wikiAPI.listWikiDepartments().then(res => { wikiAPI.listWikiDepartments().then(res => {
const departments = res.data.sort((a, b) => { const departments = res.data.sort((a, b) => {
return a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1; return a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1;
@@ -84,6 +88,8 @@ class AddWikiDialog extends React.Component {
<ModalBody> <ModalBody>
<Label>{gettext('Name')}</Label> <Label>{gettext('Name')}</Label>
<Input onKeyDown={this.handleKeyDown} autoFocus={true} value={this.state.name} onChange={this.inputNewName}/> <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> <Label className='mt-4'>{gettext('Wiki owner')} ({gettext('Optional')})</Label>
<SeahubSelect <SeahubSelect
onChange={this.handleSelectChange} onChange={this.handleSelectChange}
@@ -97,6 +103,8 @@ class AddWikiDialog extends React.Component {
) }} ) }}
noOptionsMessage={() => {return gettext('No options available');}} noOptionsMessage={() => {return gettext('No options available');}}
/> />
</>
}
</ModalBody> </ModalBody>
<ModalFooter> <ModalFooter>
<Button color="secondary" onClick={this.toggle}>{gettext('Cancel')}</Button> <Button color="secondary" onClick={this.toggle}>{gettext('Cancel')}</Button>

View File

@@ -1,6 +1,6 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import PropTypes from 'prop-types'; 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 WikiCardGroup from './wiki-card-group';
import wikiAPI from '../../utils/wiki-api'; import wikiAPI from '../../utils/wiki-api';
import { Utils } from '../../utils/utils'; import { Utils } from '../../utils/utils';
@@ -8,6 +8,8 @@ import toaster from '../toast';
import './wiki-card-view.css'; import './wiki-card-view.css';
const { multiTenancy, cloudMode } = window.app.pageOptions;
const propTypes = { const propTypes = {
data: PropTypes.object.isRequired, data: PropTypes.object.isRequired,
deleteWiki: PropTypes.func.isRequired, deleteWiki: PropTypes.func.isRequired,
@@ -22,10 +24,11 @@ class WikiCardView extends Component {
this.state = { this.state = {
departmentMap: {}, departmentMap: {},
}; };
this.isDepartment = isPro && multiTenancy && cloudMode;
} }
componentDidMount() { componentDidMount() {
if (!canPublishRepo) return; if (!canPublishRepo || !this.isDepartment) return;
let departmentMap = {}; let departmentMap = {};
wikiAPI.listWikiDepartments().then(res => { wikiAPI.listWikiDepartments().then(res => {
res.data.forEach(item => departmentMap[item.id] = true); res.data.forEach(item => departmentMap[item.id] = true);

View File

@@ -67,6 +67,8 @@
canAddRepo: {% if user.permissions.can_add_repo %} true {% else %} false {% endif %}, canAddRepo: {% if user.permissions.can_add_repo %} true {% else %} false {% endif %},
canShareRepo: {% if user.permissions.can_share_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 %}, 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}}", groupImportMembersExtraMsg: "{{group_import_members_extra_msg}}",
canGenerateShareLink: {% if user.permissions.can_generate_share_link %} true {% else %} false {% endif %}, canGenerateShareLink: {% if user.permissions.can_generate_share_link %} true {% else %} false {% endif %},
canGenerateUploadLink: {% if user.permissions.can_generate_upload_link %} true {% else %} false {% endif %}, canGenerateUploadLink: {% if user.permissions.can_generate_upload_link %} true {% else %} false {% endif %},