Commit 441d2561 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Rebuild team area

parent f4f36f78
......@@ -11,6 +11,12 @@ table {
}
}
&.headless {
tr:first-child td{
border-top: 1px solid #CCC;
}
}
th {
font-weight: bold;
vertical-align: middle;
......
class Teams::ProjectsController < Teams::ApplicationController
skip_before_filter :authorize_manage_user_team!, only: [:index]
def index
@projects = user_team.projects
@avaliable_projects = current_user.admin? ? Project.without_team(user_team) : current_user.owned_projects.without_team(user_team)
end
def new
user_team
@avaliable_projects = current_user.owned_projects.scoped
@avaliable_projects = @avaliable_projects.without_team(user_team) if user_team.projects.any?
redirect_to team_projects_path(user_team), notice: "No avalible projects." unless @avaliable_projects.any?
end
def create
redirect_to :back if params[:project_ids].blank?
......@@ -28,7 +12,7 @@ class Teams::ProjectsController < Teams::ApplicationController
# Assign projects to team
user_team.assign_to_projects(project_ids, access)
redirect_to team_projects_path(user_team), notice: 'Team of users was successfully assigned to projects.'
redirect_to edit_team_path(user_team), notice: 'Team of users was successfully assigned to projects.'
end
def edit
......@@ -37,7 +21,7 @@ class Teams::ProjectsController < Teams::ApplicationController
def update
if user_team.update_project_access(team_project, params[:greatest_project_access])
redirect_to team_projects_path(user_team), notice: 'Access was successfully updated.'
redirect_to edit_team_path(user_team), notice: 'Access was successfully updated.'
else
render :edit
end
......@@ -53,5 +37,4 @@ class Teams::ProjectsController < Teams::ApplicationController
def team_project
@project ||= user_team.projects.find_with_namespace(params[:id])
end
end
......@@ -14,6 +14,8 @@ class TeamsController < ApplicationController
end
def edit
projects
@avaliable_projects = current_user.admin? ? Project.without_team(user_team) : current_user.owned_projects.without_team(user_team)
end
def update
......
......@@ -26,14 +26,8 @@
%span.count= @team.members.count
- if can? current_user, :admin_user_team, @team
= nav_link(controller: [:projects]) do
= link_to team_projects_path(@team), class: "team-tab tab" do
Projects
%span.count= @team.projects.count
= nav_link(path: 'teams#edit') do
= link_to edit_team_path(@team), class: "stat-tab tab " do
%i.icon-edit
Edit Team
Settings
.content= yield
......@@ -5,7 +5,7 @@
(#{projects.count})
- if can? current_user, :manage_user_team, @team
%span.pull-right
= link_to new_team_project_path(@team), class: "btn btn-tiny info" do
= link_to edit_team_path(@team), class: "btn btn-tiny info" do
%i.icon-plus
Assign Project
%ul.well-list
......
%h3.page_title= "Edit Team #{@team.name}"
%hr
.row
.span7
= form_for @team, url: team_path(@team) do |f|
- if @team.errors.any?
.alert.alert-error
%span= @team.errors.full_messages.first
.clearfix
= f.label :name do
Team name is
.input
= f.text_field :name, placeholder: "Ex. OpenSource", class: "xlarge left"
.clearfix.team-description-holder
= f.label :description, "Details"
.input
= f.text_area :description, maxlength: 250, class: "xlarge js-gfm-input", rows: 4
.clearfix
= f.label :path do
Team path is
.input
= f.text_field :path, placeholder: "opensource", class: "xlarge left"
.form-actions
= f.submit 'Save team changes', class: "btn btn-primary"
.span5
.ui-box
%h5.title Remove team
.padded.bgred
%p
Removed team can not be restored!
= link_to 'Remove team', team_path(@team), method: :delete, confirm: "You are sure?", class: "btn btn-remove btn-small"
.span3
%ul.nav.nav-pills.nav-stacked
%li.active
= link_to 'Projects', '#tab-projects', 'data-toggle' => 'tab'
%li
= link_to 'Edit Team', '#tab-edit', 'data-toggle' => 'tab'
%li
= link_to 'Remove', '#tab-remove', 'data-toggle' => 'tab'
.span9
.tab-content
.tab-pane.active#tab-projects
.ui-box
%h5.title Projects
%ul.well-list
- @projects.each do |project|
%li
- if project.public
%i.icon-share
- else
%i.icon-lock.cgreen
= link_to project.name_with_namespace, project
.pull-right
= link_to 'Edit max access', edit_team_project_path(@team, project), class: "btn 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 btn-remove small"
.form-holder
= form_tag team_projects_path(@team), id: "assign_projects", class: "bulk_import", method: :post do
%table.headless
%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 span4'
%td= select_tag :greatest_project_access, options_for_select(UserTeam.access_roles), {class: "project-access-select chosen" }
%td= submit_tag 'Add Project', class: "btn btn-create", id: :assign_projects_to_team
.tab-pane#tab-edit
.ui-box
%h5.title Edit Team
%div.form-holder
= form_for @team, url: team_path(@team) do |f|
- if @team.errors.any?
.alert.alert-error
%span= @team.errors.full_messages.first
.clearfix
= f.label :name do
Team name is
.input
= f.text_field :name, placeholder: "Ex. OpenSource", class: "xlarge left"
.clearfix.team-description-holder
= f.label :description, "Details"
.input
= f.text_area :description, maxlength: 250, class: "xlarge js-gfm-input", rows: 4
.clearfix
= f.label :path do
Team path is
.input
= f.text_field :path, placeholder: "opensource", class: "xlarge left"
.form-actions
= f.submit 'Save team changes', class: "btn btn-primary"
.tab-pane#tab-remove
.ui-box.ui-box-danger
%h5.title Remove team
.ui-box-body
%p
Remove of team will cause removing members access to projects.
%p
%strong Removed team can not be restored!
= link_to 'Remove team', team_path(@team), method: :delete, confirm: "You are sure?", class: "btn btn-remove btn-small"
%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?(:manage_user_team, @team) && @avaliable_projects.any?
%span.pull-right
= link_to new_team_project_path(@team), class: "btn btn-primary small grouped", title: "New Team Member" do
Assign project to Team
%hr
- if @team.projects.present?
%table.projects-table
%thead
%tr
%th Project name
%th Max access
- if current_user.can?(:admin_user_team, @team)
%th.span3
- @team.projects.each do |project|
%tr.project
%td
= link_to project.name_with_namespace, project_path(project)
%td
%span= @team.human_max_project_access(project)
- if current_user.can?(:admin_user_team, @team)
%td.bgred
= link_to 'Edit max access', edit_team_project_path(@team, project), class: "btn 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 btn-remove small"
- else
%p.nothing_here_message This team has no projects yet
%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 Project', class: "btn btn-create", id: :assign_projects_to_team
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