mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-05 17:02:47 +00:00
Merge branch '9.0'
This commit is contained in:
@@ -122,7 +122,7 @@ class Account extends Component {
|
||||
};
|
||||
} else if (isOrgStaff) {
|
||||
data = {
|
||||
url: `${siteRoot}org/useradmin/`,
|
||||
url: `${siteRoot}org/info/`,
|
||||
text: gettext('Organization Admin')
|
||||
};
|
||||
} else if (isInstAdmin) {
|
||||
|
@@ -157,6 +157,12 @@ class CustomPermissionEditor extends React.Component {
|
||||
<span>{gettext('Download')}</span>
|
||||
</Label>
|
||||
</FormGroup>
|
||||
<FormGroup check>
|
||||
<Label check>
|
||||
<Input type="checkbox" onChange={this.onChangePermission('create')} checked={permission.create}/>
|
||||
<span>{gettext('Create')}</span>
|
||||
</Label>
|
||||
</FormGroup>
|
||||
<FormGroup check>
|
||||
<Label check>
|
||||
<Input type="checkbox" onChange={this.onChangePermission('modify')} checked={permission.modify}/>
|
||||
@@ -168,7 +174,7 @@ class CustomPermissionEditor extends React.Component {
|
||||
target={'modify-tip'}
|
||||
placement='bottom'
|
||||
isOpen={this.state.tooltipOpen}>
|
||||
({gettext('Modify includes modify file, create file and folder, move/rename file and folder')})
|
||||
({gettext('Modify includes modify file, move/rename file and folder')})
|
||||
</Tooltip>
|
||||
</Label>
|
||||
</FormGroup>
|
||||
|
67
frontend/src/components/dialog/org-import-users-dialog.js
Normal file
67
frontend/src/components/dialog/org-import-users-dialog.js
Normal file
@@ -0,0 +1,67 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Alert, Modal, ModalHeader, ModalBody, ModalFooter, Button } from 'reactstrap';
|
||||
import { gettext, siteRoot } from '../../utils/constants';
|
||||
|
||||
const propTypes = {
|
||||
toggle: PropTypes.func.isRequired,
|
||||
importUsersInBatch: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
class ImportOrgUsersDialog extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.fileInputRef = React.createRef();
|
||||
this.state = {
|
||||
errorMsg: ''
|
||||
};
|
||||
}
|
||||
|
||||
toggle = () => {
|
||||
this.props.toggle();
|
||||
}
|
||||
|
||||
openFileInput = () => {
|
||||
this.fileInputRef.current.click();
|
||||
}
|
||||
|
||||
uploadFile = (e) => {
|
||||
// no file selected
|
||||
if (!this.fileInputRef.current.files.length) {
|
||||
return;
|
||||
}
|
||||
// check file extension
|
||||
let fileName = this.fileInputRef.current.files[0].name;
|
||||
if(fileName.substr(fileName.lastIndexOf('.') + 1) != 'xlsx') {
|
||||
this.setState({
|
||||
errorMsg: gettext('Please choose a .xlsx file.')
|
||||
});
|
||||
return;
|
||||
}
|
||||
const file = this.fileInputRef.current.files[0];
|
||||
this.props.importUsersInBatch(file);
|
||||
this.toggle();
|
||||
}
|
||||
|
||||
render() {
|
||||
let { errorMsg } = this.state;
|
||||
return (
|
||||
<Modal isOpen={true} toggle={this.toggle}>
|
||||
<ModalHeader toggle={this.toggle}>{gettext('Import users from a .xlsx file')}</ModalHeader>
|
||||
<ModalBody>
|
||||
<p><a className="text-secondary small" href={`${siteRoot}useradmin/batchadduser/example/`}>{gettext('Download an example file')}</a></p>
|
||||
<button className="btn btn-outline-primary" onClick={this.openFileInput}>{gettext('Upload file')}</button>
|
||||
<input className="d-none" type="file" onChange={this.uploadFile} ref={this.fileInputRef} />
|
||||
{errorMsg && <Alert color="danger">{errorMsg}</Alert>}
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button color="secondary" onClick={this.toggle}>{gettext('Cancel')}</Button>
|
||||
</ModalFooter>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
ImportOrgUsersDialog.propTypes = propTypes;
|
||||
|
||||
export default ImportOrgUsersDialog;
|
@@ -332,11 +332,11 @@ class DirentListView extends React.Component {
|
||||
|
||||
if (this.props.selectedDirentList.length === 0) {
|
||||
let id = 'dirent-container-menu';
|
||||
|
||||
|
||||
// custom permission judgement
|
||||
if (isCustomPermission) {
|
||||
const { modify } = customPermission.permission;
|
||||
if (!modify) return;
|
||||
const { create: canCreate } = customPermission.permission;
|
||||
if (!canCreate) return;
|
||||
}
|
||||
|
||||
let menuList = [TextTranslation.NEW_FOLDER, TextTranslation.NEW_FILE];
|
||||
|
@@ -168,11 +168,11 @@ class DirOperationToolbar extends React.Component {
|
||||
|
||||
const { isCustomPermission, customPermission } = Utils.getUserPermission(userPerm);
|
||||
let canUpload = true;
|
||||
let canModify = true;
|
||||
let canCreate = true;
|
||||
if (isCustomPermission) {
|
||||
const { permission } = customPermission;
|
||||
canUpload = permission.upload;
|
||||
canModify = permission.modify;
|
||||
canCreate = permission.create;
|
||||
}
|
||||
|
||||
let content = null;
|
||||
@@ -196,7 +196,7 @@ class DirOperationToolbar extends React.Component {
|
||||
<button className="btn btn-secondary operation-item" title={gettext('Upload')} onClick={this.onUploadFile}>{gettext('Upload')}</button>}
|
||||
</Fragment>
|
||||
)}
|
||||
{canModify &&
|
||||
{canCreate &&
|
||||
<Fragment>
|
||||
<button className="btn btn-secondary operation-item" onClick={this.onCreateClick} aria-haspopup="true" aria-expanded={this.state.isUploadMenuShow} aria-controls="new-menu">{gettext('New')}</button>
|
||||
{this.state.isCreateMenuShow && (
|
||||
@@ -223,7 +223,7 @@ class DirOperationToolbar extends React.Component {
|
||||
{canUpload && (
|
||||
<DropdownItem onClick={this.onUploadFile}>{gettext('Upload')}</DropdownItem>
|
||||
)}
|
||||
{canModify && (
|
||||
{canCreate && (
|
||||
<Fragment>
|
||||
<DropdownItem onClick={this.onCreateFolderToggle}>{gettext('New Folder')}</DropdownItem>
|
||||
<DropdownItem onClick={this.onCreateFileToggle}>{gettext('New File')}</DropdownItem>
|
||||
|
@@ -207,7 +207,7 @@ class TreeNodeView extends React.Component {
|
||||
|
||||
let menuList = [RENAME, DELETE, COPY, MOVE, OPEN_VIA_CLIENT];
|
||||
if (node.object.type === 'dir') {
|
||||
menuList = [NEW_FOLDER, NEW_FILE, COPY, MOVE, RENAME, DELETE];
|
||||
menuList = [NEW_FOLDER, NEW_FILE, COPY, MOVE, RENAME, DELETE];
|
||||
}
|
||||
|
||||
const { userPerm } = this.props;
|
||||
@@ -217,11 +217,11 @@ class TreeNodeView extends React.Component {
|
||||
}
|
||||
|
||||
menuList = [];
|
||||
const { modify: canModify, delete: canDelete, copy: canCopy } = customPermission.permission;
|
||||
if (node.object.type === 'dir') {
|
||||
canModify && menuList.push(NEW_FOLDER, NEW_FILE);
|
||||
const { create: canCreate, modify: canModify, delete: canDelete, copy: canCopy } = customPermission.permission;
|
||||
if (node.object.type === 'dir') {
|
||||
canCreate && menuList.push(NEW_FOLDER, NEW_FILE);
|
||||
}
|
||||
|
||||
|
||||
canCopy && menuList.push(COPY);
|
||||
canModify && menuList.push(MOVE, RENAME);
|
||||
canDelete && menuList.push(DELETE);
|
||||
|
@@ -270,16 +270,16 @@ class TreeView extends React.Component {
|
||||
|
||||
menuList = [];
|
||||
|
||||
const { modify: canModify, delete: canDelete, copy: canCopy } = customPermission.permission;
|
||||
const { create: canCreate, modify: canModify, delete: canDelete, copy: canCopy } = customPermission.permission;
|
||||
if (!node) {
|
||||
canModify && menuList.push(NEW_FOLDER, NEW_FILE);
|
||||
canCreate && menuList.push(NEW_FOLDER, NEW_FILE);
|
||||
return menuList;
|
||||
}
|
||||
|
||||
if (node.object.type === 'dir') {
|
||||
canModify && menuList.push(NEW_FOLDER, NEW_FILE);
|
||||
if (node.object.type === 'dir') {
|
||||
canCreate && menuList.push(NEW_FOLDER, NEW_FILE);
|
||||
}
|
||||
|
||||
|
||||
canCopy && menuList.push(COPY);
|
||||
canModify && menuList.push(MOVE, RENAME);
|
||||
canDelete && menuList.push(DELETE);
|
||||
|
Reference in New Issue
Block a user