Merge pull request #2787 from gitlabhq/features/projects_page
Feature: Projects page
This commit is contained in:
commit
e3c3c67b25
17 changed files with 129 additions and 49 deletions
|
@ -1,26 +1,15 @@
|
|||
class DashboardController < ApplicationController
|
||||
respond_to :html
|
||||
|
||||
before_filter :projects
|
||||
before_filter :event_filter, only: :index
|
||||
before_filter :load_projects
|
||||
before_filter :event_filter, only: :show
|
||||
|
||||
def index
|
||||
def show
|
||||
@groups = current_user.authorized_groups
|
||||
|
||||
@has_authorized_projects = @projects.count > 0
|
||||
|
||||
@projects = case params[:scope]
|
||||
when 'personal' then
|
||||
@projects.personal(current_user)
|
||||
when 'joined' then
|
||||
@projects.joined(current_user)
|
||||
else
|
||||
@projects
|
||||
end
|
||||
|
||||
@teams = current_user.authorized_teams
|
||||
|
||||
@projects = @projects.page(params[:page]).per(30)
|
||||
@projects_count = @projects.count
|
||||
@projects = @projects.limit(20)
|
||||
|
||||
@events = Event.in_projects(current_user.authorized_projects.pluck(:id))
|
||||
@events = @event_filter.apply_filter(@events)
|
||||
|
@ -35,6 +24,19 @@ class DashboardController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def projects
|
||||
@projects = case params[:scope]
|
||||
when 'personal' then
|
||||
@projects.personal(current_user)
|
||||
when 'joined' then
|
||||
@projects.joined(current_user)
|
||||
else
|
||||
@projects
|
||||
end
|
||||
|
||||
@projects = @projects.page(params[:page]).per(30)
|
||||
end
|
||||
|
||||
# Get authored or assigned open merge requests
|
||||
def merge_requests
|
||||
@merge_requests = current_user.cared_merge_requests
|
||||
|
@ -57,7 +59,7 @@ class DashboardController < ApplicationController
|
|||
|
||||
protected
|
||||
|
||||
def projects
|
||||
def load_projects
|
||||
@projects = current_user.authorized_projects.sorted_by_activity
|
||||
end
|
||||
|
||||
|
|
|
@ -9,9 +9,9 @@ module DashboardHelper
|
|||
|
||||
case entity
|
||||
when 'issue' then
|
||||
dashboard_issues_path(options)
|
||||
issues_dashboard_path(options)
|
||||
when 'merge_request'
|
||||
dashboard_merge_requests_path(options)
|
||||
merge_requests_dashboard_path(options)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -55,7 +55,9 @@ module ProjectsHelper
|
|||
|
||||
def project_title project
|
||||
if project.group
|
||||
project.name_with_namespace
|
||||
content_tag :span do
|
||||
link_to(project.group.name, group_path(project.group)) + " / " + project.name
|
||||
end
|
||||
else
|
||||
project.name
|
||||
end
|
||||
|
|
|
@ -2,19 +2,12 @@
|
|||
%h5.title
|
||||
Projects
|
||||
%small
|
||||
(#{projects.total_count})
|
||||
(#{@projects_count})
|
||||
- if current_user.can_create_project?
|
||||
%span.right
|
||||
= link_to new_project_path, class: "btn very_small info" do
|
||||
%i.icon-plus
|
||||
New Project
|
||||
%ul.nav.nav-projects-tabs
|
||||
= nav_tab :scope, nil do
|
||||
= link_to "All", dashboard_path
|
||||
= nav_tab :scope, 'personal' do
|
||||
= link_to "Personal", dashboard_path(scope: 'personal')
|
||||
= nav_tab :scope, 'joined' do
|
||||
= link_to "Joined", dashboard_path(scope: 'joined')
|
||||
|
||||
%ul.well-list
|
||||
- projects.each do |project|
|
||||
|
@ -33,4 +26,6 @@
|
|||
- if projects.blank?
|
||||
%li
|
||||
%h3.nothing_here_message There are no projects here.
|
||||
.bottom= paginate projects, theme: "gitlab"
|
||||
- if @projects_count > 20
|
||||
%li.bottom
|
||||
%strong= link_to "show all projects", projects_dashboard_path
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
xml.instruct!
|
||||
xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do
|
||||
xml.title "#{current_user.name} issues"
|
||||
xml.link :href => dashboard_issues_url(:atom, :private_token => current_user.private_token), :rel => "self", :type => "application/atom+xml"
|
||||
xml.link :href => dashboard_issues_url(:private_token => current_user.private_token), :rel => "alternate", :type => "text/html"
|
||||
xml.id dashboard_issues_url(:private_token => current_user.private_token)
|
||||
xml.link :href => issues_dashboard_url(:atom, :private_token => current_user.private_token), :rel => "self", :type => "application/atom+xml"
|
||||
xml.link :href => issues_dashboard_url(:private_token => current_user.private_token), :rel => "alternate", :type => "text/html"
|
||||
xml.id issues_dashboard_url(:private_token => current_user.private_token)
|
||||
xml.updated @issues.first.created_at.strftime("%Y-%m-%dT%H:%M:%SZ") if @issues.any?
|
||||
|
||||
@issues.each do |issue|
|
||||
|
|
56
app/views/dashboard/projects.html.haml
Normal file
56
app/views/dashboard/projects.html.haml
Normal file
|
@ -0,0 +1,56 @@
|
|||
%h3.page_title
|
||||
Projects
|
||||
%span
|
||||
(#{@projects.total_count})
|
||||
- if current_user.can_create_project?
|
||||
%span.right
|
||||
= link_to new_project_path, class: "btn very_small info" do
|
||||
%i.icon-plus
|
||||
New Project
|
||||
|
||||
|
||||
%hr
|
||||
.row
|
||||
.span3
|
||||
%ul.nav.nav-pills.nav-stacked
|
||||
= nav_tab :scope, nil do
|
||||
= link_to "All", projects_dashboard_path
|
||||
= nav_tab :scope, 'personal' do
|
||||
= link_to "Personal", projects_dashboard_path(scope: 'personal')
|
||||
= nav_tab :scope, 'joined' do
|
||||
= link_to "Joined", projects_dashboard_path(scope: 'joined')
|
||||
|
||||
.span9
|
||||
= form_tag projects_dashboard_path, method: 'get' do
|
||||
%fieldset.dashboard-search-filter
|
||||
= hidden_field_tag "scope", params[:scope]
|
||||
= search_field_tag "search", params[:search], { placeholder: 'Search', class: 'left input-xxlarge' }
|
||||
= button_tag type: 'submit', class: 'btn' do
|
||||
%i.icon-search
|
||||
|
||||
%ul.well-list
|
||||
- @projects.each do |project|
|
||||
%li.clearfix
|
||||
.left
|
||||
= link_to project_path(project), class: dom_class(project) do
|
||||
- if project.namespace
|
||||
= project.namespace.human_name
|
||||
\/
|
||||
%strong.well-title
|
||||
= truncate(project.name, length: 25)
|
||||
%br
|
||||
%small.light
|
||||
%strong Last activity:
|
||||
%span= project_last_activity(project)
|
||||
.right.light
|
||||
- if project.owner == current_user
|
||||
%i.icon-wrench
|
||||
- tm = project.team.get_tm(current_user.id)
|
||||
- if tm
|
||||
= tm.project_access_human
|
||||
|
||||
- if @projects.blank?
|
||||
%li
|
||||
%h3.nothing_here_message There are no projects here.
|
||||
.bottom= paginate @projects, theme: "gitlab"
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
xml.instruct!
|
||||
xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do
|
||||
xml.title "#{@user.name} issues"
|
||||
xml.link :href => dashboard_issues_url(:atom, :private_token => @user.private_token), :rel => "self", :type => "application/atom+xml"
|
||||
xml.link :href => dashboard_issues_url(:private_token => @user.private_token), :rel => "alternate", :type => "text/html"
|
||||
xml.id dashboard_issues_url(:private_token => @user.private_token)
|
||||
xml.link :href => issues_dashboard_url(:atom, :private_token => @user.private_token), :rel => "self", :type => "application/atom+xml"
|
||||
xml.link :href => issues_dashboard_url(:private_token => @user.private_token), :rel => "alternate", :type => "text/html"
|
||||
xml.id issues_dashboard_url(:private_token => @user.private_token)
|
||||
xml.updated @issues.first.created_at.strftime("%Y-%m-%dT%H:%M:%SZ") if @issues.any?
|
||||
|
||||
@issues.each do |issue|
|
||||
|
|
|
@ -6,14 +6,17 @@
|
|||
= render "layouts/head_panel", title: "Dashboard"
|
||||
.container
|
||||
%ul.main_menu
|
||||
= nav_link(path: 'dashboard#index', html_options: {class: 'home'}) do
|
||||
= nav_link(path: 'dashboard#show', html_options: {class: 'home'}) do
|
||||
= link_to "Home", root_path, title: "Home"
|
||||
= nav_link(path: 'dashboard#projects') do
|
||||
= link_to projects_dashboard_path do
|
||||
Projects
|
||||
= nav_link(path: 'dashboard#issues') do
|
||||
= link_to dashboard_issues_path do
|
||||
= link_to issues_dashboard_path do
|
||||
Issues
|
||||
%span.count= current_user.assigned_issues.opened.count
|
||||
= nav_link(path: 'dashboard#merge_requests') do
|
||||
= link_to dashboard_merge_requests_path do
|
||||
= link_to merge_requests_dashboard_path do
|
||||
Merge Requests
|
||||
%span.count= current_user.cared_merge_requests.opened.count
|
||||
= nav_link(path: 'search#show') do
|
||||
|
|
|
@ -118,9 +118,13 @@ Gitlab::Application.routes.draw do
|
|||
#
|
||||
# Dashboard Area
|
||||
#
|
||||
get "dashboard" => "dashboard#index"
|
||||
get "dashboard/issues" => "dashboard#issues"
|
||||
get "dashboard/merge_requests" => "dashboard#merge_requests"
|
||||
resource :dashboard, controller: "dashboard" do
|
||||
member do
|
||||
get :projects
|
||||
get :issues
|
||||
get :merge_requests
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
# Groups Area
|
||||
|
@ -284,5 +288,5 @@ Gitlab::Application.routes.draw do
|
|||
end
|
||||
end
|
||||
|
||||
root to: "dashboard#index"
|
||||
root to: "dashboard#show"
|
||||
end
|
||||
|
|
8
features/dashboard/projects.feature
Normal file
8
features/dashboard/projects.feature
Normal file
|
@ -0,0 +1,8 @@
|
|||
Feature: Dashboard
|
||||
Background:
|
||||
Given I sign in as a user
|
||||
And I own project "Shop"
|
||||
And I visit dashboard projects page
|
||||
|
||||
Scenario: I should see issues list
|
||||
Then I should see projects list
|
|
@ -63,6 +63,12 @@ class Dashboard < Spinach::FeatureSteps
|
|||
@project.team << [current_user, :master]
|
||||
end
|
||||
|
||||
Then 'I should see projects list' do
|
||||
@user.authorized_projects.all.each do |project|
|
||||
page.should have_link project.name_with_namespace
|
||||
end
|
||||
end
|
||||
|
||||
Then 'I should see groups list' do
|
||||
Group.all.each do |group|
|
||||
page.should have_link group.name
|
||||
|
|
|
@ -33,12 +33,16 @@ module SharedPaths
|
|||
visit dashboard_path
|
||||
end
|
||||
|
||||
Given 'I visit dashboard projects page' do
|
||||
visit projects_dashboard_path
|
||||
end
|
||||
|
||||
Given 'I visit dashboard issues page' do
|
||||
visit dashboard_issues_path
|
||||
visit issues_dashboard_path
|
||||
end
|
||||
|
||||
Given 'I visit dashboard merge requests page' do
|
||||
visit dashboard_merge_requests_path
|
||||
visit merge_requests_dashboard_path
|
||||
end
|
||||
|
||||
Given 'I visit dashboard search page' do
|
||||
|
|
|
@ -10,7 +10,7 @@ describe "Dashboard Issues Feed" do
|
|||
|
||||
describe "atom feed" do
|
||||
it "should render atom feed via private token" do
|
||||
visit dashboard_issues_path(:atom, private_token: user.private_token)
|
||||
visit issues_dashboard_path(:atom, private_token: user.private_token)
|
||||
|
||||
page.response_headers['Content-Type'].should have_content("application/atom+xml")
|
||||
page.body.should have_selector("title", text: "#{user.name} issues")
|
||||
|
|
|
@ -146,14 +146,14 @@ describe KeysController, "routing" do
|
|||
end
|
||||
end
|
||||
|
||||
# dashboard GET /dashboard(.:format) dashboard#index
|
||||
# dashboard GET /dashboard(.:format) dashboard#show
|
||||
# dashboard_issues GET /dashboard/issues(.:format) dashboard#issues
|
||||
# dashboard_merge_requests GET /dashboard/merge_requests(.:format) dashboard#merge_requests
|
||||
# root / dashboard#index
|
||||
# root / dashboard#show
|
||||
describe DashboardController, "routing" do
|
||||
it "to #index" do
|
||||
get("/dashboard").should route_to('dashboard#index')
|
||||
get("/").should route_to('dashboard#index')
|
||||
get("/dashboard").should route_to('dashboard#show')
|
||||
get("/").should route_to('dashboard#show')
|
||||
end
|
||||
|
||||
it "to #issues" do
|
||||
|
|
Loading…
Reference in a new issue