forked from refined-github/refined-github
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move New Project link to header nav (refined-github#992)
- Loading branch information
1 parent
7fd3c55
commit 3a01136
Showing
5 changed files
with
24 additions
and
26 deletions.
There are no files selected for viewing
This file contains 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 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 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 was deleted.
Oops, something went wrong.
This file contains 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 |
---|---|---|
@@ -1,8 +1,29 @@ | ||
import {h} from 'dom-chef'; | ||
import select from 'select-dom'; | ||
import onetime from 'onetime'; | ||
import * as pageDetect from '../libs/page-detect'; | ||
|
||
export default function () { | ||
const projectsTab = select('.js-repo-nav .reponav-item[data-selected-links^="repo_projects"]'); | ||
const removeProjectsTab = () => { | ||
const projectsTab = select('.js-repo-nav [data-selected-links^="repo_projects"]'); | ||
if (projectsTab && projectsTab.querySelector('.Counter, .counter').textContent === '0') { | ||
projectsTab.remove(); | ||
return true; | ||
} | ||
}; | ||
|
||
const addNewProjectLink = onetime(() => { | ||
const newIssueLink = select('.HeaderMenu .dropdown-item[href$="/issues/new"]'); | ||
if (newIssueLink) { | ||
newIssueLink.after( | ||
<a class="dropdown-item" href={`/${pageDetect.getRepoURL()}/projects/new`}> | ||
New project | ||
</a> | ||
); | ||
} | ||
}); | ||
|
||
export default function () { | ||
if (removeProjectsTab()) { | ||
addNewProjectLink(); | ||
} | ||
} |