1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-08 10:22:46 +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:
Michael An
2023-09-13 08:40:50 +08:00
committed by GitHub
parent d829ba5b23
commit 14ce391007
520 changed files with 4774 additions and 3438 deletions

View File

@@ -85,7 +85,7 @@ class Draft extends React.Component {
});
return;
}
// eslint-disable-next-line
const hash = window.location.hash;
if (hash.indexOf('#history-') === 0) {
const currentCommitID = hash.slice(9, 49);
@@ -154,7 +154,9 @@ class Draft extends React.Component {
return;
}
// eslint-disable-next-line
let dl0 = siteRoot + 'repo/' + draftRepoID + '/' + draftPublishVersion + '/download?' + 'p=' + draftOriginFilePath;
// eslint-disable-next-line
let dl = siteRoot + 'repo/' + draftRepoID + '/' + originFileVersion + '/download?' + 'p=' + draftOriginFilePath;
axios.all([
seafileAPI.getFileContent(dl0),
@@ -168,7 +170,7 @@ class Draft extends React.Component {
}));
break;
}
}
};
onHistoryItemClick = (currentItem, preItem, activeItem) => {
const preCommitID = preItem.commit_id;
@@ -187,11 +189,11 @@ class Draft extends React.Component {
this.setDiffViewerContent(content1.data, content2.data);
}));
}));
}
};
onHistoryListChange = (historyList) => {
this.setState({historyList: historyList });
}
};
listComments = () => {
seafileAPI.listComments(draftRepoID, draftFilePath).then((res) => {
@@ -201,31 +203,31 @@ class Draft extends React.Component {
});
this.setState({ commentsList: commentsList });
});
}
};
addComment = (e) => {
e.stopPropagation();
this.getQuote();
if (!this.quote) return;
this.setState({ isShowCommentDialog: true });
}
};
onCommentAdded = () => {
this.listComments();
this.toggleCommentDialog();
}
};
toggleCommentDialog = () => {
this.setState({
isShowCommentDialog: !this.state.isShowCommentDialog
});
}
};
getOriginRepoInfo = () => {
seafileAPI.getRepoInfo(draftRepoID).then((res) => {
this.setState({ originRepoName: res.data.repo_name });
});
}
};
getDraftInfo = () => {
if (draftStatus === 'open') {
@@ -233,13 +235,13 @@ class Draft extends React.Component {
this.setState({ draftInfo: res.data });
});
}
}
};
getChangedNodes = () => {
const nodes = this.refs.diffViewer.value;
let keys = [];
let lastDiffState = '';
nodes.map((node, index) => {
nodes.forEach((node, index) => {
const diff_state = node.data['diff_state'];
if (diff_state === 'diff-added' && lastDiffState !== 'diff-added') {
keys.push(index);
@@ -253,7 +255,7 @@ class Draft extends React.Component {
this.setState({
changedNodes: keys
});
}
};
scrollToChangedNode = (scroll) => {
if (this.state.changedNodes.length == 0) return;
@@ -279,7 +281,7 @@ class Draft extends React.Component {
} else {
scroller.scrollTop = element.offsetTop;
}
}
};
findScrollContainer = (element, window) => {
let parent = element.parentNode;
@@ -299,7 +301,7 @@ class Draft extends React.Component {
return window.document.body;
}
return scroller;
}
};
scrollToQuote = (newIndex, oldIndex, quote) => {
const nodes = this.refs.diffViewer.value;
@@ -307,6 +309,7 @@ class Draft extends React.Component {
if (node.data['old_index'] == oldIndex && node.data['new_index'] == newIndex) {
return node;
}
return null;
});
if (commentNode) {
const element = toDOMNode(window.viewer, commentNode);
@@ -320,7 +323,7 @@ class Draft extends React.Component {
scroller.scrollTop = element.offsetTop;
}
}
}
};
showDiffViewer = () => {
return (
@@ -342,7 +345,7 @@ class Draft extends React.Component {
<i className="fa fa-plus-square review-comment-btn" ref="commentbtn" onMouseDown={this.addComment}></i>
</div>
);
}
};
listReviewers = () => {
seafileAPI.listDraftReviewers(draftID).then((res) => {
@@ -350,7 +353,7 @@ class Draft extends React.Component {
reviewers: res.data.reviewers
});
});
}
};
onSwitchShowDiff = () => {
if (!this.state.isShowDiff) {
@@ -362,13 +365,13 @@ class Draft extends React.Component {
this.setState({
isShowDiff: !this.state.isShowDiff,
});
}
};
toggleDiffTip = () => {
this.setState({
showDiffTip: !this.state.showDiffTip
});
}
};
toggleAddReviewerDialog = () => {
if (this.state.showReviewerDialog) {
@@ -377,7 +380,7 @@ class Draft extends React.Component {
this.setState({
showReviewerDialog: !this.state.showReviewerDialog
});
}
};
showDiffButton = () => {
return (
@@ -393,7 +396,7 @@ class Draft extends React.Component {
{gettext('View diff')}</Tooltip>
</div>
);
}
};
onPublishDraft = () => {
seafileAPI.publishDraft(draftID).then(res => {
@@ -401,7 +404,7 @@ class Draft extends React.Component {
draftStatus: res.data.draft_status,
});
});
}
};
initialDiffViewerContent = () => {
seafileAPI.listFileHistoryRecords(draftRepoID, draftFilePath, 1, 25).then((res) => {
@@ -432,7 +435,7 @@ class Draft extends React.Component {
});
}
});
}
};
setDiffViewerContent = (newContent, prevContent) => {
this.setState({
@@ -440,13 +443,13 @@ class Draft extends React.Component {
draftOriginContent: prevContent,
isLoading: false,
});
}
};
setURL = (newurl) => {
let url = new URL(window.location.href);
url.set('hash', newurl);
window.location.href = url.toString();
}
};
tabItemClick = (tab) => {
if (this.state.activeTab !== tab) {
@@ -462,7 +465,7 @@ class Draft extends React.Component {
activeTab: tab
});
}
}
};
showNavItem = (showTab) => {
const commentsNumber = this.state.commentsList.length;
@@ -502,7 +505,7 @@ class Draft extends React.Component {
</NavItem>
);
}
}
};
getDomNodeByPath = (path) => {
let node, parent = document.querySelector('.viewer-component');
@@ -515,7 +518,7 @@ class Draft extends React.Component {
parent = node;
}
return node;
}
};
setBtnPosition = () => {
const nativeSelection = window.getSelection();
@@ -546,7 +549,7 @@ class Draft extends React.Component {
} else {
style.top = '-1000px';
}
}
};
getQuote = () => {
if (!this.range) return;
@@ -554,7 +557,7 @@ class Draft extends React.Component {
const node = window.viewer.children[this.range.anchor.path[0]];
this.newIndex = node.data['new_index'];
this.oldIndex = node.data['old_index'];
}
};
componentDidMount() {
this.getOriginRepoInfo();
@@ -582,7 +585,7 @@ class Draft extends React.Component {
}
return this.showDiffButton();
}
}
};
renderNavItems = () => {
switch (draftStatus) {
@@ -617,7 +620,7 @@ class Draft extends React.Component {
</Nav>
);
}
}
};
renderContent = () => {
switch(draftStatus) {
@@ -632,7 +635,7 @@ class Draft extends React.Component {
}
return this.showDiffViewer();
}
}
};
render() {
const { draftInfo, reviewers, originRepoName, draftStatus } = this.state;