diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-04-10 19:49:26 +0200 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-04-11 10:51:43 +0200 |
commit | c39e3f22ce12a302e294deb3523414e4a684b6fb (patch) | |
tree | 2a0e8d4bb5c2b81ef6c8bb82758f05c52b8642fc /app/helpers/issues_helper.rb | |
parent | 04c7d0d55500e6f118bd17153f3af11e83fce826 (diff) | |
download | gitlab-ce-c39e3f22ce12a302e294deb3523414e4a684b6fb.tar.gz |
Show `New Issue` link for projects
When a user is not logged in, we want to show the `New Issue` link so
he gets directed to the login flow first.
When a project is archived, we never want to show the link.
Diffstat (limited to 'app/helpers/issues_helper.rb')
-rw-r--r-- | app/helpers/issues_helper.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 5a2f7bb01c7..96dc7ae1185 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -126,6 +126,17 @@ module IssuesHelper link_to link_text, path end + def show_new_issue_link?(project) + return false unless project + return false if project.archived? + + # We want to show the link to users that are not signed in, that way they + # get directed to the sign-in/sign-up flow and afterwards to the new issue page. + return true unless current_user + + can?(current_user, :create_issue, project) + end + # Required for Banzai::Filter::IssueReferenceFilter module_function :url_for_issue module_function :url_for_internal_issue |