Commit 0948d031 authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch 'project-page-clearer' into 'master'

Add context tabs to dashboard/projects

Closes #29045

See merge request gitlab-org/gitlab-ce!14364
parents 6c57d894 8eb2d741
...@@ -239,8 +239,8 @@ module ProjectsHelper ...@@ -239,8 +239,8 @@ module ProjectsHelper
end end
end end
def has_projects_or_name?(projects, params) def show_projects?(projects, params)
!!(params[:name] || any_projects?(projects)) !!(params[:personal] || params[:name] || any_projects?(projects))
end end
private private
......
.top-area
%ul.nav-links
= nav_link(html_options: { class: ("active" unless params[:personal].present?) }) do
= link_to s_('DashboardProjects|All'), dashboard_projects_path
= nav_link(html_options: { class: ("active" if params[:personal].present?) }) do
= link_to s_('DashboardProjects|Personal'), filter_projects_path(personal: true)
...@@ -10,8 +10,9 @@ ...@@ -10,8 +10,9 @@
= render "projects/last_push" = render "projects/last_push"
%div{ class: container_class } %div{ class: container_class }
- if has_projects_or_name?(@projects, params) - if show_projects?(@projects, params)
= render 'dashboard/projects_head' = render 'dashboard/projects_head'
= render 'nav'
= render 'projects' = render 'projects'
- else - else
= render "zero_authorized_projects" = render "zero_authorized_projects"
---
title: Added tabs to dashboard/projects to easily switch to personal projects
merge_request:
author:
type: added
...@@ -50,6 +50,25 @@ feature 'Dashboard Projects' do ...@@ -50,6 +50,25 @@ feature 'Dashboard Projects' do
end end
end end
context 'when on Your projects tab' do
it 'shows all projects by default' do
visit dashboard_projects_path
expect(page).to have_content(project.name)
end
it 'shows personal projects on personal projects tab', :js do
project3 = create(:project, namespace: user.namespace)
visit dashboard_projects_path
click_link 'Personal'
expect(page).not_to have_content(project.name)
expect(page).to have_content(project3.name)
end
end
context 'when on Starred projects tab' do context 'when on Starred projects tab' do
it 'shows only starred projects' do it 'shows only starred projects' do
user.toggle_star(project2) user.toggle_star(project2)
......
...@@ -420,22 +420,26 @@ describe ProjectsHelper do ...@@ -420,22 +420,26 @@ describe ProjectsHelper do
end end
end end
describe '#has_projects_or_name?' do describe '#show_projects' do
let(:projects) do let(:projects) do
create(:project) create(:project)
Project.all Project.all
end end
it 'returns true when there are projects' do it 'returns true when there are projects' do
expect(helper.has_projects_or_name?(projects, {})).to eq(true) expect(helper.show_projects?(projects, {})).to eq(true)
end end
it 'returns true when there are no projects but a name is given' do it 'returns true when there are no projects but a name is given' do
expect(helper.has_projects_or_name?(Project.none, name: 'foo')).to eq(true) expect(helper.show_projects?(Project.none, name: 'foo')).to eq(true)
end
it 'returns true when there are no projects but personal is present' do
expect(helper.show_projects?(Project.none, personal: 'true')).to eq(true)
end end
it 'returns false when there are no projects and there is no name' do it 'returns false when there are no projects and there is no name' do
expect(helper.has_projects_or_name?(Project.none, {})).to eq(false) expect(helper.show_projects?(Project.none, {})).to eq(false)
end end
end end
......
require 'spec_helper'
describe 'dashboard/projects/_nav.html.haml' do
it 'highlights All tab by default' do
render
expect(rendered).to have_css('li.active a', text: 'All')
end
it 'highlights Personal tab personal param is present' do
controller.params[:personal] = true
render
expect(rendered).to have_css('li.active a', text: 'Personal')
end
end
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