mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-01 23:20:51 +00:00
Merge branch '7.1' into master
This commit is contained in:
@@ -2,7 +2,7 @@ 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, storages } from '../../utils/constants';
|
||||
import { gettext, enableEncryptedLibrary, repoPasswordMinLength, storages, libraryTemplates } from '../../utils/constants';
|
||||
|
||||
const propTypes = {
|
||||
libraryType: PropTypes.string.isRequired,
|
||||
@@ -22,6 +22,7 @@ class CreateRepoDialog extends React.Component {
|
||||
errMessage: '',
|
||||
permission: 'rw',
|
||||
storage_id: storages.length ? storages[0].id : '',
|
||||
library_template: libraryTemplates.length ? libraryTemplates[0] : '',
|
||||
isSubmitBtnActive: false,
|
||||
};
|
||||
this.newInput = React.createRef();
|
||||
@@ -121,6 +122,10 @@ class CreateRepoDialog extends React.Component {
|
||||
this.setState({storage_id: selectedItem.value});
|
||||
}
|
||||
|
||||
handlelibraryTemplatesInputChange = (selectedItem) => {
|
||||
this.setState({library_template: selectedItem.value});
|
||||
}
|
||||
|
||||
onEncrypted = (e) => {
|
||||
let isChecked = e.target.checked;
|
||||
this.setState({
|
||||
@@ -162,6 +167,11 @@ class CreateRepoDialog extends React.Component {
|
||||
repo.storage_id = storage_id;
|
||||
}
|
||||
|
||||
const library_template = this.state.library_template;
|
||||
if (library_template) {
|
||||
repo.library_template = library_template;
|
||||
}
|
||||
|
||||
return repo;
|
||||
}
|
||||
|
||||
@@ -192,6 +202,19 @@ class CreateRepoDialog extends React.Component {
|
||||
/>
|
||||
</FormGroup>
|
||||
)}
|
||||
|
||||
{libraryTemplates.length > 0 && (
|
||||
<FormGroup>
|
||||
<Label for="library-templates">{gettext('Library Templates')}</Label>
|
||||
<Select
|
||||
id="library-templates"
|
||||
defaultValue={{value: libraryTemplates[0], label: libraryTemplates[0]}}
|
||||
options={libraryTemplates.map((item, index) => { return {value: item, label: item}; })}
|
||||
onChange={this.handlelibraryTemplatesInputChange}
|
||||
/>
|
||||
</FormGroup>
|
||||
)}
|
||||
|
||||
{this.props.libraryType === 'group' && (
|
||||
<FormGroup>
|
||||
<Label for="exampleSelect">{gettext('Permission')}</Label>
|
||||
|
@@ -388,6 +388,18 @@ class FileUploader extends React.Component {
|
||||
this.setState({uploadFileList: uploadFileList});
|
||||
}
|
||||
|
||||
getFileServerErrorMessage = (key) => {
|
||||
const errorMessage = {
|
||||
'File locked by others.': gettext('File locked by others.'), // 403
|
||||
'Invalid filename.': gettext('Invalid filename.'), // 440
|
||||
'File already exists.': gettext('File already exists.'), // 441
|
||||
'File size is too large.': gettext('File size is too large.'), // 442
|
||||
'Out of quota.': gettext('Out of quota.'), // 443
|
||||
'Internal error.': gettext('Internal Server Error'), // 500
|
||||
}
|
||||
return errorMessage[key] || key;
|
||||
}
|
||||
|
||||
onFileError = (resumableFile, message) => {
|
||||
let error = '';
|
||||
if (!message) {
|
||||
@@ -396,13 +408,7 @@ class FileUploader extends React.Component {
|
||||
// eg: '{"error": "Internal error" \n }'
|
||||
let errorMessage = message.replace(/\n/g, '');
|
||||
errorMessage = JSON.parse(errorMessage);
|
||||
error = errorMessage.error;
|
||||
if (error === 'File locked by others.') {
|
||||
error = gettext('File is locked by others.');
|
||||
}
|
||||
if (error === 'Internal error.') {
|
||||
error = gettext('Internal Server Error');
|
||||
}
|
||||
error = this.getFileServerErrorMessage(errorMessage.error);
|
||||
}
|
||||
|
||||
let uploadFileList = this.state.uploadFileList.map(item => {
|
||||
|
41
frontend/src/components/user-settings/web-api-auth-token.js
Normal file
41
frontend/src/components/user-settings/web-api-auth-token.js
Normal file
@@ -0,0 +1,41 @@
|
||||
import React from 'react';
|
||||
import { gettext } from '../../utils/constants';
|
||||
import { seafileAPI } from '../../utils/seafile-api';
|
||||
import { Utils } from '../../utils/utils';
|
||||
import toaster from '../toast';
|
||||
|
||||
class WebAPIAuthToken extends React.Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
authToken: '******'
|
||||
};
|
||||
}
|
||||
|
||||
getAuthToken = () => {
|
||||
seafileAPI.getAuthTokenBySession().then((res) => {
|
||||
this.setState({
|
||||
authToken: res.data.token
|
||||
});
|
||||
}).catch((error) => {
|
||||
let errMessage = Utils.getErrorMsg(error);
|
||||
toaster.danger(errMessage);
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
const { authToken } = this.state;
|
||||
return (
|
||||
<div id="get-auth-token" className="setting-item">
|
||||
<h3 className="setting-item-heading">{gettext('Web API Auth Token')}</h3>
|
||||
<div className="d-flex align-items-center">
|
||||
<input type="text" readOnly={true} value={authToken} className="form-control mr-2 col-sm-5" />
|
||||
<button className="btn btn-outline-primary" onClick={this.getAuthToken}>{gettext('Get')}</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default WebAPIAuthToken;
|
Reference in New Issue
Block a user