From 441d25618809c295349f7dae4e45bfbbc0fb7144 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 14 Mar 2013 12:38:43 +0200 Subject: [PATCH] Rebuild team area --- .../stylesheets/gitlab_bootstrap/tables.scss | 6 ++ app/controllers/teams/projects_controller.rb | 21 +--- app/controllers/teams_controller.rb | 2 + app/views/layouts/user_team.html.haml | 8 +- app/views/teams/_projects.html.haml | 2 +- app/views/teams/edit.html.haml | 99 +++++++++++++------ app/views/teams/projects/index.html.haml | 36 ------- app/views/teams/projects/new.html.haml | 23 ----- 8 files changed, 81 insertions(+), 116 deletions(-) delete mode 100644 app/views/teams/projects/index.html.haml delete mode 100644 app/views/teams/projects/new.html.haml diff --git a/app/assets/stylesheets/gitlab_bootstrap/tables.scss b/app/assets/stylesheets/gitlab_bootstrap/tables.scss index 7a9eac82..f46ae91b 100644 --- a/app/assets/stylesheets/gitlab_bootstrap/tables.scss +++ b/app/assets/stylesheets/gitlab_bootstrap/tables.scss @@ -11,6 +11,12 @@ table { } } + &.headless { + tr:first-child td{ + border-top: 1px solid #CCC; + } + } + th { font-weight: bold; vertical-align: middle; diff --git a/app/controllers/teams/projects_controller.rb b/app/controllers/teams/projects_controller.rb index e87889b4..81ffa238 100644 --- a/app/controllers/teams/projects_controller.rb +++ b/app/controllers/teams/projects_controller.rb @@ -1,20 +1,4 @@ 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 diff --git a/app/controllers/teams_controller.rb b/app/controllers/teams_controller.rb index 4861892d..26c1d84f 100644 --- a/app/controllers/teams_controller.rb +++ b/app/controllers/teams_controller.rb @@ -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 diff --git a/app/views/layouts/user_team.html.haml b/app/views/layouts/user_team.html.haml index e5e08aab..483bfad6 100644 --- a/app/views/layouts/user_team.html.haml +++ b/app/views/layouts/user_team.html.haml @@ -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 diff --git a/app/views/teams/_projects.html.haml b/app/views/teams/_projects.html.haml index 5677255b..238db928 100644 --- a/app/views/teams/_projects.html.haml +++ b/app/views/teams/_projects.html.haml @@ -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 diff --git a/app/views/teams/edit.html.haml b/app/views/teams/edit.html.haml index 95c91b50..2e13c1ec 100644 --- a/app/views/teams/edit.html.haml +++ b/app/views/teams/edit.html.haml @@ -1,34 +1,73 @@ -%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" + .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' - .clearfix.team-description-holder - = f.label :description, "Details" - .input - = f.text_area :description, maxlength: 250, class: "xlarge js-gfm-input", rows: 4 + .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 - .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" + .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" diff --git a/app/views/teams/projects/index.html.haml b/app/views/teams/projects/index.html.haml deleted file mode 100644 index 696ee29c..00000000 --- a/app/views/teams/projects/index.html.haml +++ /dev/null @@ -1,36 +0,0 @@ -%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 diff --git a/app/views/teams/projects/new.html.haml b/app/views/teams/projects/new.html.haml deleted file mode 100644 index 3f3671aa..00000000 --- a/app/views/teams/projects/new.html.haml +++ /dev/null @@ -1,23 +0,0 @@ -%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