Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

split IssueishDetailView into IssueDetailView and PullRequestDetailView #1804

Merged
merged 55 commits into from Dec 5, 2018

Conversation

annthurium
Copy link
Contributor

@annthurium annthurium commented Nov 20, 2018

addresses #1715.

These components have enough separate functionality that we should move them into their own files. There should be no user facing changes as a result of this refactor - it just makes it easier for us to maintain things in the future.

Todo

  • make new files for the new components
  • extract pr functionality from IssueishDetailView into PullRequestDetailView
  • extract issue functionality from IssueishDetailView into IssueDetailView
  • fix the graphql problems that will undoubtedly arise
  • extract emoji rendering functionality since it's shared by both components
  • do a pass on variables that could maybe be renamed?
  • nuke IssueishDetailContainer and any other dead code
  • fix missing prop warning in pr view when commits tab is clicked
  • all unit tests are green

Manual test plan:

  • open issue in Atom
    • header links to issue on dotcom
    • refresh button pulls down new data
    • issue body text and comments are styled as expected
    • link to dotcom in issue footer exists
    • emoji reactions are rendered
    • switching from an issue to a pull request (by clicking link to a pull request referenced in an issue)
  • open pull request in Atom
    • header links to pull request on dotcom
    • refresh button pulls down new data
    • pull request meta view is styled as expected
    • checkout pull request functionality works.
    • overview tab contains pull request timeline
    • emoji reactions are rendered
    • build status contains the build status
    • commits tab contains commits
    • test a pull request with more than 50 commits to make sure pagination and refetching work correctly
    • switching from an pull request to an issue (by clicking link to an issue referenced in a pull request body)

@coveralls
Copy link

coveralls commented Nov 20, 2018

Coverage Status

Coverage decreased (-0.03%) to 85.601% when pulling 181a591 on tt-18-nov-split-component into d403789 on master.

lib/views/issue-detail-view.js Outdated Show resolved Hide resolved
lib/controllers/issueish-detail-controller.js Show resolved Hide resolved
lib/views/issue-detail-view.js Show resolved Hide resolved
Stability Sprint : 20 November 2018 - 8 January 2019 : v0.24.0 automation moved this from In Progress 🔧 to QA Review 🔬 Dec 4, 2018
Copy link
Contributor

@vanessayuenn vanessayuenn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for tackling this! :shipit:

Tilde Ann Thurium added 4 commits December 4, 2018 09:51
It feels a bit dirty to be checking in multiple places, and also that 
both the issue and the pullRequest have a typename. 

I couldn't figure out how to pull the `__typename` up a level in 
graphql, but at least having a single source of truth in state for the 
type of the type of item we're dealing with seems marginally cleaner.
Copy link
Contributor

@smashwilson smashwilson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, now I am being that jerk to come in and request changes with the third review 🙈

The only showstopper I'm pointing out here is the state derivation being done with a deprecated React lifecycle method (marked with 🚨). Everything else is just my usual verbose self 😄

lib/controllers/issueish-detail-controller.js Outdated Show resolved Hide resolved
lib/controllers/issueish-detail-controller.js Outdated Show resolved Hide resolved
lib/controllers/issueish-detail-controller.js Outdated Show resolved Hide resolved
@@ -130,13 +153,13 @@ export class BareIssueishDetailController extends React.Component {
const fromPullRefspec =
headRemote.getOwner() === repository.owner.login &&
headRemote.getRepo() === repository.name &&
headPush.getShortRemoteRef() === `pull/${issueish.number}/head`;
headPush.getShortRemoteRef() === `pull/${pullRequest.number}/head`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, yeah, and this is guaranteed to be defined because we gate on this.state.typename up above. 👍

HEART: '❤️',
};

export default class EmojiReactionsView extends React.Component {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhh you extracted this from IssueishDetailView? Yesss 💯

issue={issue}
switchToIssueish={this.props.switchToIssueish}
/>
</Fragment>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So clean

so clean

lib/views/pr-detail-view.js Outdated Show resolved Hide resolved
@@ -240,32 +193,32 @@ export class BareIssueishDetailView extends React.Component {
/>
</div>
</div>
{isPr && this.renderPrMetadata(issueish, repo)}
{this.renderPrMetadata(pullRequest, repo)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting rid of all of this conditional rendering is great.

@@ -317,7 +270,7 @@ export class BareIssueishDetailView extends React.Component {
}

recordOpenInBrowserEvent() {
addEvent('open-issueish-in-browser', {package: 'github', from: 'issueish-header'});
addEvent('open-pull-request-in-browser', {package: 'github', component: this.constructor.name});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, cool, we get better granularity on these telemetry events, too.

Do we need to update anything or let @telliott27 know that this event name is changing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gooood question. I was just thinking about that during our meeting this morning.

@telliott27 : will this break the existing dashboard queries?

@@ -34,9 +34,11 @@ export function issueishDetailControllerProps(opts, overrides = {}) {
repositoryName: 'repository',
ownerLogin: 'owner',

omitIssueish: false,
omitPullRequestData: false,
omitIssueData: false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Speaking as the one who put them there, I don't love these factories, btw 💔. I'm not sure what a decent alternative to constructing these complicated prop structures that Relay gives us is, though. More builders instead... ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, this one is especially bad because to render an issue to test, you still need pull request data with a typename of Issue. I also couldn't think of a better way to handle it, though.

Tilde Ann Thurium added 6 commits December 5, 2018 12:40
`componentDidMount` is deprecated, oops.

Thought about using memoize-one, but we're memoizing to avoid a lengthly 
chained lookup in code, rather than because it's an expensive 
computation, so having a memoization helper lib isn't actually all that 
useful here.
somehow these didn't show up in my in editor linting?  IDK.
@annthurium annthurium merged commit 1a1a315 into master Dec 5, 2018
Stability Sprint : 20 November 2018 - 8 January 2019 : v0.24.0 automation moved this from QA Review 🔬 to Merged ☑️ Dec 5, 2018
@annthurium annthurium deleted the tt-18-nov-split-component branch December 5, 2018 22:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

5 participants