diff options
author | Rémy Coutable <remy@rymai.me> | 2017-05-17 14:06:14 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-05-17 14:06:14 +0000 |
commit | 42814500438bd2d9aea75cfd372ec61da0d7468d (patch) | |
tree | 6f135ca90b425cd7aa45342ed2e5ee9bbed6f23b | |
parent | 433070dc954e40c4fffdb6e675163a74290420ec (diff) | |
parent | 7844fa1fc2e54de9b36f6bb2faa6d2f3385fc4f7 (diff) | |
download | gitlab-ce-42814500438bd2d9aea75cfd372ec61da0d7468d.tar.gz |
Merge branch 'dm-contributing-viewer' into 'master'
Add auxiliary blob viewer for CONTRIBUTING
See merge request !11364
-rw-r--r-- | app/helpers/blob_helper.rb | 15 | ||||
-rw-r--r-- | app/models/blob.rb | 4 | ||||
-rw-r--r-- | app/models/blob_viewer/contributing.rb | 10 | ||||
-rw-r--r-- | app/views/projects/blob/viewers/_contributing.html.haml | 9 |
4 files changed, 37 insertions, 1 deletions
diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index 7eb3512378c..622e14e21ff 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -278,4 +278,19 @@ module BlobHelper options end + + def contribution_options(project) + options = [] + + if can?(current_user, :create_issue, project) + options << link_to("submit an issue", new_namespace_project_issue_path(project.namespace, project)) + end + + merge_project = can?(current_user, :create_merge_request, project) ? project : (current_user && current_user.fork_of(project)) + if merge_project + options << link_to("create a merge request", new_namespace_project_merge_request_path(project.namespace, project)) + end + + options + end end diff --git a/app/models/blob.rb b/app/models/blob.rb index 63a81c0e3bd..e0c539a17cf 100644 --- a/app/models/blob.rb +++ b/app/models/blob.rb @@ -39,7 +39,9 @@ class Blob < SimpleDelegator AUXILIARY_VIEWERS = [ BlobViewer::GitlabCiYml, BlobViewer::RouteMap, - BlobViewer::License + + BlobViewer::License, + BlobViewer::Contributing ].freeze attr_reader :project diff --git a/app/models/blob_viewer/contributing.rb b/app/models/blob_viewer/contributing.rb new file mode 100644 index 00000000000..fbd1dd48697 --- /dev/null +++ b/app/models/blob_viewer/contributing.rb @@ -0,0 +1,10 @@ +module BlobViewer + class Contributing < Base + include Auxiliary + include Static + + self.partial_name = 'contributing' + self.file_types = %i(contributing) + self.binary = false + end +end diff --git a/app/views/projects/blob/viewers/_contributing.html.haml b/app/views/projects/blob/viewers/_contributing.html.haml new file mode 100644 index 00000000000..c78f04c9c7c --- /dev/null +++ b/app/views/projects/blob/viewers/_contributing.html.haml @@ -0,0 +1,9 @@ += icon('book fw') +After you've reviewed these contribution guidelines, you'll be all set to + +- options = contribution_options(viewer.project) +- if options.any? + = succeed '.' do + = options.to_sentence(two_words_connector: ' or ', last_word_connector: ', or ').html_safe +- else + contribute to this project. |