From 3e9c03fc9b406e4591512636e46311a2570051c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=9F=E5=A0=82=E6=B3=BC=E8=BE=A3=E9=85=B1?= Date: Sat, 3 Sep 2022 16:58:50 +0800 Subject: [PATCH 1/2] feat: quick compare previous commit --- .../src/components/LogView/LogEntry/index.tsx | 17 +++++++++++++++++ .../src/components/LogView/LogView/index.tsx | 15 ++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/browser/src/components/LogView/LogEntry/index.tsx b/browser/src/components/LogView/LogEntry/index.tsx index 43ed2246..4a709316 100644 --- a/browser/src/components/LogView/LogEntry/index.tsx +++ b/browser/src/components/LogView/LogEntry/index.tsx @@ -125,6 +125,23 @@ class LogEntryView extends React.Component {
this.props.onViewCommit(this.props.logEntry)}>
+ + { + //Put the following function on the macro queue. after onViewCommit execute "getCommit" that micro queue,get the latest committedFiles field + setTimeout(() => { + this.props.onAction(this.props.logEntry, 'quick_compare_previous'); + }, 0); + }} + > + quick look diff + + copyText(e, this.props.logEntry.hash.full)} className="btnx hash clipboard hint--top-left hint--rounded hint--bounce" diff --git a/browser/src/components/LogView/LogView/index.tsx b/browser/src/components/LogView/LogView/index.tsx index e42ebd48..3b2909f0 100644 --- a/browser/src/components/LogView/LogView/index.tsx +++ b/browser/src/components/LogView/LogView/index.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; import { connect } from 'react-redux'; import { ResultActions } from '../../../actions/results'; -import { LogEntry, Ref } from '../../../definitions'; +import { CommittedFile, LogEntry, Ref } from '../../../definitions'; import { LogEntriesState, RootState } from '../../../reducers'; import BranchGraph from '../BranchGraph'; import LogEntryList from '../LogEntryList'; @@ -17,6 +17,7 @@ type LogViewProps = { actionRef: typeof ResultActions.actionRef; getPreviousCommits: typeof ResultActions.getPreviousCommits; getNextCommits: typeof ResultActions.getNextCommits; + actionFile: typeof ResultActions.actionFile; }; interface LogViewState {} @@ -149,6 +150,15 @@ class LogView extends React.Component { { entry, name }, ); break; + case 'quick_compare_previous': + this.props.actionFile( + this.props.logEntries.selected, + this.props.logEntries.selected.committedFiles.find( + el => el.uri.fsPath === this.props.logEntries.file.fsPath, + ), + 'compare_previous', + ); + break; default: this.props.actionCommit(entry, name); break; @@ -191,6 +201,9 @@ function mapDispatchToProps(dispatch) { dispatch(ResultActions.actionRef(logEntry, ref, name)), getNextCommits: () => dispatch(ResultActions.getNextCommits()), getPreviousCommits: () => dispatch(ResultActions.getPreviousCommits()), + actionFile: (logEntry: LogEntry, committedFile: CommittedFile, name) => { + dispatch(ResultActions.actionFile(logEntry, committedFile, name)); + }, }; } From c1379e58e7700244e2d513af8192f09ae384b640 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=9F=E5=A0=82=E6=B3=BC=E8=BE=A3=E9=85=B1?= <63482310+kangjs7854@users.noreply.github.com> Date: Sun, 4 Sep 2022 15:22:10 +0800 Subject: [PATCH 2/2] fix: Inconsistent code format --- browser/src/components/LogView/LogView/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browser/src/components/LogView/LogView/index.tsx b/browser/src/components/LogView/LogView/index.tsx index 3b2909f0..15c75aa5 100644 --- a/browser/src/components/LogView/LogView/index.tsx +++ b/browser/src/components/LogView/LogView/index.tsx @@ -154,7 +154,7 @@ class LogView extends React.Component { this.props.actionFile( this.props.logEntries.selected, this.props.logEntries.selected.committedFiles.find( - el => el.uri.fsPath === this.props.logEntries.file.fsPath, + (el) => el.uri.fsPath === this.props.logEntries.file.fsPath, ), 'compare_previous', );