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

Handle ghost users (deleted accounts) #2100

Merged
merged 31 commits into from
May 1, 2019
Merged

Conversation

kuychaco
Copy link
Contributor

Please be sure to read the contributor's guide to the GitHub package before submitting any pull requests.

Requirements

  • Filling out the template is required. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion.
  • Suggestion: You can use checklists to keep track of progress for the sections on metrics, tests, documentation, and user research.

Description of the Change

This PR introduces changes to handle ghost users throughout our UI. When a user account has been deleted, activity by them is replaced to be a "Deleted user" account -- https://github.com/ghost

Prior to this change, users were seeing errors thrown when looking up properties on a null user.

To address this, I created a GHOST_USER object in our lib/helpers.js file and used it throughout the codebase when we'd get back null from the GitHub graphql API.

export const GHOST_USER = {
  login: 'ghost',
  avatarUrl: 'https://avatars1.githubusercontent.com/u/10137?v=4',
  url: 'https://github.com/ghost',
};

Screenshot/Gif

N/A

Alternate Designs

N/A

Benefits

No more errors!

Possible Drawbacks

None.

Applicable Issues

Fixes #2014
Fixes #1921

Metrics

N/A

Tests

TODO

Documentation

N/A

Release Notes

Handle ghost users (deleted accounts) throughout the GitHub integration UI

User Experience Research (Optional)

N/A

@kuychaco kuychaco self-assigned this Apr 25, 2019
@kuychaco kuychaco changed the title Ku handle ghost users Handle ghost users Apr 25, 2019
@kuychaco kuychaco changed the title Handle ghost users Handle ghost users (deleted accounts) Apr 25, 2019
@codecov
Copy link

codecov bot commented Apr 26, 2019

Codecov Report

Merging #2100 into master will increase coverage by 0.05%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2100      +/-   ##
==========================================
+ Coverage   92.59%   92.65%   +0.05%     
==========================================
  Files         207      207              
  Lines       12036    12045       +9     
  Branches     1755     1764       +9     
==========================================
+ Hits        11145    11160      +15     
+ Misses        891      885       -6
Impacted Files Coverage Δ
...ainers/accumulators/review-comments-accumulator.js 100% <ø> (ø) ⬆️
lib/controllers/issueish-list-controller.js 100% <ø> (ø) ⬆️
...iners/accumulators/review-summaries-accumulator.js 100% <ø> (ø) ⬆️
lib/views/reviews-view.js 83.23% <100%> (ø) ⬆️
lib/helpers.js 90% <100%> (+0.04%) ⬆️
lib/views/timeline-items/commit-comment-view.js 100% <100%> (ø) ⬆️
lib/views/timeline-items/issue-comment-view.js 100% <100%> (ø) ⬆️
lib/containers/issueish-tooltip-container.js 100% <100%> (+85.71%) ⬆️
lib/models/issueish.js 83.78% <100%> (+0.45%) ⬆️
lib/views/pr-detail-view.js 100% <100%> (ø) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cf10092...5005ecb. Read the comment docs.

kuychaco and others added 16 commits April 29, 2019 12:17
... and not locally 🤔
React (and Relay) discourage you from modifying objects that are passed 
to components as props: 
https://reactjs.org/docs/components-and-props.html#props-are-read-only. 
The "data" passed to the Issueish constructor is sent directly from the 
props passed to IssueishListController, so we should treat them as 
immutable.

I thought that React froze objects passed as props in development mode 
to catch these issues. That's what's failing on CI - I have no idea why 
it isn't failing locally for us.
@kuychaco kuychaco marked this pull request as ready for review May 1, 2019 19:43
@kuychaco kuychaco requested a review from smashwilson May 1, 2019 19:44
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.

✨ A few random comments, no blockers. Thanks for taking care of this! It annoyed the hell out of me every time I did anything in find-and-replace 😆

@@ -67,6 +67,7 @@ export default createPaginationContainer(BareReviewCommentsAccumulator, {
author {
avatarUrl
login
url
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh interesting, we were just URL-hacking this in before? Yeah, much cleaner to get it from GraphQL 👍

@@ -18,7 +18,7 @@ export const IssueBuilder = createSpecBuilderClass('Issue', {
number: {default: 123},
state: {default: 'OPEN'},
bodyHTML: {default: '<h1>HI</h1>'},
author: {linked: UserBuilder},
author: {linked: UserBuilder, default: null},
Copy link
Contributor

Choose a reason for hiding this comment

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

I really like defaulting these to null in the builder. This way we'll catch anywhere that an author is fetched from GraphQL but we don't account for it being nullable 👍

@@ -32,7 +32,7 @@ export const CommitBuilder = createSpecBuilderClass('Commit', {

export const CommitCommentBuilder = createSpecBuilderClass('CommitComment', {
id: {default: nextID},
author: {linked: UserBuilder},
author: {linked: UserBuilder, default: null},
Copy link
Contributor

Choose a reason for hiding this comment

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

You could add nullable: true here too. All that really does is let you use the .nullAuthor() function on the generated builder, though, which is functionally equivalent to .author(null).

@@ -61,7 +61,7 @@ export const HeadRefForcePushedEventBuilder = createSpecBuilderClass('HeadRefFor
}, 'Node');

export const IssueCommentBuilder = createSpecBuilderClass('IssueComment', {
author: {linked: UserBuilder},
author: {linked: UserBuilder, default: null},
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here ☝️

@@ -6,6 +6,7 @@ export function createCommitComment(opts = {}) {
const o = {
id: idGen.generate('comment-comment'),
commitOid: '1234abcd',
includeAuthor: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

I've been trying to phase out these test/fixtures/factories methods in favor of GraphQL builders - the GraphQL builders are easier to write against (the builder structure maps directly to the query!) and they keep up with changes to our queries and the schema. It's tedious as hell, though, so I don't blame you for patching this in 😛

Co-Authored-By: Ash Wilson <smashwilson@gmail.com>
@kuychaco kuychaco merged commit 9b569d0 into master May 1, 2019
@kuychaco kuychaco deleted the ku-handle-ghost-users branch May 1, 2019 21:58
smashwilson pushed a commit that referenced this pull request May 8, 2019
Handle ghost users (deleted accounts)
This was referenced May 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Non-existent (Ghost) users Pull Requests crash Github tab Stack trace on opening GitHub tab
2 participants