mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-20 10:58:33 +00:00
Merge branch '7.0'
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import Select from 'react-select';
|
||||
import { Button, Modal, ModalHeader, Input, ModalBody, ModalFooter, Form, FormGroup, Label, Alert } from 'reactstrap';
|
||||
import { gettext, enableEncryptedLibrary, repoPasswordMinLength } from '../../utils/constants';
|
||||
import { gettext, enableEncryptedLibrary, repoPasswordMinLength, storages } from '../../utils/constants';
|
||||
|
||||
const propTypes = {
|
||||
libraryType: PropTypes.string.isRequired,
|
||||
@@ -20,6 +21,7 @@ class CreateRepoDialog extends React.Component {
|
||||
password2: '',
|
||||
errMessage: '',
|
||||
permission: 'rw',
|
||||
storage_id: storages.length ? storages[0].id : '',
|
||||
isSubmitBtnActive: false,
|
||||
};
|
||||
this.newInput = React.createRef();
|
||||
@@ -44,17 +46,14 @@ class CreateRepoDialog extends React.Component {
|
||||
}
|
||||
|
||||
handleSubmit = () => {
|
||||
let isValid= this.validateInputParams();
|
||||
let isValid = this.validateInputParams();
|
||||
if (isValid) {
|
||||
let repoName = this.state.repoName.trim();
|
||||
let password = this.state.encrypt ? this.state.password1 : '';
|
||||
let permission= this.state.permission;
|
||||
let repo = this.createRepo(repoName, password, permission);
|
||||
let repoData = this.prepareRepoData();
|
||||
if (this.props.libraryType === 'department') {
|
||||
this.props.onCreateRepo(repo, 'department');
|
||||
this.props.onCreateRepo(repoData, 'department');
|
||||
return;
|
||||
}
|
||||
this.props.onCreateRepo(repo);
|
||||
this.props.onCreateRepo(repoData);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,6 +117,10 @@ class CreateRepoDialog extends React.Component {
|
||||
this.setState({permission: permission});
|
||||
}
|
||||
|
||||
handleStorageInputChange = (selectedItem) => {
|
||||
this.setState({storage_id: selectedItem.value});
|
||||
}
|
||||
|
||||
onEncrypted = (e) => {
|
||||
let isChecked = e.target.checked;
|
||||
this.setState({
|
||||
@@ -126,25 +129,18 @@ class CreateRepoDialog extends React.Component {
|
||||
});
|
||||
}
|
||||
|
||||
createRepo = (repoName, password, permission) => {
|
||||
prepareRepoData = () => {
|
||||
let libraryType = this.props.libraryType;
|
||||
let encrypt = password ? true : false;
|
||||
|
||||
let repoName = this.state.repoName.trim();
|
||||
let password = this.state.encrypt ? this.state.password1 : '';
|
||||
let permission = this.state.permission;
|
||||
|
||||
let repo = null;
|
||||
if (libraryType === 'mine' || libraryType === 'public') {
|
||||
repo = {
|
||||
id: null,
|
||||
name: repoName,
|
||||
desc: '',
|
||||
encrypted: encrypt,
|
||||
passwd: password,
|
||||
passwd1: password,
|
||||
passwd2: password,
|
||||
mtime: 0,
|
||||
mtime_relative: '',
|
||||
owner: '-',
|
||||
owner_nickname: '-',
|
||||
permission: 'rw',
|
||||
storage_name: '-',
|
||||
passwd: password
|
||||
};
|
||||
}
|
||||
if (libraryType === 'group') {
|
||||
@@ -160,6 +156,12 @@ class CreateRepoDialog extends React.Component {
|
||||
passwd: password,
|
||||
};
|
||||
}
|
||||
|
||||
const storage_id = this.state.storage_id;
|
||||
if (storage_id) {
|
||||
repo.storage_id = storage_id;
|
||||
}
|
||||
|
||||
return repo;
|
||||
}
|
||||
|
||||
@@ -179,6 +181,17 @@ class CreateRepoDialog extends React.Component {
|
||||
onChange={this.handleRepoNameChange}
|
||||
/>
|
||||
</FormGroup>
|
||||
{storages.length > 0 && (
|
||||
<FormGroup>
|
||||
<Label for="storage-backend">{gettext('Storage Backend')}</Label>
|
||||
<Select
|
||||
id="storage-backend"
|
||||
defaultValue={{value: storages[0].id, label: storages[0].name}}
|
||||
options={storages.map((item, index) => { return {value: item.id, label: item.name}; })}
|
||||
onChange={this.handleStorageInputChange}
|
||||
/>
|
||||
</FormGroup>
|
||||
)}
|
||||
{this.props.libraryType === 'group' && (
|
||||
<FormGroup>
|
||||
<Label for="exampleSelect">{gettext('Permission')}</Label>
|
||||
@@ -191,7 +204,7 @@ class CreateRepoDialog extends React.Component {
|
||||
{enableEncryptedLibrary &&
|
||||
<div>
|
||||
<FormGroup check>
|
||||
<Input type="checkbox" id="encrypt" onChange={this.onEncrypted}/>
|
||||
<Input type="checkbox" id="encrypt" onChange={this.onEncrypted} />
|
||||
<Label for="encrypt">{gettext('Encrypt')}</Label>
|
||||
</FormGroup>
|
||||
{!this.state.disabled &&
|
||||
|
@@ -6,6 +6,7 @@ import copy from '@seafile/seafile-editor/dist/utils/copy-to-clipboard';
|
||||
import { gettext } from '../../utils/constants';
|
||||
import { seafileAPI } from '../../utils/seafile-api';
|
||||
import { Utils } from '../../utils/utils';
|
||||
import Loading from '../loading';
|
||||
|
||||
const propTypes = {
|
||||
path: PropTypes.string.isRequired,
|
||||
@@ -18,6 +19,7 @@ class InternalLink extends React.Component {
|
||||
super(props);
|
||||
this.state = {
|
||||
smartLink: '',
|
||||
isInternalLoding: true,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -25,7 +27,8 @@ class InternalLink extends React.Component {
|
||||
let { repoID, path, direntType } = this.props;
|
||||
seafileAPI.getInternalLink(repoID, path, direntType).then(res => {
|
||||
this.setState({
|
||||
smartLink: res.data.smart_link
|
||||
smartLink: res.data.smart_link,
|
||||
isInternalLoding: false
|
||||
});
|
||||
}).catch(error => {
|
||||
let errMessage = Utils.getErrorMsg(error);
|
||||
@@ -42,6 +45,9 @@ class InternalLink extends React.Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
if (this.state.isInternalLoding) {
|
||||
return(<Loading />);
|
||||
}
|
||||
return (
|
||||
<div>
|
||||
<p className="tip mb-1">
|
||||
|
@@ -34,7 +34,7 @@ class AddOrgAdminDialog extends React.Component {
|
||||
addOrgAdmin = () => {
|
||||
if (!this.state.selectedOption) return;
|
||||
const userEmail = this.state.selectedOption.email;
|
||||
seafileAPI.setOrgAdmin(orgID, userEmail, true).then(res => {
|
||||
seafileAPI.orgAdminSetOrgAdmin(orgID, userEmail, true).then(res => {
|
||||
let userInfo = new OrgUserInfo(res.data);
|
||||
this.props.onAddedOrgAdmin(userInfo);
|
||||
}).catch(error => {
|
||||
|
@@ -37,7 +37,7 @@ class SetOrgUserContactEmail extends React.Component {
|
||||
submitBtnDisabled: true
|
||||
});
|
||||
|
||||
seafileAPI.setOrgUserContactEmail(orgID, email, contactEmail).then((res) => {
|
||||
seafileAPI.orgAdminSetOrgUserContactEmail(orgID, email, contactEmail).then((res) => {
|
||||
const newContactEmail = contactEmail ? res.data.contact_email : '';
|
||||
this.props.updateContactEmail(newContactEmail);
|
||||
this.props.toggleDialog();
|
||||
|
@@ -39,7 +39,7 @@ class SetOrgUserName extends React.Component {
|
||||
|
||||
// when name is '', api returns the previous name
|
||||
// but newName needs to be ''
|
||||
seafileAPI.setOrgUserName(orgID, email, name).then((res) => {
|
||||
seafileAPI.orgAdminSetOrgUserName(orgID, email, name).then((res) => {
|
||||
const newName = name ? res.data.name : '';
|
||||
this.props.updateName(newName);
|
||||
this.props.toggleDialog();
|
||||
|
@@ -46,7 +46,7 @@ class SetOrgUserQuota extends React.Component {
|
||||
submitBtnDisabled: true
|
||||
});
|
||||
|
||||
seafileAPI.setOrgUserQuota(orgID, email, quota).then((res) => {
|
||||
seafileAPI.orgAdminSetOrgUserQuota(orgID, email, quota).then((res) => {
|
||||
this.props.updateQuota(res.data.quota_total);
|
||||
this.props.toggleDialog();
|
||||
}).catch((error) => {
|
||||
|
@@ -98,11 +98,13 @@ class ShareDialog extends React.Component {
|
||||
</NavLink>
|
||||
</NavItem>
|
||||
}
|
||||
<NavItem>
|
||||
<NavLink className={activeTab === 'internalLink' ? 'active' : ''} onClick={this.toggle.bind(this, 'internalLink')}>
|
||||
{gettext('Internal Link')}
|
||||
</NavLink>
|
||||
</NavItem>
|
||||
{itemType === 'dir' &&
|
||||
<NavItem>
|
||||
<NavLink className={activeTab === 'internalLink' ? 'active' : ''} onClick={this.toggle.bind(this, 'internalLink')}>
|
||||
{gettext('Internal Link')}
|
||||
</NavLink>
|
||||
</NavItem>
|
||||
}
|
||||
{enableDirPrivateShare &&
|
||||
<Fragment>
|
||||
<NavItem>
|
||||
@@ -139,13 +141,13 @@ class ShareDialog extends React.Component {
|
||||
/>
|
||||
</TabPane>
|
||||
}
|
||||
<TabPane tabId="internalLink">
|
||||
{itemType === 'dir' && activeTab === 'internalLink' &&
|
||||
<InternalLink
|
||||
path={this.props.itemPath}
|
||||
repoID={this.props.repoID}
|
||||
direntType={itemType}
|
||||
/>
|
||||
</TabPane>
|
||||
}
|
||||
{enableDirPrivateShare &&
|
||||
<Fragment>
|
||||
<TabPane tabId="shareToUser">
|
||||
@@ -190,12 +192,12 @@ class ShareDialog extends React.Component {
|
||||
closeShareDialog={this.props.toggleDialog}
|
||||
/>
|
||||
</TabPane>
|
||||
<TabPane tabId="internalLink">
|
||||
{activeTab === 'internalLink' &&
|
||||
<InternalLink
|
||||
repoID={this.props.repoID}
|
||||
path={this.props.itemPath}
|
||||
repoID={this.props.repoID}
|
||||
/>
|
||||
</TabPane>
|
||||
}
|
||||
</TabContent>
|
||||
</div>
|
||||
</Fragment>
|
||||
|
Reference in New Issue
Block a user