Skip to content

Commit

Permalink
Move New Project link to header nav (refined-github#992)
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante authored and sindresorhus committed Jan 14, 2018
1 parent 7fd3c55 commit 3a01136
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 26 deletions.
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ GitHub Enterprise is also supported. More info in the options.
- Removes annoying hover effect in the repo file browser
- Hides unnecessary buttons from the comment box toolbar (each has a keyboard shortcut)
- Removes obvious tooltips
- Removes the "Projects" repo tab when there are no projects (New projects can be created on the "Settings" tab)
- Removes the "Projects" repo tab when there are no projects (New projects can be created via the ["Create new…" menu](https://user-images.githubusercontent.com/1402241/34909214-18b6fb2e-f8cf-11e7-8556-bed748596d3b.png))

### UI improvements

Expand Down
5 changes: 0 additions & 5 deletions source/content.css
Original file line number Diff line number Diff line change
Expand Up @@ -555,11 +555,6 @@ div.inline-comment-form .form-actions,
float: none;
}

/* "Add a Project" button */
#refined-github-project-new-link {
margin-top: 5px;
}

/* Decrease the size of the search box to fit 'Yours' menu item */
.subnav-search-input[aria-label='Search all issues'] {
width: 420px;
Expand Down
5 changes: 0 additions & 5 deletions source/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import addDiffViewWithoutWhitespaceOption from './features/add-diff-view-without
import preserveWhitespaceOptionInNav from './features/preserve-whitespace-option-in-nav';
import addMilestoneNavigation from './features/add-milestone-navigation';
import addFilterCommentsByYou from './features/add-filter-comments-by-you';
import addProjectNewLink from './features/add-project-new-link';
import removeProjectsTab from './features/remove-projects-tab';
import fixSquashAndMergeTitle from './features/fix-squash-and-merge-title';
import addTitleToEmojis from './features/add-title-to-emojis';
Expand Down Expand Up @@ -226,10 +225,6 @@ function ajaxedPagesHandler() {
enableFeature(addFileCopyButton);
}

if (pageDetect.isRepoSettings()) {
enableFeature(addProjectNewLink);
}

if (pageDetect.isUserProfile()) {
enableFeature(addGistsLink);
}
Expand Down
13 changes: 0 additions & 13 deletions source/features/add-project-new-link.js

This file was deleted.

25 changes: 23 additions & 2 deletions source/features/remove-projects-tab.js
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();
}
}

0 comments on commit 3a01136

Please sign in to comment.