-
Notifications
You must be signed in to change notification settings - Fork 405
Group resolved comments #2117
Group resolved comments #2117
Changes from all commits
9e10b71
6aa6c4d
84a90a4
748a58a
9b0e519
7eff9bc
23bedb1
1d2b1a3
9f65452
cc3d925
200dcc2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,9 @@ export default class ReviewsView extends React.Component { | |
threadIDsOpen: PropTypes.shape({ | ||
has: PropTypes.func.isRequired, | ||
}), | ||
highlightedThreadIDs: PropTypes.shape({ | ||
has: PropTypes.func.isRequired, | ||
}), | ||
postingToThreadID: PropTypes.string, | ||
scrollToThreadID: PropTypes.string, | ||
// Structure: Map< relativePath: String, { | ||
|
@@ -110,26 +113,14 @@ export default class ReviewsView extends React.Component { | |
componentDidMount() { | ||
const {scrollToThreadID} = this.props; | ||
if (scrollToThreadID) { | ||
const threadHolder = this.threadHolders.get(scrollToThreadID); | ||
if (threadHolder) { | ||
threadHolder.map(element => { | ||
element.scrollIntoViewIfNeeded(); | ||
return null; // shh, eslint | ||
}); | ||
} | ||
this.scrollToThread(scrollToThreadID); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
} | ||
} | ||
|
||
componentDidUpdate(prevProps) { | ||
const {scrollToThreadID} = this.props; | ||
if (scrollToThreadID && scrollToThreadID !== prevProps.scrollToThreadID) { | ||
const threadHolder = this.threadHolders.get(scrollToThreadID); | ||
if (threadHolder) { | ||
threadHolder.map(element => { | ||
element.scrollIntoViewIfNeeded(); | ||
return null; // shh, eslint | ||
}); | ||
} | ||
this.scrollToThread(scrollToThreadID); | ||
} | ||
} | ||
|
||
|
@@ -308,7 +299,8 @@ export default class ReviewsView extends React.Component { | |
return null; | ||
} | ||
|
||
const resolvedThreads = commentThreads.filter(pair => pair.thread.isResolved).length; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hah, should have called this |
||
const resolvedThreads = commentThreads.filter(pair => pair.thread.isResolved); | ||
const unresolvedThreads = commentThreads.filter(pair => !pair.thread.isResolved); | ||
|
||
const toggleComments = evt => { | ||
evt.preventDefault(); | ||
|
@@ -329,16 +321,28 @@ export default class ReviewsView extends React.Component { | |
<span className="github-Reviews-progress"> | ||
<span className="github-Reviews-count"> | ||
Resolved | ||
{' '}<span className="github-Reviews-countNr">{resolvedThreads}</span>{' '} | ||
{' '}<span className="github-Reviews-countNr">{resolvedThreads.length}</span>{' '} | ||
of | ||
{' '}<span className="github-Reviews-countNr">{commentThreads.length}</span> | ||
{' '}<span className="github-Reviews-countNr">{resolvedThreads.length + unresolvedThreads.length}</span> | ||
</span> | ||
<progress className="github-Reviews-progessBar" value={resolvedThreads} max={commentThreads.length} /> | ||
<progress | ||
className="github-Reviews-progessBar" value={resolvedThreads.length} | ||
max={resolvedThreads.length + unresolvedThreads.length} | ||
/> | ||
</span> | ||
</summary> | ||
<main className="github-Reviews-container"> | ||
{commentThreads.map(this.renderReviewCommentThread)} | ||
</main> | ||
|
||
{unresolvedThreads.length > 0 && <main className="github-Reviews-container"> | ||
{unresolvedThreads.map(this.renderReviewCommentThread)} | ||
</main>} | ||
{resolvedThreads.length > 0 && <details className="github-Reviews-section resolved-comments" open> | ||
<summary className="github-Reviews-header"> | ||
<span className="github-Reviews-title">Resolved</span> | ||
</summary> | ||
<main className="github-Reviews-container"> | ||
{resolvedThreads.map(this.renderReviewCommentThread)} | ||
</main> | ||
</details>} | ||
|
||
</details> | ||
); | ||
|
@@ -371,7 +375,7 @@ export default class ReviewsView extends React.Component { | |
const openDiffClasses = cx('icon-diff', ...navButtonClasses); | ||
|
||
const isOpen = this.props.threadIDsOpen.has(thread.id); | ||
const isHighlighted = this.props.scrollToThreadID === thread.id; | ||
const isHighlighted = this.props.highlightedThreadIDs.has(thread.id); | ||
const toggle = evt => { | ||
evt.preventDefault(); | ||
evt.stopPropagation(); | ||
|
@@ -494,7 +498,7 @@ export default class ReviewsView extends React.Component { | |
<button | ||
className="github-Review-resolveButton btn btn-primary icon icon-check" | ||
title="Unresolve conversation" | ||
onClick={() => this.props.unresolveThread(thread)}> | ||
onClick={() => this.resolveUnresolveThread(thread)}> | ||
Unresolve conversation | ||
</button> | ||
); | ||
|
@@ -503,7 +507,7 @@ export default class ReviewsView extends React.Component { | |
<button | ||
className="github-Review-resolveButton btn btn-primary icon icon-check" | ||
title="Resolve conversation" | ||
onClick={() => this.props.resolveThread(thread)}> | ||
onClick={() => this.resolveUnresolveThread(thread)}> | ||
Resolve conversation | ||
</button> | ||
); | ||
|
@@ -644,4 +648,23 @@ export default class ReviewsView extends React.Component { | |
|
||
return {lineNumber, positionText}; | ||
} | ||
|
||
/* istanbul ignore next */ | ||
scrollToThread(threadID) { | ||
const threadHolder = this.threadHolders.get(threadID); | ||
if (threadHolder) { | ||
threadHolder.map(element => { | ||
element.scrollIntoViewIfNeeded(); | ||
return null; // shh, eslint | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I really need to make a |
||
}); | ||
} | ||
} | ||
|
||
async resolveUnresolveThread(thread) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We keep hitting situations where we need to name methods that toggle something without having a good word for the toggling action. There isn't really a good alternative for this:
|
||
if (thread.isResolved) { | ||
await this.props.unresolveThread(thread); | ||
} else { | ||
await this.props.resolveThread(thread); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish we had a way to collapse the
setState
updater functions from here andhighlightThread
into a single, atomic transaction. I'm pretty sure that's how it's working anyway and this is much cleaner but still 😛