mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-14 06:11:16 +00:00
Fix eslint warnings (#5635)
* 01 fix eslint warnings * fix code warnings * fix code warnings * fix code warnings * fix code warnings * fix code warnings
This commit is contained in:
@@ -47,6 +47,8 @@ const propTypes = {
|
||||
onAddFolder: PropTypes.func.isRequired,
|
||||
showDirentDetail: PropTypes.func.isRequired,
|
||||
onItemRename: PropTypes.func.isRequired,
|
||||
posX: PropTypes.number.isRequired,
|
||||
posY: PropTypes.number.isRequired,
|
||||
};
|
||||
|
||||
class DirentGridView extends React.Component {
|
||||
@@ -78,40 +80,40 @@ class DirentGridView extends React.Component {
|
||||
this.setState({
|
||||
isCreateFileDialogShow: !this.state.isCreateFileDialogShow,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
onGridItemClick = (dirent) => {
|
||||
hideMenu();
|
||||
this.setState({activeDirent: dirent});
|
||||
this.props.onGridItemClick(dirent);
|
||||
}
|
||||
};
|
||||
|
||||
onMoveToggle = () => {
|
||||
this.setState({isMoveDialogShow: !this.state.isMoveDialogShow});
|
||||
}
|
||||
};
|
||||
|
||||
onCopyToggle = () => {
|
||||
this.setState({isCopyDialogShow: !this.state.isCopyDialogShow});
|
||||
}
|
||||
};
|
||||
|
||||
onAddFolder = (dirPath) => {
|
||||
this.setState({isCreateFolderDialogShow: false});
|
||||
this.props.onAddFolder(dirPath);
|
||||
}
|
||||
};
|
||||
|
||||
onItemShare = (e) => {
|
||||
e.nativeEvent.stopImmediatePropagation(); //for document event
|
||||
this.setState({isShareDialogShow: !this.state.isShareDialogShow});
|
||||
}
|
||||
};
|
||||
|
||||
closeSharedDialog = () => {
|
||||
this.setState({isShareDialogShow: !this.state.isShareDialogShow});
|
||||
}
|
||||
};
|
||||
|
||||
onItemDelete = (currentObject, e) => {
|
||||
e.nativeEvent.stopImmediatePropagation(); //for document event
|
||||
this.props.onItemDelete(currentObject);
|
||||
}
|
||||
};
|
||||
|
||||
onMenuItemClick = (operation, currentObject, event) => {
|
||||
hideMenu();
|
||||
@@ -176,30 +178,30 @@ class DirentGridView extends React.Component {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
onEditFileTagToggle = () => {
|
||||
this.setState({
|
||||
isEditFileTagShow: !this.state.isEditFileTagShow
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
onFileTagChanged = () => {
|
||||
let dirent = this.state.activeDirent ? this.state.activeDirent : '';
|
||||
let direntPath = Utils.joinPath(this.props.path, dirent.name);
|
||||
this.props.onFileTagChanged(dirent, direntPath);
|
||||
}
|
||||
};
|
||||
|
||||
getDirentPath = (dirent) => {
|
||||
let path = this.props.path;
|
||||
return path === '/' ? path + dirent.name : path + '/' + dirent.name;
|
||||
}
|
||||
};
|
||||
|
||||
closeZipDialog = () => {
|
||||
this.setState({
|
||||
isZipDialogOpen: false
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
onItemDownload = (currentObject, e) => {
|
||||
e.nativeEvent.stopImmediatePropagation();
|
||||
@@ -214,31 +216,31 @@ class DirentGridView extends React.Component {
|
||||
let url = URLDecorator.getUrl({type: 'download_file_url', repoID: repoID, filePath: direntPath});
|
||||
location.href = url;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
onCreateFolderToggle = () => {
|
||||
this.setState({
|
||||
isCreateFolderDialogShow: !this.state.isCreateFolderDialogShow,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
onItemRenameToggle = () => {
|
||||
this.setState({
|
||||
isRenameDialogShow: !this.state.isRenameDialogShow,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
onItemMoveToggle = () => {
|
||||
this.setState({isMoveDialogShow: !this.state.isMoveDialogShow});
|
||||
}
|
||||
};
|
||||
|
||||
onItemCopyToggle = () => {
|
||||
this.setState({isCopyDialogShow: !this.state.isCopyDialogShow});
|
||||
}
|
||||
};
|
||||
|
||||
onPermissionItem = () => {
|
||||
this.setState({isPermissionDialogOpen: !this.state.isPermissionDialogOpen});
|
||||
}
|
||||
};
|
||||
|
||||
onLockItem = (currentObject) => {
|
||||
let repoID = this.props.repoID;
|
||||
@@ -252,7 +254,7 @@ class DirentGridView extends React.Component {
|
||||
let errMessage = Utils.getErrorMsg(error);
|
||||
toaster.danger(errMessage);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
onUnlockItem = (currentObject) => {
|
||||
let repoID = this.props.repoID;
|
||||
@@ -265,7 +267,7 @@ class DirentGridView extends React.Component {
|
||||
let errMessage = Utils.getErrorMsg(error);
|
||||
toaster.danger(errMessage);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
onMarkAsDraft = (currentObject) => {
|
||||
let repoID = this.props.repoID;
|
||||
@@ -276,7 +278,7 @@ class DirentGridView extends React.Component {
|
||||
let errMessage = Utils.getErrorMsg(error);
|
||||
toaster.danger(errMessage);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
onUnmarkAsDraft = (currentObject) => {
|
||||
let repoID = this.props.repoID;
|
||||
@@ -287,35 +289,35 @@ class DirentGridView extends React.Component {
|
||||
let errMessage = Utils.getErrorMsg(error);
|
||||
toaster.danger(errMessage);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
onCommentItem = () => {
|
||||
this.props.showDirentDetail('comments');
|
||||
}
|
||||
};
|
||||
|
||||
onHistory = (currentObject) => {
|
||||
let repoID = this.props.repoID;
|
||||
let filePath = this.getDirentPath(currentObject);
|
||||
let url = URLDecorator.getUrl({type: 'file_revisions', repoID: repoID, filePath: filePath});
|
||||
location.href = url;
|
||||
}
|
||||
};
|
||||
|
||||
onAccessLog = (currentObject) => {
|
||||
let filePath = this.getDirentPath(currentObject);
|
||||
let path = siteRoot + 'repo/file-access/' + this.props.repoID + '/?p=' + encodeURIComponent(filePath) ;
|
||||
window.open(path);
|
||||
}
|
||||
};
|
||||
|
||||
onOpenViaClient = (currentObject) => {
|
||||
let repoID = this.props.repoID;
|
||||
let filePath = this.getDirentPath(currentObject);
|
||||
let url = URLDecorator.getUrl({type: 'open_via_client', repoID: repoID, filePath: filePath});
|
||||
location.href = url;
|
||||
}
|
||||
};
|
||||
|
||||
onItemRename = (newName) => {
|
||||
this.props.onItemRename(this.state.activeDirent, newName);
|
||||
}
|
||||
};
|
||||
|
||||
prepareImageItem = (item) => {
|
||||
const name = item.name;
|
||||
@@ -329,7 +331,7 @@ class DirentGridView extends React.Component {
|
||||
'url': `${siteRoot}lib/${repoID}/file${path}`,
|
||||
'src': src
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
showImagePopup = (curItem) => {
|
||||
let items = this.props.fullDirentList.filter((item) => {
|
||||
@@ -345,29 +347,29 @@ class DirentGridView extends React.Component {
|
||||
imageItems: imageItems,
|
||||
imageIndex: items.indexOf(curItem)
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
closeImagePopup = () => {
|
||||
this.setState({isImagePopupOpen: false});
|
||||
}
|
||||
};
|
||||
|
||||
moveToPrevImage = () => {
|
||||
const imageItemsLength = this.state.imageItems.length;
|
||||
this.setState((prevState) => ({
|
||||
imageIndex: (prevState.imageIndex + imageItemsLength - 1) % imageItemsLength
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
moveToNextImage = () => {
|
||||
const imageItemsLength = this.state.imageItems.length;
|
||||
this.setState((prevState) => ({
|
||||
imageIndex: (prevState.imageIndex + 1) % imageItemsLength
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
checkDuplicatedName = (newName) => {
|
||||
return Utils.checkDuplicatedNameInList(this.props.direntList, newName);
|
||||
}
|
||||
};
|
||||
|
||||
// common contextmenu handle
|
||||
onMouseDown = (event) => {
|
||||
@@ -375,22 +377,22 @@ class DirentGridView extends React.Component {
|
||||
if (event.button === 2) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
onGridContainerMouseDown = (event) => {
|
||||
this.onMouseDown(event);
|
||||
}
|
||||
};
|
||||
|
||||
onGridItemMouseDown = (event) => {
|
||||
this.onMouseDown(event);
|
||||
}
|
||||
};
|
||||
|
||||
gridContainerClick = () => {
|
||||
hideMenu();
|
||||
if (!this.props.isDirentDetailShow) {
|
||||
this.onGridItemClick(null);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
onGridContainerContextMenu = (event) => {
|
||||
event.preventDefault();
|
||||
@@ -402,7 +404,7 @@ class DirentGridView extends React.Component {
|
||||
let id = 'dirent-grid-container-menu';
|
||||
let menuList = [TextTranslation.NEW_FOLDER, TextTranslation.NEW_FILE];
|
||||
this.handleContextClick(event, id, menuList);
|
||||
}
|
||||
};
|
||||
|
||||
onGridItemContextMenu = (event, dirent) => {
|
||||
// Display menu items according to the current dirent permission
|
||||
@@ -410,7 +412,7 @@ class DirentGridView extends React.Component {
|
||||
let menuList = this.getDirentItemMenuList(dirent, true);
|
||||
this.handleContextClick(event, id, menuList, dirent);
|
||||
this.props.onGridItemClick && this.props.onGridItemClick(dirent);
|
||||
}
|
||||
};
|
||||
|
||||
handleContextClick = (event, id, menuList, currentObject = null) => {
|
||||
event.preventDefault();
|
||||
@@ -443,13 +445,13 @@ class DirentGridView extends React.Component {
|
||||
}
|
||||
|
||||
showMenu(showMenuConfig);
|
||||
}
|
||||
};
|
||||
|
||||
getDirentItemMenuList = (dirent, isContextmenu) => {
|
||||
const isRepoOwner = this.isRepoOwner;
|
||||
const currentRepoInfo = this.props.currentRepoInfo;
|
||||
return Utils.getDirentOperationList(isRepoOwner, currentRepoInfo, dirent, isContextmenu);
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
let {direntList, path} = this.props;
|
||||
|
Reference in New Issue
Block a user