This repository was archived by the owner on Dec 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 405
Refactoring builders [do not merge] #1919
Closed
Closed
Changes from all commits
Commits
Show all changes
92 commits
Select commit
Hold shift + click to select a range
a8bea5f
when diff is decided to be "too large", we skip hunk building and ret…
vanessayuenn e2862ea
visually display the diff gate
vanessayuenn a9db48f
experimenting wiht a DelayedPatch but idk
vanessayuenn f621d49
Delayed patch parsing
smashwilson a729493
Correct pre-existing markers after building patch hunks
smashwilson 68926e5
:shirt:
smashwilson 4686cfc
get things to render properly first
vanessayuenn 0c3a2a6
Accept renderStatusOverrides in ye MultiFilePatch builder
smashwilson 7db6fb0
Pass builder options to getFilePatchForPath and getStagedChangesPatch
smashwilson 9de0eae
some clean up
vanessayuenn e8f372a
click to show diff???
vanessayuenn dc04f49
Add a renderStatus to Patch
smashwilson f0b8371
Emit events from a FilePatch when its render status changes
smashwilson 9dad4f7
Unit tests for FilePatch render status events
smashwilson cd5cc28
Remember changed renderStatus
smashwilson 7eab119
add collapse button to file patch header
b251264
Use a Marker instead of a Point to track delayed patch location
smashwilson 0bfacb6
Track changed renderStatus in CommitPreviewContainer
smashwilson 40cde30
Ditto for CommitDetailContainer
smashwilson be2ab8f
fix bad parens in mfp builder
e28522e
don't render pull request comments if patch exceeds large diff threshold
b66c88c
use a Map to avoid iterating through patches
98fbfc9
deal with null patches
ccf2a99
:shirt:
26ee209
danananana PROP TYPES
010cd56
also check for COLLAPSED patch state
cd2b7f9
honk if you like test helpers
8324cb3
clean up pr comments builder
ee6c9c2
[wip] add tests for `isPatchTooLargeOrCollapsed`
0733676
Test case for Patch Marker movement
smashwilson 1237458
Extract LayeredBuffer class and use it consistently in Patch logic
smashwilson f963e75
Rename LayeredBuffer to PatchBuffer
smashwilson 6df1380
Begin an "atomic" (with respect to markers) Modification API
smashwilson 3b34099
import LARGE_DIFF_THRESHOLD
49b406d
Preserve Markers that begin or end at a Modification's insertion point
smashwilson a2d453c
PatchBuffer::extract() to slice a Range out and preserve its markers
smashwilson 34e104a
Unit test for inserting one PatchBuffer into another
smashwilson dfc2fee
actually trigger expanding and collapsing from `FilePatchHeaderView`
ebdec24
change the chevron icon direction depending on collapsed prop
01b82f0
Implement appendPatchBuffer()
smashwilson 2d7c2f4
Translate Markers when extracting and appending PatchBuffers midline
smashwilson 03e03f3
Renamings
smashwilson 400d1b8
Rename Inserter methods as "insert..." instead of "append..."
smashwilson 37f9ae6
Produce Maps of equivalent Markers after extract/insert PatchBuffers
smashwilson 498c720
Inserter::markWhile() to mark all changes made in a block
smashwilson 5c8181e
Rewrite buildHunks() to use an Inserter
smashwilson 1a74e83
[wip] make patch model use `nextLayeredBuffer`
510c887
PatchBuffer::inspect() to debug marker placement
smashwilson 18ff065
PatchBuffer::findAllMarkers() to query markers across all layers
smashwilson 5283be0
Clip insertion point to valid buffer positions
smashwilson c56becb
Fluent APIs
smashwilson d6e5947
No need to manually touch up patch/hunk markers
smashwilson 4c39a4b
Insert newlines *between* consecutive patches, hunks, regions
smashwilson 62951be
Need IIFEs for callbacks created within loops
smashwilson 0187f4c
buildHunks() always inserts at the end
smashwilson 07f3c88
:fire: trailing newline
smashwilson f4ea1a2
Remove console.logs :eyes:
smashwilson 57c03e1
Mark zero-length patches
smashwilson 869ec0e
[wip] make Patch model tests use a PatchBuffer
d1fcf70
:fire: .only
d13d184
DelayedPatch :point_right: HiddenPatch
smashwilson d25db25
More trailing newlines
smashwilson 92a1130
updateMarkers methods to consume marker Maps
smashwilson 70ea302
Implement HiddenPatch
smashwilson 24515a1
Get starting and ending Marker sets
smashwilson f27f5ab
Create a HiddenFilePatch for diff sets that are too large
smashwilson 36ac87c
Move collapsing and expanding to MFP
smashwilson 4bba2f4
Use getRenderStatus() methods
smashwilson 5ca5f12
Use MFP-level expand and collapse methods
smashwilson fae0a50
Show specific marker layers in PatchBuffer::inspect()
smashwilson 219a409
Implement inspect() methods on patch model classes
smashwilson 9767a87
destroyMarkers() calls to... destroy... the markers
smashwilson b1d7ff5
Build hunk data for expanding too-large patches on the correct buffer
smashwilson fc3d89c
Fix up Marker-keyed maps in MFP after expand or collapse
smashwilson e1a1a5c
NullPatch implementations of adjacent-marker methods
smashwilson 37c53ca
Defer insertPatchBuffer()'s callback until the marker map is populated
smashwilson 9d174a3
More collapse and expand work
smashwilson a0ae01c
Find adjacent FilePatches by array index instead of markers
smashwilson cba6f05
Remove unused argument
smashwilson 715f10a
Touch up expected marker range
smashwilson cff0d29
Correct expected Hunk header
smashwilson 2d7c81a
Build what-the-diff output instead of just model objects
smashwilson 537fd0e
Fix building symlink related FilePatches
smashwilson 6685330
::reMarkOn() accepts a PatchBuffer
smashwilson 2cd40d3
Adapt MultiFilePatch tests to model changes
smashwilson 5af6a87
Distinguish between unset and null files
smashwilson 8bab5ed
Set file patch status on symlink pairs
smashwilson 97154cb
fp3 isn't supposed to be a symlink change?
smashwilson 5b35a4f
Use MFP-level collapse and expand functions
smashwilson ecb49ea
Retain the TextBuffer within a PatchBuffer
smashwilson e6a74b0
NullPatch::reMarkOn() accepts a PatchBuffer
smashwilson aa41930
nits nits nits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import yubikiri from 'yubikiri'; | ||
import {CompositeDisposable} from 'event-kit'; | ||
|
||
import {autobind} from '../helpers'; | ||
import ObserveModel from '../views/observe-model'; | ||
|
@@ -12,6 +13,7 @@ export default class ChangedFileContainer extends React.Component { | |
repository: PropTypes.object.isRequired, | ||
stagingStatus: PropTypes.oneOf(['staged', 'unstaged']), | ||
relPath: PropTypes.string.isRequired, | ||
largeDiffThreshold: PropTypes.number, | ||
|
||
workspace: PropTypes.object.isRequired, | ||
commands: PropTypes.object.isRequired, | ||
|
@@ -27,13 +29,26 @@ export default class ChangedFileContainer extends React.Component { | |
constructor(props) { | ||
super(props); | ||
autobind(this, 'fetchData', 'renderWithData'); | ||
|
||
this.lastMultiFilePatch = null; | ||
this.sub = new CompositeDisposable(); | ||
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. one line comment -- not part of a review. |
||
|
||
this.state = {renderStatusOverride: null}; | ||
} | ||
|
||
fetchData(repository) { | ||
const staged = this.props.stagingStatus === 'staged'; | ||
|
||
const builder = {}; | ||
if (this.state.renderStatusOverride !== null) { | ||
builder.renderStatusOverrides = {[this.props.relPath]: this.state.renderStatusOverride}; | ||
} | ||
if (this.props.largeDiffThreshold !== undefined) { | ||
builder.largeDiffThreshold = this.props.largeDiffThreshold; | ||
} | ||
|
||
return yubikiri({ | ||
multiFilePatch: repository.getFilePatchForPath(this.props.relPath, {staged}), | ||
multiFilePatch: repository.getFilePatchForPath(this.props.relPath, {staged, builder}), | ||
isPartiallyStaged: repository.isPartiallyStaged(this.props.relPath), | ||
hasUndoHistory: repository.hasDiscardHistory(this.props.relPath), | ||
}); | ||
|
@@ -48,6 +63,20 @@ export default class ChangedFileContainer extends React.Component { | |
} | ||
|
||
renderWithData(data) { | ||
const currentMultiFilePatch = data && data.multiFilePatch; | ||
if (currentMultiFilePatch !== this.lastMultiFilePatch) { | ||
this.sub.dispose(); | ||
if (currentMultiFilePatch) { | ||
// Keep this component's renderStatusOverride synchronized with the FilePatch we're rendering | ||
this.sub = new CompositeDisposable( | ||
...currentMultiFilePatch.getFilePatches().map(fp => fp.onDidChangeRenderStatus(() => { | ||
this.setState({renderStatusOverride: fp.getRenderStatus()}); | ||
})), | ||
); | ||
} | ||
this.lastMultiFilePatch = currentMultiFilePatch; | ||
} | ||
|
||
if (this.props.repository.isLoading() || data === null) { | ||
return <LoadingView />; | ||
} | ||
|
@@ -59,4 +88,8 @@ export default class ChangedFileContainer extends React.Component { | |
/> | ||
); | ||
} | ||
|
||
componentWillUnmount() { | ||
this.sub.dispose(); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ export default class CommitDetailController extends React.Component { | |
this.state = { | ||
messageCollapsible: this.props.commit.isBodyLong(), | ||
messageOpen: !this.props.commit.isBodyLong(), | ||
}; | ||
} | ||
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. mind adding the missing semicolon here? |
||
} | ||
|
||
render() { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ export default class PullRequestReviewsController extends React.Component { | |
), | ||
}), | ||
getBufferRowForDiffPosition: PropTypes.func.isRequired, | ||
isPatchTooLargeOrCollapsed: PropTypes.func.isRequired, | ||
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. this is a really long name -- can you come up with something more concise? 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. how about just |
||
} | ||
|
||
constructor(props) { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
lalalala