mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-21 19:37:28 +00:00
Optimized module code (#2574)
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Button, Modal, ModalHeader, ModalFooter, ModalBody, Alert } from 'reactstrap';
|
||||
import { gettext, repoID } from '../../utils/constants';
|
||||
import { gettext } from '../../utils/constants';
|
||||
import { Utils } from '../../utils/utils';
|
||||
import FileChooser from '../file-chooser/file-chooser';
|
||||
|
||||
const propTypes = {
|
||||
path: PropTypes.string.isRequired,
|
||||
repoID: PropTypes.string.isRequired,
|
||||
dirent: PropTypes.object,
|
||||
selectedDirentList: PropTypes.array,
|
||||
isMutipleOperation: PropTypes.bool.isRequired,
|
||||
@@ -43,7 +44,7 @@ class CopyDirent extends React.Component {
|
||||
}
|
||||
|
||||
copyItems = () => {
|
||||
let { repo, selectedPath } = this.state;
|
||||
let { repo, repoID, selectedPath } = this.state;
|
||||
let message = gettext('Invalid destination path');
|
||||
|
||||
if (!repo || selectedPath === '') {
|
||||
@@ -93,7 +94,7 @@ class CopyDirent extends React.Component {
|
||||
}
|
||||
|
||||
copyItem = () => {
|
||||
let { repo, selectedPath } = this.state;
|
||||
let { repo, repoID, selectedPath } = this.state;
|
||||
let direntPath = Utils.joinPath(this.props.path, this.props.dirent.name);
|
||||
let message = 'Invalid destination path';
|
||||
|
||||
@@ -109,7 +110,7 @@ class CopyDirent extends React.Component {
|
||||
}
|
||||
|
||||
// copy the dirent to current path
|
||||
if (selectedPath && this.props.path === selectedPath) {
|
||||
if (selectedPath && this.props.path === selectedPath && repo.repo_id === repoID) {
|
||||
this.setState({errMessage: message});
|
||||
return;
|
||||
}
|
||||
@@ -159,6 +160,7 @@ class CopyDirent extends React.Component {
|
||||
<ModalHeader toggle={this.toggle}><div dangerouslySetInnerHTML={{__html: title}}></div></ModalHeader>
|
||||
<ModalBody>
|
||||
<FileChooser
|
||||
repoID={this.props.repoID}
|
||||
onDirentItemClick={this.onDirentItemClick}
|
||||
onRepoItemClick={this.onRepoItemClick}
|
||||
/>
|
||||
|
@@ -1,10 +1,11 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Button, Modal, ModalHeader, ModalBody, ModalFooter, Input } from 'reactstrap';
|
||||
import { gettext, repoID } from '../../utils/constants';
|
||||
import { gettext } from '../../utils/constants';
|
||||
import { seafileAPI } from '../../utils/seafile-api';
|
||||
|
||||
const propTypes = {
|
||||
repoID: PropTypes.string.isRequired,
|
||||
toggleCancel: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
@@ -35,6 +36,7 @@ class CreateTagDialog extends React.Component {
|
||||
createTag = () => {
|
||||
let name = this.state.tagName;
|
||||
let color = this.state.tagColor;
|
||||
let repoID = this.props.repoID;
|
||||
seafileAPI.createRepoTag(repoID, name, color).then(() =>{
|
||||
this.props.toggleCancel();
|
||||
});
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
|
||||
import { repoID, gettext } from '../../utils/constants';
|
||||
import { gettext } from '../../utils/constants';
|
||||
import { seafileAPI } from '../../utils/seafile-api';
|
||||
import RepoTag from '../../models/repo-tag';
|
||||
|
||||
const propTypes = {
|
||||
repoID: PropTypes.string.isRequired,
|
||||
filePath: PropTypes.string.isRequired,
|
||||
fileTagList: PropTypes.array.isRequired,
|
||||
onFileTagChanged: PropTypes.func.isRequired,
|
||||
@@ -25,6 +26,7 @@ class EditFileTagDialog extends React.Component {
|
||||
}
|
||||
|
||||
getRepoTagList = () => {
|
||||
let repoID = this.props.repoID;
|
||||
seafileAPI.listRepoTags(repoID).then(res => {
|
||||
let repotagList = [];
|
||||
res.data.repo_tags.forEach(item => {
|
||||
@@ -47,6 +49,7 @@ class EditFileTagDialog extends React.Component {
|
||||
}
|
||||
|
||||
editFileTag = (repoTag) => {
|
||||
let repoID = this.props.repoID;
|
||||
let repoTagIdList = this.getRepoTagIdList();
|
||||
if (repoTagIdList.indexOf(repoTag.id) === -1) {
|
||||
let id = repoTag.id;
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import React, { Fragment } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
|
||||
import { gettext, repoID } from '../../utils/constants';
|
||||
import { gettext } from '../../utils/constants';
|
||||
import { seafileAPI } from '../../utils/seafile-api';
|
||||
import RepoTag from '../../models/repo-tag';
|
||||
import '../../css/repo-tag.css';
|
||||
@@ -31,6 +31,7 @@ class TagListItem extends React.Component {
|
||||
TagListItem.propTypes = tagListItemPropTypes;
|
||||
|
||||
const listTagPropTypes = {
|
||||
repoID: PropTypes.string.isRequired,
|
||||
onListTagCancel: PropTypes.func.isRequired,
|
||||
onCreateRepoTag: PropTypes.func.isRequired,
|
||||
onUpdateRepoTag: PropTypes.func.isRequired,
|
||||
@@ -45,6 +46,7 @@ class ListTagDialog extends React.Component {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
let repoID = this.props.repoID;
|
||||
seafileAPI.listRepoTags(repoID).then(res => {
|
||||
let repotagList = [];
|
||||
res.data.repo_tags.forEach(item => {
|
||||
|
@@ -1,12 +1,13 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Button, Modal, ModalHeader, ModalFooter, ModalBody, Alert } from 'reactstrap';
|
||||
import { gettext, repoID } from '../../utils/constants';
|
||||
import { gettext } from '../../utils/constants';
|
||||
import { Utils } from '../../utils/utils';
|
||||
import FileChooser from '../file-chooser/file-chooser';
|
||||
|
||||
const propTypes = {
|
||||
path: PropTypes.string.isRequired,
|
||||
repoID: PropTypes.string.isRequired,
|
||||
dirent: PropTypes.object,
|
||||
selectedDirentList: PropTypes.array,
|
||||
isMutipleOperation: PropTypes.bool.isRequired,
|
||||
@@ -43,7 +44,7 @@ class MoveDirent extends React.Component {
|
||||
}
|
||||
|
||||
moveItems = () => {
|
||||
let { repo, selectedPath } = this.state;
|
||||
let { repo, repoID, selectedPath } = this.state;
|
||||
let message = gettext('Invalid destination path');
|
||||
|
||||
if (!repo || selectedPath === '') {
|
||||
@@ -93,7 +94,7 @@ class MoveDirent extends React.Component {
|
||||
}
|
||||
|
||||
moveItem = () => {
|
||||
let { repo, selectedPath } = this.state;
|
||||
let { repo, repoID, selectedPath } = this.state;
|
||||
let direntPath = Utils.joinPath(this.props.path, this.props.dirent.name);
|
||||
let message = gettext('Invalid destination path');
|
||||
|
||||
@@ -109,7 +110,7 @@ class MoveDirent extends React.Component {
|
||||
}
|
||||
|
||||
// copy the dirent to current path
|
||||
if (selectedPath && Utils.getDirName(direntPath) === selectedPath) {
|
||||
if (selectedPath && this.props.path === selectedPath && repo.repo_id === repoID) {
|
||||
this.setState({errMessage: message});
|
||||
return;
|
||||
}
|
||||
@@ -159,6 +160,7 @@ class MoveDirent extends React.Component {
|
||||
<ModalHeader toggle={this.toggle}><div dangerouslySetInnerHTML={{__html: title}}></div></ModalHeader>
|
||||
<ModalBody>
|
||||
<FileChooser
|
||||
repoID={this.props.repoID}
|
||||
onDirentItemClick={this.onDirentItemClick}
|
||||
onRepoItemClick={this.onRepoItemClick}
|
||||
/>
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import React, { Fragment } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Button, Modal, ModalHeader, ModalBody, ModalFooter, Input } from 'reactstrap';
|
||||
import { gettext, repoID } from '../../utils/constants';
|
||||
import { gettext } from '../../utils/constants';
|
||||
import { seafileAPI } from '../../utils/seafile-api';
|
||||
|
||||
const propTypes = {
|
||||
currentTag: PropTypes.object,
|
||||
repoID: PropTypes.string.isRequired,
|
||||
toggleCancel: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
@@ -42,6 +43,7 @@ class UpdateTagDialog extends React.Component {
|
||||
let tag_id = this.props.currentTag.id;
|
||||
let name = this.state.newName;
|
||||
let color = this.state.newColor;
|
||||
let repoID = this.props.repoID;
|
||||
seafileAPI.updateRepoTag(repoID, tag_id, name, color).then(() => {
|
||||
this.props.toggleCancel();
|
||||
});
|
||||
@@ -65,6 +67,7 @@ class UpdateTagDialog extends React.Component {
|
||||
|
||||
onDeleteTag = () => {
|
||||
let tag = this.props.currentTag;
|
||||
let repoID = this.props.repoID;
|
||||
seafileAPI.deleteRepoTag(repoID, tag.id).then(() => {
|
||||
this.props.toggleCancel();
|
||||
});
|
||||
|
Reference in New Issue
Block a user