Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub components for Repos, Issues, PullRequests #2367

Closed
wants to merge 15 commits into from

Conversation

menghif
Copy link
Contributor

@menghif menghif commented Oct 18, 2021

Issue This PR Addresses

Fixes #2360

Type of Change

  • Bugfix: Change which fixes an issue
  • New Feature: Change which adds functionality
  • Documentation Update: Change which improves documentation
  • UI: Change which improves UI

Description

This PR adds a way to display links for all GitHub repos, issues and pull requests that are linked throughout a post. This information is displayed on the right sidebar underneath the blog post's date for easy visibility.

If there is no repo URL in the post, but there is at least one issue or PR, the repo URL will be taken from that issue or PR.

Screenshots:

Screenshot 2021-10-18 at 17-50-30 Search Telescope


Screenshot 2021-10-18 at 18-00-49 Telescope

Checklist

  • Quality: This PR builds and passes our npm test and works locally
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Screenshots: This PR includes screenshots or GIFs of the changes made or an explanation of why it does not (if applicable)
  • Documentation: This PR includes updated/added documentation to user exposed functionality or configuration variables are added/changed or an explanation of why it does not(if applicable)

@humphd
Copy link
Contributor

humphd commented Oct 18, 2021

Let's reduce vertical space between rows:

Screen Shot 2021-10-18 at 6 20 24 PM

@menghif
Copy link
Contributor Author

menghif commented Oct 18, 2021

How do I fix this?

Screen.Recording.2021-10-18.at.6.19.30.PM.mov

@humphd
Copy link
Contributor

humphd commented Oct 18, 2021

How do I fix this?

I can't see what you're talking about

@humphd
Copy link
Contributor

humphd commented Oct 18, 2021

@Andrewnt219, can you review this too please?

@menghif
Copy link
Contributor Author

menghif commented Oct 18, 2021

The github info goes over the title and date when I scroll to the bottom of the post.

@menghif
Copy link
Contributor Author

menghif commented Oct 18, 2021

Also I just realized I swapped the icons for Repos and Pull Requests 😬 Fixed now!

Copy link
Contributor

@humphd humphd left a comment

Choose a reason for hiding this comment

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

I'm loving this. A few things I notice on first read.

src/web/src/components/Posts/GitHubInfo.tsx Outdated Show resolved Hide resolved
src/web/src/components/Posts/GitHubInfo.tsx Outdated Show resolved Hide resolved
src/web/src/components/Posts/Issues.tsx Show resolved Hide resolved
src/web/src/components/Posts/Issues.tsx Show resolved Hide resolved
src/web/src/components/Posts/Issues.tsx Outdated Show resolved Hide resolved
@manekenpix
Copy link
Member

Issue with long names (check the repo)

image

@humphd
Copy link
Contributor

humphd commented Oct 19, 2021

Issue with long names (check the repo)

I noticed this too. One question I had: should we only show the repo name and not the owner? So Seneca-CDOT/telescope might show as telescope unless you hover and the title can show the whole thing? Not sure if that's good or bad, but it would help with this a bit.

@Andrewnt219
Copy link
Contributor

Issue with long names (check the repo)

image

This may be a problem with Safari. Doesn't happen on Firefox or Chrome on Window.

Add title attrbute to Issues and PRs
Simplify regex to get Issue/PR number
Add title attrbute to Repo: "user/repo"
Remove user from repo name displayed
@menghif
Copy link
Contributor Author

menghif commented Oct 19, 2021

Issue with long names (check the repo)

I noticed this too. One question I had: should we only show the repo name and not the owner? So Seneca-CDOT/telescope might show as telescope unless you hover and the title can show the whole thing? Not sure if that's good or bad, but it would help with this a bit.

I tried this and it looks better in my opinion. You can check the last deployment:
https://telescope-jt4xjjrp2-humphd.vercel.app/

Copy link
Contributor

@humphd humphd left a comment

Choose a reason for hiding this comment

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

I left some more feedback. Feel free to break the work up a bit, and file follow-up issues that we can work on vs. feeling like we have to get this perfect before we can merge. I'd be happy to take it as-is once we get the last few edges sanded down.

src/web/src/components/Posts/GitHubInfo.tsx Outdated Show resolved Hide resolved
src/web/src/components/Posts/GitHubInfo.tsx Outdated Show resolved Hide resolved
src/web/src/components/Posts/Issues.tsx Show resolved Hide resolved
src/web/src/components/Posts/PullRequests.tsx Show resolved Hide resolved
@Andrewnt219
Copy link
Contributor

Andrewnt219 commented Oct 19, 2021

Also notice this. They're forked repos.

image

@humphd
Copy link
Contributor

humphd commented Oct 20, 2021

I filed #2370, #2371, #2372, and #2373 for follow-up. @menghif, @Andrewnt219: anything else we're not going to do in this PR, please file as new issues that we can work on later once this goes in.

The fixes above based on @DukeManh's review could happen here I think, plus any other code changes based on subsequent reviews.

@HyperTHD
Copy link
Contributor

I just wanna confirm that the repo looking buggy when the name is long is also appearing for me on Google Chrome.

Just something to consider if and when this does get merged, since the css used here never had this idea in mind

image

@humphd
Copy link
Contributor

humphd commented Oct 21, 2021

@HyperTHD I can't reproduce, Is it a line-height issue? Yes, we need to file an issue on this one too.

@HyperTHD
Copy link
Contributor

HyperTHD commented Oct 21, 2021

@HyperTHD I can't reproduce, Is it a line-height issue? Yes, we need to file an issue on this one too.

I suspect that is the issue. Unless I'm mistaken, this code should be the issue causing this.

https://github.com/Seneca-CDOT/telescope/pull/2367/files#diff-52847b29df0db31f168773ddd4e97cc9828a6aac76a638d1096f07f751b34bc6R29

Use h2 instead of h1 for Repo, Issue and PR title.
Wrap extractGitHubUrlsFromPost into react's useMemo.
Copy link
Contributor

@humphd humphd left a comment

Choose a reason for hiding this comment

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

Really close, a few more things.

src/web/src/components/Posts/Post.tsx Outdated Show resolved Hide resolved
);

const getUserName = (repo: string) => {
return repo.replace(/\/([^\/]+).*/, '$1');
Copy link
Contributor

Choose a reason for hiding this comment

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

Get rid of { return, you don't need it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I got rid of the function all together since we don't need it for now.

{repoUrls.map((repo) => (
<p key={repo} className={classes.repo}>
<a
href={`https://github.com${repo}`}
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the repo have a leading / or not? In line 57 you assume it does, but in line 60 you assume it doesn't. We need to be consistent.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would suggest it should not have a / at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed the leading / and made the appropriate changes.

Copy link
Contributor

Choose a reason for hiding this comment

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

@humphd @menghif to be consistent, best to keep the leading slash in repo URLs. URL.pathname returns a string with a leading slash, so issues, commits, pull requests all have a leading slash.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This can be changed in #2374 if necessary.

humphd
humphd previously approved these changes Oct 21, 2021
Copy link
Contributor

@humphd humphd left a comment

Choose a reason for hiding this comment

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

Love it. Can't wait to start using this!

@humphd
Copy link
Contributor

humphd commented Oct 21, 2021

Filed #2380 to do a bit of reorg on these files later on.

@humphd
Copy link
Contributor

humphd commented Oct 21, 2021

This needs a rebase, but since it's got two authors, I'll do it for you and merge.

@humphd
Copy link
Contributor

humphd commented Oct 21, 2021

Rebased and merged in bce0b21. Great job everyone!

@humphd humphd closed this Oct 21, 2021
@menghif menghif deleted the issue-2360 branch December 8, 2021 01:46
@JiaHua-Zou JiaHua-Zou mentioned this pull request Feb 2, 2022
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add GitHub components for Repos, Issues, PullRequests
6 participants