Commit 18bd1c9d authored by Andrey Kumanyaev's avatar Andrey Kumanyaev Committed by Dmitriy Zaporozhets

update all teams code. refactoring and some corrections

parent 7658f8c1
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
# #
# Automatically sets the layout and ensures an administrator is logged in # Automatically sets the layout and ensures an administrator is logged in
class Admin::Teams::ApplicationController < Admin::ApplicationController class Admin::Teams::ApplicationController < Admin::ApplicationController
before_filter :user_team
private private
......
class Admin::Teams::MembersController < Admin::Teams::ApplicationController class Admin::Teams::MembersController < Admin::Teams::ApplicationController
def new def new
@users = User.active @users = User.active
@users = @users.not_in_team(@team) if @team.members.any? @users = @users.not_in_team(user_team) if user_team.members.any?
@users = UserDecorator.decorate @users @users = UserDecorator.decorate @users
end end
...@@ -10,10 +10,10 @@ class Admin::Teams::MembersController < Admin::Teams::ApplicationController ...@@ -10,10 +10,10 @@ class Admin::Teams::MembersController < Admin::Teams::ApplicationController
user_ids = params[:user_ids] user_ids = params[:user_ids]
access = params[:default_project_access] access = params[:default_project_access]
is_admin = params[:group_admin] is_admin = params[:group_admin]
@team.add_members(user_ids, access, is_admin) user_team.add_members(user_ids, access, is_admin)
end end
redirect_to admin_team_path(@team), notice: 'Members was successfully added.' redirect_to admin_team_path(user_team), notice: 'Members was successfully added into Team of users.'
end end
def edit def edit
...@@ -22,24 +22,24 @@ class Admin::Teams::MembersController < Admin::Teams::ApplicationController ...@@ -22,24 +22,24 @@ class Admin::Teams::MembersController < Admin::Teams::ApplicationController
def update def update
options = {default_projects_access: params[:default_project_access], group_admin: params[:group_admin]} options = {default_projects_access: params[:default_project_access], group_admin: params[:group_admin]}
if @team.update_membership(team_member, options) if user_team.update_membership(team_member, options)
redirect_to admin_team_path(@team), notice: 'Membership was successfully updated.' redirect_to admin_team_path(user_team), notice: "Membership for #{team_member.name} was successfully updated in Team of users."
else else
render :edit render :edit
end end
end end
def destroy def destroy
if @team.remove_member(team_member) if user_team.remove_member(team_member)
redirect_to admin_team_path(@team), notice: "Member was successfully removed from team." redirect_to admin_team_path(user_team), notice: "Member #{team_member.name} was successfully removed from Team of users."
else else
redirect_to admin_team_members(@team), notice: "Something wrong." redirect_to admin_team_members(user_team), notice: "Something is wrong."
end end
end end
protected protected
def team_member def team_member
@member ||= @team.members.find(params[:id]) @member ||= user_team.members.find(params[:id])
end end
end end
class Admin::Teams::ProjectsController < Admin::Teams::ApplicationController class Admin::Teams::ProjectsController < Admin::Teams::ApplicationController
def new def new
@projects = Project.scoped @projects = Project.scoped
@projects = @projects.without_team(@team) if @team.projects.any? @projects = @projects.without_team(user_team) if user_team.projects.any?
#@projects.reject!(&:empty_repo?) #@projects.reject!(&:empty_repo?)
end end
...@@ -9,10 +9,10 @@ class Admin::Teams::ProjectsController < Admin::Teams::ApplicationController ...@@ -9,10 +9,10 @@ class Admin::Teams::ProjectsController < Admin::Teams::ApplicationController
unless params[:project_ids].blank? unless params[:project_ids].blank?
project_ids = params[:project_ids] project_ids = params[:project_ids]
access = params[:greatest_project_access] access = params[:greatest_project_access]
@team.assign_to_projects(project_ids, access) user_team.assign_to_projects(project_ids, access)
end end
redirect_to admin_team_path(@team), notice: 'Projects was successfully added.' redirect_to admin_team_path(user_team), notice: 'Team of users was successfully assgned to projects.'
end end
def edit def edit
...@@ -20,22 +20,22 @@ class Admin::Teams::ProjectsController < Admin::Teams::ApplicationController ...@@ -20,22 +20,22 @@ class Admin::Teams::ProjectsController < Admin::Teams::ApplicationController
end end
def update def update
if @team.update_project_access(team_project, params[:greatest_project_access]) if user_team.update_project_access(team_project, params[:greatest_project_access])
redirect_to admin_team_path(@team), notice: 'Membership was successfully updated.' redirect_to admin_team_path(user_team), notice: 'Access was successfully updated.'
else else
render :edit render :edit
end end
end end
def destroy def destroy
@team.resign_from_project(team_project) user_team.resign_from_project(team_project)
redirect_to admin_team_path(@team), notice: 'Project was successfully removed.' redirect_to admin_team_path(user_team), notice: 'Team of users was successfully reassigned from project.'
end end
protected protected
def team_project def team_project
@project ||= @team.projects.find_by_path(params[:id]) @project ||= user_team.projects.find_with_namespace(params[:id])
end end
end end
...@@ -24,12 +24,12 @@ class Admin::TeamsController < Admin::ApplicationController ...@@ -24,12 +24,12 @@ class Admin::TeamsController < Admin::ApplicationController
end end
def create def create
user_team = UserTeam.new(params[:user_team]) @team = UserTeam.new(params[:user_team])
user_team.path = user_team.name.dup.parameterize if user_team.name @team.path = @team.name.dup.parameterize if @team.name
user_team.owner = current_user @team.owner = current_user
if user_team.save if @team.save
redirect_to admin_team_path(user_team), notice: 'UserTeam was successfully created.' redirect_to admin_team_path(@team), notice: 'Team of users was successfully created.'
else else
render action: "new" render action: "new"
end end
...@@ -44,7 +44,7 @@ class Admin::TeamsController < Admin::ApplicationController ...@@ -44,7 +44,7 @@ class Admin::TeamsController < Admin::ApplicationController
end end
if user_team.update_attributes(user_team_params) if user_team.update_attributes(user_team_params)
redirect_to admin_team_path(user_team), notice: 'UserTeam was successfully updated.' redirect_to admin_team_path(user_team), notice: 'Team of users was successfully updated.'
else else
render action: "edit" render action: "edit"
end end
...@@ -53,7 +53,7 @@ class Admin::TeamsController < Admin::ApplicationController ...@@ -53,7 +53,7 @@ class Admin::TeamsController < Admin::ApplicationController
def destroy def destroy
user_team.destroy user_team.destroy
redirect_to admin_user_teams_path, notice: 'UserTeam was successfully deleted.' redirect_to admin_user_teams_path, notice: 'Team of users was successfully deleted.'
end end
protected protected
......
...@@ -94,6 +94,14 @@ class ApplicationController < ActionController::Base ...@@ -94,6 +94,14 @@ class ApplicationController < ActionController::Base
return access_denied! unless can?(current_user, :download_code, project) return access_denied! unless can?(current_user, :download_code, project)
end end
def authorize_manage_user_team!
return access_denied! unless user_team.present? && can?(current_user, :manage_user_team, user_team)
end
def authorize_admin_user_team!
return access_denied! unless user_team.present? && can?(current_user, :admin_user_team, user_team)
end
def access_denied! def access_denied!
render "errors/access_denied", layout: "errors", status: 404 render "errors/access_denied", layout: "errors", status: 404
end end
...@@ -135,4 +143,5 @@ class ApplicationController < ActionController::Base ...@@ -135,4 +143,5 @@ class ApplicationController < ActionController::Base
def dev_tools def dev_tools
Rack::MiniProfiler.authorize_request Rack::MiniProfiler.authorize_request
end end
end end
...@@ -4,6 +4,7 @@ class TeamMembersController < ProjectResourceController ...@@ -4,6 +4,7 @@ class TeamMembersController < ProjectResourceController
before_filter :authorize_admin_project!, except: [:index, :show] before_filter :authorize_admin_project!, except: [:index, :show]
def index def index
@teams = UserTeam.scoped
end end
def show def show
......
...@@ -5,11 +5,7 @@ class Teams::ApplicationController < ApplicationController ...@@ -5,11 +5,7 @@ class Teams::ApplicationController < ApplicationController
protected protected
def user_team def user_team
@user_team ||= UserTeam.find_by_path(params[:team_id]) @team ||= UserTeam.find_by_path(params[:team_id])
end
def authorize_manage_user_team!
return access_denied! unless can?(current_user, :manage_user_team, user_team)
end end
end end
class Teams::MembersController < Teams::ApplicationController class Teams::MembersController < Teams::ApplicationController
# Authorize
skip_before_filter :authorize_manage_user_team!, only: [:index] skip_before_filter :authorize_manage_user_team!, only: [:index]
def index def index
@members = @user_team.members @members = user_team.members
end
def show
@team_member = @user_team.members.find(params[:id])
@events = @team_member.recent_events.limit(7)
end end
def new def new
@team_member = @user_team.members.new @users = User.active
@users = @users.not_in_team(user_team) if user_team.members.any?
@users = UserDecorator.decorate @users
end end
def create def create
users = User.where(id: params[:user_ids]) unless params[:user_ids].blank?
user_ids = params[:user_ids]
access = params[:default_project_access]
is_admin = params[:group_admin]
user_team.add_members(user_ids, access, is_admin)
end
@project.team << [users, params[:default_project_access]] redirect_to team_path(user_team), notice: 'Members was successfully added into Team of users.'
end
if params[:redirect_to] def edit
redirect_to params[:redirect_to] team_member
else
redirect_to project_team_index_path(@project)
end
end end
def update def update
@team_member = @user_team.members.find(params[:id]) options = {default_projects_access: params[:default_project_access], group_admin: params[:group_admin]}
@team_member.update_attributes(params[:team_member]) if user_team.update_membership(team_member, options)
redirect_to team_path(user_team), notice: "Membership for #{team_member.name} was successfully updated in Team of users."
unless @team_member.valid? else
flash[:alert] = "User should have at least one role" render :edit
end end
redirect_to team_member_path(@project)
end end
def destroy def destroy
@team_member = project.users_projects.find(params[:id]) if user_team.remove_member(team_member)
@team_member.destroy redirect_to team_path(user_team), notice: "Member #{team_member.name} was successfully removed from Team of users."
else
respond_to do |format| redirect_to team_members(user_team), notice: "Something is wrong."
format.html { redirect_to project_team_index_path(@project) }
format.js { render nothing: true }
end end
end end
def apply_import protected
giver = Project.find(params[:source_project_id])
status = @project.team.import(giver)
notice = status ? "Succesfully imported" : "Import failed"
redirect_to project_team_members_path(project), notice: notice def team_member
@member ||= user_team.members.find(params[:id])
end end
end end
...@@ -8,9 +8,12 @@ class Teams::ProjectsController < Teams::ApplicationController ...@@ -8,9 +8,12 @@ class Teams::ProjectsController < Teams::ApplicationController
end end
def new def new
@projects = Project.scoped user_team
@projects = @projects.without_team(user_team) if user_team.projects.any? @avaliable_projects = Project.scoped
@avaliable_projects = @avaliable_projects.without_team(user_team) if user_team.projects.any?
#@projects.reject!(&:empty_repo?) #@projects.reject!(&:empty_repo?)
redirect_to team_projects_path(user_team), notice: "No avalible projects." unless @avaliable_projects.any?
end end
def create def create
...@@ -20,7 +23,7 @@ class Teams::ProjectsController < Teams::ApplicationController ...@@ -20,7 +23,7 @@ class Teams::ProjectsController < Teams::ApplicationController
user_team.assign_to_projects(project_ids, access) user_team.assign_to_projects(project_ids, access)
end end
redirect_to admin_team_path(user_team), notice: 'Projects was successfully added.' redirect_to team_projects_path(user_team), notice: 'Team of users was successfully assgned to projects.'
end end
def edit def edit
...@@ -29,7 +32,7 @@ class Teams::ProjectsController < Teams::ApplicationController ...@@ -29,7 +32,7 @@ class Teams::ProjectsController < Teams::ApplicationController
def update def update
if user_team.update_project_access(team_project, params[:greatest_project_access]) if user_team.update_project_access(team_project, params[:greatest_project_access])
redirect_to admin_team_path(user_team), notice: 'Membership was successfully updated.' redirect_to team_projects_path(user_team), notice: 'Access was successfully updated.'
else else
render :edit render :edit
end end
...@@ -37,13 +40,13 @@ class Teams::ProjectsController < Teams::ApplicationController ...@@ -37,13 +40,13 @@ class Teams::ProjectsController < Teams::ApplicationController
def destroy def destroy
user_team.resign_from_project(team_project) user_team.resign_from_project(team_project)
redirect_to admin_team_path(user_team), notice: 'Project was successfully removed.' redirect_to team_projects_path(user_team), notice: 'Team of users was successfully reassigned from project.'
end end
private private
def team_project def team_project
@project ||= @team.projects.find_by_path(params[:id]) @project ||= user_team.projects.find_with_namespace(params[:id])
end end
end end
class TeamsController < ApplicationController class TeamsController < ApplicationController
respond_to :html # Authorize
layout 'user_team', only: [:show, :edit, :update, :destroy, :issues, :merge_requests, :search] before_filter :authorize_manage_user_team!
before_filter :authorize_admin_user_team!
before_filter :user_team, only: [:show, :edit, :update, :destroy, :issues, :merge_requests, :search] # Skip access control on public section
before_filter :projects, only: [:show, :edit, :update, :destroy, :issues, :merge_requests, :search] skip_before_filter :authorize_manage_user_team!, only: [:index, :show, :new, :destroy, :create, :search, :issues, :merge_requests]
skip_before_filter :authorize_admin_user_team!, only: [:index, :show, :new, :create, :search, :issues, :merge_requests]
# Authorize layout 'user_team', only: [:show, :edit, :update, :destroy, :issues, :merge_requests, :search]
before_filter :authorize_manage_user_team!, only: [:edit, :update]
before_filter :authorize_admin_user_team!, only: [:destroy]
def index def index
@teams = UserTeam.all @teams = UserTeam.order('name ASC')
end end
def show def show
@events = Event.in_projects(project_ids).limit(20).offset(params[:offset] || 0) user_team
projects
respond_to do |format| @events = Event.in_projects(user_team.project_ids).limit(20).offset(params[:offset] || 0)
format.html
format.js
format.atom { render layout: false }
end
end end
def edit def edit
user_team
end end
def update def update
...@@ -58,56 +54,37 @@ class TeamsController < ApplicationController ...@@ -58,56 +54,37 @@ class TeamsController < ApplicationController
# Get authored or assigned open merge requests # Get authored or assigned open merge requests
def merge_requests def merge_requests
@merge_requests = MergeRequest.of_user_team(@user_team) @merge_requests = MergeRequest.of_user_team(user_team)
@merge_requests = FilterContext.new(@merge_requests, params).execute @merge_requests = FilterContext.new(@merge_requests, params).execute
@merge_requests = @merge_requests.recent.page(params[:page]).per(20) @merge_requests = @merge_requests.recent.page(params[:page]).per(20)
end end
# Get only assigned issues # Get only assigned issues
def issues def issues
@issues = Issue.of_user_team(@user_team) @issues = Issue.of_user_team(user_team)
@issues = FilterContext.new(@issues, params).execute @issues = FilterContext.new(@issues, params).execute
@issues = @issues.recent.page(params[:page]).per(20) @issues = @issues.recent.page(params[:page]).per(20)
@issues = @issues.includes(:author, :project) @issues = @issues.includes(:author, :project)
respond_to do |format|
format.html
format.atom { render layout: false }
end
end end
def search def search
result = SearchContext.new(project_ids, params).execute result = SearchContext.new(user_team.project_ids, params).execute
@projects = result[:projects] @projects = result[:projects]
@merge_requests = result[:merge_requests] @merge_requests = result[:merge_requests]
@issues = result[:issues] @issues = result[:issues]
@wiki_pages = result[:wiki_pages] @wiki_pages = result[:wiki_pages]
@teams = result[:teams]
end end
protected protected
def user_team
@user_team ||= UserTeam.find_by_path(params[:id])
end
def projects def projects
@projects ||= user_team.projects.sorted_by_activity @projects ||= user_team.projects.sorted_by_activity
end end
def project_ids def user_team
projects.map(&:id) @team ||= UserTeam.find_by_path(params[:id])
end
def authorize_manage_user_team!
unless user_team.present? or can?(current_user, :manage_user_team, user_team)
return render_404
end
end end
def authorize_admin_user_team!
unless user_team.owner == current_user || current_user.admin?
return render_404
end
end
end end
...@@ -34,4 +34,5 @@ ...@@ -34,4 +34,5 @@
%td.bgred %td.bgred
= link_to 'Rename', edit_admin_team_path(team), id: "edit_#{dom_id(team)}", class: "btn small" = link_to 'Rename', edit_admin_team_path(team), id: "edit_#{dom_id(team)}", class: "btn small"
= link_to 'Destroy', admin_team_path(team), confirm: "REMOVE #{team.name}? Are you sure?", method: :delete, class: "btn small danger" = link_to 'Destroy', admin_team_path(team), confirm: "REMOVE #{team.name}? Are you sure?", method: :delete, class: "btn small danger"
= paginate @teams, theme: "admin" = paginate @teams, theme: "admin"
...@@ -14,8 +14,6 @@ ...@@ -14,8 +14,6 @@
%hr %hr
.padded .padded
%ul %ul
%li Team is kind of directory for several projects %li All created teams are public (users can view who enter into team and which project are assigned for this team)
%li All created teams are private
%li People within a team see only projects they have access to %li People within a team see only projects they have access to
%li All projects of team will be stored in team directory %li You will be able to assign existing projects for team
%li You will be able to move existing projects into team
...@@ -40,54 +40,51 @@ ...@@ -40,54 +40,51 @@
= link_to "Cancel", "#", class: "btn change-owner-cancel-link" = link_to "Cancel", "#", class: "btn change-owner-cancel-link"
%fieldset %fieldset
%legend Members (#{@team.members.count}) %legend
%table#members_list Members (#{@team.members.count})
%thead %span= link_to 'Add members', new_admin_team_member_path(@team), class: "btn success small right", id: :add_members_to_team
%tr - if @team.members.any?
%th User name %table#members_list
%th Default project access %thead
%th Team access %tr
%th.cred Danger Zone! %th User name
- @team.members.each do |member| %th Default project access
%tr.member %th Team access
%td %th.cred.span3 Danger Zone!
= link_to [:admin, member] do - @team.members.each do |member|
= member.name %tr.member
%small= "(#{member.email})" %td
%td= @team.human_default_projects_access(member) = link_to [:admin, member] do
%td= @team.admin?(member) ? "Admin" : "Member" = member.name
%td.bgred %small= "(#{member.email})"
= link_to 'Edit', edit_admin_team_member_path(@team, member), class: "btn small" %td= @team.human_default_projects_access(member)
&nbsp; %td= @team.admin?(member) ? "Admin" : "Member"
= link_to 'Remove', admin_team_member_path(@team, member), confirm: 'Remove member from team. Are you sure?', method: :delete, class: "btn danger small" %td.bgred
%tr = link_to 'Edit', edit_admin_team_member_path(@team, member), class: "btn small"
%td &nbsp;
%td = link_to 'Remove', admin_team_member_path(@team, member), confirm: 'Remove member from team. Are you sure?', method: :delete, class: "btn danger small"
%td
%td= link_to 'Add members', new_admin_team_member_path(@team), class: "btn primary", id: :add_members_to_team
%fieldset %fieldset
%legend Projects (#{@team.projects.count}) %legend
%table#projects_list Projects (#{@team.projects.count})
%thead %span= link_to 'Add projects', new_admin_team_project_path(@team), class: "btn success small right", id: :assign_projects_to_team
%tr - if @team.projects.any?
%th Project name %table#projects_list
%th Max access %thead
%th.cred Danger Zone! %tr
- @team.projects.each do |project| %th Project name
%tr.project %th Max access
%td %th.cred.span3 Danger Zone!
= link_to project.name_with_namespace, [:admin, project] - @team.projects.each do |project|
%td %tr.project
%span= @team.human_max_project_access(project) %td
%td.bgred = link_to project.name_with_namespace, [:admin, project]
= link_to 'Edit', edit_admin_team_project_path(@team, project), class: "btn small" %td
&nbsp; %span= @team.human_max_project_access(project)
= link_to 'Relegate', admin_team_project_path(@team, project), confirm: 'Remove project from team. Are you sure?', method: :delete, class: "btn danger small" %td.bgred
%tr = link_to 'Edit', edit_admin_team_project_path(@team, project), class: "btn small"
%td &nbsp;
%td = link_to 'Relegate', admin_team_project_path(@team, project), confirm: 'Remove project from team. Are you sure?', method: :delete, class: "btn danger small"
%td= link_to 'Add projects', new_admin_team_project_path(@team), class: "btn primary", id: :assign_projects_to_team
:javascript :javascript
$(function(){ $(function(){
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
%h5.title %h5.title
My Teams My Teams
%small %small
(#{teams.count}) (#{@teams.count})
%span.right %span.right
= link_to new_team_path, class: "btn very_small info" do = link_to new_team_path, class: "btn very_small info" do
%i.icon-plus %i.icon-plus
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
%i.icon-user %i.icon-user
All Teams All Teams
%ul.well-list %ul.well-list
- teams.each do |team| - @teams.each do |team|
%li %li
= link_to team_path(id: team.path), class: dom_class(team) do = link_to team_path(id: team.path), class: dom_class(team) do
%strong.well-title= truncate(team.name, length: 35) %strong.well-title= truncate(team.name, length: 35)
...@@ -20,4 +20,7 @@ ...@@ -20,4 +20,7 @@
&rarr; &rarr;
%span.last_activity %span.last_activity
%strong Projects: %strong Projects:
%span= current_user.authorized_projects.in_team(team).count %span= team.projects.count
%span.last_activity
%strong Members:
%span= team.members.count
...@@ -8,6 +8,9 @@ ...@@ -8,6 +8,9 @@
%span.separator %span.separator
%h1.project_name= title %h1.project_name= title
%ul.nav %ul.nav
%li
= link_to teams_path, title: "Teams of users", class: 'has_bottom_tooltip', 'data-original-title' => 'Teams list' do
%i.icon-globe
- if current_user.is_admin? - if current_user.is_admin?
%li %li
= link_to admin_root_path, title: "Admin area", class: 'has_bottom_tooltip', 'data-original-title' => 'Admin area' do = link_to admin_root_path, title: "Admin area", class: 'has_bottom_tooltip', 'data-original-title' => 'Admin area' do
......
!!! 5 !!! 5
%html{ lang: "en"} %html{ lang: "en"}
= render "layouts/head", title: "#{@user_team.name}" = render "layouts/head", title: "#{@team.name}"
%body{class: "#{app_theme} application"} %body{class: "#{app_theme} application"}
= render "layouts/flash" = render "layouts/flash"
= render "layouts/head_panel", title: "#{@user_team.name}" = render "layouts/head_panel", title: "#{@team.name}"
.container .container
%ul.main_menu %ul.main_menu
= nav_link(path: 'teams#show', html_options: {class: 'home'}) do = nav_link(path: 'teams#show', html_options: {class: 'home'}) do
= link_to "Home", team_path(@user_team), title: "Home" = link_to "Home", team_path(@team), title: "Home"
= nav_link(path: 'teams#issues') do = nav_link(path: 'teams#issues') do
= link_to issues_team_path(@user_team) do = link_to issues_team_path(@team) do
Issues Issues
%span.count= Issue.opened.of_user_team(@user_team).count %span.count= Issue.opened.of_user_team(@team).count
= nav_link(path: 'teams#merge_requests') do = nav_link(path: 'teams#merge_requests') do
= link_to merge_requests_team_path(@user_team) do = link_to merge_requests_team_path(@team) do
Merge Requests Merge Requests
%span.count= MergeRequest.opened.of_user_team(@user_team).count %span.count= MergeRequest.opened.of_user_team(@team).count
= nav_link(path: 'teams#search') do = nav_link(path: 'teams#search') do
= link_to "Search", search_team_path(@user_team) = link_to "Search", search_team_path(@team)
.content= yield .content= yield
%ul.nav.nav-tabs %ul.nav.nav-tabs
= nav_link(path: 'teams#show') do = nav_link(path: 'teams#show') do
= link_to team_path(@user_team), class: "activities-tab tab" do = link_to team_path(@team), class: "activities-tab tab" do
%i.icon-home %i.icon-home
Show Show
= nav_link(controller: [:members]) do = nav_link(controller: [:members]) do
= link_to team_members_path(@user_team), class: "team-tab tab" do = link_to team_members_path(@team), class: "team-tab tab" do
%i.icon-user %i.icon-user
Members Members
= nav_link(controller: [:projects]) do = nav_link(controller: [:projects]) do
= link_to team_projects_path(@user_team), class: "team-tab tab" do = link_to team_projects_path(@team), class: "team-tab tab" do
%i.icon-briefcase %i.icon-briefcase
Projects Projects
- if can? current_user, :manage_user_team, @user_team - if can? current_user, :admin_user_team, @team
= nav_link(path: 'teams#edit', html_options: {class: 'right'}) do = nav_link(path: 'teams#edit', html_options: {class: 'right'}) do
= link_to edit_team_path(@user_team), class: "stat-tab tab " do = link_to edit_team_path(@team), class: "stat-tab tab " do
%i.icon-edit %i.icon-edit
Edit Edit Team
= render "team_head" = render "team_head"
%h3.page_title= "Edit Team #{@user_team.name}" %h3.page_title= "Edit Team #{@team.name}"
%hr %hr
= form_for @user_team, url: teams_path do |f| = form_for @team, url: teams_path do |f|
- if @user_team.errors.any? - if @team.errors.any?
.alert-message.block-message.error .alert-message.block-message.error
%span= @user_team.errors.full_messages.first %span= @team.errors.full_messages.first
.clearfix .clearfix
= f.label :name do = f.label :name do
Team name is Team name is
...@@ -21,12 +21,4 @@ ...@@ -21,12 +21,4 @@
.input.span3.center .input.span3.center
= f.submit 'Save team changes', class: "btn primary" = f.submit 'Save team changes', class: "btn primary"
.input.span3.center .input.span3.center
= link_to 'Delete team', team_path(@user_team), method: :delete, confirm: "You are shure?", class: "btn danger" = link_to 'Delete team', team_path(@team), method: :delete, confirm: "You are shure?", class: "btn danger"
%hr
.padded
%ul
%li Team is kind of directory for several projects
%li All created teams are private
%li People within a team see only projects they have access to
%li All projects of team will be stored in team directory
%li You will be able to move existing projects into team
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
%small %small
list of all teams list of all teams
= link_to 'New Team', new_team_path, class: "btn small right" = link_to 'New Team', new_team_path, class: "btn success small right"
%br %br
= form_tag search_teams_path, method: :get, class: 'form-inline' do = form_tag search_teams_path, method: :get, class: 'form-inline' do
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
%td= link_to team.owner.name, team_member_path(team, team.owner) %td= link_to team.owner.name, team_member_path(team, team.owner)
%td %td
- if current_user.can?(:manage_user_team, team) - if current_user.can?(:manage_user_team, team)
- if team.owner == current_user - if current_user.can?(:admin_user_team, team)
= link_to "Destroy", team_path(team), method: :delete, confirm: "You are shure?", class: "danger btn small right" = link_to "Destroy", team_path(team), method: :delete, confirm: "You are shure?", class: "danger btn small right"
&nbsp;
= link_to "Edit", edit_team_path(team), class: "btn small right" = link_to "Edit", edit_team_path(team), class: "btn small right"
%h3.page_title = form_tag admin_team_member_path(@team, @member), method: :put do
= "New Team member(s)" -if @member.errors.any?
%hr
= form_for @team_member, as: :team_member, url: project_team_members_path(@project, @team_member) do |f|
-if @team_member.errors.any?
.alert-message.block-message.error .alert-message.block-message.error
%ul %ul
- @team_member.errors.full_messages.each do |msg| - @member.errors.full_messages.each do |msg|
%li= msg %li= msg
%h6 1. Choose people you want in the team
.clearfix .clearfix
= f.label :user_ids, "People" %label Default access for Team projects:
.input= select_tag(:user_ids, options_from_collection_for_select(User.active.not_in_project(@project).alphabetically, :id, :name), {data: {placeholder: "Select users"}, class: "chosen xxlarge", multiple: true}) .input
= select_tag :default_project_access, options_for_select(UserTeam.access_roles, @team.default_projects_access(@member)), class: "project-access-select chosen span3"
%h6 2. Set access level for them
.clearfix .clearfix
= f.label :project_access, "Project Access" %label Team admin?
.input= select_tag :project_access, options_for_select(Project.access_options, @team_member.project_access), class: "project-access-select chosen" .input
= check_box_tag :group_admin, true, @team.admin?(@member)
%br
.actions .actions
= f.submit 'Save', class: "btn save-btn" = submit_tag 'Save', class: "btn primary"
= link_to "Cancel", project_team_index_path(@project), class: "btn cancel-btn" = link_to 'Cancel', :back, class: "btn"
- user = member.user - user = member.user
- allow_admin = can? current_user, :manage_user_team, @user_team - allow_admin = can? current_user, :manage_user_team, @team
%li{id: dom_id(member), class: "team_member_row user_#{user.id}"} %li{id: dom_id(member), class: "team_member_row user_#{user.id}"}
.row .row
.span5 .span5
= link_to team_member_path(@user_team, user), title: user.name, class: "dark" do = link_to team_member_path(@team, user), title: user.name, class: "dark" do
= image_tag gravatar_icon(user.email, 40), class: "avatar s32" = image_tag gravatar_icon(user.email, 40), class: "avatar s32"
= link_to team_member_path(@user_team, user), title: user.name, class: "dark" do = link_to team_member_path(@team, user), title: user.name, class: "dark" do
%strong= truncate(user.name, lenght: 40) %strong= truncate(user.name, lenght: 40)
%br %br
%small.cgray= user.email %small.cgray= user.email
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
.span6.right .span6.right
- if allow_admin - if allow_admin
.left.span2 .left.span2
= form_for(member, as: :team_member, url: team_member_path(@user_team, user)) do |f| = form_for(member, as: :team_member, url: team_member_path(@team, user)) do |f|
= f.select :permission, options_for_select(UsersProject.access_roles, @user_team.default_projects_access(user)), {}, class: "medium project-access-select span2" = f.select :permission, options_for_select(UsersProject.access_roles, @team.default_projects_access(user)), {}, class: "medium project-access-select span2"
.left.span2 .left.span2
%span %span
Admin access Admin access
...@@ -22,10 +22,10 @@ ...@@ -22,10 +22,10 @@
.right .right
- if current_user == user - if current_user == user
%span.btn.disabled This is you! %span.btn.disabled This is you!
- if @user_team.owner == user - if @team.owner == user
%span.btn.disabled.success Owner %span.btn.disabled.success Owner
- elsif user.blocked - elsif user.blocked
%span.btn.disabled.blocked Blocked %span.btn.disabled.blocked Blocked
- elsif allow_admin - elsif allow_admin
= link_to team_member_path(@user_team, user), confirm: remove_from_user_team_message(@user_team, user), method: :delete, class: "very_small btn danger" do = link_to team_member_path(@team, user), confirm: remove_from_user_team_message(@team, user), method: :delete, class: "very_small btn danger" do
%i.icon-minus.icon-white %i.icon-minus.icon-white
- grouped_user_team_members(@user_team).each do |access, members| - grouped_user_team_members(@team).each do |access, members|
.ui-box .ui-box
%h5.title %h5.title
= Project.access_options.key(access).pluralize = Project.access_options.key(access).pluralize
......
%h1 Teams::Members#edit = render "teams/team_head"
%p Find me in app/views/teams/members/edit.html.haml
\ No newline at end of file %h3
Edit access #{@member.name} in #{@team.name} team
%hr
%table.zebra-striped
%tr
%td User:
%td= @member.name
%tr
%td Team:
%td= @team.name
%tr
%td Since:
%td= member_since(@team, @member).stamp("Nov 11, 2010")
= render 'form'
= render "projects/project_head"
%h3.page_title
= "Import team from another project"
%hr
%p.slead
Read more about team import #{link_to "here", '#', class: 'vlink'}.
= form_tag apply_import_project_team_members_path(@project), method: 'post' do
%p.slead Choose project you want to use as team source:
.padded
= label_tag :source_project_id, "Project"
.input= select_tag(:source_project_id, options_from_collection_for_select(current_user.authorized_projects, :id, :name_with_namespace), prompt: "Select project", class: "chosen xxlarge", required: true)
.actions
= submit_tag 'Import', class: "btn save-btn"
= link_to "Cancel", project_team_index_path(@project), class: "btn cancel-btn"
= render "teams/team_head" = render "teams/team_head"
%h3.page_title %h3.page_title
Team Members Team Members
(#{@members.count}) (#{@members.count})
...@@ -6,13 +7,13 @@ ...@@ -6,13 +7,13 @@
Read more about project permissions Read more about project permissions
%strong= link_to "here", help_permissions_path, class: "vlink" %strong= link_to "here", help_permissions_path, class: "vlink"
- if can? current_user, :manage_user_team, @user_team - if can? current_user, :manage_user_team, @team
%span.right %span.right
= link_to new_team_member_path(@user_team), class: "btn success small grouped", title: "New Team Member" do = link_to new_team_member_path(@team), class: "btn success small grouped", title: "New Team Member" do
New Team Member New Team Member
%hr %hr
.clearfix .clearfix
%div.team-table %div.team-table
= render partial: "teams/members/team", locals: {project: @user_team} = render partial: "teams/members/team", locals: {project: @team}
= render "projects/project_head" = render "teams/team_head"
= render "team_members/form"
%h3.page_title
Team: #{@team.name}
%fieldset
%legend Members (#{@team.members.count})
= form_tag team_members_path(@team), id: "team_members", class: "bulk_import", method: :post do
%table#members_list
%thead
%tr
%th User name
%th Default project access
%th Team access
%th
- @team.members.each do |member|
%tr.member
%td
= member.name
%small= "(#{member.email})"
%td= @team.human_default_projects_access(member)
%td= @team.admin?(member) ? "Admin" : "Member"
%td
%tr
%td= select_tag :user_ids, options_from_collection_for_select(@users , :id, :name_with_email), multiple: true, data: {placeholder: 'Select users'}, class: 'chosen span5'
%td= select_tag :default_project_access, options_for_select(Project.access_options), {class: "project-access-select chosen span3" }
%td
%span= check_box_tag :group_admin
%span Admin?
%td= submit_tag 'Add', class: "btn primary", id: :add_members_to_team
= 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
......
= 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)
......
...@@ -14,8 +14,6 @@ ...@@ -14,8 +14,6 @@
%hr %hr
.padded .padded
%ul %ul
%li Team is kind of directory for several projects %li All created teams are public (users can view who enter into team and which project are assigned for this team)
%li All created teams are private
%li People within a team see only projects they have access to %li People within a team see only projects they have access to
%li All projects of team will be stored in team directory %li You will be able to assign existing projects for team
%li You will be able to move existing projects into team
= form_tag team_project_path(@team, @project), method: :put do
-if @project.errors.any?
.alert-message.block-message.error
%ul
- @project.errors.full_messages.each do |msg|
%li= msg
.clearfix
%label Max access for Team members:
.input
= select_tag :greatest_project_access, options_for_select(UserTeam.access_roles, @team.max_project_access(@project)), class: "project-access-select chosen span3"
%br
.actions
= submit_tag 'Save', class: "btn primary"
= link_to 'Cancel', :back, class: "btn"
= render "teams/team_head" = render "teams/team_head"
%h1 Teams::Projects#edit %h3
%p Find me in app/views/teams/projects/edit.html.haml Edit max access in #{@project.name} for #{@team.name} team
%hr
%table.zebra-striped
%tr
%td Project:
%td= @project.name
%tr
%td Team:
%td= @team.name
%tr
%td Since:
%td= assigned_since(@team, @project).stamp("Nov 11, 2010")
= render 'form'
= render "teams/team_head" = render "teams/team_head"
%fieldset %h3.page_title
%legend Projects (#{@user_team.projects.count}) Assigned projects (#{@team.projects.count})
= form_tag delegate_projects_team_path(@user_team), id: "team_projects", class: "bulk_import", method: :post do %small
%table Read more about project permissions
%thead %strong= link_to "here", help_permissions_path, class: "vlink"
%tr
%th Project name
%th Max access
%th
- @user_team.projects.each do |project|
%tr.project
%td
= link_to project.name_with_namespace, project
%td
%span= @user_team.human_max_project_access(project)
-# if current_user.can?(:manage_user_team, @user_team)
- relation = project.user_team_project_relationships.find_by_user_team_id(@user_team)
= form_for(relation, as: :project, url: team_project_path(@user_team, project)) do |f|
= f.select :greatest_access, options_for_select(UsersProject.access_roles, @user_team.max_project_access(project)), {}, class: "medium project-access-select span2"
- if current_user.can?(:admin_user_team, @user_team) - if current_user.can?(:manage_user_team, @team) && @avaliable_projects.any?
%td.bgred %span.right
-#= link_to 'Edit max access', edit_project_team_path(@user_team, project), class: "btn small" = link_to new_team_project_path(@team), class: "btn success small grouped", title: "New Team Member" do
= link_to 'Relegate', relegate_project_team_path(@user_team, project_id: project.id), confirm: 'Remove project from team and move to global namespace. Are you sure?', method: :delete, class: "btn danger small" Assign project to Team
- else
%td
- if @avaliable_projects.any? %hr
%tr
%td= select_tag :project_ids, options_from_collection_for_select(@avaliable_projects , :id, :name_with_namespace), multiple: true, data: {placeholder: 'Select projects'}, class: 'chosen span5' %table
%td= select_tag :greatest_project_access, options_for_select(Project.access_options), {class: "project-access-select chosen span3" } %thead
%td= submit_tag 'Add', class: "btn primary" %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)
- 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"
= render "teams/team_head" = render "teams/team_head"
%h1 Teams::Projects#new %h3.page_title
%p Find me in app/views/teams/projects/new.html.haml Team: #{@team.name}
%fieldset
%legend Projects (#{@team.projects.count})
= form_tag team_projects_path(@team), id: "assign_projects", class: "bulk_import", method: :post do
%table#projects_list
%thead
%tr
%th Project name
%th Max access
%th
- @team.projects.each do |project|
%tr.project
%td
= link_to project.name_with_namespace, team_project_path(@team, project)
%td
%span= @team.human_max_project_access(project)
%td
%tr
%td= select_tag :project_ids, options_from_collection_for_select(@avaliable_projects , :id, :name_with_namespace), multiple: true, data: {placeholder: 'Select projects'}, class: 'chosen span5'
%td= select_tag :greatest_project_access, options_for_select(UserTeam.access_roles), {class: "project-access-select chosen span3" }
%td= submit_tag 'Add', class: "btn primary", id: :assign_projects_to_team
= render "teams/team_head"
%h1 Teams::Projects#edit
%p Find me in app/views/teams/projects/edit.html.haml
= render "team_head" = render "team_head"
= form_tag search_team_path(@user_team), method: :get, class: 'form-inline' do |f| = form_tag search_team_path(@team), method: :get, class: 'form-inline' do |f|
.padded .padded
= label_tag :search do = label_tag :search do
%strong Looking for %strong Looking for
......
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