mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-04 16:31:13 +00:00
fix list wiki department permission (#6301)
This commit is contained in:
@@ -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,19 +88,23 @@ 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}/>
|
||||||
<Label className='mt-4'>{gettext('Wiki owner')} ({gettext('Optional')})</Label>
|
{this.isDepartment &&
|
||||||
<SeahubSelect
|
<>
|
||||||
onChange={this.handleSelectChange}
|
<Label className='mt-4'>{gettext('Wiki owner')} ({gettext('Optional')})</Label>
|
||||||
options={this.state.options}
|
<SeahubSelect
|
||||||
hideSelectedOptions={true}
|
onChange={this.handleSelectChange}
|
||||||
placeholder={gettext('Select a department')}
|
options={this.state.options}
|
||||||
maxMenuHeight={200}
|
hideSelectedOptions={true}
|
||||||
value={this.state.selectedOption}
|
placeholder={gettext('Select a department')}
|
||||||
components={{ NoOptionsMessage: (
|
maxMenuHeight={200}
|
||||||
<div style={{margin: '6px 10px', textAlign: 'center', color: 'hsl(0,0%,50%)'}}>{gettext('No department')}</div>
|
value={this.state.selectedOption}
|
||||||
) }}
|
components={{ NoOptionsMessage: (
|
||||||
noOptionsMessage={() => {return gettext('No options available');}}
|
<div style={{margin: '6px 10px', textAlign: 'center', color: 'hsl(0,0%,50%)'}}>{gettext('No department')}</div>
|
||||||
/>
|
) }}
|
||||||
|
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>
|
||||||
|
@@ -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);
|
||||||
|
@@ -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 %},
|
||||||
|
Reference in New Issue
Block a user