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