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 407
Add tab for all changed files in a pull request #1829
Merged
Merged
Changes from all commits
Commits
Show all changes
104 commits
Select commit
Hold shift + click to select a range
0853912
add tab for changed files
66e485c
Making fetch happen
686cf43
make patch URL actually valid
9f378a5
drill them props
4d2098d
drill these props too
e3fb672
[wip] actually build the file patch
58f00d0
hacky fix for height problem
66c0398
pass `itemType` to all the components that need it
2a22816
jeez, you want more props? so needy.
acd9626
smell ya later unnecessary div
5041b71
add some tests for `PullRequestChangedFilesoContainer`
f344abb
love too commit .only and console logging
edd2b07
moar tests! moar!
8733b9b
Document and reorganize PropTypes a bit
smashwilson ddea33e
Pass the host and token through IssueishDetail components
smashwilson 314439e
Shuffle a bunch of stuff in PrChangedFilesContainer because I'm me
smashwilson 4401f8b
I'm calling that prop "diff" now
smashwilson 081264b
Pass pull request attributes directly rather than parsing them from t…
smashwilson 39bb8b9
Capital TODO to trigger TODO bot
smashwilson 61920e0
Drill that Repository down to the MultiFilePatch components
smashwilson 6390955
Overkill custom PropType validator for itemType
smashwilson 8d5a845
Use itemType within the IssueishDetail item
smashwilson 99daac3
move diff parsing into `PrChangedFilesContainer`
63e3cfa
fix derp merge
bb2ab96
PrDetailView tests :white_check_mark: and :100:
smashwilson ae98c0e
add tests for `PullRequestChangedFilesController`
db3f189
wip -- why diff fixture no worky?
d4e2dca
Dedent patch fixture
kuychaco 3df90c5
Don't JSON stringify stubbed response
kuychaco 9c69216
naming things is hard, let's go shopping
206c352
`itemType` test is now unnecessary
924113b
rename `patch` to `multiFilePatch`
5aa73c1
fix multiFilePatch prop test in PullRequestChangedFilesController
31c744c
pluralization is hard ok
f149919
fix missing prop errors in test
44f5fd1
move `destroy` method to `IssueishDetailItem`
00232d1
:fire: PullRequestChangedFiles controller and view
df729f9
Make header and nav full-width
simurai 8a3ddd8
Add scrolling
simurai ac5de8e
refetch diff on refresh
vanessayuenn 6b2590b
Endpoint model to derive GitHub API endpoints from a domain
smashwilson f639ddb
Access an Endpoint from a Remote
smashwilson 3589080
Access a login model key for an Endpoint
smashwilson abca1f5
Access an Endpoint's host, the user-facing GitHub domain
smashwilson 792ee9a
Pass Endpoints instead of host strings
smashwilson 27a411c
Count PrDetailView tab openings
smashwilson 0ba6c63
somewhat better error handling
vanessayuenn ef27922
Yep that was totally me
smashwilson 3080420
Missed a getEnvironmentForHost() call
smashwilson 439de1f
Spelling
smashwilson 15f6cfa
Use URL as the Map key
smashwilson 30d230c
A++ error messages
vanessayuenn 870c178
reset error state upon refresh
vanessayuenn 8472a77
copy!
vanessayuenn 446741e
leverage the existing ErrorView
vanessayuenn 624da7a
don't always show logout button on errorview
vanessayuenn 52623a1
add test for when fetch fails
7f8707d
update component atlas
vanessayuenn 18a8973
fix test to deal with improved error handling
66e5a62
:shirt:
aa5f337
test diff parsing error state
424b5c4
:shirt: againnn
879c638
istanbul ignore dev debugging code to log rate limits
aeae3b3
add test for refetching data
714ec4b
more istanbul ignoring
d5a0f63
Fix PrTimeline scrolling issues
simurai d84707e
Make header more compact
simurai 23e81f2
add test for if network request fails
dfaa101
:shirt:
92573bf
Merge branch 'master' into 18-dec-files-changed-tab
abc7a0a
add counts to tabs
a85931f
add required props to `pullRequestDetailViewProps` fixture thingy
001ebfc
fix PullRequestDetailView tabs tests
47d9f4f
:shirt:
6f5fd17
fix tab metrics tests
c1d1c72
put istanbul ignore in the right place
ca3fab2
:fire: .only
3a4763c
more styling tweaks
eac9755
Merge branch 'master' into pr-1829/atom/18-dec-files-changed-tab
smashwilson 34ea974
:shirt:
smashwilson 1e91002
Tweak tab colors
simurai 7aadd36
Increase contrast for messageHeadline
simurai 1390a6a
Use font-size from themes in FilePatchViews
simurai 8ab8ef4
Make branches wrap
simurai 3d5018a
Make headerLink wrap
simurai c62bb51
for realsies istanbul ignore relay-network-layer-manager
14a2d27
IssueishDetailItem uses `github.com` as its host
smashwilson 3397d53
workdirPath is missing when looking at an issueish from another repo
smashwilson 788dd70
onBranch and openCommit will not be set for issues
smashwilson e2bfeea
Pass Endpoint into RemoteContainer separately
smashwilson 0228ee0
add tests for UserStore uncovered lines
83c8ecb
stupid .only
b745c37
:shirt: I really need to fix my in editor linting.
b9b29c3
log console errors in `PullRequestChangedFilesContainer`
1c58579
add test for `UserStore.loadMentionableUsers`
ac64240
add tests for `ErrorView`
0e9e1cd
Move dock styles to its own file
simurai 12c6df1
Separate left/right and bottom docks
simurai 8b1055b
Restyle PR panes in docks
simurai 41f4045
Style Commit Detail in dock
simurai 412cfae
Fix styling for issues
simurai 54d3190
remove unused import
vanessayuenn f422a4b
hide unstage / staging buttons for filemode and symlink changes
edc4226
add tests for FilePatchHeaderView buttons
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
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
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 |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| import React from 'react'; | ||
| import PropTypes from 'prop-types'; | ||
| import {parse as parseDiff} from 'what-the-diff'; | ||
|
|
||
| import {ItemTypePropType, EndpointPropType} from '../prop-types'; | ||
| import MultiFilePatchController from '../controllers/multi-file-patch-controller'; | ||
| import LoadingView from '../views/loading-view'; | ||
| import ErrorView from '../views/error-view'; | ||
| import {buildMultiFilePatch} from '../models/patch'; | ||
|
|
||
| export default class PullRequestChangedFilesContainer extends React.Component { | ||
| static propTypes = { | ||
| // Pull request properties | ||
| owner: PropTypes.string.isRequired, | ||
| repo: PropTypes.string.isRequired, | ||
| number: PropTypes.number.isRequired, | ||
|
|
||
| // Connection properties | ||
| endpoint: EndpointPropType.isRequired, | ||
| token: PropTypes.string.isRequired, | ||
|
|
||
| // Item context | ||
| itemType: ItemTypePropType.isRequired, | ||
|
|
||
| // action methods | ||
| destroy: PropTypes.func.isRequired, | ||
|
|
||
| // Atom environment | ||
| workspace: PropTypes.object.isRequired, | ||
| commands: PropTypes.object.isRequired, | ||
| keymaps: PropTypes.object.isRequired, | ||
| tooltips: PropTypes.object.isRequired, | ||
| config: PropTypes.object.isRequired, | ||
|
|
||
| // local repo as opposed to pull request repo | ||
| localRepository: PropTypes.object.isRequired, | ||
|
|
||
| // refetch diff on refresh | ||
| shouldRefetch: PropTypes.bool.isRequired, | ||
| } | ||
|
|
||
| constructor(props) { | ||
| super(props); | ||
| this.state = {isLoading: true, error: null}; | ||
| this.fetchDiff(); | ||
| } | ||
|
|
||
| componentDidUpdate(prevProps) { | ||
| if (this.props.shouldRefetch && !prevProps.shouldRefetch) { | ||
| this.setState({isLoading: true, error: null}); | ||
| this.fetchDiff(); | ||
| } | ||
| } | ||
|
|
||
| // Generate a v3 GitHub API REST URL for the pull request resource. | ||
| // Example: https://api.github.com/repos/atom/github/pulls/1829 | ||
| getDiffURL() { | ||
| return this.props.endpoint.getRestURI('repos', this.props.owner, this.props.repo, 'pulls', this.props.number); | ||
| } | ||
|
|
||
| buildPatch(rawDiff) { | ||
| const diffs = parseDiff(rawDiff); | ||
| return buildMultiFilePatch(diffs); | ||
| } | ||
|
|
||
| async fetchDiff() { | ||
| const diffError = (message, err = null) => new Promise(resolve => { | ||
| if (err) { | ||
| // eslint-disable-next-line no-console | ||
| console.error(err); | ||
| } | ||
| this.setState({isLoading: false, error: message}, resolve); | ||
| }); | ||
| const url = this.getDiffURL(); | ||
|
|
||
| const response = await fetch(url, { | ||
| headers: { | ||
| Accept: 'application/vnd.github.v3.diff', | ||
| Authorization: `bearer ${this.props.token}`, | ||
| }, | ||
| // eslint-disable-next-line handle-callback-err | ||
| }).catch(err => { | ||
| diffError(`Network error encountered at fetching ${url}`, err); | ||
| }); | ||
| if (this.state.error) { | ||
| return; | ||
| } | ||
| try { | ||
| if (response && response.ok) { | ||
| const rawDiff = await response.text(); | ||
| const multiFilePatch = this.buildPatch(rawDiff); | ||
| await new Promise(resolve => this.setState({isLoading: false, multiFilePatch}, resolve)); | ||
| } else { | ||
| diffError(`Unable to fetch diff for this pull request${response ? ': ' + response.statusText : ''}.`); | ||
| } | ||
| } catch (err) { | ||
| diffError('Unable to parse diff for this pull request.', err); | ||
| } | ||
| } | ||
|
|
||
| render() { | ||
| if (this.state.isLoading) { | ||
| return <LoadingView />; | ||
| } | ||
|
|
||
| if (this.state.error) { | ||
| return <ErrorView descriptions={[this.state.error]} />; | ||
| } | ||
|
|
||
| return ( | ||
| <MultiFilePatchController | ||
| multiFilePatch={this.state.multiFilePatch} | ||
| repository={this.props.localRepository} | ||
| {...this.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.
Always makes me nervous when I see
setStateused synchronously. I think it's okay here because we don't actually need to wait for the re-render with{isLoading: true}to complete before we start fetching the updated diff.