Commit cddc5047 authored by Douwe Maan's avatar Douwe Maan

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
parents 220a5c37 3b462b45
...@@ -36,7 +36,8 @@ module PreferencesHelper ...@@ -36,7 +36,8 @@ module PreferencesHelper
def project_view_choices def project_view_choices
[ [
['Files and Readme (default)', :files], ['Files and Readme (default)', :files],
['Activity', :activity] ['Activity', :activity],
['Readme', :readme]
] ]
end end
......
...@@ -182,13 +182,8 @@ class User < ActiveRecord::Base ...@@ -182,13 +182,8 @@ class User < ActiveRecord::Base
enum dashboard: [:projects, :stars, :project_activity, :starred_project_activity, :groups, :todos] enum dashboard: [:projects, :stars, :project_activity, :starred_project_activity, :groups, :todos]
# User's Project preference # User's Project preference
# # Note: When adding an option, it MUST go on the end of the array.
# Note: When adding an option, it MUST go on the end of the hash with a enum project_view: [:readme, :activity, :files]
# 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 }
alias_attribute :private_token, :authentication_token alias_attribute :private_token, :authentication_token
......
- 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.
---
title: Add readme only option as project view
merge_request: 14900
author:
type: changed
...@@ -222,6 +222,14 @@ describe ProjectsController do ...@@ -222,6 +222,14 @@ describe ProjectsController do
get :show, namespace_id: public_project.namespace, id: public_project get :show, namespace_id: public_project.namespace, id: public_project
expect(response).to render_template('_files') expect(response).to render_template('_files')
end end
it "renders the readme view" do
allow(controller).to receive(:current_user).and_return(user)
allow(user).to receive(:project_view).and_return('readme')
get :show, namespace_id: public_project.namespace, id: public_project
expect(response).to render_template('_readme')
end
end end
context "when the url contains .atom" do context "when the url contains .atom" do
......
...@@ -5,12 +5,7 @@ require Rails.root.join('db', 'post_migrate', '20170406142253_migrate_user_proje ...@@ -5,12 +5,7 @@ require Rails.root.join('db', 'post_migrate', '20170406142253_migrate_user_proje
describe MigrateUserProjectView, :truncate do describe MigrateUserProjectView, :truncate do
let(:migration) { described_class.new } let(:migration) { described_class.new }
let!(:user) { create(:user) } let!(:user) { create(:user, project_view: 'readme') }
before do
# 0 is the numeric value for the old 'readme' option
user.update_column(:project_view, 0)
end
describe '#up' do describe '#up' do
it 'updates project view setting with new value' do it 'updates project view setting with new value' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment