teams refactoring and cleanup pt.1
This commit is contained in:
parent
1c88fbb391
commit
74e329064a
19 changed files with 39 additions and 126 deletions
|
@ -64,16 +64,6 @@ class TeamsController < ApplicationController
|
||||||
@issues = @issues.includes(:author, :project)
|
@issues = @issues.includes(:author, :project)
|
||||||
end
|
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
|
protected
|
||||||
|
|
||||||
def projects
|
def projects
|
||||||
|
|
|
@ -80,7 +80,7 @@ class Project < ActiveRecord::Base
|
||||||
# Scopes
|
# Scopes
|
||||||
scope :without_user, ->(user) { where("id NOT IN (:ids)", ids: user.authorized_projects.map(&:id) ) }
|
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 :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_team, ->(team) { where("id IN (:ids)", ids: team.projects.map(&:id)) }
|
||||||
scope :in_namespace, ->(namespace) { where(namespace_id: namespace.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") }
|
scope :sorted_by_activity, ->() { order("(SELECT max(events.created_at) FROM events WHERE events.project_id = projects.id) DESC") }
|
||||||
|
|
|
@ -19,18 +19,16 @@
|
||||||
Merge Requests
|
Merge Requests
|
||||||
%span.count= MergeRequest.opened.of_user_team(@team).count
|
%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
|
= nav_link(controller: [:members]) do
|
||||||
= link_to team_members_path(@team), class: "team-tab tab" do
|
= link_to team_members_path(@team), class: "team-tab tab" do
|
||||||
Members
|
Members
|
||||||
|
%span.count= @team.members.count
|
||||||
|
|
||||||
- if can? current_user, :admin_user_team, @team
|
- if can? current_user, :admin_user_team, @team
|
||||||
= nav_link(controller: [:projects]) do
|
= nav_link(controller: [:projects]) do
|
||||||
= link_to team_projects_path(@team), class: "team-tab tab" do
|
= link_to team_projects_path(@team), class: "team-tab tab" do
|
||||||
%i.icon-briefcase
|
|
||||||
Projects
|
Projects
|
||||||
|
%span.count= @team.projects.count
|
||||||
|
|
||||||
= nav_link(path: 'teams#edit') do
|
= nav_link(path: 'teams#edit') do
|
||||||
= link_to edit_team_path(@team), class: "stat-tab tab " do
|
= link_to edit_team_path(@team), class: "stat-tab tab " do
|
||||||
|
|
|
@ -31,6 +31,20 @@
|
||||||
.controls
|
.controls
|
||||||
= f.text_field :email, class: "input-xlarge", required: true
|
= f.text_field :email, class: "input-xlarge", required: true
|
||||||
%span.help-block We also use email for avatar detection.
|
%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
|
.span5.right
|
||||||
%fieldset.tips
|
%fieldset.tips
|
||||||
|
@ -59,24 +73,6 @@
|
||||||
Want to share a team between projects?
|
Want to share a team between projects?
|
||||||
= link_to new_team_path, class: "btn very_small" do
|
= link_to new_team_path, class: "btn very_small" do
|
||||||
Create a team
|
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
|
%fieldset
|
||||||
%legend
|
%legend
|
||||||
Personal projects:
|
Personal projects:
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
= render "team_head"
|
|
||||||
|
|
||||||
%h3.page_title= "Edit Team #{@team.name}"
|
%h3.page_title= "Edit Team #{@team.name}"
|
||||||
%hr
|
%hr
|
||||||
= form_for @team, url: teams_path do |f|
|
= form_for @team, url: teams_path do |f|
|
||||||
|
|
|
@ -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"
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
= render "team_head"
|
|
||||||
|
|
||||||
%h3.page_title
|
%h3.page_title
|
||||||
Issues
|
Issues
|
||||||
%small (in Team projects assigned to Team members)
|
%small (in Team projects assigned to Team members)
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
= render "teams/team_head"
|
%h3.page_title
|
||||||
|
|
||||||
%h3
|
|
||||||
Edit access #{@member.name} in #{@team.name} team
|
Edit access #{@member.name} in #{@team.name} team
|
||||||
|
|
||||||
%hr
|
%hr
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
= render "teams/team_head"
|
|
||||||
|
|
||||||
%h3.page_title
|
%h3.page_title
|
||||||
Team Members
|
Team Members
|
||||||
(#{@members.count})
|
(#{@members.count})
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
= render "teams/team_head"
|
|
||||||
|
|
||||||
%h3.page_title
|
%h3.page_title
|
||||||
Team: #{@team.name}
|
Team: #{@team.name}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
= render "teams/team_head"
|
|
||||||
|
|
||||||
- allow_admin = can? current_user, :admin_project, @project
|
- allow_admin = can? current_user, :admin_project, @project
|
||||||
- user = @team_member.user
|
- user = @team_member.user
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
= render "team_head"
|
|
||||||
|
|
||||||
%h3.page_title
|
%h3.page_title
|
||||||
Merge Requests
|
Merge Requests
|
||||||
%small (authored by or assigned to Team members)
|
%small (authored by or assigned to Team members)
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
= render "teams/team_head"
|
|
||||||
|
|
||||||
%h3
|
%h3
|
||||||
Edit max access in #{@project.name} for #{@team.name} team
|
Edit max access in #{@project.name} for #{@team.name} team
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
= render "teams/team_head"
|
|
||||||
|
|
||||||
%h3.page_title
|
%h3.page_title
|
||||||
Assigned projects (#{@team.projects.count})
|
Assigned projects (#{@team.projects.count})
|
||||||
%small
|
%small
|
||||||
|
@ -13,22 +11,26 @@
|
||||||
|
|
||||||
%hr
|
%hr
|
||||||
|
|
||||||
%table.projects-table
|
- if @team.projects.present?
|
||||||
%thead
|
%table.projects-table
|
||||||
%tr
|
%thead
|
||||||
%th Project name
|
%tr
|
||||||
%th Max access
|
%th Project name
|
||||||
- if current_user.can?(:admin_user_team, @team)
|
%th Max access
|
||||||
%th.span3
|
- if current_user.can?(:admin_user_team, @team)
|
||||||
|
%th.span3
|
||||||
|
|
||||||
- @team.projects.each do |project|
|
- @team.projects.each do |project|
|
||||||
%tr.project
|
%tr.project
|
||||||
%td
|
%td
|
||||||
= link_to project.name_with_namespace, project_path(project)
|
= link_to project.name_with_namespace, project_path(project)
|
||||||
%td
|
%td
|
||||||
%span= @team.human_max_project_access(project)
|
%span= @team.human_max_project_access(project)
|
||||||
|
|
||||||
- if current_user.can?(:admin_user_team, @team)
|
- if current_user.can?(:admin_user_team, @team)
|
||||||
%td.bgred
|
%td.bgred
|
||||||
= link_to 'Edit max access', edit_team_project_path(@team, project), class: "btn small"
|
= 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"
|
= 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
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
= render "teams/team_head"
|
|
||||||
|
|
||||||
%h3.page_title
|
%h3.page_title
|
||||||
Team: #{@team.name}
|
Team: #{@team.name}
|
||||||
|
|
||||||
|
|
|
@ -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'
|
|
|
@ -1,5 +1,3 @@
|
||||||
= render "team_head"
|
|
||||||
|
|
||||||
.projects
|
.projects
|
||||||
.activities.span8
|
.activities.span8
|
||||||
= link_to dashboard_path, class: 'btn very_small' do
|
= link_to dashboard_path, class: 'btn very_small' do
|
||||||
|
|
|
@ -142,15 +142,11 @@ Gitlab::Application.routes.draw do
|
||||||
member do
|
member do
|
||||||
get :issues
|
get :issues
|
||||||
get :merge_requests
|
get :merge_requests
|
||||||
get :search
|
|
||||||
end
|
end
|
||||||
scope module: :teams do
|
scope module: :teams do
|
||||||
resources :members, only: [:index, :new, :create, :edit, :update, :destroy]
|
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_\-\/]+/ }
|
resources :projects, only: [:index, :new, :create, :edit, :update, :destroy], constraints: { id: /[a-zA-Z.0-9_\-\/]+/ }
|
||||||
end
|
end
|
||||||
collection do
|
|
||||||
get :search
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :projects, constraints: { id: /[^\/]+/ }, only: [:new, :create]
|
resources :projects, constraints: { id: /[^\/]+/ }, only: [:new, :create]
|
||||||
|
|
Loading…
Add table
Reference in a new issue