diff options
author | Douwe Maan <douwe@gitlab.com> | 2017-10-18 10:54:52 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2017-10-18 10:54:52 +0000 |
commit | cddc504740eea1e017c1ce23b84c6b19044020f4 (patch) | |
tree | 2d6db7826d63a5d8f58bb91dc4854b54c3bbbe5d /app | |
parent | 220a5c375972462a3c583a106c5ca4c8a2138267 (diff) | |
parent | 3b462b457756f36142d2450eaac7cf9f3e2061ae (diff) | |
download | gitlab-ce-cddc504740eea1e017c1ce23b84c6b19044020f4.tar.gz |
Merge branch '30140-restore-readme-only-preference' into 'master'
Add readme only option as project view
Closes #30140
See merge request gitlab-org/gitlab-ce!14900
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/preferences_helper.rb | 3 | ||||
-rw-r--r-- | app/models/user.rb | 9 | ||||
-rw-r--r-- | app/views/projects/_readme.html.haml | 23 |
3 files changed, 27 insertions, 8 deletions
diff --git a/app/helpers/preferences_helper.rb b/app/helpers/preferences_helper.rb index 0d7347ed30d..8e822ed0ea2 100644 --- a/app/helpers/preferences_helper.rb +++ b/app/helpers/preferences_helper.rb @@ -36,7 +36,8 @@ module PreferencesHelper def project_view_choices [ ['Files and Readme (default)', :files], - ['Activity', :activity] + ['Activity', :activity], + ['Readme', :readme] ] end diff --git a/app/models/user.rb b/app/models/user.rb index 533a776bc65..9459b6d4fa4 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -182,13 +182,8 @@ class User < ActiveRecord::Base enum dashboard: [:projects, :stars, :project_activity, :starred_project_activity, :groups, :todos] # User's Project preference - # - # Note: When adding an option, it MUST go on the end of the hash with a - # number higher than the current max. We cannot move options and/or change - # their numbers. - # - # We skip 0 because this was used by an option that has since been removed. - enum project_view: { activity: 1, files: 2 } + # Note: When adding an option, it MUST go on the end of the array. + enum project_view: [:readme, :activity, :files] alias_attribute :private_token, :authentication_token diff --git a/app/views/projects/_readme.html.haml b/app/views/projects/_readme.html.haml new file mode 100644 index 00000000000..44aa9eb3826 --- /dev/null +++ b/app/views/projects/_readme.html.haml @@ -0,0 +1,23 @@ +- if (readme = @repository.readme) && readme.rich_viewer + %article.file-holder.readme-holder{ id: 'readme', class: ("limited-width-container" unless fluid_layout) } + .js-file-title.file-title + = blob_icon readme.mode, readme.name + = link_to project_blob_path(@project, tree_join(@ref, readme.path)) do + %strong + = readme.name + = render 'projects/blob/viewer', viewer: readme.rich_viewer, viewer_url: namespace_project_blob_path(@project.namespace, @project, tree_join(@ref, readme.path), viewer: :rich, format: :json) + +- else + .row-content-block.second-block.center + %h3.page-title + This project does not have a README yet + - if can?(current_user, :push_code, @project) + %p + A + %code README + file contains information about other files in a repository and is commonly + distributed with computer software, forming part of its documentation. + %p + We recommend you to + = link_to "add a README", add_special_file_path(@project, file_name: 'README.md'), class: 'underlined-link' + file to the repository and GitLab will render it here instead of this message. |