Commit 74e329064abc1306132dd73dcb2e25221379f568
1 parent
1c88fbb3
Exists in
master
and in
4 other branches
teams refactoring and cleanup pt.1
Showing
19 changed files
with
39 additions
and
126 deletions
Show diff stats
app/controllers/teams_controller.rb
@@ -64,16 +64,6 @@ class TeamsController < ApplicationController | @@ -64,16 +64,6 @@ class TeamsController < ApplicationController | ||
64 | @issues = @issues.includes(:author, :project) | 64 | @issues = @issues.includes(:author, :project) |
65 | end | 65 | end |
66 | 66 | ||
67 | - def search | ||
68 | - result = SearchContext.new(user_team.project_ids, params).execute | ||
69 | - | ||
70 | - @projects = result[:projects] | ||
71 | - @merge_requests = result[:merge_requests] | ||
72 | - @issues = result[:issues] | ||
73 | - @wiki_pages = result[:wiki_pages] | ||
74 | - @teams = result[:teams] | ||
75 | - end | ||
76 | - | ||
77 | protected | 67 | protected |
78 | 68 | ||
79 | def projects | 69 | def projects |
app/models/project.rb
@@ -80,7 +80,7 @@ class Project < ActiveRecord::Base | @@ -80,7 +80,7 @@ class Project < ActiveRecord::Base | ||
80 | # Scopes | 80 | # Scopes |
81 | scope :without_user, ->(user) { where("id NOT IN (:ids)", ids: user.authorized_projects.map(&:id) ) } | 81 | scope :without_user, ->(user) { where("id NOT IN (:ids)", ids: user.authorized_projects.map(&:id) ) } |
82 | scope :not_in_group, ->(group) { where("id NOT IN (:ids)", ids: group.project_ids ) } | 82 | scope :not_in_group, ->(group) { where("id NOT IN (:ids)", ids: group.project_ids ) } |
83 | - scope :without_team, ->(team) { where("id NOT IN (:ids)", ids: team.projects.map(&:id)) } | 83 | + scope :without_team, ->(team) { team.projects.present? ? where("id NOT IN (:ids)", ids: team.projects.map(&:id)) : scoped } |
84 | scope :in_team, ->(team) { where("id IN (:ids)", ids: team.projects.map(&:id)) } | 84 | scope :in_team, ->(team) { where("id IN (:ids)", ids: team.projects.map(&:id)) } |
85 | scope :in_namespace, ->(namespace) { where(namespace_id: namespace.id) } | 85 | scope :in_namespace, ->(namespace) { where(namespace_id: namespace.id) } |
86 | scope :sorted_by_activity, ->() { order("(SELECT max(events.created_at) FROM events WHERE events.project_id = projects.id) DESC") } | 86 | scope :sorted_by_activity, ->() { order("(SELECT max(events.created_at) FROM events WHERE events.project_id = projects.id) DESC") } |
app/views/layouts/user_team.html.haml
@@ -19,18 +19,16 @@ | @@ -19,18 +19,16 @@ | ||
19 | Merge Requests | 19 | Merge Requests |
20 | %span.count= MergeRequest.opened.of_user_team(@team).count | 20 | %span.count= MergeRequest.opened.of_user_team(@team).count |
21 | 21 | ||
22 | - = nav_link(path: 'teams#search') do | ||
23 | - = link_to "Search", search_team_path(@team) | ||
24 | - | ||
25 | = nav_link(controller: [:members]) do | 22 | = nav_link(controller: [:members]) do |
26 | = link_to team_members_path(@team), class: "team-tab tab" do | 23 | = link_to team_members_path(@team), class: "team-tab tab" do |
27 | Members | 24 | Members |
25 | + %span.count= @team.members.count | ||
28 | 26 | ||
29 | - if can? current_user, :admin_user_team, @team | 27 | - if can? current_user, :admin_user_team, @team |
30 | = nav_link(controller: [:projects]) do | 28 | = nav_link(controller: [:projects]) do |
31 | = link_to team_projects_path(@team), class: "team-tab tab" do | 29 | = link_to team_projects_path(@team), class: "team-tab tab" do |
32 | - %i.icon-briefcase | ||
33 | Projects | 30 | Projects |
31 | + %span.count= @team.projects.count | ||
34 | 32 | ||
35 | = nav_link(path: 'teams#edit') do | 33 | = nav_link(path: 'teams#edit') do |
36 | = link_to edit_team_path(@team), class: "stat-tab tab " do | 34 | = link_to edit_team_path(@team), class: "stat-tab tab " do |
app/views/profiles/show.html.haml
@@ -31,6 +31,20 @@ | @@ -31,6 +31,20 @@ | ||
31 | .controls | 31 | .controls |
32 | = f.text_field :email, class: "input-xlarge", required: true | 32 | = f.text_field :email, class: "input-xlarge", required: true |
33 | %span.help-block We also use email for avatar detection. | 33 | %span.help-block We also use email for avatar detection. |
34 | + .control-group | ||
35 | + = f.label :skype, class: "control-label" | ||
36 | + .controls= f.text_field :skype, class: "input-xlarge" | ||
37 | + .control-group | ||
38 | + = f.label :linkedin, class: "control-label" | ||
39 | + .controls= f.text_field :linkedin, class: "input-xlarge" | ||
40 | + .control-group | ||
41 | + = f.label :twitter, class: "control-label" | ||
42 | + .controls= f.text_field :twitter, class: "input-xlarge" | ||
43 | + .control-group | ||
44 | + = f.label :bio, class: "control-label" | ||
45 | + .controls | ||
46 | + = f.text_area :bio, rows: 6, class: "input-xlarge", maxlength: 250 | ||
47 | + %span.help-block Tell us about yourself in fewer than 250 characters. | ||
34 | 48 | ||
35 | .span5.right | 49 | .span5.right |
36 | %fieldset.tips | 50 | %fieldset.tips |
@@ -59,24 +73,6 @@ | @@ -59,24 +73,6 @@ | ||
59 | Want to share a team between projects? | 73 | Want to share a team between projects? |
60 | = link_to new_team_path, class: "btn very_small" do | 74 | = link_to new_team_path, class: "btn very_small" do |
61 | Create a team | 75 | Create a team |
62 | - | ||
63 | - .row | ||
64 | - .span7 | ||
65 | - .control-group | ||
66 | - = f.label :skype, class: "control-label" | ||
67 | - .controls= f.text_field :skype, class: "input-xlarge" | ||
68 | - .control-group | ||
69 | - = f.label :linkedin, class: "control-label" | ||
70 | - .controls= f.text_field :linkedin, class: "input-xlarge" | ||
71 | - .control-group | ||
72 | - = f.label :twitter, class: "control-label" | ||
73 | - .controls= f.text_field :twitter, class: "input-xlarge" | ||
74 | - .control-group | ||
75 | - = f.label :bio, class: "control-label" | ||
76 | - .controls | ||
77 | - = f.text_area :bio, rows: 6, class: "input-xlarge", maxlength: 250 | ||
78 | - %span.help-block Tell us about yourself in fewer than 250 characters. | ||
79 | - .span5.right | ||
80 | %fieldset | 76 | %fieldset |
81 | %legend | 77 | %legend |
82 | Personal projects: | 78 | Personal projects: |
app/views/teams/_team_head.html.haml
app/views/teams/edit.html.haml
app/views/teams/index.html.haml
@@ -1,38 +0,0 @@ | @@ -1,38 +0,0 @@ | ||
1 | -%h3.page_title | ||
2 | - Teams | ||
3 | - %small | ||
4 | - list of all teams | ||
5 | - | ||
6 | - = link_to 'New Team', new_team_path, class: "btn success small right" | ||
7 | - %br | ||
8 | - | ||
9 | -= form_tag search_teams_path, method: :get, class: 'form-inline' do | ||
10 | - = text_field_tag :name, params[:name], class: "xlarge" | ||
11 | - = submit_tag "Search", class: "btn submit primary" | ||
12 | - | ||
13 | -%table.teams_list | ||
14 | - %thead | ||
15 | - %tr | ||
16 | - %th | ||
17 | - Name | ||
18 | - %i.icon-sort-down | ||
19 | - %th Path | ||
20 | - %th Projects | ||
21 | - %th Members | ||
22 | - %th Owner | ||
23 | - %th.cred Danger Zone! | ||
24 | - | ||
25 | - - @teams.each do |team| | ||
26 | - %tr | ||
27 | - %td | ||
28 | - %strong= link_to team.name, team_path(team) | ||
29 | - %td= team.path | ||
30 | - %td= link_to team.projects.count, team_projects_path(team) | ||
31 | - %td= link_to team.members.count, team_members_path(team) | ||
32 | - %td= link_to team.owner.name, team_member_path(team, team.owner) | ||
33 | - %td.bgred | ||
34 | - - if current_user.can?(:manage_user_team, team) | ||
35 | - = link_to "Edit", edit_team_path(team), class: "btn small" | ||
36 | - - if current_user.can?(:admin_user_team, team) | ||
37 | - = link_to "Destroy", team_path(team), method: :delete, confirm: "You are shure?", class: "danger btn small" | ||
38 | - |
app/views/teams/issues.html.haml
app/views/teams/members/edit.html.haml
app/views/teams/members/index.html.haml
app/views/teams/members/new.html.haml
app/views/teams/members/show.html.haml
app/views/teams/merge_requests.html.haml
app/views/teams/projects/edit.html.haml
app/views/teams/projects/index.html.haml
1 | -= render "teams/team_head" | ||
2 | - | ||
3 | %h3.page_title | 1 | %h3.page_title |
4 | Assigned projects (#{@team.projects.count}) | 2 | Assigned projects (#{@team.projects.count}) |
5 | %small | 3 | %small |
@@ -13,22 +11,26 @@ | @@ -13,22 +11,26 @@ | ||
13 | 11 | ||
14 | %hr | 12 | %hr |
15 | 13 | ||
16 | -%table.projects-table | ||
17 | - %thead | ||
18 | - %tr | ||
19 | - %th Project name | ||
20 | - %th Max access | ||
21 | - - if current_user.can?(:admin_user_team, @team) | ||
22 | - %th.span3 | 14 | +- if @team.projects.present? |
15 | + %table.projects-table | ||
16 | + %thead | ||
17 | + %tr | ||
18 | + %th Project name | ||
19 | + %th Max access | ||
20 | + - if current_user.can?(:admin_user_team, @team) | ||
21 | + %th.span3 | ||
22 | + | ||
23 | + - @team.projects.each do |project| | ||
24 | + %tr.project | ||
25 | + %td | ||
26 | + = link_to project.name_with_namespace, project_path(project) | ||
27 | + %td | ||
28 | + %span= @team.human_max_project_access(project) | ||
23 | 29 | ||
24 | - - @team.projects.each do |project| | ||
25 | - %tr.project | ||
26 | - %td | ||
27 | - = link_to project.name_with_namespace, project_path(project) | ||
28 | - %td | ||
29 | - %span= @team.human_max_project_access(project) | 30 | + - if current_user.can?(:admin_user_team, @team) |
31 | + %td.bgred | ||
32 | + = link_to 'Edit max access', edit_team_project_path(@team, project), class: "btn small" | ||
33 | + = 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" | ||
30 | 34 | ||
31 | - - if current_user.can?(:admin_user_team, @team) | ||
32 | - %td.bgred | ||
33 | - = link_to 'Edit max access', edit_team_project_path(@team, project), class: "btn small" | ||
34 | - = 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" | 35 | +- else |
36 | + %p.nothing_here_message This team has no projects yet |
app/views/teams/projects/new.html.haml
app/views/teams/search.html.haml
@@ -1,11 +0,0 @@ | @@ -1,11 +0,0 @@ | ||
1 | -= render "team_head" | ||
2 | - | ||
3 | -= form_tag search_team_path(@team), method: :get, class: 'form-inline' do |f| | ||
4 | - .padded | ||
5 | - = label_tag :search do | ||
6 | - %strong Looking for | ||
7 | - .input | ||
8 | - = search_field_tag :search, params[:search], placeholder: "issue 143", class: "input-xxlarge search-text-input", id: "dashboard_search" | ||
9 | - = submit_tag 'Search', class: "btn primary wide" | ||
10 | -- if params[:search].present? | ||
11 | - = render 'search/result' |
app/views/teams/show.html.haml
config/routes.rb
@@ -142,15 +142,11 @@ Gitlab::Application.routes.draw do | @@ -142,15 +142,11 @@ Gitlab::Application.routes.draw do | ||
142 | member do | 142 | member do |
143 | get :issues | 143 | get :issues |
144 | get :merge_requests | 144 | get :merge_requests |
145 | - get :search | ||
146 | end | 145 | end |
147 | scope module: :teams do | 146 | scope module: :teams do |
148 | resources :members, only: [:index, :new, :create, :edit, :update, :destroy] | 147 | resources :members, only: [:index, :new, :create, :edit, :update, :destroy] |
149 | resources :projects, only: [:index, :new, :create, :edit, :update, :destroy], constraints: { id: /[a-zA-Z.0-9_\-\/]+/ } | 148 | resources :projects, only: [:index, :new, :create, :edit, :update, :destroy], constraints: { id: /[a-zA-Z.0-9_\-\/]+/ } |
150 | end | 149 | end |
151 | - collection do | ||
152 | - get :search | ||
153 | - end | ||
154 | end | 150 | end |
155 | 151 | ||
156 | resources :projects, constraints: { id: /[^\/]+/ }, only: [:new, :create] | 152 | resources :projects, constraints: { id: /[^\/]+/ }, only: [:new, :create] |