Repository navigation
Remove the "Projects" repo tab when there are no projects - #411
Conversation
paulmolluzzo
left a comment
There was a problem hiding this comment.
A few comments, but this is on track!
|
|
||
| function addProjectNewLink() { | ||
| const projectNewLink = `<a href="/${repoUrl}/projects/new" class="btn btn-sm" id="refined-github-project-new-link">Add a project</a>`; | ||
| $('#projects-feature').next('p.note').after(projectNewLink); |
There was a problem hiding this comment.
The ideal method for selecting would $.fn.nextAll():
$('#projects-feature').nextAll('p.note')I've tested it on the Settings page and it finds the needed element. We could also use a CSS selector:
$('#projects-feature ~ p.note')|
|
||
| function removeProjectsTab() { | ||
| const projectsTab = $('.js-repo-nav').find('.reponav-item[data-selected-links^="repo_projects"]'); | ||
| if (projectsTab.find('.Counter').text() === '0') { |
There was a problem hiding this comment.
We should check that the projectsTab even exists. If not the find() is going to throw an error.
| const projectNewLinkId = 'refined-github-project-new-link'; | ||
| const projectNewLink = `<a href="/${repoUrl}/projects/new" class="btn btn-sm" id="${projectNewLinkId}">Add a project</a>`; | ||
| if ($(`#${projectNewLinkId}`).length === 0) { | ||
| $('#projects-feature').siblings('p.note').after(projectNewLink); |
There was a problem hiding this comment.
@lukaszklis @paulmolluzzo Please see my other comment: #411 (comment) I've posted it just after your commit.
Pasting it here:
The ideal method for selecting would $.fn.nextAll():
$('#projects-feature').nextAll('p.note')I've tested it on the Settings page and it finds the needed element. We could also use a CSS selector:
$('#projects-feature ~ p.note')There was a problem hiding this comment.
Okay, in this case I think it will be better to go with the CSS selector. Seems to be more consistent with other places where we try to achieve a similar effect.
| function addProjectNewLink() { | ||
| const projectNewLinkId = 'refined-github-project-new-link'; | ||
| const projectNewLink = `<a href="/${repoUrl}/projects/new" class="btn btn-sm" id="${projectNewLinkId}">Add a project</a>`; | ||
| if ($(`#${projectNewLinkId}`).length === 0) { |
There was a problem hiding this comment.
We'd need to add the button only if the Projects checkbox is checked. Otherwise, the link is pointing to a 404 when the Projects are not enabled. I guess we can skip adding it when you are just checking the checkbox. I don't think it's worth it.
There was a problem hiding this comment.
Re: checkbox: true that, this can prevent an unnecessary UI element for a feature which a user can decide to disable anyway. In this case we should extend the condition we use in the statement.
Just one more thing that came to my mind: what about the case when a user has some projects already? Shall we still have the button shown in the Settings page?
There was a problem hiding this comment.
Just one more thing that came to my mind: what about the case when a user has some projects already? Shall we still have the button shown in the Settings page?
I don't see why not, it will be most handy to people using Projects already anyway.
There was a problem hiding this comment.
Alright, sounds good! Will apply the changes!
|
@hkdobrev I think it will make sense for me to squash the commits before merging to master (unless there is still something you think should be improved in this PR). ;) |
|
@lukaszklis No need to squash, unless you want to do something special with interactive rebase about your commits as we're merging with the "Squash and merge" feature of GitHub. |
Dismissing as requested changes were implemented.
|
@lukaszklis Could you please resolve the conflicts in CSS? Many thanks! @paulmolluzzo @sindresorhus Any more comments on this? |
|
@hkdobrev seems like GitHub’s UI |
They are not using these settings to resolve automatically, unfortunately: |
|
|
||
| const isNotifications = () => /\/notifications(\/participating)?/.test(location.pathname); | ||
|
|
||
| const isSettings = () => isRepo() && /^\/settings/.test(getRepoPath()); |
There was a problem hiding this comment.
isRepoSettings, as isSettings is too vague. It could be user account settings.
|
Can you add it to the https://github.com/sindresorhus/refined-github#highlights section? No screenshot needed. |
39eb51f to
2aa68b0
Compare
|
@sindresorhus thank you for fixing the readme 🙇 |
|
Looks great! Thanks for working this @lukaszklis 🍰✨ |
|
🎉 and sorry for the typos 🙈 |
|
While this behavior does clean up the interface, it kept me from getting started with GitHub Projects. I wanted to create my first project and did not know why the tab was missing. |
|
Open a new issue, we should not hide them when the current user is the owner of the repo. Or better yet, send a PR if you can |

Things done as part of this PR:
Closes #309.