summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-01-25 16:36:14 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-01-25 16:36:14 +0200
commit74e329064abc1306132dd73dcb2e25221379f568 (patch)
treec36c8646c1f90c031732f7279528a41440c0667e
parent1c88fbb3915e6d2efcac5cc2edb8d480f1112c75 (diff)
downloadgitlab-ce-74e329064abc1306132dd73dcb2e25221379f568.tar.gz
teams refactoring and cleanup pt.1
-rw-r--r--app/controllers/teams_controller.rb10
-rw-r--r--app/models/project.rb2
-rw-r--r--app/views/layouts/user_team.html.haml6
-rw-r--r--app/views/profiles/show.html.haml32
-rw-r--r--app/views/teams/_team_head.html.haml0
-rw-r--r--app/views/teams/edit.html.haml2
-rw-r--r--app/views/teams/index.html.haml38
-rw-r--r--app/views/teams/issues.html.haml2
-rw-r--r--app/views/teams/members/edit.html.haml4
-rw-r--r--app/views/teams/members/index.html.haml2
-rw-r--r--app/views/teams/members/new.html.haml2
-rw-r--r--app/views/teams/members/show.html.haml2
-rw-r--r--app/views/teams/merge_requests.html.haml2
-rw-r--r--app/views/teams/projects/edit.html.haml2
-rw-r--r--app/views/teams/projects/index.html.haml40
-rw-r--r--app/views/teams/projects/new.html.haml2
-rw-r--r--app/views/teams/search.html.haml11
-rw-r--r--app/views/teams/show.html.haml2
-rw-r--r--config/routes.rb4
19 files changed, 39 insertions, 126 deletions
diff --git a/app/controllers/teams_controller.rb b/app/controllers/teams_controller.rb
index 1ac0d5696b6..ef66b77e232 100644
--- a/app/controllers/teams_controller.rb
+++ b/app/controllers/teams_controller.rb
@@ -64,16 +64,6 @@ class TeamsController < ApplicationController
@issues = @issues.includes(:author, :project)
end
- def search
- result = SearchContext.new(user_team.project_ids, params).execute
-
- @projects = result[:projects]
- @merge_requests = result[:merge_requests]
- @issues = result[:issues]
- @wiki_pages = result[:wiki_pages]
- @teams = result[:teams]
- end
-
protected
def projects
diff --git a/app/models/project.rb b/app/models/project.rb
index ba46fea2864..e521dfc93da 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -80,7 +80,7 @@ class Project < ActiveRecord::Base
# Scopes
scope :without_user, ->(user) { where("id NOT IN (:ids)", ids: user.authorized_projects.map(&:id) ) }
scope :not_in_group, ->(group) { where("id NOT IN (:ids)", ids: group.project_ids ) }
- scope :without_team, ->(team) { where("id NOT IN (:ids)", ids: team.projects.map(&:id)) }
+ scope :without_team, ->(team) { team.projects.present? ? where("id NOT IN (:ids)", ids: team.projects.map(&:id)) : scoped }
scope :in_team, ->(team) { where("id IN (:ids)", ids: team.projects.map(&:id)) }
scope :in_namespace, ->(namespace) { where(namespace_id: namespace.id) }
scope :sorted_by_activity, ->() { order("(SELECT max(events.created_at) FROM events WHERE events.project_id = projects.id) DESC") }
diff --git a/app/views/layouts/user_team.html.haml b/app/views/layouts/user_team.html.haml
index 12fce837238..2d397e80905 100644
--- a/app/views/layouts/user_team.html.haml
+++ b/app/views/layouts/user_team.html.haml
@@ -19,18 +19,16 @@
Merge Requests
%span.count= MergeRequest.opened.of_user_team(@team).count
- = nav_link(path: 'teams#search') do
- = link_to "Search", search_team_path(@team)
-
= nav_link(controller: [:members]) do
= link_to team_members_path(@team), class: "team-tab tab" do
Members
+ %span.count= @team.members.count
- if can? current_user, :admin_user_team, @team
= nav_link(controller: [:projects]) do
= link_to team_projects_path(@team), class: "team-tab tab" do
- %i.icon-briefcase
Projects
+ %span.count= @team.projects.count
= nav_link(path: 'teams#edit') do
= link_to edit_team_path(@team), class: "stat-tab tab " do
diff --git a/app/views/profiles/show.html.haml b/app/views/profiles/show.html.haml
index 4e55922ef8d..7a3177f0efc 100644
--- a/app/views/profiles/show.html.haml
+++ b/app/views/profiles/show.html.haml
@@ -31,6 +31,20 @@
.controls
= f.text_field :email, class: "input-xlarge", required: true
%span.help-block We also use email for avatar detection.
+ .control-group
+ = f.label :skype, class: "control-label"
+ .controls= f.text_field :skype, class: "input-xlarge"
+ .control-group
+ = f.label :linkedin, class: "control-label"
+ .controls= f.text_field :linkedin, class: "input-xlarge"
+ .control-group
+ = f.label :twitter, class: "control-label"
+ .controls= f.text_field :twitter, class: "input-xlarge"
+ .control-group
+ = f.label :bio, class: "control-label"
+ .controls
+ = f.text_area :bio, rows: 6, class: "input-xlarge", maxlength: 250
+ %span.help-block Tell us about yourself in fewer than 250 characters.
.span5.right
%fieldset.tips
@@ -59,24 +73,6 @@
Want to share a team between projects?
= link_to new_team_path, class: "btn very_small" do
Create a team
-
- .row
- .span7
- .control-group
- = f.label :skype, class: "control-label"
- .controls= f.text_field :skype, class: "input-xlarge"
- .control-group
- = f.label :linkedin, class: "control-label"
- .controls= f.text_field :linkedin, class: "input-xlarge"
- .control-group
- = f.label :twitter, class: "control-label"
- .controls= f.text_field :twitter, class: "input-xlarge"
- .control-group
- = f.label :bio, class: "control-label"
- .controls
- = f.text_area :bio, rows: 6, class: "input-xlarge", maxlength: 250
- %span.help-block Tell us about yourself in fewer than 250 characters.
- .span5.right
%fieldset
%legend
Personal projects:
diff --git a/app/views/teams/_team_head.html.haml b/app/views/teams/_team_head.html.haml
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/app/views/teams/_team_head.html.haml
+++ /dev/null
diff --git a/app/views/teams/edit.html.haml b/app/views/teams/edit.html.haml
index b2ceb2bdb21..60535330c4a 100644
--- a/app/views/teams/edit.html.haml
+++ b/app/views/teams/edit.html.haml
@@ -1,5 +1,3 @@
-= render "team_head"
-
%h3.page_title= "Edit Team #{@team.name}"
%hr
= form_for @team, url: teams_path do |f|
diff --git a/app/views/teams/index.html.haml b/app/views/teams/index.html.haml
deleted file mode 100644
index 6610cdbd76e..00000000000
--- a/app/views/teams/index.html.haml
+++ /dev/null
@@ -1,38 +0,0 @@
-%h3.page_title
- Teams
- %small
- list of all teams
-
- = link_to 'New Team', new_team_path, class: "btn success small right"
- %br
-
-= form_tag search_teams_path, method: :get, class: 'form-inline' do
- = text_field_tag :name, params[:name], class: "xlarge"
- = submit_tag "Search", class: "btn submit primary"
-
-%table.teams_list
- %thead
- %tr
- %th
- Name
- %i.icon-sort-down
- %th Path
- %th Projects
- %th Members
- %th Owner
- %th.cred Danger Zone!
-
- - @teams.each do |team|
- %tr
- %td
- %strong= link_to team.name, team_path(team)
- %td= team.path
- %td= link_to team.projects.count, team_projects_path(team)
- %td= link_to team.members.count, team_members_path(team)
- %td= link_to team.owner.name, team_member_path(team, team.owner)
- %td.bgred
- - if current_user.can?(:manage_user_team, team)
- = link_to "Edit", edit_team_path(team), class: "btn small"
- - if current_user.can?(:admin_user_team, team)
- = link_to "Destroy", team_path(team), method: :delete, confirm: "You are shure?", class: "danger btn small"
- &nbsp;
diff --git a/app/views/teams/issues.html.haml b/app/views/teams/issues.html.haml
index 3c17e85a115..4481e2eaa03 100644
--- a/app/views/teams/issues.html.haml
+++ b/app/views/teams/issues.html.haml
@@ -1,5 +1,3 @@
-= render "team_head"
-
%h3.page_title
Issues
%small (in Team projects assigned to Team members)
diff --git a/app/views/teams/members/edit.html.haml b/app/views/teams/members/edit.html.haml
index 9caff799552..375880496ab 100644
--- a/app/views/teams/members/edit.html.haml
+++ b/app/views/teams/members/edit.html.haml
@@ -1,6 +1,4 @@
-= render "teams/team_head"
-
-%h3
+%h3.page_title
Edit access #{@member.name} in #{@team.name} team
%hr
diff --git a/app/views/teams/members/index.html.haml b/app/views/teams/members/index.html.haml
index 1628237ede0..90fa0aef35c 100644
--- a/app/views/teams/members/index.html.haml
+++ b/app/views/teams/members/index.html.haml
@@ -1,5 +1,3 @@
-= render "teams/team_head"
-
%h3.page_title
Team Members
(#{@members.count})
diff --git a/app/views/teams/members/new.html.haml b/app/views/teams/members/new.html.haml
index 43f7c5d7b6f..274cdbadf29 100644
--- a/app/views/teams/members/new.html.haml
+++ b/app/views/teams/members/new.html.haml
@@ -1,5 +1,3 @@
-= render "teams/team_head"
-
%h3.page_title
Team: #{@team.name}
diff --git a/app/views/teams/members/show.html.haml b/app/views/teams/members/show.html.haml
index 03ef21be7a6..4008e8bd23e 100644
--- a/app/views/teams/members/show.html.haml
+++ b/app/views/teams/members/show.html.haml
@@ -1,5 +1,3 @@
-= render "teams/team_head"
-
- allow_admin = can? current_user, :admin_project, @project
- user = @team_member.user
diff --git a/app/views/teams/merge_requests.html.haml b/app/views/teams/merge_requests.html.haml
index f16331e1cdd..c9af529e113 100644
--- a/app/views/teams/merge_requests.html.haml
+++ b/app/views/teams/merge_requests.html.haml
@@ -1,5 +1,3 @@
-= render "team_head"
-
%h3.page_title
Merge Requests
%small (authored by or assigned to Team members)
diff --git a/app/views/teams/projects/edit.html.haml b/app/views/teams/projects/edit.html.haml
index 056ee6852c1..b91a4982b81 100644
--- a/app/views/teams/projects/edit.html.haml
+++ b/app/views/teams/projects/edit.html.haml
@@ -1,5 +1,3 @@
-= render "teams/team_head"
-
%h3
Edit max access in #{@project.name} for #{@team.name} team
diff --git a/app/views/teams/projects/index.html.haml b/app/views/teams/projects/index.html.haml
index af6ffe5f3a4..493fc2c5c9e 100644
--- a/app/views/teams/projects/index.html.haml
+++ b/app/views/teams/projects/index.html.haml
@@ -1,5 +1,3 @@
-= render "teams/team_head"
-
%h3.page_title
Assigned projects (#{@team.projects.count})
%small
@@ -13,22 +11,26 @@
%hr
-%table.projects-table
- %thead
- %tr
- %th Project name
- %th Max access
- - if current_user.can?(:admin_user_team, @team)
- %th.span3
+- if @team.projects.present?
+ %table.projects-table
+ %thead
+ %tr
+ %th Project name
+ %th Max access
+ - if current_user.can?(:admin_user_team, @team)
+ %th.span3
+
+ - @team.projects.each do |project|
+ %tr.project
+ %td
+ = link_to project.name_with_namespace, project_path(project)
+ %td
+ %span= @team.human_max_project_access(project)
- - @team.projects.each do |project|
- %tr.project
- %td
- = link_to project.name_with_namespace, project_path(project)
- %td
- %span= @team.human_max_project_access(project)
+ - if current_user.can?(:admin_user_team, @team)
+ %td.bgred
+ = link_to 'Edit max access', edit_team_project_path(@team, project), class: "btn small"
+ = link_to 'Relegate', team_project_path(@team, project), confirm: 'Remove project from team and move to global namespace. Are you sure?', method: :delete, class: "btn danger small"
- - if current_user.can?(:admin_user_team, @team)
- %td.bgred
- = link_to 'Edit max access', edit_team_project_path(@team, project), class: "btn small"
- = link_to 'Relegate', team_project_path(@team, project), confirm: 'Remove project from team and move to global namespace. Are you sure?', method: :delete, class: "btn danger small"
+- else
+ %p.nothing_here_message This team has no projects yet
diff --git a/app/views/teams/projects/new.html.haml b/app/views/teams/projects/new.html.haml
index 000f62bb643..d57f56b2fee 100644
--- a/app/views/teams/projects/new.html.haml
+++ b/app/views/teams/projects/new.html.haml
@@ -1,5 +1,3 @@
-= render "teams/team_head"
-
%h3.page_title
Team: #{@team.name}
diff --git a/app/views/teams/search.html.haml b/app/views/teams/search.html.haml
deleted file mode 100644
index 5c357c5cfcb..00000000000
--- a/app/views/teams/search.html.haml
+++ /dev/null
@@ -1,11 +0,0 @@
-= render "team_head"
-
-= form_tag search_team_path(@team), method: :get, class: 'form-inline' do |f|
- .padded
- = label_tag :search do
- %strong Looking for
- .input
- = search_field_tag :search, params[:search], placeholder: "issue 143", class: "input-xxlarge search-text-input", id: "dashboard_search"
- = submit_tag 'Search', class: "btn primary wide"
-- if params[:search].present?
- = render 'search/result'
diff --git a/app/views/teams/show.html.haml b/app/views/teams/show.html.haml
index 9acbf3e1ecf..d9257ab090c 100644
--- a/app/views/teams/show.html.haml
+++ b/app/views/teams/show.html.haml
@@ -1,5 +1,3 @@
-= render "team_head"
-
.projects
.activities.span8
= link_to dashboard_path, class: 'btn very_small' do
diff --git a/config/routes.rb b/config/routes.rb
index ba350a70bfa..d67f0a47a00 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -142,15 +142,11 @@ Gitlab::Application.routes.draw do
member do
get :issues
get :merge_requests
- get :search
end
scope module: :teams do
resources :members, only: [:index, :new, :create, :edit, :update, :destroy]
resources :projects, only: [:index, :new, :create, :edit, :update, :destroy], constraints: { id: /[a-zA-Z.0-9_\-\/]+/ }
end
- collection do
- get :search
- end
end
resources :projects, constraints: { id: /[^\/]+/ }, only: [:new, :create]