Commit ba74fa1413d3274f7a3282d7f59046beecb32912

Authored by Dmitriy Zaporozhets
1 parent 7f6bbf06

Remove some bugs. Add warnings for renaming group. Add ability to cahnge group owner.

app/assets/stylesheets/gitlab_bootstrap/common.scss
... ... @@ -100,17 +100,3 @@ input[type='search'].search-text-input {
100 100 }
101 101  
102 102 fieldset legend { font-size: 17px; }
103   -
104   -ul.nav.nav-projects-tabs {
105   - @extend .nav-tabs;
106   -
107   - padding-left: 8px;
108   -
109   - li {
110   - a {
111   - padding: 4px 20px;
112   - margin-top: 2px;
113   - border-color: #DDD;
114   - }
115   - }
116   -}
... ...
app/assets/stylesheets/sections/projects.scss
... ... @@ -4,7 +4,6 @@
4 4 }
5 5  
6 6 .side {
7   - @extend .span4;
8 7 @extend .right;
9 8  
10 9 .groups_box,
... ... @@ -117,3 +116,25 @@
117 116 }
118 117  
119 118 }
  119 +
  120 +ul.nav.nav-projects-tabs {
  121 + @extend .nav-tabs;
  122 +
  123 + padding-left: 8px;
  124 +
  125 + li {
  126 + a {
  127 + padding: 4px 20px;
  128 + margin-top: 2px;
  129 + border-color: #DDD;
  130 + background-color: #EEE;
  131 + text-shadow: 0 1px 1px white;
  132 + color: #555;
  133 + }
  134 + &.active {
  135 + a {
  136 + font-weight: bold;
  137 + }
  138 + }
  139 + }
  140 +}
... ...
app/controllers/admin/groups_controller.rb
... ... @@ -11,6 +11,7 @@ class Admin::GroupsController < AdminController
11 11 @projects = Project.scoped
12 12 @projects = @projects.not_in_group(@group) if @group.projects.present?
13 13 @projects = @projects.all
  14 + @projects.reject!(&:empty_repo?)
14 15 end
15 16  
16 17 def new
... ...
app/controllers/admin/projects_controller.rb
... ... @@ -4,6 +4,7 @@ class Admin::ProjectsController < AdminController
4 4 def index
5 5 @projects = Project.scoped
6 6 @projects = @projects.where(namespace_id: params[:namespace_id]) if params[:namespace_id].present?
  7 + @projects = @projects.where(namespace_id: nil) if params[:namespace_id] == Namespace.global_id
7 8 @projects = @projects.search(params[:name]) if params[:name].present?
8 9 @projects = @projects.includes(:namespace).order("namespaces.path, projects.name ASC").page(params[:page]).per(20)
9 10 end
... ...
app/views/admin/groups/_form.html.haml
... ... @@ -1,12 +0,0 @@
1   -= form_for [:admin, @group] do |f|
2   - - if @group.errors.any?
3   - .alert-message.block-message.error
4   - %span= @group.errors.full_messages.first
5   - .clearfix.group_name_holder
6   - = f.label :name do
7   - Group name is
8   - .input
9   - = f.text_field :name, placeholder: "Example Group", class: "xxlarge"
10   -
11   - .form-actions
12   - = f.submit 'Save group', class: "btn save-btn"
app/views/admin/groups/edit.html.haml
1   -%h3.page_title Edit Group
2   -%br
3   -= render 'form'
  1 +%h3.page_title Rename Group
  2 +%hr
  3 +.alert
  4 + Renaming group can have unintended side effects.
  5 + %br
  6 + Renaming group will rename directory for all related projects
  7 += form_for [:admin, @group] do |f|
  8 + - if @group.errors.any?
  9 + .alert-message.block-message.error
  10 + %span= @group.errors.full_messages.first
  11 + .clearfix.group_name_holder
  12 + = f.label :name do
  13 + Group name is
  14 + .input
  15 + = f.text_field :name, placeholder: "Example Group", class: "xxlarge"
  16 +
  17 + .form-actions
  18 + = f.submit 'Rename group', class: "btn save-btn"
  19 + = link_to 'Cancel', admin_groups_path, class: "btn cancel-btn"
... ...
app/views/admin/groups/index.html.haml
... ... @@ -15,7 +15,6 @@
15 15 %th Name
16 16 %th Path
17 17 %th Projects
18   - %th Edit
19 18 %th.cred Danger Zone!
20 19  
21 20 - @groups.each do |group|
... ... @@ -23,6 +22,7 @@
23 22 %td= link_to group.name, [:admin, group]
24 23 %td= group.path
25 24 %td= group.projects.count
26   - %td= link_to 'Edit', edit_admin_group_path(group), id: "edit_#{dom_id(group)}", class: "btn small"
27   - %td.bgred= link_to 'Destroy', [:admin, group], confirm: "REMOVE #{group.name}? Are you sure?", method: :delete, class: "btn small danger"
  25 + %td.bgred
  26 + = link_to 'Rename', edit_admin_group_path(group), id: "edit_#{dom_id(group)}", class: "btn small"
  27 + = link_to 'Destroy', [:admin, group], confirm: "REMOVE #{group.name}? Are you sure?", method: :delete, class: "btn small danger"
28 28 = paginate @groups, theme: "admin"
... ...
app/views/admin/groups/show.html.haml
1 1 %h3.page_title
2 2 Group: #{@group.name}
3   - = link_to edit_admin_group_path(@group), class: "btn right" do
4   - %i.icon-edit
5   - Edit
6 3  
7 4 %br
8 5 %table.zebra-striped
... ... @@ -16,6 +13,10 @@
16 13 Name:
17 14 %td
18 15 = @group.name
  16 +  
  17 + = link_to edit_admin_group_path(@group), class: "btn btn-small right" do
  18 + %i.icon-edit
  19 + Rename
19 20 %tr
20 21 %td
21 22 %b
... ... @@ -28,24 +29,43 @@
28 29 Owner:
29 30 %td
30 31 = @group.owner_name
31   -.ui-box
32   - %h5
33   - Projects
34   - %small
35   - (#{@group.projects.count})
36   - %ul.unstyled
  32 + .right
  33 + = link_to "#", class: "btn btn-small change-owner-link" do
  34 + %i.icon-edit
  35 + Change owner
  36 + .change-owner-holder.hide
  37 + = form_for [:admin, @group] do |f|
  38 + = f.select :owner_id, User.all.map { |user| [user.name, user.id] }, {}, {class: 'chosen'}
  39 + = f.submit 'Save', class: "btn btn-small save-btn"
  40 + = link_to "Cancel", "#", class: "btn btn-small change-owner-cancel-link"
  41 +
  42 +%fieldset
  43 + %legend Projects (#{@group.projects.count})
  44 + %table
  45 + %thead
  46 + %tr
  47 + %th Project name
  48 + %th Path
  49 + %th Users
  50 + %th.cred Danger Zone!
37 51 - @group.projects.each do |project|
38   - %li.wll
39   - %strong
40   - = link_to project.name, [:admin, project]
41   - .right
42   - = link_to 'Remove from group', remove_project_admin_group_path(@group, project_id: project.id), confirm: 'Are you sure?', method: :delete, class: "btn danger small"
43   - .clearfix
  52 + %tr
  53 + %td
  54 + = link_to project.name_with_namespace, [:admin, project]
  55 + %td
  56 + %span.monospace= project.path_with_namespace + ".git"
  57 + %td= project.users.count
  58 + %td.bgred
  59 + = link_to 'Transfer project to global namespace', remove_project_admin_group_path(@group, project_id: project.id), confirm: 'Remove project from group and move to global namespace. Are you sure?', method: :delete, class: "btn danger small"
44 60  
45 61  
46 62 = form_tag project_update_admin_group_path(@group), class: "bulk_import", method: :put do
47 63 %fieldset
48 64 %legend Move projects to group
  65 + .alert
  66 + You can move only projects with existing repos
  67 + %br
  68 + Group projects will be moved in group directory and will not be accessible by old path
49 69 .clearfix
50 70 = label_tag :project_ids do
51 71 Projects
... ... @@ -53,3 +73,17 @@
53 73 = select_tag :project_ids, options_from_collection_for_select(@projects , :id, :name_with_namespace), multiple: true, data: {placeholder: 'Select projects'}, class: 'chosen span5'
54 74 .form-actions
55 75 = submit_tag 'Add', class: "btn primary"
  76 +
  77 +:javascript
  78 + $(function(){
  79 + var modal = $('.change-owner-holder');
  80 + $('.change-owner-link').bind("click", function(){
  81 + $(this).hide();
  82 + modal.show();
  83 + });
  84 + $('.change-owner-cancel-link').bind("click", function(){
  85 + modal.hide();
  86 + $('.change-owner-link').show();
  87 + })
  88 + })
  89 +
... ...
app/views/admin/projects/_form.html.haml
... ... @@ -22,7 +22,10 @@
22 22 - unless project.new_record?
23 23 .clearfix
24 24 = f.label :namespace_id
25   - .input= f.select :namespace_id, namespaces_options(@project.namespace_id), {}, {class: 'chosen'}
  25 + .input
  26 + = f.select :namespace_id, namespaces_options(@project.namespace_id), {}, {class: 'chosen'}
  27 +  
  28 + %span.cred Be careful. Changing project namespace can have unintended side effects
26 29  
27 30 - if project.repo_exists?
28 31 .clearfix
... ...
app/views/dashboard/index.html.haml
... ... @@ -2,7 +2,7 @@
2 2 .projects
3 3 .activities.span8
4 4 = render 'activities'
5   - .side
  5 + .side.span4
6 6 = render 'sidebar'
7 7  
8 8 - else
... ...
app/views/groups/show.html.haml
... ... @@ -11,7 +11,7 @@
11 11 - else
12 12 %p.nothing_here_message Projects activity will be displayed here
13 13 .loading.hide
14   - .side
  14 + .side.span4
15 15 = render "projects", projects: @projects
16 16 %div
17 17 %span.rss-icon
... ...