From 81697850eb16d66615fb072e7c288b3b3dc70758 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 17 Jun 2013 13:07:16 +0300 Subject: create UsersGroup entity. Modify ability to check group owners instead one owner --- app/models/ability.rb | 2 +- app/models/group.rb | 6 +++ app/models/users_group.rb | 21 ++++++++ db/migrate/20130617095603_create_users_groups.rb | 11 ++++ db/schema.rb | 68 +++++++++++------------- spec/factories/users_groups.rb | 9 ++++ spec/models/users_group_spec.rb | 5 ++ 7 files changed, 85 insertions(+), 37 deletions(-) create mode 100644 app/models/users_group.rb create mode 100644 db/migrate/20130617095603_create_users_groups.rb create mode 100644 spec/factories/users_groups.rb create mode 100644 spec/models/users_group_spec.rb diff --git a/app/models/ability.rb b/app/models/ability.rb index 0b6314cd555..0199012d6fc 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -132,7 +132,7 @@ class Ability rules = [] # Only group owner and administrators can manage group - if group.owner == user || user.admin? + if group.owners.include?(user) || user.admin? rules << [ :manage_group, :manage_namespace diff --git a/app/models/group.rb b/app/models/group.rb index 17671c3defe..643308f250a 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -13,6 +13,8 @@ # class Group < Namespace + has_many :users_groups, dependent: :destroy + has_many :users, through: :users_groups def add_users_to_project_teams(user_ids, project_access) UsersProject.add_users_into_projects( @@ -35,4 +37,8 @@ class Group < Namespace def truncate_teams UsersProject.truncate_teams(project_ids) end + + def owners + @owners ||= (users_groups.owners.map(&:user) << owner) + end end diff --git a/app/models/users_group.rb b/app/models/users_group.rb new file mode 100644 index 00000000000..b95dd2520c0 --- /dev/null +++ b/app/models/users_group.rb @@ -0,0 +1,21 @@ +class UsersGroup < ActiveRecord::Base + GUEST = 10 + REPORTER = 20 + DEVELOPER = 30 + MASTER = 40 + OWNER = 50 + + attr_accessible :group_access, :group_id, :user_id + + belongs_to :user + belongs_to :project + + scope :guests, -> { where(group_access: GUEST) } + scope :reporters, -> { where(group_access: REPORTER) } + scope :developers, -> { where(group_access: DEVELOPER) } + scope :masters, -> { where(group_access: MASTER) } + scope :owners, -> { where(group_access: OWNER) } + + scope :with_group, ->(group) { where(group_id: group.id) } + scope :with_user, ->(user) { where(user_id: user.id) } +end diff --git a/db/migrate/20130617095603_create_users_groups.rb b/db/migrate/20130617095603_create_users_groups.rb new file mode 100644 index 00000000000..2efc04f1151 --- /dev/null +++ b/db/migrate/20130617095603_create_users_groups.rb @@ -0,0 +1,11 @@ +class CreateUsersGroups < ActiveRecord::Migration + def change + create_table :users_groups do |t| + t.integer :group_access, null: false + t.integer :group_id, null: false + t.integer :user_id, null: false + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index c3c751e3a19..2e3312cf640 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -53,8 +53,8 @@ ActiveRecord::Schema.define(:version => 20130614132337) do t.integer "assignee_id" t.integer "author_id" t.integer "project_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.integer "position", :default => 0 t.string "branch_name" t.text "description" @@ -71,8 +71,8 @@ ActiveRecord::Schema.define(:version => 20130614132337) do create_table "keys", :force => true do |t| t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.text "key" t.string "title" t.string "identifier" @@ -89,8 +89,8 @@ ActiveRecord::Schema.define(:version => 20130614132337) do t.integer "author_id" t.integer "assignee_id" t.string "title" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.text "st_commits", :limit => 2147483647 t.text "st_diffs", :limit => 2147483647 t.integer "milestone_id" @@ -139,8 +139,8 @@ ActiveRecord::Schema.define(:version => 20130614132337) do t.text "note" t.string "noteable_type" t.integer "author_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.integer "project_id" t.string "attachment" t.string "line_code" @@ -158,8 +158,8 @@ ActiveRecord::Schema.define(:version => 20130614132337) do t.string "name" t.string "path" t.text "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.integer "creator_id" t.string "default_branch" t.boolean "issues_enabled", :default => true, :null => false @@ -206,8 +206,8 @@ ActiveRecord::Schema.define(:version => 20130614132337) do t.text "content" t.integer "author_id", :null => false t.integer "project_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.string "file_name" t.datetime "expires_at" t.boolean "private", :default => true, :null => false @@ -228,9 +228,6 @@ ActiveRecord::Schema.define(:version => 20130614132337) do t.datetime "created_at" end - add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id" - add_index "taggings", ["taggable_id", "taggable_type", "context"], :name => "index_taggings_on_taggable_id_and_taggable_type_and_context" - create_table "tags", :force => true do |t| t.string "name" end @@ -262,44 +259,43 @@ ActiveRecord::Schema.define(:version => 20130614132337) do end create_table "users", :force => true do |t| - t.string "email", :default => "", :null => false - t.string "encrypted_password", :default => "", :null => false + t.string "email", :default => "", :null => false + t.string "encrypted_password", :limit => 128, :default => "", :null => false t.string "reset_password_token" t.datetime "reset_password_sent_at" t.datetime "remember_created_at" - t.integer "sign_in_count", :default => 0 + t.integer "sign_in_count", :default => 0 t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" t.string "current_sign_in_ip" t.string "last_sign_in_ip" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.string "name" - t.boolean "admin", :default => false, :null => false - t.integer "projects_limit", :default => 10 - t.string "skype", :default => "", :null => false - t.string "linkedin", :default => "", :null => false - t.string "twitter", :default => "", :null => false + t.boolean "admin", :default => false, :null => false + t.integer "projects_limit", :default => 10 + t.string "skype", :default => "", :null => false + t.string "linkedin", :default => "", :null => false + t.string "twitter", :default => "", :null => false t.string "authentication_token" - t.integer "theme_id", :default => 1, :null => false + t.integer "theme_id", :default => 1, :null => false t.string "bio" - t.integer "failed_attempts", :default => 0 + t.integer "failed_attempts", :default => 0 t.datetime "locked_at" t.string "extern_uid" t.string "provider" t.string "username" - t.boolean "can_create_group", :default => true, :null => false - t.boolean "can_create_team", :default => true, :null => false + t.boolean "can_create_group", :default => true, :null => false + t.boolean "can_create_team", :default => true, :null => false t.string "state" - t.integer "color_scheme_id", :default => 1, :null => false - t.integer "notification_level", :default => 1, :null => false + t.integer "color_scheme_id", :default => 1, :null => false + t.integer "notification_level", :default => 1, :null => false t.datetime "password_expires_at" t.integer "created_by_id" end add_index "users", ["admin"], :name => "index_users_on_admin" add_index "users", ["email"], :name => "index_users_on_email", :unique => true - add_index "users", ["extern_uid", "provider"], :name => "index_users_on_extern_uid_and_provider", :unique => true add_index "users", ["name"], :name => "index_users_on_name" add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true add_index "users", ["username"], :name => "index_users_on_username" @@ -307,8 +303,8 @@ ActiveRecord::Schema.define(:version => 20130614132337) do create_table "users_projects", :force => true do |t| t.integer "user_id", :null => false t.integer "project_id", :null => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.integer "project_access", :default => 0, :null => false t.integer "notification_level", :default => 3, :null => false end @@ -320,8 +316,8 @@ ActiveRecord::Schema.define(:version => 20130614132337) do create_table "web_hooks", :force => true do |t| t.string "url" t.integer "project_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.string "type", :default => "ProjectHook" t.integer "service_id" end diff --git a/spec/factories/users_groups.rb b/spec/factories/users_groups.rb new file mode 100644 index 00000000000..f19f5d1eb95 --- /dev/null +++ b/spec/factories/users_groups.rb @@ -0,0 +1,9 @@ +# Read about factories at https://github.com/thoughtbot/factory_girl + +FactoryGirl.define do + factory :users_group do + access_level 1 + group_id 1 + user_id 1 + end +end diff --git a/spec/models/users_group_spec.rb b/spec/models/users_group_spec.rb new file mode 100644 index 00000000000..e0c1d23711d --- /dev/null +++ b/spec/models/users_group_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe UsersGroup do + pending "add some examples to (or delete) #{__FILE__}" +end -- cgit v1.2.1 From 95965d3f5417b62ec61fcdd3d7f21fe1f6260993 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 17 Jun 2013 13:26:58 +0300 Subject: Added UsersGroup validations. Added ability to add UsersGroup to group via UI --- app/controllers/groups_controller.rb | 9 ++-- app/models/group.rb | 6 +++ app/models/users_group.rb | 18 +++++++ app/views/groups/_new_group_member.html.haml | 6 +-- app/views/groups/people.html.haml | 15 ++++-- db/schema.rb | 78 ++++++++++++++++------------ 6 files changed, 87 insertions(+), 45 deletions(-) diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index e6559b8d8fe..9cbe6ec44f2 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -63,18 +63,19 @@ class GroupsController < ApplicationController def people @project = group.projects.find(params[:project_id]) if params[:project_id] - @users = @project ? @project.users : group.users - @users.sort_by!(&:name) + + @users_groups = group.users_groups if @project @team_member = @project.users_projects.new else - @team_member = UsersProject.new + @team_member = UsersGroup.new end end def team_members - @group.add_users_to_project_teams(params[:user_ids].split(','), params[:project_access]) + @group.add_users(params[:user_ids].split(','), params[:group_access]) + redirect_to people_group_path(@group), notice: 'Users were successfully added.' end diff --git a/app/models/group.rb b/app/models/group.rb index 643308f250a..5a6e30e1c2d 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -16,6 +16,12 @@ class Group < Namespace has_many :users_groups, dependent: :destroy has_many :users, through: :users_groups + def add_users(user_ids, group_access) + user_ids.compact.each do |user_id| + self.users_groups.create(user_id: user_id, group_access: group_access) + end + end + def add_users_to_project_teams(user_ids, project_access) UsersProject.add_users_into_projects( projects.map(&:id), diff --git a/app/models/users_group.rb b/app/models/users_group.rb index b95dd2520c0..999aeb2c3e4 100644 --- a/app/models/users_group.rb +++ b/app/models/users_group.rb @@ -5,6 +5,16 @@ class UsersGroup < ActiveRecord::Base MASTER = 40 OWNER = 50 + def self.group_access_roles + { + "Guest" => GUEST, + "Reporter" => REPORTER, + "Developer" => DEVELOPER, + "Master" => MASTER, + "Owner" => OWNER + } + end + attr_accessible :group_access, :group_id, :user_id belongs_to :user @@ -18,4 +28,12 @@ class UsersGroup < ActiveRecord::Base scope :with_group, ->(group) { where(group_id: group.id) } scope :with_user, ->(user) { where(user_id: user.id) } + + validates :group_access, inclusion: { in: UsersGroup.group_access_roles.values }, presence: true + validates :user_id, presence: true + validates :group_id, presence: true + + def human_group_access + UsersGroup.group_access_roles.index(self.group_access) + end end diff --git a/app/views/groups/_new_group_member.html.haml b/app/views/groups/_new_group_member.html.haml index 78db1c23320..77dfda7e1d4 100644 --- a/app/views/groups/_new_group_member.html.haml +++ b/app/views/groups/_new_group_member.html.haml @@ -9,10 +9,10 @@ %h6 2. Set access level for them .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" + = f.label :group_access, "Group Access" + .input= select_tag :group_access, options_for_select(UsersGroup.group_access_roles, @team_member.group_access), class: "project-access-select chosen" .form-actions = hidden_field_tag :redirect_to, people_group_path(@group) - = f.submit 'Add', class: "btn btn-save" + = f.submit 'Add users into group', class: "btn btn-create" diff --git a/app/views/groups/people.html.haml b/app/views/groups/people.html.haml index 3e4eb082f56..857856df26e 100644 --- a/app/views/groups/people.html.haml +++ b/app/views/groups/people.html.haml @@ -8,13 +8,18 @@ %h5.title Team %small - (#{@users.size}) + (#{@users_groups.count}) %ul.well-list - - @users.each do |user| + - @users_groups.each do |users_group| + - user = users_group.user %li = image_tag gravatar_icon(user.email, 16), class: "avatar s16" %strong= user.name - %span.cgray= user.email - - if @group.owner == user - %span.btn.btn-small.disabled.pull-right Group Owner + %span.cgray= user.username + + %span.pull-right + - if @group.owners.include?(user) + %span.label.label-info Group Owner + - else + = users_group.human_group_access diff --git a/db/schema.rb b/db/schema.rb index 2e3312cf640..8b13b084281 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20130614132337) do +ActiveRecord::Schema.define(:version => 20130617095603) do create_table "deploy_keys_projects", :force => true do |t| t.integer "deploy_key_id", :null => false @@ -53,8 +53,8 @@ ActiveRecord::Schema.define(:version => 20130614132337) do t.integer "assignee_id" t.integer "author_id" t.integer "project_id" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.integer "position", :default => 0 t.string "branch_name" t.text "description" @@ -71,8 +71,8 @@ ActiveRecord::Schema.define(:version => 20130614132337) do create_table "keys", :force => true do |t| t.integer "user_id" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.text "key" t.string "title" t.string "identifier" @@ -89,8 +89,8 @@ ActiveRecord::Schema.define(:version => 20130614132337) do t.integer "author_id" t.integer "assignee_id" t.string "title" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.text "st_commits", :limit => 2147483647 t.text "st_diffs", :limit => 2147483647 t.integer "milestone_id" @@ -139,8 +139,8 @@ ActiveRecord::Schema.define(:version => 20130614132337) do t.text "note" t.string "noteable_type" t.integer "author_id" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.integer "project_id" t.string "attachment" t.string "line_code" @@ -158,8 +158,8 @@ ActiveRecord::Schema.define(:version => 20130614132337) do t.string "name" t.string "path" t.text "description" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.integer "creator_id" t.string "default_branch" t.boolean "issues_enabled", :default => true, :null => false @@ -206,8 +206,8 @@ ActiveRecord::Schema.define(:version => 20130614132337) do t.text "content" t.integer "author_id", :null => false t.integer "project_id" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.string "file_name" t.datetime "expires_at" t.boolean "private", :default => true, :null => false @@ -228,6 +228,9 @@ ActiveRecord::Schema.define(:version => 20130614132337) do t.datetime "created_at" end + add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id" + add_index "taggings", ["taggable_id", "taggable_type", "context"], :name => "index_taggings_on_taggable_id_and_taggable_type_and_context" + create_table "tags", :force => true do |t| t.string "name" end @@ -259,52 +262,61 @@ ActiveRecord::Schema.define(:version => 20130614132337) do end create_table "users", :force => true do |t| - t.string "email", :default => "", :null => false - t.string "encrypted_password", :limit => 128, :default => "", :null => false + t.string "email", :default => "", :null => false + t.string "encrypted_password", :default => "", :null => false t.string "reset_password_token" t.datetime "reset_password_sent_at" t.datetime "remember_created_at" - t.integer "sign_in_count", :default => 0 + t.integer "sign_in_count", :default => 0 t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" t.string "current_sign_in_ip" t.string "last_sign_in_ip" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.string "name" - t.boolean "admin", :default => false, :null => false - t.integer "projects_limit", :default => 10 - t.string "skype", :default => "", :null => false - t.string "linkedin", :default => "", :null => false - t.string "twitter", :default => "", :null => false + t.boolean "admin", :default => false, :null => false + t.integer "projects_limit", :default => 10 + t.string "skype", :default => "", :null => false + t.string "linkedin", :default => "", :null => false + t.string "twitter", :default => "", :null => false t.string "authentication_token" - t.integer "theme_id", :default => 1, :null => false + t.integer "theme_id", :default => 1, :null => false t.string "bio" - t.integer "failed_attempts", :default => 0 + t.integer "failed_attempts", :default => 0 t.datetime "locked_at" t.string "extern_uid" t.string "provider" t.string "username" - t.boolean "can_create_group", :default => true, :null => false - t.boolean "can_create_team", :default => true, :null => false + t.boolean "can_create_group", :default => true, :null => false + t.boolean "can_create_team", :default => true, :null => false t.string "state" - t.integer "color_scheme_id", :default => 1, :null => false - t.integer "notification_level", :default => 1, :null => false + t.integer "color_scheme_id", :default => 1, :null => false + t.integer "notification_level", :default => 1, :null => false t.datetime "password_expires_at" t.integer "created_by_id" end add_index "users", ["admin"], :name => "index_users_on_admin" add_index "users", ["email"], :name => "index_users_on_email", :unique => true + add_index "users", ["extern_uid", "provider"], :name => "index_users_on_extern_uid_and_provider", :unique => true add_index "users", ["name"], :name => "index_users_on_name" add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true add_index "users", ["username"], :name => "index_users_on_username" + create_table "users_groups", :force => true do |t| + t.integer "access_level", :null => false + t.integer "group_id", :null => false + t.integer "user_id", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "users_projects", :force => true do |t| t.integer "user_id", :null => false t.integer "project_id", :null => false - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.integer "project_access", :default => 0, :null => false t.integer "notification_level", :default => 3, :null => false end @@ -316,8 +328,8 @@ ActiveRecord::Schema.define(:version => 20130614132337) do create_table "web_hooks", :force => true do |t| t.string "url" t.integer "project_id" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.string "type", :default => "ProjectHook" t.integer "service_id" end -- cgit v1.2.1 From fa877b63126c84cb304228cf37b61d186d5e4477 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 17 Jun 2013 13:41:35 +0300 Subject: UsersGroup specs. Fixed db/schema --- app/models/users_group.rb | 4 ++- app/views/groups/people.html.haml | 2 +- db/schema.rb | 70 ++++++++++++++++++--------------------- spec/factories/users_groups.rb | 8 ++--- spec/models/users_group_spec.rb | 24 +++++++++++++- 5 files changed, 63 insertions(+), 45 deletions(-) diff --git a/app/models/users_group.rb b/app/models/users_group.rb index 999aeb2c3e4..146b788c004 100644 --- a/app/models/users_group.rb +++ b/app/models/users_group.rb @@ -15,7 +15,7 @@ class UsersGroup < ActiveRecord::Base } end - attr_accessible :group_access, :group_id, :user_id + attr_accessible :group_access, :user_id belongs_to :user belongs_to :project @@ -33,6 +33,8 @@ class UsersGroup < ActiveRecord::Base validates :user_id, presence: true validates :group_id, presence: true + delegate :name, :username, :email, to: :user, prefix: true + def human_group_access UsersGroup.group_access_roles.index(self.group_access) end diff --git a/app/views/groups/people.html.haml b/app/views/groups/people.html.haml index 857856df26e..965a761db1e 100644 --- a/app/views/groups/people.html.haml +++ b/app/views/groups/people.html.haml @@ -6,7 +6,7 @@ = render (@project ? "new_member" : "new_group_member") .ui-box %h5.title - Team + #{@group.name} Team %small (#{@users_groups.count}) %ul.well-list diff --git a/db/schema.rb b/db/schema.rb index 8b13b084281..415e9723456 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -53,8 +53,8 @@ ActiveRecord::Schema.define(:version => 20130617095603) do t.integer "assignee_id" t.integer "author_id" t.integer "project_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.integer "position", :default => 0 t.string "branch_name" t.text "description" @@ -71,8 +71,8 @@ ActiveRecord::Schema.define(:version => 20130617095603) do create_table "keys", :force => true do |t| t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.text "key" t.string "title" t.string "identifier" @@ -89,8 +89,8 @@ ActiveRecord::Schema.define(:version => 20130617095603) do t.integer "author_id" t.integer "assignee_id" t.string "title" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.text "st_commits", :limit => 2147483647 t.text "st_diffs", :limit => 2147483647 t.integer "milestone_id" @@ -139,8 +139,8 @@ ActiveRecord::Schema.define(:version => 20130617095603) do t.text "note" t.string "noteable_type" t.integer "author_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.integer "project_id" t.string "attachment" t.string "line_code" @@ -158,8 +158,8 @@ ActiveRecord::Schema.define(:version => 20130617095603) do t.string "name" t.string "path" t.text "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.integer "creator_id" t.string "default_branch" t.boolean "issues_enabled", :default => true, :null => false @@ -206,8 +206,8 @@ ActiveRecord::Schema.define(:version => 20130617095603) do t.text "content" t.integer "author_id", :null => false t.integer "project_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.string "file_name" t.datetime "expires_at" t.boolean "private", :default => true, :null => false @@ -228,9 +228,6 @@ ActiveRecord::Schema.define(:version => 20130617095603) do t.datetime "created_at" end - add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id" - add_index "taggings", ["taggable_id", "taggable_type", "context"], :name => "index_taggings_on_taggable_id_and_taggable_type_and_context" - create_table "tags", :force => true do |t| t.string "name" end @@ -262,50 +259,49 @@ ActiveRecord::Schema.define(:version => 20130617095603) do end create_table "users", :force => true do |t| - t.string "email", :default => "", :null => false - t.string "encrypted_password", :default => "", :null => false + t.string "email", :default => "", :null => false + t.string "encrypted_password", :limit => 128, :default => "", :null => false t.string "reset_password_token" t.datetime "reset_password_sent_at" t.datetime "remember_created_at" - t.integer "sign_in_count", :default => 0 + t.integer "sign_in_count", :default => 0 t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" t.string "current_sign_in_ip" t.string "last_sign_in_ip" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.string "name" - t.boolean "admin", :default => false, :null => false - t.integer "projects_limit", :default => 10 - t.string "skype", :default => "", :null => false - t.string "linkedin", :default => "", :null => false - t.string "twitter", :default => "", :null => false + t.boolean "admin", :default => false, :null => false + t.integer "projects_limit", :default => 10 + t.string "skype", :default => "", :null => false + t.string "linkedin", :default => "", :null => false + t.string "twitter", :default => "", :null => false t.string "authentication_token" - t.integer "theme_id", :default => 1, :null => false + t.integer "theme_id", :default => 1, :null => false t.string "bio" - t.integer "failed_attempts", :default => 0 + t.integer "failed_attempts", :default => 0 t.datetime "locked_at" t.string "extern_uid" t.string "provider" t.string "username" - t.boolean "can_create_group", :default => true, :null => false - t.boolean "can_create_team", :default => true, :null => false + t.boolean "can_create_group", :default => true, :null => false + t.boolean "can_create_team", :default => true, :null => false t.string "state" - t.integer "color_scheme_id", :default => 1, :null => false - t.integer "notification_level", :default => 1, :null => false + t.integer "color_scheme_id", :default => 1, :null => false + t.integer "notification_level", :default => 1, :null => false t.datetime "password_expires_at" t.integer "created_by_id" end add_index "users", ["admin"], :name => "index_users_on_admin" add_index "users", ["email"], :name => "index_users_on_email", :unique => true - add_index "users", ["extern_uid", "provider"], :name => "index_users_on_extern_uid_and_provider", :unique => true add_index "users", ["name"], :name => "index_users_on_name" add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true add_index "users", ["username"], :name => "index_users_on_username" create_table "users_groups", :force => true do |t| - t.integer "access_level", :null => false + t.integer "group_access", :null => false t.integer "group_id", :null => false t.integer "user_id", :null => false t.datetime "created_at", :null => false @@ -315,8 +311,8 @@ ActiveRecord::Schema.define(:version => 20130617095603) do create_table "users_projects", :force => true do |t| t.integer "user_id", :null => false t.integer "project_id", :null => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.integer "project_access", :default => 0, :null => false t.integer "notification_level", :default => 3, :null => false end @@ -328,8 +324,8 @@ ActiveRecord::Schema.define(:version => 20130617095603) do create_table "web_hooks", :force => true do |t| t.string "url" t.integer "project_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.string "type", :default => "ProjectHook" t.integer "service_id" end diff --git a/spec/factories/users_groups.rb b/spec/factories/users_groups.rb index f19f5d1eb95..cb272e35c92 100644 --- a/spec/factories/users_groups.rb +++ b/spec/factories/users_groups.rb @@ -1,9 +1,7 @@ -# Read about factories at https://github.com/thoughtbot/factory_girl - FactoryGirl.define do factory :users_group do - access_level 1 - group_id 1 - user_id 1 + group_access { UsersGroup::OWNER } + group + user end end diff --git a/spec/models/users_group_spec.rb b/spec/models/users_group_spec.rb index e0c1d23711d..fd847dad48c 100644 --- a/spec/models/users_group_spec.rb +++ b/spec/models/users_group_spec.rb @@ -1,5 +1,27 @@ require 'spec_helper' describe UsersGroup do - pending "add some examples to (or delete) #{__FILE__}" + describe "Associations" do + it { should belong_to(:group) } + it { should belong_to(:user) } + end + + describe "Mass assignment" do + it { should_not allow_mass_assignment_of(:group_id) } + end + + describe "Validation" do + let!(:users_group) { create(:users_group) } + + it { should validate_presence_of(:user) } + it { should validate_uniqueness_of(:user_id).scoped_to(:group_id).with_message(/already exists/) } + + it { should validate_presence_of(:group) } + it { should ensure_inclusion_of(:group_access).in_array(UsersGroup.group_access_roles.values) } + end + + describe "Delegate methods" do + it { should respond_to(:user_name) } + it { should respond_to(:user_email) } + end end -- cgit v1.2.1 From e940fbc7c1b322c15f5d5ae878fbd3117e9b98f9 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 17 Jun 2013 14:17:32 +0300 Subject: Add UsersGroup relation to be respected by abilities and Project#team --- app/controllers/groups_controller.rb | 4 ++-- app/models/ability.rb | 4 ++++ app/models/project_team.rb | 24 +++++++++++++++++++----- app/models/users_group.rb | 2 +- app/models/users_project.rb | 4 +--- app/services/system_hooks_service.rb | 2 +- app/views/groups/_new_group_member.html.haml | 4 ++-- app/views/groups/_new_member.html.haml | 6 +++--- app/views/groups/_people_filter.html.haml | 14 ++++++++++---- app/views/groups/people.html.haml | 18 ++++++++++++------ 10 files changed, 55 insertions(+), 27 deletions(-) diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index 9cbe6ec44f2..a191aff2b6b 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -64,11 +64,11 @@ class GroupsController < ApplicationController def people @project = group.projects.find(params[:project_id]) if params[:project_id] - @users_groups = group.users_groups - if @project + @members = @project.users_projects @team_member = @project.users_projects.new else + @members = group.users_groups @team_member = UsersGroup.new end end diff --git a/app/models/ability.rb b/app/models/ability.rb index 0199012d6fc..70a4435e699 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -50,6 +50,10 @@ class Ability rules << project_admin_rules end + if project.group && project.group.owners.include?(user) + rules << project_admin_rules + end + rules.flatten end diff --git a/app/models/project_team.rb b/app/models/project_team.rb index f3e5c0e5354..d84d46431f5 100644 --- a/app/models/project_team.rb +++ b/app/models/project_team.rb @@ -47,23 +47,23 @@ class ProjectTeam end def members - project.users_projects + fetch_members end def guests - members.guests.map(&:user) + @guests ||= fetch_members(:guests) end def reporters - members.reporters.map(&:user) + @reporters ||= fetch_members(:reporters) end def developers - members.developers.map(&:user) + @developers ||= fetch_members(:developers) end def masters - members.masters.map(&:user) + @masters ||= fetch_members(:masters) end def import(source_project) @@ -96,4 +96,18 @@ class ProjectTeam rescue false end + + private + + def fetch_members(level = nil) + project_members = project.users_projects + group_members = project.group.users_groups + + if level + project_members = project_members.send(level) + group_members = group_members.send(level) + end + + (project_members + group_members).map(&:user).uniq + end end diff --git a/app/models/users_group.rb b/app/models/users_group.rb index 146b788c004..e9caa3fe705 100644 --- a/app/models/users_group.rb +++ b/app/models/users_group.rb @@ -35,7 +35,7 @@ class UsersGroup < ActiveRecord::Base delegate :name, :username, :email, to: :user, prefix: true - def human_group_access + def human_access UsersGroup.group_access_roles.index(self.group_access) end end diff --git a/app/models/users_project.rb b/app/models/users_project.rb index 935ecede42c..4c58b009380 100644 --- a/app/models/users_project.rb +++ b/app/models/users_project.rb @@ -129,9 +129,7 @@ class UsersProject < ActiveRecord::Base Project.access_options.key(self.project_access) end - def repo_access_human - self.class.access_roles.invert[self.project_access] - end + alias_method :human_access, :project_access_human def skip_git? !!@skip_git diff --git a/app/services/system_hooks_service.rb b/app/services/system_hooks_service.rb index a52d13d5237..01ddf99e97b 100644 --- a/app/services/system_hooks_service.rb +++ b/app/services/system_hooks_service.rb @@ -43,7 +43,7 @@ class SystemHooksService project_id: model.project_id, user_name: model.user.name, user_email: model.user.email, - project_access: model.repo_access_human + project_access: model.project_access_human }) end end diff --git a/app/views/groups/_new_group_member.html.haml b/app/views/groups/_new_group_member.html.haml index 77dfda7e1d4..bc1b12f257d 100644 --- a/app/views/groups/_new_group_member.html.haml +++ b/app/views/groups/_new_group_member.html.haml @@ -1,8 +1,8 @@ = form_for @team_member, as: :team_member, url: team_members_group_path(@group) do |f| %fieldset - %legend= "New Team member(s) for projects in #{@group.name}" + %legend= "New Group member(s) for #{@group.name}" - %h6 1. Choose people you want in the team + %h6 1. Choose people you want in the group .clearfix = f.label :user_ids, "People" .input= users_select_tag(:user_ids, multiple: true) diff --git a/app/views/groups/_new_member.html.haml b/app/views/groups/_new_member.html.haml index 4a762ed39ed..70c3e8cd248 100644 --- a/app/views/groups/_new_member.html.haml +++ b/app/views/groups/_new_member.html.haml @@ -1,8 +1,8 @@ = form_for @team_member, as: :team_member, url: project_team_members_path(@project, @team_member) do |f| %fieldset - %legend= "New Team member(s) for #{@project.name}" + %legend= "New Project member(s) for #{@project.name}" - %h6 1. Choose people you want in the team + %h6 1. Choose people you want in the project .clearfix = f.label :user_ids, "People" .input= users_select_tag(:user_ids, multiple: true) @@ -14,5 +14,5 @@ .form-actions = hidden_field_tag :redirect_to, people_group_path(@group, project_id: @project.id) - = f.submit 'Add', class: "btn btn-save" + = f.submit 'Add users into project', class: "btn btn-create" diff --git a/app/views/groups/_people_filter.html.haml b/app/views/groups/_people_filter.html.haml index ee63743eb4f..598b1e7b979 100644 --- a/app/views/groups/_people_filter.html.haml +++ b/app/views/groups/_people_filter.html.haml @@ -1,6 +1,15 @@ +%fieldset + %legend Group members: + %ul.nav.nav-pills.nav-stacked + %li{class: ("active" if params[:project_id].blank?)} + = link_to people_group_path(@group) do + #{@group.name} Group + %small.pull-right= @group.users.count + + = form_tag people_group_path(@group), method: 'get' do %fieldset - %legend Projects: + %legend Project members: %ul.nav.nav-pills.nav-stacked - @projects.each do |project| %li{class: ("active" if params[:project_id] == project.id.to_s)} @@ -10,7 +19,4 @@ - if @projects.blank? %p.nothing_here_message This group has no projects yet - %fieldset - %hr - = link_to "Reset", people_group_path(@group), class: 'btn pull-right' diff --git a/app/views/groups/people.html.haml b/app/views/groups/people.html.haml index 965a761db1e..b55e1b1379e 100644 --- a/app/views/groups/people.html.haml +++ b/app/views/groups/people.html.haml @@ -6,12 +6,18 @@ = render (@project ? "new_member" : "new_group_member") .ui-box %h5.title - #{@group.name} Team - %small - (#{@users_groups.count}) + - if @project + #{@project.name} Project Members + %small + (#{@members.count}) + - else + #{@group.name} Group Members + %small + (#{@members.count}) %ul.well-list - - @users_groups.each do |users_group| - - user = users_group.user + - @members.each do |member| + - user = member.user + - next unless user %li = image_tag gravatar_icon(user.email, 16), class: "avatar s16" %strong= user.name @@ -21,5 +27,5 @@ - if @group.owners.include?(user) %span.label.label-info Group Owner - else - = users_group.human_group_access + = member.human_access -- cgit v1.2.1 From 209f96bebeaf012ba941f2f8b1e659dd2334b5a1 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 17 Jun 2013 14:55:41 +0300 Subject: Use project.team over project.users --- app/controllers/issues_controller.rb | 2 +- app/models/group.rb | 6 ------ app/models/project_team.rb | 5 +++++ app/views/groups/people.html.haml | 14 +------------- app/views/issues/_form.html.haml | 2 +- app/views/issues/_issues.html.haml | 4 ++-- app/views/users_groups/_users_group.html.haml | 12 ++++++++++++ 7 files changed, 22 insertions(+), 23 deletions(-) create mode 100644 app/views/users_groups/_users_group.html.haml diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index ba92ba2bdae..65e72792924 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -23,7 +23,7 @@ class IssuesController < ProjectResourceController assignee_id, milestone_id = params[:assignee_id], params[:milestone_id] - @assignee = @project.users.find(assignee_id) if assignee_id.present? && !assignee_id.to_i.zero? + @assignee = @project.team.find(assignee_id) if assignee_id.present? && !assignee_id.to_i.zero? @milestone = @project.milestones.find(milestone_id) if milestone_id.present? && !milestone_id.to_i.zero? respond_to do |format| diff --git a/app/models/group.rb b/app/models/group.rb index 5a6e30e1c2d..72baa78910d 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -30,12 +30,6 @@ class Group < Namespace ) end - def users - users = User.joins(:users_projects).where(users_projects: {project_id: project_ids}) - users = users << owner - users.uniq - end - def human_name name end diff --git a/app/models/project_team.rb b/app/models/project_team.rb index d84d46431f5..7f8a00d077c 100644 --- a/app/models/project_team.rb +++ b/app/models/project_team.rb @@ -21,6 +21,11 @@ class ProjectTeam end end + def find user_id + user = project.users.find_by_id(user_id) + user ||= project.group.users.find_by_id(user_id) + end + def get_tm user_id project.users_projects.find_by_user_id(user_id) end diff --git a/app/views/groups/people.html.haml b/app/views/groups/people.html.haml index b55e1b1379e..39657a084ca 100644 --- a/app/views/groups/people.html.haml +++ b/app/views/groups/people.html.haml @@ -16,16 +16,4 @@ (#{@members.count}) %ul.well-list - @members.each do |member| - - user = member.user - - next unless user - %li - = image_tag gravatar_icon(user.email, 16), class: "avatar s16" - %strong= user.name - %span.cgray= user.username - - %span.pull-right - - if @group.owners.include?(user) - %span.label.label-info Group Owner - - else - = member.human_access - + = render 'users_groups/users_group', member: member diff --git a/app/views/issues/_form.html.haml b/app/views/issues/_form.html.haml index 57460e623ab..38aea6f06dc 100644 --- a/app/views/issues/_form.html.haml +++ b/app/views/issues/_form.html.haml @@ -21,7 +21,7 @@ Assign to .input .pull-left - = f.select(:assignee_id, @project.users.alphabetically.collect {|p| [ p.name, p.id ] }, { include_blank: "Select a user" }, {class: 'chosen'}) + = f.select(:assignee_id, @project.team.members.sort_by(&:name).map {|p| [ p.name, p.id ] }, { include_blank: "Select a user" }, {class: 'chosen'}) .pull-right   = link_to 'Assign to me', '#', class: 'btn btn-small assign-to-me-link' diff --git a/app/views/issues/_issues.html.haml b/app/views/issues/_issues.html.haml index cc8d8d9cae2..68598684f90 100644 --- a/app/views/issues/_issues.html.haml +++ b/app/views/issues/_issues.html.haml @@ -7,7 +7,7 @@ %span.update_issues_text Update selected issues with   .left = select_tag('update[status]', options_for_select(['open', 'closed']), prompt: "Status") - = select_tag('update[assignee_id]', options_from_collection_for_select(@project.users.all, "id", "name", params[:assignee_id]), prompt: "Assignee") + = select_tag('update[assignee_id]', options_from_collection_for_select(@project.team.members, "id", "name", params[:assignee_id]), prompt: "Assignee") = select_tag('update[milestone_id]', options_from_collection_for_select(issues_active_milestones, "id", "title", params[:milestone_id]), prompt: "Milestone") = hidden_field_tag 'update[issues_ids]', [] = hidden_field_tag :status, params[:status] @@ -50,7 +50,7 @@ Any = link_to project_issues_with_filter_path(@project, assignee_id: 0) do Unassigned - - @project.users.sort_by(&:name).each do |user| + - @project.team.members.sort_by(&:name).each do |user| %li = link_to project_issues_with_filter_path(@project, assignee_id: user.id) do = image_tag gravatar_icon(user.email), class: "avatar s16" diff --git a/app/views/users_groups/_users_group.html.haml b/app/views/users_groups/_users_group.html.haml new file mode 100644 index 00000000000..75f6d1182db --- /dev/null +++ b/app/views/users_groups/_users_group.html.haml @@ -0,0 +1,12 @@ +- user = member.user +- return unless user +%li + = image_tag gravatar_icon(user.email, 16), class: "avatar s16" + %strong= user.name + %span.cgray= user.username + + %span.pull-right + - if @group.owners.include?(user) + %span.label.label-info Group Owner + - else + = member.human_access -- cgit v1.2.1 From c9fb7e39eb601d1b959ea89363bb877f7679b2bc Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 17 Jun 2013 15:38:19 +0300 Subject: Project Team now supports a non-group projects --- app/models/project_team.rb | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/models/project_team.rb b/app/models/project_team.rb index 7f8a00d077c..20c6690e80b 100644 --- a/app/models/project_team.rb +++ b/app/models/project_team.rb @@ -23,7 +23,12 @@ class ProjectTeam def find user_id user = project.users.find_by_id(user_id) - user ||= project.group.users.find_by_id(user_id) + + if group + user ||= group.users.find_by_id(user_id) + end + + user end def get_tm user_id @@ -106,13 +111,17 @@ class ProjectTeam def fetch_members(level = nil) project_members = project.users_projects - group_members = project.group.users_groups + group_members = group ? group.users_groups : [] if level project_members = project_members.send(level) - group_members = group_members.send(level) + group_members = group_members.send(level) if group end (project_members + group_members).map(&:user).uniq end + + def group + project.group + end end -- cgit v1.2.1 From e12c9ee2bc76026b146ea1b29fd0acc5ac696d34 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 17 Jun 2013 16:51:43 +0300 Subject: Added UsersGroup scaffold. Simplify adding people to group --- app/assets/javascripts/dispatcher.js.coffee | 2 ++ app/assets/javascripts/groups.js.coffee | 6 ++++ app/controllers/groups_controller.rb | 18 ++---------- app/controllers/users_groups_controller.rb | 40 +++++++++++++++++++++++++++ app/helpers/groups_helper.rb | 4 +++ app/models/users_group.rb | 1 + app/views/groups/_new_group_member.html.haml | 6 ++-- app/views/groups/_new_member.html.haml | 18 ------------ app/views/groups/_people_filter.html.haml | 22 --------------- app/views/groups/people.html.haml | 24 +++++++--------- app/views/users_groups/_users_group.html.haml | 6 +++- config/routes.rb | 4 +-- 12 files changed, 76 insertions(+), 75 deletions(-) create mode 100644 app/assets/javascripts/groups.js.coffee create mode 100644 app/controllers/users_groups_controller.rb delete mode 100644 app/views/groups/_new_member.html.haml delete mode 100644 app/views/groups/_people_filter.html.haml diff --git a/app/assets/javascripts/dispatcher.js.coffee b/app/assets/javascripts/dispatcher.js.coffee index fb149b7f677..ce53d14d671 100644 --- a/app/assets/javascripts/dispatcher.js.coffee +++ b/app/assets/javascripts/dispatcher.js.coffee @@ -32,6 +32,8 @@ class Dispatcher new Wall(project_id) when 'teams:members:index' new TeamMembers() + when 'groups:people' + new GroupMembers() switch path.first() when 'admin' then new Admin() diff --git a/app/assets/javascripts/groups.js.coffee b/app/assets/javascripts/groups.js.coffee new file mode 100644 index 00000000000..c0ffccd8f70 --- /dev/null +++ b/app/assets/javascripts/groups.js.coffee @@ -0,0 +1,6 @@ +class GroupMembers + constructor: -> + $('li.users_group').bind 'ajax:success', -> + $(this).fadeOut() + +@GroupMembers = GroupMembers diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index a191aff2b6b..617cfddd21a 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -1,6 +1,6 @@ class GroupsController < ApplicationController respond_to :html - before_filter :group, except: [:new, :create] + before_filter :group, except: [:new, :create, :people] # Authorize before_filter :authorize_read_group!, except: [:new, :create] @@ -63,20 +63,8 @@ class GroupsController < ApplicationController def people @project = group.projects.find(params[:project_id]) if params[:project_id] - - if @project - @members = @project.users_projects - @team_member = @project.users_projects.new - else - @members = group.users_groups - @team_member = UsersGroup.new - end - end - - def team_members - @group.add_users(params[:user_ids].split(','), params[:group_access]) - - redirect_to people_group_path(@group), notice: 'Users were successfully added.' + @members = group.users_groups + @users_group = UsersGroup.new end def edit diff --git a/app/controllers/users_groups_controller.rb b/app/controllers/users_groups_controller.rb new file mode 100644 index 00000000000..ebc79d621a4 --- /dev/null +++ b/app/controllers/users_groups_controller.rb @@ -0,0 +1,40 @@ +class UsersGroupsController < ApplicationController + before_filter :group + + # Authorize + before_filter :authorize_admin_group! + + layout 'group' + + def create + @group.add_users(params[:user_ids].split(','), params[:group_access]) + + redirect_to people_group_path(@group), notice: 'Users were successfully added.' + end + + def update + # TODO: implement + end + + def destroy + @users_group = @group.users_groups.find(params[:id]) + @users_group.destroy + + respond_to do |format| + format.html { redirect_to people_group_path(@group), notice: 'User was successfully removed from group.' } + format.js { render nothing: true } + end + end + + protected + + def group + @group ||= Group.find_by_path(params[:group_id]) + end + + def authorize_admin_group! + unless can?(current_user, :manage_group, group) + return render_404 + end + end +end diff --git a/app/helpers/groups_helper.rb b/app/helpers/groups_helper.rb index 283119bc24c..2ffbff7af8d 100644 --- a/app/helpers/groups_helper.rb +++ b/app/helpers/groups_helper.rb @@ -14,4 +14,8 @@ module GroupsHelper merge_requests_group_path(@group, options) end end + + def remove_user_from_group_message(group, user) + "You are going to remove #{user.name} from #{group.name} Group. Are you sure?" + end end diff --git a/app/models/users_group.rb b/app/models/users_group.rb index e9caa3fe705..de24ab39282 100644 --- a/app/models/users_group.rb +++ b/app/models/users_group.rb @@ -32,6 +32,7 @@ class UsersGroup < ActiveRecord::Base validates :group_access, inclusion: { in: UsersGroup.group_access_roles.values }, presence: true validates :user_id, presence: true validates :group_id, presence: true + validates :user_id, uniqueness: { scope: [:group_id], message: "already exists in group" } delegate :name, :username, :email, to: :user, prefix: true diff --git a/app/views/groups/_new_group_member.html.haml b/app/views/groups/_new_group_member.html.haml index bc1b12f257d..786a52a6011 100644 --- a/app/views/groups/_new_group_member.html.haml +++ b/app/views/groups/_new_group_member.html.haml @@ -1,16 +1,16 @@ -= form_for @team_member, as: :team_member, url: team_members_group_path(@group) do |f| += form_for @users_group, url: group_users_groups_path(@group) do |f| %fieldset %legend= "New Group member(s) for #{@group.name}" %h6 1. Choose people you want in the group .clearfix = f.label :user_ids, "People" - .input= users_select_tag(:user_ids, multiple: true) + .input= users_select_tag(:user_ids, multiple: true, class: 'input-large') %h6 2. Set access level for them .clearfix = f.label :group_access, "Group Access" - .input= select_tag :group_access, options_for_select(UsersGroup.group_access_roles, @team_member.group_access), class: "project-access-select chosen" + .input= select_tag :group_access, options_for_select(UsersGroup.group_access_roles, @users_group.group_access), class: "project-access-select chosen" .form-actions = hidden_field_tag :redirect_to, people_group_path(@group) diff --git a/app/views/groups/_new_member.html.haml b/app/views/groups/_new_member.html.haml deleted file mode 100644 index 70c3e8cd248..00000000000 --- a/app/views/groups/_new_member.html.haml +++ /dev/null @@ -1,18 +0,0 @@ -= form_for @team_member, as: :team_member, url: project_team_members_path(@project, @team_member) do |f| - %fieldset - %legend= "New Project member(s) for #{@project.name}" - - %h6 1. Choose people you want in the project - .clearfix - = f.label :user_ids, "People" - .input= users_select_tag(:user_ids, multiple: true) - - %h6 2. Set access level for them - .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" - - .form-actions - = hidden_field_tag :redirect_to, people_group_path(@group, project_id: @project.id) - = f.submit 'Add users into project', class: "btn btn-create" - diff --git a/app/views/groups/_people_filter.html.haml b/app/views/groups/_people_filter.html.haml deleted file mode 100644 index 598b1e7b979..00000000000 --- a/app/views/groups/_people_filter.html.haml +++ /dev/null @@ -1,22 +0,0 @@ -%fieldset - %legend Group members: - %ul.nav.nav-pills.nav-stacked - %li{class: ("active" if params[:project_id].blank?)} - = link_to people_group_path(@group) do - #{@group.name} Group - %small.pull-right= @group.users.count - - -= form_tag people_group_path(@group), method: 'get' do - %fieldset - %legend Project members: - %ul.nav.nav-pills.nav-stacked - - @projects.each do |project| - %li{class: ("active" if params[:project_id] == project.id.to_s)} - = link_to people_group_path(@group, project_id: project.id) do - = project.name_with_namespace - %small.pull-right= project.users.count - - if @projects.blank? - %p.nothing_here_message This group has no projects yet - - diff --git a/app/views/groups/people.html.haml b/app/views/groups/people.html.haml index 39657a084ca..4c082537a43 100644 --- a/app/views/groups/people.html.haml +++ b/app/views/groups/people.html.haml @@ -1,19 +1,15 @@ +- can_manage_group = current_user.can? :manage_group, @group .row - .span3 - = render 'people_filter' - .span9 - - if can?(current_user, :manage_group, @group) - = render (@project ? "new_member" : "new_group_member") + .span6 + = render "new_group_member" + .span6 .ui-box %h5.title - - if @project - #{@project.name} Project Members - %small - (#{@members.count}) - - else - #{@group.name} Group Members - %small - (#{@members.count}) + #{@group.name} Group Members + %small + (#{@members.count}) %ul.well-list - @members.each do |member| - = render 'users_groups/users_group', member: member + = render 'users_groups/users_group', member: member, show_controls: can_manage_group + %p.light + Group members get access to all projects in this group diff --git a/app/views/users_groups/_users_group.html.haml b/app/views/users_groups/_users_group.html.haml index 75f6d1182db..31a829952ac 100644 --- a/app/views/users_groups/_users_group.html.haml +++ b/app/views/users_groups/_users_group.html.haml @@ -1,6 +1,6 @@ - user = member.user - return unless user -%li +%li{class: dom_class(member)} = image_tag gravatar_icon(user.email, 16), class: "avatar s16" %strong= user.name %span.cgray= user.username @@ -10,3 +10,7 @@ %span.label.label-info Group Owner - else = member.human_access + + - if show_controls && user != current_user + = link_to group_users_group_path(@group, member), confirm: remove_user_from_group_message(@group, user), method: :delete, remote: true, class: "btn-tiny btn btn-remove", title: 'Remove user from group' do + %i.icon-minus.icon-white diff --git a/config/routes.rb b/config/routes.rb index 39c79635c40..b431cb23c83 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -149,10 +149,10 @@ Gitlab::Application.routes.draw do member do get :issues get :merge_requests - get :search get :people - post :team_members end + + resources :users_groups, only: [:create, :update, :destroy] end # -- cgit v1.2.1 From fcc1ba5bf2df46d58a4270a6b6695e0ae51b1fbc Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 17 Jun 2013 17:00:24 +0300 Subject: Fix spinach group --- app/models/users_group.rb | 2 +- features/steps/group/group.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/users_group.rb b/app/models/users_group.rb index de24ab39282..b29c6fa1119 100644 --- a/app/models/users_group.rb +++ b/app/models/users_group.rb @@ -37,6 +37,6 @@ class UsersGroup < ActiveRecord::Base delegate :name, :username, :email, to: :user, prefix: true def human_access - UsersGroup.group_access_roles.index(self.group_access) + UsersGroup.group_access_roles.key(self.group_access) end end diff --git a/features/steps/group/group.rb b/features/steps/group/group.rb index 102bc440d82..a6b9aa606c6 100644 --- a/features/steps/group/group.rb +++ b/features/steps/group/group.rb @@ -39,11 +39,11 @@ class Groups < Spinach::FeatureSteps And 'I select user "John" from list with role "Reporter"' do user = User.find_by_name("John") - within "#new_team_member" do + within ".new_users_group" do select2(user.id, from: "#user_ids", multiple: true) - select "Reporter", from: "project_access" + select "Reporter", from: "group_access" end - click_button "Add" + click_button "Add users into group" end Then 'I should see user "John" in team list' do -- cgit v1.2.1 From b4fe5a76a75577c45be70459ec8f4e7612d0139b Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 17 Jun 2013 17:03:56 +0300 Subject: Fix UsersGroup specs --- app/models/users_group.rb | 2 +- spec/models/users_group_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/users_group.rb b/app/models/users_group.rb index b29c6fa1119..0cb26854f9c 100644 --- a/app/models/users_group.rb +++ b/app/models/users_group.rb @@ -18,7 +18,7 @@ class UsersGroup < ActiveRecord::Base attr_accessible :group_access, :user_id belongs_to :user - belongs_to :project + belongs_to :group scope :guests, -> { where(group_access: GUEST) } scope :reporters, -> { where(group_access: REPORTER) } diff --git a/spec/models/users_group_spec.rb b/spec/models/users_group_spec.rb index fd847dad48c..c802b8213d5 100644 --- a/spec/models/users_group_spec.rb +++ b/spec/models/users_group_spec.rb @@ -13,10 +13,10 @@ describe UsersGroup do describe "Validation" do let!(:users_group) { create(:users_group) } - it { should validate_presence_of(:user) } + it { should validate_presence_of(:user_id) } it { should validate_uniqueness_of(:user_id).scoped_to(:group_id).with_message(/already exists/) } - it { should validate_presence_of(:group) } + it { should validate_presence_of(:group_id) } it { should ensure_inclusion_of(:group_access).in_array(UsersGroup.group_access_roles.values) } end -- cgit v1.2.1 From 5bed576ac2c6ea9aa4eac634c605473a12e96b3a Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 17 Jun 2013 17:55:43 +0300 Subject: Show group members on project team page --- app/controllers/team_members_controller.rb | 1 + app/views/team_members/_team_member.html.haml | 34 ++++++++++----------------- app/views/team_members/index.html.haml | 9 +++++++ 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/app/controllers/team_members_controller.rb b/app/controllers/team_members_controller.rb index 35aa315dac1..588c2b63cf3 100644 --- a/app/controllers/team_members_controller.rb +++ b/app/controllers/team_members_controller.rb @@ -8,6 +8,7 @@ class TeamMembersController < ProjectResourceController @team = @team.send(params[:type]) if %w(masters developers reporters guests).include?(params[:type]) @team = @team.sort_by(&:project_access).reverse.group_by(&:project_access) + @group = @project.group @assigned_teams = @project.user_team_project_relationships end diff --git a/app/views/team_members/_team_member.html.haml b/app/views/team_members/_team_member.html.haml index d829a79213c..4bd4fca6718 100644 --- a/app/views/team_members/_team_member.html.haml +++ b/app/views/team_members/_team_member.html.haml @@ -1,27 +1,17 @@ - user = member.user - allow_admin = current_user_can_admin_project %li{id: dom_id(user), class: "team_member_row user_#{user.id}"} - .row - .span4 - = link_to user, title: user.name, class: "dark" do - = image_tag gravatar_icon(user.email, 32), class: "avatar s32" - %strong= truncate(user.name, lenght: 40) - %br - %small.cgray= user.username + .pull-right + - if allow_admin + .pull-left + = form_for(member, as: :team_member, url: project_team_member_path(@project, member.user)) do |f| + = f.select :project_access, options_for_select(UsersProject.access_roles, member.project_access), {}, class: "medium project-access-select span2 trigger-submit" +   + = link_to project_team_member_path(@project, user), confirm: remove_from_project_team_message(@project, user), method: :delete, class: "btn-tiny btn btn-remove", title: 'Remove user from team' do + %i.icon-minus.icon-white + = image_tag gravatar_icon(user.email, 32), class: "avatar s32" + %p + %strong= user.name + %span.cgray= user.username - .span4.pull-right - - if allow_admin - .left - = form_for(member, as: :team_member, url: project_team_member_path(@project, member.user)) do |f| - = f.select :project_access, options_for_select(UsersProject.access_roles, member.project_access), {}, class: "medium project-access-select span2 trigger-submit" - .pull-right - - if current_user == user - %span.label.label-success This is you! - - if @project.namespace_owner == user - %span.label.label-info Owner - - elsif user.blocked? - %span.label.label-error Blocked - - elsif allow_admin - = link_to project_team_member_path(@project, user), confirm: remove_from_project_team_message(@project, user), method: :delete, class: "btn-tiny btn btn-remove", title: 'Remove user from team' do - %i.icon-minus.icon-white diff --git a/app/views/team_members/index.html.haml b/app/views/team_members/index.html.haml index c0f7ee4330d..ec47c28bddf 100644 --- a/app/views/team_members/index.html.haml +++ b/app/views/team_members/index.html.haml @@ -17,6 +17,7 @@ %hr + .clearfix .row .span3 @@ -49,6 +50,14 @@ = render "team_members/assigned_teams", assigned_teams: @assigned_teams .span9 + - if @group + .ui-box + %h5.title + = link_to people_group_path(@group) do + Members of #{@group.name} group + %ul.well-list + - @group.users_groups.each do |member| + = render 'users_groups/users_group', member: member, show_controls: false %div.team-table = render "team_members/team", team: @team -- cgit v1.2.1 From 7d57b96ee0f668acf10067b06a614b3052e27f89 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 17 Jun 2013 19:59:41 +0300 Subject: Update authorized/owned resources with new group permissions --- app/models/user.rb | 10 ++++++---- app/views/groups/people.html.haml | 7 ++++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 6de8d2d4c39..904d2919429 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -71,7 +71,9 @@ class User < ActiveRecord::Base has_many :keys, dependent: :destroy # Groups - has_many :groups, class_name: "Group", foreign_key: :owner_id + has_many :own_groups, class_name: "Group", foreign_key: :owner_id + has_many :users_groups, dependent: :destroy + has_many :groups, through: :users_groups # Teams has_many :own_teams, dependent: :destroy, class_name: "UserTeam", foreign_key: :owner_id @@ -230,7 +232,7 @@ class User < ActiveRecord::Base # Groups where user is an owner def owned_groups - groups + own_groups end def owned_teams @@ -239,14 +241,14 @@ class User < ActiveRecord::Base # Groups user has access to def authorized_groups - @group_ids ||= (groups.pluck(:id) + authorized_projects.pluck(:namespace_id)) + @group_ids ||= (groups.pluck(:id) + own_groups.pluck(:id) + authorized_projects.pluck(:namespace_id)) Group.where(id: @group_ids) end # Projects user has access to def authorized_projects - @project_ids ||= (owned_projects.pluck(:id) + projects.pluck(:id)).uniq + @project_ids ||= (owned_projects.pluck(:id) + groups.map(&:projects).flatten.map(&:id) + projects.pluck(:id)).uniq Project.where(id: @project_ids) end diff --git a/app/views/groups/people.html.haml b/app/views/groups/people.html.haml index 4c082537a43..5b595ad3584 100644 --- a/app/views/groups/people.html.haml +++ b/app/views/groups/people.html.haml @@ -1,7 +1,12 @@ - can_manage_group = current_user.can? :manage_group, @group .row .span6 - = render "new_group_member" + - if can_manage_group + = render "new_group_member" + - else + .light-well + %h4.nothing_here_message + Only group owners can manage group members .span6 .ui-box %h5.title -- cgit v1.2.1 From ed9cff9a3c0a230f5497e85e8e178699ed02683e Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 17 Jun 2013 21:00:59 +0300 Subject: Restyle project members page to fit both group and personal projects --- app/assets/stylesheets/gitlab_bootstrap/lists.scss | 6 ++ app/controllers/dashboard_controller.rb | 5 +- app/controllers/groups_controller.rb | 2 +- app/controllers/team_members_controller.rb | 5 +- app/views/team_members/_group_members.html.haml | 7 +++ app/views/team_members/_team.html.haml | 12 ++-- app/views/team_members/index.html.haml | 70 +++++++--------------- 7 files changed, 44 insertions(+), 63 deletions(-) create mode 100644 app/views/team_members/_group_members.html.haml diff --git a/app/assets/stylesheets/gitlab_bootstrap/lists.scss b/app/assets/stylesheets/gitlab_bootstrap/lists.scss index e661e02623e..0fa4da44de5 100644 --- a/app/assets/stylesheets/gitlab_bootstrap/lists.scss +++ b/app/assets/stylesheets/gitlab_bootstrap/lists.scss @@ -16,6 +16,12 @@ color: #888; } + &.unstyled { + &:hover { + background: none; + } + } + &.smoke { background-color: #f5f5f5; } &:hover { diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index b74c22b1547..9b3f59600c6 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -34,11 +34,12 @@ class DashboardController < ApplicationController @projects end - @projects = @projects.tagged_with(params[:label]) if params[:label].present? @projects = @projects.search(params[:search]) if params[:search].present? - @projects = @projects.page(params[:page]).per(30) @labels = Project.where(id: @projects.map(&:id)).tags_on(:labels) + + @projects = @projects.tagged_with(params[:label]) if params[:label].present? + @projects = @projects.page(params[:page]).per(30) end # Get authored or assigned open merge requests diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index 617cfddd21a..870a00d4ece 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -63,7 +63,7 @@ class GroupsController < ApplicationController def people @project = group.projects.find(params[:project_id]) if params[:project_id] - @members = group.users_groups + @members = group.users_groups.order('group_access DESC') @users_group = UsersGroup.new end diff --git a/app/controllers/team_members_controller.rb b/app/controllers/team_members_controller.rb index 588c2b63cf3..095d7a3af55 100644 --- a/app/controllers/team_members_controller.rb +++ b/app/controllers/team_members_controller.rb @@ -4,11 +4,8 @@ class TeamMembersController < ProjectResourceController before_filter :authorize_admin_project!, except: [:index, :show] def index - @team = @project.users_projects.scoped - @team = @team.send(params[:type]) if %w(masters developers reporters guests).include?(params[:type]) - @team = @team.sort_by(&:project_access).reverse.group_by(&:project_access) - @group = @project.group + @users_projects = @project.users_projects.order('project_access DESC') @assigned_teams = @project.user_team_project_relationships end diff --git a/app/views/team_members/_group_members.html.haml b/app/views/team_members/_group_members.html.haml new file mode 100644 index 00000000000..256e6ce7744 --- /dev/null +++ b/app/views/team_members/_group_members.html.haml @@ -0,0 +1,7 @@ +.ui-box + %h5.title + = link_to people_group_path(@group) do + Members of #{@group.name} group + %ul.well-list + - @group.users_groups.order('group_access DESC').each do |member| + = render 'users_groups/users_group', member: member, show_controls: false diff --git a/app/views/team_members/_team.html.haml b/app/views/team_members/_team.html.haml index 4ff170ac86e..3c7686c7b76 100644 --- a/app/views/team_members/_team.html.haml +++ b/app/views/team_members/_team.html.haml @@ -1,10 +1,8 @@ -- can_admin_project = (can? current_user, :admin_project, @project) -- team.each do |access, members| - - role = Project.access_options.key(access).pluralize - .ui-box{class: role.downcase} +.team-table + - can_admin_project = (can? current_user, :admin_project, @project) + .ui-box %h5.title - = role - %span.light (#{members.size}) + Project members (#{members.count}) %ul.well-list - - members.sort_by(&:user_name).each do |team_member| + - members.each do |team_member| = render 'team_members/team_member', member: team_member, current_user_can_admin_project: can_admin_project diff --git a/app/views/team_members/index.html.haml b/app/views/team_members/index.html.haml index ec47c28bddf..5df22813f19 100644 --- a/app/views/team_members/index.html.haml +++ b/app/views/team_members/index.html.haml @@ -1,10 +1,6 @@ = render "projects/settings_nav" %h3.page_title - Project Members - (#{@project.users.count}) - %small - Read more about project permissions - %strong= link_to "here", help_permissions_path, class: "vlink" + Users with access to this project - if can? current_user, :admin_team_member, @project %span.pull-right @@ -15,51 +11,27 @@ = link_to new_project_team_member_path(@project), class: "btn btn-primary small grouped", title: "New Team Member" do New Team Member -%hr +%p.light + Read more about project permissions + %strong= link_to "here", help_permissions_path, class: "vlink" -.clearfix -.row - .span3 - %ul.nav.nav-pills.nav-stacked - %li{class: ("active" if !params[:type])} - = link_to project_team_index_path(type: nil) do - All - %li{class: ("active" if params[:type] == 'masters')} - = link_to project_team_index_path(type: 'masters') do - Masters - %span.pull-right= @project.users_projects.masters.count - %li{class: ("active" if params[:type] == 'developers')} - = link_to project_team_index_path(type: 'developers') do - Developers - %span.pull-right= @project.users_projects.developers.count - %li{class: ("active" if params[:type] == 'reporters')} - = link_to project_team_index_path(type: 'reporters') do - Reporters - %span.pull-right= @project.users_projects.reporters.count - %li{class: ("active" if params[:type] == 'guests')} - = link_to project_team_index_path(type: 'guests') do - Guests - %span.pull-right= @project.users_projects.guests.count - - - if @assigned_teams.present? - %h5 - Assigned teams - (#{@project.user_teams.count}) - %div - = render "team_members/assigned_teams", assigned_teams: @assigned_teams - - .span9 - - if @group - .ui-box - %h5.title - = link_to people_group_path(@group) do - Members of #{@group.name} group - %ul.well-list - - @group.users_groups.each do |member| - = render 'users_groups/users_group', member: member, show_controls: false - %div.team-table - = render "team_members/team", team: @team - +.clearfix +- if @group + .row + .span6 + = render "team_members/group_members" + .span6 + = render "team_members/team", members: @users_projects + +- else + = render "team_members/team", members: @users_projects + +- if @assigned_teams.present? + %h5 + Assigned teams + (#{@project.user_teams.count}) + %div + = render "team_members/assigned_teams", assigned_teams: @assigned_teams -- cgit v1.2.1 From 32ef2f37f6a3eee713638bdf4da8c5ee2c570169 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 18 Jun 2013 16:56:31 +0300 Subject: Add owner to group members after group create --- app/controllers/groups_controller.rb | 2 +- app/models/group.rb | 30 +++++++++++++----------------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index 870a00d4ece..f44bc10cf39 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -72,7 +72,7 @@ class GroupsController < ApplicationController def update group_params = params[:group].dup - owner_id =group_params.delete(:owner_id) + owner_id = group_params.delete(:owner_id) if owner_id @group.owner = User.find(owner_id) diff --git a/app/models/group.rb b/app/models/group.rb index 72baa78910d..0593d9cd4bb 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -16,29 +16,25 @@ class Group < Namespace has_many :users_groups, dependent: :destroy has_many :users, through: :users_groups - def add_users(user_ids, group_access) - user_ids.compact.each do |user_id| - self.users_groups.create(user_id: user_id, group_access: group_access) - end - end - - def add_users_to_project_teams(user_ids, project_access) - UsersProject.add_users_into_projects( - projects.map(&:id), - user_ids, - project_access - ) - end + after_create :add_owner def human_name name end - def truncate_teams - UsersProject.truncate_teams(project_ids) - end - def owners @owners ||= (users_groups.owners.map(&:user) << owner) end + + def add_users(user_ids, group_access) + user_ids.compact.each do |user_id| + self.users_groups.create(user_id: user_id, group_access: group_access) + end + end + + private + + def add_owner + self.add_users([owner.id], UsersGroup::OWNER) + end end -- cgit v1.2.1 From a0b6c964c5f3b69aa98411a2fc7815f6c3a37854 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 18 Jun 2013 17:09:04 +0300 Subject: Proper naming for project members page --- app/views/projects/_settings_nav.html.haml | 2 +- app/views/team_members/_group_members.html.haml | 7 +++++-- app/views/team_members/_team.html.haml | 3 ++- app/views/team_members/index.html.haml | 2 -- features/steps/project/project_active_tab.rb | 4 ++-- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/views/projects/_settings_nav.html.haml b/app/views/projects/_settings_nav.html.haml index 346bbd2daf3..272c5e4402f 100644 --- a/app/views/projects/_settings_nav.html.haml +++ b/app/views/projects/_settings_nav.html.haml @@ -6,7 +6,7 @@ = nav_link(controller: [:team_members, :teams]) do = link_to project_team_index_path(@project), class: "team-tab tab" do %i.icon-group - Project Members + Members = nav_link(controller: :deploy_keys) do = link_to project_deploy_keys_path(@project) do %span diff --git a/app/views/team_members/_group_members.html.haml b/app/views/team_members/_group_members.html.haml index 256e6ce7744..7d9333d38e6 100644 --- a/app/views/team_members/_group_members.html.haml +++ b/app/views/team_members/_group_members.html.haml @@ -1,7 +1,10 @@ .ui-box %h5.title - = link_to people_group_path(@group) do - Members of #{@group.name} group + %strong #{@group.name} Group + members (#{@group.users_groups.count}) + .pull-right + = link_to people_group_path(@group), class: 'btn btn-small' do + %i.icon-edit %ul.well-list - @group.users_groups.order('group_access DESC').each do |member| = render 'users_groups/users_group', member: member, show_controls: false diff --git a/app/views/team_members/_team.html.haml b/app/views/team_members/_team.html.haml index 3c7686c7b76..2a663bd9941 100644 --- a/app/views/team_members/_team.html.haml +++ b/app/views/team_members/_team.html.haml @@ -2,7 +2,8 @@ - can_admin_project = (can? current_user, :admin_project, @project) .ui-box %h5.title - Project members (#{members.count}) + %strong #{@project.name} Project + members (#{members.count}) %ul.well-list - members.each do |team_member| = render 'team_members/team_member', member: team_member, current_user_can_admin_project: can_admin_project diff --git a/app/views/team_members/index.html.haml b/app/views/team_members/index.html.haml index 5df22813f19..bae7215323c 100644 --- a/app/views/team_members/index.html.haml +++ b/app/views/team_members/index.html.haml @@ -15,8 +15,6 @@ Read more about project permissions %strong= link_to "here", help_permissions_path, class: "vlink" - - .clearfix - if @group diff --git a/features/steps/project/project_active_tab.rb b/features/steps/project/project_active_tab.rb index 5170ab82e8a..a0ee32b9ec0 100644 --- a/features/steps/project/project_active_tab.rb +++ b/features/steps/project/project_active_tab.rb @@ -45,7 +45,7 @@ class ProjectActiveTab < Spinach::FeatureSteps # Sub Tabs: Home Given 'I click the "Team" tab' do - click_link('Project Members') + click_link('Members') end Given 'I click the "Attachments" tab' do @@ -73,7 +73,7 @@ class ProjectActiveTab < Spinach::FeatureSteps end Then 'the active sub tab should be Team' do - ensure_active_sub_tab('Project Members') + ensure_active_sub_tab('Members') end Then 'the active sub tab should be Attachments' do -- cgit v1.2.1 From 48019f1a0fa884c1a8439848fe0dd1d6bc8588cc Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 18 Jun 2013 17:32:33 +0300 Subject: Update admin area with new group memberships --- app/controllers/admin/groups_controller.rb | 4 +-- app/controllers/users_controller.rb | 2 +- app/views/admin/groups/show.html.haml | 39 +++++++++++++++--------------- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/app/controllers/admin/groups_controller.rb b/app/controllers/admin/groups_controller.rb index c38461c89db..6e6c8d54e29 100644 --- a/app/controllers/admin/groups_controller.rb +++ b/app/controllers/admin/groups_controller.rb @@ -66,14 +66,12 @@ class Admin::GroupsController < Admin::ApplicationController end def project_teams_update - @group.add_users_to_project_teams(params[:user_ids].split(','), params[:project_access]) + @group.add_users(params[:user_ids].split(','), params[:group_access]) redirect_to [:admin, @group], notice: 'Users were successfully added.' end def destroy - @group.truncate_teams - @group.destroy redirect_to admin_groups_path, notice: 'Group was successfully deleted.' diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 4947c33f959..028af8ff59f 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -3,7 +3,7 @@ class UsersController < ApplicationController def show @user = User.find_by_username!(params[:username]) - @projects = @user.authorized_projects.where('projects.id in (?)', current_user.authorized_projects.map(&:id)) + @projects = @user.authorized_projects.where('projects.id in (?)', current_user.authorized_projects.map(&:id)).order('namespace_id DESC') @events = @user.recent_events.where(project_id: @projects.map(&:id)).limit(20) @title = @user.name diff --git a/app/views/admin/groups/show.html.haml b/app/views/admin/groups/show.html.haml index 9c4b91b1bfa..88e40c3f401 100644 --- a/app/views/admin/groups/show.html.haml +++ b/app/views/admin/groups/show.html.haml @@ -49,10 +49,23 @@ %strong = @group.created_at.stamp("March 1, 1999") + .ui-box + %h5.title + Projects + %small + (#{@group.projects.count}) + %ul.well-list + - @group.projects.sort_by(&:name).each do |project| + %li + %strong + = link_to project.name_with_namespace, [:admin, project] + %span.pull-right.light + %span.monospace= project.path_with_namespace + ".git" + .span6 .ui-box %h5.title - Add user to Group projects: + Add user to the group: .ui-box-body.form-holder %p.light Read more about project permissions @@ -64,30 +77,18 @@ %div.prepend-top-10 = select_tag :project_access, options_for_select(Project.access_options), {class: "project-access-select chosen span2"} %hr - = submit_tag 'Add user to projects in group', class: "btn btn-create" + = submit_tag 'Add user to the group', class: "btn btn-create" .ui-box %h5.title - Users from Group projects + Users from #{@group.name} Group %small - (#{@group.users.count}) + (#{@group.users_groups.count}) %ul.well-list - - @group.users.sort_by(&:name).each do |user| + - @group.users_groups.order('group_access DESC').each do |member| + - user = member.user %li{class: dom_class(user)} %strong = link_to user.name, admin_user_path(user) %span.pull-right.light - = pluralize user.authorized_projects.in_namespace(@group).count, 'project' + = member.human_access - .span6 - .ui-box - %h5.title - Projects - %small - (#{@group.projects.count}) - %ul.well-list - - @group.projects.sort_by(&:name).each do |project| - %li - %strong - = link_to project.name_with_namespace, [:admin, project] - %span.pull-right.light - %span.monospace= project.path_with_namespace + ".git" -- cgit v1.2.1 From 4e5b3d9aaebd420fc95152540a664a17ec3019e7 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 18 Jun 2013 18:39:18 +0300 Subject: Fixin tests --- app/views/admin/groups/show.html.haml | 4 ++-- features/steps/admin/admin_groups.rb | 2 +- features/steps/project/project_team_management.rb | 20 +++++++++++++++++--- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/app/views/admin/groups/show.html.haml b/app/views/admin/groups/show.html.haml index 88e40c3f401..3de0091801f 100644 --- a/app/views/admin/groups/show.html.haml +++ b/app/views/admin/groups/show.html.haml @@ -65,7 +65,7 @@ .span6 .ui-box %h5.title - Add user to the group: + Add user(s): .ui-box-body.form-holder %p.light Read more about project permissions @@ -77,7 +77,7 @@ %div.prepend-top-10 = select_tag :project_access, options_for_select(Project.access_options), {class: "project-access-select chosen span2"} %hr - = submit_tag 'Add user to the group', class: "btn btn-create" + = submit_tag 'Add users into group', class: "btn btn-create" .ui-box %h5.title Users from #{@group.name} Group diff --git a/features/steps/admin/admin_groups.rb b/features/steps/admin/admin_groups.rb index d780d9c96d9..2f98b8100dc 100644 --- a/features/steps/admin/admin_groups.rb +++ b/features/steps/admin/admin_groups.rb @@ -45,7 +45,7 @@ class AdminGroups < Spinach::FeatureSteps within "#new_team_member" do select "Reporter", from: "project_access" end - click_button "Add user to projects in group" + click_button "Add users into group" end Then 'I should see "John" in team list in every project as "Reporter"' do diff --git a/features/steps/project/project_team_management.rb b/features/steps/project/project_team_management.rb index ffd2aa24676..7e9533de8f6 100644 --- a/features/steps/project/project_team_management.rb +++ b/features/steps/project/project_team_management.rb @@ -30,14 +30,20 @@ class ProjectTeamManagement < Spinach::FeatureSteps end Then 'I should see "Mike" in team list as "Reporter"' do - within '.reporters' do + user = User.find_by_name("Mike") + + within "#user_#{user.id}" do page.should have_content('Mike') + page.find('#team_member_project_access').value.should == access_value(:reporter) end end Given 'I should see "Sam" in team list as "Developer"' do - within '.developers' do + user = User.find_by_name("Sam") + + within "#user_#{user.id}" do page.should have_content('Sam') + page.find('#team_member_project_access').value.should == access_value(:developer) end end @@ -49,8 +55,10 @@ class ProjectTeamManagement < Spinach::FeatureSteps end And 'I should see "Sam" in team list as "Reporter"' do - within '.reporters' do + user = User.find_by_name("Sam") + within ".user_#{user.id}" do page.should have_content('Sam') + page.find('#team_member_project_access').value.should == access_value(:reporter) end end @@ -103,4 +111,10 @@ class ProjectTeamManagement < Spinach::FeatureSteps click_link('Remove user from team') end end + + private + + def access_value(key) + UsersProject.roles_hash[key].to_s + end end -- cgit v1.2.1 From 60bb35161741338e585feedf09538f5935bba271 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 18 Jun 2013 18:58:33 +0300 Subject: Prevent page crash if failed to parse graphs data --- app/controllers/graphs_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/graphs_controller.rb b/app/controllers/graphs_controller.rb index 5ae9c15c0f7..6c2ac5fcbf4 100644 --- a/app/controllers/graphs_controller.rb +++ b/app/controllers/graphs_controller.rb @@ -10,7 +10,7 @@ class GraphsController < ProjectResourceController format.js do @repo = @project.repository @stats = Gitlab::Git::GitStats.new(@repo.raw, @repo.root_ref) - @log = @stats.parsed_log.to_json + @log = @stats.parsed_log.to_json rescue [] end end end -- cgit v1.2.1 From 670aaaeb9db7902c8776cb7754ac8fd1e7a606a1 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 18 Jun 2013 21:05:43 +0300 Subject: Version to 6.0.0.pre --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 455f90e3b18..ce87c8b840a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5.3.0.beta1 +6.0.0.pre -- cgit v1.2.1 From 439f399bece8c2b01dc064b6c02f28fb4149595e Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 18 Jun 2013 21:22:34 +0300 Subject: Remove all team resources except models. Move models to deprecated directory --- .../admin/teams/application_controller.rb | 11 - app/controllers/admin/teams/members_controller.rb | 40 --- app/controllers/admin/teams/projects_controller.rb | 41 --- app/controllers/admin/teams_controller.rb | 59 ---- app/controllers/dashboard_controller.rb | 1 - app/controllers/projects/teams_controller.rb | 34 -- app/controllers/teams/application_controller.rb | 13 - app/controllers/teams/members_controller.rb | 53 --- app/controllers/teams/projects_controller.rb | 40 --- app/controllers/teams_controller.rb | 93 ------ app/helpers/application_helper.rb | 3 +- app/helpers/user_teams_helper.rb | 25 -- app/models/ability.rb | 17 - app/models/deprecated/user_team.rb | 116 +++++++ .../deprecated/user_team_project_relationship.rb | 44 +++ .../deprecated/user_team_user_relationship.rb | 32 ++ app/models/user.rb | 20 -- app/models/user_team.rb | 116 ------- app/models/user_team_project_relationship.rb | 44 --- app/models/user_team_user_relationship.rb | 32 -- app/views/admin/dashboard/index.html.haml | 4 - app/views/admin/teams/edit.html.haml | 28 -- app/views/admin/teams/index.html.haml | 48 --- app/views/admin/teams/members/_form.html.haml | 20 -- app/views/admin/teams/members/edit.html.haml | 16 - app/views/admin/teams/members/new.html.haml | 27 -- app/views/admin/teams/new.html.haml | 26 -- app/views/admin/teams/projects/_form.html.haml | 16 - app/views/admin/teams/projects/edit.html.haml | 16 - app/views/admin/teams/projects/new.html.haml | 18 -- app/views/admin/teams/show.html.haml | 96 ------ app/views/admin/users/show.html.haml | 7 - app/views/dashboard/_sidebar.html.haml | 4 - app/views/layouts/nav/_admin.html.haml | 2 - app/views/projects/teams/available.html.haml | 22 -- app/views/teams/_filter.html.haml | 33 -- app/views/teams/_projects.html.haml | 22 -- app/views/teams/edit.html.haml | 74 ----- app/views/teams/issues.html.haml | 23 -- app/views/teams/members/_form.html.haml | 20 -- app/views/teams/members/_member.html.haml | 31 -- app/views/teams/members/_team.html.haml | 10 - app/views/teams/members/edit.html.haml | 16 - app/views/teams/members/index.html.haml | 37 --- app/views/teams/members/new.html.haml | 25 -- app/views/teams/merge_requests.html.haml | 24 -- app/views/teams/new.html.haml | 37 --- app/views/teams/projects/_form.html.haml | 16 - app/views/teams/projects/edit.html.haml | 6 - app/views/teams/show.atom.builder | 28 -- app/views/teams/show.html.haml | 25 -- app/views/teams/show.js.haml | 2 - config/routes.rb | 26 -- features/steps/userteams/userteams.rb | 241 -------------- features/teams/team.feature | 65 ---- lib/api/api.rb | 1 - lib/api/entities.rb | 4 - lib/api/user_teams.rb | 276 ---------------- lib/gitlab/user_team_manager.rb | 146 --------- spec/models/user_team_project_relationship_spec.rb | 17 - spec/models/user_team_spec.rb | 37 --- spec/models/user_team_user_relationship_spec.rb | 18 -- spec/requests/api/user_teams_spec.rb | 360 --------------------- 63 files changed, 193 insertions(+), 2611 deletions(-) delete mode 100644 app/controllers/admin/teams/application_controller.rb delete mode 100644 app/controllers/admin/teams/members_controller.rb delete mode 100644 app/controllers/admin/teams/projects_controller.rb delete mode 100644 app/controllers/admin/teams_controller.rb delete mode 100644 app/controllers/projects/teams_controller.rb delete mode 100644 app/controllers/teams/application_controller.rb delete mode 100644 app/controllers/teams/members_controller.rb delete mode 100644 app/controllers/teams/projects_controller.rb delete mode 100644 app/controllers/teams_controller.rb delete mode 100644 app/helpers/user_teams_helper.rb create mode 100644 app/models/deprecated/user_team.rb create mode 100644 app/models/deprecated/user_team_project_relationship.rb create mode 100644 app/models/deprecated/user_team_user_relationship.rb delete mode 100644 app/models/user_team.rb delete mode 100644 app/models/user_team_project_relationship.rb delete mode 100644 app/models/user_team_user_relationship.rb delete mode 100644 app/views/admin/teams/edit.html.haml delete mode 100644 app/views/admin/teams/index.html.haml delete mode 100644 app/views/admin/teams/members/_form.html.haml delete mode 100644 app/views/admin/teams/members/edit.html.haml delete mode 100644 app/views/admin/teams/members/new.html.haml delete mode 100644 app/views/admin/teams/new.html.haml delete mode 100644 app/views/admin/teams/projects/_form.html.haml delete mode 100644 app/views/admin/teams/projects/edit.html.haml delete mode 100644 app/views/admin/teams/projects/new.html.haml delete mode 100644 app/views/admin/teams/show.html.haml delete mode 100644 app/views/projects/teams/available.html.haml delete mode 100644 app/views/teams/_filter.html.haml delete mode 100644 app/views/teams/_projects.html.haml delete mode 100644 app/views/teams/edit.html.haml delete mode 100644 app/views/teams/issues.html.haml delete mode 100644 app/views/teams/members/_form.html.haml delete mode 100644 app/views/teams/members/_member.html.haml delete mode 100644 app/views/teams/members/_team.html.haml delete mode 100644 app/views/teams/members/edit.html.haml delete mode 100644 app/views/teams/members/index.html.haml delete mode 100644 app/views/teams/members/new.html.haml delete mode 100644 app/views/teams/merge_requests.html.haml delete mode 100644 app/views/teams/new.html.haml delete mode 100644 app/views/teams/projects/_form.html.haml delete mode 100644 app/views/teams/projects/edit.html.haml delete mode 100644 app/views/teams/show.atom.builder delete mode 100644 app/views/teams/show.html.haml delete mode 100644 app/views/teams/show.js.haml delete mode 100644 features/steps/userteams/userteams.rb delete mode 100644 features/teams/team.feature delete mode 100644 lib/api/user_teams.rb delete mode 100644 lib/gitlab/user_team_manager.rb delete mode 100644 spec/models/user_team_project_relationship_spec.rb delete mode 100644 spec/models/user_team_spec.rb delete mode 100644 spec/models/user_team_user_relationship_spec.rb delete mode 100644 spec/requests/api/user_teams_spec.rb diff --git a/app/controllers/admin/teams/application_controller.rb b/app/controllers/admin/teams/application_controller.rb deleted file mode 100644 index 8710821454e..00000000000 --- a/app/controllers/admin/teams/application_controller.rb +++ /dev/null @@ -1,11 +0,0 @@ -# Provides a base class for Admin controllers to subclass -# -# Automatically sets the layout and ensures an administrator is logged in -class Admin::Teams::ApplicationController < Admin::ApplicationController - - private - - def user_team - @team = UserTeam.find_by_path(params[:team_id]) - end -end diff --git a/app/controllers/admin/teams/members_controller.rb b/app/controllers/admin/teams/members_controller.rb deleted file mode 100644 index 590617f67c9..00000000000 --- a/app/controllers/admin/teams/members_controller.rb +++ /dev/null @@ -1,40 +0,0 @@ -class Admin::Teams::MembersController < Admin::Teams::ApplicationController - def new - @users = User.potential_team_members(user_team) - end - - def create - 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 admin_team_path(user_team), notice: 'Members were successfully added into Team of users.' - end - - def edit - team_member - end - - def update - options = {default_projects_access: params[:default_project_access], group_admin: params[:group_admin]} - 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 - 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." - end - - protected - - def team_member - @member ||= user_team.members.find_by_username(params[:id]) - end -end diff --git a/app/controllers/admin/teams/projects_controller.rb b/app/controllers/admin/teams/projects_controller.rb deleted file mode 100644 index 8584a188b20..00000000000 --- a/app/controllers/admin/teams/projects_controller.rb +++ /dev/null @@ -1,41 +0,0 @@ -class Admin::Teams::ProjectsController < Admin::Teams::ApplicationController - def new - @projects = Project.scoped - @projects = @projects.without_team(user_team) if user_team.projects.any? - #@projects.reject!(&:empty_repo?) - end - - def create - unless params[:project_ids].blank? - project_ids = params[:project_ids] - access = params[:greatest_project_access] - user_team.assign_to_projects(project_ids, access) - end - - redirect_to admin_team_path(user_team), notice: 'Team of users was successfully assgned to projects.' - end - - def edit - team_project - end - - def update - 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 - 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 ||= user_team.projects.find_with_namespace(params[:id]) - end - -end diff --git a/app/controllers/admin/teams_controller.rb b/app/controllers/admin/teams_controller.rb deleted file mode 100644 index 786957cbc59..00000000000 --- a/app/controllers/admin/teams_controller.rb +++ /dev/null @@ -1,59 +0,0 @@ -class Admin::TeamsController < Admin::ApplicationController - def index - @teams = UserTeam.order('name ASC') - @teams = @teams.search(params[:name]) if params[:name].present? - @teams = @teams.page(params[:page]).per(20) - end - - def show - user_team - end - - def new - @team = UserTeam.new - end - - def edit - user_team - end - - def create - @team = UserTeam.new(params[:user_team]) - @team.path = @team.name.dup.parameterize if @team.name - @team.owner = current_user - - if @team.save - redirect_to admin_team_path(@team), notice: 'Team of users was successfully created.' - else - render action: "new" - end - end - - def update - user_team_params = params[:user_team].dup - owner_id = user_team_params.delete(:owner_id) - - if owner_id - user_team.owner = User.find(owner_id) - end - - if user_team.update_attributes(user_team_params) - redirect_to admin_team_path(user_team), notice: 'Team of users was successfully updated.' - else - render action: "edit" - end - end - - def destroy - user_team.destroy - - redirect_to admin_teams_path, notice: 'Team of users was successfully deleted.' - end - - protected - - def user_team - @team ||= UserTeam.find_by_path(params[:id]) - end - -end diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index 9b3f59600c6..fc7dc3fab63 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -7,7 +7,6 @@ class DashboardController < ApplicationController def show @groups = current_user.authorized_groups.sort_by(&:human_name) @has_authorized_projects = @projects.count > 0 - @teams = current_user.authorized_teams @projects_count = @projects.count @projects = @projects.limit(20) diff --git a/app/controllers/projects/teams_controller.rb b/app/controllers/projects/teams_controller.rb deleted file mode 100644 index c7d51b84fc4..00000000000 --- a/app/controllers/projects/teams_controller.rb +++ /dev/null @@ -1,34 +0,0 @@ -class Projects::TeamsController < Projects::ApplicationController - - before_filter :authorize_admin_team_member! - - def available - @teams = current_user.is_admin? ? UserTeam.scoped : current_user.user_teams - @teams = @teams.without_project(project) - unless @teams.any? - redirect_to project_team_index_path(project), notice: "No available teams for assigment." - end - end - - def assign - unless params[:team_id].blank? - team = UserTeam.find(params[:team_id]) - access = params[:greatest_project_access] - team.assign_to_project(project, access) - end - redirect_to project_team_index_path(project) - end - - def resign - team = project.user_teams.find_by_path(params[:id]) - team.resign_from_project(project) - - redirect_to project_team_index_path(project) - end - - protected - - def user_team - @team ||= UserTeam.find_by_path(params[:id]) - end -end diff --git a/app/controllers/teams/application_controller.rb b/app/controllers/teams/application_controller.rb deleted file mode 100644 index fc23202610c..00000000000 --- a/app/controllers/teams/application_controller.rb +++ /dev/null @@ -1,13 +0,0 @@ -class Teams::ApplicationController < ApplicationController - - layout 'user_team' - - before_filter :authorize_manage_user_team! - - protected - - def user_team - @team ||= UserTeam.find_by_path(params[:team_id]) - end - -end diff --git a/app/controllers/teams/members_controller.rb b/app/controllers/teams/members_controller.rb deleted file mode 100644 index 8ef786d1a66..00000000000 --- a/app/controllers/teams/members_controller.rb +++ /dev/null @@ -1,53 +0,0 @@ -class Teams::MembersController < Teams::ApplicationController - - skip_before_filter :authorize_manage_user_team!, only: [:index] - - def index - @members = user_team.members - end - - def new - @users = User.potential_team_members(user_team) - end - - def create - unless params[:user_ids].blank? - user_ids = params[:user_ids].split(',') - access = params[:default_project_access] - is_admin = params[:group_admin] - user_team.add_members(user_ids, access, is_admin) - end - - redirect_to team_members_path(user_team), notice: 'Members were successfully added into Team of users.' - end - - def edit - team_member - end - - def update - member_params = params[:team_member] - - options = { - default_projects_access: member_params[:permission], - group_admin: member_params[:group_admin] - } - - if user_team.update_membership(team_member, options) - redirect_to team_members_path(user_team), notice: "Membership for #{team_member.name} was successfully updated in Team of users." - else - render :edit - end - end - - def destroy - user_team.remove_member(team_member) - redirect_to team_path(user_team), notice: "Member #{team_member.name} was successfully removed from Team of users." - end - - protected - - def team_member - @member ||= user_team.members.find_by_username(params[:id]) - end -end diff --git a/app/controllers/teams/projects_controller.rb b/app/controllers/teams/projects_controller.rb deleted file mode 100644 index 81ffa238b46..00000000000 --- a/app/controllers/teams/projects_controller.rb +++ /dev/null @@ -1,40 +0,0 @@ -class Teams::ProjectsController < Teams::ApplicationController - def create - redirect_to :back if params[:project_ids].blank? - - project_ids = params[:project_ids] - access = params[:greatest_project_access] - - # Reject non-allowed projects - allowed_project_ids = current_user.owned_projects.map(&:id) - project_ids.select! { |id| allowed_project_ids.include?(id.to_i) } - - # Assign projects to team - user_team.assign_to_projects(project_ids, access) - - redirect_to edit_team_path(user_team), notice: 'Team of users was successfully assigned to projects.' - end - - def edit - team_project - end - - def update - if user_team.update_project_access(team_project, params[:greatest_project_access]) - redirect_to edit_team_path(user_team), notice: 'Access was successfully updated.' - else - render :edit - end - end - - def destroy - user_team.resign_from_project(team_project) - redirect_to team_projects_path(user_team), notice: 'Team of users was successfully reassigned from project.' - end - - private - - 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 deleted file mode 100644 index 57ab2a88e03..00000000000 --- a/app/controllers/teams_controller.rb +++ /dev/null @@ -1,93 +0,0 @@ -class TeamsController < ApplicationController - # Authorize - before_filter :authorize_create_team!, only: [:new, :create] - before_filter :authorize_manage_user_team!, only: [:edit, :update] - before_filter :authorize_admin_user_team!, only: [:destroy] - - before_filter :user_team, except: [:new, :create] - - layout :determine_layout - - before_filter :set_title, only: [:new, :create] - - def show - projects - @events = Event.in_projects(user_team.project_ids).limit(20).offset(params[:offset] || 0) - end - - def edit - projects - @avaliable_projects = current_user.owned_projects.without_team(user_team) - end - - def update - if user_team.update_attributes(params[:user_team]) - redirect_to team_path(user_team) - else - render action: :edit - end - end - - def destroy - user_team.destroy - redirect_to dashboard_path - end - - def new - @team = UserTeam.new - end - - def create - @team = UserTeam.new(params[:user_team]) - @team.owner = current_user unless params[:owner] - @team.path = @team.name.dup.parameterize if @team.name - - if @team.save - # Add current user as Master to the team - @team.add_members([current_user.id], UsersProject::MASTER, true) - - redirect_to team_path(@team) - else - render action: :new - end - end - - # Get authored or assigned open merge requests - def merge_requests - projects - @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 - projects - @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) - end - - protected - - def projects - @projects ||= user_team.projects.sorted_by_activity - end - - def user_team - @team ||= current_user.authorized_teams.find_by_path(params[:id]) - end - - def set_title - @title = 'New Team' - end - - def determine_layout - if [:new, :create].include?(action_name.to_sym) - 'navless' - else - 'user_team' - end - end -end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index a73d574f22e..8ccb2380d62 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -92,7 +92,6 @@ module ApplicationHelper def search_autocomplete_source projects = current_user.authorized_projects.map { |p| { label: "project: #{simple_sanitize(p.name_with_namespace)}", url: project_path(p) } } groups = current_user.authorized_groups.map { |group| { label: "group: #{simple_sanitize(group.name)}", url: group_path(group) } } - teams = current_user.authorized_teams.map { |team| { label: "team: #{simple_sanitize(team.name)}", url: team_path(team) } } default_nav = [ { label: "My Profile", url: profile_path }, @@ -128,7 +127,7 @@ module ApplicationHelper ] end - [groups, teams, projects, default_nav, project_nav, help_nav].flatten.to_json + [groups, projects, default_nav, project_nav, help_nav].flatten.to_json end def emoji_autocomplete_source diff --git a/app/helpers/user_teams_helper.rb b/app/helpers/user_teams_helper.rb deleted file mode 100644 index 8603ee434a8..00000000000 --- a/app/helpers/user_teams_helper.rb +++ /dev/null @@ -1,25 +0,0 @@ -module UserTeamsHelper - def team_filter_path(entity, options={}) - exist_opts = { - status: params[:status], - project_id: params[:project_id], - } - - options = exist_opts.merge(options) - - case entity - when 'issue' then - issues_team_path(@team, options) - when 'merge_request' - merge_requests_team_path(@team, options) - end - end - - def grouped_user_team_members(team) - team.user_team_user_relationships.sort_by(&:permission).reverse.group_by(&:permission) - end - - def remove_from_user_team_message(team, member) - "You are going to remove #{member.name} from #{team.name}. Are you sure?" - end -end diff --git a/app/models/ability.rb b/app/models/ability.rb index 70a4435e699..7e8d14ab10d 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -11,7 +11,6 @@ class Ability when "PersonalSnippet" then personal_snippet_abilities(user, subject) when "MergeRequest" then merge_request_abilities(user, subject) when "Group", "Namespace" then group_abilities(user, subject) - when "UserTeam" then user_team_abilities(user, subject) else [] end.concat(global_abilities(user)) end @@ -19,7 +18,6 @@ class Ability def global_abilities(user) rules = [] rules << :create_group if user.can_create_group - rules << :create_team if user.can_create_team rules end @@ -146,21 +144,6 @@ class Ability rules.flatten end - def user_team_abilities user, team - rules = [] - - # Only group owner and administrators can manage team - if user.admin? || team.owner == user || team.admin?(user) - rules << [ :manage_user_team ] - end - - if team.owner == user || user.admin? - rules << [ :admin_user_team ] - end - - rules.flatten - end - [:issue, :note, :project_snippet, :personal_snippet, :merge_request].each do |name| define_method "#{name}_abilities" do |user, subject| if subject.author == user diff --git a/app/models/deprecated/user_team.rb b/app/models/deprecated/user_team.rb new file mode 100644 index 00000000000..a036cedc4c7 --- /dev/null +++ b/app/models/deprecated/user_team.rb @@ -0,0 +1,116 @@ +# == Schema Information +# +# Table name: user_teams +# +# id :integer not null, primary key +# name :string(255) +# path :string(255) +# owner_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# description :string(255) default(""), not null +# + +class UserTeam < ActiveRecord::Base + attr_accessible :name, :description, :owner_id, :path + + belongs_to :owner, class_name: User + + has_many :user_team_project_relationships, dependent: :destroy + has_many :user_team_user_relationships, dependent: :destroy + + has_many :projects, through: :user_team_project_relationships + has_many :members, through: :user_team_user_relationships, source: :user + + validates :owner, presence: true + validates :name, presence: true, uniqueness: true, + length: { within: 0..255 }, + format: { with: Gitlab::Regex.name_regex, + message: "only letters, digits, spaces & '_' '-' '.' allowed." } + validates :description, length: { within: 0..255 } + validates :path, uniqueness: true, presence: true, length: { within: 1..255 }, + format: { with: Gitlab::Regex.path_regex, + message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" } + + scope :with_member, ->(user){ joins(:user_team_user_relationships).where(user_team_user_relationships: {user_id: user.id}) } + scope :with_project, ->(project){ joins(:user_team_project_relationships).where(user_team_project_relationships: {project_id: project})} + scope :without_project, ->(project){ where("user_teams.id NOT IN (:ids)", ids: (a = with_project(project); a.blank? ? 0 : a))} + scope :created_by, ->(user){ where(owner_id: user) } + + class << self + def search query + where("name LIKE :query OR path LIKE :query", query: "%#{query}%") + end + + def global_id + 'GLN' + end + + def access_roles + UsersProject.access_roles + end + end + + def to_param + path + end + + def assign_to_projects(projects, access) + projects.each do |project| + assign_to_project(project, access) + end + end + + def assign_to_project(project, access) + Gitlab::UserTeamManager.assign(self, project, access) + end + + def resign_from_project(project) + Gitlab::UserTeamManager.resign(self, project) + end + + def add_members(users, access, group_admin) + # reject existing users + users.reject! { |id| member_ids.include?(id.to_i) } + + users.each do |user| + add_member(user, access, group_admin) + end + end + + def add_member(user, access, group_admin) + Gitlab::UserTeamManager.add_member_into_team(self, user, access, group_admin) + end + + def remove_member(user) + Gitlab::UserTeamManager.remove_member_from_team(self, user) + end + + def update_membership(user, options) + Gitlab::UserTeamManager.update_team_user_membership(self, user, options) + end + + def update_project_access(project, permission) + Gitlab::UserTeamManager.update_project_greates_access(self, project, permission) + end + + def max_project_access(project) + user_team_project_relationships.find_by_project_id(project).greatest_access + end + + def human_max_project_access(project) + self.class.access_roles.invert[max_project_access(project)] + end + + def default_projects_access(member) + user_team_user_relationships.find_by_user_id(member).permission + end + + def human_default_projects_access(member) + self.class.access_roles.invert[default_projects_access(member)] + end + + def admin?(member) + user_team_user_relationships.with_user(member).first.try(:group_admin?) + end +end diff --git a/app/models/deprecated/user_team_project_relationship.rb b/app/models/deprecated/user_team_project_relationship.rb new file mode 100644 index 00000000000..991510be936 --- /dev/null +++ b/app/models/deprecated/user_team_project_relationship.rb @@ -0,0 +1,44 @@ +# == Schema Information +# +# Table name: user_team_project_relationships +# +# id :integer not null, primary key +# project_id :integer +# user_team_id :integer +# greatest_access :integer +# created_at :datetime not null +# updated_at :datetime not null +# + +class UserTeamProjectRelationship < ActiveRecord::Base + attr_accessible :greatest_access, :project_id, :user_team_id + + belongs_to :user_team + belongs_to :project + + validates :project, presence: true + validates :user_team, presence: true + validate :check_greatest_access + + scope :with_project, ->(project){ where(project_id: project.id) } + + def team_name + user_team.name + end + + def human_max_access + UserTeam.access_roles.key(greatest_access) + end + + private + + def check_greatest_access + errors.add(:base, :incorrect_access_code) unless correct_access? + end + + def correct_access? + return false if greatest_access.blank? + return true if UsersProject.access_roles.has_value?(greatest_access) + false + end +end diff --git a/app/models/deprecated/user_team_user_relationship.rb b/app/models/deprecated/user_team_user_relationship.rb new file mode 100644 index 00000000000..1f7e2625f5f --- /dev/null +++ b/app/models/deprecated/user_team_user_relationship.rb @@ -0,0 +1,32 @@ +# == Schema Information +# +# Table name: user_team_user_relationships +# +# id :integer not null, primary key +# user_id :integer +# user_team_id :integer +# group_admin :boolean +# permission :integer +# created_at :datetime not null +# updated_at :datetime not null +# + +class UserTeamUserRelationship < ActiveRecord::Base + attr_accessible :group_admin, :permission, :user_id, :user_team_id + + belongs_to :user_team + belongs_to :user + + validates :user_team, presence: true + validates :user, presence: true + + scope :with_user, ->(user) { where(user_id: user.id) } + + def user_name + user.name + end + + def access_human + UsersProject.access_roles.invert[permission] + end +end diff --git a/app/models/user.rb b/app/models/user.rb index 904d2919429..d8c9ac647b5 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -75,13 +75,6 @@ class User < ActiveRecord::Base has_many :users_groups, dependent: :destroy has_many :groups, through: :users_groups - # Teams - has_many :own_teams, dependent: :destroy, class_name: "UserTeam", foreign_key: :owner_id - has_many :user_team_user_relationships, dependent: :destroy - has_many :user_teams, through: :user_team_user_relationships - has_many :user_team_project_relationships, through: :user_teams - has_many :team_projects, through: :user_team_project_relationships - # Projects has_many :snippets, dependent: :destroy, foreign_key: :author_id, class_name: "Snippet" has_many :users_projects, dependent: :destroy @@ -235,10 +228,6 @@ class User < ActiveRecord::Base own_groups end - def owned_teams - own_teams - end - # Groups user has access to def authorized_groups @group_ids ||= (groups.pluck(:id) + own_groups.pluck(:id) + authorized_projects.pluck(:namespace_id)) @@ -252,15 +241,6 @@ class User < ActiveRecord::Base Project.where(id: @project_ids) end - def authorized_teams - if admin? - UserTeam.scoped - else - @team_ids ||= (user_teams.pluck(:id) + own_teams.pluck(:id)).uniq - UserTeam.where(id: @team_ids) - end - end - # Team membership in authorized projects def tm_in_authorized_projects UsersProject.where(project_id: authorized_projects.map(&:id), user_id: self.id) diff --git a/app/models/user_team.rb b/app/models/user_team.rb deleted file mode 100644 index a036cedc4c7..00000000000 --- a/app/models/user_team.rb +++ /dev/null @@ -1,116 +0,0 @@ -# == Schema Information -# -# Table name: user_teams -# -# id :integer not null, primary key -# name :string(255) -# path :string(255) -# owner_id :integer -# created_at :datetime not null -# updated_at :datetime not null -# description :string(255) default(""), not null -# - -class UserTeam < ActiveRecord::Base - attr_accessible :name, :description, :owner_id, :path - - belongs_to :owner, class_name: User - - has_many :user_team_project_relationships, dependent: :destroy - has_many :user_team_user_relationships, dependent: :destroy - - has_many :projects, through: :user_team_project_relationships - has_many :members, through: :user_team_user_relationships, source: :user - - validates :owner, presence: true - validates :name, presence: true, uniqueness: true, - length: { within: 0..255 }, - format: { with: Gitlab::Regex.name_regex, - message: "only letters, digits, spaces & '_' '-' '.' allowed." } - validates :description, length: { within: 0..255 } - validates :path, uniqueness: true, presence: true, length: { within: 1..255 }, - format: { with: Gitlab::Regex.path_regex, - message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" } - - scope :with_member, ->(user){ joins(:user_team_user_relationships).where(user_team_user_relationships: {user_id: user.id}) } - scope :with_project, ->(project){ joins(:user_team_project_relationships).where(user_team_project_relationships: {project_id: project})} - scope :without_project, ->(project){ where("user_teams.id NOT IN (:ids)", ids: (a = with_project(project); a.blank? ? 0 : a))} - scope :created_by, ->(user){ where(owner_id: user) } - - class << self - def search query - where("name LIKE :query OR path LIKE :query", query: "%#{query}%") - end - - def global_id - 'GLN' - end - - def access_roles - UsersProject.access_roles - end - end - - def to_param - path - end - - def assign_to_projects(projects, access) - projects.each do |project| - assign_to_project(project, access) - end - end - - def assign_to_project(project, access) - Gitlab::UserTeamManager.assign(self, project, access) - end - - def resign_from_project(project) - Gitlab::UserTeamManager.resign(self, project) - end - - def add_members(users, access, group_admin) - # reject existing users - users.reject! { |id| member_ids.include?(id.to_i) } - - users.each do |user| - add_member(user, access, group_admin) - end - end - - def add_member(user, access, group_admin) - Gitlab::UserTeamManager.add_member_into_team(self, user, access, group_admin) - end - - def remove_member(user) - Gitlab::UserTeamManager.remove_member_from_team(self, user) - end - - def update_membership(user, options) - Gitlab::UserTeamManager.update_team_user_membership(self, user, options) - end - - def update_project_access(project, permission) - Gitlab::UserTeamManager.update_project_greates_access(self, project, permission) - end - - def max_project_access(project) - user_team_project_relationships.find_by_project_id(project).greatest_access - end - - def human_max_project_access(project) - self.class.access_roles.invert[max_project_access(project)] - end - - def default_projects_access(member) - user_team_user_relationships.find_by_user_id(member).permission - end - - def human_default_projects_access(member) - self.class.access_roles.invert[default_projects_access(member)] - end - - def admin?(member) - user_team_user_relationships.with_user(member).first.try(:group_admin?) - end -end diff --git a/app/models/user_team_project_relationship.rb b/app/models/user_team_project_relationship.rb deleted file mode 100644 index 991510be936..00000000000 --- a/app/models/user_team_project_relationship.rb +++ /dev/null @@ -1,44 +0,0 @@ -# == Schema Information -# -# Table name: user_team_project_relationships -# -# id :integer not null, primary key -# project_id :integer -# user_team_id :integer -# greatest_access :integer -# created_at :datetime not null -# updated_at :datetime not null -# - -class UserTeamProjectRelationship < ActiveRecord::Base - attr_accessible :greatest_access, :project_id, :user_team_id - - belongs_to :user_team - belongs_to :project - - validates :project, presence: true - validates :user_team, presence: true - validate :check_greatest_access - - scope :with_project, ->(project){ where(project_id: project.id) } - - def team_name - user_team.name - end - - def human_max_access - UserTeam.access_roles.key(greatest_access) - end - - private - - def check_greatest_access - errors.add(:base, :incorrect_access_code) unless correct_access? - end - - def correct_access? - return false if greatest_access.blank? - return true if UsersProject.access_roles.has_value?(greatest_access) - false - end -end diff --git a/app/models/user_team_user_relationship.rb b/app/models/user_team_user_relationship.rb deleted file mode 100644 index 1f7e2625f5f..00000000000 --- a/app/models/user_team_user_relationship.rb +++ /dev/null @@ -1,32 +0,0 @@ -# == Schema Information -# -# Table name: user_team_user_relationships -# -# id :integer not null, primary key -# user_id :integer -# user_team_id :integer -# group_admin :boolean -# permission :integer -# created_at :datetime not null -# updated_at :datetime not null -# - -class UserTeamUserRelationship < ActiveRecord::Base - attr_accessible :group_admin, :permission, :user_id, :user_team_id - - belongs_to :user_team - belongs_to :user - - validates :user_team, presence: true - validates :user, presence: true - - scope :with_user, ->(user) { where(user_id: user.id) } - - def user_name - user.name - end - - def access_human - UsersProject.access_roles.invert[permission] - end -end diff --git a/app/views/admin/dashboard/index.html.haml b/app/views/admin/dashboard/index.html.haml index a69b26073f0..2774ccb85fe 100644 --- a/app/views/admin/dashboard/index.html.haml +++ b/app/views/admin/dashboard/index.html.haml @@ -49,10 +49,6 @@ .span4 %h4 Stats %hr - %p - Teams - %span.light.pull-right - = UserTeam.count %p Forks %span.light.pull-right diff --git a/app/views/admin/teams/edit.html.haml b/app/views/admin/teams/edit.html.haml deleted file mode 100644 index 0a3d993b132..00000000000 --- a/app/views/admin/teams/edit.html.haml +++ /dev/null @@ -1,28 +0,0 @@ -%h3.page_title Edit Team -%hr -= form_for @team, url: admin_team_path(@team), method: :put do |f| - - if @team.errors.any? - .alert.alert-error - %span= @team.errors.full_messages.first - .clearfix.team_name_holder - = f.label :name do - Team name is - .input - = f.text_field :name, placeholder: "Example Team", class: "xxlarge" - - .clearfix.team-description-holder - = f.label :description, "Details" - .input - = f.text_area :description, maxlength: 250, class: "xxlarge js-gfm-input", rows: 4 - - .clearfix.team_name_holder - = f.label :path do - %span.cred Team path is - .input - = f.text_field :path, placeholder: "example-team", class: "xxlarge danger" - %ul.cred - %li It will change web url for access team and team projects. - - .form-actions - = f.submit 'Edit team', class: "btn btn-remove" - = link_to 'Cancel', admin_teams_path, class: "btn btn-cancel" diff --git a/app/views/admin/teams/index.html.haml b/app/views/admin/teams/index.html.haml deleted file mode 100644 index 05ddc3cee89..00000000000 --- a/app/views/admin/teams/index.html.haml +++ /dev/null @@ -1,48 +0,0 @@ -%h3.page_title - Teams (#{@teams.total_count}) - %small - allow you to organize groups of people that have a common focus. Use teams to simplify the process of assigning roles to groups of people. - - = link_to 'New Team', new_admin_team_path, class: "btn btn-small pull-right" -%br - -= form_tag admin_teams_path, method: :get, class: 'form-inline' do - = text_field_tag :name, params[:name], class: "span6" - = submit_tag "Search", class: "btn submit btn-primary" - -%hr - -%ul.bordered-list - - @teams.each do |team| - %li - .clearfix - .pull-right.prepend-top-10 - = link_to 'Edit', edit_admin_team_path(team), id: "edit_#{dom_id(team)}", class: "btn btn-small" - = link_to 'Destroy', admin_team_path(team), confirm: "REMOVE #{team.name}? Are you sure?", method: :delete, class: "btn btn-small btn-remove" - - %h4 - = link_to admin_team_path(team) do - %i.icon-group - = team.name - - .clearfix.light.append-bottom-10 - %span - %b Owner: - - if team.owner - = link_to team.owner.name, admin_user_path(team.owner) - - else - (deleted) - \| - %span - %b Users: - %span.badge= team.members.count - \| - %span - %b Projects: - %span.badge= team.projects.count - - .clearfix - %p - = truncate team.description, length: 150 - -= paginate @teams, theme: "gitlab" diff --git a/app/views/admin/teams/members/_form.html.haml b/app/views/admin/teams/members/_form.html.haml deleted file mode 100644 index f1388aab4bb..00000000000 --- a/app/views/admin/teams/members/_form.html.haml +++ /dev/null @@ -1,20 +0,0 @@ -= form_tag admin_team_member_path(@team, @member), method: :put do - -if @member.errors.any? - .alert.alert-error - %ul - - @member.errors.full_messages.each do |msg| - %li= msg - - .clearfix - %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 - %label Team admin? - .input - = check_box_tag :group_admin, true, @team.admin?(@member) - - %br - .actions - = submit_tag 'Save', class: "btn btn-primary" - = link_to 'Cancel', :back, class: "btn" diff --git a/app/views/admin/teams/members/edit.html.haml b/app/views/admin/teams/members/edit.html.haml deleted file mode 100644 index a82847ee5f8..00000000000 --- a/app/views/admin/teams/members/edit.html.haml +++ /dev/null @@ -1,16 +0,0 @@ -%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' diff --git a/app/views/admin/teams/members/new.html.haml b/app/views/admin/teams/members/new.html.haml deleted file mode 100644 index 96b6d61b974..00000000000 --- a/app/views/admin/teams/members/new.html.haml +++ /dev/null @@ -1,27 +0,0 @@ -%h3.page_title - New members for - = link_to @team.name, admin_team_path(@team) - team -%hr -= form_tag admin_team_members_path(@team), id: "team_members", class: "bulk_import", method: :post do - - if @team.errors.any? - .alert.alert-error - %span= @team.errors.full_messages.first - .clearfix - = label_tag :user_ids do - Users to add - .input - = select_tag :user_ids, options_from_collection_for_select(@users , :id, :name_with_username), multiple: true, data: {placeholder: 'Select users'}, class: 'chosen span5' - .clearfix.group-description-holder - = label_tag :default_project_access do - Default permission in projects - .input - = select_tag :default_project_access, options_for_select(Project.access_options), {class: "project-access-select chosen span3" } - .clearfix - = label_tag :group_admin do - Is team admin - .input - = check_box_tag :group_admin - .clearfix.form-actions - = submit_tag 'Add users into team', class: "btn btn-primary", id: :add_members_to_team - = link_to 'Cancel', :back, class: "btn" diff --git a/app/views/admin/teams/new.html.haml b/app/views/admin/teams/new.html.haml deleted file mode 100644 index 8bccdacc351..00000000000 --- a/app/views/admin/teams/new.html.haml +++ /dev/null @@ -1,26 +0,0 @@ -%h3.page_title New Team -%hr -= form_for @team, url: admin_teams_path 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: "xxlarge left" - - .clearfix.team-description-holder - = f.label :description, "Details" - .input - = f.text_area :description, maxlength: 250, class: "xxlarge js-gfm-input", rows: 4 - - .form-actions - = f.submit 'Create team', class: "btn btn-create" - - %hr - .padded - %ul - %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 You will be able to assign existing projects for team diff --git a/app/views/admin/teams/projects/_form.html.haml b/app/views/admin/teams/projects/_form.html.haml deleted file mode 100644 index 5b79d518d42..00000000000 --- a/app/views/admin/teams/projects/_form.html.haml +++ /dev/null @@ -1,16 +0,0 @@ -= form_tag admin_team_project_path(@team, @project), method: :put do - -if @project.errors.any? - .alert.alert-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 btn-primary" - = link_to 'Cancel', :back, class: "btn" diff --git a/app/views/admin/teams/projects/edit.html.haml b/app/views/admin/teams/projects/edit.html.haml deleted file mode 100644 index b91a4982b81..00000000000 --- a/app/views/admin/teams/projects/edit.html.haml +++ /dev/null @@ -1,16 +0,0 @@ -%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' diff --git a/app/views/admin/teams/projects/new.html.haml b/app/views/admin/teams/projects/new.html.haml deleted file mode 100644 index dcb3dbbc433..00000000000 --- a/app/views/admin/teams/projects/new.html.haml +++ /dev/null @@ -1,18 +0,0 @@ -%h3.page_title - Team: #{@team.name} -%hr -= form_tag admin_team_projects_path(@team), id: "assign_projects", class: "bulk_import", method: :post do - %h6 Choose Projects you want to assign: - .clearfix - = label_tag :project_ids, "Projects" - .input - = select_tag :project_ids, options_from_collection_for_select(@projects , :id, :name_with_namespace), multiple: true, data: {placeholder: 'Select projects'}, class: 'chosen span5' - - %h6 Choose greatest user acces for your team in this projects: - .clearfix - = label_tag :greatest_project_access, "Greatest Access" - .input - = select_tag :greatest_project_access, options_for_select(Project.access_options), {class: "project-access-select chosen span3" } - - .form-actions - = submit_tag 'Add team to projects', class: "btn btn-create", id: :assign_projects_to_team diff --git a/app/views/admin/teams/show.html.haml b/app/views/admin/teams/show.html.haml deleted file mode 100644 index cf105c096e3..00000000000 --- a/app/views/admin/teams/show.html.haml +++ /dev/null @@ -1,96 +0,0 @@ -%h3.page_title - Team: #{@team.name} - - - = link_to edit_admin_team_path(@team), class: "btn btn-small pull-right" do - %i.icon-edit - Edit -%hr - - -.row - .span6 - .ui-box - %h5.title - Team info: - %ul.well-list - %li - %span.light Name: - %strong= @team.name - %li - %span.light Path: - %strong - = @team.path - - %li - %span.light Description: - %strong - = @team.description - - %li - %span.light Owned by: - %strong - - if @team.owner - = link_to @team.owner.name, admin_user_path(@team.owner) - - else - (deleted) - .pull-right - = link_to "#", class: "btn btn-small change-owner-link" do - %i.icon-edit - Change owner - %li.change-owner-holder.hide.bgred - .form-holder - %strong.cred New Owner: - = form_for @team, url: admin_team_path(@team) do |f| - = users_select_tag(:"user_team[owner_id]") - .prepend-top-10 - = f.submit 'Change Owner', class: "btn btn-remove" - = link_to "Cancel", "#", class: "btn change-owner-cancel-link" - - %li - %span.light Created at: - %strong - = @team.created_at.stamp("March 1, 1999") - - .span6 - .ui-box - %h5.title - Members (#{@team.members.count}) - .pull-right - = link_to 'Add members', new_admin_team_member_path(@team), class: "btn btn-small", id: :add_members_to_team - %ul.well-list#members_list - - @team.members.each do |member| - %li.member{ class: "user_#{member.id}"} - = link_to [:admin, member] do - %strong - = member.name - .pull-right - %span.light - = @team.human_default_projects_access(member) - - if @team.admin?(member) - %span.label.label-info Admin -   - = link_to 'Edit', edit_admin_team_member_path(@team, member), class: "btn btn-small" -   - = link_to 'Remove', admin_team_member_path(@team, member), confirm: 'Remove member from team. Are you sure?', method: :delete, class: "btn btn-remove btn-small", id: "remove_member_#{member.id}" - - - .ui-box - %h5.title - Projects (#{@team.projects.count}) - .pull-right - = link_to 'Add projects', new_admin_team_project_path(@team), class: "btn btn-small", id: :assign_projects_to_team - %ul.well-list#projects_list - - @team.projects.each do |project| - %li.project - = link_to [:admin, project] do - %strong - = project.name_with_namespace - - .pull-right - %span.light - = @team.human_max_project_access(project) -   - = link_to 'Edit', edit_admin_team_project_path(@team, project), class: "btn btn-small" -   - = link_to 'Relegate', admin_team_project_path(@team, project), confirm: 'Remove project from team. Are you sure?', method: :delete, class: "btn btn-remove small", id: "relegate_project_#{project.id}" diff --git a/app/views/admin/users/show.html.haml b/app/views/admin/users/show.html.haml index 6cf7152e5f7..b8fa41898d5 100644 --- a/app/views/admin/users/show.html.haml +++ b/app/views/admin/users/show.html.haml @@ -93,13 +93,6 @@ %li %strong= link_to group.name, admin_group_path(group) - - if @admin_user.owned_teams.present? - .ui-box - %h5.title Owned teams: - %ul.well-list - - @admin_user.owned_teams.each do |team| - %li - %strong= link_to team.name, admin_team_path(team) .span6 diff --git a/app/views/dashboard/_sidebar.html.haml b/app/views/dashboard/_sidebar.html.haml index 748ff9810b5..7886b1e9be0 100644 --- a/app/views/dashboard/_sidebar.html.haml +++ b/app/views/dashboard/_sidebar.html.haml @@ -3,16 +3,12 @@ = link_to 'Projects', '#projects', 'data-toggle' => 'tab', id: 'sidebar-projects-tab' %li = link_to 'Groups', '#groups', 'data-toggle' => 'tab', id: 'sidebar-groups-tab' - %li - = link_to 'Teams', '#teams', 'data-toggle' => 'tab', id: 'sidebar-teams-tab' .tab-content .tab-pane.active#projects = render "projects", projects: @projects .tab-pane#groups = render "groups", groups: @groups - .tab-pane#teams - = render "teams", teams: @teams .prepend-top-20 %span.rss-icon diff --git a/app/views/layouts/nav/_admin.html.haml b/app/views/layouts/nav/_admin.html.haml index e9ca29ea3be..73946f99889 100644 --- a/app/views/layouts/nav/_admin.html.haml +++ b/app/views/layouts/nav/_admin.html.haml @@ -4,8 +4,6 @@ %i.icon-home = nav_link(controller: :projects) do = link_to "Projects", admin_projects_path - = nav_link(controller: :teams) do - = link_to "Teams", admin_teams_path = nav_link(controller: :groups) do = link_to "Groups", admin_groups_path = nav_link(controller: :users) do diff --git a/app/views/projects/teams/available.html.haml b/app/views/projects/teams/available.html.haml deleted file mode 100644 index 29fe8ed25cd..00000000000 --- a/app/views/projects/teams/available.html.haml +++ /dev/null @@ -1,22 +0,0 @@ -= render "projects/settings_nav" - -%h3.page_title - = "Assign project to team of users" -%hr -%p.slead - Read more about assign to team of users #{link_to "here", '#', class: 'vlink'}. -= form_tag assign_project_teams_path(@project), method: 'post' do - %p.slead Choose Team of users you want to assign: - .padded - = label_tag :team_id, "Team" - .input= select_tag(:team_id, options_from_collection_for_select(@teams, :id, :name), prompt: "Select team", class: "chosen xxlarge", required: true) - %p.slead Choose greatest user acces in team you want to assign: - .padded - = label_tag :team_ids, "Permission" - .input= select_tag :greatest_project_access, options_for_select(UserTeam.access_roles), {class: "project-access-select chosen span3" } - - - .actions - = submit_tag 'Assign', class: "btn btn-create" - = link_to "Cancel", project_team_index_path(@project), class: "btn btn-cancel" - diff --git a/app/views/teams/_filter.html.haml b/app/views/teams/_filter.html.haml deleted file mode 100644 index f461fcad42e..00000000000 --- a/app/views/teams/_filter.html.haml +++ /dev/null @@ -1,33 +0,0 @@ -= form_tag team_filter_path(entity), method: 'get' do - %fieldset.dashboard-search-filter - = search_field_tag "search", params[:search], { placeholder: 'Search', class: 'search-text-input' } - = button_tag type: 'submit', class: 'btn' do - %i.icon-search - - %fieldset - %legend Status: - %ul.nav.nav-pills.nav-stacked - %li{class: ("active" if !params[:status])} - = link_to team_filter_path(entity, status: nil) do - Open - %li{class: ("active" if params[:status] == 'closed')} - = link_to team_filter_path(entity, status: 'closed') do - Closed - %li{class: ("active" if params[:status] == 'all')} - = link_to team_filter_path(entity, status: 'all') do - All - - %fieldset - %legend Projects: - %ul.nav.nav-pills.nav-stacked - - @projects.each do |project| - - unless entities_per_project(project, entity).zero? - %li{class: ("active" if params[:project_id] == project.id.to_s)} - = link_to team_filter_path(entity, project_id: project.id) do - = project.name_with_namespace - %small.pull-right= entities_per_project(project, entity) - - %fieldset - %hr - = link_to "Reset", team_filter_path(entity), class: 'btn pull-right' - diff --git a/app/views/teams/_projects.html.haml b/app/views/teams/_projects.html.haml deleted file mode 100644 index d0061aa2df7..00000000000 --- a/app/views/teams/_projects.html.haml +++ /dev/null @@ -1,22 +0,0 @@ -.ui-box - %h5.title - Projects - %small - (#{projects.count}) - - if can? current_user, :manage_user_team, @team - %span.pull-right - = link_to edit_team_path(@team), class: "btn btn-tiny info" do - %i.icon-plus - Assign Project - %ul.well-list - - if projects.blank? - %p.nothing_here_message This team has no projects yet - - projects.each do |project| - %li - = link_to project_path(project), class: dom_class(project) do - %strong.well-title= truncate(project.name_with_namespace, length: 40) - %span.arrow - → - %span.last_activity - %strong Last activity: - %span= project_last_activity(project) diff --git a/app/views/teams/edit.html.haml b/app/views/teams/edit.html.haml deleted file mode 100644 index 7f2273ee26c..00000000000 --- a/app/views/teams/edit.html.haml +++ /dev/null @@ -1,74 +0,0 @@ -.row - .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' - - if can? current_user, :admin_user_team, @team - %li - = link_to 'Remove', '#tab-remove', 'data-toggle' => 'tab' - - .span9 - .tab-content - .tab-pane.active#tab-projects - .ui-box.projects-table - %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" diff --git a/app/views/teams/issues.html.haml b/app/views/teams/issues.html.haml deleted file mode 100644 index 94818ccd7f4..00000000000 --- a/app/views/teams/issues.html.haml +++ /dev/null @@ -1,23 +0,0 @@ -%h3.page_title - Issues - %small (in Team projects assigned to Team members) - %small.pull-right #{@issues.total_count} issues - -%hr -.row - .span3 - = render 'filter', entity: 'issue' - .span9 - - if @issues.any? - - @issues.group_by(&:project).each do |group| - %div.ui-box - - @project = group[0] - %h5.title - = link_to_project @project - %ul.well-list.issues-list - - group[1].each do |issue| - = render issue - %hr - = paginate @issues, theme: "gitlab" - - else - %p.nothing_here_message Nothing to show here diff --git a/app/views/teams/members/_form.html.haml b/app/views/teams/members/_form.html.haml deleted file mode 100644 index c22ee78305f..00000000000 --- a/app/views/teams/members/_form.html.haml +++ /dev/null @@ -1,20 +0,0 @@ -= form_tag admin_team_member_path(@team, @member), method: :put do - -if @member.errors.any? - .alert.alert-error - %ul - - @member.errors.full_messages.each do |msg| - %li= msg - - .clearfix - %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 - %label Team admin? - .input - = check_box_tag :group_admin, true, @team.admin?(@member) - - %br - .actions - = submit_tag 'Save', class: "btn btn-save" - = link_to 'Cancel', :back, class: "btn" diff --git a/app/views/teams/members/_member.html.haml b/app/views/teams/members/_member.html.haml deleted file mode 100644 index 17096d2f1cd..00000000000 --- a/app/views/teams/members/_member.html.haml +++ /dev/null @@ -1,31 +0,0 @@ -- user = member.user -- allow_admin = can? current_user, :manage_user_team, @team -%li{id: dom_id(member), class: "team_member_row user_#{user.id}"} - .row - .span3 - = link_to user_path(user.username), title: user.name, class: "dark" do - = image_tag gravatar_icon(user.email, 40), class: "avatar s32" - = link_to user_path(user.username), title: user.name, class: "dark" do - %strong= truncate(user.name, lenght: 40) - %br - %small.cgray= user.username - - .span5.pull-right - - if allow_admin - .pull-left - = form_for(member, as: :team_member, url: team_member_path(@team, user)) do |f| - = label_tag :group_admin do - = f.check_box :group_admin, class: 'trigger-submit' - %span Admin access -   - = f.select :permission, options_for_select(UsersProject.access_roles, @team.default_projects_access(user)), {}, class: "span2 trigger-submit" - .pull-right - - if current_user == user - %span.label.label-success This is you! - - if @team.owner == user - %span.label.label-info Owner - - elsif user.blocked? - %span.label.label-error Blocked - - elsif allow_admin - = link_to team_member_path(@team, user), confirm: remove_from_user_team_message(@team, user), method: :delete, class: "btn-tiny btn btn-remove", title: "Remove from team" do - %i.icon-minus.icon-white diff --git a/app/views/teams/members/_team.html.haml b/app/views/teams/members/_team.html.haml deleted file mode 100644 index 52bb597cd80..00000000000 --- a/app/views/teams/members/_team.html.haml +++ /dev/null @@ -1,10 +0,0 @@ -- grouped_user_team_members(team).each do |access, members| - - access_key = Project.access_options.key(access) - - next if params[:type].present? && params[:type] != access_key.tableize - .ui-box - %h5.title - = access_key.pluralize - %small= members.size - %ul.well-list.team-members - - members.sort_by(&:user_name).each do |member| - = render 'teams/members/member', member: member diff --git a/app/views/teams/members/edit.html.haml b/app/views/teams/members/edit.html.haml deleted file mode 100644 index 375880496ab..00000000000 --- a/app/views/teams/members/edit.html.haml +++ /dev/null @@ -1,16 +0,0 @@ -%h3.page_title - 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' diff --git a/app/views/teams/members/index.html.haml b/app/views/teams/members/index.html.haml deleted file mode 100644 index 02700e9fb71..00000000000 --- a/app/views/teams/members/index.html.haml +++ /dev/null @@ -1,37 +0,0 @@ -%h3.page_title - Team Members - (#{@members.count}) - %small - Read more about project permissions - %strong= link_to "here", help_permissions_path, class: "vlink" - - - if can? current_user, :manage_user_team, @team - %span.pull-right - = link_to new_team_member_path(@team), class: "btn btn-primary small grouped", title: "New Team Member" do - New Team Member -%hr - - -.row - .span3 - %ul.nav.nav-pills.nav-stacked - %li{class: ("active" if !params[:type])} - = link_to team_members_path(@team, type: nil) do - All - %li{class: ("active" if params[:type] == 'masters')} - = link_to team_members_path(@team, type: 'masters') do - Masters - %li{class: ("active" if params[:type] == 'developers')} - = link_to team_members_path(@team, type: 'developers') do - Developers - %li{class: ("active" if params[:type] == 'reporters')} - = link_to team_members_path(@team, type: 'reporters') do - Reporters - %li{class: ("active" if params[:type] == 'guests')} - = link_to team_members_path(@team, type: 'guests') do - Guests - - .span9 - .clearfix - %div.team-table - = render "teams/members/team", team: @team diff --git a/app/views/teams/members/new.html.haml b/app/views/teams/members/new.html.haml deleted file mode 100644 index 99530ebb7f0..00000000000 --- a/app/views/teams/members/new.html.haml +++ /dev/null @@ -1,25 +0,0 @@ -%h3.page_title - Team: #{@team.name} - -%hr - -= form_tag team_members_path(@team), id: "team_members", class: "bulk_import", method: :post do - %h6 1. Choose people you want in the team - .clearfix - = label_tag :user_ids, "People" - .input - = users_select_tag(:user_ids, multiple: true) - - %h6 2. Set access level for them - .clearfix - = label_tag :project_access, "Project Access" - .input= select_tag :default_project_access, options_for_select(Project.access_options), class: "project-access-select chosen" - - .clearfix - = label_tag :group_admin do - %span Team Admin? - .input= check_box_tag :group_admin - - .actions - = submit_tag 'Add users', class: "btn btn-create", id: :add_members_to_team - = link_to "Cancel", team_members_path(@team), class: "btn btn-cancel" diff --git a/app/views/teams/merge_requests.html.haml b/app/views/teams/merge_requests.html.haml deleted file mode 100644 index 417d1aa6040..00000000000 --- a/app/views/teams/merge_requests.html.haml +++ /dev/null @@ -1,24 +0,0 @@ -%h3.page_title - Merge Requests - %small (authored by or assigned to Team members) - %small.pull-right #{@merge_requests.total_count} merge requests - -%hr -.row - .span3 - = render 'filter', entity: 'merge_request' - .span9 - - if @merge_requests.any? - - @merge_requests.group_by(&:project).each do |group| - .ui-box - - @project = group[0] - %h5.title - = link_to_project @project - %ul.well-list - - group[1].each do |merge_request| - = render(partial: 'merge_requests/merge_request', locals: {merge_request: merge_request}) - %hr - = paginate @merge_requests, theme: "gitlab" - - - else - %h3.nothing_here_message Nothing to show here diff --git a/app/views/teams/new.html.haml b/app/views/teams/new.html.haml deleted file mode 100644 index fe1f9cf10ec..00000000000 --- a/app/views/teams/new.html.haml +++ /dev/null @@ -1,37 +0,0 @@ -= form_for @team, url: teams_path 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. Ruby Developers", class: "xxlarge left" - - .clearfix.team-description-holder - = f.label :description, "Details" - .input - = f.text_area :description, maxlength: 250, class: "xxlarge js-gfm-input", rows: 4 - - - .clearfix - .input - %ul - %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 You will be able to assign existing projects for team - .form-actions - = f.submit 'Create team', class: "btn btn-create" - - - if current_user.can_create_group? - .clearfix - .input.light - Need a group for several dependent projects? - = link_to new_group_path, class: "btn btn-tiny" do - Create a group - - if current_user.can_create_project? - .clearfix - .input.light - Want to create a project? - = link_to new_project_path, class: "btn btn-tiny" do - Create a project diff --git a/app/views/teams/projects/_form.html.haml b/app/views/teams/projects/_form.html.haml deleted file mode 100644 index d2c89b0c36b..00000000000 --- a/app/views/teams/projects/_form.html.haml +++ /dev/null @@ -1,16 +0,0 @@ -= form_tag team_project_path(@team, @project), method: :put do - -if @project.errors.any? - .alert.alert-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 btn-save" - = link_to 'Cancel', :back, class: "btn btn-cancel" diff --git a/app/views/teams/projects/edit.html.haml b/app/views/teams/projects/edit.html.haml deleted file mode 100644 index 82c7d734815..00000000000 --- a/app/views/teams/projects/edit.html.haml +++ /dev/null @@ -1,6 +0,0 @@ -%h3.page_title - Edit max access in #{link_to @project.name_with_namespace, @project} for #{link_to(@team.name, team_path(@team))} team - -%hr - -= render 'form' diff --git a/app/views/teams/show.atom.builder b/app/views/teams/show.atom.builder deleted file mode 100644 index fffb78d53e8..00000000000 --- a/app/views/teams/show.atom.builder +++ /dev/null @@ -1,28 +0,0 @@ -xml.instruct! -xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do - xml.title "Team feed - #{@team.name}" - xml.link :href => team_url(@team, :atom), :rel => "self", :type => "application/atom+xml" - xml.link :href => team_url(@team), :rel => "alternate", :type => "text/html" - xml.id projects_url - xml.updated @events.maximum(:updated_at).strftime("%Y-%m-%dT%H:%M:%SZ") if @events.any? - - @events.each do |event| - if event.proper? - xml.entry do - event_link = event_feed_url(event) - event_title = event_feed_title(event) - - xml.id "tag:#{request.host},#{event.created_at.strftime("%Y-%m-%d")}:#{event.id}" - xml.link :href => event_link - xml.title truncate(event_title, :length => 80) - xml.updated event.created_at.strftime("%Y-%m-%dT%H:%M:%SZ") - xml.media :thumbnail, :width => "40", :height => "40", :url => gravatar_icon(event.author_email) - xml.author do |author| - xml.name event.author_name - xml.email event.author_email - end - xml.summary event_title - end - end - end -end diff --git a/app/views/teams/show.html.haml b/app/views/teams/show.html.haml deleted file mode 100644 index 8582f85a2b5..00000000000 --- a/app/views/teams/show.html.haml +++ /dev/null @@ -1,25 +0,0 @@ -.dashboard - .activities.span8 - = link_to dashboard_path, class: 'btn btn-tiny' do - ← To dashboard -   - %span.cgray Events and projects are filtered in scope of team - %hr - - if @events.any? - .content_list - - else - %p.nothing_here_message Projects activity will be displayed here - .loading.hide - .side.span4 - - if @team.description.present? - .description-block - = @team.description - = render "projects", projects: @projects - .prepend-top-20 - = link_to team_path(@team, { format: :atom, private_token: current_user.private_token }), title: "Feed" do - %strong - %i.icon-rss - News Feed - - %hr - = render 'shared/promo' diff --git a/app/views/teams/show.js.haml b/app/views/teams/show.js.haml deleted file mode 100644 index 7e5a148e5ef..00000000000 --- a/app/views/teams/show.js.haml +++ /dev/null @@ -1,2 +0,0 @@ -:plain - Pager.append(#{@events.count}, "#{escape_javascript(render(@events))}"); diff --git a/config/routes.rb b/config/routes.rb index b431cb23c83..1a3ea15a17a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -155,20 +155,6 @@ Gitlab::Application.routes.draw do resources :users_groups, only: [:create, :update, :destroy] end - # - # Teams Area - # - resources :teams, constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/} do - member do - get :issues - get :merge_requests - end - scope module: :teams do - resources :members, only: [:index, :new, :create, :edit, :update, :destroy] - resources :projects, only: [:index, :new, :create, :edit, :update, :destroy], constraints: { id: /[a-zA-Z.0-9_\-\/]+/ } - end - end - resources :projects, constraints: { id: /[^\/]+/ }, only: [:new, :create] devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks, registrations: :registrations } @@ -307,18 +293,6 @@ Gitlab::Application.routes.draw do end end - scope module: :projects do - resources :teams, only: [] do - collection do - get :available - post :assign - end - member do - delete :resign - end - end - end - resources :notes, only: [:index, :create, :destroy] do collection do post :preview diff --git a/features/steps/userteams/userteams.rb b/features/steps/userteams/userteams.rb deleted file mode 100644 index b4b2fb66a50..00000000000 --- a/features/steps/userteams/userteams.rb +++ /dev/null @@ -1,241 +0,0 @@ -class Userteams < Spinach::FeatureSteps - include SharedAuthentication - include SharedPaths - include SharedProject - include Select2Helper - - When 'I do not have teams with me' do - UserTeam.with_member(current_user).destroy_all - end - - Then 'I should see dashboard page without teams info block' do - page.has_no_css?(".teams-box").must_equal true - end - - When 'I have teams with my membership' do - team = create :user_team, owner: current_user - team.add_member(current_user, UserTeam.access_roles["Master"], true) - end - - Then 'I should see dashboard page with teams information block' do - page.should have_css(".teams-box") - end - - When 'exist user teams' do - team = create :user_team - team.add_member(current_user, UserTeam.access_roles["Master"], true) - end - - And 'I click on "All teams" link' do - click_link("All Teams") - end - - Then 'I should see "All teams" page' do - current_path.should == teams_path - end - - And 'I should see exist teams in teams list' do - team = UserTeam.last - find_in_list(".teams_list tr", team).must_equal true - end - - When 'I click to "New team" link' do - click_link("New Team") - end - - And 'I submit form with new team info' do - fill_in 'name', with: 'gitlab' - - fill_in 'user_team_description', with: 'team description' - click_button 'Create team' - end - - And 'I should see newly created team' do - page.should have_content "gitlab" - page.should have_content "team description" - end - - Then 'I should be redirected to new team page' do - team = UserTeam.last - current_path.should == team_path(team) - end - - When 'I have teams with projects and members' do - team = create :user_team, owner: current_user - @project = create :project - team.add_member(current_user, UserTeam.access_roles["Master"], true) - team.assign_to_project(@project, UserTeam.access_roles["Master"]) - @event = create(:closed_issue_event, project: @project) - end - - When 'I visit team page' do - visit team_path(UserTeam.last) - end - - Then 'I should see projects list' do - within(".side .ui-box") do - page.should have_content(@project.name) - end - end - - And 'project from team has issues assigned to me' do - team = UserTeam.last - team.projects.each do |project| - project.issues << create(:issue, assignee: current_user) - end - end - - When 'I visit team issues page' do - team = UserTeam.last - visit issues_team_path(team) - end - - Then 'I should see issues from this team assigned to me' do - team = UserTeam.last - team.projects.each do |project| - project.issues.assigned_to(current_user).each do |issue| - page.should have_content issue.title - end - end - end - - Given 'I have team with projects and members' do - team = create :user_team, owner: current_user - project = create :project - user = create :user - team.add_member(current_user, UserTeam.access_roles["Master"], true) - team.add_member(user, UserTeam.access_roles["Developer"], false) - team.assign_to_project(project, UserTeam.access_roles["Master"]) - end - - Given 'project from team has issues assigned to teams members' do - team = UserTeam.last - team.projects.each do |project| - team.members.each do |member| - project.issues << create(:issue, assignee: member) - end - end - end - - Then 'I should see issues from this team assigned to teams members' do - team = UserTeam.last - team.projects.each do |project| - team.members.each do |member| - project.issues.assigned_to(member).each do |issue| - page.should have_content issue.title - end - end - end - end - - Given 'project from team has merge requests assigned to me' do - team = UserTeam.last - team.projects.each do |project| - create(:merge_request, assignee: current_user, project: project) - end - end - - When 'I visit team merge requests page' do - team = UserTeam.last - visit merge_requests_team_path(team) - end - - Then 'I should see merge requests from this team assigned to me' do - team = UserTeam.last - team.projects.each do |project| - project.merge_requests.each do |merge_request| - page.should have_content merge_request.title - end - end - end - - Given 'project from team has merge requests assigned to team members' do - team = UserTeam.last - team.projects.each do |project| - member = team.members.sample - create(:merge_request, assignee: member, project: project) - end - end - - Given 'I have new user "John"' do - create :user, name: "John" - end - - When 'I visit team people page' do - team = UserTeam.last - visit team_members_path(team) - end - - And 'I select user "John" from list with role "Reporter"' do - user = User.find_by_name("John") - select2(user.id, from: "#user_ids", multiple: true) - within "#team_members" do - select "Reporter", from: "default_project_access" - end - click_button "Add" - end - - Then 'I should see user "John" in team list' do - user = User.find_by_name("John") - team_members_list = find(".team-table") - team_members_list.should have_content user.name - end - - And 'I have my own project without teams' do - @project = create :project, namespace: current_user.namespace - end - - And 'I visit my team page' do - team = UserTeam.where(owner_id: current_user.id).last - visit team_path(team) - end - - When 'I click on link "Assign Project"' do - click_link "Assign Project" - end - - Then 'I should see form with my own project in available projects list' do - projects_select = find("#project_ids") - projects_select.should have_content(@project.name) - end - - When 'I submit form with selected project and max access' do - within "#assign_projects" do - select @project.name_with_namespace, from: "project_ids" - select "Reporter", from: "greatest_project_access" - end - click_button "Add" - end - - Then 'I should see my own project in team projects list' do - projects = find(".projects-table") - projects.should have_content(@project.name) - end - - When 'I click link "New Team Member"' do - click_link "New Team Member" - end - - protected - - def current_team - @user_team ||= UserTeam.first - end - - def project - current_team.projects.first - end - - def assigned_to_user key, user - project.send(key).where(assignee_id: user) - end - - def find_in_list(selector, item) - members_list = all(selector) - entered = false - members_list.each do |member_item| - entered = true if member_item.has_content?(item.name) - end - entered - end -end diff --git a/features/teams/team.feature b/features/teams/team.feature deleted file mode 100644 index ac34ed76f04..00000000000 --- a/features/teams/team.feature +++ /dev/null @@ -1,65 +0,0 @@ -Feature: UserTeams - Background: - Given I sign in as a user - And I own project "Shop" - And project "Shop" has push event - - Scenario: I should see teams info block - When I have teams with my membership - And I visit dashboard page - Then I should see dashboard page with teams information block - - Scenario: I should can create new team - When I have teams with my membership - And I visit dashboard page - When I click to "New team" link - And I submit form with new team info - Then I should be redirected to new team page - Then I should see newly created team - - Scenario: I should see team dashboard list - When I have teams with projects and members - When I visit team page - Then I should see projects list - - Scenario: I should see team issues list - Given I have team with projects and members - And project from team has issues assigned to me - When I visit team issues page - Then I should see issues from this team assigned to me - - Scenario: I should see teams members issues list - Given I have team with projects and members - Given project from team has issues assigned to teams members - When I visit team issues page - Then I should see issues from this team assigned to teams members - - Scenario: I should see team merge requests list - Given I have team with projects and members - Given project from team has merge requests assigned to me - When I visit team merge requests page - Then I should see merge requests from this team assigned to me - - Scenario: I should see teams members merge requests list - Given I have team with projects and members - Given project from team has merge requests assigned to team members - When I visit team merge requests page - Then I should see merge requests from this team assigned to me - - @javascript - Scenario: I should add user to projects in Team - Given I have team with projects and members - Given I have new user "John" - When I visit team people page - When I click link "New Team Member" - And I select user "John" from list with role "Reporter" - Then I should see user "John" in team list - - Scenario: I should assign my team to my own project - Given I have team with projects and members - And I have my own project without teams - And I visit my team page - When I click on link "Assign Project" - Then I should see form with my own project in available projects list - When I submit form with selected project and max access - Then I should see my own project in team projects list diff --git a/lib/api/api.rb b/lib/api/api.rb index 5d97d50cb82..c4c9f166db1 100644 --- a/lib/api/api.rb +++ b/lib/api/api.rb @@ -35,7 +35,6 @@ module API mount Notes mount Internal mount SystemHooks - mount UserTeams mount ProjectSnippets mount DeployKeys mount ProjectHooks diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 0d8cac5c8fd..14d6c0f9353 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -99,10 +99,6 @@ module API expose :id, :title, :key, :created_at end - class UserTeam < Grape::Entity - expose :id, :name, :path, :owner_id - end - class MergeRequest < Grape::Entity expose :id, :target_branch, :source_branch, :project_id, :title, :state expose :author, :assignee, using: Entities::UserBasic diff --git a/lib/api/user_teams.rb b/lib/api/user_teams.rb deleted file mode 100644 index 05aa72f0e92..00000000000 --- a/lib/api/user_teams.rb +++ /dev/null @@ -1,276 +0,0 @@ -module API - # user_teams API - class UserTeams < Grape::API - before { authenticate! } - - resource :user_teams do - helpers do - def handle_team_member_errors(errors) - if errors[:permission].any? - render_api_error!(errors[:permission], 422) - end - not_found! - end - - def validate_access_level?(level) - [UsersProject::GUEST, UsersProject::REPORTER, UsersProject::DEVELOPER, UsersProject::MASTER].include? level.to_i - end - end - - - # Get a user_teams list - # - # Example Request: - # GET /user_teams - get do - if current_user.admin - @user_teams = paginate UserTeam - else - @user_teams = paginate current_user.user_teams - end - present @user_teams, with: Entities::UserTeam - end - - - # Create user_team. Available only for admin - # - # Parameters: - # name (required) - The name of the user_team - # path (required) - The path of the user_team - # Example Request: - # POST /user_teams - post do - authenticated_as_admin! - required_attributes! [:name, :path] - - attrs = attributes_for_keys [:name, :path] - @user_team = UserTeam.new(attrs) - @user_team.owner = current_user - - if @user_team.save - present @user_team, with: Entities::UserTeam - else - not_found! - end - end - - - # Get a single user_team - # - # Parameters: - # id (required) - The ID of a user_team - # Example Request: - # GET /user_teams/:id - get ":id" do - @user_team = UserTeam.find(params[:id]) - if current_user.admin or current_user.user_teams.include? @user_team - present @user_team, with: Entities::UserTeam - else - not_found! - end - end - - - # Get user_team members - # - # Parameters: - # id (required) - The ID of a user_team - # Example Request: - # GET /user_teams/:id/members - get ":id/members" do - @user_team = UserTeam.find(params[:id]) - if current_user.admin or current_user.user_teams.include? @user_team - @members = paginate @user_team.members - present @members, with: Entities::TeamMember, user_team: @user_team - else - not_found! - end - end - - - # Add a new user_team member - # - # Parameters: - # id (required) - The ID of a user_team - # user_id (required) - The ID of a user - # access_level (required) - Project access level - # Example Request: - # POST /user_teams/:id/members - post ":id/members" do - authenticated_as_admin! - required_attributes! [:user_id, :access_level] - - if not validate_access_level?(params[:access_level]) - render_api_error!("Wrong access level", 422) - end - - @user_team = UserTeam.find(params[:id]) - if @user_team - team_member = @user_team.user_team_user_relationships.find_by_user_id(params[:user_id]) - # Not existing member - if team_member.nil? - @user_team.add_member(params[:user_id], params[:access_level], false) - team_member = @user_team.user_team_user_relationships.find_by_user_id(params[:user_id]) - - if team_member.nil? - render_api_error!("Error creating membership", 500) - else - @member = team_member.user - present @member, with: Entities::TeamMember, user_team: @user_team - end - else - render_api_error!("Already exists", 409) - end - else - not_found! - end - end - - - # Get a single team member from user_team - # - # Parameters: - # id (required) - The ID of a user_team - # user_id (required) - The ID of a team member - # Example Request: - # GET /user_teams/:id/members/:user_id - get ":id/members/:user_id" do - @user_team = UserTeam.find(params[:id]) - if current_user.admin or current_user.user_teams.include? @user_team - team_member = @user_team.user_team_user_relationships.find_by_user_id(params[:user_id]) - unless team_member.nil? - present team_member.user, with: Entities::TeamMember, user_team: @user_team - else - not_found! - end - else - not_found! - end - end - - # Remove a team member from user_team - # - # Parameters: - # id (required) - The ID of a user_team - # user_id (required) - The ID of a team member - # Example Request: - # DELETE /user_teams/:id/members/:user_id - delete ":id/members/:user_id" do - authenticated_as_admin! - - @user_team = UserTeam.find(params[:id]) - if @user_team - team_member = @user_team.user_team_user_relationships.find_by_user_id(params[:user_id]) - unless team_member.nil? - team_member.destroy - else - not_found! - end - else - not_found! - end - end - - - # Get to user_team assigned projects - # - # Parameters: - # id (required) - The ID of a user_team - # Example Request: - # GET /user_teams/:id/projects - get ":id/projects" do - @user_team = UserTeam.find(params[:id]) - if current_user.admin or current_user.user_teams.include? @user_team - @projects = paginate @user_team.projects - present @projects, with: Entities::TeamProject, user_team: @user_team - else - not_found! - end - end - - - # Add a new user_team project - # - # Parameters: - # id (required) - The ID of a user_team - # project_id (required) - The ID of a project - # greatest_access_level (required) - Project access level - # Example Request: - # POST /user_teams/:id/projects - post ":id/projects" do - authenticated_as_admin! - required_attributes! [:project_id, :greatest_access_level] - - if not validate_access_level?(params[:greatest_access_level]) - render_api_error!("Wrong greatest_access_level", 422) - end - - @user_team = UserTeam.find(params[:id]) - if @user_team - team_project = @user_team.user_team_project_relationships.find_by_project_id(params[:project_id]) - - # No existing project - if team_project.nil? - @user_team.assign_to_projects([params[:project_id]], params[:greatest_access_level]) - team_project = @user_team.user_team_project_relationships.find_by_project_id(params[:project_id]) - if team_project.nil? - render_api_error!("Error creating project assignment", 500) - else - @project = team_project.project - present @project, with: Entities::TeamProject, user_team: @user_team - end - else - render_api_error!("Already exists", 409) - end - else - not_found! - end - end - - # Show a single team project from user_team - # - # Parameters: - # id (required) - The ID of a user_team - # project_id (required) - The ID of a project assigned to the team - # Example Request: - # GET /user_teams/:id/projects/:project_id - get ":id/projects/:project_id" do - @user_team = UserTeam.find(params[:id]) - if current_user.admin or current_user.user_teams.include? @user_team - team_project = @user_team.user_team_project_relationships.find_by_project_id(params[:project_id]) - unless team_project.nil? - present team_project.project, with: Entities::TeamProject, user_team: @user_team - else - not_found! - end - else - not_found! - end - end - - # Remove a team project from user_team - # - # Parameters: - # id (required) - The ID of a user_team - # project_id (required) - The ID of a project assigned to the team - # Example Request: - # DELETE /user_teams/:id/projects/:project_id - delete ":id/projects/:project_id" do - authenticated_as_admin! - - @user_team = UserTeam.find(params[:id]) - if @user_team - team_project = @user_team.user_team_project_relationships.find_by_project_id(params[:project_id]) - unless team_project.nil? - team_project.destroy - else - not_found! - end - else - not_found! - end - end - - end - end -end diff --git a/lib/gitlab/user_team_manager.rb b/lib/gitlab/user_team_manager.rb deleted file mode 100644 index d5ec4ff6676..00000000000 --- a/lib/gitlab/user_team_manager.rb +++ /dev/null @@ -1,146 +0,0 @@ -# UserTeamManager class -# -# Used for manage User teams with project repositories -module Gitlab - class UserTeamManager - class << self - def assign(team, project, access) - project = Project.find(project) unless project.is_a? Project - searched_project = team.user_team_project_relationships.find_by_project_id(project.id) - - unless searched_project.present? - team.user_team_project_relationships.create(project_id: project.id, greatest_access: access) - update_team_users_access_in_project(team, project, :added) - end - end - - def resign(team, project) - project = Project.find(project) unless project.is_a? Project - - team.user_team_project_relationships.with_project(project).destroy_all - - update_team_users_access_in_project(team, project, :updated) - end - - def update_team_user_membership(team, member, options) - updates = {} - - if options[:default_projects_access].present? - default_projects_access = options[:default_projects_access].to_s - - if default_projects_access != team.default_projects_access(member).to_s - updates[:permission] = default_projects_access - end - end - - if options[:group_admin].present? - group_admin = options[:group_admin].to_s == "1" ? true : false - - if group_admin != team.admin?(member) - updates[:group_admin] = group_admin - end - end - - return true if updates.blank? - - user_team_relationship = team.user_team_user_relationships.find_by_user_id(member) - return false unless user_team_relationship.update_attributes(updates) - - rebuild_project_permissions_to_member(team, member) if updates[:permission] - - true - end - - def update_project_greates_access(team, project, permission) - project_relation = team.user_team_project_relationships.find_by_project_id(project) - if permission != team.max_project_access(project) - if project_relation.update_attributes(greatest_access: permission) - update_team_users_access_in_project(team, project, :updated) - true - else - false - end - else - true - end - end - - def rebuild_project_permissions_to_member(team, member) - team.projects.each do |project| - update_team_user_access_in_project(team, member, project, :updated) - end - end - - def update_team_users_access_in_project(team, project, action) - members = team.members - members.each do |member| - update_team_user_access_in_project(team, member, project, action) - end - end - - def update_team_user_access_in_project(team, user, project, action) - granted_access = max_teams_member_permission_in_project(user, project, action) - project_team_user = UsersProject.find_by_user_id_and_project_id(user.id, project.id) - - if granted_access.zero? - project_team_user.destroy if project_team_user.present? - return - end - - if project_team_user.present? - project_team_user.update_attributes(project_access: granted_access) - else - project.team << [user, granted_access] - end - end - - def max_teams_member_permission_in_project(user, project, action = nil, teams = nil) - result_access = 0 - - teams ||= project.user_teams.with_member(user) - - if action && (action == :added) - result_access = project.users_projects.with_user(user).first.project_access if project.users_projects.with_user(user).any? - end - - if teams.any? - teams.each do |team| - granted_access = max_team_member_permission_in_project(team, user, project) - result_access = [granted_access, result_access].max - end - end - result_access - end - - def max_team_member_permission_in_project(team, user, project) - member_access = team.default_projects_access(user) - team_access = team.user_team_project_relationships.find_by_project_id(project.id).greatest_access - - [team_access, member_access].min - end - - def add_member_into_team(team, user, access, admin) - user = User.find(user) unless user.is_a? User - - team.user_team_user_relationships.create(user_id: user.id, permission: access, group_admin: admin) - team.projects.each do |project| - update_team_user_access_in_project(team, user, project, :added) - end - end - - def remove_member_from_team(team, user) - user = User.find(user) unless user.is_a? User - - team.user_team_user_relationships.with_user(user).destroy_all - other_teams = [] - team.projects.each do |project| - other_teams << project.user_teams.with_member(user) - end - other_teams.uniq - unless other_teams.any? - UsersProject.in_projects(team.projects).with_user(user).destroy_all - end - end - end - end -end diff --git a/spec/models/user_team_project_relationship_spec.rb b/spec/models/user_team_project_relationship_spec.rb deleted file mode 100644 index 86150cf305f..00000000000 --- a/spec/models/user_team_project_relationship_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -# == Schema Information -# -# Table name: user_team_project_relationships -# -# id :integer not null, primary key -# project_id :integer -# user_team_id :integer -# greatest_access :integer -# created_at :datetime not null -# updated_at :datetime not null -# - -require 'spec_helper' - -describe UserTeamProjectRelationship do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/models/user_team_spec.rb b/spec/models/user_team_spec.rb deleted file mode 100644 index d330bbf3e33..00000000000 --- a/spec/models/user_team_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -# == Schema Information -# -# Table name: user_teams -# -# id :integer not null, primary key -# name :string(255) -# path :string(255) -# owner_id :integer -# created_at :datetime not null -# updated_at :datetime not null -# description :string(255) default(""), not null -# - -require 'spec_helper' - -describe UserTeam do - let(:team) { FactoryGirl.create :user_team } - - context ".add_member" do - let(:user) { FactoryGirl.create :user } - - it "should work" do - team.add_member(user, UsersProject::DEVELOPER, false) - team.members.should include(user) - end - end - - context ".remove_member" do - let(:user) { FactoryGirl.create :user } - before { team.add_member(user, UsersProject::DEVELOPER, false) } - - it "should work" do - team.remove_member(user) - team.members.should_not include(user) - end - end -end diff --git a/spec/models/user_team_user_relationship_spec.rb b/spec/models/user_team_user_relationship_spec.rb deleted file mode 100644 index 981ad1e8873..00000000000 --- a/spec/models/user_team_user_relationship_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -# == Schema Information -# -# Table name: user_team_user_relationships -# -# id :integer not null, primary key -# user_id :integer -# user_team_id :integer -# group_admin :boolean -# permission :integer -# created_at :datetime not null -# updated_at :datetime not null -# - -require 'spec_helper' - -describe UserTeamUserRelationship do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/requests/api/user_teams_spec.rb b/spec/requests/api/user_teams_spec.rb deleted file mode 100644 index 68f05b11a83..00000000000 --- a/spec/requests/api/user_teams_spec.rb +++ /dev/null @@ -1,360 +0,0 @@ -require 'spec_helper' - -describe API::API do - include ApiHelpers - - # Create test objects - let(:user1) { create(:user) } - let(:user2) { create(:user) } - let(:admin) { create(:admin) } - let!(:group1) { create(:group, owner: user1) } - let!(:group2) { create(:group, owner: user2) } - let(:user_team1) { create(:user_team, owner: user1) } - let(:user_team2) { create(:user_team, owner: user2) } - let!(:project1) { create(:project, creator_id: admin.id) } - let!(:project2) { create(:project, creator_id: admin.id) } - - - before { - # Add members to teams - user_team1.add_member(user1, UsersProject::MASTER, false) - user_team2.add_member(user2, UsersProject::MASTER, false) - - # Add projects to teams - user_team1.assign_to_projects([project1.id], UsersProject::MASTER) - user_team2.assign_to_projects([project2.id], UsersProject::MASTER) - - } - - describe "GET /user_teams" do - context "when unauthenticated" do - it "should return authentication error" do - get api("/user_teams") - response.status.should == 401 - end - end - - context "when authenticated as user" do - it "normal user: should return an array of user_teams of user1" do - get api("/user_teams", user1) - response.status.should == 200 - json_response.should be_an Array - json_response.length.should == 1 - json_response.first['name'].should == user_team1.name - end - end - - context "when authenticated as admin" do - it "admin: should return an array of all user_teams" do - get api("/user_teams", admin) - response.status.should == 200 - json_response.should be_an Array - json_response.length.should == 2 - end - end - end - - describe "GET /user_teams/:id" do - context "when authenticated as user" do - it "should return one of user1's user_teams" do - get api("/user_teams/#{user_team1.id}", user1) - response.status.should == 200 - json_response['name'] == user_team1.name - end - - it "should not return a non existing team" do - get api("/user_teams/1328", user1) - response.status.should == 404 - end - - it "should not return a user_team not attached to user1" do - get api("/user_teams/#{user_team2.id}", user1) - response.status.should == 404 - end - end - - context "when authenticated as admin" do - it "should return any existing user_team" do - get api("/user_teams/#{user_team2.id}", admin) - response.status.should == 200 - json_response['name'].should == user_team2.name - end - - it "should not return a non existing user_team" do - get api("/user_teams/1328", admin) - response.status.should == 404 - end - end - end - - describe "POST /user_teams" do - context "when authenticated as user" do - it "should not create user_team" do - count_before=UserTeam.count - post api("/user_teams", user1), attributes_for(:user_team) - response.status.should == 403 - UserTeam.count.should == count_before - end - end - - context "when authenticated as admin" do - it "should create user_team" do - count_before=UserTeam.count - post api("/user_teams", admin), attributes_for(:user_team) - response.status.should == 201 - UserTeam.count.should == count_before + 1 - end - - it "should not create user_team, duplicate" do - post api("/user_teams", admin), {:name => "Duplicate Test", :path => user_team2.path} - response.status.should == 404 - end - - it "should return 400 bad request error if name not given" do - post api("/user_teams", admin), {:path => user_team2.path} - response.status.should == 400 - end - - it "should return 400 bad request error if path not given" do - post api("/user_teams", admin), {:name => 'test'} - response.status.should == 400 - end - end - end - - # Members - - describe "GET /user_teams/:id/members" do - context "when authenticated as user" do - it "should return user1 as member of user1's user_teams" do - get api("/user_teams/#{user_team1.id}/members", user1) - response.status.should == 200 - json_response.first['name'].should == user1.name - json_response.first['access_level'].should == UsersProject::MASTER - end - end - - context "when authenticated as admin" do - it "should return member of any existing user_team" do - get api("/user_teams/#{user_team2.id}/members", admin) - response.status.should == 200 - json_response.first['name'].should == user2.name - json_response.first['access_level'].should == UsersProject::MASTER - end - end - end - - describe "POST /user_teams/:id/members" do - context "when authenticated as user" do - it "should not add user2 as member of user_team1" do - post api("/user_teams/#{user_team1.id}/members", user1), user_id: user2.id, access_level: UsersProject::MASTER - response.status.should == 403 - end - end - - context "when authenticated as admin" do - it "should return ok and add new member" do - count_before=user_team1.user_team_user_relationships.count - post api("/user_teams/#{user_team1.id}/members", admin), user_id: user2.id, access_level: UsersProject::MASTER - response.status.should == 201 - json_response['name'].should == user2.name - json_response['access_level'].should == UsersProject::MASTER - user_team1.user_team_user_relationships.count.should == count_before + 1 - end - it "should return ok if member already exists" do - post api("/user_teams/#{user_team2.id}/members", admin), user_id: user2.id, access_level: UsersProject::MASTER - response.status.should == 409 - end - it "should return a 400 error when user id is not given" do - post api("/user_teams/#{user_team2.id}/members", admin), access_level: UsersProject::MASTER - response.status.should == 400 - end - it "should return a 400 error when access level is not given" do - post api("/user_teams/#{user_team2.id}/members", admin), user_id: user2.id - response.status.should == 400 - end - - it "should return a 422 error when access level is not known" do - post api("/user_teams/#{user_team2.id}/members", admin), user_id: user1.id, access_level: 1234 - response.status.should == 422 - end - - end - end - - # Get single member - describe "GET /user_teams/:id/members/:user_id" do - context "when authenticated as member" do - it "should show user1's membership of user_team1" do - get api("/user_teams/#{user_team1.id}/members/#{user1.id}", user1) - response.status.should == 200 - json_response['name'].should == user1.name - json_response['access_level'].should == UsersProject::MASTER - end - it "should show that user2 is not member of user_team1" do - get api("/user_teams/#{user_team1.id}/members/#{user2.id}", user1) - response.status.should == 404 - end - end - - context "when authenticated as non-member" do - it "should not show user1's membership of user_team1" do - get api("/user_teams/#{user_team1.id}/members/#{user1.id}", user2) - response.status.should == 404 - end - end - - context "when authenticated as admin" do - it "should show user1's membership of user_team1" do - get api("/user_teams/#{user_team1.id}/members/#{user1.id}", admin) - response.status.should == 200 - json_response['name'].should == user1.name - json_response['access_level'].should == UsersProject::MASTER - end - it "should return a 404 error when user id is not known" do - get api("/user_teams/#{user_team2.id}/members/1328", admin) - response.status.should == 404 - end - end - end - - describe "DELETE /user_teams/:id/members/:user_id" do - context "when authenticated as user" do - it "should not delete user1's membership of user_team1" do - delete api("/user_teams/#{user_team1.id}/members/#{user1.id}", user1) - response.status.should == 403 - end - end - - context "when authenticated as admin" do - it "should delete user1's membership of user_team1" do - count_before=user_team1.user_team_user_relationships.count - delete api("/user_teams/#{user_team1.id}/members/#{user1.id}", admin) - response.status.should == 200 - user_team1.user_team_user_relationships.count.should == count_before - 1 - end - it "should return a 404 error when user id is not known" do - delete api("/user_teams/#{user_team2.id}/members/1328", admin) - response.status.should == 404 - end - end - end - - # Projects - - describe "GET /user_teams/:id/projects" do - context "when authenticated as user" do - it "should return project1 as assigned to user_team1 as member user1" do - get api("/user_teams/#{user_team1.id}/projects", user1) - response.status.should == 200 - json_response.first['name'].should == project1.name - json_response.length.should == user_team1.user_team_project_relationships.count - end - end - - context "when authenticated as admin" do - it "should return project2 as assigned to user_team2 as non-member, but admin" do - get api("/user_teams/#{user_team2.id}/projects", admin) - response.status.should == 200 - json_response.first['name'].should == project2.name - json_response.first['greatest_access_level'].should == UsersProject::MASTER - end - end - end - - describe "POST /user_teams/:id/projects" do - context "when authenticated as admin" do - it "should return ok and add new project" do - count_before=user_team1.user_team_project_relationships.count - post api("/user_teams/#{user_team1.id}/projects", admin), - project_id: project2.id, - greatest_access_level: UsersProject::MASTER - response.status.should == 201 - json_response['name'].should == project2.name - json_response['greatest_access_level'].should == UsersProject::MASTER - user_team1.user_team_project_relationships.count.should == count_before + 1 - end - it "should return ok if project already exists" do - post api("/user_teams/#{user_team2.id}/projects", admin), - project_id: project2.id, - greatest_access_level: UsersProject::MASTER - response.status.should == 409 - end - it "should return a 400 error when project id is not given" do - post api("/user_teams/#{user_team2.id}/projects", admin), greatest_access_level: UsersProject::MASTER - response.status.should == 400 - end - it "should return a 400 error when access level is not given" do - post api("/user_teams/#{user_team2.id}/projects", admin), project_id: project2.id - response.status.should == 400 - end - - it "should return a 422 error when access level is not known" do - post api("/user_teams/#{user_team2.id}/projects", admin), - project_id: project2.id, - greatest_access_level: 1234 - response.status.should == 422 - end - - end - end - - - describe "GET /user_teams/:id/projects/:project_id" do - context "when authenticated as member" do - it "should show project1's assignment to user_team1" do - get api("/user_teams/#{user_team1.id}/projects/#{project1.id}", user1) - response.status.should == 200 - json_response['name'].should == project1.name - json_response['greatest_access_level'].should == UsersProject::MASTER - end - it "should show project2's is not assigned to user_team1" do - get api("/user_teams/#{user_team1.id}/projects/#{project2.id}", user1) - response.status.should == 404 - end - end - - context "when authenticated as non-member" do - it "should not show project1's assignment to user_team1" do - get api("/user_teams/#{user_team1.id}/projects/#{project1.id}", user2) - response.status.should == 404 - end - end - - context "when authenticated as admin" do - it "should show project1's assignment to user_team1" do - get api("/user_teams/#{user_team1.id}/projects/#{project1.id}", admin) - response.status.should == 200 - json_response['name'].should == project1.name - json_response['greatest_access_level'].should == UsersProject::MASTER - end - it "should return a 404 error when project id is not known" do - get api("/user_teams/#{user_team2.id}/projects/1328", admin) - response.status.should == 404 - end - end - end - - describe "DELETE /user_teams/:id/projects/:project_id" do - context "when authenticated as user" do - it "should not delete project1's assignment to user_team2" do - delete api("/user_teams/#{user_team2.id}/projects/#{project1.id}", user1) - response.status.should == 403 - end - end - - context "when authenticated as admin" do - it "should delete project1's assignment to user_team1" do - count_before=user_team1.user_team_project_relationships.count - delete api("/user_teams/#{user_team1.id}/projects/#{project1.id}", admin) - response.status.should == 200 - user_team1.user_team_project_relationships.count.should == count_before - 1 - end - it "should return a 404 error when project id is not known" do - delete api("/user_teams/#{user_team2.id}/projects/1328", admin) - response.status.should == 404 - end - end - end - -end -- cgit v1.2.1 From 2a63f64f24d25865dec249021ea806da86d8bb9e Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 18 Jun 2013 21:44:04 +0300 Subject: Remove team factories and few links --- app/controllers/team_members_controller.rb | 1 - app/views/team_members/index.html.haml | 2 -- spec/factories/user_team_project_relationships.rb | 21 --------------------- spec/factories/user_team_user_relationships.rb | 23 ----------------------- spec/factories/user_teams.rb | 23 ----------------------- 5 files changed, 70 deletions(-) delete mode 100644 spec/factories/user_team_project_relationships.rb delete mode 100644 spec/factories/user_team_user_relationships.rb delete mode 100644 spec/factories/user_teams.rb diff --git a/app/controllers/team_members_controller.rb b/app/controllers/team_members_controller.rb index 095d7a3af55..0058c32462a 100644 --- a/app/controllers/team_members_controller.rb +++ b/app/controllers/team_members_controller.rb @@ -6,7 +6,6 @@ class TeamMembersController < ProjectResourceController def index @group = @project.group @users_projects = @project.users_projects.order('project_access DESC') - @assigned_teams = @project.user_team_project_relationships end def new diff --git a/app/views/team_members/index.html.haml b/app/views/team_members/index.html.haml index bae7215323c..781cb36a583 100644 --- a/app/views/team_members/index.html.haml +++ b/app/views/team_members/index.html.haml @@ -6,8 +6,6 @@ %span.pull-right = link_to import_project_team_members_path(@project), class: "btn btn-small grouped", title: "Import team from another project" do Import team from another project - = link_to available_project_teams_path(@project), class: "btn btn-small grouped", title: "Assign project to team of users" do - Assign project to Team of users = link_to new_project_team_member_path(@project), class: "btn btn-primary small grouped", title: "New Team Member" do New Team Member diff --git a/spec/factories/user_team_project_relationships.rb b/spec/factories/user_team_project_relationships.rb deleted file mode 100644 index e900d86c2e4..00000000000 --- a/spec/factories/user_team_project_relationships.rb +++ /dev/null @@ -1,21 +0,0 @@ -# == Schema Information -# -# Table name: user_team_project_relationships -# -# id :integer not null, primary key -# project_id :integer -# user_team_id :integer -# greatest_access :integer -# created_at :datetime not null -# updated_at :datetime not null -# - -# Read about factories at https://github.com/thoughtbot/factory_girl - -FactoryGirl.define do - factory :user_team_project_relationship do - project - user_team - greatest_access { UsersProject::MASTER } - end -end diff --git a/spec/factories/user_team_user_relationships.rb b/spec/factories/user_team_user_relationships.rb deleted file mode 100644 index 8c729dd8751..00000000000 --- a/spec/factories/user_team_user_relationships.rb +++ /dev/null @@ -1,23 +0,0 @@ -# == Schema Information -# -# Table name: user_team_user_relationships -# -# id :integer not null, primary key -# user_id :integer -# user_team_id :integer -# group_admin :boolean -# permission :integer -# created_at :datetime not null -# updated_at :datetime not null -# - -# Read about factories at https://github.com/thoughtbot/factory_girl - -FactoryGirl.define do - factory :user_team_user_relationship do - user - user_team - group_admin false - permission { UsersProject::MASTER } - end -end diff --git a/spec/factories/user_teams.rb b/spec/factories/user_teams.rb deleted file mode 100644 index 3aeea40a6c9..00000000000 --- a/spec/factories/user_teams.rb +++ /dev/null @@ -1,23 +0,0 @@ -# == Schema Information -# -# Table name: user_teams -# -# id :integer not null, primary key -# name :string(255) -# path :string(255) -# owner_id :integer -# created_at :datetime not null -# updated_at :datetime not null -# description :string(255) default(""), not null -# - -# Read about factories at https://github.com/thoughtbot/factory_girl - -FactoryGirl.define do - factory :user_team do - sequence(:name) { |n| "team#{n}" } - sequence(:description) { |n| "team_description#{n}" } - path { name.downcase.gsub(/\s/, '_') } - owner - end -end -- cgit v1.2.1 From e1882b535c3f4140b8b55d6f3a26525f84c5007b Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 18 Jun 2013 21:54:31 +0300 Subject: More userteam links removed. Removed teams spinach tests --- app/views/profiles/show.html.haml | 6 - app/views/projects/new.html.haml | 6 - features/admin/teams.feature | 70 ----------- features/steps/admin/admin_teams.rb | 236 ------------------------------------ 4 files changed, 318 deletions(-) delete mode 100644 features/admin/teams.feature delete mode 100644 features/steps/admin/admin_teams.rb diff --git a/app/views/profiles/show.html.haml b/app/views/profiles/show.html.haml index d4793da8987..7ca2546afdf 100644 --- a/app/views/profiles/show.html.haml +++ b/app/views/profiles/show.html.haml @@ -67,12 +67,6 @@ Need a group for several dependent projects? = link_to new_group_path, class: "btn btn-tiny" do Create a group - - if current_user.can_create_team? - %li - %p - Want to share a team between projects? - = link_to new_team_path, class: "btn btn-tiny" do - Create a team - unless current_user.projects_limit_left > 100 %fieldset %legend diff --git a/app/views/projects/new.html.haml b/app/views/projects/new.html.haml index 0754ee83114..ba389018d59 100644 --- a/app/views/projects/new.html.haml +++ b/app/views/projects/new.html.haml @@ -40,12 +40,6 @@ Need a group for several dependent projects? = link_to new_group_path, class: "btn btn-tiny" do Create a group - - if current_user.can_create_team? - .clearfix - .input.light - Want to share a project between team? - = link_to new_team_path, class: "btn btn-tiny" do - Create a team .save-project-loader.hide %center diff --git a/features/admin/teams.feature b/features/admin/teams.feature deleted file mode 100644 index 6a15fddcdcc..00000000000 --- a/features/admin/teams.feature +++ /dev/null @@ -1,70 +0,0 @@ -Feature: Admin Teams - Background: - Given I sign in as an admin - And Create gitlab user "John" - - Scenario: Create a team - When I visit admin teams page - And I click new team link - And submit form with new team info - Then I should be redirected to team page - And I should see newly created team - - Scenario: Add user to team - When I visit admin teams page - When I have clean "HardCoders" team - And I visit "HardCoders" team page - When I click to "Add members" link - When I select user "John" from user list as "Developer" - And submit form with new team member info - Then I should see "John" in teams members list as "Developer" - - Scenario: Assign team to existing project - When I visit admin teams page - When I have "HardCoders" team with "John" member with "Developer" role - When I have "Shop" project - And I visit "HardCoders" team page - Then I should see empty projects table - When I click to "Add projects" link - When I select project "Shop" with max access "Reporter" - And submit form with new team project info - Then I should see "Shop" project in projects list - When I visit "Shop" project admin page - Then I should see "John" user with role "Reporter" in team table - - Scenario: Add user to team with ptojects - When I visit admin teams page - When I have "HardCoders" team with "John" member with "Developer" role - And "HardCoders" team assigned to "Shop" project with "Developer" max role access - When I have gitlab user "Jimm" - And I visit "HardCoders" team page - Then I should see members table without "Jimm" member - When I click to "Add members" link - When I select user "Jimm" ub team members list as "Master" - And submit form with new team member info - Then I should see "Jimm" in teams members list as "Master" - - Scenario: Remove member from team - Given I have users team "HardCoders" - And gitlab user "John" is a member "HardCoders" team - And gitlab user "Jimm" is a member "HardCoders" team - And "HardCoders" team is assigned to "Shop" project - When I visit admin teams page - When I visit "HardCoders" team admin page - Then I shoould see "John" in members list - And I should see "Jimm" in members list - And I should see "Shop" in projects list - When I click on remove "Jimm" user link - Then I should be redirected to "HardCoders" team admin page - And I should not to see "Jimm" user in members list - - Scenario: Remove project from team - Given I have users team "HardCoders" - And gitlab user "John" is a member "HardCoders" team - And gitlab user "Jimm" is a member "HardCoders" team - And "HardCoders" team is assigned to "Shop" project - When I visit admin teams page - When I visit "HardCoders" team admin page - Then I should see "Shop" project in projects list - When I click on "Relegate" link on "Shop" project - Then I should see projects liston team page without "Shop" project diff --git a/features/steps/admin/admin_teams.rb b/features/steps/admin/admin_teams.rb deleted file mode 100644 index 066fc3fa603..00000000000 --- a/features/steps/admin/admin_teams.rb +++ /dev/null @@ -1,236 +0,0 @@ -class AdminTeams < Spinach::FeatureSteps - include SharedAuthentication - include SharedPaths - include SharedActiveTab - include SharedAdmin - - And 'I have own project' do - create :project - end - - And 'Create gitlab user "John"' do - @user = create(:user, name: "John") - end - - And 'I click new team link' do - click_link "New Team" - end - - And 'submit form with new team info' do - fill_in 'user_team_name', with: 'gitlab' - fill_in 'user_team_description', with: 'description' - click_button 'Create team' - end - - Then 'I should be redirected to team page' do - current_path.should == admin_team_path(UserTeam.last) - end - - And 'I should see newly created team' do - page.should have_content "Team: gitlab" - page.should have_content "description" - end - - When 'I visit admin teams page' do - visit admin_teams_path - end - - When 'I have clean "HardCoders" team' do - @team = create :user_team, name: "HardCoders", owner: current_user - end - - And 'I visit "HardCoders" team page' do - visit admin_team_path(UserTeam.find_by_name("HardCoders")) - end - - Then 'I should see only me in members table' do - members_list = find("#members_list .member") - members_list.should have_content(current_user.name) - members_list.should have_content(current_user.username) - end - - When 'I select user "John" from user list as "Developer"' do - @user ||= User.find_by_name("John") - within "#team_members" do - select "#{@user.name} (#{@user.username})", from: "user_ids" - select "Developer", from: "default_project_access" - end - end - - And 'submit form with new team member info' do - click_button 'add_members_to_team' - end - - Then 'I should see "John" in teams members list as "Developer"' do - @user ||= User.find_by_name("John") - find_in_list("#members_list .member", @user).must_equal true - end - - When 'I visit "John" user admin page' do - pending 'step not implemented' - end - - Then 'I should see "HardCoders" team in teams table' do - pending 'step not implemented' - end - - When 'I have "HardCoders" team with "John" member with "Developer" role' do - @team = create :user_team, name: "HardCoders", owner: current_user - @user ||= User.find_by_name("John") - @team.add_member(@user, UserTeam.access_roles["Developer"], group_admin: false) - end - - When 'I have "Shop" project' do - @project = create :project, name: "Shop" - end - - Then 'I should see empty projects table' do - page.should have_content "Projects (0)" - end - - When 'I select project "Shop" with max access "Reporter"' do - @project ||= Project.find_by_name("Shop") - within "#assign_projects" do - select @project.name, from: "project_ids" - select "Reporter", from: "greatest_project_access" - end - - end - - And 'submit form with new team project info' do - click_button 'assign_projects_to_team' - end - - Then 'I should see "Shop" project in projects list' do - project = Project.find_by_name("Shop") - find_in_list("#projects_list .project", project).must_equal true - end - - When 'I visit "Shop" project admin page' do - project = Project.find_by_name("Shop") - visit admin_project_path(project) - end - - And '"HardCoders" team assigned to "Shop" project with "Developer" max role access' do - @team = UserTeam.find_by_name("HardCoders") - @project = create :project, name: "Shop" - @team.assign_to_project(@project, UserTeam.access_roles["Developer"]) - end - - When 'I have gitlab user "Jimm"' do - create :user, name: "Jimm" - end - - Then 'I should see members table without "Jimm" member' do - user = User.find_by_name("Jimm") - find_in_list("#members_list .member", user).must_equal false - end - - When 'I select user "Jimm" ub team members list as "Master"' do - user = User.find_by_name("Jimm") - within "#team_members" do - select "#{user.name} (#{user.username})", from: "user_ids" - select "Developer", from: "default_project_access" - end - end - - Then 'I should see "Jimm" in teams members list as "Master"' do - user = User.find_by_name("Jimm") - find_in_list("#members_list .member", user).must_equal true - end - - Given 'I have users team "HardCoders"' do - @team = create :user_team, name: "HardCoders" - end - - And 'gitlab user "John" is a member "HardCoders" team' do - @team = UserTeam.find_by_name("HardCoders") - @user = User.find_by_name("John") - @user = create :user, name: "John" unless @user - @team.add_member(@user, UserTeam.access_roles["Master"], group_admin: false) - end - - And 'gitlab user "Jimm" is a member "HardCoders" team' do - @team = UserTeam.find_by_name("HardCoders") - @user = User.find_by_name("Jimm") - @user = create :user, name: "Jimm" unless @user - @team.add_member(@user, UserTeam.access_roles["Master"], group_admin: false) - end - - And '"HardCoders" team is assigned to "Shop" project' do - @team = UserTeam.find_by_name("HardCoders") - @project = create :project, name: "Shop" - @team.assign_to_project(@project, UserTeam.access_roles["Developer"]) - end - - When 'I visit "HardCoders" team admin page' do - visit admin_team_path(UserTeam.find_by_name("HardCoders")) - end - - Then 'I shoould see "John" in members list' do - user = User.find_by_name("John") - find_in_list("#members_list .member", user).must_equal true - end - - And 'I should see "Jimm" in members list' do - user = User.find_by_name("Jimm") - find_in_list("#members_list .member", user).must_equal true - end - - And 'I should see "Shop" in projects list' do - project = Project.find_by_name("Shop") - find_in_list("#projects_list .project", project).must_equal true - end - - When 'I click on remove "Jimm" user link' do - user = User.find_by_name("Jimm") - click_link "remove_member_#{user.id}" - end - - Then 'I should be redirected to "HardCoders" team admin page' do - current_path.should == admin_team_path(UserTeam.find_by_name("HardCoders")) - end - - And 'I should not to see "Jimm" user in members list' do - user = User.find_by_name("Jimm") - find_in_list("#members_list .member", user).must_equal false - end - - When 'I click on "Relegate" link on "Shop" project' do - project = Project.find_by_name("Shop") - click_link "relegate_project_#{project.id}" - end - - Then 'I should see projects liston team page without "Shop" project' do - project = Project.find_by_name("Shop") - find_in_list("#projects_list .project", project).must_equal false - end - - Then 'I should see "John" user with role "Reporter" in team table' do - user = User.find_by_name("John") - find_in_list(".team_members", user).must_equal true - end - - When 'I click to "Add members" link' do - click_link "Add members" - end - - When 'I click to "Add projects" link' do - click_link "Add projects" - end - - protected - - def current_team - @team ||= Team.first - end - - def find_in_list(selector, item) - members_list = all(selector) - entered = false - members_list.each do |member_item| - entered = true if member_item.has_content?(item.name) - end - entered - end -end -- cgit v1.2.1 From 1b3b90dbfd3219f571084321c751bd2263ad1836 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 18 Jun 2013 22:06:20 +0300 Subject: Remove teams specs --- spec/lib/gitlab/user_team_manager_spec.rb | 28 ---------------------------- spec/models/user_spec.rb | 17 ----------------- 2 files changed, 45 deletions(-) delete mode 100644 spec/lib/gitlab/user_team_manager_spec.rb diff --git a/spec/lib/gitlab/user_team_manager_spec.rb b/spec/lib/gitlab/user_team_manager_spec.rb deleted file mode 100644 index 2ee3587b367..00000000000 --- a/spec/lib/gitlab/user_team_manager_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'spec_helper' - -describe Gitlab::UserTeamManager do - before do - @user = create :user - @project = create :project, creator: @user - - @master = create :user - @developer = create :user - @reporter = create :user - - @project.team << [@master, :master] - @project.team << [@developer, :developer] - @project.team << [@reporter, :reporter] - - @team = create :user_team, owner: @user - - @team.add_members([@master.id, @developer.id, @reporter.id], UsersProject::DEVELOPER, false) - end - - it "should assign team to project with correct permissions result" do - @team.assign_to_project(@project, UsersProject::MASTER) - - @project.users_projects.find_by_user_id(@master).project_access.should == UsersProject::MASTER - @project.users_projects.find_by_user_id(@developer).project_access.should == UsersProject::DEVELOPER - @project.users_projects.find_by_user_id(@reporter).project_access.should == UsersProject::DEVELOPER - end -end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 4dd2048ccad..f0a6012d0c2 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -148,23 +148,6 @@ describe User do it { @user.owned_groups.should == [@group] } end - describe 'teams' do - before do - ActiveRecord::Base.observers.enable(:user_observer) - @admin = create :user, admin: true - @user1 = create :user - @user2 = create :user - @team = create :user_team, owner: @user1 - end - - it { @admin.authorized_teams.should == [@team] } - it { @user1.authorized_teams.should == [@team] } - it { @user2.authorized_teams.should be_empty } - it { @admin.should be_can(:manage_user_team, @team) } - it { @user1.should be_can(:manage_user_team, @team) } - it { @user2.should_not be_can(:manage_user_team, @team) } - end - describe 'namespaced' do before do ActiveRecord::Base.observers.enable(:user_observer) -- cgit v1.2.1 From 78680a81774d67997fa0abece4dc1d4a5ec12ce6 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 19 Jun 2013 13:52:25 +0300 Subject: Filter projects on dashboard --- app/assets/javascripts/dashboard.js.coffee | 15 +++++++++++++++ app/assets/stylesheets/sections/dashboard.scss | 10 ++++++++++ app/views/dashboard/_projects.html.haml | 10 ++++------ app/views/dashboard/_sidebar.html.haml | 8 ++++++-- 4 files changed, 35 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/dashboard.js.coffee b/app/assets/javascripts/dashboard.js.coffee index c2fb95ca635..57ede4ca598 100644 --- a/app/assets/javascripts/dashboard.js.coffee +++ b/app/assets/javascripts/dashboard.js.coffee @@ -8,6 +8,21 @@ class Dashboard @toggleFilter($(event.currentTarget)) @reloadActivities() + $(".dash-projects-filter").keyup -> + terms = $(this).val() + if terms == "" || terms == undefined + $(".dash-projects-list li").show() + else + $(".dash-projects-list li").each (index) -> + name = $(this).find(".well-title").text() + + if name.search(terms) == -1 + $(this).hide() + else + $(this).show() + + + reloadActivities: -> $(".content_list").html '' Pager.init 20, true diff --git a/app/assets/stylesheets/sections/dashboard.scss b/app/assets/stylesheets/sections/dashboard.scss index 9bc4a09a097..a0588563065 100644 --- a/app/assets/stylesheets/sections/dashboard.scss +++ b/app/assets/stylesheets/sections/dashboard.scss @@ -46,3 +46,13 @@ } } +.dashboard { + .dash-projects-filter { + margin: 0; + padding: 4px 6px; + width: 202px; + float: left; + margin-top: 3px; + margin-left: -2px; + } +} diff --git a/app/views/dashboard/_projects.html.haml b/app/views/dashboard/_projects.html.haml index a106e83e783..9d9d77b30d7 100644 --- a/app/views/dashboard/_projects.html.haml +++ b/app/views/dashboard/_projects.html.haml @@ -1,15 +1,13 @@ .ui-box - %h5.title - Projects - %span.light - (#{@projects_count}) + %h5.title.clearfix + = search_field_tag :filter_projects, nil, placeholder: 'Filter by name', class: 'dash-projects-filter' - if current_user.can_create_project? %span.pull-right - = link_to new_project_path, class: "btn btn-small" do + = link_to new_project_path, class: "btn" do %i.icon-plus New Project - %ul.well-list + %ul.well-list.dash-projects-list - projects.each do |project| %li = link_to project_path(project), class: dom_class(project) do diff --git a/app/views/dashboard/_sidebar.html.haml b/app/views/dashboard/_sidebar.html.haml index 7886b1e9be0..fed4b2776ae 100644 --- a/app/views/dashboard/_sidebar.html.haml +++ b/app/views/dashboard/_sidebar.html.haml @@ -1,8 +1,12 @@ %ul.nav.nav-tabs.dash-sidebar-tabs %li.active - = link_to 'Projects', '#projects', 'data-toggle' => 'tab', id: 'sidebar-projects-tab' + = link_to '#projects', 'data-toggle' => 'tab', id: 'sidebar-projects-tab' do + Projects + %span.badge= @projects_count %li - = link_to 'Groups', '#groups', 'data-toggle' => 'tab', id: 'sidebar-groups-tab' + = link_to '#groups', 'data-toggle' => 'tab', id: 'sidebar-groups-tab' do + Groups + %span.badge= @groups.count .tab-content .tab-pane.active#projects -- cgit v1.2.1 From 6e35aceff29ddeae6282de31e81e48446ab927fa Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 19 Jun 2013 15:40:33 +0300 Subject: Annotated --- app/models/campfire_service.rb | 2 ++ app/models/deploy_key.rb | 14 ++++++++++++++ app/models/deploy_keys_project.rb | 11 +++++++++++ app/models/forked_project_link.rb | 11 +++++++++++ app/models/gitlab_ci_service.rb | 2 ++ app/models/hipchat_service.rb | 4 +++- app/models/issue.rb | 4 ++-- app/models/key.rb | 6 +++--- app/models/merge_request.rb | 4 ++-- app/models/note.rb | 4 ++-- app/models/personal_snippet.rb | 9 +++++---- app/models/project.rb | 5 +++-- app/models/project_hook.rb | 4 ++-- app/models/project_snippet.rb | 9 +++++---- app/models/service.rb | 2 ++ app/models/service_hook.rb | 4 ++-- app/models/snippet.rb | 9 +++++---- app/models/system_hook.rb | 4 ++-- app/models/user.rb | 8 +++++--- app/models/users_group.rb | 12 ++++++++++++ app/models/users_project.rb | 4 ++-- app/models/web_hook.rb | 4 ++-- spec/factories/forked_project_links.rb | 11 +++++++++++ spec/factories/users_groups.rb | 12 ++++++++++++ spec/models/deploy_key_spec.rb | 6 +++--- spec/models/deploy_keys_project_spec.rb | 11 +++++++++++ spec/models/forked_project_link_spec.rb | 11 +++++++++++ spec/models/gitlab_ci_service_spec.rb | 2 ++ spec/models/issue_spec.rb | 4 ++-- spec/models/key_spec.rb | 6 +++--- spec/models/merge_request_spec.rb | 4 ++-- spec/models/note_spec.rb | 4 ++-- spec/models/project_snippet_spec.rb | 8 +++++--- spec/models/project_spec.rb | 5 +++-- spec/models/service_hook_spec.rb | 4 ++-- spec/models/service_spec.rb | 2 ++ spec/models/snippet_spec.rb | 8 +++++--- spec/models/system_hook_spec.rb | 4 ++-- spec/models/user_spec.rb | 8 +++++--- spec/models/users_group_spec.rb | 12 ++++++++++++ spec/models/users_project_spec.rb | 4 ++-- spec/models/web_hook_spec.rb | 4 ++-- 42 files changed, 198 insertions(+), 68 deletions(-) diff --git a/app/models/campfire_service.rb b/app/models/campfire_service.rb index 6450ffe7318..fb2a49fd586 100644 --- a/app/models/campfire_service.rb +++ b/app/models/campfire_service.rb @@ -11,6 +11,8 @@ # updated_at :datetime not null # active :boolean default(FALSE), not null # project_url :string(255) +# subdomain :string(255) +# room :string(255) # class CampfireService < Service diff --git a/app/models/deploy_key.rb b/app/models/deploy_key.rb index 548ef4f9a27..f983198085c 100644 --- a/app/models/deploy_key.rb +++ b/app/models/deploy_key.rb @@ -1,3 +1,17 @@ +# == Schema Information +# +# Table name: keys +# +# id :integer not null, primary key +# user_id :integer +# created_at :datetime +# updated_at :datetime +# key :text +# title :string(255) +# identifier :string(255) +# type :string(255) +# + class DeployKey < Key has_many :deploy_keys_projects, dependent: :destroy has_many :projects, through: :deploy_keys_projects diff --git a/app/models/deploy_keys_project.rb b/app/models/deploy_keys_project.rb index 48350a3e4d9..6f109e48314 100644 --- a/app/models/deploy_keys_project.rb +++ b/app/models/deploy_keys_project.rb @@ -1,3 +1,14 @@ +# == Schema Information +# +# Table name: deploy_keys_projects +# +# id :integer not null, primary key +# deploy_key_id :integer not null +# project_id :integer not null +# created_at :datetime not null +# updated_at :datetime not null +# + class DeployKeysProject < ActiveRecord::Base attr_accessible :key_id, :project_id diff --git a/app/models/forked_project_link.rb b/app/models/forked_project_link.rb index c3199ca264e..aaa527a1145 100644 --- a/app/models/forked_project_link.rb +++ b/app/models/forked_project_link.rb @@ -1,3 +1,14 @@ +# == Schema Information +# +# Table name: forked_project_links +# +# id :integer not null, primary key +# forked_to_project_id :integer not null +# forked_from_project_id :integer not null +# created_at :datetime not null +# updated_at :datetime not null +# + class ForkedProjectLink < ActiveRecord::Base attr_accessible :forked_from_project_id, :forked_to_project_id diff --git a/app/models/gitlab_ci_service.rb b/app/models/gitlab_ci_service.rb index bdbe7724be0..7f5380a4551 100644 --- a/app/models/gitlab_ci_service.rb +++ b/app/models/gitlab_ci_service.rb @@ -11,6 +11,8 @@ # updated_at :datetime not null # active :boolean default(FALSE), not null # project_url :string(255) +# subdomain :string(255) +# room :string(255) # class GitlabCiService < Service diff --git a/app/models/hipchat_service.rb b/app/models/hipchat_service.rb index 13429fa83b4..c3fb4826334 100644 --- a/app/models/hipchat_service.rb +++ b/app/models/hipchat_service.rb @@ -11,6 +11,8 @@ # updated_at :datetime not null # active :boolean default(FALSE), not null # project_url :string(255) +# subdomain :string(255) +# room :string(255) # class HipchatService < Service @@ -70,4 +72,4 @@ class HipchatService < Service message end -end \ No newline at end of file +end diff --git a/app/models/issue.rb b/app/models/issue.rb index de6e015c68e..f56928891dc 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -7,8 +7,8 @@ # assignee_id :integer # author_id :integer # project_id :integer -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # position :integer default(0) # branch_name :string(255) # description :text diff --git a/app/models/key.rb b/app/models/key.rb index 185aef46e9e..a87ea4943e9 100644 --- a/app/models/key.rb +++ b/app/models/key.rb @@ -4,12 +4,12 @@ # # id :integer not null, primary key # user_id :integer -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # key :text # title :string(255) # identifier :string(255) -# project_id :integer +# type :string(255) # require 'digest/md5' diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index f41473336bc..c45af9f713e 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -9,8 +9,8 @@ # author_id :integer # assignee_id :integer # title :string(255) -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # st_commits :text(2147483647) # st_diffs :text(2147483647) # milestone_id :integer diff --git a/app/models/note.rb b/app/models/note.rb index 9a3481faaaa..c2e664d1bcd 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -6,8 +6,8 @@ # note :text # noteable_type :string(255) # author_id :integer -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # project_id :integer # attachment :string(255) # line_code :string(255) diff --git a/app/models/personal_snippet.rb b/app/models/personal_snippet.rb index d581c6092aa..a3c0d201ee5 100644 --- a/app/models/personal_snippet.rb +++ b/app/models/personal_snippet.rb @@ -6,13 +6,14 @@ # title :string(255) # content :text # author_id :integer not null -# project_id :integer not null -# created_at :datetime not null -# updated_at :datetime not null +# project_id :integer +# created_at :datetime +# updated_at :datetime # file_name :string(255) # expires_at :datetime +# private :boolean default(TRUE), not null # type :string(255) -# private :boolean +# class PersonalSnippet < Snippet end diff --git a/app/models/project.rb b/app/models/project.rb index 234d5e98b4f..ff61eca60de 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -6,8 +6,8 @@ # name :string(255) # path :string(255) # description :text -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # creator_id :integer # default_branch :string(255) # issues_enabled :boolean default(TRUE), not null @@ -20,6 +20,7 @@ # issues_tracker_id :string(255) # snippets_enabled :boolean default(TRUE), not null # last_activity_at :datetime +# imported :boolean default(FALSE), not null # require "grit" diff --git a/app/models/project_hook.rb b/app/models/project_hook.rb index 2576fc979d4..b82e1ffd4ab 100644 --- a/app/models/project_hook.rb +++ b/app/models/project_hook.rb @@ -5,8 +5,8 @@ # id :integer not null, primary key # url :string(255) # project_id :integer -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # type :string(255) default("ProjectHook") # service_id :integer # diff --git a/app/models/project_snippet.rb b/app/models/project_snippet.rb index a86f2e7a32f..14c88046423 100644 --- a/app/models/project_snippet.rb +++ b/app/models/project_snippet.rb @@ -6,13 +6,14 @@ # title :string(255) # content :text # author_id :integer not null -# project_id :integer not null -# created_at :datetime not null -# updated_at :datetime not null +# project_id :integer +# created_at :datetime +# updated_at :datetime # file_name :string(255) # expires_at :datetime +# private :boolean default(TRUE), not null # type :string(255) -# private :boolean +# class ProjectSnippet < Snippet belongs_to :project diff --git a/app/models/service.rb b/app/models/service.rb index 3e945aa898c..d21e8a2c567 100644 --- a/app/models/service.rb +++ b/app/models/service.rb @@ -11,6 +11,8 @@ # updated_at :datetime not null # active :boolean default(FALSE), not null # project_url :string(255) +# subdomain :string(255) +# room :string(255) # # To add new service you should build a class inherited from Service diff --git a/app/models/service_hook.rb b/app/models/service_hook.rb index 4cd2b272eec..433e8059788 100644 --- a/app/models/service_hook.rb +++ b/app/models/service_hook.rb @@ -5,8 +5,8 @@ # id :integer not null, primary key # url :string(255) # project_id :integer -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # type :string(255) default("ProjectHook") # service_id :integer # diff --git a/app/models/snippet.rb b/app/models/snippet.rb index 1b37ffe8339..3a2fc17e59c 100644 --- a/app/models/snippet.rb +++ b/app/models/snippet.rb @@ -6,13 +6,14 @@ # title :string(255) # content :text # author_id :integer not null -# project_id :integer not null -# created_at :datetime not null -# updated_at :datetime not null +# project_id :integer +# created_at :datetime +# updated_at :datetime # file_name :string(255) # expires_at :datetime +# private :boolean default(TRUE), not null # type :string(255) -# private :boolean +# class Snippet < ActiveRecord::Base include Linguist::BlobHelper diff --git a/app/models/system_hook.rb b/app/models/system_hook.rb index 5cdf046644f..2d28f4cd452 100644 --- a/app/models/system_hook.rb +++ b/app/models/system_hook.rb @@ -5,8 +5,8 @@ # id :integer not null, primary key # url :string(255) # project_id :integer -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # type :string(255) default("ProjectHook") # service_id :integer # diff --git a/app/models/user.rb b/app/models/user.rb index d8c9ac647b5..6a5411b222d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -4,7 +4,7 @@ # # id :integer not null, primary key # email :string(255) default(""), not null -# encrypted_password :string(255) default(""), not null +# encrypted_password :string(128) default(""), not null # reset_password_token :string(255) # reset_password_sent_at :datetime # remember_created_at :datetime @@ -13,8 +13,8 @@ # last_sign_in_at :datetime # current_sign_in_ip :string(255) # last_sign_in_ip :string(255) -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # name :string(255) # admin :boolean default(FALSE), not null # projects_limit :integer default(10) @@ -34,6 +34,8 @@ # state :string(255) # color_scheme_id :integer default(1), not null # notification_level :integer default(1), not null +# password_expires_at :datetime +# created_by_id :integer # class User < ActiveRecord::Base diff --git a/app/models/users_group.rb b/app/models/users_group.rb index 0cb26854f9c..d70f56f681f 100644 --- a/app/models/users_group.rb +++ b/app/models/users_group.rb @@ -1,3 +1,15 @@ +# == Schema Information +# +# Table name: users_groups +# +# id :integer not null, primary key +# group_access :integer not null +# group_id :integer not null +# user_id :integer not null +# created_at :datetime not null +# updated_at :datetime not null +# + class UsersGroup < ActiveRecord::Base GUEST = 10 REPORTER = 20 diff --git a/app/models/users_project.rb b/app/models/users_project.rb index 4c58b009380..58d05fbe077 100644 --- a/app/models/users_project.rb +++ b/app/models/users_project.rb @@ -5,8 +5,8 @@ # id :integer not null, primary key # user_id :integer not null # project_id :integer not null -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # project_access :integer default(0), not null # notification_level :integer default(3), not null # diff --git a/app/models/web_hook.rb b/app/models/web_hook.rb index 3f22b1082fb..1e6ea885ea9 100644 --- a/app/models/web_hook.rb +++ b/app/models/web_hook.rb @@ -5,8 +5,8 @@ # id :integer not null, primary key # url :string(255) # project_id :integer -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # type :string(255) default("ProjectHook") # service_id :integer # diff --git a/spec/factories/forked_project_links.rb b/spec/factories/forked_project_links.rb index 64bcdf09429..2f9b91acf2c 100644 --- a/spec/factories/forked_project_links.rb +++ b/spec/factories/forked_project_links.rb @@ -1,3 +1,14 @@ +# == Schema Information +# +# Table name: forked_project_links +# +# id :integer not null, primary key +# forked_to_project_id :integer not null +# forked_from_project_id :integer not null +# created_at :datetime not null +# updated_at :datetime not null +# + # Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do diff --git a/spec/factories/users_groups.rb b/spec/factories/users_groups.rb index cb272e35c92..654bb2caee8 100644 --- a/spec/factories/users_groups.rb +++ b/spec/factories/users_groups.rb @@ -1,3 +1,15 @@ +# == Schema Information +# +# Table name: users_groups +# +# id :integer not null, primary key +# group_access :integer not null +# group_id :integer not null +# user_id :integer not null +# created_at :datetime not null +# updated_at :datetime not null +# + FactoryGirl.define do factory :users_group do group_access { UsersGroup::OWNER } diff --git a/spec/models/deploy_key_spec.rb b/spec/models/deploy_key_spec.rb index 3658a6ff1d0..ec1f5d2c4e2 100644 --- a/spec/models/deploy_key_spec.rb +++ b/spec/models/deploy_key_spec.rb @@ -4,12 +4,12 @@ # # id :integer not null, primary key # user_id :integer -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # key :text # title :string(255) # identifier :string(255) -# project_id :integer +# type :string(255) # require 'spec_helper' diff --git a/spec/models/deploy_keys_project_spec.rb b/spec/models/deploy_keys_project_spec.rb index bb62c48bbcc..aeec1713558 100644 --- a/spec/models/deploy_keys_project_spec.rb +++ b/spec/models/deploy_keys_project_spec.rb @@ -1,3 +1,14 @@ +# == Schema Information +# +# Table name: deploy_keys_projects +# +# id :integer not null, primary key +# deploy_key_id :integer not null +# project_id :integer not null +# created_at :datetime not null +# updated_at :datetime not null +# + require 'spec_helper' describe DeployKeysProject do diff --git a/spec/models/forked_project_link_spec.rb b/spec/models/forked_project_link_spec.rb index c362b21f088..5f25e2abd23 100644 --- a/spec/models/forked_project_link_spec.rb +++ b/spec/models/forked_project_link_spec.rb @@ -1,3 +1,14 @@ +# == Schema Information +# +# Table name: forked_project_links +# +# id :integer not null, primary key +# forked_to_project_id :integer not null +# forked_from_project_id :integer not null +# created_at :datetime not null +# updated_at :datetime not null +# + require 'spec_helper' describe ForkedProjectLink, "add link on fork" do diff --git a/spec/models/gitlab_ci_service_spec.rb b/spec/models/gitlab_ci_service_spec.rb index b86588af1ac..56efa9df457 100644 --- a/spec/models/gitlab_ci_service_spec.rb +++ b/spec/models/gitlab_ci_service_spec.rb @@ -11,6 +11,8 @@ # updated_at :datetime not null # active :boolean default(FALSE), not null # project_url :string(255) +# subdomain :string(255) +# room :string(255) # require 'spec_helper' diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb index 1bc794dcd77..ed0a725add6 100644 --- a/spec/models/issue_spec.rb +++ b/spec/models/issue_spec.rb @@ -7,8 +7,8 @@ # assignee_id :integer # author_id :integer # project_id :integer -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # position :integer default(0) # branch_name :string(255) # description :text diff --git a/spec/models/key_spec.rb b/spec/models/key_spec.rb index 9ccad18248c..6c06f5268b3 100644 --- a/spec/models/key_spec.rb +++ b/spec/models/key_spec.rb @@ -4,12 +4,12 @@ # # id :integer not null, primary key # user_id :integer -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # key :text # title :string(255) # identifier :string(255) -# project_id :integer +# type :string(255) # require 'spec_helper' diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index a4660806cca..a0a43fbb815 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -9,8 +9,8 @@ # author_id :integer # assignee_id :integer # title :string(255) -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # st_commits :text(2147483647) # st_diffs :text(2147483647) # milestone_id :integer diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb index 52e24a78eb4..ba94f940dc8 100644 --- a/spec/models/note_spec.rb +++ b/spec/models/note_spec.rb @@ -6,8 +6,8 @@ # note :text # noteable_type :string(255) # author_id :integer -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # project_id :integer # attachment :string(255) # line_code :string(255) diff --git a/spec/models/project_snippet_spec.rb b/spec/models/project_snippet_spec.rb index 716fd81c91b..42147179387 100644 --- a/spec/models/project_snippet_spec.rb +++ b/spec/models/project_snippet_spec.rb @@ -6,11 +6,13 @@ # title :string(255) # content :text # author_id :integer not null -# project_id :integer not null -# created_at :datetime not null -# updated_at :datetime not null +# project_id :integer +# created_at :datetime +# updated_at :datetime # file_name :string(255) # expires_at :datetime +# private :boolean default(TRUE), not null +# type :string(255) # require 'spec_helper' diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 2e3870b1b65..0845d2edea3 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -6,8 +6,8 @@ # name :string(255) # path :string(255) # description :text -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # creator_id :integer # default_branch :string(255) # issues_enabled :boolean default(TRUE), not null @@ -20,6 +20,7 @@ # issues_tracker_id :string(255) # snippets_enabled :boolean default(TRUE), not null # last_activity_at :datetime +# imported :boolean default(FALSE), not null # require 'spec_helper' diff --git a/spec/models/service_hook_spec.rb b/spec/models/service_hook_spec.rb index 0b0262c97f1..e5ba59c0d65 100644 --- a/spec/models/service_hook_spec.rb +++ b/spec/models/service_hook_spec.rb @@ -5,8 +5,8 @@ # id :integer not null, primary key # url :string(255) # project_id :integer -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # type :string(255) default("ProjectHook") # service_id :integer # diff --git a/spec/models/service_spec.rb b/spec/models/service_spec.rb index 1a58f680baf..55ef1914730 100644 --- a/spec/models/service_spec.rb +++ b/spec/models/service_spec.rb @@ -11,6 +11,8 @@ # updated_at :datetime not null # active :boolean default(FALSE), not null # project_url :string(255) +# subdomain :string(255) +# room :string(255) # require 'spec_helper' diff --git a/spec/models/snippet_spec.rb b/spec/models/snippet_spec.rb index 52355c38f0c..a77c594aaf1 100644 --- a/spec/models/snippet_spec.rb +++ b/spec/models/snippet_spec.rb @@ -6,11 +6,13 @@ # title :string(255) # content :text # author_id :integer not null -# project_id :integer not null -# created_at :datetime not null -# updated_at :datetime not null +# project_id :integer +# created_at :datetime +# updated_at :datetime # file_name :string(255) # expires_at :datetime +# private :boolean default(TRUE), not null +# type :string(255) # require 'spec_helper' diff --git a/spec/models/system_hook_spec.rb b/spec/models/system_hook_spec.rb index a9ed6a5fa7c..7f11f9ec247 100644 --- a/spec/models/system_hook_spec.rb +++ b/spec/models/system_hook_spec.rb @@ -5,8 +5,8 @@ # id :integer not null, primary key # url :string(255) # project_id :integer -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # type :string(255) default("ProjectHook") # service_id :integer # diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index f0a6012d0c2..4c37a48c4d1 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -4,7 +4,7 @@ # # id :integer not null, primary key # email :string(255) default(""), not null -# encrypted_password :string(255) default(""), not null +# encrypted_password :string(128) default(""), not null # reset_password_token :string(255) # reset_password_sent_at :datetime # remember_created_at :datetime @@ -13,8 +13,8 @@ # last_sign_in_at :datetime # current_sign_in_ip :string(255) # last_sign_in_ip :string(255) -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # name :string(255) # admin :boolean default(FALSE), not null # projects_limit :integer default(10) @@ -34,6 +34,8 @@ # state :string(255) # color_scheme_id :integer default(1), not null # notification_level :integer default(1), not null +# password_expires_at :datetime +# created_by_id :integer # require 'spec_helper' diff --git a/spec/models/users_group_spec.rb b/spec/models/users_group_spec.rb index c802b8213d5..4da31a55fcb 100644 --- a/spec/models/users_group_spec.rb +++ b/spec/models/users_group_spec.rb @@ -1,3 +1,15 @@ +# == Schema Information +# +# Table name: users_groups +# +# id :integer not null, primary key +# group_access :integer not null +# group_id :integer not null +# user_id :integer not null +# created_at :datetime not null +# updated_at :datetime not null +# + require 'spec_helper' describe UsersGroup do diff --git a/spec/models/users_project_spec.rb b/spec/models/users_project_spec.rb index e289a592b03..aa4b8cb449b 100644 --- a/spec/models/users_project_spec.rb +++ b/spec/models/users_project_spec.rb @@ -5,8 +5,8 @@ # id :integer not null, primary key # user_id :integer not null # project_id :integer not null -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # project_access :integer default(0), not null # notification_level :integer default(3), not null # diff --git a/spec/models/web_hook_spec.rb b/spec/models/web_hook_spec.rb index 2d9301732dd..4f88ed849e0 100644 --- a/spec/models/web_hook_spec.rb +++ b/spec/models/web_hook_spec.rb @@ -5,8 +5,8 @@ # id :integer not null, primary key # url :string(255) # project_id :integer -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # type :string(255) default("ProjectHook") # service_id :integer # -- cgit v1.2.1 From 63a67bb4abff7690ef5f1c91b924c6aaf7f90985 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 19 Jun 2013 17:48:43 +0300 Subject: Remove second search. More compact list. Additional filter --- app/controllers/dashboard_controller.rb | 14 +++--- app/views/dashboard/projects.html.haml | 87 ++++++++++++--------------------- 2 files changed, 38 insertions(+), 63 deletions(-) diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index fc7dc3fab63..4b9bfcf843b 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -1,7 +1,7 @@ class DashboardController < ApplicationController respond_to :html - before_filter :load_projects + before_filter :load_projects, except: [:projects] before_filter :event_filter, only: :show def show @@ -26,16 +26,18 @@ class DashboardController < ApplicationController def projects @projects = case params[:scope] when 'personal' then - @projects.personal(current_user) + current_user.namespace.projects when 'joined' then - @projects.joined(current_user) + current_user.authorized_projects.joined(current_user) + when 'owned' then + current_user.owned_projects else - @projects - end + current_user.authorized_projects + end.sorted_by_activity @projects = @projects.search(params[:search]) if params[:search].present? - @labels = Project.where(id: @projects.map(&:id)).tags_on(:labels) + @labels = current_user.authorized_projects.tags_on(:labels) @projects = @projects.tagged_with(params[:label]) if params[:label].present? @projects = @projects.page(params[:page]).per(30) diff --git a/app/views/dashboard/projects.html.haml b/app/views/dashboard/projects.html.haml index 9b16db340b2..683052eadaa 100644 --- a/app/views/dashboard/projects.html.haml +++ b/app/views/dashboard/projects.html.haml @@ -1,15 +1,3 @@ -%h3.page_title - Projects - %span - (#{@projects.total_count}) - - if current_user.can_create_project? - %span.pull-right - = link_to new_project_path, class: "btn btn-tiny info" do - %i.icon-plus - New Project - - -%hr .row .span3 %ul.nav.nav-pills.nav-stacked @@ -19,58 +7,43 @@ = link_to "Personal", projects_dashboard_path(scope: 'personal') = nav_tab :scope, 'joined' do = link_to "Joined", projects_dashboard_path(scope: 'joined') + = nav_tab :scope, 'owned' do + = link_to "Owned", projects_dashboard_path(scope: 'owned') - %p.light Filter by label: - %ul.bordered-list - - @labels.each do |label| - %li{ class: (label.name == params[:label]) ? 'active' : 'light' } - = link_to projects_dashboard_path(scope: params[:scope], label: label.name) do - %i.icon-tag - = label.name + - if @labels.present? + %p.light Filter by label: + %ul.bordered-list + - @labels.each do |label| + %li{ class: (label.name == params[:label]) ? 'active' : 'light' } + = link_to projects_dashboard_path(scope: params[:scope], label: label.name) do + %i.icon-tag + = label.name .span9 - = form_tag projects_dashboard_path, method: 'get' do - %fieldset.dashboard-search-filter - = hidden_field_tag "scope", params[:scope] - = search_field_tag "search", params[:search], { id: 'dashboard_projects_search', placeholder: 'Search', class: 'left input-xxlarge'} - = button_tag type: 'submit', class: 'btn' do - %i.icon-search - - %ul.bordered-list - - @projects.each do |project| - %li.clearfix - .clearfix - %h5 - = link_to project_path(project), class: dom_class(project) do - - if project.namespace - = project.namespace.human_name - %span= "/" - %strong - = truncate(project.name, length: 45) - .pull-right.light - - if project.owner == current_user - %i.icon-wrench - - tm = project.team.get_tm(current_user.id) - - if tm - %strong= tm.project_access_human - .clearfix - .left - - if project.description.present? - %span.light= project.description - - project.labels.each do |label| - %span.label.label-info - %i.icon-tag - = label.name + .ui-box + %h5.title + Projects (#{@projects.total_count}) + %ul.well-list + - @projects.each do |project| + %li + - if project.public + = public_icon + - else + = private_icon + = link_to project_path(project), class: dom_class(project) do + %strong + = project.name_with_namespace + - if project.description.present? + %span.light + = truncate project.description, length: 80 .pull-right.light - %small.light - Last activity #{project_last_activity(project)} + %small Last activity #{project_last_activity(project)} - - if @projects.blank? - %li - %h3.nothing_here_message There are no projects here. + - if @projects.blank? + %li + %h3.nothing_here_message There are no projects here. .bottom - %hr = paginate @projects, theme: "gitlab" -- cgit v1.2.1 From a3b42b6fa13991440aeb75264f865329cff719a3 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 19 Jun 2013 18:24:18 +0300 Subject: Remove dash projects search test --- features/dashboard/projects.feature | 4 ---- features/steps/dashboard/dashboard_projects.rb | 12 ------------ 2 files changed, 16 deletions(-) diff --git a/features/dashboard/projects.feature b/features/dashboard/projects.feature index 7e617bd1bfc..7d8c129face 100644 --- a/features/dashboard/projects.feature +++ b/features/dashboard/projects.feature @@ -6,7 +6,3 @@ Feature: Dashboard projects Scenario: I should see projects list Then I should see projects list - - Scenario: I should see project I am looking for - Given I search for "Sho" - Then I should see "Shop" project link diff --git a/features/steps/dashboard/dashboard_projects.rb b/features/steps/dashboard/dashboard_projects.rb index 670e25a97a4..85251565446 100644 --- a/features/steps/dashboard/dashboard_projects.rb +++ b/features/steps/dashboard/dashboard_projects.rb @@ -8,16 +8,4 @@ class DashboardProjects < Spinach::FeatureSteps page.should have_link project.name_with_namespace end end - - Given 'I search for "Sho"' do - fill_in "dashboard_projects_search", with: "Sho" - - within ".dashboard-search-filter" do - find('button').click - end - end - - Then 'I should see "Shop" project link' do - page.should have_link "Shop" - end end -- cgit v1.2.1 From cf8b465cb96f5aa6e53fec60c0d6e62ad1ccbc5e Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 19 Jun 2013 18:32:08 +0300 Subject: Remove Global namespace from options. Prepared file for migration of global projects --- app/contexts/projects/create_context.rb | 10 +++------- app/contexts/projects/transfer_context.rb | 7 +------ app/controllers/admin/projects_controller.rb | 1 - app/helpers/namespaces_helper.rb | 1 - app/views/projects/edit.html.haml | 2 +- lib/tasks/migrate/migrate_global_projects.rake | 12 ++++++++++++ 6 files changed, 17 insertions(+), 16 deletions(-) create mode 100644 lib/tasks/migrate/migrate_global_projects.rake diff --git a/app/contexts/projects/create_context.rb b/app/contexts/projects/create_context.rb index d3b8dee3948..4045fe15a1d 100644 --- a/app/contexts/projects/create_context.rb +++ b/app/contexts/projects/create_context.rb @@ -33,7 +33,7 @@ module Projects # Find matching namespace and check if it allowed # for current user if namespace_id passed. if allowed_namespace?(current_user, namespace_id) - @project.namespace_id = namespace_id unless namespace_id == Namespace.global_id + @project.namespace_id = namespace_id else deny_namespace return @project @@ -75,12 +75,8 @@ module Projects end def allowed_namespace?(user, namespace_id) - if namespace_id == Namespace.global_id - return user.admin - else - namespace = Namespace.find_by_id(namespace_id) - current_user.can?(:manage_namespace, namespace) - end + namespace = Namespace.find_by_id(namespace_id) + current_user.can?(:manage_namespace, namespace) end end end diff --git a/app/contexts/projects/transfer_context.rb b/app/contexts/projects/transfer_context.rb index aed396a5da5..3011984e3f8 100644 --- a/app/contexts/projects/transfer_context.rb +++ b/app/contexts/projects/transfer_context.rb @@ -5,12 +5,7 @@ module Projects allowed_transfer = can?(current_user, :change_namespace, project) || role == :admin if allowed_transfer && namespace_id.present? - if namespace_id == Namespace.global_id - if project.namespace.present? - # Transfer to global namespace from anyone - project.transfer(nil) - end - elsif namespace_id.to_i != project.namespace_id + if namespace_id.to_i != project.namespace_id # Transfer to someone namespace namespace = Namespace.find(namespace_id) project.transfer(namespace) diff --git a/app/controllers/admin/projects_controller.rb b/app/controllers/admin/projects_controller.rb index a63c4694a81..e73a54dd1a5 100644 --- a/app/controllers/admin/projects_controller.rb +++ b/app/controllers/admin/projects_controller.rb @@ -9,7 +9,6 @@ class Admin::ProjectsController < Admin::ApplicationController @projects = @projects.where(public: true) if params[:public_only].present? @projects = @projects.with_push if params[:with_push].present? @projects = @projects.abandoned if params[:abandoned].present? - @projects = @projects.where(namespace_id: nil) if params[:namespace_id] == Namespace.global_id @projects = @projects.search(params[:name]) if params[:name].present? @projects = @projects.includes(:namespace).order("namespaces.path, projects.name ASC").page(params[:page]).per(20) end diff --git a/app/helpers/namespaces_helper.rb b/app/helpers/namespaces_helper.rb index 69ad3de5031..a6fcf8d8cf2 100644 --- a/app/helpers/namespaces_helper.rb +++ b/app/helpers/namespaces_helper.rb @@ -3,7 +3,6 @@ module NamespacesHelper groups = current_user.owned_groups.select {|n| n.type == 'Group'} users = current_user.namespaces.reject {|n| n.type == 'Group'} - global_opts = ["Global", [['/', Namespace.global_id]] ] group_opts = ["Groups", groups.sort_by(&:human_name).map {|g| [g.human_name, g.id]} ] users_opts = [ "Users", users.sort_by(&:human_name).map {|u| [u.human_name, u.id]} ] diff --git a/app/views/projects/edit.html.haml b/app/views/projects/edit.html.haml index bec64bf6c58..43199bc3dd9 100644 --- a/app/views/projects/edit.html.haml +++ b/app/views/projects/edit.html.haml @@ -129,7 +129,7 @@ %span Namespace .controls .clearfix - = f.select :namespace_id, namespaces_options(@project.namespace_id || Namespace::global_id), {prompt: 'Choose a project namespace'}, {class: 'chosen'} + = f.select :namespace_id, namespaces_options(@project.namespace_id), {prompt: 'Choose a project namespace'}, {class: 'chosen'} %ul %li Be careful. Changing project namespace can have unintended side effects %li You can transfer project only to namespaces you can manage diff --git a/lib/tasks/migrate/migrate_global_projects.rake b/lib/tasks/migrate/migrate_global_projects.rake new file mode 100644 index 00000000000..f2f74723c3b --- /dev/null +++ b/lib/tasks/migrate/migrate_global_projects.rake @@ -0,0 +1,12 @@ +desc "GITLAB | Migrate Global Projects to Namespaces" +task migrate_global_projects: :environment do + puts "This will move all projects without namespace to owner namespace" + ask_to_continue + + Project.where(namespace_id: nil).find_each(batch_size: 20) do |project| + + # TODO: transfer code here + print '.' + end +end + -- cgit v1.2.1 From d274ca3888b1d099fc80ba135754df81243cee6e Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 19 Jun 2013 19:38:43 +0300 Subject: Fix random failing tests with project teams --- app/views/team_members/_team_member.html.haml | 2 +- features/steps/project/project_team_management.rb | 22 ++++------------------ 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/app/views/team_members/_team_member.html.haml b/app/views/team_members/_team_member.html.haml index 4bd4fca6718..63336bfc19a 100644 --- a/app/views/team_members/_team_member.html.haml +++ b/app/views/team_members/_team_member.html.haml @@ -1,6 +1,6 @@ - user = member.user - allow_admin = current_user_can_admin_project -%li{id: dom_id(user), class: "team_member_row user_#{user.id}"} +%li{id: dom_id(user), class: "team_member_row access-#{member.human_access.downcase}"} .pull-right - if allow_admin .pull-left diff --git a/features/steps/project/project_team_management.rb b/features/steps/project/project_team_management.rb index 7e9533de8f6..af41fd42612 100644 --- a/features/steps/project/project_team_management.rb +++ b/features/steps/project/project_team_management.rb @@ -30,35 +30,27 @@ class ProjectTeamManagement < Spinach::FeatureSteps end Then 'I should see "Mike" in team list as "Reporter"' do - user = User.find_by_name("Mike") - - within "#user_#{user.id}" do + within ".access-reporter" do page.should have_content('Mike') - page.find('#team_member_project_access').value.should == access_value(:reporter) end end Given 'I should see "Sam" in team list as "Developer"' do - user = User.find_by_name("Sam") - - within "#user_#{user.id}" do + within ".access-developer" do page.should have_content('Sam') - page.find('#team_member_project_access').value.should == access_value(:developer) end end And 'I change "Sam" role to "Reporter"' do user = User.find_by_name("Sam") - within ".user_#{user.id}" do + within "#user_#{user.id}" do select "Reporter", from: "team_member_project_access" end end And 'I should see "Sam" in team list as "Reporter"' do - user = User.find_by_name("Sam") - within ".user_#{user.id}" do + within ".access-reporter" do page.should have_content('Sam') - page.find('#team_member_project_access').value.should == access_value(:reporter) end end @@ -111,10 +103,4 @@ class ProjectTeamManagement < Spinach::FeatureSteps click_link('Remove user from team') end end - - private - - def access_value(key) - UsersProject.roles_hash[key].to_s - end end -- cgit v1.2.1 From b3ef63a0a547610ba8ac6435674eabc5a2130c3d Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 19 Jun 2013 19:48:48 +0300 Subject: Migrate global project taks. Removed more teams related functionality --- app/controllers/application_controller.rb | 8 -------- app/helpers/admin/teams/members_helper.rb | 5 ----- app/helpers/admin/teams/projects_helper.rb | 5 ----- app/helpers/namespaces_helper.rb | 1 - app/models/concerns/issuable.rb | 1 - app/models/project.rb | 6 ------ app/views/dashboard/_teams.html.haml | 23 ---------------------- app/views/layouts/nav/_team.html.haml | 25 ------------------------ app/views/team_members/_assigned_team.html.haml | 10 ---------- app/views/team_members/_assigned_teams.html.haml | 4 ---- app/views/team_members/index.html.haml | 7 ------- lib/tasks/migrate/migrate_global_projects.rake | 10 +++++++--- 12 files changed, 7 insertions(+), 98 deletions(-) delete mode 100644 app/helpers/admin/teams/members_helper.rb delete mode 100644 app/helpers/admin/teams/projects_helper.rb delete mode 100644 app/views/dashboard/_teams.html.haml delete mode 100644 app/views/layouts/nav/_team.html.haml delete mode 100644 app/views/team_members/_assigned_team.html.haml delete mode 100644 app/views/team_members/_assigned_teams.html.haml diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index fda05feefc0..e84220c1e57 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -95,14 +95,6 @@ class ApplicationController < ActionController::Base return access_denied! unless can?(current_user, :create_team, nil) 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 diff --git a/app/helpers/admin/teams/members_helper.rb b/app/helpers/admin/teams/members_helper.rb deleted file mode 100644 index 58b9f1896c4..00000000000 --- a/app/helpers/admin/teams/members_helper.rb +++ /dev/null @@ -1,5 +0,0 @@ -module Admin::Teams::MembersHelper - def member_since(team, member) - team.user_team_user_relationships.find_by_user_id(member).created_at - end -end diff --git a/app/helpers/admin/teams/projects_helper.rb b/app/helpers/admin/teams/projects_helper.rb deleted file mode 100644 index b97cc403337..00000000000 --- a/app/helpers/admin/teams/projects_helper.rb +++ /dev/null @@ -1,5 +0,0 @@ -module Admin::Teams::ProjectsHelper - def assigned_since(team, project) - team.user_team_project_relationships.find_by_project_id(project).created_at - end -end diff --git a/app/helpers/namespaces_helper.rb b/app/helpers/namespaces_helper.rb index a6fcf8d8cf2..dc88e178360 100644 --- a/app/helpers/namespaces_helper.rb +++ b/app/helpers/namespaces_helper.rb @@ -7,7 +7,6 @@ module NamespacesHelper users_opts = [ "Users", users.sort_by(&:human_name).map {|u| [u.human_name, u.id]} ] options = [] - options << global_opts if current_user.admin options << group_opts options << users_opts diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb index 11e3d8eed19..cb238c15ed8 100644 --- a/app/models/concerns/issuable.rb +++ b/app/models/concerns/issuable.rb @@ -21,7 +21,6 @@ module Issuable scope :opened, -> { with_state(:opened) } scope :closed, -> { with_state(:closed) } scope :of_group, ->(group) { where(project_id: group.project_ids) } - scope :of_user_team, ->(team) { where(project_id: team.project_ids, assignee_id: team.member_ids) } scope :assigned_to, ->(u) { where(assignee_id: u.id)} scope :recent, -> { order("created_at DESC") } scope :assigned, -> { where("assignee_id IS NOT NULL") } diff --git a/app/models/project.rb b/app/models/project.rb index ff61eca60de..5045cb21303 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -61,12 +61,6 @@ class Project < ActiveRecord::Base has_many :snippets, dependent: :destroy, class_name: "ProjectSnippet" has_many :hooks, dependent: :destroy, class_name: "ProjectHook" has_many :protected_branches, dependent: :destroy - has_many :user_team_project_relationships, dependent: :destroy - - has_many :users, through: :users_projects - has_many :user_teams, through: :user_team_project_relationships - has_many :user_team_user_relationships, through: :user_teams - has_many :user_teams_members, through: :user_team_user_relationships has_many :deploy_keys_projects, dependent: :destroy has_many :deploy_keys, through: :deploy_keys_projects diff --git a/app/views/dashboard/_teams.html.haml b/app/views/dashboard/_teams.html.haml deleted file mode 100644 index 95d87f508e0..00000000000 --- a/app/views/dashboard/_teams.html.haml +++ /dev/null @@ -1,23 +0,0 @@ -.ui-box.teams-box - %h5.title - Teams - %span.light - (#{teams.count}) - %span.pull-right - = link_to new_team_path, class: "btn btn-small" do - %i.icon-plus - New Team - %ul.well-list - - 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) - %span.pull-right.light - - if team.owner == current_user - %i.icon-wrench - - tm = current_user.user_team_user_relationships.find_by_user_team_id(team.id) - - if tm - = tm.access_human - - if teams.blank? - %li - %h3.nothing_here_message You have no teams yet. diff --git a/app/views/layouts/nav/_team.html.haml b/app/views/layouts/nav/_team.html.haml deleted file mode 100644 index 575c5b7e1f3..00000000000 --- a/app/views/layouts/nav/_team.html.haml +++ /dev/null @@ -1,25 +0,0 @@ -%ul - = nav_link(path: 'teams#show', html_options: {class: 'home'}) do - = link_to team_path(@team), title: "Home" do - %i.icon-home - - = nav_link(path: 'teams#issues') do - = link_to issues_team_path(@team) do - Issues - %span.count= Issue.opened.of_user_team(@team).count - - = nav_link(path: 'teams#merge_requests') do - = link_to merge_requests_team_path(@team) do - Merge Requests - %span.count= MergeRequest.opened.of_user_team(@team).count - - = nav_link(controller: [:members]) do - = link_to team_members_path(@team), class: "team-tab tab" do - Members - %span.count= @team.members.count - - - if can? current_user, :manage_user_team, @team - = nav_link(path: 'teams#edit') do - = link_to edit_team_path(@team), class: "stat-tab tab " do - Settings - diff --git a/app/views/team_members/_assigned_team.html.haml b/app/views/team_members/_assigned_team.html.haml deleted file mode 100644 index 51a31a6456d..00000000000 --- a/app/views/team_members/_assigned_team.html.haml +++ /dev/null @@ -1,10 +0,0 @@ -%li{id: dom_id(team), class: "user_team_row team_#{team.id}"} - .pull-right - - if can?(current_user, :admin_team_member, @project) - = link_to resign_project_team_path(@project, team), method: :delete, confirm: "Are you sure?", class: "btn btn-remove btn-tiny" do - %i.icon-minus.icon-white - - %strong= link_to team.name, team_path(team), title: team.name, class: "dark" - %br - %small.cgray Members: #{team.members.count} - %small.cgray Max access: #{team_relation.human_max_access} diff --git a/app/views/team_members/_assigned_teams.html.haml b/app/views/team_members/_assigned_teams.html.haml deleted file mode 100644 index 91c6d8f7157..00000000000 --- a/app/views/team_members/_assigned_teams.html.haml +++ /dev/null @@ -1,4 +0,0 @@ -.ui-box - %ul.well-list - - assigned_teams.sort_by(&:team_name).each do |team_relation| - = render "team_members/assigned_team", team_relation: team_relation, team: team_relation.user_team diff --git a/app/views/team_members/index.html.haml b/app/views/team_members/index.html.haml index 781cb36a583..146e5c02f95 100644 --- a/app/views/team_members/index.html.haml +++ b/app/views/team_members/index.html.haml @@ -24,10 +24,3 @@ - else = render "team_members/team", members: @users_projects - -- if @assigned_teams.present? - %h5 - Assigned teams - (#{@project.user_teams.count}) - %div - = render "team_members/assigned_teams", assigned_teams: @assigned_teams diff --git a/lib/tasks/migrate/migrate_global_projects.rake b/lib/tasks/migrate/migrate_global_projects.rake index f2f74723c3b..2cf9c23fb80 100644 --- a/lib/tasks/migrate/migrate_global_projects.rake +++ b/lib/tasks/migrate/migrate_global_projects.rake @@ -4,9 +4,13 @@ task migrate_global_projects: :environment do ask_to_continue Project.where(namespace_id: nil).find_each(batch_size: 20) do |project| - - # TODO: transfer code here - print '.' + begin + project.transfer(project.owner.namespace) + print '.' + rescue => ex + puts ex.message + print 'F' + end end end -- cgit v1.2.1 From 93e003aa61e885fe129b9678b1894e485c25c81c Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 19 Jun 2013 19:54:10 +0300 Subject: Restore users assoc with project --- app/models/project.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/project.rb b/app/models/project.rb index 5045cb21303..63c3d39ad3f 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -56,12 +56,14 @@ class Project < ActiveRecord::Base has_many :merge_requests, dependent: :destroy has_many :issues, dependent: :destroy, order: "state DESC, created_at DESC" has_many :milestones, dependent: :destroy - has_many :users_projects, dependent: :destroy has_many :notes, dependent: :destroy has_many :snippets, dependent: :destroy, class_name: "ProjectSnippet" has_many :hooks, dependent: :destroy, class_name: "ProjectHook" has_many :protected_branches, dependent: :destroy + has_many :users_projects, dependent: :destroy + has_many :users, through: :users_projects + has_many :deploy_keys_projects, dependent: :destroy has_many :deploy_keys, through: :deploy_keys_projects -- cgit v1.2.1 From 8e737ed54235ba0d296d25bc24f2f00e986c1507 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 19 Jun 2013 21:58:52 +0300 Subject: Dont show remove/modify controls for personal project owner --- app/models/project.rb | 4 ++++ app/views/team_members/_team_member.html.haml | 16 ++++++++-------- app/views/users_groups/_users_group.html.haml | 2 ++ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index 63c3d39ad3f..e1f135b54f7 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -414,6 +414,10 @@ class Project < ActiveRecord::Base imported end + def personal? + !group + end + def rename_repo old_path_with_namespace = File.join(namespace_dir, path_was) new_path_with_namespace = File.join(namespace_dir, path) diff --git a/app/views/team_members/_team_member.html.haml b/app/views/team_members/_team_member.html.haml index 63336bfc19a..916cf2e7a87 100644 --- a/app/views/team_members/_team_member.html.haml +++ b/app/views/team_members/_team_member.html.haml @@ -1,14 +1,14 @@ - user = member.user -- allow_admin = current_user_can_admin_project %li{id: dom_id(user), class: "team_member_row access-#{member.human_access.downcase}"} .pull-right - - if allow_admin - .pull-left - = form_for(member, as: :team_member, url: project_team_member_path(@project, member.user)) do |f| - = f.select :project_access, options_for_select(UsersProject.access_roles, member.project_access), {}, class: "medium project-access-select span2 trigger-submit" -   - = link_to project_team_member_path(@project, user), confirm: remove_from_project_team_message(@project, user), method: :delete, class: "btn-tiny btn btn-remove", title: 'Remove user from team' do - %i.icon-minus.icon-white + - if current_user_can_admin_project + - unless @project.personal? && user == current_user + .pull-left + = form_for(member, as: :team_member, url: project_team_member_path(@project, member.user)) do |f| + = f.select :project_access, options_for_select(UsersProject.access_roles, member.project_access), {}, class: "medium project-access-select span2 trigger-submit" +   + = link_to project_team_member_path(@project, user), confirm: remove_from_project_team_message(@project, user), method: :delete, class: "btn-tiny btn btn-remove", title: 'Remove user from team' do + %i.icon-minus.icon-white = image_tag gravatar_icon(user.email, 32), class: "avatar s32" %p %strong= user.name diff --git a/app/views/users_groups/_users_group.html.haml b/app/views/users_groups/_users_group.html.haml index 31a829952ac..c6dca5f3425 100644 --- a/app/views/users_groups/_users_group.html.haml +++ b/app/views/users_groups/_users_group.html.haml @@ -4,6 +4,8 @@ = image_tag gravatar_icon(user.email, 16), class: "avatar s16" %strong= user.name %span.cgray= user.username + - if user == current_user + %span.label.label-success It's you %span.pull-right - if @group.owners.include?(user) -- cgit v1.2.1 From 1811d32e23f2c7c4c76f4e868ab3b5850f6addb3 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 19 Jun 2013 22:44:57 +0300 Subject: Squash project settings navs --- app/assets/stylesheets/gitlab_bootstrap/nav.scss | 7 + app/controllers/deploy_keys_controller.rb | 2 + app/controllers/hooks_controller.rb | 2 + app/controllers/projects_controller.rb | 3 +- app/controllers/services_controller.rb | 2 + app/controllers/team_members_controller.rb | 2 + app/views/deploy_keys/index.html.haml | 6 +- app/views/deploy_keys/new.html.haml | 2 - app/views/deploy_keys/show.html.haml | 2 - app/views/hooks/index.html.haml | 2 - app/views/layouts/project_settings.html.haml | 20 ++ app/views/projects/_settings_nav.html.haml | 4 +- app/views/projects/edit.html.haml | 316 +++++++++++------------ app/views/services/edit.html.haml | 2 - app/views/services/index.html.haml | 2 - app/views/team_members/import.html.haml | 2 - app/views/team_members/index.html.haml | 14 +- app/views/team_members/new.html.haml | 1 - 18 files changed, 190 insertions(+), 201 deletions(-) create mode 100644 app/views/layouts/project_settings.html.haml diff --git a/app/assets/stylesheets/gitlab_bootstrap/nav.scss b/app/assets/stylesheets/gitlab_bootstrap/nav.scss index db0023cff92..56102909035 100644 --- a/app/assets/stylesheets/gitlab_bootstrap/nav.scss +++ b/app/assets/stylesheets/gitlab_bootstrap/nav.scss @@ -22,6 +22,13 @@ color: $style_color; font-weight: bold; } + + &.nav-stacked-menu { + background: #FAFAFA; + li > a { + padding: 20px; + } + } } } diff --git a/app/controllers/deploy_keys_controller.rb b/app/controllers/deploy_keys_controller.rb index 35d28becd05..4bd810f20c0 100644 --- a/app/controllers/deploy_keys_controller.rb +++ b/app/controllers/deploy_keys_controller.rb @@ -4,6 +4,8 @@ class DeployKeysController < ProjectResourceController # Authorize before_filter :authorize_admin_project! + layout "project_settings" + def index @enabled_keys = @project.deploy_keys.all @available_keys = available_keys - @enabled_keys diff --git a/app/controllers/hooks_controller.rb b/app/controllers/hooks_controller.rb index b7d25e36252..feaa16b6875 100644 --- a/app/controllers/hooks_controller.rb +++ b/app/controllers/hooks_controller.rb @@ -5,6 +5,8 @@ class HooksController < ProjectResourceController respond_to :html + layout "project_settings" + def index @hooks = @project.hooks.all @hook = ProjectHook.new diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index fad681eeef8..62b8e62eba9 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -15,6 +15,7 @@ class ProjectsController < ProjectResourceController end def edit + render 'edit', layout: "project_settings" end def create @@ -42,7 +43,7 @@ class ProjectsController < ProjectResourceController format.html { redirect_to edit_project_path(@project), notice: 'Project was successfully updated.' } format.js else - format.html { render action: "edit" } + format.html { render action: "edit", layout: "project_settings" } format.js end end diff --git a/app/controllers/services_controller.rb b/app/controllers/services_controller.rb index fcfc4c84a91..5710f553fa4 100644 --- a/app/controllers/services_controller.rb +++ b/app/controllers/services_controller.rb @@ -5,6 +5,8 @@ class ServicesController < ProjectResourceController respond_to :html + layout "project_settings" + def index @project.build_missing_services @services = @project.services.reload diff --git a/app/controllers/team_members_controller.rb b/app/controllers/team_members_controller.rb index 0058c32462a..5f2493137c1 100644 --- a/app/controllers/team_members_controller.rb +++ b/app/controllers/team_members_controller.rb @@ -3,6 +3,8 @@ class TeamMembersController < ProjectResourceController before_filter :authorize_read_project! before_filter :authorize_admin_project!, except: [:index, :show] + layout "project_settings" + def index @group = @project.group @users_projects = @project.users_projects.order('project_access DESC') diff --git a/app/views/deploy_keys/index.html.haml b/app/views/deploy_keys/index.html.haml index 7801302d3f4..a1fa3475a84 100644 --- a/app/views/deploy_keys/index.html.haml +++ b/app/views/deploy_keys/index.html.haml @@ -1,5 +1,3 @@ -= render "projects/settings_nav" - %p.slead Deploy keys allow read-only access to repository. They can be used for CI, staging or production servers @@ -12,7 +10,7 @@ %hr.clearfix .row - .span6.enabled-keys + .span5.enabled-keys %h5.cgreen Enabled deploy keys %small for this project @@ -21,7 +19,7 @@ - if @enabled_keys.blank? .light-well %p.nothing_here_message Create #{link_to 'new deploy key', new_project_deploy_key_path(@project)} or add existing one - .span6.available-keys + .span5.available-keys %h5 Available deploy keys %small from projects you are able to manage diff --git a/app/views/deploy_keys/new.html.haml b/app/views/deploy_keys/new.html.haml index 0bbea1ebed5..b0e2a8b2949 100644 --- a/app/views/deploy_keys/new.html.haml +++ b/app/views/deploy_keys/new.html.haml @@ -1,5 +1,3 @@ -= render "projects/settings_nav" - %h3.page_title New Deploy key %hr diff --git a/app/views/deploy_keys/show.html.haml b/app/views/deploy_keys/show.html.haml index 5b59d322343..26fd7428b7e 100644 --- a/app/views/deploy_keys/show.html.haml +++ b/app/views/deploy_keys/show.html.haml @@ -1,5 +1,3 @@ -= render "projects/settings_nav" - %h3.page_title Deploy key: = @key.title diff --git a/app/views/hooks/index.html.haml b/app/views/hooks/index.html.haml index 3155dd32177..918c159a200 100644 --- a/app/views/hooks/index.html.haml +++ b/app/views/hooks/index.html.haml @@ -1,5 +1,3 @@ -= render "projects/settings_nav" - - if can? current_user, :admin_project, @project .alert.alert-info %span diff --git a/app/views/layouts/project_settings.html.haml b/app/views/layouts/project_settings.html.haml new file mode 100644 index 00000000000..ea739da73d8 --- /dev/null +++ b/app/views/layouts/project_settings.html.haml @@ -0,0 +1,20 @@ +!!! 5 +%html{ lang: "en"} + = render "layouts/head", title: @project.name_with_namespace + %body{class: "#{app_theme} project", :'data-page' => body_data_page, :'data-project-id' => @project.id } + = render "layouts/head_panel", title: project_title(@project) + = render "layouts/init_auto_complete" + = render "layouts/flash" + - if can?(current_user, :download_code, @project) + = render 'shared/no_ssh' + + %nav.main-nav + .container= render 'layouts/nav/project' + + .container + .content + .row + .span2 + = render "projects/settings_nav" + .span10 + = yield diff --git a/app/views/projects/_settings_nav.html.haml b/app/views/projects/_settings_nav.html.haml index 272c5e4402f..f59e2871aa3 100644 --- a/app/views/projects/_settings_nav.html.haml +++ b/app/views/projects/_settings_nav.html.haml @@ -1,8 +1,8 @@ -%ul.nav.nav-tabs +%ul.nav.nav-pills.nav-stacked.nav-stacked-menu = nav_link(path: 'projects#edit') do = link_to edit_project_path(@project), class: "stat-tab tab " do %i.icon-edit - Edit + Edit Project = nav_link(controller: [:team_members, :teams]) do = link_to project_team_index_path(@project), class: "team-tab tab" do %i.icon-group diff --git a/app/views/projects/edit.html.haml b/app/views/projects/edit.html.haml index 43199bc3dd9..562e4e3ae79 100644 --- a/app/views/projects/edit.html.haml +++ b/app/views/projects/edit.html.haml @@ -1,175 +1,153 @@ -= render "projects/settings_nav" - .project-edit-container - %h3.page_title Edit Project - %hr .project-edit-errors .project-edit-content - .row - .span3 - %ul.nav.nav-pills.nav-stacked - %li.active - = link_to 'Settings', '#tab-settings', 'data-toggle' => 'tab' - %li - = link_to 'Rename repo', '#tab-rename', 'data-toggle' => 'tab' - %li - = link_to 'Transfer', '#tab-transfer', 'data-toggle' => 'tab' - %li - = link_to 'Remove', '#tab-remove', 'data-toggle' => 'tab' - - .span9 - .tab-content - .tab-pane.active#tab-settings - .ui-box.white - %h5.title Settings: - .form-holder - = form_for(@project, remote: true) do |f| - %fieldset - .clearfix.project_name_holder - = f.label :name do - Project name is - .input - = f.text_field :name, placeholder: "Example Project", class: "span5" - - - .clearfix - = f.label :description do - Project description - %span.light (optional) - .input - = f.text_area :description, placeholder: "awesome project", class: "span5", rows: 3, maxlength: 250 - - - unless @project.empty_repo? - .clearfix - = f.label :default_branch, "Default Branch" - .input= f.select(:default_branch, @repository.branch_names, {}, {class: 'chosen'}) - - - - if can?(current_user, :change_public_mode, @project) - %fieldset.public-mode - %legend - Public mode: - .control-group - = f.label :public, class: 'control-label' do - %span Public access - .controls - = f.check_box :public - %span.descr - If checked, this project can be cloned - %em without any - authentication. - It will also be listed on the #{link_to "public access directory", public_root_path}. - %em Any - user will have #{link_to "Guest", help_permissions_path} permissions on the repository. - - %fieldset.features - %legend - Labels: - .control-group - = f.label :label_list, "Labels", class: 'control-label' - .controls - = f.text_field :label_list, maxlength: 2000, class: "span5" - %p.hint Separate with comma. - - %fieldset.features - %legend - Features: - .control-group - = f.label :issues_enabled, "Issues", class: 'control-label' - .controls - = f.check_box :issues_enabled - %span.descr Lightweight issue tracking system for this project - - - if Project.issues_tracker.values.count > 1 - .control-group - = f.label :issues_tracker, "Issues tracker", class: 'control-label' - .input= f.select(:issues_tracker, Project.issues_tracker.values, {}, { disabled: !@project.issues_enabled }) - - .clearfix - = f.label :issues_tracker_id, "Project name or id in issues tracker", class: 'control-label' - .input= f.text_field :issues_tracker_id, disabled: !@project.can_have_issues_tracker_id? - - .control-group - = f.label :merge_requests_enabled, "Merge Requests", class: 'control-label' - .controls - = f.check_box :merge_requests_enabled - %span.descr Submit changes to be merged upstream. - - .control-group - = f.label :wiki_enabled, "Wiki", class: 'control-label' - .controls - = f.check_box :wiki_enabled - %span.descr Pages for project documentation - - .control-group - = f.label :wall_enabled, "Wall", class: 'control-label' - .controls - = f.check_box :wall_enabled - %span.descr Simple chat system for broadcasting inside project - - .control-group - = f.label :snippets_enabled, "Snippets", class: 'control-label' - .controls - = f.check_box :snippets_enabled - %span.descr Share code pastes with others out of git repository - - - .form-actions - = f.submit 'Save', class: "btn btn-save" - - .tab-pane#tab-transfer - - if can?(current_user, :change_namespace, @project) - .ui-box.ui-box-danger - %h5.title Transfer project - .errors-holder - .form-holder - = form_for(@project, url: transfer_project_path(@project), remote: true, html: { class: 'transfer-project' }) do |f| - .control-group - = f.label :namespace_id do - %span Namespace - .controls - .clearfix - = f.select :namespace_id, namespaces_options(@project.namespace_id), {prompt: 'Choose a project namespace'}, {class: 'chosen'} - %ul - %li Be careful. Changing project namespace can have unintended side effects - %li You can transfer project only to namespaces you can manage - %li You will need to update your local repositories to point to the new location. - .form-actions - = f.submit 'Transfer', class: "btn btn-remove" - - else - %p.nothing_here_message Only project owner can transfer a project - - .tab-pane#tab-rename - .ui-box.ui-box-danger - %h5.title Rename repository - .errors-holder - .form-holder - = form_for(@project) do |f| - .control-group - = f.label :path do - %span Path - .controls - .clearfix - = f.text_field :path - %ul - %li Be careful. Rename of project repo can have unintended side effects - %li You will need to update your local repositories to point to the new location. - .form-actions - = f.submit 'Rename', class: "btn btn-remove" - - .tab-pane#tab-remove - - if can?(current_user, :remove_project, @project) - .ui-box.ui-box-danger - %h5.title Remove project - .ui-box-body - %p - Remove of project will cause removing repository and all related resources like issues, merge requests etc. - %p - %strong Removed project can not be restored! - - = link_to 'Remove project', @project, confirm: remove_project_message(@project), method: :delete, class: "btn btn-remove btn-small" - - else - %p.nothing_here_message Only project owner can remove a project + .ui-box.white + %h5.title Settings: + .form-holder + = form_for(@project, remote: true) do |f| + %fieldset + .clearfix.project_name_holder + = f.label :name do + Project name is + .input + = f.text_field :name, placeholder: "Example Project", class: "span5" + + + .clearfix + = f.label :description do + Project description + %span.light (optional) + .input + = f.text_area :description, placeholder: "awesome project", class: "span5", rows: 3, maxlength: 250 + + - unless @project.empty_repo? + .clearfix + = f.label :default_branch, "Default Branch" + .input= f.select(:default_branch, @repository.branch_names, {}, {class: 'chosen'}) + + + - if can?(current_user, :change_public_mode, @project) + %fieldset.public-mode + %legend + Public mode: + .control-group + = f.label :public, class: 'control-label' do + %span Public access + .controls + = f.check_box :public + %span.descr + If checked, this project can be cloned + %em without any + authentication. + It will also be listed on the #{link_to "public access directory", public_root_path}. + %em Any + user will have #{link_to "Guest", help_permissions_path} permissions on the repository. + + %fieldset.features + %legend + Labels: + .control-group + = f.label :label_list, "Labels", class: 'control-label' + .controls + = f.text_field :label_list, maxlength: 2000, class: "span5" + %p.hint Separate with comma. + + %fieldset.features + %legend + Features: + .control-group + = f.label :issues_enabled, "Issues", class: 'control-label' + .controls + = f.check_box :issues_enabled + %span.descr Lightweight issue tracking system for this project + + - if Project.issues_tracker.values.count > 1 + .control-group + = f.label :issues_tracker, "Issues tracker", class: 'control-label' + .input= f.select(:issues_tracker, Project.issues_tracker.values, {}, { disabled: !@project.issues_enabled }) + + .clearfix + = f.label :issues_tracker_id, "Project name or id in issues tracker", class: 'control-label' + .input= f.text_field :issues_tracker_id, disabled: !@project.can_have_issues_tracker_id? + + .control-group + = f.label :merge_requests_enabled, "Merge Requests", class: 'control-label' + .controls + = f.check_box :merge_requests_enabled + %span.descr Submit changes to be merged upstream. + + .control-group + = f.label :wiki_enabled, "Wiki", class: 'control-label' + .controls + = f.check_box :wiki_enabled + %span.descr Pages for project documentation + + .control-group + = f.label :wall_enabled, "Wall", class: 'control-label' + .controls + = f.check_box :wall_enabled + %span.descr Simple chat system for broadcasting inside project + + .control-group + = f.label :snippets_enabled, "Snippets", class: 'control-label' + .controls + = f.check_box :snippets_enabled + %span.descr Share code pastes with others out of git repository + + + .form-actions + = f.submit 'Save', class: "btn btn-save" + + - if can?(current_user, :change_namespace, @project) + .ui-box.ui-box-danger + %h5.title Transfer project + .errors-holder + .form-holder + = form_for(@project, url: transfer_project_path(@project), remote: true, html: { class: 'transfer-project' }) do |f| + .control-group + = f.label :namespace_id do + %span Namespace + .controls + .clearfix + = f.select :namespace_id, namespaces_options(@project.namespace_id), {prompt: 'Choose a project namespace'}, {class: 'chosen'} + %ul + %li Be careful. Changing project namespace can have unintended side effects + %li You can transfer project only to namespaces you can manage + %li You will need to update your local repositories to point to the new location. + .form-actions + = f.submit 'Transfer', class: "btn btn-remove" + - else + %p.nothing_here_message Only project owner can transfer a project + + .ui-box.ui-box-danger + %h5.title Rename repository + .errors-holder + .form-holder + = form_for(@project) do |f| + .control-group + = f.label :path do + %span Path + .controls + .clearfix + = f.text_field :path + %ul + %li Be careful. Rename of project repo can have unintended side effects + %li You will need to update your local repositories to point to the new location. + .form-actions + = f.submit 'Rename', class: "btn btn-remove" + + - if can?(current_user, :remove_project, @project) + .ui-box.ui-box-danger + %h5.title Remove project + .ui-box-body + %p + Remove of project will cause removing repository and all related resources like issues, merge requests etc. + %p + %strong Removed project can not be restored! + + = link_to 'Remove project', @project, confirm: remove_project_message(@project), method: :delete, class: "btn btn-remove btn-small" + - else + %p.nothing_here_message Only project owner can remove a project .save-project-loader.hide %center diff --git a/app/views/services/edit.html.haml b/app/views/services/edit.html.haml index d4bc9e41c27..bcc5832792f 100644 --- a/app/views/services/edit.html.haml +++ b/app/views/services/edit.html.haml @@ -1,3 +1 @@ -= render "projects/settings_nav" - = render 'form' diff --git a/app/views/services/index.html.haml b/app/views/services/index.html.haml index bd52948a6fd..6d254f66f1c 100644 --- a/app/views/services/index.html.haml +++ b/app/views/services/index.html.haml @@ -1,5 +1,3 @@ -= render "projects/settings_nav" - %h3.page_title Services %br diff --git a/app/views/team_members/import.html.haml b/app/views/team_members/import.html.haml index 0f7175b9018..2b22c917a16 100644 --- a/app/views/team_members/import.html.haml +++ b/app/views/team_members/import.html.haml @@ -1,5 +1,3 @@ -= render "projects/settings_nav" - %h3.page_title = "Import team from another project" %hr diff --git a/app/views/team_members/index.html.haml b/app/views/team_members/index.html.haml index 146e5c02f95..59c65a66794 100644 --- a/app/views/team_members/index.html.haml +++ b/app/views/team_members/index.html.haml @@ -1,4 +1,3 @@ -= render "projects/settings_nav" %h3.page_title Users with access to this project @@ -12,15 +11,6 @@ %p.light Read more about project permissions %strong= link_to "here", help_permissions_path, class: "vlink" - -.clearfix - - if @group - .row - .span6 - = render "team_members/group_members" - .span6 - = render "team_members/team", members: @users_projects - -- else - = render "team_members/team", members: @users_projects + = render "team_members/group_members" += render "team_members/team", members: @users_projects diff --git a/app/views/team_members/new.html.haml b/app/views/team_members/new.html.haml index 7e20f50d964..4f70fb4b046 100644 --- a/app/views/team_members/new.html.haml +++ b/app/views/team_members/new.html.haml @@ -1,2 +1 @@ -= render "projects/settings_nav" = render "team_members/form" -- cgit v1.2.1 From cc2145da80abe53052598b062d7853efdf225d8b Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 19 Jun 2013 22:52:57 +0300 Subject: Fixed sub navs spinach tests for project --- features/project/active_tab.feature | 30 ++++++++-------------------- features/steps/project/project_active_tab.rb | 28 ++++++++------------------ features/steps/shared/active_tab.rb | 8 ++++++++ 3 files changed, 24 insertions(+), 42 deletions(-) diff --git a/features/project/active_tab.feature b/features/project/active_tab.feature index f33e4b9e369..48c217fbea7 100644 --- a/features/project/active_tab.feature +++ b/features/project/active_tab.feature @@ -52,48 +52,34 @@ Feature: Project active tab Then the active main tab should be Home And no other main tabs should be active - #Scenario: On Project Settings/Attachments - #Given I visit my project's home page - #And I click the "Attachments" tab - #Then the active sub tab should be Attachments - #And no other sub tabs should be active - #And the active main tab should be Home - - #Scenario: On Project Settings/Snippets - #Given I visit my project's home page - #And I click the "Snippets" tab - #Then the active sub tab should be Snippets - #And no other sub tabs should be active - #And the active main tab should be Home - # Sub Tabs: Settings Scenario: On Project Settings/Team Given I visit my project's settings page And I click the "Team" tab - Then the active sub tab should be Team - And no other sub tabs should be active + Then the active sub nav should be Team + And no other sub navs should be active And the active main tab should be Settings Scenario: On Project Settings/Edit Given I visit my project's settings page And I click the "Edit" tab - Then the active sub tab should be Edit - And no other sub tabs should be active + Then the active sub nav should be Edit + And no other sub navs should be active And the active main tab should be Settings Scenario: On Project Settings/Hooks Given I visit my project's settings page And I click the "Hooks" tab - Then the active sub tab should be Hooks - And no other sub tabs should be active + Then the active sub nav should be Hooks + And no other sub navs should be active And the active main tab should be Settings Scenario: On Project Settings/Deploy Keys Given I visit my project's settings page And I click the "Deploy Keys" tab - Then the active sub tab should be Deploy Keys - And no other sub tabs should be active + Then the active sub nav should be Deploy Keys + And no other sub navs should be active And the active main tab should be Settings # Sub Tabs: Commits diff --git a/features/steps/project/project_active_tab.rb b/features/steps/project/project_active_tab.rb index a0ee32b9ec0..e04a17168be 100644 --- a/features/steps/project/project_active_tab.rb +++ b/features/steps/project/project_active_tab.rb @@ -68,32 +68,20 @@ class ProjectActiveTab < Spinach::FeatureSteps click_link('Deploy Keys') end - Then 'the active sub tab should be Show' do - ensure_active_sub_tab('Show') + Then 'the active sub nav should be Team' do + ensure_active_sub_nav('Members') end - Then 'the active sub tab should be Team' do - ensure_active_sub_tab('Members') + Then 'the active sub nav should be Edit' do + ensure_active_sub_nav('Edit Project') end - Then 'the active sub tab should be Attachments' do - ensure_active_sub_tab('Attachments') + Then 'the active sub nav should be Hooks' do + ensure_active_sub_nav('Web Hooks') end - Then 'the active sub tab should be Snippets' do - ensure_active_sub_tab('Snippets') - end - - Then 'the active sub tab should be Edit' do - ensure_active_sub_tab('Edit') - end - - Then 'the active sub tab should be Hooks' do - ensure_active_sub_tab('Web Hooks') - end - - Then 'the active sub tab should be Deploy Keys' do - ensure_active_sub_tab('Deploy Keys') + Then 'the active sub nav should be Deploy Keys' do + ensure_active_sub_nav('Deploy Keys') end # Sub Tabs: Commits diff --git a/features/steps/shared/active_tab.rb b/features/steps/shared/active_tab.rb index 617a077b914..d504fda3327 100644 --- a/features/steps/shared/active_tab.rb +++ b/features/steps/shared/active_tab.rb @@ -13,6 +13,10 @@ module SharedActiveTab page.find('div.content ul.nav-tabs li.active').should have_content(content) end + def ensure_active_sub_nav(content) + page.find('div.content ul.nav-stacked-menu li.active').should have_content(content) + end + And 'no other main tabs should be active' do page.should have_selector('.main-nav li.active', count: 1) end @@ -20,4 +24,8 @@ module SharedActiveTab And 'no other sub tabs should be active' do page.should have_selector('div.content ul.nav-tabs li.active', count: 1) end + + And 'no other sub navs should be active' do + page.should have_selector('div.content ul.nav-stacked-menu li.active', count: 1) + end end -- cgit v1.2.1 From 3d978f065f184beb10ef6652c08a19f672ebcb91 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 19 Jun 2013 22:55:49 +0300 Subject: Move from table to list for Hooks page --- app/views/hooks/index.html.haml | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/app/views/hooks/index.html.haml b/app/views/hooks/index.html.haml index 918c159a200..641ab082d8d 100644 --- a/app/views/hooks/index.html.haml +++ b/app/views/hooks/index.html.haml @@ -20,21 +20,15 @@ %hr -if @hooks.any? - %h3.page_title - Hooks (#{@hooks.count}) - %br - %table - %thead - %tr - %th URL - %th - - @hooks.each do |hook| - %tr - %td + .ui-box + %h5.title + Hooks (#{@hooks.count}) + %ul.well-list + - @hooks.each do |hook| + %li %span.badge.badge-info POST → %span.monospace= hook.url - %td .pull-right = link_to 'Test Hook', test_project_hook_path(@project, hook), class: "btn btn-small grouped" = link_to 'Remove', project_hook_path(@project, hook), confirm: 'Are you sure?', method: :delete, class: "btn btn-remove btn-small grouped" -- cgit v1.2.1 From c54d07b9ed083fe5739cc0e467eaf79b2deda255 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 19 Jun 2013 23:03:43 +0300 Subject: Add < 1200px support for project filter on dashboard --- app/assets/stylesheets/sections/dashboard.scss | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/assets/stylesheets/sections/dashboard.scss b/app/assets/stylesheets/sections/dashboard.scss index a0588563065..2e5c93134a7 100644 --- a/app/assets/stylesheets/sections/dashboard.scss +++ b/app/assets/stylesheets/sections/dashboard.scss @@ -56,3 +56,9 @@ margin-left: -2px; } } + +@media (max-width: 1200px) { + .dashboard .dash-projects-filter { + width: 132px; + } +} -- cgit v1.2.1 From 5a2111526dd7a255f74c98b95eeefc578ab0f444 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 20 Jun 2013 11:32:59 +0300 Subject: New logo/color for login screen --- app/assets/images/login-logo.png | Bin 1429 -> 10209 bytes app/assets/stylesheets/sections/login.scss | 2 +- app/views/devise/passwords/edit.html.haml | 1 - app/views/devise/passwords/new.html.erb | 9 --------- app/views/devise/passwords/new.html.haml | 11 +++++++++++ app/views/devise/registrations/new.html.haml | 3 ++- app/views/devise/sessions/new.html.haml | 4 ++-- app/views/layouts/devise.html.haml | 2 ++ 8 files changed, 18 insertions(+), 14 deletions(-) delete mode 100644 app/views/devise/passwords/new.html.erb create mode 100644 app/views/devise/passwords/new.html.haml diff --git a/app/assets/images/login-logo.png b/app/assets/images/login-logo.png index 8c064b12dd0..a61c41303c4 100644 Binary files a/app/assets/images/login-logo.png and b/app/assets/images/login-logo.png differ diff --git a/app/assets/stylesheets/sections/login.scss b/app/assets/stylesheets/sections/login.scss index e3fe0b436c3..e6fbc837d9e 100644 --- a/app/assets/stylesheets/sections/login.scss +++ b/app/assets/stylesheets/sections/login.scss @@ -1,6 +1,6 @@ /* Login Page */ body.login-page{ - background: #EEE; + background: #474D57; .container .content { padding-top: 5%; } } diff --git a/app/views/devise/passwords/edit.html.haml b/app/views/devise/passwords/edit.html.haml index e5800025c6d..d85b4ab08b2 100644 --- a/app/views/devise/passwords/edit.html.haml +++ b/app/views/devise/passwords/edit.html.haml @@ -1,5 +1,4 @@ = form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put, class: "login-box" }) do |f| - = image_tag "login-logo.png", width: "304", height: "66", class: "login-logo", alt: "Login Logo" %h3 Change your password = devise_error_messages! = f.hidden_field :reset_password_token diff --git a/app/views/devise/passwords/new.html.erb b/app/views/devise/passwords/new.html.erb deleted file mode 100644 index 0e39f318726..00000000000 --- a/app/views/devise/passwords/new.html.erb +++ /dev/null @@ -1,9 +0,0 @@ -<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { class: "login-box", method: :post }) do |f| %> - <%= image_tag "login-logo.png", width: "304", height: "66", class: "login-logo", alt: "Login Logo" %> - <%= devise_error_messages! %> - <%= f.email_field :email, placeholder: "Email", class: "text" %> -
-
- <%= f.submit "Reset password", class: "btn-primary btn" %> -
<%= link_to "Sign in", new_session_path(resource_name), class: "btn" %>
-<% end %> diff --git a/app/views/devise/passwords/new.html.haml b/app/views/devise/passwords/new.html.haml new file mode 100644 index 00000000000..5d47cbc3b83 --- /dev/null +++ b/app/views/devise/passwords/new.html.haml @@ -0,0 +1,11 @@ += form_for(resource, as: resource_name, url: password_path(resource_name), html: { class: "login-box", method: :post }) do |f| + %h3.page_title Reset password + %br + = devise_error_messages! + = f.email_field :email, placeholder: "Email", class: "text" + %br/ + %br/ + = f.submit "Reset password", class: "btn-primary btn" + .pull-right + = link_to "Sign in", new_session_path(resource_name), class: "btn" + %br/ diff --git a/app/views/devise/registrations/new.html.haml b/app/views/devise/registrations/new.html.haml index 12b0438229b..17a0c8fd79a 100644 --- a/app/views/devise/registrations/new.html.haml +++ b/app/views/devise/registrations/new.html.haml @@ -1,5 +1,6 @@ = form_for(resource, as: resource_name, url: registration_path(resource_name), html: { class: "login-box" }) do |f| - = image_tag "login-logo.png", width: "304", height: "66", class: "login-logo", alt: "Login Logo" + %h3.page_title Sign Up + %br = devise_error_messages! %div = f.text_field :name, class: "text top", placeholder: "Name", required: true diff --git a/app/views/devise/sessions/new.html.haml b/app/views/devise/sessions/new.html.haml index 8b71ebed5f4..241133662fb 100644 --- a/app/views/devise/sessions/new.html.haml +++ b/app/views/devise/sessions/new.html.haml @@ -1,6 +1,6 @@ .login-box - = image_tag "login-logo.png", width: "304", height: "66", class: "login-logo", alt: "Login Logo" - + %h3.page_title Sing in + %br - if ldap_enabled? %ul.nav.nav-tabs %li.active diff --git a/app/views/layouts/devise.html.haml b/app/views/layouts/devise.html.haml index a9758f19d36..0fa36211739 100644 --- a/app/views/layouts/devise.html.haml +++ b/app/views/layouts/devise.html.haml @@ -5,4 +5,6 @@ = render "layouts/flash" .container .content + %center + = image_tag image_path "login-logo.png" = yield -- cgit v1.2.1 From 38a9fc4f4701ff3f2d1a06e8567f45d1bb9fb9c6 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 20 Jun 2013 11:46:54 +0300 Subject: Classic (mars) theme will be default for 6.0 --- app/models/user.rb | 1 + lib/gitlab/theme.rb | 16 +++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 6a5411b222d..8efae30f35e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -205,6 +205,7 @@ class User < ActiveRecord::Base u.projects_limit = Gitlab.config.gitlab.default_projects_limit u.can_create_group = Gitlab.config.gitlab.default_can_create_group u.can_create_team = Gitlab.config.gitlab.default_can_create_team + u.theme_id = Gitlab::Theme::MARS end end diff --git a/lib/gitlab/theme.rb b/lib/gitlab/theme.rb index 7f833867e39..89604162304 100644 --- a/lib/gitlab/theme.rb +++ b/lib/gitlab/theme.rb @@ -1,12 +1,18 @@ module Gitlab class Theme + BASIC = 1 + MARS = 2 + MODERN = 3 + GRAY = 4 + COLOR = 5 + def self.css_class_by_id(id) themes = { - 1 => "ui_basic", - 2 => "ui_mars", - 3 => "ui_modern", - 4 => "ui_gray", - 5 => "ui_color" + BASIC => "ui_basic", + MARS => "ui_mars", + MODERN => "ui_modern", + GRAY => "ui_gray", + COLOR => "ui_color" } id ||= 1 -- cgit v1.2.1 From 86d9ed9a0a9d58c09b89da08dd4216b89a2025a2 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 20 Jun 2013 12:06:44 +0300 Subject: Fix user add to group from admin area --- app/controllers/admin/groups_controller.rb | 7 ------- app/views/admin/groups/show.html.haml | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/app/controllers/admin/groups_controller.rb b/app/controllers/admin/groups_controller.rb index 6e6c8d54e29..44ec6079e5b 100644 --- a/app/controllers/admin/groups_controller.rb +++ b/app/controllers/admin/groups_controller.rb @@ -58,13 +58,6 @@ class Admin::GroupsController < Admin::ApplicationController redirect_to :back, notice: 'Group was successfully updated.' end - def remove_project - @project = Project.find(params[:project_id]) - @project.transfer(nil) - - redirect_to :back, notice: 'Group was successfully updated.' - end - def project_teams_update @group.add_users(params[:user_ids].split(','), params[:group_access]) diff --git a/app/views/admin/groups/show.html.haml b/app/views/admin/groups/show.html.haml index 3de0091801f..bec9b0c650b 100644 --- a/app/views/admin/groups/show.html.haml +++ b/app/views/admin/groups/show.html.haml @@ -75,7 +75,7 @@ %div = users_select_tag(:user_ids, multiple: true) %div.prepend-top-10 - = select_tag :project_access, options_for_select(Project.access_options), {class: "project-access-select chosen span2"} + = select_tag :group_access, options_for_select(UsersGroup.group_access_roles), class: "project-access-select chosen" %hr = submit_tag 'Add users into group', class: "btn btn-create" .ui-box -- cgit v1.2.1 From f47ba909a29f70d59180a373b9a89dd8935fd455 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 20 Jun 2013 13:14:23 +0300 Subject: Fix seeds. More projects for dev seeds --- db/fixtures/development/01_admin.rb | 1 + db/fixtures/development/02_source_code.rb | 29 ------------- db/fixtures/development/03_group.rb | 5 --- db/fixtures/development/04_project.rb | 61 ++++++++++++++++++++-------- db/fixtures/development/05_users.rb | 2 +- db/fixtures/development/06_teams.rb | 23 +++++++---- db/fixtures/development/09_issues.rb | 1 - db/fixtures/development/10_merge_requests.rb | 1 - 8 files changed, 63 insertions(+), 60 deletions(-) delete mode 100644 db/fixtures/development/02_source_code.rb delete mode 100644 db/fixtures/development/03_group.rb diff --git a/db/fixtures/development/01_admin.rb b/db/fixtures/development/01_admin.rb index fbe41e4d22d..948a3459283 100644 --- a/db/fixtures/development/01_admin.rb +++ b/db/fixtures/development/01_admin.rb @@ -7,5 +7,6 @@ User.seed(:id, [ password: "5iveL!fe", password_confirmation: "5iveL!fe", admin: true, + projects_limit: 100, } ]) diff --git a/db/fixtures/development/02_source_code.rb b/db/fixtures/development/02_source_code.rb deleted file mode 100644 index 5ce5bcf4aba..00000000000 --- a/db/fixtures/development/02_source_code.rb +++ /dev/null @@ -1,29 +0,0 @@ -gitlab_shell_path = File.expand_path("~#{Gitlab.config.gitlab_shell.ssh_user}") -root = Gitlab.config.gitlab_shell.repos_path - -projects = [ - { path: 'underscore.git', git: 'https://github.com/documentcloud/underscore.git' }, - { path: 'diaspora.git', git: 'https://github.com/diaspora/diaspora.git' }, - { path: 'brightbox/brightbox-cli.git', git: 'https://github.com/brightbox/brightbox-cli.git' }, - { path: 'brightbox/puppet.git', git: 'https://github.com/brightbox/puppet.git' }, - { path: 'gitlab/gitlabhq.git', git: 'https://github.com/gitlabhq/gitlabhq.git' }, - { path: 'gitlab/gitlab-ci.git', git: 'https://github.com/gitlabhq/gitlab-ci.git' }, - { path: 'gitlab/gitlab-recipes.git', git: 'https://github.com/gitlabhq/gitlab-recipes.git' }, -] - -projects.each do |project| - project_path = File.join(root, project[:path]) - - if File.exists?(project_path) - print '-' - next - end - if system("#{gitlab_shell_path}/gitlab-shell/bin/gitlab-projects import-project #{project[:path]} #{project[:git]}") - print '.' - else - print 'F' - end -end - -puts "OK".green - diff --git a/db/fixtures/development/03_group.rb b/db/fixtures/development/03_group.rb deleted file mode 100644 index 01174a4b72a..00000000000 --- a/db/fixtures/development/03_group.rb +++ /dev/null @@ -1,5 +0,0 @@ -Group.seed(:id, [ - { id: 99, name: "GitLab", path: 'gitlab', owner_id: 1 }, - { id: 100, name: "Brightbox", path: 'brightbox', owner_id: 1 }, - { id: 101, name: "KDE", path: 'kde', owner_id: 1 }, -]) diff --git a/db/fixtures/development/04_project.rb b/db/fixtures/development/04_project.rb index 9904c48e518..43178dee25d 100644 --- a/db/fixtures/development/04_project.rb +++ b/db/fixtures/development/04_project.rb @@ -1,20 +1,49 @@ -Project.seed(:id, [ +project_urls = [ + 'https://github.com/documentcloud/underscore.git', + 'https://github.com/diaspora/diaspora.git', + 'https://github.com/diaspora/diaspora-project-site.git', + 'https://github.com/diaspora/diaspora-client.git', + 'https://github.com/brightbox/brightbox-cli.git', + 'https://github.com/brightbox/puppet.git', + 'https://github.com/gitlabhq/gitlabhq.git', + 'https://github.com/gitlabhq/gitlab-ci.git', + 'https://github.com/gitlabhq/gitlab-recipes.git', + 'https://github.com/gitlabhq/gitlab-shell.git', + 'https://github.com/gitlabhq/grack.git', + 'https://github.com/twitter/flight.git', + 'https://github.com/twitter/typeahead.js.git', + 'https://github.com/h5bp/html5-boilerplate.git', + 'https://github.com/h5bp/mobile-boilerplate.git', +] - # Global - { id: 1, name: "Underscore.js", path: "underscore", creator_id: 1 }, - { id: 2, name: "Diaspora", path: "diaspora", creator_id: 1 }, +project_urls.each_with_index do |url, i| + group_path, project_path = url.split('/')[-2..-1] - # Brightbox - { id: 3, namespace_id: 100, name: "Brightbox CLI", path: "brightbox-cli", creator_id: 1 }, - { id: 4, namespace_id: 100, name: "Puppet", path: "puppet", creator_id: 1 }, + group = Group.find_by_path(group_path) - # KDE - { id: 5, namespace_id: 101, name: "kdebase", path: "kdebase", creator_id: 1}, - { id: 6, namespace_id: 101, name: "kdelibs", path: "kdelibs", creator_id: 1}, - { id: 7, namespace_id: 101, name: "amarok", path: "amarok", creator_id: 1}, + unless group + group = Group.new( + name: group_path.titleize, + path: group_path + ) + group.owner = User.first + group.save + end - # GitLab - { id: 8, namespace_id: 99, name: "gitlabhq", path: "gitlabhq", creator_id: 1}, - { id: 9, namespace_id: 99, name: "gitlab-ci", path: "gitlab-ci", creator_id: 1}, - { id: 10, namespace_id: 99, name: "gitlab-recipes", path: "gitlab-recipes", creator_id: 1}, -]) + project_path.gsub!(".git", "") + + params = { + import_url: url, + namespace_id: group.id, + name: project_path.titleize + } + + project = Projects::CreateContext.new(User.first, params).execute + + if project.valid? + print '.' + else + puts project.errors.full_messages + print 'F' + end +end diff --git a/db/fixtures/development/05_users.rb b/db/fixtures/development/05_users.rb index abcb0259618..cbb3e636acc 100644 --- a/db/fixtures/development/05_users.rb +++ b/db/fixtures/development/05_users.rb @@ -1,5 +1,5 @@ Gitlab::Seeder.quiet do - (2..300).each do |i| + (2..50).each do |i| begin User.seed(:id, [{ id: i, diff --git a/db/fixtures/development/06_teams.rb b/db/fixtures/development/06_teams.rb index f82977d7fdc..a1e01879db5 100644 --- a/db/fixtures/development/06_teams.rb +++ b/db/fixtures/development/06_teams.rb @@ -1,14 +1,23 @@ ActiveRecord::Base.observers.disable :all Gitlab::Seeder.quiet do - Project.all.each do |project| - project.team << [User.first, :master] - print '.' + Group.all.each do |group| + User.all.sample(4).each do |user| + if group.add_users([user.id], UsersGroup.group_access_roles.values.sample) + print '.' + else + print 'F' + end + end + end - User.all.sample(rand(10)).each do |user| - role = [:master, :developer, :reporter].sample - project.team << [user, role] - print '.' + Project.all.each do |project| + User.all.sample(4).each do |user| + if project.team << [user, UsersProject.access_roles.values.sample] + print '.' + else + print 'F' + end end end end diff --git a/db/fixtures/development/09_issues.rb b/db/fixtures/development/09_issues.rb index d13d520e3dd..32c1139521f 100644 --- a/db/fixtures/development/09_issues.rb +++ b/db/fixtures/development/09_issues.rb @@ -11,7 +11,6 @@ Gitlab::Seeder.quiet do next unless user user_id = user.id - IssueObserver.current_user = user Issue.seed(:id, [{ id: i, diff --git a/db/fixtures/development/10_merge_requests.rb b/db/fixtures/development/10_merge_requests.rb index d122d96235e..0a9f986818f 100644 --- a/db/fixtures/development/10_merge_requests.rb +++ b/db/fixtures/development/10_merge_requests.rb @@ -17,7 +17,6 @@ Gitlab::Seeder.quiet do next if branches.uniq.size < 2 user_id = user.id - MergeRequestObserver.current_user = user MergeRequest.seed(:id, [{ id: i, source_branch: branches.first, -- cgit v1.2.1 From 2864aca48c11d4f50471b988d9f11fec7b8f825b Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 20 Jun 2013 13:29:17 +0300 Subject: Fix admin:groups test --- app/views/admin/groups/show.html.haml | 2 +- features/steps/admin/admin_groups.rb | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/views/admin/groups/show.html.haml b/app/views/admin/groups/show.html.haml index bec9b0c650b..56a32db59b6 100644 --- a/app/views/admin/groups/show.html.haml +++ b/app/views/admin/groups/show.html.haml @@ -83,7 +83,7 @@ Users from #{@group.name} Group %small (#{@group.users_groups.count}) - %ul.well-list + %ul.well-list.group-users-list - @group.users_groups.order('group_access DESC').each do |member| - user = member.user %li{class: dom_class(user)} diff --git a/features/steps/admin/admin_groups.rb b/features/steps/admin/admin_groups.rb index 2f98b8100dc..c463d379d78 100644 --- a/features/steps/admin/admin_groups.rb +++ b/features/steps/admin/admin_groups.rb @@ -43,13 +43,16 @@ class AdminGroups < Spinach::FeatureSteps user = User.find_by_name("John") select2(user.id, from: "#user_ids", multiple: true) within "#new_team_member" do - select "Reporter", from: "project_access" + select "Reporter", from: "group_access" end click_button "Add users into group" end Then 'I should see "John" in team list in every project as "Reporter"' do - user = User.find_by_name("John") + within ".group-users-list" do + page.should have_content "John" + page.should have_content "Reporter" + end end protected -- cgit v1.2.1 From 4d149ac8a9103f5249eb8641879b8643304723a0 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 20 Jun 2013 15:59:39 +0300 Subject: Dark color for group name at header. Better name for activity --- app/assets/stylesheets/sections/header.scss | 5 ++++- app/views/users/show.html.haml | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/sections/header.scss b/app/assets/stylesheets/sections/header.scss index e315b4ebcaa..46a5a489958 100644 --- a/app/assets/stylesheets/sections/header.scss +++ b/app/assets/stylesheets/sections/header.scss @@ -155,7 +155,10 @@ header { } .project_name { a { - color: #FFF; + color: #DDD; + &:hover { + color: #FFF; + } } color: #fff; text-shadow: 0 1px 1px #444; diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index 10bd90b166a..80c83a98b2f 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -14,7 +14,7 @@ %small member since #{@user.created_at.stamp("Nov 12, 2031")} .clearfix %hr - %h5 Recent events + %h5 User Activity: = render @events .span4 = render 'profile', user: @user -- cgit v1.2.1 From 1ecdfb46a46a1725c47df33c786f1d059a2ab97e Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 21 Jun 2013 08:51:15 +0300 Subject: Fix spell error in sing in --- app/views/devise/sessions/new.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/devise/sessions/new.html.haml b/app/views/devise/sessions/new.html.haml index 241133662fb..fe2134d62fa 100644 --- a/app/views/devise/sessions/new.html.haml +++ b/app/views/devise/sessions/new.html.haml @@ -1,5 +1,5 @@ .login-box - %h3.page_title Sing in + %h3.page_title Sign in %br - if ldap_enabled? %ul.nav.nav-tabs -- cgit v1.2.1 From 7e4ee824ab4cfedba72e742331536a6e207f7f2d Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 21 Jun 2013 09:19:31 +0300 Subject: Better name for sign in tab --- app/views/devise/sessions/new.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/devise/sessions/new.html.haml b/app/views/devise/sessions/new.html.haml index fe2134d62fa..50452255860 100644 --- a/app/views/devise/sessions/new.html.haml +++ b/app/views/devise/sessions/new.html.haml @@ -6,7 +6,7 @@ %li.active = link_to 'LDAP', '#tab-ldap', 'data-toggle' => 'tab' %li - = link_to 'Ordinary', '#tab-signin', 'data-toggle' => 'tab' + = link_to 'Standard', '#tab-signin', 'data-toggle' => 'tab' .tab-content %div#tab-ldap.tab-pane.active = render partial: 'devise/sessions/new_ldap' -- cgit v1.2.1 From 2c482097fc8028ec9f96d268c42016720aaf9be8 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 21 Jun 2013 16:16:05 +0300 Subject: Remove invalid information from /u/:user page --- app/views/users/_projects.html.haml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/app/views/users/_projects.html.haml b/app/views/users/_projects.html.haml index 4bee2f0c8ff..9f1446c0317 100644 --- a/app/views/users/_projects.html.haml +++ b/app/views/users/_projects.html.haml @@ -9,12 +9,3 @@ \/ %strong.well-title = truncate(project.name, length: 45) - %span.pull-right.light - - if project.owner == user - %i.icon-wrench - - tm = project.team.get_tm(user.id) - - if tm - = tm.project_access_human -%p.light - %i.icon-wrench - – user is a project owner -- cgit v1.2.1 From b1dbabdec30d8e03afb0155b9494cfe2ef351352 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 21 Jun 2013 16:36:28 +0300 Subject: Improve query of authorized_projects. Cache results for authorized_groups, authorized_projects methods --- app/models/user.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 8efae30f35e..2944b332dd8 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -88,6 +88,7 @@ class User < ActiveRecord::Base has_many :assigned_issues, dependent: :destroy, foreign_key: :assignee_id, class_name: "Issue" has_many :assigned_merge_requests, dependent: :destroy, foreign_key: :assignee_id, class_name: "MergeRequest" + has_many :groups_projects, through: :groups, source: :projects has_many :personal_projects, through: :namespace, source: :projects has_many :projects, through: :users_projects has_many :master_projects, through: :users_projects, source: :project, @@ -233,15 +234,19 @@ class User < ActiveRecord::Base # Groups user has access to def authorized_groups - @group_ids ||= (groups.pluck(:id) + own_groups.pluck(:id) + authorized_projects.pluck(:namespace_id)) - Group.where(id: @group_ids) + @authorized_groups ||= begin + group_ids = (groups.pluck(:id) + own_groups.pluck(:id) + authorized_projects.pluck(:namespace_id)) + Group.where(id: group_ids) + end end # Projects user has access to def authorized_projects - @project_ids ||= (owned_projects.pluck(:id) + groups.map(&:projects).flatten.map(&:id) + projects.pluck(:id)).uniq - Project.where(id: @project_ids) + @authorized_projects ||= begin + project_ids = (owned_projects.pluck(:id) + groups_projects.pluck(:id) + projects.pluck(:id)).uniq + Project.where(id: project_ids).includes(:namespace) + end end # Team membership in authorized projects -- cgit v1.2.1 From d0efe2c07cdbd13698bfb70f9be7157ec4f7245b Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 21 Jun 2013 16:42:59 +0300 Subject: Since masters_projects does not cover most of cases now we use authorized_projects for DeployKey read access --- app/models/user.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 2944b332dd8..ddea2da53e8 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -91,8 +91,6 @@ class User < ActiveRecord::Base has_many :groups_projects, through: :groups, source: :projects has_many :personal_projects, through: :namespace, source: :projects has_many :projects, through: :users_projects - has_many :master_projects, through: :users_projects, source: :project, - conditions: { users_projects: { project_access: UsersProject::MASTER } } has_many :own_projects, foreign_key: :creator_id, class_name: 'Project' has_many :owned_projects, through: :namespaces, source: :projects @@ -355,7 +353,7 @@ class User < ActiveRecord::Base end def accessible_deploy_keys - DeployKey.in_projects(self.master_projects).uniq + DeployKey.in_projects(self.authorized_projects).uniq end def created_by -- cgit v1.2.1 From 8c918e583a5a0ec4c0c904522730215b2d147ae6 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 21 Jun 2013 21:50:34 +0300 Subject: Remove tests for missing method --- spec/models/user_spec.rb | 7 ------- 1 file changed, 7 deletions(-) diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 4c37a48c4d1..f8b788a5f63 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -128,13 +128,6 @@ describe User do it { @user.personal_projects.should include(@project) } it { @user.personal_projects.should_not include(@project_2) } it { @user.personal_projects.should_not include(@project_3) } - - # master_projects doesn't check creator/namespace. - # In real case the users_projects relation will certainly be assigned - # when the project is created. - it { @user.master_projects.should_not include(@project) } - it { @user.master_projects.should include(@project_2) } - it { @user.master_projects.should_not include(@project_3) } end describe 'groups' do -- cgit v1.2.1 From c78393ec1714daaa01313793cdc3fa2e98378d7a Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 21 Jun 2013 22:08:16 +0300 Subject: Remove $.ready events --- app/views/compare/_form.html.haml | 14 ++++++-------- app/views/layouts/_init_auto_complete.html.haml | 8 +++----- app/views/merge_requests/_form.html.haml | 22 ++++++++++------------ app/views/milestones/_form.html.haml | 12 +++++------- app/views/search/_result.html.haml | 4 +--- 5 files changed, 25 insertions(+), 35 deletions(-) diff --git a/app/views/compare/_form.html.haml b/app/views/compare/_form.html.haml index ef80cd4ac90..ccdd0fc98eb 100644 --- a/app/views/compare/_form.html.haml +++ b/app/views/compare/_form.html.haml @@ -27,13 +27,11 @@ :javascript - $(function() { - var availableTags = #{@project.repository.ref_names.to_json}; + var availableTags = #{@project.repository.ref_names.to_json}; - $("#from, #to").autocomplete({ - source: availableTags, - minLength: 1 - }); - - disableButtonIfEmptyField('#to', '.commits-compare-btn'); + $("#from, #to").autocomplete({ + source: availableTags, + minLength: 1 }); + + disableButtonIfEmptyField('#to', '.commits-compare-btn'); diff --git a/app/views/layouts/_init_auto_complete.html.haml b/app/views/layouts/_init_auto_complete.html.haml index 3549794b90d..7d16a75af6e 100644 --- a/app/views/layouts/_init_auto_complete.html.haml +++ b/app/views/layouts/_init_auto_complete.html.haml @@ -1,6 +1,4 @@ :javascript - $(function() { - GitLab.GfmAutoComplete.dataSource = "#{autocomplete_sources_project_path(@project)}" - GitLab.GfmAutoComplete.Emoji.assetBase = '#{image_path("emoji")}' - GitLab.GfmAutoComplete.setup(); - }); + GitLab.GfmAutoComplete.dataSource = "#{autocomplete_sources_project_path(@project)}" + GitLab.GfmAutoComplete.Emoji.assetBase = '#{image_path("emoji")}' + GitLab.GfmAutoComplete.setup(); diff --git a/app/views/merge_requests/_form.html.haml b/app/views/merge_requests/_form.html.haml index 1c3aca176ab..24e66249aeb 100644 --- a/app/views/merge_requests/_form.html.haml +++ b/app/views/merge_requests/_form.html.haml @@ -62,20 +62,18 @@ Cancel :javascript - $(function(){ - disableButtonIfEmptyField("#merge_request_title", ".btn-save"); + disableButtonIfEmptyField("#merge_request_title", ".btn-save"); - var source_branch = $("#merge_request_source_branch") - , target_branch = $("#merge_request_target_branch"); + var source_branch = $("#merge_request_source_branch") + , target_branch = $("#merge_request_target_branch"); - $.get("#{branch_from_project_merge_requests_path(@project)}", {ref: source_branch.val() }); - $.get("#{branch_to_project_merge_requests_path(@project)}", {ref: target_branch.val() }); + $.get("#{branch_from_project_merge_requests_path(@project)}", {ref: source_branch.val() }); + $.get("#{branch_to_project_merge_requests_path(@project)}", {ref: target_branch.val() }); - source_branch.live("change", function() { - $.get("#{branch_from_project_merge_requests_path(@project)}", {ref: $(this).val() }); - }); + source_branch.live("change", function() { + $.get("#{branch_from_project_merge_requests_path(@project)}", {ref: $(this).val() }); + }); - target_branch.live("change", function() { - $.get("#{branch_to_project_merge_requests_path(@project)}", {ref: $(this).val() }); - }); + target_branch.live("change", function() { + $.get("#{branch_to_project_merge_requests_path(@project)}", {ref: $(this).val() }); }); diff --git a/app/views/milestones/_form.html.haml b/app/views/milestones/_form.html.haml index fbaf64a305c..50e3e71b2c3 100644 --- a/app/views/milestones/_form.html.haml +++ b/app/views/milestones/_form.html.haml @@ -40,10 +40,8 @@ :javascript - $(function() { - disableButtonIfEmptyField("#milestone_title", ".btn-save"); - $( ".datepicker" ).datepicker({ - dateFormat: "yy-mm-dd", - onSelect: function(dateText, inst) { $("#milestone_due_date").val(dateText) } - }).datepicker("setDate", $.datepicker.parseDate('yy-mm-dd', $('#milestone_due_date').val())); - }); + disableButtonIfEmptyField("#milestone_title", ".btn-save"); + $( ".datepicker" ).datepicker({ + dateFormat: "yy-mm-dd", + onSelect: function(dateText, inst) { $("#milestone_due_date").val(dateText) } + }).datepicker("setDate", $.datepicker.parseDate('yy-mm-dd', $('#milestone_due_date').val())); diff --git a/app/views/search/_result.html.haml b/app/views/search/_result.html.haml index 4d8caa5e70c..4e56eea084e 100644 --- a/app/views/search/_result.html.haml +++ b/app/views/search/_result.html.haml @@ -49,7 +49,5 @@ = paginate @blobs, theme: 'gitlab' :javascript - $(function() { - $(".search_results .term").highlight("#{escape_javascript(params[:search])}"); - }) + $(".search_results .term").highlight("#{escape_javascript(params[:search])}"); -- cgit v1.2.1 From c3c849927d42c4ba5431b3970dab63fdb89b77f5 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 21 Jun 2013 22:29:30 +0300 Subject: Unbind note events to prevent firing twice with turbolinks --- app/assets/javascripts/notes.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/notes.js b/app/assets/javascripts/notes.js index f5005ec2c94..e0715f45417 100644 --- a/app/assets/javascripts/notes.js +++ b/app/assets/javascripts/notes.js @@ -1,5 +1,5 @@ var NoteList = { - + id: null, notes_path: null, target_params: null, target_id: 0, @@ -16,6 +16,16 @@ var NoteList = { // get initial set of notes NoteList.getContent(); + // Unbind events to prevent firing twice + $(document).off("click", ".js-add-diff-note-button"); + $(document).off("click", ".js-discussion-reply-button"); + $(document).off("click", ".js-note-preview-button"); + $(document).off("click", ".js-note-attachment-input"); + $(document).off("click", ".js-close-discussion-note-form"); + $(document).off("click", ".js-note-delete"); + $(document).off("ajax:complete", ".js-main-target-form"); + + // add a new diff note $(document).on("click", ".js-add-diff-note-button", -- cgit v1.2.1 From be26d2724bc710bdc0cb2327830aff84ce61fba2 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 21 Jun 2013 22:34:38 +0300 Subject: Unbind all document.on click/scroll after page fetch --- app/assets/javascripts/main.js.coffee | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/main.js.coffee b/app/assets/javascripts/main.js.coffee index fd7e296efde..59dfab8f35b 100644 --- a/app/assets/javascripts/main.js.coffee +++ b/app/assets/javascripts/main.js.coffee @@ -50,11 +50,13 @@ window.startSpinner = -> window.stopSpinner = -> $('.turbolink-spinner').fadeOut() -window.stopEndlessScroll = -> +window.unbindEvents = -> $(document).unbind('scroll') + $(document).off('scroll') + $(document).off('click') document.addEventListener("page:fetch", startSpinner) -document.addEventListener("page:fetch", stopEndlessScroll) +document.addEventListener("page:fetch", unbindEvents) document.addEventListener("page:receive", stopSpinner) $ -> -- cgit v1.2.1 From 0273b79b92fb38086f14f2a44e621c37c35cc748 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 21 Jun 2013 22:38:43 +0300 Subject: User#owned_groups is now respect group membership --- app/models/user.rb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index ddea2da53e8..30f5aae0b56 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -74,6 +74,8 @@ class User < ActiveRecord::Base # Groups has_many :own_groups, class_name: "Group", foreign_key: :owner_id + has_many :owned_groups, through: :users_groups, source: :group, conditions: { users_groups: { group_access: UsersGroup::OWNER } } + has_many :users_groups, dependent: :destroy has_many :groups, through: :users_groups @@ -225,11 +227,6 @@ class User < ActiveRecord::Base end end - # Groups where user is an owner - def owned_groups - own_groups - end - # Groups user has access to def authorized_groups @authorized_groups ||= begin -- cgit v1.2.1 From e8e9e0f771c34cf45e9c42f69de4da6b747f07e0 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 21 Jun 2013 22:44:40 +0300 Subject: Use own abilities for namespace class --- app/models/ability.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/app/models/ability.rb b/app/models/ability.rb index 7e8d14ab10d..0b77564adc6 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -10,7 +10,8 @@ class Ability when "ProjectSnippet" then project_snippet_abilities(user, subject) when "PersonalSnippet" then personal_snippet_abilities(user, subject) when "MergeRequest" then merge_request_abilities(user, subject) - when "Group", "Namespace" then group_abilities(user, subject) + when "Group" then group_abilities(user, subject) + when "Namespace" then namespace_abilities(user, subject) else [] end.concat(global_abilities(user)) end @@ -144,6 +145,19 @@ class Ability rules.flatten end + def namespace_abilities user, namespace + rules = [] + + # Only namespace owner and administrators can manage it + if namespace.owner == user || user.admin? + rules << [ + :manage_namespace + ] + end + + rules.flatten + end + [:issue, :note, :project_snippet, :personal_snippet, :merge_request].each do |name| define_method "#{name}_abilities" do |user, subject| if subject.author == user -- cgit v1.2.1 From 7384541b345169a829c4c9f2b63bf71fd223d9b9 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 21 Jun 2013 22:47:49 +0300 Subject: Do not create a User <-> Project relation if project is under group --- app/contexts/projects/create_context.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/contexts/projects/create_context.rb b/app/contexts/projects/create_context.rb index 4045fe15a1d..a8c8effa79e 100644 --- a/app/contexts/projects/create_context.rb +++ b/app/contexts/projects/create_context.rb @@ -58,7 +58,7 @@ module Projects end end - if @project.save + if @project.save && !@project.group @project.users_projects.create(project_access: UsersProject::MASTER, user: current_user) end -- cgit v1.2.1 From f0606451194db37f897f2f487f8ab855271674a5 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 21 Jun 2013 23:17:20 +0300 Subject: Add notification level to group membership --- db/migrate/20130621195223_add_notification_level_to_user_group.rb | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 db/migrate/20130621195223_add_notification_level_to_user_group.rb diff --git a/db/migrate/20130621195223_add_notification_level_to_user_group.rb b/db/migrate/20130621195223_add_notification_level_to_user_group.rb new file mode 100644 index 00000000000..8c2e3dfcaca --- /dev/null +++ b/db/migrate/20130621195223_add_notification_level_to_user_group.rb @@ -0,0 +1,5 @@ +class AddNotificationLevelToUserGroup < ActiveRecord::Migration + def change + add_column :users_groups, :notification_level, :integer, null: false, default: 3 + end +end -- cgit v1.2.1 From f3cbbfe020678d6734573bc3f21b53f8c2668070 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 21 Jun 2013 23:17:41 +0300 Subject: Notifiable concern --- app/models/concerns/notifiable.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 app/models/concerns/notifiable.rb diff --git a/app/models/concerns/notifiable.rb b/app/models/concerns/notifiable.rb new file mode 100644 index 00000000000..722f375e71d --- /dev/null +++ b/app/models/concerns/notifiable.rb @@ -0,0 +1,15 @@ +# == Notifiable concern +# +# Contains notification functionality shared between UsersProject and UsersGroup +# +module Notifiable + extend ActiveSupport::Concern + + included do + validates :notification_level, inclusion: { in: Notification.project_notification_levels }, presence: true + end + + def notification + @notification ||= Notification.new(self) + end +end -- cgit v1.2.1 From fe514b17ab6de8c9d1f091e50e94aaf27183aa6d Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 21 Jun 2013 23:17:58 +0300 Subject: Adding groups to notification settings --- app/controllers/notifications_controller.rb | 5 ++++ app/models/users_group.rb | 2 ++ app/models/users_project.rb | 6 +--- app/services/notification_service.rb | 17 ++++++++---- app/views/notifications/_settings.html.haml | 29 +++++++++++++++++++ app/views/notifications/show.html.haml | 43 +++++++++-------------------- db/schema.rb | 13 +++++---- 7 files changed, 68 insertions(+), 47 deletions(-) create mode 100644 app/views/notifications/_settings.html.haml diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 4aa3172912f..370bdaa2fa1 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -4,6 +4,7 @@ class NotificationsController < ApplicationController def show @notification = current_user.notification @users_projects = current_user.users_projects + @users_groups = current_user.users_groups end def update @@ -12,6 +13,10 @@ class NotificationsController < ApplicationController @saved = if type == 'global' current_user.notification_level = params[:notification_level] current_user.save + elsif type == 'group' + users_group = current_user.users_groups.find(params[:notification_id]) + users_group.notification_level = params[:notification_level] + users_group.save else users_project = current_user.users_projects.find(params[:notification_id]) users_project.notification_level = params[:notification_level] diff --git a/app/models/users_group.rb b/app/models/users_group.rb index d70f56f681f..b334066b8c8 100644 --- a/app/models/users_group.rb +++ b/app/models/users_group.rb @@ -11,6 +11,8 @@ # class UsersGroup < ActiveRecord::Base + include Notifiable + GUEST = 10 REPORTER = 20 DEVELOPER = 30 diff --git a/app/models/users_project.rb b/app/models/users_project.rb index 58d05fbe077..a982b16575f 100644 --- a/app/models/users_project.rb +++ b/app/models/users_project.rb @@ -13,6 +13,7 @@ class UsersProject < ActiveRecord::Base include Gitlab::ShellAdapter + include Notifiable GUEST = 10 REPORTER = 20 @@ -30,7 +31,6 @@ class UsersProject < ActiveRecord::Base validates :user_id, uniqueness: { scope: [:project_id], message: "already exists in project" } validates :project_access, inclusion: { in: [GUEST, REPORTER, DEVELOPER, MASTER] }, presence: true validates :project, presence: true - validates :notification_level, inclusion: { in: Notification.project_notification_levels }, presence: true delegate :name, :username, :email, to: :user, prefix: true @@ -134,8 +134,4 @@ class UsersProject < ActiveRecord::Base def skip_git? !!@skip_git end - - def notification - @notification ||= Notification.new(self) - end end diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index 379d2c54629..1a999a6c8e6 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -148,13 +148,18 @@ class NotificationService # Get project users with WATCH notification level def project_watchers(project) - # Get project notification settings since it has higher priority - user_ids = project.users_projects.where(notification_level: Notification::N_WATCH).pluck(:user_id) - project_watchers = User.where(id: user_ids) + member_methods = [:users_projects] + member_methods << :users_groups if project.group - # next collect users who use global settings with watch state - user_ids = project.users_projects.where(notification_level: Notification::N_GLOBAL).pluck(:user_id) - project_watchers += User.where(id: user_ids, notification_level: Notification::N_WATCH) + member_methods.each do |member_method| + # Get project notification settings since it has higher priority + user_ids = project.send(member_method).where(notification_level: Notification::N_WATCH).pluck(:user_id) + project_watchers = User.where(id: user_ids) + + # next collect users who use global settings with watch state + user_ids = project.send(member_method).where(notification_level: Notification::N_GLOBAL).pluck(:user_id) + project_watchers += User.where(id: user_ids, notification_level: Notification::N_WATCH) + end project_watchers.uniq end diff --git a/app/views/notifications/_settings.html.haml b/app/views/notifications/_settings.html.haml new file mode 100644 index 00000000000..1a4a4a9f916 --- /dev/null +++ b/app/views/notifications/_settings.html.haml @@ -0,0 +1,29 @@ +%li + .row + .span4 + %span + - if membership.kind_of? UsersGroup + = link_to membership.group.name, membership.group + - else + = link_to_project(membership.project) + .span7 + = form_tag profile_notifications_path, method: :put, remote: true, class: 'update-notifications' do + = hidden_field_tag :notification_type, type, id: dom_id(membership, 'notification_type') + = hidden_field_tag :notification_id, membership.id, id: dom_id(membership, 'notification_id') + + = label_tag do + = radio_button_tag :notification_level, Notification::N_GLOBAL, notification.global?, id: dom_id(membership, 'notification_level'), class: 'trigger-submit' + %span Use global setting + + = label_tag do + = radio_button_tag :notification_level, Notification::N_DISABLED, notification.disabled?, id: dom_id(membership, 'notification_level'), class: 'trigger-submit' + %span Disabled + + = label_tag do + = radio_button_tag :notification_level, Notification::N_PARTICIPATING, notification.participating?, id: dom_id(membership, 'notification_level'), class: 'trigger-submit' + %span Participating + + = label_tag do + = radio_button_tag :notification_level, Notification::N_WATCH, notification.watch?, id: dom_id(membership, 'notification_level'), class: 'trigger-submit' + %span Watch + diff --git a/app/views/notifications/show.html.haml b/app/views/notifications/show.html.haml index b7f39306fd8..f4ac48255f4 100644 --- a/app/views/notifications/show.html.haml +++ b/app/views/notifications/show.html.haml @@ -36,36 +36,19 @@ = link_to '#', class: 'js-toggle-visibility-link' do %h6.btn.btn-tiny %i.icon-chevron-down - %span Per project notifications setting - -%ul.well-list.js-toggle-visibility-container.hide - - @users_projects.each do |users_project| - - notification = Notification.new(users_project) - %li - .row - .span4 - %span - = link_to_project(users_project.project) - .span7 - = form_tag profile_notifications_path, method: :put, remote: true, class: 'update-notifications' do - = hidden_field_tag :notification_type, 'project', id: dom_id(users_project, 'notification_type') - = hidden_field_tag :notification_id, users_project.id, id: dom_id(users_project, 'notification_id') - - = label_tag do - = radio_button_tag :notification_level, Notification::N_GLOBAL, notification.global?, id: dom_id(users_project, 'notification_level'), class: 'trigger-submit' - %span Use global setting - - = label_tag do - = radio_button_tag :notification_level, Notification::N_DISABLED, notification.disabled?, id: dom_id(users_project, 'notification_level'), class: 'trigger-submit' - %span Disabled - - = label_tag do - = radio_button_tag :notification_level, Notification::N_PARTICIPATING, notification.participating?, id: dom_id(users_project, 'notification_level'), class: 'trigger-submit' - %span Participating - - = label_tag do - = radio_button_tag :notification_level, Notification::N_WATCH, notification.watch?, id: dom_id(users_project, 'notification_level'), class: 'trigger-submit' - %span Watch + %span Advanced notifications settings +.js-toggle-visibility-container.hide + %h5 Groups: + %ul.well-list + - @users_groups.each do |users_group| + - notification = Notification.new(users_group) + = render 'settings', type: 'project', membership: users_group, notification: notification + + %h5 Projects: + %ul.well-list + - @users_projects.each do |users_project| + - notification = Notification.new(users_project) + = render 'settings', type: 'project', membership: users_project, notification: notification .save-status-fixed diff --git a/db/schema.rb b/db/schema.rb index 415e9723456..500828a97e2 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20130617095603) do +ActiveRecord::Schema.define(:version => 20130621195223) do create_table "deploy_keys_projects", :force => true do |t| t.integer "deploy_key_id", :null => false @@ -301,11 +301,12 @@ ActiveRecord::Schema.define(:version => 20130617095603) do add_index "users", ["username"], :name => "index_users_on_username" create_table "users_groups", :force => true do |t| - t.integer "group_access", :null => false - t.integer "group_id", :null => false - t.integer "user_id", :null => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.integer "group_access", :null => false + t.integer "group_id", :null => false + t.integer "user_id", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "notification_level", :default => 3, :null => false end create_table "users_projects", :force => true do |t| -- cgit v1.2.1 From 99eb96075dbfc87d401e544888dfe718711e0a84 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 21 Jun 2013 23:19:30 +0300 Subject: You can setup per-group notification level --- app/views/notifications/show.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/notifications/show.html.haml b/app/views/notifications/show.html.haml index f4ac48255f4..069747097c5 100644 --- a/app/views/notifications/show.html.haml +++ b/app/views/notifications/show.html.haml @@ -42,7 +42,7 @@ %ul.well-list - @users_groups.each do |users_group| - notification = Notification.new(users_group) - = render 'settings', type: 'project', membership: users_group, notification: notification + = render 'settings', type: 'group', membership: users_group, notification: notification %h5 Projects: %ul.well-list -- cgit v1.2.1 From 3208dad1e7e0c1eeb638e5a2779a290ed9c3e73a Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 21 Jun 2013 23:21:55 +0300 Subject: Respect group membership in notification service --- app/services/notification_service.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index 1a999a6c8e6..ac2820ff2b1 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -174,6 +174,10 @@ class NotificationService tm = project.users_projects.find_by_user_id(user.id) + if !tm && project.group + tm = project.users_groups.find_by_user_id(user.id) + end + # reject users who globally disabled notification and has no membership next user.notification.disabled? unless tm -- cgit v1.2.1 From 4c9e47f6e054649eefd453089d1658b9508c16fc Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 21 Jun 2013 23:36:02 +0300 Subject: Fix notifications for group projects --- app/services/notification_service.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index ac2820ff2b1..ef8ecd6e37a 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -147,17 +147,17 @@ class NotificationService # Get project users with WATCH notification level def project_watchers(project) + project_watchers = [] + member_methods = { project => :users_projects } + member_methods.merge!(project.group => :users_groups) if project.group - member_methods = [:users_projects] - member_methods << :users_groups if project.group - - member_methods.each do |member_method| + member_methods.each do |object, member_method| # Get project notification settings since it has higher priority - user_ids = project.send(member_method).where(notification_level: Notification::N_WATCH).pluck(:user_id) - project_watchers = User.where(id: user_ids) + user_ids = object.send(member_method).where(notification_level: Notification::N_WATCH).pluck(:user_id) + project_watchers += User.where(id: user_ids) # next collect users who use global settings with watch state - user_ids = project.send(member_method).where(notification_level: Notification::N_GLOBAL).pluck(:user_id) + user_ids = object.send(member_method).where(notification_level: Notification::N_GLOBAL).pluck(:user_id) project_watchers += User.where(id: user_ids, notification_level: Notification::N_WATCH) end @@ -175,7 +175,7 @@ class NotificationService tm = project.users_projects.find_by_user_id(user.id) if !tm && project.group - tm = project.users_groups.find_by_user_id(user.id) + tm = project.group.users_groups.find_by_user_id(user.id) end # reject users who globally disabled notification and has no membership -- cgit v1.2.1 From ede746bf079dd45ac1e2f701e8a9019dba8e0417 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 21 Jun 2013 23:47:42 +0300 Subject: prevent document unbind since it breaks rails ujs --- app/assets/javascripts/main.js.coffee | 1 - app/controllers/groups_controller.rb | 2 +- app/controllers/users_groups_controller.rb | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/main.js.coffee b/app/assets/javascripts/main.js.coffee index 59dfab8f35b..b96ef65af93 100644 --- a/app/assets/javascripts/main.js.coffee +++ b/app/assets/javascripts/main.js.coffee @@ -53,7 +53,6 @@ window.stopSpinner = -> window.unbindEvents = -> $(document).unbind('scroll') $(document).off('scroll') - $(document).off('click') document.addEventListener("page:fetch", startSpinner) document.addEventListener("page:fetch", unbindEvents) diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index f44bc10cf39..416bfa77af0 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -1,6 +1,6 @@ class GroupsController < ApplicationController respond_to :html - before_filter :group, except: [:new, :create, :people] + before_filter :group, except: [:new, :create] # Authorize before_filter :authorize_read_group!, except: [:new, :create] diff --git a/app/controllers/users_groups_controller.rb b/app/controllers/users_groups_controller.rb index ebc79d621a4..9181f1683ae 100644 --- a/app/controllers/users_groups_controller.rb +++ b/app/controllers/users_groups_controller.rb @@ -21,7 +21,7 @@ class UsersGroupsController < ApplicationController @users_group.destroy respond_to do |format| - format.html { redirect_to people_group_path(@group), notice: 'User was successfully removed from group.' } + format.html { redirect_to people_group_path(@group), notice: 'User was successfully removed from group.' } format.js { render nothing: true } end end -- cgit v1.2.1 From fdf7fc044ae1666a0d7dfb9a0022c48dfa3d7231 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 22 Jun 2013 00:02:09 +0300 Subject: Make it possible to assign/mention users from group members --- app/controllers/projects_controller.rb | 2 +- app/views/merge_requests/_form.html.haml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 62b8e62eba9..fe450899b6f 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -101,7 +101,7 @@ class ProjectsController < ProjectResourceController @suggestions = { emojis: Emoji.names, issues: @project.issues.select([:id, :title, :description]), - members: @project.users.select([:username, :name]).order(:username) + members: @project.team.members.sort_by(&:username).map { |user| { username: user.username, name: user.name } } } respond_to do |format| diff --git a/app/views/merge_requests/_form.html.haml b/app/views/merge_requests/_form.html.haml index 24e66249aeb..b3da15608e4 100644 --- a/app/views/merge_requests/_form.html.haml +++ b/app/views/merge_requests/_form.html.haml @@ -40,12 +40,12 @@ = f.label :assignee_id do %i.icon-user Assign to - .input= f.select(:assignee_id, @project.users.alphabetically.collect {|p| [ p.name, p.id ] }, { include_blank: "Select user" }, {class: 'chosen span3'}) + .input= f.select(:assignee_id, @project.team.members.sort_by(&:name).map {|p| [ p.name, p.id ] }, { include_blank: "Select user" }, {class: 'chosen span3'}) .left = f.label :milestone_id do %i.icon-time Milestone - .input= f.select(:milestone_id, @project.milestones.active.all.collect {|p| [ p.title, p.id ] }, { include_blank: "Select milestone" }, {class: 'chosen'}) + .input= f.select(:milestone_id, @project.milestones.active.all.map {|p| [ p.title, p.id ] }, { include_blank: "Select milestone" }, {class: 'chosen'}) .control-group -- cgit v1.2.1 From 6577d3a49cf6f21b1e044339f9cb984a67e9fdab Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 22 Jun 2013 00:06:21 +0300 Subject: Markdown now support users from groups --- app/models/project.rb | 1 + lib/gitlab/markdown.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/project.rb b/app/models/project.rb index e1f135b54f7..f36385cf6b1 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -68,6 +68,7 @@ class Project < ActiveRecord::Base has_many :deploy_keys, through: :deploy_keys_projects delegate :name, to: :owner, allow_nil: true, prefix: true + delegate :members, to: :team, prefix: true # Validations validates :creator, presence: true diff --git a/lib/gitlab/markdown.rb b/lib/gitlab/markdown.rb index cea026f6182..e9c4df220c9 100644 --- a/lib/gitlab/markdown.rb +++ b/lib/gitlab/markdown.rb @@ -166,7 +166,7 @@ module Gitlab end def reference_user(identifier) - if member = @project.users_projects.joins(:user).where(users: { username: identifier }).first + if member = @project.team_members.find { |user| user.username == identifier } link_to("@#{identifier}", user_path(identifier), html_options.merge(class: "gfm gfm-team_member #{html_options[:class]}")) if member end end -- cgit v1.2.1 From dc0f08f8d807c363e082f9ada7a1addeefdb554d Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 22 Jun 2013 00:11:06 +0300 Subject: Show also group members on project page at admin area --- app/controllers/admin/projects_controller.rb | 1 + app/views/admin/projects/show.html.haml | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/app/controllers/admin/projects_controller.rb b/app/controllers/admin/projects_controller.rb index e73a54dd1a5..088174fd3b8 100644 --- a/app/controllers/admin/projects_controller.rb +++ b/app/controllers/admin/projects_controller.rb @@ -15,6 +15,7 @@ class Admin::ProjectsController < Admin::ApplicationController def show @repository = @project.repository + @group = @project.group end protected diff --git a/app/views/admin/projects/show.html.haml b/app/views/admin/projects/show.html.haml index 92b8960151e..5e6658508e1 100644 --- a/app/views/admin/projects/show.html.haml +++ b/app/views/admin/projects/show.html.haml @@ -74,6 +74,18 @@ %i.icon-lock Private .span6 + - if @group + .ui-box + %h5.title + %strong #{@group.name} Group + members (#{@group.users_groups.count}) + .pull-right + = link_to admin_group_path(@group), class: 'btn btn-small' do + %i.icon-edit + %ul.well-list + - @group.users_groups.order('group_access DESC').each do |member| + = render 'users_groups/users_group', member: member, show_controls: false + .ui-box %h5.title Team -- cgit v1.2.1 From 1dd6606161bea762cefe14c7a39f79a8c0b43dd7 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 22 Jun 2013 10:56:51 +0300 Subject: Send project transfer email to all members. Added specs for project move email --- app/mailers/emails/projects.rb | 8 ++++---- app/models/project.rb | 4 ++-- spec/mailers/notify_spec.rb | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/app/mailers/emails/projects.rb b/app/mailers/emails/projects.rb index dcd894bb8ef..1ad7ca588bd 100644 --- a/app/mailers/emails/projects.rb +++ b/app/mailers/emails/projects.rb @@ -8,10 +8,10 @@ module Emails end - def project_was_moved_email(user_project_id) - @users_project = UsersProject.find user_project_id - @project = @users_project.project - mail(to: @users_project.user.email, + def project_was_moved_email(project_id, user_id) + @user = User.find user_id + @project = Project.find project_id + mail(to: @user.email, subject: subject("project was moved")) end end diff --git a/app/models/project.rb b/app/models/project.rb index f36385cf6b1..c1405a70b39 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -246,8 +246,8 @@ class Project < ActiveRecord::Base end def send_move_instructions - self.users_projects.each do |member| - Notify.delay.project_was_moved_email(member.id) + team.members.each do |user| + Notify.delay.project_was_moved_email(self.id, user.id) end end diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb index d2e1e8a8743..7290e2b739d 100644 --- a/spec/mailers/notify_spec.rb +++ b/spec/mailers/notify_spec.rb @@ -218,6 +218,24 @@ describe Notify do end end + describe 'project was moved' do + let(:project) { create(:project) } + let(:user) { create(:user) } + subject { Notify.project_was_moved_email(project.id, user.id) } + + it 'has the correct subject' do + should have_subject /project was moved/ + end + + it 'contains name of project' do + should have_body_text /#{project.name_with_namespace}/ + end + + it 'contains new user role' do + should have_body_text /#{project.ssh_url_to_repo}/ + end + end + describe 'project access changed' do let(:project) { create(:project) } let(:user) { create(:user) } -- cgit v1.2.1 From 9de23248d8f3d6464d329b979ccfe98c23eb4aa3 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 22 Jun 2013 11:02:31 +0300 Subject: You should not be able to remove a Group owner --- app/controllers/users_groups_controller.rb | 2 +- app/views/users_groups/_users_group.html.haml | 2 +- lib/tasks/migrate/migrate_groups.rake | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 lib/tasks/migrate/migrate_groups.rake diff --git a/app/controllers/users_groups_controller.rb b/app/controllers/users_groups_controller.rb index 9181f1683ae..c30034d7d0e 100644 --- a/app/controllers/users_groups_controller.rb +++ b/app/controllers/users_groups_controller.rb @@ -18,7 +18,7 @@ class UsersGroupsController < ApplicationController def destroy @users_group = @group.users_groups.find(params[:id]) - @users_group.destroy + @users_group.destroy unless @users_group.user == @group.owner respond_to do |format| format.html { redirect_to people_group_path(@group), notice: 'User was successfully removed from group.' } diff --git a/app/views/users_groups/_users_group.html.haml b/app/views/users_groups/_users_group.html.haml index c6dca5f3425..3a1e32dd79d 100644 --- a/app/views/users_groups/_users_group.html.haml +++ b/app/views/users_groups/_users_group.html.haml @@ -13,6 +13,6 @@ - else = member.human_access - - if show_controls && user != current_user + - if show_controls && user != current_user && user != @group.owner = link_to group_users_group_path(@group, member), confirm: remove_user_from_group_message(@group, user), method: :delete, remote: true, class: "btn-tiny btn btn-remove", title: 'Remove user from group' do %i.icon-minus.icon-white diff --git a/lib/tasks/migrate/migrate_groups.rake b/lib/tasks/migrate/migrate_groups.rake new file mode 100644 index 00000000000..153172dc90a --- /dev/null +++ b/lib/tasks/migrate/migrate_groups.rake @@ -0,0 +1,16 @@ +desc "GITLAB | Migrate Gropus to match v6.0" +task migrate_groups: :environment do + puts "This will add group owners to group membership" + ask_to_continue + + Group.find_each(batch_size: 20) do |group| + begin + group.send :add_owner + print '.' + rescue => ex + puts ex.message + print 'F' + end + end +end + -- cgit v1.2.1 From 09daff61780a2fa391cf1a80bf152cca15740754 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 22 Jun 2013 11:38:47 +0300 Subject: Colors for author additions/develtions in graph --- .../javascripts/stat_graph_contributors.js.coffee | 32 ++++++++++++++++++---- app/assets/stylesheets/sections/graph.scss | 19 +++++++++++-- 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/stat_graph_contributors.js.coffee b/app/assets/javascripts/stat_graph_contributors.js.coffee index 12dfe4da841..6cf6f1f022a 100644 --- a/app/assets/javascripts/stat_graph_contributors.js.coffee +++ b/app/assets/javascripts/stat_graph_contributors.js.coffee @@ -19,7 +19,27 @@ class window.ContributorsStatGraph author_graph.draw() ) format_author_commit_info: (author) -> - author.commits + " commits " + author.additions + " ++ / " + author.deletions + " --" + commits = $('', { + class: 'graph-author-commits-count' + }) + commits.text(author.commits + " commits") + + additions = $('', { + class: 'graph-additions' + }) + additions.text(author.additions + " ++") + + deletions = $('', { + class: 'graph-deletions' + }) + deletions.text(author.deletions + " --") + + $('').append(commits) + .append(" / ") + .append(additions) + .append(" / ") + .append(deletions) + create_author_header: (author) -> list_item = $('
  • ', { class: 'person' @@ -30,7 +50,7 @@ class window.ContributorsStatGraph class: 'commits' }) author_commit_info = @format_author_commit_info(author) - author_commit_info_span.text(author_commit_info) + author_commit_info_span.html(author_commit_info) list_item.append(author_name) list_item.append(author_commit_info_span) list_item @@ -52,10 +72,10 @@ class window.ContributorsStatGraph @field = field change_date_header: -> x_domain = ContributorsGraph.prototype.x_domain - print_date_format = d3.time.format("%B %e %Y"); - print = print_date_format(x_domain[0]) + " - " + print_date_format(x_domain[1]); - $("#date_header").text(print); + print_date_format = d3.time.format("%B %e %Y") + print = print_date_format(x_domain[0]) + " - " + print_date_format(x_domain[1]) + $("#date_header").text(print) redraw_author_commit_info: (author) -> author_list_item = $(@authors[author.author].list_item) author_commit_info = @format_author_commit_info(author) - author_list_item.find("span").text(author_commit_info) \ No newline at end of file + author_list_item.find("span").html(author_commit_info) diff --git a/app/assets/stylesheets/sections/graph.scss b/app/assets/stylesheets/sections/graph.scss index 9be4cb788c1..dd5d638b721 100644 --- a/app/assets/stylesheets/sections/graph.scss +++ b/app/assets/stylesheets/sections/graph.scss @@ -1,15 +1,15 @@ -.graph_holder { +.graph_holder { border: 1px solid #aaa; padding: 1px; - h4 { + h4 { padding: 0 10px; border-bottom: 1px solid #bbb; @include bg-gray-gradient; } - .graph { + .graph { background: #f1f1f1; height: 500px; overflow-y: scroll; @@ -17,3 +17,16 @@ } } +.graphs { + .graph-author-commits-count { + } + + .graph-additions { + color: #4a2; + } + + .graph-deletions { + color: #d12f19; + } +} + -- cgit v1.2.1 From c2317d6785016918975d93c08d915055448d56cb Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 22 Jun 2013 12:57:05 +0300 Subject: cache project.team.members --- app/models/project_team.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/project_team.rb b/app/models/project_team.rb index 20c6690e80b..ad3ac10ed1f 100644 --- a/app/models/project_team.rb +++ b/app/models/project_team.rb @@ -57,7 +57,7 @@ class ProjectTeam end def members - fetch_members + @members ||= fetch_members end def guests -- cgit v1.2.1 From 19d628dd239f03e950a41c4498131f9b2a221909 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 22 Jun 2013 13:39:34 +0300 Subject: Set default order to authorized_project and authorized_groups --- app/models/project.rb | 2 +- app/models/user.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index c1405a70b39..4beba83df2c 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -100,7 +100,7 @@ class Project < ActiveRecord::Base scope :in_team, ->(team) { where("projects.id IN (:ids)", ids: team.projects.map(&:id)) } scope :in_namespace, ->(namespace) { where(namespace_id: namespace.id) } scope :in_group_namespace, -> { joins(:group) } - scope :sorted_by_activity, -> { order("projects.last_activity_at DESC") } + scope :sorted_by_activity, -> { reorder("projects.last_activity_at DESC") } scope :personal, ->(user) { where(namespace_id: user.namespace_id) } scope :joined, ->(user) { where("namespace_id != ?", user.namespace_id) } scope :public_only, -> { where(public: true) } diff --git a/app/models/user.rb b/app/models/user.rb index 30f5aae0b56..cf42d736058 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -231,7 +231,7 @@ class User < ActiveRecord::Base def authorized_groups @authorized_groups ||= begin group_ids = (groups.pluck(:id) + own_groups.pluck(:id) + authorized_projects.pluck(:namespace_id)) - Group.where(id: group_ids) + Group.where(id: group_ids).order('namespaces.name ASC') end end @@ -240,7 +240,7 @@ class User < ActiveRecord::Base def authorized_projects @authorized_projects ||= begin project_ids = (owned_projects.pluck(:id) + groups_projects.pluck(:id) + projects.pluck(:id)).uniq - Project.where(id: project_ids).includes(:namespace) + Project.where(id: project_ids).joins(:namespace).order('namespaces.name ASC') end end -- cgit v1.2.1 From 0bc714c271174137431d9194d8f1567953f97a8b Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 22 Jun 2013 13:41:08 +0300 Subject: Remove form for adding user to several projects from admin area. Remove unnecessary projects order on User#show --- app/controllers/admin/users_controller.rb | 5 ----- app/controllers/users_controller.rb | 2 +- app/views/admin/users/show.html.haml | 22 ---------------------- app/views/dashboard/projects.html.haml | 4 +++- spec/factories.rb | 1 + spec/features/admin/admin_users_spec.rb | 14 -------------- spec/models/user_spec.rb | 8 ++------ 7 files changed, 7 insertions(+), 49 deletions(-) diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index ec3209fdfe2..36c6f3af41c 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -9,11 +9,6 @@ class Admin::UsersController < Admin::ApplicationController end def show - # Projects user can be added to - @not_in_projects = Project.scoped - @not_in_projects = @not_in_projects.without_user(admin_user) if admin_user.authorized_projects.present? - - # Projects he already own or joined @projects = admin_user.authorized_projects end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 028af8ff59f..4947c33f959 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -3,7 +3,7 @@ class UsersController < ApplicationController def show @user = User.find_by_username!(params[:username]) - @projects = @user.authorized_projects.where('projects.id in (?)', current_user.authorized_projects.map(&:id)).order('namespace_id DESC') + @projects = @user.authorized_projects.where('projects.id in (?)', current_user.authorized_projects.map(&:id)) @events = @user.recent_events.where(project_id: @projects.map(&:id)).limit(20) @title = @user.name diff --git a/app/views/admin/users/show.html.haml b/app/views/admin/users/show.html.haml index b8fa41898d5..a95bc819a4d 100644 --- a/app/views/admin/users/show.html.haml +++ b/app/views/admin/users/show.html.haml @@ -63,28 +63,6 @@ %strong = link_to @admin_user.created_by.name, [:admin, @admin_user.created_by] - %hr - %h5 - Add User to Projects - %small - Read more about project permissions - %strong= link_to "here", help_permissions_path, class: "vlink" - %br - = form_tag team_update_admin_user_path(@admin_user), class: "bulk_import", method: :put do - .control-group - = label_tag :project_ids, "Projects", class: 'control-label' - .controls - = select_tag :project_ids, options_from_collection_for_select(@not_in_projects , :id, :name_with_namespace), multiple: true, data: {placeholder: 'Select projects'}, class: 'chosen span3' - .control-group - = label_tag :project_access, "Project Access", class: 'control-label' - .controls - = select_tag :project_access, options_for_select(Project.access_options), class: "project-access-select chosen span3" - - .form-actions - = submit_tag 'Add', class: "btn btn-create" - .pull-right - %br - - if @admin_user.owned_groups.present? .ui-box %h5.title Owned groups: diff --git a/app/views/dashboard/projects.html.haml b/app/views/dashboard/projects.html.haml index 683052eadaa..5c5fa528fab 100644 --- a/app/views/dashboard/projects.html.haml +++ b/app/views/dashboard/projects.html.haml @@ -24,6 +24,8 @@ .ui-box %h5.title Projects (#{@projects.total_count}) + .pull-right.light + %small Last activity %ul.well-list - @projects.each do |project| %li @@ -39,7 +41,7 @@ = truncate project.description, length: 80 .pull-right.light - %small Last activity #{project_last_activity(project)} + %small #{project_last_activity(project)} - if @projects.blank? %li diff --git a/spec/factories.rb b/spec/factories.rb index b596f80fa9e..b6ef87d4c2a 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -27,6 +27,7 @@ FactoryGirl.define do sequence(:name) { |n| "project#{n}" } path { name.downcase.gsub(/\s/, '_') } creator + namespace { creator.namespace } end factory :redmine_project, parent: :project do diff --git a/spec/features/admin/admin_users_spec.rb b/spec/features/admin/admin_users_spec.rb index 15de101a17a..2aaa4e97340 100644 --- a/spec/features/admin/admin_users_spec.rb +++ b/spec/features/admin/admin_users_spec.rb @@ -109,18 +109,4 @@ describe "Admin::Users" do end end end - - describe "Add new project" do - before do - @new_project = create(:project) - visit admin_user_path(@user) - end - - it "should create new user" do - select @new_project.name, from: "project_ids" - expect { click_button "Add" }.to change { UsersProject.count }.by(1) - page.should have_content @new_project.name - current_path.should == admin_user_path(@user) - end - end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index f8b788a5f63..92a371ede05 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -111,12 +111,8 @@ describe User do @project_2 = create :project # Grant MASTER access to the user @project_3 = create :project # Grant DEVELOPER access to the user - UsersProject.add_users_into_projects( - [@project_2.id], [@user.id], UsersProject::MASTER - ) - UsersProject.add_users_into_projects( - [@project_3.id], [@user.id], UsersProject::DEVELOPER - ) + @project_2.team << [@user, :master] + @project_3.team << [@user, :developer] end it { @user.authorized_projects.should include(@project) } -- cgit v1.2.1 From 59f75e6c1ec29721d1430e8dbcb5858a0ddb910a Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 22 Jun 2013 13:47:11 +0300 Subject: Remove unused accessor --- app/models/project_team.rb | 1 - app/models/users_project.rb | 8 -------- 2 files changed, 9 deletions(-) diff --git a/app/models/project_team.rb b/app/models/project_team.rb index ad3ac10ed1f..09b866376b1 100644 --- a/app/models/project_team.rb +++ b/app/models/project_team.rb @@ -92,7 +92,6 @@ class ProjectTeam new_tm = tm.dup new_tm.id = nil new_tm.project_id = target_project.id - new_tm.skip_git = true new_tm end diff --git a/app/models/users_project.rb b/app/models/users_project.rb index a982b16575f..45e9305cafb 100644 --- a/app/models/users_project.rb +++ b/app/models/users_project.rb @@ -25,8 +25,6 @@ class UsersProject < ActiveRecord::Base belongs_to :user belongs_to :project - attr_accessor :skip_git - validates :user, presence: true validates :user_id, uniqueness: { scope: [:project_id], message: "already exists in project" } validates :project_access, inclusion: { in: [GUEST, REPORTER, DEVELOPER, MASTER] }, presence: true @@ -77,7 +75,6 @@ class UsersProject < ActiveRecord::Base user_ids.each do |user_id| users_project = UsersProject.new(project_access: project_access, user_id: user_id) users_project.project_id = project_id - users_project.skip_git = true users_project.save end end @@ -92,7 +89,6 @@ class UsersProject < ActiveRecord::Base UsersProject.transaction do users_projects = UsersProject.where(project_id: project_ids) users_projects.each do |users_project| - users_project.skip_git = true users_project.destroy end end @@ -130,8 +126,4 @@ class UsersProject < ActiveRecord::Base end alias_method :human_access, :project_access_human - - def skip_git? - !!@skip_git - end end -- cgit v1.2.1 From ee13297af2706be438666a3761938423fc9a51db Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 22 Jun 2013 14:11:20 +0300 Subject: Cleanup: removed unused routing/methods. Improved admin area usability --- app/controllers/admin/groups_controller.rb | 10 ---------- .../admin/projects/members_controller.rb | 15 -------------- app/controllers/admin/users_controller.rb | 11 ----------- app/views/admin/groups/show.html.haml | 5 +++-- app/views/admin/projects/members/_form.html.haml | 16 --------------- app/views/admin/projects/members/edit.html.haml | 8 -------- app/views/admin/projects/show.html.haml | 16 +++++++++------ app/views/admin/users/show.html.haml | 23 ++++++++-------------- config/routes.rb | 11 +---------- 9 files changed, 22 insertions(+), 93 deletions(-) delete mode 100644 app/views/admin/projects/members/_form.html.haml delete mode 100644 app/views/admin/projects/members/edit.html.haml diff --git a/app/controllers/admin/groups_controller.rb b/app/controllers/admin/groups_controller.rb index 824eaca348f..949a3996040 100644 --- a/app/controllers/admin/groups_controller.rb +++ b/app/controllers/admin/groups_controller.rb @@ -44,16 +44,6 @@ class Admin::GroupsController < Admin::ApplicationController end end - def project_update - project_ids = params[:project_ids] - - Project.where(id: project_ids).each do |project| - project.transfer(@group) - end - - redirect_to :back, notice: 'Group was successfully updated.' - end - def project_teams_update @group.add_users(params[:user_ids].split(','), params[:group_access]) diff --git a/app/controllers/admin/projects/members_controller.rb b/app/controllers/admin/projects/members_controller.rb index d9c0d572bb1..c7546fb6d67 100644 --- a/app/controllers/admin/projects/members_controller.rb +++ b/app/controllers/admin/projects/members_controller.rb @@ -1,18 +1,4 @@ class Admin::Projects::MembersController < Admin::Projects::ApplicationController - def edit - @member = team_member - @project = project - @team_member_relation = team_member_relation - end - - def update - if team_member_relation.update_attributes(params[:team_member]) - redirect_to [:admin, project], notice: 'Project Access was successfully updated.' - else - render action: "edit" - end - end - def destroy team_member_relation.destroy @@ -28,5 +14,4 @@ class Admin::Projects::MembersController < Admin::Projects::ApplicationControlle def team_member_relation team_member.users_projects.find_by_project_id(project) end - end diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index 36c6f3af41c..16f8d9f225b 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -12,17 +12,6 @@ class Admin::UsersController < Admin::ApplicationController @projects = admin_user.authorized_projects end - def team_update - UsersProject.add_users_into_projects( - params[:project_ids], - [admin_user.id], - params[:project_access] - ) - - redirect_to [:admin, admin_user], notice: 'Teams were successfully updated.' - end - - def new @admin_user = User.new.with_defaults end diff --git a/app/views/admin/groups/show.html.haml b/app/views/admin/groups/show.html.haml index 56a32db59b6..977fac291f3 100644 --- a/app/views/admin/groups/show.html.haml +++ b/app/views/admin/groups/show.html.haml @@ -65,7 +65,7 @@ .span6 .ui-box %h5.title - Add user(s): + Add user(s) to the group: .ui-box-body.form-holder %p.light Read more about project permissions @@ -80,7 +80,8 @@ = submit_tag 'Add users into group', class: "btn btn-create" .ui-box %h5.title - Users from #{@group.name} Group + %strong #{@group.name} + Group Members %small (#{@group.users_groups.count}) %ul.well-list.group-users-list diff --git a/app/views/admin/projects/members/_form.html.haml b/app/views/admin/projects/members/_form.html.haml deleted file mode 100644 index 8041202980d..00000000000 --- a/app/views/admin/projects/members/_form.html.haml +++ /dev/null @@ -1,16 +0,0 @@ -= form_for @team_member_relation, as: :team_member, url: admin_project_member_path(@project, @member) do |f| - -if @team_member_relation.errors.any? - .alert.alert-error - %ul - - @team_member_relation.errors.full_messages.each do |msg| - %li= msg - - .clearfix - %label Project Access: - .input - = f.select :project_access, options_for_select(Project.access_options, @team_member_relation.project_access), {}, class: "project-access-select chosen span3" - - %br - .actions - = f.submit 'Save', class: "btn btn-primary" - = link_to 'Cancel', :back, class: "btn" diff --git a/app/views/admin/projects/members/edit.html.haml b/app/views/admin/projects/members/edit.html.haml deleted file mode 100644 index 2d76deb2aca..00000000000 --- a/app/views/admin/projects/members/edit.html.haml +++ /dev/null @@ -1,8 +0,0 @@ -%p.slead - Edit access for - = link_to @member.name, admin_user_path(@member) - in - = link_to @project.name_with_namespace, admin_project_path(@project) - -%hr -= render 'form' diff --git a/app/views/admin/projects/show.html.haml b/app/views/admin/projects/show.html.haml index 5e6658508e1..8779ec08870 100644 --- a/app/views/admin/projects/show.html.haml +++ b/app/views/admin/projects/show.html.haml @@ -91,12 +91,16 @@ Team %small (#{@project.users.count}) - = link_to project_team_index_path(@project), class: "btn btn-tiny" do - %i.icon-edit - Edit Team + .pull-right + = link_to project_team_index_path(@project), class: "btn btn-tiny" do + %i.icon-edit + Manage Access %ul.well-list.team_members - - @project.users.each do |tm| + - @project.users.each do |user| %li %strong - = link_to tm.name, admin_user_path(tm) - %span.pull-right.light= @project.project_access_human(tm) + = link_to user.name, admin_user_path(user) + .pull-right + %span.light= @project.project_access_human(user) + = link_to admin_project_member_path(@project, user), confirm: remove_from_project_team_message(@project, user), method: :delete, class: "btn btn-small btn-remove" do + %i.icon-remove diff --git a/app/views/admin/users/show.html.haml b/app/views/admin/users/show.html.haml index a95bc819a4d..d0d2cc7ff4d 100644 --- a/app/views/admin/users/show.html.haml +++ b/app/views/admin/users/show.html.haml @@ -63,15 +63,16 @@ %strong = link_to @admin_user.created_by.name, [:admin, @admin_user.created_by] - - if @admin_user.owned_groups.present? + - if @admin_user.users_groups.present? .ui-box - %h5.title Owned groups: + %h5.title Groups: %ul.well-list - - @admin_user.groups.each do |group| + - @admin_user.users_groups.each do |user_group| + - group = user_group.group %li %strong= link_to group.name, admin_group_path(group) - - + .pull-right + %span.light= user_group.human_access .span6 .ui-box @@ -87,16 +88,8 @@ %strong.well-title = truncate(project.name, length: 45) - - if project.owner == @admin_user - %span.label.label-info owner - - if tm .pull-right - = link_to edit_admin_project_member_path(project, tm.user), class: "btn grouped btn-small" do - %i.icon-edit - = link_to admin_project_member_path(project, tm.user), confirm: remove_from_project_team_message(project, @admin_user), method: :delete, class: "btn grouped btn-small btn-remove" do + %span.light= tm.human_access + = link_to admin_project_member_path(project, tm.user), confirm: remove_from_project_team_message(project, @admin_user), method: :delete, class: "btn btn-small btn-remove" do %i.icon-remove - - .pull-right.light - = tm.project_access_human -   diff --git a/config/routes.rb b/config/routes.rb index 1a3ea15a17a..1b184fcac0b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -76,16 +76,7 @@ Gitlab::Application.routes.draw do resources :groups, constraints: { id: /[^\/]+/ } do member do - put :project_update put :project_teams_update - delete :remove_project - end - end - - resources :teams, constraints: { id: /[^\/]+/ } do - scope module: :teams do - resources :members, only: [:edit, :update, :destroy, :new, :create] - resources :projects, only: [:edit, :update, :destroy, :new, :create], constraints: { id: /[a-zA-Z.\/0-9_\-]+/ } end end @@ -98,7 +89,7 @@ Gitlab::Application.routes.draw do resources :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }, only: [:index, :show] do scope module: :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ } do - resources :members, only: [:edit, :update, :destroy] + resources :members, only: [:destroy] end end -- cgit v1.2.1 From 9787c37aed0c934d9ae4f6786413eb25b55c3a17 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 22 Jun 2013 15:01:08 +0300 Subject: More db index --- db/migrate/20130622115340_add_more_db_index.rb | 12 ++++++++++++ db/schema.rb | 13 ++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20130622115340_add_more_db_index.rb diff --git a/db/migrate/20130622115340_add_more_db_index.rb b/db/migrate/20130622115340_add_more_db_index.rb new file mode 100644 index 00000000000..9570a7a3f1e --- /dev/null +++ b/db/migrate/20130622115340_add_more_db_index.rb @@ -0,0 +1,12 @@ +class AddMoreDbIndex < ActiveRecord::Migration + def change + add_index :deploy_keys_projects, :project_id + add_index :web_hooks, :project_id + add_index :protected_branches, :project_id + + add_index :users_groups, :user_id + add_index :snippets, :author_id + add_index :notes, :author_id + add_index :notes, [:noteable_id, :noteable_type] + end +end diff --git a/db/schema.rb b/db/schema.rb index ef9dcfcdcc0..4076c1b37d7 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20130621195223) do +ActiveRecord::Schema.define(:version => 20130622115340) do create_table "deploy_keys_projects", :force => true do |t| t.integer "deploy_key_id", :null => false @@ -20,6 +20,8 @@ ActiveRecord::Schema.define(:version => 20130621195223) do t.datetime "updated_at", :null => false end + add_index "deploy_keys_projects", ["project_id"], :name => "index_deploy_keys_projects_on_project_id" + create_table "events", :force => true do |t| t.string "target_type" t.integer "target_id" @@ -148,8 +150,10 @@ ActiveRecord::Schema.define(:version => 20130621195223) do t.integer "noteable_id" end + add_index "notes", ["author_id"], :name => "index_notes_on_author_id" add_index "notes", ["commit_id"], :name => "index_notes_on_commit_id" add_index "notes", ["created_at"], :name => "index_notes_on_created_at" + add_index "notes", ["noteable_id", "noteable_type"], :name => "index_notes_on_noteable_id_and_noteable_type" add_index "notes", ["noteable_type"], :name => "index_notes_on_noteable_type" add_index "notes", ["project_id", "noteable_type"], :name => "index_notes_on_project_id_and_noteable_type" add_index "notes", ["project_id"], :name => "index_notes_on_project_id" @@ -186,6 +190,8 @@ ActiveRecord::Schema.define(:version => 20130621195223) do t.datetime "updated_at", :null => false end + add_index "protected_branches", ["project_id"], :name => "index_protected_branches_on_project_id" + create_table "services", :force => true do |t| t.string "type" t.string "title" @@ -214,6 +220,7 @@ ActiveRecord::Schema.define(:version => 20130621195223) do t.string "type" end + add_index "snippets", ["author_id"], :name => "index_snippets_on_author_id" add_index "snippets", ["created_at"], :name => "index_snippets_on_created_at" add_index "snippets", ["expires_at"], :name => "index_snippets_on_expires_at" add_index "snippets", ["project_id"], :name => "index_snippets_on_project_id" @@ -310,6 +317,8 @@ ActiveRecord::Schema.define(:version => 20130621195223) do t.integer "notification_level", :default => 3, :null => false end + add_index "users_groups", ["user_id"], :name => "index_users_groups_on_user_id" + create_table "users_projects", :force => true do |t| t.integer "user_id", :null => false t.integer "project_id", :null => false @@ -332,4 +341,6 @@ ActiveRecord::Schema.define(:version => 20130621195223) do t.integer "service_id" end + add_index "web_hooks", ["project_id"], :name => "index_web_hooks_on_project_id" + end -- cgit v1.2.1 From edcd46599b8363c3447c07ae4dcf320af8bfd4c1 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 22 Jun 2013 15:04:49 +0300 Subject: Use simplified render syntax --- app/views/snippets/_snippets.html.haml | 2 +- app/views/wikis/edit.html.haml | 2 +- app/views/wikis/git_access.html.haml | 2 +- app/views/wikis/history.html.haml | 2 +- app/views/wikis/pages.html.haml | 2 +- app/views/wikis/show.html.haml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/views/snippets/_snippets.html.haml b/app/views/snippets/_snippets.html.haml index 636bf37f6d9..6c72b335f3a 100644 --- a/app/views/snippets/_snippets.html.haml +++ b/app/views/snippets/_snippets.html.haml @@ -1,5 +1,5 @@ %ul.bordered-list - = render partial: 'snippet', collection: @snippets + = render @snippets - if @snippets.empty? %li %h3.nothing_here_message Nothing here. diff --git a/app/views/wikis/edit.html.haml b/app/views/wikis/edit.html.haml index 7441ceff5c8..cd74a738f8b 100644 --- a/app/views/wikis/edit.html.haml +++ b/app/views/wikis/edit.html.haml @@ -1,7 +1,7 @@ = render 'wikis/nav' %h3.page_title Editing page - = render partial: 'main_links' + = render 'main_links' = render 'form' .pull-right diff --git a/app/views/wikis/git_access.html.haml b/app/views/wikis/git_access.html.haml index 462d483fd85..0b363cbb8c9 100644 --- a/app/views/wikis/git_access.html.haml +++ b/app/views/wikis/git_access.html.haml @@ -2,7 +2,7 @@ %h3.page_title Git Access %strong= @gollum_wiki.path_with_namespace - = render partial: 'main_links' + = render 'main_links' %br .content diff --git a/app/views/wikis/history.html.haml b/app/views/wikis/history.html.haml index f4946ed000d..243c5c7c2c3 100644 --- a/app/views/wikis/history.html.haml +++ b/app/views/wikis/history.html.haml @@ -2,7 +2,7 @@ %h3.page_title %span.light History for = @wiki.title.titleize - = render partial: 'main_links' + = render 'main_links' %br %table %thead diff --git a/app/views/wikis/pages.html.haml b/app/views/wikis/pages.html.haml index 95d5eef16f5..48c11b8e395 100644 --- a/app/views/wikis/pages.html.haml +++ b/app/views/wikis/pages.html.haml @@ -1,7 +1,7 @@ = render 'wikis/nav' %h3.page_title All Pages - = render partial: 'main_links' + = render 'main_links' %br %table %thead diff --git a/app/views/wikis/show.html.haml b/app/views/wikis/show.html.haml index b237bc524ed..b40bbcb4923 100644 --- a/app/views/wikis/show.html.haml +++ b/app/views/wikis/show.html.haml @@ -1,7 +1,7 @@ = render 'wikis/nav' %h3.page_title = @wiki.title.titleize - = render partial: 'main_links' + = render 'main_links' %br - if @wiki.historical? .warning_message -- cgit v1.2.1 From 102aaf0682e7e670fecbaf2cdc9ed1c35647f04f Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 22 Jun 2013 15:08:11 +0300 Subject: Use simple render syntax in controllers --- app/controllers/admin/groups_controller.rb | 4 ++-- app/controllers/admin/users_controller.rb | 4 ++-- app/controllers/merge_requests_controller.rb | 4 ++-- app/controllers/projects_controller.rb | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/controllers/admin/groups_controller.rb b/app/controllers/admin/groups_controller.rb index 949a3996040..31d25377b76 100644 --- a/app/controllers/admin/groups_controller.rb +++ b/app/controllers/admin/groups_controller.rb @@ -25,7 +25,7 @@ class Admin::GroupsController < Admin::ApplicationController if @group.save redirect_to [:admin, @group], notice: 'Group was successfully created.' else - render action: "new" + render "new" end end @@ -40,7 +40,7 @@ class Admin::GroupsController < Admin::ApplicationController if @group.update_attributes(group_params) redirect_to [:admin, @group], notice: 'Group was successfully updated.' else - render action: "edit" + render "edit" end end diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index 16f8d9f225b..fefd2594880 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -53,7 +53,7 @@ class Admin::UsersController < Admin::ApplicationController format.html { redirect_to [:admin, @admin_user], notice: 'User was successfully created.' } format.json { render json: @admin_user, status: :created, location: @admin_user } else - format.html { render action: "new" } + format.html { render "new" } format.json { render json: @admin_user.errors, status: :unprocessable_entity } end end @@ -76,7 +76,7 @@ class Admin::UsersController < Admin::ApplicationController else # restore username to keep form action url. admin_user.username = params[:id] - format.html { render action: "edit" } + format.html { render "edit" } format.json { render json: admin_user.errors, status: :unprocessable_entity } end end diff --git a/app/controllers/merge_requests_controller.rb b/app/controllers/merge_requests_controller.rb index 17c0392c384..8d19e1b8b0b 100644 --- a/app/controllers/merge_requests_controller.rb +++ b/app/controllers/merge_requests_controller.rb @@ -54,7 +54,7 @@ class MergeRequestsController < ProjectResourceController @merge_request.reload_code redirect_to [@project, @merge_request], notice: 'Merge request was successfully created.' else - render action: "new" + render "new" end end @@ -64,7 +64,7 @@ class MergeRequestsController < ProjectResourceController @merge_request.mark_as_unchecked redirect_to [@project, @merge_request], notice: 'Merge request was successfully updated.' else - render action: "edit" + render "edit" end end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index fe450899b6f..858a638c7be 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -27,7 +27,7 @@ class ProjectsController < ProjectResourceController if @project.saved? redirect_to @project else - render action: "new" + render "new" end end format.js @@ -43,7 +43,7 @@ class ProjectsController < ProjectResourceController format.html { redirect_to edit_project_path(@project), notice: 'Project was successfully updated.' } format.js else - format.html { render action: "edit", layout: "project_settings" } + format.html { render "edit", layout: "project_settings" } format.js end end @@ -90,7 +90,7 @@ class ProjectsController < ProjectResourceController redirect_to(@forked_project, notice: 'Project was successfully forked.') else @title = 'Fork project' - render action: "fork" + render "fork" end end format.js -- cgit v1.2.1 From 96f3a88c0111b56cce8ac77b7c48225510b2b73b Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 22 Jun 2013 15:11:23 +0300 Subject: Restrict auto generated routes --- config/routes.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index 1b184fcac0b..3b6a861b668 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -113,8 +113,8 @@ Gitlab::Application.routes.draw do put :update_username end - resource :notifications - resource :password + resource :notifications, only: [:show, :update] + resource :password, only: [:new, :create] end resources :keys @@ -125,7 +125,7 @@ Gitlab::Application.routes.draw do # # Dashboard Area # - resource :dashboard, controller: "dashboard" do + resource :dashboard, controller: "dashboard", only: [:show] do member do get :projects get :issues @@ -198,7 +198,7 @@ Gitlab::Application.routes.draw do end end - resource :repository do + resource :repository, only: [:show] do member do get "branches" get "tags" -- cgit v1.2.1 From 529feb4b40bacf2a35cd76501ec1b56788bc9b14 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 22 Jun 2013 16:00:39 +0300 Subject: Add comment title to rss feed --- app/helpers/events_helper.rb | 10 ++++++---- app/models/event.rb | 2 +- app/views/notes/_discussion.html.haml | 2 +- app/views/notes/_note.html.haml | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb index 7c1aee76d4a..b93b1502b34 100644 --- a/app/helpers/events_helper.rb +++ b/app/helpers/events_helper.rb @@ -45,13 +45,15 @@ module EventsHelper def event_feed_title(event) if event.issue? - "#{event.author_name} #{event.action_name} issue ##{event.target_id}: #{event.issue_title} at #{event.project.name}" + "#{event.author_name} #{event.action_name} issue ##{event.target_id}: #{event.issue_title} at #{event.project_name}" elsif event.merge_request? - "#{event.author_name} #{event.action_name} MR ##{event.target_id}: #{event.merge_request_title} at #{event.project.name}" + "#{event.author_name} #{event.action_name} MR ##{event.target_id}: #{event.merge_request_title} at #{event.project_name}" elsif event.push? - "#{event.author_name} #{event.push_action_name} #{event.ref_type} #{event.ref_name} at #{event.project.name}" + "#{event.author_name} #{event.push_action_name} #{event.ref_type} #{event.ref_name} at #{event.project_name}" elsif event.membership_changed? - "#{event.author_name} #{event.action_name} #{event.project.name}" + "#{event.author_name} #{event.action_name} #{event.project_name}" + elsif event.note? + "#{event.author_name} commented on #{event.note_target_type} ##{truncate event.note_target_id} at #{event.project_name}" else "" end diff --git a/app/models/event.rb b/app/models/event.rb index 793ed445947..a6b5167fba6 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -68,7 +68,7 @@ class Event < ActiveRecord::Base def project_name if project - project.name + project.name_with_namespace else "(deleted project)" end diff --git a/app/views/notes/_discussion.html.haml b/app/views/notes/_discussion.html.haml index 24cb4228174..eaefb442662 100644 --- a/app/views/notes/_discussion.html.haml +++ b/app/views/notes/_discussion.html.haml @@ -8,7 +8,7 @@ = link_to "javascript:;", class: "js-details-target turn-off js-toggler-target" do %i.icon-eye-open Show discussion - = image_tag gravatar_icon(note.author.email), class: "avatar s32" + = image_tag gravatar_icon(note.author_email), class: "avatar s32" %div = link_to_member(@project, note.author, avatar: false) - if note.for_merge_request? diff --git a/app/views/notes/_note.html.haml b/app/views/notes/_note.html.haml index b355e2a0bd4..6a1159bc8f0 100644 --- a/app/views/notes/_note.html.haml +++ b/app/views/notes/_note.html.haml @@ -8,7 +8,7 @@ - if(note.author_id == current_user.id) || can?(current_user, :admin_note, @project) = link_to project_note_path(@project, note), title: "Remove comment", method: :delete, confirm: 'Are you sure you want to remove comment?', remote: true, class: "danger js-note-delete" do %i.icon-trash.cred - = image_tag gravatar_icon(note.author.email), class: "avatar s32" + = image_tag gravatar_icon(note.author_email), class: "avatar s32" = link_to_member(@project, note.author, avatar: false) %span.note-last-update = time_ago_in_words(note.updated_at) -- cgit v1.2.1 From 7b87fcbad42c57317f34d178b83176a96e914ebd Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 22 Jun 2013 16:46:57 +0300 Subject: Fix broken factory --- spec/factories.rb | 1 - spec/models/user_spec.rb | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/spec/factories.rb b/spec/factories.rb index b6ef87d4c2a..b596f80fa9e 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -27,7 +27,6 @@ FactoryGirl.define do sequence(:name) { |n| "project#{n}" } path { name.downcase.gsub(/\s/, '_') } creator - namespace { creator.namespace } end factory :redmine_project, parent: :project do diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 92a371ede05..eb8ffa5aafe 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -108,8 +108,8 @@ describe User do ActiveRecord::Base.observers.enable(:user_observer) @user = create :user @project = create :project, namespace: @user.namespace - @project_2 = create :project # Grant MASTER access to the user - @project_3 = create :project # Grant DEVELOPER access to the user + @project_2 = create :project, group: create(:group) # Grant MASTER access to the user + @project_3 = create :project, group: create(:group) # Grant DEVELOPER access to the user @project_2.team << [@user, :master] @project_3.team << [@user, :developer] -- cgit v1.2.1 From 248ece76e51014700733727e553a428e2f85579d Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 22 Jun 2013 16:48:34 +0300 Subject: gitlab_meta gem to 6.0 --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 0150ffb94ea..63b64b62421 100644 --- a/Gemfile +++ b/Gemfile @@ -198,5 +198,5 @@ group :test do end group :production do - gem "gitlab_meta", '5.0' + gem "gitlab_meta", '6.0' end diff --git a/Gemfile.lock b/Gemfile.lock index 313d2ffbca5..8063ae184e3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -168,7 +168,7 @@ GEM activesupport (~> 3.2.13) github-linguist (~> 2.3.4) gitlab-grit (~> 2.5.1) - gitlab_meta (5.0) + gitlab_meta (6.0) gitlab_omniauth-ldap (1.0.3) net-ldap (~> 0.3.1) omniauth (~> 1.0) @@ -545,7 +545,7 @@ DEPENDENCIES gitlab-grack (~> 1.0.1) gitlab-pygments.rb (~> 0.3.2) gitlab_git (~> 1.3.0) - gitlab_meta (= 5.0) + gitlab_meta (= 6.0) gitlab_omniauth-ldap (= 1.0.3) gon grape (~> 0.4.1) -- cgit v1.2.1 From e45179c9b4d0504def48f00cfe4b97463b090614 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 22 Jun 2013 18:57:34 +0300 Subject: remove useless routing tests. Added symlink creation for project with code --- features/steps/project/project_fork.rb | 4 ++-- features/steps/shared/project.rb | 4 ++-- spec/factories.rb | 7 +++++++ spec/features/search_spec.rb | 3 ++- spec/requests/api/projects_spec.rb | 2 +- spec/routing/admin_routing_spec.rb | 10 ---------- spec/routing/project_routing_spec.rb | 25 ------------------------- spec/support/login_helpers.rb | 5 ++++- spec/support/test_env.rb | 5 ----- 9 files changed, 18 insertions(+), 47 deletions(-) diff --git a/features/steps/project/project_fork.rb b/features/steps/project/project_fork.rb index f3335deb279..775af0c5c58 100644 --- a/features/steps/project/project_fork.rb +++ b/features/steps/project/project_fork.rb @@ -10,7 +10,7 @@ class ForkProject < Spinach::FeatureSteps step 'I am a member of project "Shop"' do @project = Project.find_by_name "Shop" - @project ||= create(:project_with_code, name: "Shop") + @project ||= create(:project_with_code, name: "Shop", group: create(:group)) @project.team << [@user, :reporter] end @@ -27,4 +27,4 @@ class ForkProject < Spinach::FeatureSteps page.should have_content "Name has already been taken" end -end \ No newline at end of file +end diff --git a/features/steps/shared/project.rb b/features/steps/shared/project.rb index b16032a8300..44f9d390cb1 100644 --- a/features/steps/shared/project.rb +++ b/features/steps/shared/project.rb @@ -3,14 +3,14 @@ module SharedProject # Create a project without caring about what it's called And "I own a project" do - @project = create(:project_with_code) + @project = create(:project_with_code, namespace: @user.namespace) @project.team << [@user, :master] end # Create a specific project called "Shop" And 'I own project "Shop"' do @project = Project.find_by_name "Shop" - @project ||= create(:project_with_code, name: "Shop") + @project ||= create(:project_with_code, name: "Shop", namespace: @user.namespace) @project.team << [@user, :master] end diff --git a/spec/factories.rb b/spec/factories.rb index b596f80fa9e..272623440e1 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -36,6 +36,13 @@ FactoryGirl.define do factory :project_with_code, parent: :project do path { 'gitlabhq' } + + after :create do |project| + repos_path = Rails.root.join('tmp', 'test-git-base-path') + seed_repo = Rails.root.join('tmp', 'repositories', 'gitlabhq') + target_repo = File.join(repos_path, project.path_with_namespace + '.git') + system("ln -s #{seed_repo} #{target_repo}") + end end factory :group do diff --git a/spec/features/search_spec.rb b/spec/features/search_spec.rb index 5ce4cae3551..3ca59da493b 100644 --- a/spec/features/search_spec.rb +++ b/spec/features/search_spec.rb @@ -2,8 +2,9 @@ require 'spec_helper' describe "Search" do before do + ActiveRecord::Base.observers.enable(:user_observer) login_as :user - @project = create(:project) + @project = create(:project, namespace: @user.namespace) @project.team << [@user, :reporter] visit search_path diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index 31075149647..437722c774c 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -8,7 +8,7 @@ describe API::API do let(:user2) { create(:user) } let(:user3) { create(:user) } let(:admin) { create(:admin) } - let!(:project) { create(:project_with_code, creator_id: user.id) } + let!(:project) { create(:project_with_code, creator_id: user.id, namespace: user.namespace) } let!(:hook) { create(:project_hook, project: project, url: "http://example.com") } let!(:snippet) { create(:project_snippet, author: user, project: project, title: 'example') } let!(:users_project) { create(:users_project, user: user, project: project, project_access: UsersProject::MASTER) } diff --git a/spec/routing/admin_routing_spec.rb b/spec/routing/admin_routing_spec.rb index 36b546fb077..de5e831c4b4 100644 --- a/spec/routing/admin_routing_spec.rb +++ b/spec/routing/admin_routing_spec.rb @@ -75,18 +75,8 @@ describe Admin::ProjectsController, "routing" do end end -# edit_admin_project_member GET /admin/projects/:project_id/members/:id/edit(.:format) admin/projects/members#edit {id: /[^\/]+/, project_id: /[^\/]+/} -# admin_project_member PUT /admin/projects/:project_id/members/:id(.:format) admin/projects/members#update {id: /[^\/]+/, project_id: /[^\/]+/} # DELETE /admin/projects/:project_id/members/:id(.:format) admin/projects/members#destroy {id: /[^\/]+/, project_id: /[^\/]+/} describe Admin::Projects::MembersController, "routing" do - it "to #edit" do - get("/admin/projects/test/members/1/edit").should route_to('admin/projects/members#edit', project_id: 'test', id: '1') - end - - it "to #update" do - put("/admin/projects/test/members/1").should route_to('admin/projects/members#update', project_id: 'test', id: '1') - end - it "to #destroy" do delete("/admin/projects/test/members/1").should route_to('admin/projects/members#destroy', project_id: 'test', id: '1') end diff --git a/spec/routing/project_routing_spec.rb b/spec/routing/project_routing_spec.rb index b2b20ef6b5d..7f88029de52 100644 --- a/spec/routing/project_routing_spec.rb +++ b/spec/routing/project_routing_spec.rb @@ -124,12 +124,7 @@ end # branches_project_repository GET /:project_id/repository/branches(.:format) repositories#branches # tags_project_repository GET /:project_id/repository/tags(.:format) repositories#tags # archive_project_repository GET /:project_id/repository/archive(.:format) repositories#archive -# project_repository POST /:project_id/repository(.:format) repositories#create -# new_project_repository GET /:project_id/repository/new(.:format) repositories#new # edit_project_repository GET /:project_id/repository/edit(.:format) repositories#edit -# GET /:project_id/repository(.:format) repositories#show -# PUT /:project_id/repository(.:format) repositories#update -# DELETE /:project_id/repository(.:format) repositories#destroy describe RepositoriesController, "routing" do it "to #branches" do get("/gitlabhq/repository/branches").should route_to('repositories#branches', project_id: 'gitlabhq') @@ -143,29 +138,9 @@ describe RepositoriesController, "routing" do get("/gitlabhq/repository/archive").should route_to('repositories#archive', project_id: 'gitlabhq') end - it "to #create" do - post("/gitlabhq/repository").should route_to('repositories#create', project_id: 'gitlabhq') - end - - it "to #new" do - get("/gitlabhq/repository/new").should route_to('repositories#new', project_id: 'gitlabhq') - end - - it "to #edit" do - get("/gitlabhq/repository/edit").should route_to('repositories#edit', project_id: 'gitlabhq') - end - it "to #show" do get("/gitlabhq/repository").should route_to('repositories#show', project_id: 'gitlabhq') end - - it "to #update" do - put("/gitlabhq/repository").should route_to('repositories#update', project_id: 'gitlabhq') - end - - it "to #destroy" do - delete("/gitlabhq/repository").should route_to('repositories#destroy', project_id: 'gitlabhq') - end end # project_deploy_keys GET /:project_id/deploy_keys(.:format) deploy_keys#index diff --git a/spec/support/login_helpers.rb b/spec/support/login_helpers.rb index d423ccf8a10..46794f48384 100644 --- a/spec/support/login_helpers.rb +++ b/spec/support/login_helpers.rb @@ -3,7 +3,10 @@ module LoginHelpers # # role - User role (e.g., :admin, :user) def login_as(role) - @user = create(role) + ActiveRecord::Base.observers.enable(:user_observer) do + @user = create(role) + end + login_with(@user) end diff --git a/spec/support/test_env.rb b/spec/support/test_env.rb index efc629e6478..cf80d4901b8 100644 --- a/spec/support/test_env.rb +++ b/spec/support/test_env.rb @@ -65,11 +65,6 @@ module TestEnv # Recreate tmp/test-git-base-path FileUtils.mkdir_p Gitlab.config.gitlab_shell.repos_path - - # Symlink tmp/repositories/gitlabhq to tmp/test-git-base-path/gitlabhq - seed_repo = Rails.root.join('tmp', 'repositories', 'gitlabhq') - target_repo = File.join(repos_path, 'gitlabhq.git') - system("ln -s #{seed_repo} #{target_repo}") end def create_temp_repo(path) -- cgit v1.2.1 From 95791316f4037273af7b747ce1851d5f4e46933f Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 22 Jun 2013 23:57:29 +0300 Subject: Lets fix tests --- app/views/snippets/_snippets.html.haml | 2 +- features/project/team_management.feature | 3 ++- features/steps/dashboard/dashboard.rb | 11 +++++++---- features/steps/project/project_team_management.rb | 5 +++-- features/steps/shared/project.rb | 2 +- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/app/views/snippets/_snippets.html.haml b/app/views/snippets/_snippets.html.haml index 6c72b335f3a..636bf37f6d9 100644 --- a/app/views/snippets/_snippets.html.haml +++ b/app/views/snippets/_snippets.html.haml @@ -1,5 +1,5 @@ %ul.bordered-list - = render @snippets + = render partial: 'snippet', collection: @snippets - if @snippets.empty? %li %h3.nothing_here_message Nothing here. diff --git a/features/project/team_management.feature b/features/project/team_management.feature index fc353424e36..e153978e043 100644 --- a/features/project/team_management.feature +++ b/features/project/team_management.feature @@ -31,6 +31,7 @@ Feature: Project Team management Scenario: Import team from another project Given I own project "Website" And "Mike" is "Website" reporter + When I visit project "Shop" team page And I click link "Import team from another project" - When I submit "Website" project for import team + And I submit "Website" project for import team Then I should see "Mike" in team list as "Reporter" diff --git a/features/steps/dashboard/dashboard.rb b/features/steps/dashboard/dashboard.rb index c6832056435..329571ac6ef 100644 --- a/features/steps/dashboard/dashboard.rb +++ b/features/steps/dashboard/dashboard.rb @@ -29,7 +29,7 @@ class Dashboard < Spinach::FeatureSteps Given 'user with name "John Doe" joined project "Shop"' do user = create(:user, {name: "John Doe"}) - project = Project.find_by_name "Shop" + project.team << [user, :master] Event.create( project: project, author_id: user.id, @@ -38,12 +38,11 @@ class Dashboard < Spinach::FeatureSteps end Then 'I should see "John Doe joined project at Shop" event' do - page.should have_content "John Doe joined project at Shop" + page.should have_content "John Doe joined project at #{project.name_with_namespace}" end And 'user with name "John Doe" left project "Shop"' do user = User.find_by_name "John Doe" - project = Project.find_by_name "Shop" Event.create( project: project, author_id: user.id, @@ -52,7 +51,7 @@ class Dashboard < Spinach::FeatureSteps end Then 'I should see "John Doe left project at Shop" event' do - page.should have_content "John Doe left project at Shop" + page.should have_content "John Doe left project at #{project.name_with_namespace}" end And 'I have group with projects' do @@ -83,4 +82,8 @@ class Dashboard < Spinach::FeatureSteps Then 'I should see 1 project at group list' do page.find('span.last_activity/span').should have_content('1') end + + def project + @project ||= Project.find_by_name "Shop" + end end diff --git a/features/steps/project/project_team_management.rb b/features/steps/project/project_team_management.rb index af41fd42612..93ba1086f6e 100644 --- a/features/steps/project/project_team_management.rb +++ b/features/steps/project/project_team_management.rb @@ -79,7 +79,7 @@ class ProjectTeamManagement < Spinach::FeatureSteps end Given 'I own project "Website"' do - @project = create(:project, name: "Website") + @project = create(:project, name: "Website", namespace: @user.namespace) @project.team << [@user, :master] end @@ -94,7 +94,8 @@ class ProjectTeamManagement < Spinach::FeatureSteps end When 'I submit "Website" project for import team' do - select 'Website', from: 'source_project_id' + project = Project.find_by_name("Website") + select project.name_with_namespace, from: 'source_project_id' click_button 'Import' end diff --git a/features/steps/shared/project.rb b/features/steps/shared/project.rb index 44f9d390cb1..66553e1e089 100644 --- a/features/steps/shared/project.rb +++ b/features/steps/shared/project.rb @@ -42,7 +42,7 @@ module SharedProject Then 'I should see project "Shop" activity feed' do project = Project.find_by_name("Shop") - page.should have_content "#{@user.name} pushed new branch new_design at #{project.name}" + page.should have_content "#{@user.name} pushed new branch new_design at #{project.name_with_namespace}" end Then 'I should see project settings' do -- cgit v1.2.1 From 2ed7cbfba4ff3c6a4cf3e72515a0375544998de0 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sun, 23 Jun 2013 19:47:22 +0300 Subject: Move projects controllers/views in Projects module --- app/assets/javascripts/dispatcher.js.coffee | 10 +- app/controllers/blame_controller.rb | 14 -- app/controllers/blob_controller.rb | 13 -- app/controllers/commit_controller.rb | 43 ----- app/controllers/commits_controller.rb | 23 --- app/controllers/compare_controller.rb | 23 --- app/controllers/deploy_keys_controller.rb | 61 ------- app/controllers/edit_tree_controller.rb | 49 ------ app/controllers/graphs_controller.rb | 17 -- app/controllers/hooks_controller.rb | 39 ----- app/controllers/issues_controller.rb | 114 ------------ app/controllers/labels_controller.rb | 24 --- app/controllers/merge_requests_controller.rb | 163 ----------------- app/controllers/milestones_controller.rb | 94 ---------- app/controllers/network_controller.rb | 23 --- app/controllers/notes_controller.rb | 76 -------- app/controllers/project_resource_controller.rb | 4 - app/controllers/projects/application_controller.rb | 1 + app/controllers/projects/blame_controller.rb | 14 ++ app/controllers/projects/blob_controller.rb | 13 ++ app/controllers/projects/commit_controller.rb | 43 +++++ app/controllers/projects/commits_controller.rb | 23 +++ app/controllers/projects/compare_controller.rb | 23 +++ app/controllers/projects/deploy_keys_controller.rb | 61 +++++++ app/controllers/projects/edit_tree_controller.rb | 49 ++++++ app/controllers/projects/graphs_controller.rb | 17 ++ app/controllers/projects/hooks_controller.rb | 39 +++++ app/controllers/projects/issues_controller.rb | 114 ++++++++++++ app/controllers/projects/labels_controller.rb | 24 +++ .../projects/merge_requests_controller.rb | 163 +++++++++++++++++ app/controllers/projects/milestones_controller.rb | 94 ++++++++++ app/controllers/projects/network_controller.rb | 23 +++ app/controllers/projects/notes_controller.rb | 76 ++++++++ .../projects/protected_branches_controller.rb | 26 +++ app/controllers/projects/raw_controller.rb | 25 +++ app/controllers/projects/refs_controller.rb | 43 +++++ .../projects/repositories_controller.rb | 41 +++++ app/controllers/projects/services_controller.rb | 39 +++++ app/controllers/projects/snippets_controller.rb | 2 +- .../projects/team_members_controller.rb | 62 +++++++ app/controllers/projects/tree_controller.rb | 17 ++ app/controllers/projects/walls_controller.rb | 20 +++ app/controllers/projects/wikis_controller.rb | 95 ++++++++++ app/controllers/projects_controller.rb | 2 +- app/controllers/protected_branches_controller.rb | 26 --- app/controllers/raw_controller.rb | 25 --- app/controllers/refs_controller.rb | 43 ----- app/controllers/repositories_controller.rb | 41 ----- app/controllers/services_controller.rb | 39 ----- app/controllers/team_members_controller.rb | 62 ------- app/controllers/tree_controller.rb | 17 -- app/controllers/walls_controller.rb | 20 --- app/controllers/wikis_controller.rb | 95 ---------- app/helpers/commits_helper.rb | 2 +- app/helpers/tree_helper.rb | 6 +- app/views/blame/_head.html.haml | 2 - app/views/blame/show.html.haml | 49 ------ app/views/blob/_actions.html.haml | 12 -- app/views/blob/_blob.html.haml | 32 ---- app/views/blob/_download.html.haml | 8 - app/views/blob/_image.html.haml | 2 - app/views/blob/_text.html.haml | 14 -- app/views/blob/show.html.haml | 4 - app/views/commit/_commit_box.html.haml | 50 ------ app/views/commit/huge_commit.html.haml | 3 - app/views/commit/show.html.haml | 11 -- app/views/commits/_commit.html.haml | 21 --- app/views/commits/_commits.html.haml | 9 - app/views/commits/_diff_head.html.haml | 26 --- app/views/commits/_diffs.html.haml | 49 ------ app/views/commits/_head.html.haml | 27 --- app/views/commits/_image.html.haml | 63 ------- app/views/commits/_text_file.html.haml | 23 --- app/views/commits/show.atom.builder | 23 --- app/views/commits/show.html.haml | 15 -- app/views/commits/show.js.haml | 3 - app/views/compare/_form.html.haml | 37 ---- app/views/compare/index.html.haml | 7 - app/views/compare/show.html.haml | 23 --- app/views/dashboard/issues.html.haml | 2 +- app/views/deploy_keys/_deploy_key.html.haml | 25 --- app/views/deploy_keys/_form.html.haml | 23 --- app/views/deploy_keys/index.html.haml | 30 ---- app/views/deploy_keys/new.html.haml | 4 - app/views/deploy_keys/show.html.haml | 13 -- app/views/edit_tree/show.html.haml | 45 ----- app/views/graphs/show.html.haml | 31 ---- app/views/graphs/show.js.haml | 16 -- app/views/groups/issues.html.haml | 2 +- app/views/hooks/_data_ex.html.erb | 43 ----- app/views/hooks/index.html.haml | 34 ---- app/views/issues/_filter.html.haml | 23 --- app/views/issues/_form.html.haml | 95 ---------- app/views/issues/_head.html.haml | 10 -- app/views/issues/_issue.html.haml | 44 ----- app/views/issues/_issues.html.haml | 94 ---------- app/views/issues/edit.html.haml | 1 - app/views/issues/index.atom.builder | 23 --- app/views/issues/index.html.haml | 25 --- app/views/issues/index.js.haml | 4 - app/views/issues/new.html.haml | 1 - app/views/issues/show.html.haml | 68 -------- app/views/issues/update.js.haml | 4 - app/views/labels/_label.html.haml | 15 -- app/views/labels/index.html.haml | 14 -- app/views/layouts/project_resource.html.haml | 15 -- app/views/layouts/projects.html.haml | 15 ++ app/views/merge_requests/_filter.html.haml | 20 --- app/views/merge_requests/_form.html.haml | 79 --------- app/views/merge_requests/_head.html.haml | 5 - app/views/merge_requests/_merge_request.html.haml | 29 --- app/views/merge_requests/_show.html.haml | 37 ---- app/views/merge_requests/automerge.js.haml | 7 - app/views/merge_requests/branch_from.js.haml | 2 - app/views/merge_requests/branch_to.js.haml | 2 - app/views/merge_requests/commits.js.haml | 4 - app/views/merge_requests/diffs.html.haml | 1 - app/views/merge_requests/diffs.js.haml | 2 - app/views/merge_requests/edit.html.haml | 4 - app/views/merge_requests/index.html.haml | 35 ---- app/views/merge_requests/invalid.html.haml | 17 -- app/views/merge_requests/new.html.haml | 3 - app/views/merge_requests/show.html.haml | 1 - app/views/merge_requests/show.js.haml | 2 - app/views/merge_requests/show/_commits.html.haml | 30 ---- app/views/merge_requests/show/_diffs.html.haml | 10 -- .../merge_requests/show/_how_to_merge.html.haml | 19 -- app/views/merge_requests/show/_mr_accept.html.haml | 52 ------ app/views/merge_requests/show/_mr_box.html.haml | 36 ---- app/views/merge_requests/show/_mr_ci.html.haml | 35 ---- app/views/merge_requests/show/_mr_title.html.haml | 31 ---- app/views/milestones/_form.html.haml | 47 ----- app/views/milestones/_issues.html.haml | 11 -- app/views/milestones/_merge_request.html.haml | 5 - app/views/milestones/_milestone.html.haml | 28 --- app/views/milestones/edit.html.haml | 1 - app/views/milestones/index.html.haml | 32 ---- app/views/milestones/new.html.haml | 1 - app/views/milestones/show.html.haml | 106 ----------- app/views/milestones/update.js.haml | 2 - app/views/network/_head.html.haml | 26 --- app/views/network/show.html.haml | 18 -- app/views/network/show.json.erb | 23 --- app/views/notes/_diff_note_link.html.haml | 10 -- app/views/notes/_diff_notes_with_reply.html.haml | 11 -- app/views/notes/_discussion.html.haml | 63 ------- app/views/notes/_discussion_diff.html.haml | 24 --- app/views/notes/_discussion_reply_button.html.haml | 10 -- app/views/notes/_form.html.haml | 37 ---- app/views/notes/_form_errors.html.haml | 3 - app/views/notes/_note.html.haml | 37 ---- app/views/notes/_notes.html.haml | 11 -- app/views/notes/_notes_with_form.html.haml | 9 - app/views/notes/create.js.haml | 18 -- app/views/notes/index.js.haml | 4 - app/views/projects/blame/_head.html.haml | 2 + app/views/projects/blame/show.html.haml | 49 ++++++ app/views/projects/blob/_actions.html.haml | 12 ++ app/views/projects/blob/_blob.html.haml | 32 ++++ app/views/projects/blob/_download.html.haml | 8 + app/views/projects/blob/_image.html.haml | 2 + app/views/projects/blob/_text.html.haml | 14 ++ app/views/projects/blob/show.html.haml | 4 + app/views/projects/commit/_commit_box.html.haml | 50 ++++++ app/views/projects/commit/huge_commit.html.haml | 3 + app/views/projects/commit/show.html.haml | 11 ++ app/views/projects/commits/_commit.html.haml | 21 +++ app/views/projects/commits/_commits.html.haml | 9 + app/views/projects/commits/_diff_head.html.haml | 26 +++ app/views/projects/commits/_diffs.html.haml | 49 ++++++ app/views/projects/commits/_head.html.haml | 27 +++ app/views/projects/commits/_image.html.haml | 63 +++++++ app/views/projects/commits/_text_file.html.haml | 23 +++ app/views/projects/commits/show.atom.builder | 23 +++ app/views/projects/commits/show.html.haml | 15 ++ app/views/projects/commits/show.js.haml | 3 + app/views/projects/compare/_form.html.haml | 37 ++++ app/views/projects/compare/index.html.haml | 7 + app/views/projects/compare/show.html.haml | 23 +++ .../projects/deploy_keys/_deploy_key.html.haml | 25 +++ app/views/projects/deploy_keys/_form.html.haml | 23 +++ app/views/projects/deploy_keys/index.html.haml | 30 ++++ app/views/projects/deploy_keys/new.html.haml | 4 + app/views/projects/deploy_keys/show.html.haml | 13 ++ app/views/projects/edit_tree/show.html.haml | 45 +++++ app/views/projects/graphs/show.html.haml | 31 ++++ app/views/projects/graphs/show.js.haml | 16 ++ app/views/projects/hooks/_data_ex.html.erb | 43 +++++ app/views/projects/hooks/index.html.haml | 34 ++++ app/views/projects/issues/_filter.html.haml | 23 +++ app/views/projects/issues/_form.html.haml | 95 ++++++++++ app/views/projects/issues/_head.html.haml | 10 ++ app/views/projects/issues/_issue.html.haml | 44 +++++ app/views/projects/issues/_issues.html.haml | 94 ++++++++++ app/views/projects/issues/edit.html.haml | 1 + app/views/projects/issues/index.atom.builder | 23 +++ app/views/projects/issues/index.html.haml | 25 +++ app/views/projects/issues/index.js.haml | 4 + app/views/projects/issues/new.html.haml | 1 + app/views/projects/issues/show.html.haml | 68 ++++++++ app/views/projects/issues/update.js.haml | 4 + app/views/projects/labels/_label.html.haml | 15 ++ app/views/projects/labels/index.html.haml | 14 ++ .../projects/merge_requests/_filter.html.haml | 20 +++ app/views/projects/merge_requests/_form.html.haml | 79 +++++++++ app/views/projects/merge_requests/_head.html.haml | 5 + .../merge_requests/_merge_request.html.haml | 29 +++ app/views/projects/merge_requests/_show.html.haml | 37 ++++ .../projects/merge_requests/automerge.js.haml | 7 + .../projects/merge_requests/branch_from.js.haml | 2 + .../projects/merge_requests/branch_to.js.haml | 2 + app/views/projects/merge_requests/commits.js.haml | 4 + app/views/projects/merge_requests/diffs.html.haml | 1 + app/views/projects/merge_requests/diffs.js.haml | 2 + app/views/projects/merge_requests/edit.html.haml | 4 + app/views/projects/merge_requests/index.html.haml | 35 ++++ .../projects/merge_requests/invalid.html.haml | 17 ++ app/views/projects/merge_requests/new.html.haml | 3 + app/views/projects/merge_requests/show.html.haml | 1 + app/views/projects/merge_requests/show.js.haml | 2 + .../merge_requests/show/_commits.html.haml | 30 ++++ .../projects/merge_requests/show/_diffs.html.haml | 10 ++ .../merge_requests/show/_how_to_merge.html.haml | 19 ++ .../merge_requests/show/_mr_accept.html.haml | 52 ++++++ .../projects/merge_requests/show/_mr_box.html.haml | 36 ++++ .../projects/merge_requests/show/_mr_ci.html.haml | 35 ++++ .../merge_requests/show/_mr_title.html.haml | 31 ++++ app/views/projects/milestones/_form.html.haml | 47 +++++ app/views/projects/milestones/_issues.html.haml | 11 ++ .../projects/milestones/_merge_request.html.haml | 5 + app/views/projects/milestones/_milestone.html.haml | 28 +++ app/views/projects/milestones/edit.html.haml | 1 + app/views/projects/milestones/index.html.haml | 32 ++++ app/views/projects/milestones/new.html.haml | 1 + app/views/projects/milestones/show.html.haml | 106 +++++++++++ app/views/projects/milestones/update.js.haml | 2 + app/views/projects/network/_head.html.haml | 26 +++ app/views/projects/network/show.html.haml | 18 ++ app/views/projects/network/show.json.erb | 23 +++ app/views/projects/notes/_diff_note_link.html.haml | 10 ++ .../notes/_diff_notes_with_reply.html.haml | 11 ++ app/views/projects/notes/_discussion.html.haml | 63 +++++++ .../projects/notes/_discussion_diff.html.haml | 24 +++ .../notes/_discussion_reply_button.html.haml | 10 ++ app/views/projects/notes/_form.html.haml | 37 ++++ app/views/projects/notes/_form_errors.html.haml | 3 + app/views/projects/notes/_note.html.haml | 37 ++++ app/views/projects/notes/_notes.html.haml | 11 ++ .../projects/notes/_notes_with_form.html.haml | 9 + app/views/projects/notes/create.js.haml | 18 ++ app/views/projects/notes/index.js.haml | 4 + .../projects/protected_branches/index.html.haml | 54 ++++++ app/views/projects/refs/logs_tree.js.haml | 8 + app/views/projects/repositories/_branch.html.haml | 26 +++ app/views/projects/repositories/_feed.html.haml | 19 ++ app/views/projects/repositories/_filter.html.haml | 9 + app/views/projects/repositories/branches.html.haml | 15 ++ app/views/projects/repositories/show.html.haml | 14 ++ app/views/projects/repositories/stats.html.haml | 33 ++++ app/views/projects/repositories/tags.html.haml | 36 ++++ app/views/projects/services/_form.html.haml | 48 +++++ app/views/projects/services/edit.html.haml | 1 + app/views/projects/services/index.html.haml | 16 ++ app/views/projects/snippets/show.html.haml | 2 +- app/views/projects/team_members/_form.html.haml | 24 +++ .../projects/team_members/_group_members.html.haml | 10 ++ app/views/projects/team_members/_team.html.haml | 9 + .../projects/team_members/_team_member.html.haml | 17 ++ app/views/projects/team_members/import.html.haml | 15 ++ app/views/projects/team_members/index.html.haml | 16 ++ app/views/projects/team_members/new.html.haml | 1 + app/views/projects/team_members/update.js.haml | 6 + app/views/projects/tree/_blob_item.html.haml | 9 + app/views/projects/tree/_readme.html.haml | 13 ++ app/views/projects/tree/_submodule_item.html.haml | 11 ++ app/views/projects/tree/_tree.html.haml | 51 ++++++ .../projects/tree/_tree_commit_column.html.haml | 2 + app/views/projects/tree/_tree_item.html.haml | 9 + app/views/projects/tree/show.html.haml | 4 + app/views/projects/walls/show.html.haml | 23 +++ app/views/projects/wikis/_form.html.haml | 36 ++++ app/views/projects/wikis/_main_links.html.haml | 8 + app/views/projects/wikis/_nav.html.haml | 19 ++ app/views/projects/wikis/_new.html.haml | 12 ++ app/views/projects/wikis/edit.html.haml | 10 ++ app/views/projects/wikis/empty.html.haml | 4 + app/views/projects/wikis/git_access.html.haml | 37 ++++ app/views/projects/wikis/history.html.haml | 31 ++++ app/views/projects/wikis/pages.html.haml | 25 +++ app/views/projects/wikis/show.html.haml | 16 ++ app/views/protected_branches/index.html.haml | 54 ------ app/views/refs/logs_tree.js.haml | 8 - app/views/repositories/_branch.html.haml | 26 --- app/views/repositories/_feed.html.haml | 19 -- app/views/repositories/_filter.html.haml | 9 - app/views/repositories/branches.html.haml | 15 -- app/views/repositories/show.html.haml | 14 -- app/views/repositories/stats.html.haml | 33 ---- app/views/repositories/tags.html.haml | 36 ---- app/views/services/_form.html.haml | 48 ----- app/views/services/edit.html.haml | 1 - app/views/services/index.html.haml | 16 -- app/views/shared/_merge_requests.html.haml | 2 +- app/views/team_members/_form.html.haml | 24 --- app/views/team_members/_group_members.html.haml | 10 -- app/views/team_members/_team.html.haml | 9 - app/views/team_members/_team_member.html.haml | 17 -- app/views/team_members/import.html.haml | 15 -- app/views/team_members/index.html.haml | 16 -- app/views/team_members/new.html.haml | 1 - app/views/team_members/update.js.haml | 6 - app/views/tree/_blob_item.html.haml | 9 - app/views/tree/_readme.html.haml | 13 -- app/views/tree/_submodule_item.html.haml | 11 -- app/views/tree/_tree.html.haml | 51 ------ app/views/tree/_tree_commit_column.html.haml | 2 - app/views/tree/_tree_item.html.haml | 9 - app/views/tree/show.html.haml | 4 - app/views/walls/show.html.haml | 23 --- app/views/wikis/_form.html.haml | 36 ---- app/views/wikis/_main_links.html.haml | 8 - app/views/wikis/_nav.html.haml | 19 -- app/views/wikis/_new.html.haml | 12 -- app/views/wikis/edit.html.haml | 10 -- app/views/wikis/empty.html.haml | 4 - app/views/wikis/git_access.html.haml | 37 ---- app/views/wikis/history.html.haml | 31 ---- app/views/wikis/pages.html.haml | 25 --- app/views/wikis/show.html.haml | 16 -- config/routes.rb | 194 ++++++++++----------- 330 files changed, 4167 insertions(+), 4170 deletions(-) delete mode 100644 app/controllers/blame_controller.rb delete mode 100644 app/controllers/blob_controller.rb delete mode 100644 app/controllers/commit_controller.rb delete mode 100644 app/controllers/commits_controller.rb delete mode 100644 app/controllers/compare_controller.rb delete mode 100644 app/controllers/deploy_keys_controller.rb delete mode 100644 app/controllers/edit_tree_controller.rb delete mode 100644 app/controllers/graphs_controller.rb delete mode 100644 app/controllers/hooks_controller.rb delete mode 100644 app/controllers/issues_controller.rb delete mode 100644 app/controllers/labels_controller.rb delete mode 100644 app/controllers/merge_requests_controller.rb delete mode 100644 app/controllers/milestones_controller.rb delete mode 100644 app/controllers/network_controller.rb delete mode 100644 app/controllers/notes_controller.rb delete mode 100644 app/controllers/project_resource_controller.rb create mode 100644 app/controllers/projects/blame_controller.rb create mode 100644 app/controllers/projects/blob_controller.rb create mode 100644 app/controllers/projects/commit_controller.rb create mode 100644 app/controllers/projects/commits_controller.rb create mode 100644 app/controllers/projects/compare_controller.rb create mode 100644 app/controllers/projects/deploy_keys_controller.rb create mode 100644 app/controllers/projects/edit_tree_controller.rb create mode 100644 app/controllers/projects/graphs_controller.rb create mode 100644 app/controllers/projects/hooks_controller.rb create mode 100644 app/controllers/projects/issues_controller.rb create mode 100644 app/controllers/projects/labels_controller.rb create mode 100644 app/controllers/projects/merge_requests_controller.rb create mode 100644 app/controllers/projects/milestones_controller.rb create mode 100644 app/controllers/projects/network_controller.rb create mode 100644 app/controllers/projects/notes_controller.rb create mode 100644 app/controllers/projects/protected_branches_controller.rb create mode 100644 app/controllers/projects/raw_controller.rb create mode 100644 app/controllers/projects/refs_controller.rb create mode 100644 app/controllers/projects/repositories_controller.rb create mode 100644 app/controllers/projects/services_controller.rb create mode 100644 app/controllers/projects/team_members_controller.rb create mode 100644 app/controllers/projects/tree_controller.rb create mode 100644 app/controllers/projects/walls_controller.rb create mode 100644 app/controllers/projects/wikis_controller.rb delete mode 100644 app/controllers/protected_branches_controller.rb delete mode 100644 app/controllers/raw_controller.rb delete mode 100644 app/controllers/refs_controller.rb delete mode 100644 app/controllers/repositories_controller.rb delete mode 100644 app/controllers/services_controller.rb delete mode 100644 app/controllers/team_members_controller.rb delete mode 100644 app/controllers/tree_controller.rb delete mode 100644 app/controllers/walls_controller.rb delete mode 100644 app/controllers/wikis_controller.rb delete mode 100644 app/views/blame/_head.html.haml delete mode 100644 app/views/blame/show.html.haml delete mode 100644 app/views/blob/_actions.html.haml delete mode 100644 app/views/blob/_blob.html.haml delete mode 100644 app/views/blob/_download.html.haml delete mode 100644 app/views/blob/_image.html.haml delete mode 100644 app/views/blob/_text.html.haml delete mode 100644 app/views/blob/show.html.haml delete mode 100644 app/views/commit/_commit_box.html.haml delete mode 100644 app/views/commit/huge_commit.html.haml delete mode 100644 app/views/commit/show.html.haml delete mode 100644 app/views/commits/_commit.html.haml delete mode 100644 app/views/commits/_commits.html.haml delete mode 100644 app/views/commits/_diff_head.html.haml delete mode 100644 app/views/commits/_diffs.html.haml delete mode 100644 app/views/commits/_head.html.haml delete mode 100644 app/views/commits/_image.html.haml delete mode 100644 app/views/commits/_text_file.html.haml delete mode 100644 app/views/commits/show.atom.builder delete mode 100644 app/views/commits/show.html.haml delete mode 100644 app/views/commits/show.js.haml delete mode 100644 app/views/compare/_form.html.haml delete mode 100644 app/views/compare/index.html.haml delete mode 100644 app/views/compare/show.html.haml delete mode 100644 app/views/deploy_keys/_deploy_key.html.haml delete mode 100644 app/views/deploy_keys/_form.html.haml delete mode 100644 app/views/deploy_keys/index.html.haml delete mode 100644 app/views/deploy_keys/new.html.haml delete mode 100644 app/views/deploy_keys/show.html.haml delete mode 100644 app/views/edit_tree/show.html.haml delete mode 100644 app/views/graphs/show.html.haml delete mode 100644 app/views/graphs/show.js.haml delete mode 100644 app/views/hooks/_data_ex.html.erb delete mode 100644 app/views/hooks/index.html.haml delete mode 100644 app/views/issues/_filter.html.haml delete mode 100644 app/views/issues/_form.html.haml delete mode 100644 app/views/issues/_head.html.haml delete mode 100644 app/views/issues/_issue.html.haml delete mode 100644 app/views/issues/_issues.html.haml delete mode 100644 app/views/issues/edit.html.haml delete mode 100644 app/views/issues/index.atom.builder delete mode 100644 app/views/issues/index.html.haml delete mode 100644 app/views/issues/index.js.haml delete mode 100644 app/views/issues/new.html.haml delete mode 100644 app/views/issues/show.html.haml delete mode 100644 app/views/issues/update.js.haml delete mode 100644 app/views/labels/_label.html.haml delete mode 100644 app/views/labels/index.html.haml delete mode 100644 app/views/layouts/project_resource.html.haml create mode 100644 app/views/layouts/projects.html.haml delete mode 100644 app/views/merge_requests/_filter.html.haml delete mode 100644 app/views/merge_requests/_form.html.haml delete mode 100644 app/views/merge_requests/_head.html.haml delete mode 100644 app/views/merge_requests/_merge_request.html.haml delete mode 100644 app/views/merge_requests/_show.html.haml delete mode 100644 app/views/merge_requests/automerge.js.haml delete mode 100644 app/views/merge_requests/branch_from.js.haml delete mode 100644 app/views/merge_requests/branch_to.js.haml delete mode 100644 app/views/merge_requests/commits.js.haml delete mode 100644 app/views/merge_requests/diffs.html.haml delete mode 100644 app/views/merge_requests/diffs.js.haml delete mode 100644 app/views/merge_requests/edit.html.haml delete mode 100644 app/views/merge_requests/index.html.haml delete mode 100644 app/views/merge_requests/invalid.html.haml delete mode 100644 app/views/merge_requests/new.html.haml delete mode 100644 app/views/merge_requests/show.html.haml delete mode 100644 app/views/merge_requests/show.js.haml delete mode 100644 app/views/merge_requests/show/_commits.html.haml delete mode 100644 app/views/merge_requests/show/_diffs.html.haml delete mode 100644 app/views/merge_requests/show/_how_to_merge.html.haml delete mode 100644 app/views/merge_requests/show/_mr_accept.html.haml delete mode 100644 app/views/merge_requests/show/_mr_box.html.haml delete mode 100644 app/views/merge_requests/show/_mr_ci.html.haml delete mode 100644 app/views/merge_requests/show/_mr_title.html.haml delete mode 100644 app/views/milestones/_form.html.haml delete mode 100644 app/views/milestones/_issues.html.haml delete mode 100644 app/views/milestones/_merge_request.html.haml delete mode 100644 app/views/milestones/_milestone.html.haml delete mode 100644 app/views/milestones/edit.html.haml delete mode 100644 app/views/milestones/index.html.haml delete mode 100644 app/views/milestones/new.html.haml delete mode 100644 app/views/milestones/show.html.haml delete mode 100644 app/views/milestones/update.js.haml delete mode 100644 app/views/network/_head.html.haml delete mode 100644 app/views/network/show.html.haml delete mode 100644 app/views/network/show.json.erb delete mode 100644 app/views/notes/_diff_note_link.html.haml delete mode 100644 app/views/notes/_diff_notes_with_reply.html.haml delete mode 100644 app/views/notes/_discussion.html.haml delete mode 100644 app/views/notes/_discussion_diff.html.haml delete mode 100644 app/views/notes/_discussion_reply_button.html.haml delete mode 100644 app/views/notes/_form.html.haml delete mode 100644 app/views/notes/_form_errors.html.haml delete mode 100644 app/views/notes/_note.html.haml delete mode 100644 app/views/notes/_notes.html.haml delete mode 100644 app/views/notes/_notes_with_form.html.haml delete mode 100644 app/views/notes/create.js.haml delete mode 100644 app/views/notes/index.js.haml create mode 100644 app/views/projects/blame/_head.html.haml create mode 100644 app/views/projects/blame/show.html.haml create mode 100644 app/views/projects/blob/_actions.html.haml create mode 100644 app/views/projects/blob/_blob.html.haml create mode 100644 app/views/projects/blob/_download.html.haml create mode 100644 app/views/projects/blob/_image.html.haml create mode 100644 app/views/projects/blob/_text.html.haml create mode 100644 app/views/projects/blob/show.html.haml create mode 100644 app/views/projects/commit/_commit_box.html.haml create mode 100644 app/views/projects/commit/huge_commit.html.haml create mode 100644 app/views/projects/commit/show.html.haml create mode 100644 app/views/projects/commits/_commit.html.haml create mode 100644 app/views/projects/commits/_commits.html.haml create mode 100644 app/views/projects/commits/_diff_head.html.haml create mode 100644 app/views/projects/commits/_diffs.html.haml create mode 100644 app/views/projects/commits/_head.html.haml create mode 100644 app/views/projects/commits/_image.html.haml create mode 100644 app/views/projects/commits/_text_file.html.haml create mode 100644 app/views/projects/commits/show.atom.builder create mode 100644 app/views/projects/commits/show.html.haml create mode 100644 app/views/projects/commits/show.js.haml create mode 100644 app/views/projects/compare/_form.html.haml create mode 100644 app/views/projects/compare/index.html.haml create mode 100644 app/views/projects/compare/show.html.haml create mode 100644 app/views/projects/deploy_keys/_deploy_key.html.haml create mode 100644 app/views/projects/deploy_keys/_form.html.haml create mode 100644 app/views/projects/deploy_keys/index.html.haml create mode 100644 app/views/projects/deploy_keys/new.html.haml create mode 100644 app/views/projects/deploy_keys/show.html.haml create mode 100644 app/views/projects/edit_tree/show.html.haml create mode 100644 app/views/projects/graphs/show.html.haml create mode 100644 app/views/projects/graphs/show.js.haml create mode 100644 app/views/projects/hooks/_data_ex.html.erb create mode 100644 app/views/projects/hooks/index.html.haml create mode 100644 app/views/projects/issues/_filter.html.haml create mode 100644 app/views/projects/issues/_form.html.haml create mode 100644 app/views/projects/issues/_head.html.haml create mode 100644 app/views/projects/issues/_issue.html.haml create mode 100644 app/views/projects/issues/_issues.html.haml create mode 100644 app/views/projects/issues/edit.html.haml create mode 100644 app/views/projects/issues/index.atom.builder create mode 100644 app/views/projects/issues/index.html.haml create mode 100644 app/views/projects/issues/index.js.haml create mode 100644 app/views/projects/issues/new.html.haml create mode 100644 app/views/projects/issues/show.html.haml create mode 100644 app/views/projects/issues/update.js.haml create mode 100644 app/views/projects/labels/_label.html.haml create mode 100644 app/views/projects/labels/index.html.haml create mode 100644 app/views/projects/merge_requests/_filter.html.haml create mode 100644 app/views/projects/merge_requests/_form.html.haml create mode 100644 app/views/projects/merge_requests/_head.html.haml create mode 100644 app/views/projects/merge_requests/_merge_request.html.haml create mode 100644 app/views/projects/merge_requests/_show.html.haml create mode 100644 app/views/projects/merge_requests/automerge.js.haml create mode 100644 app/views/projects/merge_requests/branch_from.js.haml create mode 100644 app/views/projects/merge_requests/branch_to.js.haml create mode 100644 app/views/projects/merge_requests/commits.js.haml create mode 100644 app/views/projects/merge_requests/diffs.html.haml create mode 100644 app/views/projects/merge_requests/diffs.js.haml create mode 100644 app/views/projects/merge_requests/edit.html.haml create mode 100644 app/views/projects/merge_requests/index.html.haml create mode 100644 app/views/projects/merge_requests/invalid.html.haml create mode 100644 app/views/projects/merge_requests/new.html.haml create mode 100644 app/views/projects/merge_requests/show.html.haml create mode 100644 app/views/projects/merge_requests/show.js.haml create mode 100644 app/views/projects/merge_requests/show/_commits.html.haml create mode 100644 app/views/projects/merge_requests/show/_diffs.html.haml create mode 100644 app/views/projects/merge_requests/show/_how_to_merge.html.haml create mode 100644 app/views/projects/merge_requests/show/_mr_accept.html.haml create mode 100644 app/views/projects/merge_requests/show/_mr_box.html.haml create mode 100644 app/views/projects/merge_requests/show/_mr_ci.html.haml create mode 100644 app/views/projects/merge_requests/show/_mr_title.html.haml create mode 100644 app/views/projects/milestones/_form.html.haml create mode 100644 app/views/projects/milestones/_issues.html.haml create mode 100644 app/views/projects/milestones/_merge_request.html.haml create mode 100644 app/views/projects/milestones/_milestone.html.haml create mode 100644 app/views/projects/milestones/edit.html.haml create mode 100644 app/views/projects/milestones/index.html.haml create mode 100644 app/views/projects/milestones/new.html.haml create mode 100644 app/views/projects/milestones/show.html.haml create mode 100644 app/views/projects/milestones/update.js.haml create mode 100644 app/views/projects/network/_head.html.haml create mode 100644 app/views/projects/network/show.html.haml create mode 100644 app/views/projects/network/show.json.erb create mode 100644 app/views/projects/notes/_diff_note_link.html.haml create mode 100644 app/views/projects/notes/_diff_notes_with_reply.html.haml create mode 100644 app/views/projects/notes/_discussion.html.haml create mode 100644 app/views/projects/notes/_discussion_diff.html.haml create mode 100644 app/views/projects/notes/_discussion_reply_button.html.haml create mode 100644 app/views/projects/notes/_form.html.haml create mode 100644 app/views/projects/notes/_form_errors.html.haml create mode 100644 app/views/projects/notes/_note.html.haml create mode 100644 app/views/projects/notes/_notes.html.haml create mode 100644 app/views/projects/notes/_notes_with_form.html.haml create mode 100644 app/views/projects/notes/create.js.haml create mode 100644 app/views/projects/notes/index.js.haml create mode 100644 app/views/projects/protected_branches/index.html.haml create mode 100644 app/views/projects/refs/logs_tree.js.haml create mode 100644 app/views/projects/repositories/_branch.html.haml create mode 100644 app/views/projects/repositories/_feed.html.haml create mode 100644 app/views/projects/repositories/_filter.html.haml create mode 100644 app/views/projects/repositories/branches.html.haml create mode 100644 app/views/projects/repositories/show.html.haml create mode 100644 app/views/projects/repositories/stats.html.haml create mode 100644 app/views/projects/repositories/tags.html.haml create mode 100644 app/views/projects/services/_form.html.haml create mode 100644 app/views/projects/services/edit.html.haml create mode 100644 app/views/projects/services/index.html.haml create mode 100644 app/views/projects/team_members/_form.html.haml create mode 100644 app/views/projects/team_members/_group_members.html.haml create mode 100644 app/views/projects/team_members/_team.html.haml create mode 100644 app/views/projects/team_members/_team_member.html.haml create mode 100644 app/views/projects/team_members/import.html.haml create mode 100644 app/views/projects/team_members/index.html.haml create mode 100644 app/views/projects/team_members/new.html.haml create mode 100644 app/views/projects/team_members/update.js.haml create mode 100644 app/views/projects/tree/_blob_item.html.haml create mode 100644 app/views/projects/tree/_readme.html.haml create mode 100644 app/views/projects/tree/_submodule_item.html.haml create mode 100644 app/views/projects/tree/_tree.html.haml create mode 100644 app/views/projects/tree/_tree_commit_column.html.haml create mode 100644 app/views/projects/tree/_tree_item.html.haml create mode 100644 app/views/projects/tree/show.html.haml create mode 100644 app/views/projects/walls/show.html.haml create mode 100644 app/views/projects/wikis/_form.html.haml create mode 100644 app/views/projects/wikis/_main_links.html.haml create mode 100644 app/views/projects/wikis/_nav.html.haml create mode 100644 app/views/projects/wikis/_new.html.haml create mode 100644 app/views/projects/wikis/edit.html.haml create mode 100644 app/views/projects/wikis/empty.html.haml create mode 100644 app/views/projects/wikis/git_access.html.haml create mode 100644 app/views/projects/wikis/history.html.haml create mode 100644 app/views/projects/wikis/pages.html.haml create mode 100644 app/views/projects/wikis/show.html.haml delete mode 100644 app/views/protected_branches/index.html.haml delete mode 100644 app/views/refs/logs_tree.js.haml delete mode 100644 app/views/repositories/_branch.html.haml delete mode 100644 app/views/repositories/_feed.html.haml delete mode 100644 app/views/repositories/_filter.html.haml delete mode 100644 app/views/repositories/branches.html.haml delete mode 100644 app/views/repositories/show.html.haml delete mode 100644 app/views/repositories/stats.html.haml delete mode 100644 app/views/repositories/tags.html.haml delete mode 100644 app/views/services/_form.html.haml delete mode 100644 app/views/services/edit.html.haml delete mode 100644 app/views/services/index.html.haml delete mode 100644 app/views/team_members/_form.html.haml delete mode 100644 app/views/team_members/_group_members.html.haml delete mode 100644 app/views/team_members/_team.html.haml delete mode 100644 app/views/team_members/_team_member.html.haml delete mode 100644 app/views/team_members/import.html.haml delete mode 100644 app/views/team_members/index.html.haml delete mode 100644 app/views/team_members/new.html.haml delete mode 100644 app/views/team_members/update.js.haml delete mode 100644 app/views/tree/_blob_item.html.haml delete mode 100644 app/views/tree/_readme.html.haml delete mode 100644 app/views/tree/_submodule_item.html.haml delete mode 100644 app/views/tree/_tree.html.haml delete mode 100644 app/views/tree/_tree_commit_column.html.haml delete mode 100644 app/views/tree/_tree_item.html.haml delete mode 100644 app/views/tree/show.html.haml delete mode 100644 app/views/walls/show.html.haml delete mode 100644 app/views/wikis/_form.html.haml delete mode 100644 app/views/wikis/_main_links.html.haml delete mode 100644 app/views/wikis/_nav.html.haml delete mode 100644 app/views/wikis/_new.html.haml delete mode 100644 app/views/wikis/edit.html.haml delete mode 100644 app/views/wikis/empty.html.haml delete mode 100644 app/views/wikis/git_access.html.haml delete mode 100644 app/views/wikis/history.html.haml delete mode 100644 app/views/wikis/pages.html.haml delete mode 100644 app/views/wikis/show.html.haml diff --git a/app/assets/javascripts/dispatcher.js.coffee b/app/assets/javascripts/dispatcher.js.coffee index ce53d14d671..8ce13e6851e 100644 --- a/app/assets/javascripts/dispatcher.js.coffee +++ b/app/assets/javascripts/dispatcher.js.coffee @@ -18,19 +18,19 @@ class Dispatcher path = page.split(':') switch page - when 'issues:index' + when 'projects:issues:index' Issues.init() when 'dashboard:show' new Dashboard() - when 'commit:show' + when 'projects:commit:show' new Commit() - when 'groups:show', 'teams:show', 'projects:show' + when 'groups:show', 'projects:show' Pager.init(20, true) when 'projects:new', 'projects:edit' new Project() - when 'walls:show' + when 'projects:walls:show' new Wall(project_id) - when 'teams:members:index' + when 'projects:teams:members:index' new TeamMembers() when 'groups:people' new GroupMembers() diff --git a/app/controllers/blame_controller.rb b/app/controllers/blame_controller.rb deleted file mode 100644 index c950af56e26..00000000000 --- a/app/controllers/blame_controller.rb +++ /dev/null @@ -1,14 +0,0 @@ -# Controller for viewing a file's blame -class BlameController < ProjectResourceController - include ExtractsPath - - # Authorize - before_filter :authorize_read_project! - before_filter :authorize_code_access! - before_filter :require_non_empty_project - - def show - @blob = Gitlab::Git::Blob.new(@repository, @commit.id, @ref, @path) - @blame = Gitlab::Git::Blame.new(project.repository, @commit.id, @path) - end -end diff --git a/app/controllers/blob_controller.rb b/app/controllers/blob_controller.rb deleted file mode 100644 index 3547dfe2323..00000000000 --- a/app/controllers/blob_controller.rb +++ /dev/null @@ -1,13 +0,0 @@ -# Controller for viewing a file's blame -class BlobController < ProjectResourceController - include ExtractsPath - - # Authorize - before_filter :authorize_read_project! - before_filter :authorize_code_access! - before_filter :require_non_empty_project - - def show - @blob = Gitlab::Git::Blob.new(@repository, @commit.id, @ref, @path) - end -end diff --git a/app/controllers/commit_controller.rb b/app/controllers/commit_controller.rb deleted file mode 100644 index a164de33107..00000000000 --- a/app/controllers/commit_controller.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Controller for a specific Commit -# -# Not to be confused with CommitsController, plural. -class CommitController < ProjectResourceController - # Authorize - before_filter :authorize_read_project! - before_filter :authorize_code_access! - before_filter :require_non_empty_project - - def show - result = CommitLoadContext.new(project, current_user, params).execute - - @commit = result[:commit] - - if @commit.nil? - git_not_found! - return - end - - @suppress_diff = result[:suppress_diff] - - @note = result[:note] - @line_notes = result[:line_notes] - @notes_count = result[:notes_count] - @target_type = :commit - @target_id = @commit.id - - @comments_allowed = @reply_allowed = true - @comments_target = { noteable_type: 'Commit', - commit_id: @commit.id } - - respond_to do |format| - format.html do - if result[:status] == :huge_commit - render "huge_commit" and return - end - end - - format.diff { render text: @commit.to_diff } - format.patch { render text: @commit.to_patch } - end - end -end diff --git a/app/controllers/commits_controller.rb b/app/controllers/commits_controller.rb deleted file mode 100644 index cde1f459d76..00000000000 --- a/app/controllers/commits_controller.rb +++ /dev/null @@ -1,23 +0,0 @@ -require "base64" - -class CommitsController < ProjectResourceController - include ExtractsPath - - # Authorize - before_filter :authorize_read_project! - before_filter :authorize_code_access! - before_filter :require_non_empty_project - - def show - @repo = @project.repository - @limit, @offset = (params[:limit] || 40), (params[:offset] || 0) - - @commits = @repo.commits(@ref, @path, @limit, @offset) - - respond_to do |format| - format.html # index.html.erb - format.js - format.atom { render layout: false } - end - end -end diff --git a/app/controllers/compare_controller.rb b/app/controllers/compare_controller.rb deleted file mode 100644 index 750e9c2380e..00000000000 --- a/app/controllers/compare_controller.rb +++ /dev/null @@ -1,23 +0,0 @@ -class CompareController < ProjectResourceController - # Authorize - before_filter :authorize_read_project! - before_filter :authorize_code_access! - before_filter :require_non_empty_project - - def index - end - - def show - compare = Gitlab::Git::Compare.new(project.repository, params[:from], params[:to]) - - @commits = compare.commits - @commit = compare.commit - @diffs = compare.diffs - @refs_are_same = compare.same - @line_notes = [] - end - - def create - redirect_to project_compare_path(@project, params[:from], params[:to]) - end -end diff --git a/app/controllers/deploy_keys_controller.rb b/app/controllers/deploy_keys_controller.rb deleted file mode 100644 index 4bd810f20c0..00000000000 --- a/app/controllers/deploy_keys_controller.rb +++ /dev/null @@ -1,61 +0,0 @@ -class DeployKeysController < ProjectResourceController - respond_to :html - - # Authorize - before_filter :authorize_admin_project! - - layout "project_settings" - - def index - @enabled_keys = @project.deploy_keys.all - @available_keys = available_keys - @enabled_keys - end - - def show - @key = @project.deploy_keys.find(params[:id]) - end - - def new - @key = @project.deploy_keys.new - - respond_with(@key) - end - - def create - @key = DeployKey.new(params[:deploy_key]) - - if @key.valid? && @project.deploy_keys << @key - redirect_to project_deploy_keys_path(@project) - else - render "new" - end - end - - def destroy - @key = @project.deploy_keys.find(params[:id]) - @key.destroy - - respond_to do |format| - format.html { redirect_to project_deploy_keys_url } - format.js { render nothing: true } - end - end - - def enable - project.deploy_keys << available_keys.find(params[:id]) - - redirect_to project_deploy_keys_path(@project) - end - - def disable - @project.deploy_keys_projects.where(deploy_key_id: params[:id]).last.destroy - - redirect_to project_deploy_keys_path(@project) - end - - protected - - def available_keys - @available_keys ||= current_user.accessible_deploy_keys - end -end diff --git a/app/controllers/edit_tree_controller.rb b/app/controllers/edit_tree_controller.rb deleted file mode 100644 index 9ed7a2143e4..00000000000 --- a/app/controllers/edit_tree_controller.rb +++ /dev/null @@ -1,49 +0,0 @@ -# Controller for edit a repository's file -class EditTreeController < ProjectResourceController - include ExtractsPath - - # Authorize - before_filter :authorize_read_project! - before_filter :authorize_code_access! - before_filter :require_non_empty_project - - before_filter :edit_requirements, only: [:show, :update] - - def show - @last_commit = @project.repository.last_commit_for(@ref, @path).sha - end - - def update - edit_file_action = Gitlab::Satellite::EditFileAction.new(current_user, @project, @ref, @path) - updated_successfully = edit_file_action.commit!( - params[:content], - params[:commit_message], - params[:last_commit] - ) - - if updated_successfully - redirect_to project_blob_path(@project, @id), notice: "Your changes have been successfully commited" - else - flash[:notice] = "Your changes could not be commited, because the file has been changed" - render :show - end - end - - private - - def edit_requirements - @blob = Gitlab::Git::Blob.new(@repository, @commit.id, @ref, @path) - - unless @blob.exists? && @blob.text? - redirect_to project_blob_path(@project, @id), notice: "You can only edit text files" - end - - allowed = if project.protected_branch? @ref - can?(current_user, :push_code_to_protected_branches, project) - else - can?(current_user, :push_code, project) - end - - return access_denied! unless allowed - end -end diff --git a/app/controllers/graphs_controller.rb b/app/controllers/graphs_controller.rb deleted file mode 100644 index 6c2ac5fcbf4..00000000000 --- a/app/controllers/graphs_controller.rb +++ /dev/null @@ -1,17 +0,0 @@ -class GraphsController < ProjectResourceController - # Authorize - before_filter :authorize_read_project! - before_filter :authorize_code_access! - before_filter :require_non_empty_project - - def show - respond_to do |format| - format.html - format.js do - @repo = @project.repository - @stats = Gitlab::Git::GitStats.new(@repo.raw, @repo.root_ref) - @log = @stats.parsed_log.to_json rescue [] - end - end - end -end diff --git a/app/controllers/hooks_controller.rb b/app/controllers/hooks_controller.rb deleted file mode 100644 index feaa16b6875..00000000000 --- a/app/controllers/hooks_controller.rb +++ /dev/null @@ -1,39 +0,0 @@ -class HooksController < ProjectResourceController - # Authorize - before_filter :authorize_read_project! - before_filter :authorize_admin_project!, only: [:new, :create, :destroy] - - respond_to :html - - layout "project_settings" - - def index - @hooks = @project.hooks.all - @hook = ProjectHook.new - end - - def create - @hook = @project.hooks.new(params[:hook]) - @hook.save - - if @hook.valid? - redirect_to project_hooks_path(@project) - else - @hooks = @project.hooks.all - render :index - end - end - - def test - TestHookContext.new(project, current_user, params).execute - - redirect_to :back - end - - def destroy - @hook = @project.hooks.find(params[:id]) - @hook.destroy - - redirect_to project_hooks_path(@project) - end -end diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb deleted file mode 100644 index 65e72792924..00000000000 --- a/app/controllers/issues_controller.rb +++ /dev/null @@ -1,114 +0,0 @@ -class IssuesController < ProjectResourceController - before_filter :module_enabled - before_filter :issue, only: [:edit, :update, :show] - - # Allow read any issue - before_filter :authorize_read_issue! - - # Allow write(create) issue - before_filter :authorize_write_issue!, only: [:new, :create] - - # Allow modify issue - before_filter :authorize_modify_issue!, only: [:edit, :update] - - respond_to :js, :html - - def index - terms = params['issue_search'] - - @issues = issues_filtered - @issues = @issues.where("title LIKE ?", "%#{terms}%") if terms.present? - @issues = @issues.page(params[:page]).per(20) - - - assignee_id, milestone_id = params[:assignee_id], params[:milestone_id] - - @assignee = @project.team.find(assignee_id) if assignee_id.present? && !assignee_id.to_i.zero? - @milestone = @project.milestones.find(milestone_id) if milestone_id.present? && !milestone_id.to_i.zero? - - respond_to do |format| - format.html # index.html.erb - format.js - format.atom { render layout: false } - end - end - - def new - @issue = @project.issues.new(params[:issue]) - respond_with(@issue) - end - - def edit - respond_with(@issue) - end - - def show - @note = @project.notes.new(noteable: @issue) - @target_type = :issue - @target_id = @issue.id - - respond_to do |format| - format.html - format.js - end - end - - def create - @issue = @project.issues.new(params[:issue]) - @issue.author = current_user - @issue.save - - respond_to do |format| - format.html do - if @issue.valid? - redirect_to project_issue_path(@project, @issue) - else - render :new - end - end - format.js - end - end - - def update - @issue.update_attributes(params[:issue].merge(author_id_of_changes: current_user.id)) - - respond_to do |format| - format.js - format.html do - if @issue.valid? - redirect_to [@project, @issue] - else - render :edit - end - end - end - end - - def bulk_update - result = Issues::BulkUpdateContext.new(project, current_user, params).execute - redirect_to :back, notice: "#{result[:count]} issues updated" - end - - protected - - def issue - @issue ||= @project.issues.find(params[:id]) - end - - def authorize_modify_issue! - return render_404 unless can?(current_user, :modify_issue, @issue) - end - - def authorize_admin_issue! - return render_404 unless can?(current_user, :admin_issue, @issue) - end - - def module_enabled - return render_404 unless @project.issues_enabled - end - - def issues_filtered - @issues = Issues::ListContext.new(project, current_user, params).execute - end -end diff --git a/app/controllers/labels_controller.rb b/app/controllers/labels_controller.rb deleted file mode 100644 index 0e78cecf4d1..00000000000 --- a/app/controllers/labels_controller.rb +++ /dev/null @@ -1,24 +0,0 @@ -class LabelsController < ProjectResourceController - before_filter :module_enabled - - # Allow read any issue - before_filter :authorize_read_issue! - - respond_to :js, :html - - def index - @labels = @project.issues_labels - end - - def generate - Gitlab::IssuesLabels.generate(@project) - - redirect_to project_labels_path(@project) - end - - protected - - def module_enabled - return render_404 unless @project.issues_enabled - end -end diff --git a/app/controllers/merge_requests_controller.rb b/app/controllers/merge_requests_controller.rb deleted file mode 100644 index 8d19e1b8b0b..00000000000 --- a/app/controllers/merge_requests_controller.rb +++ /dev/null @@ -1,163 +0,0 @@ -require 'gitlab/satellite/satellite' - -class MergeRequestsController < ProjectResourceController - before_filter :module_enabled - before_filter :merge_request, only: [:edit, :update, :show, :commits, :diffs, :automerge, :automerge_check, :ci_status] - before_filter :validates_merge_request, only: [:show, :diffs] - before_filter :define_show_vars, only: [:show, :diffs] - - # Allow read any merge_request - before_filter :authorize_read_merge_request! - - # Allow write(create) merge_request - before_filter :authorize_write_merge_request!, only: [:new, :create] - - # Allow modify merge_request - before_filter :authorize_modify_merge_request!, only: [:close, :edit, :update, :sort] - - def index - @merge_requests = MergeRequestsLoadContext.new(project, current_user, params).execute - end - - def show - respond_to do |format| - format.html - format.js - - format.diff { render text: @merge_request.to_diff } - format.patch { render text: @merge_request.to_patch } - end - end - - def diffs - @diffs = @merge_request.diffs - @commit = @merge_request.last_commit - - @comments_allowed = @reply_allowed = true - @comments_target = { noteable_type: 'MergeRequest', - noteable_id: @merge_request.id } - @line_notes = @merge_request.notes.where("line_code is not null") - end - - def new - @merge_request = @project.merge_requests.new(params[:merge_request]) - end - - def edit - end - - def create - @merge_request = @project.merge_requests.new(params[:merge_request]) - @merge_request.author = current_user - - if @merge_request.save - @merge_request.reload_code - redirect_to [@project, @merge_request], notice: 'Merge request was successfully created.' - else - render "new" - end - end - - def update - if @merge_request.update_attributes(params[:merge_request].merge(author_id_of_changes: current_user.id)) - @merge_request.reload_code - @merge_request.mark_as_unchecked - redirect_to [@project, @merge_request], notice: 'Merge request was successfully updated.' - else - render "edit" - end - end - - def automerge_check - if @merge_request.unchecked? - @merge_request.check_if_can_be_merged - end - render json: {merge_status: @merge_request.merge_status_name} - rescue Gitlab::SatelliteNotExistError - render json: {merge_status: :no_satellite} - end - - def automerge - return access_denied! unless allowed_to_merge? - - if @merge_request.opened? && @merge_request.can_be_merged? - @merge_request.should_remove_source_branch = params[:should_remove_source_branch] - @merge_request.automerge!(current_user) - @status = true - else - @status = false - end - end - - def branch_from - @commit = @repository.commit(params[:ref]) - end - - def branch_to - @commit = @repository.commit(params[:ref]) - end - - def ci_status - status = project.gitlab_ci_service.commit_status(merge_request.last_commit.sha) - response = { status: status } - - render json: response - end - - protected - - def merge_request - @merge_request ||= @project.merge_requests.find(params[:id]) - end - - def authorize_modify_merge_request! - return render_404 unless can?(current_user, :modify_merge_request, @merge_request) - end - - def authorize_admin_merge_request! - return render_404 unless can?(current_user, :admin_merge_request, @merge_request) - end - - def module_enabled - return render_404 unless @project.merge_requests_enabled - end - - def validates_merge_request - # Show git not found page if target branch doesn't exist - return invalid_mr unless @project.repository.branch_names.include?(@merge_request.target_branch) - - # Show git not found page if source branch doesn't exist - # and there is no saved commits between source & target branch - return invalid_mr if !@project.repository.branch_names.include?(@merge_request.source_branch) && @merge_request.commits.blank? - end - - def define_show_vars - # Build a note object for comment form - @note = @project.notes.new(noteable: @merge_request) - - # Get commits from repository - # or from cache if already merged - @commits = @merge_request.commits - - @allowed_to_merge = allowed_to_merge? - @show_merge_controls = @merge_request.opened? && @commits.any? && @allowed_to_merge - - @target_type = :merge_request - @target_id = @merge_request.id - end - - def allowed_to_merge? - action = if project.protected_branch?(@merge_request.target_branch) - :push_code_to_protected_branches - else - :push_code - end - - can?(current_user, action, @project) - end - - def invalid_mr - # Render special view for MR with removed source or target branch - render 'invalid' - end -end diff --git a/app/controllers/milestones_controller.rb b/app/controllers/milestones_controller.rb deleted file mode 100644 index 25647f97576..00000000000 --- a/app/controllers/milestones_controller.rb +++ /dev/null @@ -1,94 +0,0 @@ -class MilestonesController < ProjectResourceController - before_filter :module_enabled - before_filter :milestone, only: [:edit, :update, :destroy, :show] - - # Allow read any milestone - before_filter :authorize_read_milestone! - - # Allow admin milestone - before_filter :authorize_admin_milestone!, except: [:index, :show] - - respond_to :html - - def index - @milestones = case params[:f] - when 'all'; @project.milestones.order("state, due_date DESC") - when 'closed'; @project.milestones.closed.order("due_date DESC") - else @project.milestones.active.order("due_date DESC") - end - - @milestones = @milestones.includes(:project) - @milestones = @milestones.page(params[:page]).per(20) - end - - def new - @milestone = @project.milestones.new - respond_with(@milestone) - end - - def edit - respond_with(@milestone) - end - - def show - @issues = @milestone.issues - @users = @milestone.participants.uniq - @merge_requests = @milestone.merge_requests - - respond_to do |format| - format.html - format.js - end - end - - def create - @milestone = @project.milestones.new(params[:milestone]) - @milestone.author_id_of_changes = current_user.id - - if @milestone.save - redirect_to project_milestone_path(@project, @milestone) - else - render "new" - end - end - - def update - @milestone.update_attributes(params[:milestone].merge(author_id_of_changes: current_user.id)) - - respond_to do |format| - format.js - format.html do - if @milestone.valid? - redirect_to [@project, @milestone] - else - render :edit - end - end - end - end - - def destroy - return access_denied! unless can?(current_user, :admin_milestone, @milestone) - - @milestone.destroy - - respond_to do |format| - format.html { redirect_to project_milestones_path } - format.js { render nothing: true } - end - end - - protected - - def milestone - @milestone ||= @project.milestones.find(params[:id]) - end - - def authorize_admin_milestone! - return render_404 unless can?(current_user, :admin_milestone, @project) - end - - def module_enabled - return render_404 unless @project.issues_enabled - end -end diff --git a/app/controllers/network_controller.rb b/app/controllers/network_controller.rb deleted file mode 100644 index 3c8e747ba4e..00000000000 --- a/app/controllers/network_controller.rb +++ /dev/null @@ -1,23 +0,0 @@ -class NetworkController < ProjectResourceController - include ExtractsPath - include ApplicationHelper - - # Authorize - before_filter :authorize_read_project! - before_filter :authorize_code_access! - before_filter :require_non_empty_project - - def show - if @options[:q] - @commit = @project.repository.commit(@options[:q]) || @commit - end - - respond_to do |format| - format.html - - format.json do - @graph = Network::Graph.new(project, @ref, @commit, @options[:filter_ref]) - end - end - end -end diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb deleted file mode 100644 index 15ca963f281..00000000000 --- a/app/controllers/notes_controller.rb +++ /dev/null @@ -1,76 +0,0 @@ -class NotesController < ProjectResourceController - # Authorize - before_filter :authorize_read_note! - before_filter :authorize_write_note!, only: [:create] - - respond_to :js - - def index - @notes = Notes::LoadContext.new(project, current_user, params).execute - @target_type = params[:target_type].camelize - @target_id = params[:target_id] - - if params[:target_type] == "merge_request" - @discussions = discussions_from_notes - end - - respond_with(@notes) - end - - def create - @note = Notes::CreateContext.new(project, current_user, params).execute - @target_type = params[:target_type].camelize - @target_id = params[:target_id] - - respond_to do |format| - format.html {redirect_to :back} - format.js - end - end - - def destroy - @note = @project.notes.find(params[:id]) - return access_denied! unless can?(current_user, :admin_note, @note) - @note.destroy - - respond_to do |format| - format.js { render nothing: true } - end - end - - def preview - render text: view_context.markdown(params[:note]) - end - - protected - - def discussion_notes_for(note) - @notes.select do |other_note| - note.discussion_id == other_note.discussion_id - end - end - - def discussions_from_notes - discussion_ids = [] - discussions = [] - - @notes.each do |note| - next if discussion_ids.include?(note.discussion_id) - - # don't group notes for the main target - if note_for_main_target?(note) - discussions << [note] - else - discussions << discussion_notes_for(note) - discussion_ids << note.discussion_id - end - end - - discussions - end - - # Helps to distinguish e.g. commit notes in mr notes list - def note_for_main_target?(note) - (@target_type.camelize == note.noteable_type && !note.for_diff_line?) - end -end diff --git a/app/controllers/project_resource_controller.rb b/app/controllers/project_resource_controller.rb deleted file mode 100644 index ea78b3ff7c4..00000000000 --- a/app/controllers/project_resource_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -class ProjectResourceController < ApplicationController - before_filter :project - before_filter :repository -end diff --git a/app/controllers/projects/application_controller.rb b/app/controllers/projects/application_controller.rb index 86e4a7cbd6b..1f2a75175cf 100644 --- a/app/controllers/projects/application_controller.rb +++ b/app/controllers/projects/application_controller.rb @@ -1,4 +1,5 @@ class Projects::ApplicationController < ApplicationController before_filter :project before_filter :repository + layout 'projects' end diff --git a/app/controllers/projects/blame_controller.rb b/app/controllers/projects/blame_controller.rb new file mode 100644 index 00000000000..e58b4507202 --- /dev/null +++ b/app/controllers/projects/blame_controller.rb @@ -0,0 +1,14 @@ +# Controller for viewing a file's blame +class Projects::BlameController < Projects::ApplicationController + include ExtractsPath + + # Authorize + before_filter :authorize_read_project! + before_filter :authorize_code_access! + before_filter :require_non_empty_project + + def show + @blob = Gitlab::Git::Blob.new(@repository, @commit.id, @ref, @path) + @blame = Gitlab::Git::Blame.new(project.repository, @commit.id, @path) + end +end diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb new file mode 100644 index 00000000000..b1329c01ce7 --- /dev/null +++ b/app/controllers/projects/blob_controller.rb @@ -0,0 +1,13 @@ +# Controller for viewing a file's blame +class Projects::BlobController < Projects::ApplicationController + include ExtractsPath + + # Authorize + before_filter :authorize_read_project! + before_filter :authorize_code_access! + before_filter :require_non_empty_project + + def show + @blob = Gitlab::Git::Blob.new(@repository, @commit.id, @ref, @path) + end +end diff --git a/app/controllers/projects/commit_controller.rb b/app/controllers/projects/commit_controller.rb new file mode 100644 index 00000000000..6a2d2315c1d --- /dev/null +++ b/app/controllers/projects/commit_controller.rb @@ -0,0 +1,43 @@ +# Controller for a specific Commit +# +# Not to be confused with CommitsController, plural. +class Projects::CommitController < Projects::ApplicationController + # Authorize + before_filter :authorize_read_project! + before_filter :authorize_code_access! + before_filter :require_non_empty_project + + def show + result = CommitLoadContext.new(project, current_user, params).execute + + @commit = result[:commit] + + if @commit.nil? + git_not_found! + return + end + + @suppress_diff = result[:suppress_diff] + + @note = result[:note] + @line_notes = result[:line_notes] + @notes_count = result[:notes_count] + @target_type = :commit + @target_id = @commit.id + + @comments_allowed = @reply_allowed = true + @comments_target = { noteable_type: 'Commit', + commit_id: @commit.id } + + respond_to do |format| + format.html do + if result[:status] == :huge_commit + render "huge_commit" and return + end + end + + format.diff { render text: @commit.to_diff } + format.patch { render text: @commit.to_patch } + end + end +end diff --git a/app/controllers/projects/commits_controller.rb b/app/controllers/projects/commits_controller.rb new file mode 100644 index 00000000000..bdffc940ea5 --- /dev/null +++ b/app/controllers/projects/commits_controller.rb @@ -0,0 +1,23 @@ +require "base64" + +class Projects::CommitsController < Projects::ApplicationController + include ExtractsPath + + # Authorize + before_filter :authorize_read_project! + before_filter :authorize_code_access! + before_filter :require_non_empty_project + + def show + @repo = @project.repository + @limit, @offset = (params[:limit] || 40), (params[:offset] || 0) + + @commits = @repo.commits(@ref, @path, @limit, @offset) + + respond_to do |format| + format.html # index.html.erb + format.js + format.atom { render layout: false } + end + end +end diff --git a/app/controllers/projects/compare_controller.rb b/app/controllers/projects/compare_controller.rb new file mode 100644 index 00000000000..126a2ea50c9 --- /dev/null +++ b/app/controllers/projects/compare_controller.rb @@ -0,0 +1,23 @@ +class Projects::CompareController < Projects::ApplicationController + # Authorize + before_filter :authorize_read_project! + before_filter :authorize_code_access! + before_filter :require_non_empty_project + + def index + end + + def show + compare = Gitlab::Git::Compare.new(project.repository, params[:from], params[:to]) + + @commits = compare.commits + @commit = compare.commit + @diffs = compare.diffs + @refs_are_same = compare.same + @line_notes = [] + end + + def create + redirect_to project_compare_path(@project, params[:from], params[:to]) + end +end diff --git a/app/controllers/projects/deploy_keys_controller.rb b/app/controllers/projects/deploy_keys_controller.rb new file mode 100644 index 00000000000..0750e0a146f --- /dev/null +++ b/app/controllers/projects/deploy_keys_controller.rb @@ -0,0 +1,61 @@ +class Projects::DeployKeysController < Projects::ApplicationController + respond_to :html + + # Authorize + before_filter :authorize_admin_project! + + layout "project_settings" + + def index + @enabled_keys = @project.deploy_keys.all + @available_keys = available_keys - @enabled_keys + end + + def show + @key = @project.deploy_keys.find(params[:id]) + end + + def new + @key = @project.deploy_keys.new + + respond_with(@key) + end + + def create + @key = DeployKey.new(params[:deploy_key]) + + if @key.valid? && @project.deploy_keys << @key + redirect_to project_deploy_keys_path(@project) + else + render "new" + end + end + + def destroy + @key = @project.deploy_keys.find(params[:id]) + @key.destroy + + respond_to do |format| + format.html { redirect_to project_deploy_keys_url } + format.js { render nothing: true } + end + end + + def enable + project.deploy_keys << available_keys.find(params[:id]) + + redirect_to project_deploy_keys_path(@project) + end + + def disable + @project.deploy_keys_projects.where(deploy_key_id: params[:id]).last.destroy + + redirect_to project_deploy_keys_path(@project) + end + + protected + + def available_keys + @available_keys ||= current_user.accessible_deploy_keys + end +end diff --git a/app/controllers/projects/edit_tree_controller.rb b/app/controllers/projects/edit_tree_controller.rb new file mode 100644 index 00000000000..11c97291296 --- /dev/null +++ b/app/controllers/projects/edit_tree_controller.rb @@ -0,0 +1,49 @@ +# Controller for edit a repository's file +class Projects::EditTreeController < Projects::ApplicationController + include ExtractsPath + + # Authorize + before_filter :authorize_read_project! + before_filter :authorize_code_access! + before_filter :require_non_empty_project + + before_filter :edit_requirements, only: [:show, :update] + + def show + @last_commit = @project.repository.last_commit_for(@ref, @path).sha + end + + def update + edit_file_action = Gitlab::Satellite::EditFileAction.new(current_user, @project, @ref, @path) + updated_successfully = edit_file_action.commit!( + params[:content], + params[:commit_message], + params[:last_commit] + ) + + if updated_successfully + redirect_to project_blob_path(@project, @id), notice: "Your changes have been successfully commited" + else + flash[:notice] = "Your changes could not be commited, because the file has been changed" + render :show + end + end + + private + + def edit_requirements + @blob = Gitlab::Git::Blob.new(@repository, @commit.id, @ref, @path) + + unless @blob.exists? && @blob.text? + redirect_to project_blob_path(@project, @id), notice: "You can only edit text files" + end + + allowed = if project.protected_branch? @ref + can?(current_user, :push_code_to_protected_branches, project) + else + can?(current_user, :push_code, project) + end + + return access_denied! unless allowed + end +end diff --git a/app/controllers/projects/graphs_controller.rb b/app/controllers/projects/graphs_controller.rb new file mode 100644 index 00000000000..5ff330ba6ca --- /dev/null +++ b/app/controllers/projects/graphs_controller.rb @@ -0,0 +1,17 @@ +class Projects::GraphsController < Projects::ApplicationController + # Authorize + before_filter :authorize_read_project! + before_filter :authorize_code_access! + before_filter :require_non_empty_project + + def show + respond_to do |format| + format.html + format.js do + @repo = @project.repository + @stats = Gitlab::Git::GitStats.new(@repo.raw, @repo.root_ref) + @log = @stats.parsed_log.to_json rescue [] + end + end + end +end diff --git a/app/controllers/projects/hooks_controller.rb b/app/controllers/projects/hooks_controller.rb new file mode 100644 index 00000000000..3367ddb5d14 --- /dev/null +++ b/app/controllers/projects/hooks_controller.rb @@ -0,0 +1,39 @@ +class Projects::HooksController < Projects::ApplicationController + # Authorize + before_filter :authorize_read_project! + before_filter :authorize_admin_project!, only: [:new, :create, :destroy] + + respond_to :html + + layout "project_settings" + + def index + @hooks = @project.hooks.all + @hook = ProjectHook.new + end + + def create + @hook = @project.hooks.new(params[:hook]) + @hook.save + + if @hook.valid? + redirect_to project_hooks_path(@project) + else + @hooks = @project.hooks.all + render :index + end + end + + def test + TestHookContext.new(project, current_user, params).execute + + redirect_to :back + end + + def destroy + @hook = @project.hooks.find(params[:id]) + @hook.destroy + + redirect_to project_hooks_path(@project) + end +end diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb new file mode 100644 index 00000000000..06f8a1233a3 --- /dev/null +++ b/app/controllers/projects/issues_controller.rb @@ -0,0 +1,114 @@ +class Projects::IssuesController < Projects::ApplicationController + before_filter :module_enabled + before_filter :issue, only: [:edit, :update, :show] + + # Allow read any issue + before_filter :authorize_read_issue! + + # Allow write(create) issue + before_filter :authorize_write_issue!, only: [:new, :create] + + # Allow modify issue + before_filter :authorize_modify_issue!, only: [:edit, :update] + + respond_to :js, :html + + def index + terms = params['issue_search'] + + @issues = issues_filtered + @issues = @issues.where("title LIKE ?", "%#{terms}%") if terms.present? + @issues = @issues.page(params[:page]).per(20) + + + assignee_id, milestone_id = params[:assignee_id], params[:milestone_id] + + @assignee = @project.team.find(assignee_id) if assignee_id.present? && !assignee_id.to_i.zero? + @milestone = @project.milestones.find(milestone_id) if milestone_id.present? && !milestone_id.to_i.zero? + + respond_to do |format| + format.html # index.html.erb + format.js + format.atom { render layout: false } + end + end + + def new + @issue = @project.issues.new(params[:issue]) + respond_with(@issue) + end + + def edit + respond_with(@issue) + end + + def show + @note = @project.notes.new(noteable: @issue) + @target_type = :issue + @target_id = @issue.id + + respond_to do |format| + format.html + format.js + end + end + + def create + @issue = @project.issues.new(params[:issue]) + @issue.author = current_user + @issue.save + + respond_to do |format| + format.html do + if @issue.valid? + redirect_to project_issue_path(@project, @issue) + else + render :new + end + end + format.js + end + end + + def update + @issue.update_attributes(params[:issue].merge(author_id_of_changes: current_user.id)) + + respond_to do |format| + format.js + format.html do + if @issue.valid? + redirect_to [@project, @issue] + else + render :edit + end + end + end + end + + def bulk_update + result = Issues::BulkUpdateContext.new(project, current_user, params).execute + redirect_to :back, notice: "#{result[:count]} issues updated" + end + + protected + + def issue + @issue ||= @project.issues.find(params[:id]) + end + + def authorize_modify_issue! + return render_404 unless can?(current_user, :modify_issue, @issue) + end + + def authorize_admin_issue! + return render_404 unless can?(current_user, :admin_issue, @issue) + end + + def module_enabled + return render_404 unless @project.issues_enabled + end + + def issues_filtered + @issues = Issues::ListContext.new(project, current_user, params).execute + end +end diff --git a/app/controllers/projects/labels_controller.rb b/app/controllers/projects/labels_controller.rb new file mode 100644 index 00000000000..65f9e2b9d57 --- /dev/null +++ b/app/controllers/projects/labels_controller.rb @@ -0,0 +1,24 @@ +class Projects::LabelsController < Projects::ApplicationController + before_filter :module_enabled + + # Allow read any issue + before_filter :authorize_read_issue! + + respond_to :js, :html + + def index + @labels = @project.issues_labels + end + + def generate + Gitlab::IssuesLabels.generate(@project) + + redirect_to project_labels_path(@project) + end + + protected + + def module_enabled + return render_404 unless @project.issues_enabled + end +end diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb new file mode 100644 index 00000000000..0aa8bc8a6df --- /dev/null +++ b/app/controllers/projects/merge_requests_controller.rb @@ -0,0 +1,163 @@ +require 'gitlab/satellite/satellite' + +class Projects::MergeRequestsController < Projects::ApplicationController + before_filter :module_enabled + before_filter :merge_request, only: [:edit, :update, :show, :commits, :diffs, :automerge, :automerge_check, :ci_status] + before_filter :validates_merge_request, only: [:show, :diffs] + before_filter :define_show_vars, only: [:show, :diffs] + + # Allow read any merge_request + before_filter :authorize_read_merge_request! + + # Allow write(create) merge_request + before_filter :authorize_write_merge_request!, only: [:new, :create] + + # Allow modify merge_request + before_filter :authorize_modify_merge_request!, only: [:close, :edit, :update, :sort] + + def index + @merge_requests = MergeRequestsLoadContext.new(project, current_user, params).execute + end + + def show + respond_to do |format| + format.html + format.js + + format.diff { render text: @merge_request.to_diff } + format.patch { render text: @merge_request.to_patch } + end + end + + def diffs + @diffs = @merge_request.diffs + @commit = @merge_request.last_commit + + @comments_allowed = @reply_allowed = true + @comments_target = { noteable_type: 'MergeRequest', + noteable_id: @merge_request.id } + @line_notes = @merge_request.notes.where("line_code is not null") + end + + def new + @merge_request = @project.merge_requests.new(params[:merge_request]) + end + + def edit + end + + def create + @merge_request = @project.merge_requests.new(params[:merge_request]) + @merge_request.author = current_user + + if @merge_request.save + @merge_request.reload_code + redirect_to [@project, @merge_request], notice: 'Merge request was successfully created.' + else + render "new" + end + end + + def update + if @merge_request.update_attributes(params[:merge_request].merge(author_id_of_changes: current_user.id)) + @merge_request.reload_code + @merge_request.mark_as_unchecked + redirect_to [@project, @merge_request], notice: 'Merge request was successfully updated.' + else + render "edit" + end + end + + def automerge_check + if @merge_request.unchecked? + @merge_request.check_if_can_be_merged + end + render json: {merge_status: @merge_request.merge_status_name} + rescue Gitlab::SatelliteNotExistError + render json: {merge_status: :no_satellite} + end + + def automerge + return access_denied! unless allowed_to_merge? + + if @merge_request.opened? && @merge_request.can_be_merged? + @merge_request.should_remove_source_branch = params[:should_remove_source_branch] + @merge_request.automerge!(current_user) + @status = true + else + @status = false + end + end + + def branch_from + @commit = @repository.commit(params[:ref]) + end + + def branch_to + @commit = @repository.commit(params[:ref]) + end + + def ci_status + status = project.gitlab_ci_service.commit_status(merge_request.last_commit.sha) + response = { status: status } + + render json: response + end + + protected + + def merge_request + @merge_request ||= @project.merge_requests.find(params[:id]) + end + + def authorize_modify_merge_request! + return render_404 unless can?(current_user, :modify_merge_request, @merge_request) + end + + def authorize_admin_merge_request! + return render_404 unless can?(current_user, :admin_merge_request, @merge_request) + end + + def module_enabled + return render_404 unless @project.merge_requests_enabled + end + + def validates_merge_request + # Show git not found page if target branch doesn't exist + return invalid_mr unless @project.repository.branch_names.include?(@merge_request.target_branch) + + # Show git not found page if source branch doesn't exist + # and there is no saved commits between source & target branch + return invalid_mr if !@project.repository.branch_names.include?(@merge_request.source_branch) && @merge_request.commits.blank? + end + + def define_show_vars + # Build a note object for comment form + @note = @project.notes.new(noteable: @merge_request) + + # Get commits from repository + # or from cache if already merged + @commits = @merge_request.commits + + @allowed_to_merge = allowed_to_merge? + @show_merge_controls = @merge_request.opened? && @commits.any? && @allowed_to_merge + + @target_type = :merge_request + @target_id = @merge_request.id + end + + def allowed_to_merge? + action = if project.protected_branch?(@merge_request.target_branch) + :push_code_to_protected_branches + else + :push_code + end + + can?(current_user, action, @project) + end + + def invalid_mr + # Render special view for MR with removed source or target branch + render 'invalid' + end +end diff --git a/app/controllers/projects/milestones_controller.rb b/app/controllers/projects/milestones_controller.rb new file mode 100644 index 00000000000..f4ee7427d29 --- /dev/null +++ b/app/controllers/projects/milestones_controller.rb @@ -0,0 +1,94 @@ +class Projects::MilestonesController < Projects::ApplicationController + before_filter :module_enabled + before_filter :milestone, only: [:edit, :update, :destroy, :show] + + # Allow read any milestone + before_filter :authorize_read_milestone! + + # Allow admin milestone + before_filter :authorize_admin_milestone!, except: [:index, :show] + + respond_to :html + + def index + @milestones = case params[:f] + when 'all'; @project.milestones.order("state, due_date DESC") + when 'closed'; @project.milestones.closed.order("due_date DESC") + else @project.milestones.active.order("due_date DESC") + end + + @milestones = @milestones.includes(:project) + @milestones = @milestones.page(params[:page]).per(20) + end + + def new + @milestone = @project.milestones.new + respond_with(@milestone) + end + + def edit + respond_with(@milestone) + end + + def show + @issues = @milestone.issues + @users = @milestone.participants.uniq + @merge_requests = @milestone.merge_requests + + respond_to do |format| + format.html + format.js + end + end + + def create + @milestone = @project.milestones.new(params[:milestone]) + @milestone.author_id_of_changes = current_user.id + + if @milestone.save + redirect_to project_milestone_path(@project, @milestone) + else + render "new" + end + end + + def update + @milestone.update_attributes(params[:milestone].merge(author_id_of_changes: current_user.id)) + + respond_to do |format| + format.js + format.html do + if @milestone.valid? + redirect_to [@project, @milestone] + else + render :edit + end + end + end + end + + def destroy + return access_denied! unless can?(current_user, :admin_milestone, @milestone) + + @milestone.destroy + + respond_to do |format| + format.html { redirect_to project_milestones_path } + format.js { render nothing: true } + end + end + + protected + + def milestone + @milestone ||= @project.milestones.find(params[:id]) + end + + def authorize_admin_milestone! + return render_404 unless can?(current_user, :admin_milestone, @project) + end + + def module_enabled + return render_404 unless @project.issues_enabled + end +end diff --git a/app/controllers/projects/network_controller.rb b/app/controllers/projects/network_controller.rb new file mode 100644 index 00000000000..e4a84f80787 --- /dev/null +++ b/app/controllers/projects/network_controller.rb @@ -0,0 +1,23 @@ +class Projects::NetworkController < Projects::ApplicationController + include ExtractsPath + include ApplicationHelper + + # Authorize + before_filter :authorize_read_project! + before_filter :authorize_code_access! + before_filter :require_non_empty_project + + def show + if @options[:q] + @commit = @project.repository.commit(@options[:q]) || @commit + end + + respond_to do |format| + format.html + + format.json do + @graph = Network::Graph.new(project, @ref, @commit, @options[:filter_ref]) + end + end + end +end diff --git a/app/controllers/projects/notes_controller.rb b/app/controllers/projects/notes_controller.rb new file mode 100644 index 00000000000..ef15e419dbe --- /dev/null +++ b/app/controllers/projects/notes_controller.rb @@ -0,0 +1,76 @@ +class Projects::NotesController < Projects::ApplicationController + # Authorize + before_filter :authorize_read_note! + before_filter :authorize_write_note!, only: [:create] + + respond_to :js + + def index + @notes = Notes::LoadContext.new(project, current_user, params).execute + @target_type = params[:target_type].camelize + @target_id = params[:target_id] + + if params[:target_type] == "merge_request" + @discussions = discussions_from_notes + end + + respond_with(@notes) + end + + def create + @note = Notes::CreateContext.new(project, current_user, params).execute + @target_type = params[:target_type].camelize + @target_id = params[:target_id] + + respond_to do |format| + format.html {redirect_to :back} + format.js + end + end + + def destroy + @note = @project.notes.find(params[:id]) + return access_denied! unless can?(current_user, :admin_note, @note) + @note.destroy + + respond_to do |format| + format.js { render nothing: true } + end + end + + def preview + render text: view_context.markdown(params[:note]) + end + + protected + + def discussion_notes_for(note) + @notes.select do |other_note| + note.discussion_id == other_note.discussion_id + end + end + + def discussions_from_notes + discussion_ids = [] + discussions = [] + + @notes.each do |note| + next if discussion_ids.include?(note.discussion_id) + + # don't group notes for the main target + if note_for_main_target?(note) + discussions << [note] + else + discussions << discussion_notes_for(note) + discussion_ids << note.discussion_id + end + end + + discussions + end + + # Helps to distinguish e.g. commit notes in mr notes list + def note_for_main_target?(note) + (@target_type.camelize == note.noteable_type && !note.for_diff_line?) + end +end diff --git a/app/controllers/projects/protected_branches_controller.rb b/app/controllers/projects/protected_branches_controller.rb new file mode 100644 index 00000000000..81531bb0ac0 --- /dev/null +++ b/app/controllers/projects/protected_branches_controller.rb @@ -0,0 +1,26 @@ +class Projects::ProtectedBranchesController < Projects::ApplicationController + # Authorize + before_filter :authorize_read_project! + before_filter :require_non_empty_project + + before_filter :authorize_admin_project!, only: [:destroy, :create] + + def index + @branches = @project.protected_branches.all + @protected_branch = @project.protected_branches.new + end + + def create + @project.protected_branches.create(params[:protected_branch]) + redirect_to project_protected_branches_path(@project) + end + + def destroy + @project.protected_branches.find(params[:id]).destroy + + respond_to do |format| + format.html { redirect_to project_protected_branches_path } + format.js { render nothing: true } + end + end +end diff --git a/app/controllers/projects/raw_controller.rb b/app/controllers/projects/raw_controller.rb new file mode 100644 index 00000000000..0d35f373e9c --- /dev/null +++ b/app/controllers/projects/raw_controller.rb @@ -0,0 +1,25 @@ +# Controller for viewing a file's raw +class Projects::RawController < Projects::ApplicationController + include ExtractsPath + + # Authorize + before_filter :authorize_read_project! + before_filter :authorize_code_access! + before_filter :require_non_empty_project + + def show + @blob = Gitlab::Git::Blob.new(@repository, @commit.id, @ref, @path) + + if @blob.exists? + send_data( + @blob.data, + type: @blob.mime_type, + disposition: 'inline', + filename: @blob.name + ) + else + not_found! + end + end +end + diff --git a/app/controllers/projects/refs_controller.rb b/app/controllers/projects/refs_controller.rb new file mode 100644 index 00000000000..e5c090e1f4d --- /dev/null +++ b/app/controllers/projects/refs_controller.rb @@ -0,0 +1,43 @@ +class Projects::RefsController < Projects::ApplicationController + include ExtractsPath + + # Authorize + before_filter :authorize_read_project! + before_filter :authorize_code_access! + before_filter :require_non_empty_project + + def switch + respond_to do |format| + format.html do + new_path = if params[:destination] == "tree" + project_tree_path(@project, (@id)) + elsif params[:destination] == "blob" + project_blob_path(@project, (@id)) + elsif params[:destination] == "graph" + project_network_path(@project, @id, @options) + else + project_commits_path(@project, @id) + end + + redirect_to new_path + end + format.js do + @ref = params[:ref] + define_tree_vars + render "tree" + end + end + end + + def logs_tree + contents = @tree.entries + @logs = contents.map do |content| + file = params[:path] ? File.join(params[:path], content.name) : content.name + last_commit = @repo.commits(@commit.id, file, 1).last + { + file_name: content.name, + commit: last_commit + } + end + end +end diff --git a/app/controllers/projects/repositories_controller.rb b/app/controllers/projects/repositories_controller.rb new file mode 100644 index 00000000000..b65af029803 --- /dev/null +++ b/app/controllers/projects/repositories_controller.rb @@ -0,0 +1,41 @@ +class Projects::RepositoriesController < Projects::ApplicationController + # Authorize + before_filter :authorize_read_project! + before_filter :authorize_code_access! + before_filter :require_non_empty_project + + def show + @activities = @repository.commits_with_refs(20) + end + + def branches + @branches = @repository.branches + end + + def tags + @tags = @repository.tags + end + + def stats + @stats = Gitlab::Git::Stats.new(@repository.raw, @repository.root_ref) + @graph = @stats.graph + end + + def archive + unless can?(current_user, :download_code, @project) + render_404 and return + end + + + storage_path = Rails.root.join("tmp", "repositories") + + file_path = @repository.archive_repo(params[:ref], storage_path) + + if file_path + # Send file to user + send_file file_path + else + render_404 + end + end +end diff --git a/app/controllers/projects/services_controller.rb b/app/controllers/projects/services_controller.rb new file mode 100644 index 00000000000..6db22186c14 --- /dev/null +++ b/app/controllers/projects/services_controller.rb @@ -0,0 +1,39 @@ +class Projects::ServicesController < Projects::ApplicationController + # Authorize + before_filter :authorize_admin_project! + before_filter :service, only: [:edit, :update, :test] + + respond_to :html + + layout "project_settings" + + def index + @project.build_missing_services + @services = @project.services.reload + end + + def edit + end + + def update + if @service.update_attributes(params[:service]) + redirect_to edit_project_service_path(@project, @service.to_param) + else + render 'edit' + end + end + + def test + data = GitPushService.new.sample_data(project, current_user) + + @service.execute(data) + + redirect_to :back + end + + private + + def service + @service ||= @project.services.find { |service| service.to_param == params[:id] } + end +end diff --git a/app/controllers/projects/snippets_controller.rb b/app/controllers/projects/snippets_controller.rb index 1165fa1c583..59063103ecb 100644 --- a/app/controllers/projects/snippets_controller.rb +++ b/app/controllers/projects/snippets_controller.rb @@ -14,7 +14,7 @@ class Projects::SnippetsController < Projects::ApplicationController # Allow destroy snippet before_filter :authorize_admin_project_snippet!, only: [:destroy] - layout 'project_resource' + layout 'projects' respond_to :html diff --git a/app/controllers/projects/team_members_controller.rb b/app/controllers/projects/team_members_controller.rb new file mode 100644 index 00000000000..07ad7d86153 --- /dev/null +++ b/app/controllers/projects/team_members_controller.rb @@ -0,0 +1,62 @@ +class Projects::TeamMembersController < Projects::ApplicationController + # Authorize + before_filter :authorize_read_project! + before_filter :authorize_admin_project!, except: [:index, :show] + + layout "project_settings" + + def index + @group = @project.group + @users_projects = @project.users_projects.order('project_access DESC') + end + + def new + @user_project_relation = project.users_projects.new + end + + def create + users = User.where(id: params[:user_ids].split(',')) + + @project.team << [users, params[:project_access]] + + if params[:redirect_to] + redirect_to params[:redirect_to] + else + redirect_to project_team_index_path(@project) + end + end + + def update + @user_project_relation = project.users_projects.find_by_user_id(member) + @user_project_relation.update_attributes(params[:team_member]) + + unless @user_project_relation.valid? + flash[:alert] = "User should have at least one role" + end + redirect_to project_team_index_path(@project) + end + + def destroy + @user_project_relation = project.users_projects.find_by_user_id(member) + @user_project_relation.destroy + + respond_to do |format| + format.html { redirect_to project_team_index_path(@project) } + format.js { render nothing: true } + end + end + + def apply_import + giver = Project.find(params[:source_project_id]) + status = @project.team.import(giver) + notice = status ? "Succesfully imported" : "Import failed" + + redirect_to project_team_index_path(project), notice: notice + end + + protected + + def member + @member ||= User.find_by_username(params[:id]) + end +end diff --git a/app/controllers/projects/tree_controller.rb b/app/controllers/projects/tree_controller.rb new file mode 100644 index 00000000000..5d543f35665 --- /dev/null +++ b/app/controllers/projects/tree_controller.rb @@ -0,0 +1,17 @@ +# Controller for viewing a repository's file structure +class Projects::TreeController < Projects::ApplicationController + include ExtractsPath + + # Authorize + before_filter :authorize_read_project! + before_filter :authorize_code_access! + before_filter :require_non_empty_project + + def show + respond_to do |format| + format.html + # Disable cache so browser history works + format.js { no_cache_headers } + end + end +end diff --git a/app/controllers/projects/walls_controller.rb b/app/controllers/projects/walls_controller.rb new file mode 100644 index 00000000000..834215a1473 --- /dev/null +++ b/app/controllers/projects/walls_controller.rb @@ -0,0 +1,20 @@ +class Projects::WallsController < Projects::ApplicationController + before_filter :module_enabled + + respond_to :js, :html + + def show + @note = @project.notes.new + + respond_to do |format| + format.html + end + end + + protected + + def module_enabled + return render_404 unless @project.wall_enabled + end +end + diff --git a/app/controllers/projects/wikis_controller.rb b/app/controllers/projects/wikis_controller.rb new file mode 100644 index 00000000000..797f3d3dd41 --- /dev/null +++ b/app/controllers/projects/wikis_controller.rb @@ -0,0 +1,95 @@ +class Projects::WikisController < Projects::ApplicationController + before_filter :authorize_read_wiki! + before_filter :authorize_write_wiki!, only: [:edit, :create, :history] + before_filter :authorize_admin_wiki!, only: :destroy + before_filter :load_gollum_wiki + + def pages + @wiki_pages = @gollum_wiki.pages + end + + def show + @wiki = @gollum_wiki.find_page(params[:id], params[:version_id]) + + if @wiki + render 'show' + else + return render('empty') unless can?(current_user, :write_wiki, @project) + @wiki = WikiPage.new(@gollum_wiki) + @wiki.title = params[:id] + + render 'edit' + end + end + + def edit + @wiki = @gollum_wiki.find_page(params[:id]) + end + + def update + @wiki = @gollum_wiki.find_page(params[:id]) + + return render('empty') unless can?(current_user, :write_wiki, @project) + + if @wiki.update(content, format, message) + redirect_to [@project, @wiki], notice: 'Wiki was successfully updated.' + else + render 'edit' + end + end + + def create + @wiki = WikiPage.new(@gollum_wiki) + + if @wiki.create(wiki_params) + redirect_to project_wiki_path(@project, @wiki), notice: 'Wiki was successfully updated.' + else + render action: "edit" + end + end + + def history + @wiki = @gollum_wiki.find_page(params[:id]) + + redirect_to(project_wiki_path(@project, :home), notice: "Page not found") unless @wiki + end + + def destroy + @wiki = @gollum_wiki.find_page(params[:id]) + @wiki.delete if @wiki + redirect_to project_wiki_path(@project, :home), notice: "Page was successfully deleted" + end + + def git_access + end + + private + + def load_gollum_wiki + @gollum_wiki = GollumWiki.new(@project, current_user) + + # Call #wiki to make sure the Wiki Repo is initialized + @gollum_wiki.wiki + rescue GollumWiki::CouldNotCreateWikiError => ex + flash[:notice] = "Could not create Wiki Repository at this time. Please try again later." + redirect_to @project + return false + end + + def wiki_params + params[:wiki].slice(:title, :content, :format, :message) + end + + def content + params[:wiki][:content] + end + + def format + params[:wiki][:format] + end + + def message + params[:wiki][:message] + end + +end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 858a638c7be..34b1d708ba7 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -1,4 +1,4 @@ -class ProjectsController < ProjectResourceController +class ProjectsController < Projects::ApplicationController skip_before_filter :project, only: [:new, :create] skip_before_filter :repository, only: [:new, :create] diff --git a/app/controllers/protected_branches_controller.rb b/app/controllers/protected_branches_controller.rb deleted file mode 100644 index fd2734eff84..00000000000 --- a/app/controllers/protected_branches_controller.rb +++ /dev/null @@ -1,26 +0,0 @@ -class ProtectedBranchesController < ProjectResourceController - # Authorize - before_filter :authorize_read_project! - before_filter :require_non_empty_project - - before_filter :authorize_admin_project!, only: [:destroy, :create] - - def index - @branches = @project.protected_branches.all - @protected_branch = @project.protected_branches.new - end - - def create - @project.protected_branches.create(params[:protected_branch]) - redirect_to project_protected_branches_path(@project) - end - - def destroy - @project.protected_branches.find(params[:id]).destroy - - respond_to do |format| - format.html { redirect_to project_protected_branches_path } - format.js { render nothing: true } - end - end -end diff --git a/app/controllers/raw_controller.rb b/app/controllers/raw_controller.rb deleted file mode 100644 index 18b401fe611..00000000000 --- a/app/controllers/raw_controller.rb +++ /dev/null @@ -1,25 +0,0 @@ -# Controller for viewing a file's raw -class RawController < ProjectResourceController - include ExtractsPath - - # Authorize - before_filter :authorize_read_project! - before_filter :authorize_code_access! - before_filter :require_non_empty_project - - def show - @blob = Gitlab::Git::Blob.new(@repository, @commit.id, @ref, @path) - - if @blob.exists? - send_data( - @blob.data, - type: @blob.mime_type, - disposition: 'inline', - filename: @blob.name - ) - else - not_found! - end - end -end - diff --git a/app/controllers/refs_controller.rb b/app/controllers/refs_controller.rb deleted file mode 100644 index cae9193a1da..00000000000 --- a/app/controllers/refs_controller.rb +++ /dev/null @@ -1,43 +0,0 @@ -class RefsController < ProjectResourceController - include ExtractsPath - - # Authorize - before_filter :authorize_read_project! - before_filter :authorize_code_access! - before_filter :require_non_empty_project - - def switch - respond_to do |format| - format.html do - new_path = if params[:destination] == "tree" - project_tree_path(@project, (@id)) - elsif params[:destination] == "blob" - project_blob_path(@project, (@id)) - elsif params[:destination] == "graph" - project_network_path(@project, @id, @options) - else - project_commits_path(@project, @id) - end - - redirect_to new_path - end - format.js do - @ref = params[:ref] - define_tree_vars - render "tree" - end - end - end - - def logs_tree - contents = @tree.entries - @logs = contents.map do |content| - file = params[:path] ? File.join(params[:path], content.name) : content.name - last_commit = @repo.commits(@commit.id, file, 1).last - { - file_name: content.name, - commit: last_commit - } - end - end -end diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb deleted file mode 100644 index a7d393af82b..00000000000 --- a/app/controllers/repositories_controller.rb +++ /dev/null @@ -1,41 +0,0 @@ -class RepositoriesController < ProjectResourceController - # Authorize - before_filter :authorize_read_project! - before_filter :authorize_code_access! - before_filter :require_non_empty_project - - def show - @activities = @repository.commits_with_refs(20) - end - - def branches - @branches = @repository.branches - end - - def tags - @tags = @repository.tags - end - - def stats - @stats = Gitlab::Git::Stats.new(@repository.raw, @repository.root_ref) - @graph = @stats.graph - end - - def archive - unless can?(current_user, :download_code, @project) - render_404 and return - end - - - storage_path = Rails.root.join("tmp", "repositories") - - file_path = @repository.archive_repo(params[:ref], storage_path) - - if file_path - # Send file to user - send_file file_path - else - render_404 - end - end -end diff --git a/app/controllers/services_controller.rb b/app/controllers/services_controller.rb deleted file mode 100644 index 5710f553fa4..00000000000 --- a/app/controllers/services_controller.rb +++ /dev/null @@ -1,39 +0,0 @@ -class ServicesController < ProjectResourceController - # Authorize - before_filter :authorize_admin_project! - before_filter :service, only: [:edit, :update, :test] - - respond_to :html - - layout "project_settings" - - def index - @project.build_missing_services - @services = @project.services.reload - end - - def edit - end - - def update - if @service.update_attributes(params[:service]) - redirect_to edit_project_service_path(@project, @service.to_param) - else - render 'edit' - end - end - - def test - data = GitPushService.new.sample_data(project, current_user) - - @service.execute(data) - - redirect_to :back - end - - private - - def service - @service ||= @project.services.find { |service| service.to_param == params[:id] } - end -end diff --git a/app/controllers/team_members_controller.rb b/app/controllers/team_members_controller.rb deleted file mode 100644 index 5f2493137c1..00000000000 --- a/app/controllers/team_members_controller.rb +++ /dev/null @@ -1,62 +0,0 @@ -class TeamMembersController < ProjectResourceController - # Authorize - before_filter :authorize_read_project! - before_filter :authorize_admin_project!, except: [:index, :show] - - layout "project_settings" - - def index - @group = @project.group - @users_projects = @project.users_projects.order('project_access DESC') - end - - def new - @user_project_relation = project.users_projects.new - end - - def create - users = User.where(id: params[:user_ids].split(',')) - - @project.team << [users, params[:project_access]] - - if params[:redirect_to] - redirect_to params[:redirect_to] - else - redirect_to project_team_index_path(@project) - end - end - - def update - @user_project_relation = project.users_projects.find_by_user_id(member) - @user_project_relation.update_attributes(params[:team_member]) - - unless @user_project_relation.valid? - flash[:alert] = "User should have at least one role" - end - redirect_to project_team_index_path(@project) - end - - def destroy - @user_project_relation = project.users_projects.find_by_user_id(member) - @user_project_relation.destroy - - respond_to do |format| - format.html { redirect_to project_team_index_path(@project) } - format.js { render nothing: true } - end - end - - def apply_import - giver = Project.find(params[:source_project_id]) - status = @project.team.import(giver) - notice = status ? "Succesfully imported" : "Import failed" - - redirect_to project_team_index_path(project), notice: notice - end - - protected - - def member - @member ||= User.find_by_username(params[:id]) - end -end diff --git a/app/controllers/tree_controller.rb b/app/controllers/tree_controller.rb deleted file mode 100644 index 24e1329f926..00000000000 --- a/app/controllers/tree_controller.rb +++ /dev/null @@ -1,17 +0,0 @@ -# Controller for viewing a repository's file structure -class TreeController < ProjectResourceController - include ExtractsPath - - # Authorize - before_filter :authorize_read_project! - before_filter :authorize_code_access! - before_filter :require_non_empty_project - - def show - respond_to do |format| - format.html - # Disable cache so browser history works - format.js { no_cache_headers } - end - end -end diff --git a/app/controllers/walls_controller.rb b/app/controllers/walls_controller.rb deleted file mode 100644 index 5993a5e2409..00000000000 --- a/app/controllers/walls_controller.rb +++ /dev/null @@ -1,20 +0,0 @@ -class WallsController < ProjectResourceController - before_filter :module_enabled - - respond_to :js, :html - - def show - @note = @project.notes.new - - respond_to do |format| - format.html - end - end - - protected - - def module_enabled - return render_404 unless @project.wall_enabled - end -end - diff --git a/app/controllers/wikis_controller.rb b/app/controllers/wikis_controller.rb deleted file mode 100644 index be9ae4f37a4..00000000000 --- a/app/controllers/wikis_controller.rb +++ /dev/null @@ -1,95 +0,0 @@ -class WikisController < ProjectResourceController - before_filter :authorize_read_wiki! - before_filter :authorize_write_wiki!, only: [:edit, :create, :history] - before_filter :authorize_admin_wiki!, only: :destroy - before_filter :load_gollum_wiki - - def pages - @wiki_pages = @gollum_wiki.pages - end - - def show - @wiki = @gollum_wiki.find_page(params[:id], params[:version_id]) - - if @wiki - render 'show' - else - return render('empty') unless can?(current_user, :write_wiki, @project) - @wiki = WikiPage.new(@gollum_wiki) - @wiki.title = params[:id] - - render 'edit' - end - end - - def edit - @wiki = @gollum_wiki.find_page(params[:id]) - end - - def update - @wiki = @gollum_wiki.find_page(params[:id]) - - return render('empty') unless can?(current_user, :write_wiki, @project) - - if @wiki.update(content, format, message) - redirect_to [@project, @wiki], notice: 'Wiki was successfully updated.' - else - render 'edit' - end - end - - def create - @wiki = WikiPage.new(@gollum_wiki) - - if @wiki.create(wiki_params) - redirect_to project_wiki_path(@project, @wiki), notice: 'Wiki was successfully updated.' - else - render action: "edit" - end - end - - def history - @wiki = @gollum_wiki.find_page(params[:id]) - - redirect_to(project_wiki_path(@project, :home), notice: "Page not found") unless @wiki - end - - def destroy - @wiki = @gollum_wiki.find_page(params[:id]) - @wiki.delete if @wiki - redirect_to project_wiki_path(@project, :home), notice: "Page was successfully deleted" - end - - def git_access - end - - private - - def load_gollum_wiki - @gollum_wiki = GollumWiki.new(@project, current_user) - - # Call #wiki to make sure the Wiki Repo is initialized - @gollum_wiki.wiki - rescue GollumWiki::CouldNotCreateWikiError => ex - flash[:notice] = "Could not create Wiki Repository at this time. Please try again later." - redirect_to @project - return false - end - - def wiki_params - params[:wiki].slice(:title, :content, :format, :message) - end - - def content - params[:wiki][:content] - end - - def format - params[:wiki][:format] - end - - def message - params[:wiki][:message] - end - -end diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb index 95ca294cd2d..2bc61894193 100644 --- a/app/helpers/commits_helper.rb +++ b/app/helpers/commits_helper.rb @@ -109,7 +109,7 @@ module CommitsHelper end def commit_to_html commit - escape_javascript(render 'commits/commit', commit: commit) + escape_javascript(render 'projects/commits/commit', commit: commit) end def diff_line_content(line) diff --git a/app/helpers/tree_helper.rb b/app/helpers/tree_helper.rb index af633f6fd04..d41f8377559 100644 --- a/app/helpers/tree_helper.rb +++ b/app/helpers/tree_helper.rb @@ -10,13 +10,13 @@ module TreeHelper tree = "" # Render folders if we have any - tree += render partial: 'tree/tree_item', collection: folders, locals: {type: 'folder'} if folders.present? + tree += render partial: 'projects/tree/tree_item', collection: folders, locals: {type: 'folder'} if folders.present? # Render files if we have any - tree += render partial: 'tree/blob_item', collection: files, locals: {type: 'file'} if files.present? + tree += render partial: 'projects/tree/blob_item', collection: files, locals: {type: 'file'} if files.present? # Render submodules if we have any - tree += render partial: 'tree/submodule_item', collection: submodules if submodules.present? + tree += render partial: 'projects/tree/submodule_item', collection: submodules if submodules.present? tree.html_safe end diff --git a/app/views/blame/_head.html.haml b/app/views/blame/_head.html.haml deleted file mode 100644 index 3a883829562..00000000000 --- a/app/views/blame/_head.html.haml +++ /dev/null @@ -1,2 +0,0 @@ -%div.tree-ref-holder - = render 'shared/ref_switcher', destination: 'tree', path: params[:path] diff --git a/app/views/blame/show.html.haml b/app/views/blame/show.html.haml deleted file mode 100644 index 297e30356a7..00000000000 --- a/app/views/blame/show.html.haml +++ /dev/null @@ -1,49 +0,0 @@ -= render "head" - -#tree-holder.tree-holder - %ul.breadcrumb - %li - %i.icon-angle-right - = link_to project_tree_path(@project, @ref) do - = @project.name - - tree_breadcrumbs(@tree, 6) do |link| - \/ - %li= link - .clear - - .file_holder - .file_title - %i.icon-file - %span.file_name - = @blob.name - %small= number_to_human_size @blob.size - %span.options= render "blob/actions" - .file_content.blame - %table - - current_line = 1 - - @blame.each do |commit, lines| - - commit = Commit.new(commit) - %tr - %td.blame-commit - %span.commit - = link_to commit.short_id(8), project_commit_path(@project, commit), class: "commit_short_id" -   - = commit_author_link(commit, avatar: true, size: 16) -   - = link_to_gfm truncate(commit.title, length: 20), project_commit_path(@project, commit.id), class: "row_title" - %td.lines.blame-numbers - %pre - - if lines.empty? - = current_line - - current_line += 1 - - else - - lines.each do |line| - = current_line - \ - - current_line += 1 - %td.lines - %pre - :erb - <% lines.each do |line| %> - <%= line %> - <% end %> diff --git a/app/views/blob/_actions.html.haml b/app/views/blob/_actions.html.haml deleted file mode 100644 index 456c7432c94..00000000000 --- a/app/views/blob/_actions.html.haml +++ /dev/null @@ -1,12 +0,0 @@ -.btn-group.tree-btn-group - -# only show edit link for text files - - if @blob.text? - = link_to "edit", project_edit_tree_path(@project, @id), class: "btn btn-tiny", disabled: !allowed_tree_edit? - = link_to "raw", project_raw_path(@project, @id), class: "btn btn-tiny", target: "_blank" - -# only show normal/blame view links for text files - - if @blob.text? - - if current_page? project_blame_path(@project, @id) - = link_to "normal view", project_blob_path(@project, @id), class: "btn btn-tiny" - - else - = link_to "blame", project_blame_path(@project, @id), class: "btn btn-tiny" unless @blob.empty? - = link_to "history", project_commits_path(@project, @id), class: "btn btn-tiny" diff --git a/app/views/blob/_blob.html.haml b/app/views/blob/_blob.html.haml deleted file mode 100644 index 68d6c06065c..00000000000 --- a/app/views/blob/_blob.html.haml +++ /dev/null @@ -1,32 +0,0 @@ -%ul.breadcrumb - %li - %i.icon-angle-right - = link_to project_tree_path(@project, @ref) do - = @project.path - - tree_breadcrumbs(@tree, 6) do |title, path| - \/ - %li - - if path - - if path.end_with?(@path) - = link_to project_blob_path(@project, path) do - %span.cblue - = truncate(title, length: 40) - - else - = link_to truncate(title, length: 40), project_tree_path(@project, path) - - else - = link_to title, '#' - -%div#tree-content-holder.tree-content-holder - .file_holder - .file_title - %i.icon-file - %span.file_name - = blob.name - %small= number_to_human_size blob.size - %span.options= render "actions" - - if blob.text? - = render "text", blob: blob - - elsif blob.image? - = render "image", blob: blob - - else - = render "download", blob: blob diff --git a/app/views/blob/_download.html.haml b/app/views/blob/_download.html.haml deleted file mode 100644 index 864c209db76..00000000000 --- a/app/views/blob/_download.html.haml +++ /dev/null @@ -1,8 +0,0 @@ -.file_content.blob_file - %center - = link_to project_blob_path(@project, @id) do - %div.padded - %h4 - %i.icon-download-alt - %br - Download (#{number_to_human_size blob.size}) diff --git a/app/views/blob/_image.html.haml b/app/views/blob/_image.html.haml deleted file mode 100644 index 7b23f0c810c..00000000000 --- a/app/views/blob/_image.html.haml +++ /dev/null @@ -1,2 +0,0 @@ -.file_content.image_file - %img{ src: "data:#{blob.mime_type};base64,#{Base64.encode64(blob.data)}"} diff --git a/app/views/blob/_text.html.haml b/app/views/blob/_text.html.haml deleted file mode 100644 index 122e275219d..00000000000 --- a/app/views/blob/_text.html.haml +++ /dev/null @@ -1,14 +0,0 @@ -- if gitlab_markdown?(blob.name) - .file_content.wiki - = preserve do - = markdown(blob.data) -- elsif markup?(blob.name) - .file_content.wiki - = raw GitHub::Markup.render(blob.name, blob.data) -- else - .file_content.code - - unless blob.empty? - %div{class: user_color_scheme_class} - = raw blob.colorize(formatter: :gitlab) - - else - %p.nothing_here_message Empty file diff --git a/app/views/blob/show.html.haml b/app/views/blob/show.html.haml deleted file mode 100644 index d96595bc7f0..00000000000 --- a/app/views/blob/show.html.haml +++ /dev/null @@ -1,4 +0,0 @@ -%div.tree-ref-holder - = render 'shared/ref_switcher', destination: 'blob', path: @path -%div#tree-holder.tree-holder - = render 'blob', blob: @blob diff --git a/app/views/commit/_commit_box.html.haml b/app/views/commit/_commit_box.html.haml deleted file mode 100644 index 646791773b2..00000000000 --- a/app/views/commit/_commit_box.html.haml +++ /dev/null @@ -1,50 +0,0 @@ -.ui-box.ui-box-show - .ui-box-head - .pull-right - - if @notes_count > 0 - %span.btn.disabled.grouped - %i.icon-comment - = @notes_count - .left.btn-group - %a.btn.grouped.dropdown-toggle{ data: {toggle: :dropdown} } - %i.icon-download-alt - Download as - %span.caret - %ul.dropdown-menu - %li= link_to "Email Patches", project_commit_path(@project, @commit, format: :patch) - %li= link_to "Plain Diff", project_commit_path(@project, @commit, format: :diff) - = link_to project_tree_path(@project, @commit), class: "btn btn-primary grouped" do - %span Browse Code » - %h3.commit-title.page_title - = gfm escape_once(@commit.title) - - if @commit.description.present? - %pre.commit-description - = gfm escape_once(@commit.description) - .ui-box-body - .row - .span5 - .author - = commit_author_link(@commit, avatar: true, size: 32) - authored - %time{title: @commit.authored_date.stamp("Aug 21, 2011 9:23pm")} - #{time_ago_in_words(@commit.authored_date)} ago - - if @commit.different_committer? - .committer - → - = commit_committer_link(@commit) - committed - %time{title: @commit.committed_date.stamp("Aug 21, 2011 9:23pm")} - #{time_ago_in_words(@commit.committed_date)} ago - .span6.pull-right - .pull-right - .sha-block - %span.cgray commit - %span.label_commit= @commit.id - .clearfix - .pull-right - .sha-block - %span.cgray= pluralize(@commit.parents.count, "parent") - - @commit.parents.each do |parent| - = link_to parent.id[0...10], project_commit_path(@project, parent) - - diff --git a/app/views/commit/huge_commit.html.haml b/app/views/commit/huge_commit.html.haml deleted file mode 100644 index 5d447d6cee5..00000000000 --- a/app/views/commit/huge_commit.html.haml +++ /dev/null @@ -1,3 +0,0 @@ -= render "commit/commit_box" -.alert.alert-error - %h4 Commit diffs are too big to be displayed diff --git a/app/views/commit/show.html.haml b/app/views/commit/show.html.haml deleted file mode 100644 index 6cb1a6905ca..00000000000 --- a/app/views/commit/show.html.haml +++ /dev/null @@ -1,11 +0,0 @@ -= render "commit_box" - -- unless @commit.has_zero_stats? - %p.pull-right.cgray - This commit has - %span.cgreen #{@commit.stats.additions} additions - and - %span.cred #{@commit.stats.deletions} deletions - -= render "commits/diffs", diffs: @commit.diffs -= render "notes/notes_with_form" diff --git a/app/views/commits/_commit.html.haml b/app/views/commits/_commit.html.haml deleted file mode 100644 index eba6c206c46..00000000000 --- a/app/views/commits/_commit.html.haml +++ /dev/null @@ -1,21 +0,0 @@ -%li.commit - .browse_code_link_holder - %p - %strong= link_to "Browse Code »", project_tree_path(@project, commit), class: "right" - %p - = link_to commit.short_id(8), project_commit_path(@project, commit), class: "commit_short_id" - = commit_author_link(commit, avatar: true, size: 24) -   - = link_to_gfm truncate(commit.title, length: 70), project_commit_path(@project, commit.id), class: "row_title" - - %time.committed_ago{ datetime: commit.committed_date, title: commit.committed_date.stamp("Aug 21, 2011 9:23pm") } - = time_ago_in_words(commit.committed_date) - ago -   - - %span.notes_count - - notes = @project.notes.for_commit_id(commit.id) - - if notes.any? - %span.badge.badge-info - %i.icon-comment - = notes.count diff --git a/app/views/commits/_commits.html.haml b/app/views/commits/_commits.html.haml deleted file mode 100644 index 933780e4534..00000000000 --- a/app/views/commits/_commits.html.haml +++ /dev/null @@ -1,9 +0,0 @@ -- @commits.group_by { |c| c.committed_date.to_date }.sort.reverse.each do |day, commits| - %div.ui-box - %h5.title - %i.icon-calendar - %span= day.stamp("28 Aug, 2010") - - .pull-right - %small= pluralize(commits.count, 'commit') - %ul.well-list= render commits diff --git a/app/views/commits/_diff_head.html.haml b/app/views/commits/_diff_head.html.haml deleted file mode 100644 index 5aa542287fe..00000000000 --- a/app/views/commits/_diff_head.html.haml +++ /dev/null @@ -1,26 +0,0 @@ -%ul.bordered-list - - diffs.each_with_index do |diff, i| - %li - - if diff.deleted_file - %span.deleted-file - %a{href: "#diff-#{i}"} - %i.icon-minus - = diff.old_path - - elsif diff.renamed_file - %span.renamed-file - %a{href: "#diff-#{i}"} - %i.icon-minus - = diff.old_path - = "->" - = diff.new_path - - elsif diff.new_file - %span.new-file - %a{href: "#diff-#{i}"} - %i.icon-plus - = diff.new_path - - else - %span.edit-file - %a{href: "#diff-#{i}"} - %i.icon-adjust - = diff.new_path - diff --git a/app/views/commits/_diffs.html.haml b/app/views/commits/_diffs.html.haml deleted file mode 100644 index 3f4d51f753a..00000000000 --- a/app/views/commits/_diffs.html.haml +++ /dev/null @@ -1,49 +0,0 @@ -- if @suppress_diff - .alert.alert-block - %p - %strong Warning! Large commit with more than #{Commit::DIFF_SAFE_SIZE} files changed. - %p To prevent performance issue we rejected diff information. - %p - But if you still want to see diff - = link_to "click this link", project_commit_path(@project, @commit, force_show_diff: true), class: "underlined_link" - -%p.cgray - Showing #{pluralize(diffs.count, "changed file")} -.file-stats - = render "commits/diff_head", diffs: diffs - -.files - - unless @suppress_diff - - diffs.each_with_index do |diff, i| - - next if diff.diff.empty? - - file = Gitlab::Git::Blob.new(@repository, @commit.id, @ref, diff.new_path) - - file = Gitlab::Git::Blob.new(@repository, @commit.parent_id, @ref, diff.old_path) unless file.exists? - - next unless file.exists? - .file{id: "diff-#{i}"} - .header - - if diff.deleted_file - %span= diff.old_path - - - if @commit.parent_ids.present? - = link_to project_blob_path(@project, tree_join(@commit.parent_id, diff.new_path)), {:class => 'btn btn-tiny pull-right view-file'} do - View file @ - %span.commit-short-id= @commit.short_id(6) - - else - %span= diff.new_path - - if diff.a_mode && diff.b_mode && diff.a_mode != diff.b_mode - %span.file-mode= "#{diff.a_mode} → #{diff.b_mode}" - - = link_to project_blob_path(@project, tree_join(@commit.id, diff.new_path)), {:class => 'btn btn-tiny pull-right view-file'} do - View file @ - %span.commit-short-id= @commit.short_id(6) - - .content - -# Skipp all non non-supported blobs - - next unless file.respond_to?('text?') - - if file.text? - = render "commits/text_file", diff: diff, index: i - - elsif file.image? - - old_file = Gitlab::Git::Blob.new(@repository, @commit.parent_id, @ref, diff.old_path) if @commit.parent_id - = render "commits/image", diff: diff, old_file: old_file, file: file, index: i - - else - %p.nothing_here_message No preview for this file type diff --git a/app/views/commits/_head.html.haml b/app/views/commits/_head.html.haml deleted file mode 100644 index 20b9195c4c3..00000000000 --- a/app/views/commits/_head.html.haml +++ /dev/null @@ -1,27 +0,0 @@ -%ul.nav.nav-tabs - %li= render partial: 'shared/ref_switcher', locals: {destination: 'commits'} - - = nav_link(controller: [:commit, :commits]) do - = link_to 'Commits', project_commits_path(@project, @repository.root_ref) - = nav_link(controller: :compare) do - = link_to 'Compare', project_compare_index_path(@project) - - = nav_link(html_options: {class: branches_tab_class}) do - = link_to project_repository_path(@project) do - Branches - %span.badge= @repository.branches.length - - = nav_link(controller: :repositories, action: :tags) do - = link_to tags_project_repository_path(@project) do - Tags - %span.badge= @repository.tags.length - - = nav_link(controller: :repositories, action: :stats) do - = link_to stats_project_repository_path(@project) do - Stats - - - - if current_controller?(:commits) && current_user.private_token - %li.pull-right - = link_to project_commits_path(@project, @ref, {format: :atom, private_token: current_user.private_token}), title: "Feed" do - %i.icon-rss diff --git a/app/views/commits/_image.html.haml b/app/views/commits/_image.html.haml deleted file mode 100644 index db02fa333b9..00000000000 --- a/app/views/commits/_image.html.haml +++ /dev/null @@ -1,63 +0,0 @@ -- if diff.renamed_file || diff.new_file || diff.deleted_file - .image - %span.wrap - .frame{class: image_diff_class(diff)} - %img{src: "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"} - %p.image-info= "#{number_to_human_size file.size}" -- else - .image - %div.two-up.view - %span.wrap - .frame.deleted - %a{href: project_tree_path(@project, tree_join(@commit.id, diff.old_path))} - %img{src: "data:#{old_file.mime_type};base64,#{Base64.encode64(old_file.data)}"} - %p.image-info.hide - %span.meta-filesize= "#{number_to_human_size old_file.size}" - | - %b W: - %span.meta-width - | - %b H: - %span.meta-height - %span.wrap - .frame.added - %a{href: project_tree_path(@project, tree_join(@commit.id, diff.new_path))} - %img{src: "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"} - %p.image-info.hide - %span.meta-filesize= "#{number_to_human_size file.size}" - | - %b W: - %span.meta-width - | - %b H: - %span.meta-height - - %div.swipe.view.hide - .swipe-frame - .frame.deleted - %img{src: "data:#{old_file.mime_type};base64,#{Base64.encode64(old_file.data)}"} - .swipe-wrap - .frame.added - %img{src: "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"} - %span.swipe-bar - %span.top-handle - %span.bottom-handle - - %div.onion-skin.view.hide - .onion-skin-frame - .frame.deleted - %img{src: "data:#{old_file.mime_type};base64,#{Base64.encode64(old_file.data)}"} - .frame.added - %img{src: "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"} - .controls - .transparent - .drag-track - .dragger{:style => "left: 0px;"} - .opaque - - - .view-modes.hide - %ul.view-modes-menu - %li.two-up{data: {mode: 'two-up'}} 2-up - %li.swipe{data: {mode: 'swipe'}} Swipe - %li.onion-skin{data: {mode: 'onion-skin'}} Onion skin \ No newline at end of file diff --git a/app/views/commits/_text_file.html.haml b/app/views/commits/_text_file.html.haml deleted file mode 100644 index 8f737e43887..00000000000 --- a/app/views/commits/_text_file.html.haml +++ /dev/null @@ -1,23 +0,0 @@ -- too_big = diff.diff.lines.count > 1000 -- if too_big - %a.supp_diff_link Diff suppressed. Click to show - -%table.text-file{class: "#{'hide' if too_big}"} - - each_diff_line(diff, index) do |line, type, line_code, line_new, line_old| - %tr.line_holder{ id: line_code, class: "#{type}" } - - if type == "match" - %td.old_line= "..." - %td.new_line= "..." - %td.line_content.matched= line - - else - %td.old_line - = link_to raw(type == "new" ? " " : line_old), "##{line_code}", id: line_code - - if @comments_allowed - = render "notes/diff_note_link", line_code: line_code - %td.new_line= link_to raw(type == "old" ? " " : line_new) , "##{line_code}", id: line_code - %td.line_content{class: "noteable_line #{type} #{line_code}", "line_code" => line_code}= raw diff_line_content(line) - - - if @reply_allowed - - comments = @line_notes.select { |n| n.line_code == line_code }.sort_by(&:created_at) - - unless comments.empty? - = render "notes/diff_notes_with_reply", notes: comments diff --git a/app/views/commits/show.atom.builder b/app/views/commits/show.atom.builder deleted file mode 100644 index 46f9838e84a..00000000000 --- a/app/views/commits/show.atom.builder +++ /dev/null @@ -1,23 +0,0 @@ -xml.instruct! -xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do - xml.title "Recent commits to #{@project.name}:#{@ref}" - xml.link :href => project_commits_url(@project, @ref, format: :atom), :rel => "self", :type => "application/atom+xml" - xml.link :href => project_commits_url(@project, @ref), :rel => "alternate", :type => "text/html" - xml.id project_commits_url(@project) - xml.updated @commits.first.committed_date.strftime("%Y-%m-%dT%H:%M:%SZ") if @commits.any? - - @commits.each do |commit| - xml.entry do - xml.id project_commit_url(@project, :id => commit.id) - xml.link :href => project_commit_url(@project, :id => commit.id) - xml.title truncate(commit.title, :length => 80) - xml.updated commit.committed_date.strftime("%Y-%m-%dT%H:%M:%SZ") - xml.media :thumbnail, :width => "40", :height => "40", :url => gravatar_icon(commit.author_email) - xml.author do |author| - xml.name commit.author_name - xml.email commit.author_email - end - xml.summary gfm(commit.description) - end - end -end diff --git a/app/views/commits/show.html.haml b/app/views/commits/show.html.haml deleted file mode 100644 index cb9ef820d3e..00000000000 --- a/app/views/commits/show.html.haml +++ /dev/null @@ -1,15 +0,0 @@ -= render "head" - -- if @path.present? - %ul.breadcrumb - = commits_breadcrumbs - -%div{id: dom_id(@project)} - #commits-list= render "commits" -.clear -.loading{ style: "display:none;"} - -- if @commits.count == @limit - :javascript - CommitsList.init("#{@ref}", #{@limit}); - diff --git a/app/views/commits/show.js.haml b/app/views/commits/show.js.haml deleted file mode 100644 index 797bc14cc1b..00000000000 --- a/app/views/commits/show.js.haml +++ /dev/null @@ -1,3 +0,0 @@ -:plain - CommitsList.append(#{@commits.count}, "#{escape_javascript(render(partial: 'commits/commits'))}"); - diff --git a/app/views/compare/_form.html.haml b/app/views/compare/_form.html.haml deleted file mode 100644 index ccdd0fc98eb..00000000000 --- a/app/views/compare/_form.html.haml +++ /dev/null @@ -1,37 +0,0 @@ -%div - - unless params[:to] - %p.slead - Fill input field with commit id like - %code.label-branch 4eedf23 - or branch/tag name like - %code.label-branch master - and press compare button for commits list, code diff. - - %br - - = form_tag project_compare_index_path(@project), method: :post do - .clearfix - .pull-left - - if params[:to] && params[:from] - = link_to 'switch', {from: params[:to], to: params[:from]}, {class: 'commits-compare-switch has_tooltip', title: 'Switch base of comparison'} - = text_field_tag :from, params[:from], placeholder: "master", class: "xlarge" - = "..." - = text_field_tag :to, params[:to], placeholder: "aa8b4ef", class: "xlarge" - .pull-left -   - = submit_tag "Compare", class: "btn btn-primary wide commits-compare-btn" - - if @refs_are_same - .alert - %span Refs are the same - - - -:javascript - var availableTags = #{@project.repository.ref_names.to_json}; - - $("#from, #to").autocomplete({ - source: availableTags, - minLength: 1 - }); - - disableButtonIfEmptyField('#to', '.commits-compare-btn'); diff --git a/app/views/compare/index.html.haml b/app/views/compare/index.html.haml deleted file mode 100644 index 6c9a5fd8305..00000000000 --- a/app/views/compare/index.html.haml +++ /dev/null @@ -1,7 +0,0 @@ -= render "commits/head" - -%h3.page_title - Compare View -%hr - -= render "form" diff --git a/app/views/compare/show.html.haml b/app/views/compare/show.html.haml deleted file mode 100644 index 56c4a113ea0..00000000000 --- a/app/views/compare/show.html.haml +++ /dev/null @@ -1,23 +0,0 @@ -= render "commits/head" - -%h3.page_title - Compare View -%hr - -= render "form" - -- if @commits.size > 100 - .alert.alert-block - %p - %strong Warning! This comparison include 100+ commits. - %p To prevent performance issue we dont show diff information. - -- if @commits.present? - %div.ui-box - %h5.title - Commits (#{@commits.count}) - %ul.well-list= render Commit.decorate(@commits) - - - unless @diffs.empty? - %h4 Diff - = render "commits/diffs", diffs: @diffs diff --git a/app/views/dashboard/issues.html.haml b/app/views/dashboard/issues.html.haml index b41edb9eb60..356e0847ae7 100644 --- a/app/views/dashboard/issues.html.haml +++ b/app/views/dashboard/issues.html.haml @@ -22,7 +22,7 @@ %ul.well-list.issues-list - group[1].each do |issue| - = render issue + = render 'projects/issues/issue', issue: issue %hr = paginate @issues, theme: "gitlab" - else diff --git a/app/views/deploy_keys/_deploy_key.html.haml b/app/views/deploy_keys/_deploy_key.html.haml deleted file mode 100644 index 45f80ecd556..00000000000 --- a/app/views/deploy_keys/_deploy_key.html.haml +++ /dev/null @@ -1,25 +0,0 @@ -%li - .pull-right - - if @available_keys.include?(deploy_key) - = link_to enable_project_deploy_key_path(@project, deploy_key), class: 'btn btn-small', method: :put do - %i.icon-plus - Enable - - else - - if deploy_key.projects.count > 1 - = link_to disable_project_deploy_key_path(@project, deploy_key), class: 'btn btn-small', method: :put do - %i.icon-off - Disable - - else - = link_to 'Remove', project_deploy_key_path(@project, deploy_key), confirm: 'You are going to remove deploy key. Are you sure?', method: :delete, class: "btn btn-remove delete-key btn-small pull-right" - - - = link_to project_deploy_key_path(deploy_key.projects.include?(@project) ? @project : deploy_key.projects.first, deploy_key) do - %i.icon-key - %strong= deploy_key.title - - %p.light.prepend-top-10 - - deploy_key.projects.map(&:name_with_namespace).each do |project_name| - %span.label= project_name - %small.pull-right - Created #{time_ago_in_words(deploy_key.created_at)} ago - diff --git a/app/views/deploy_keys/_form.html.haml b/app/views/deploy_keys/_form.html.haml deleted file mode 100644 index 71bf309dd8b..00000000000 --- a/app/views/deploy_keys/_form.html.haml +++ /dev/null @@ -1,23 +0,0 @@ -%div - = form_for [@project, @key], url: project_deploy_keys_path do |f| - -if @key.errors.any? - .alert.alert-error - %ul - - @key.errors.full_messages.each do |msg| - %li= msg - - .clearfix - = f.label :title - .input= f.text_field :title - .clearfix - = f.label :key - .input - = f.text_area :key, class: [:xxlarge, :thin_area] - %p.hint - Paste a machine public key here. Read more about how generate it - = link_to "here", help_ssh_path - - .actions - = f.submit 'Create', class: "btn-create btn" - = link_to "Cancel", project_deploy_keys_path(@project), class: "btn btn-cancel" - diff --git a/app/views/deploy_keys/index.html.haml b/app/views/deploy_keys/index.html.haml deleted file mode 100644 index a1fa3475a84..00000000000 --- a/app/views/deploy_keys/index.html.haml +++ /dev/null @@ -1,30 +0,0 @@ -%p.slead - Deploy keys allow read-only access to repository. They can be used for CI, staging or production servers - -%p - You can create a deploy key or add existing one - = link_to new_project_deploy_key_path(@project), class: "btn btn-primary pull-right", title: "New Deploy Key" do - %i.icon-plus - New Deploy Key - -%hr.clearfix - -.row - .span5.enabled-keys - %h5.cgreen - Enabled deploy keys - %small for this project - %ul.bordered-list - = render @enabled_keys - - if @enabled_keys.blank? - .light-well - %p.nothing_here_message Create #{link_to 'new deploy key', new_project_deploy_key_path(@project)} or add existing one - .span5.available-keys - %h5 - Available deploy keys - %small from projects you are able to manage - %ul.bordered-list - = render @available_keys - - if @available_keys.blank? - .light-well - %p.nothing_here_message All deploy keys created in projects you own will be displayed here diff --git a/app/views/deploy_keys/new.html.haml b/app/views/deploy_keys/new.html.haml deleted file mode 100644 index b0e2a8b2949..00000000000 --- a/app/views/deploy_keys/new.html.haml +++ /dev/null @@ -1,4 +0,0 @@ -%h3.page_title New Deploy key -%hr - -= render 'form' diff --git a/app/views/deploy_keys/show.html.haml b/app/views/deploy_keys/show.html.haml deleted file mode 100644 index 26fd7428b7e..00000000000 --- a/app/views/deploy_keys/show.html.haml +++ /dev/null @@ -1,13 +0,0 @@ -%h3.page_title - Deploy key: - = @key.title - %small - created at - = @key.created_at.stamp("Aug 21, 2011") -.back_link - = link_to project_deploy_keys_path(@project) do - ← To keys list -%hr -%pre= @key.key -.pull-right - = link_to 'Remove', project_deploy_key_path(@project, @key), confirm: 'Are you sure?', method: :delete, class: "btn-remove btn delete-key" diff --git a/app/views/edit_tree/show.html.haml b/app/views/edit_tree/show.html.haml deleted file mode 100644 index 101b479afed..00000000000 --- a/app/views/edit_tree/show.html.haml +++ /dev/null @@ -1,45 +0,0 @@ -.file-editor - = form_tag(project_edit_tree_path(@project, @id), method: :put, class: "form-horizontal") do - .file_holder - .file_title - %i.icon-file - %span.file_name - = @path - %small - on - %strong= @ref - %span.options - .btn-group.tree-btn-group - = link_to "Cancel", project_blob_path(@project, @id), class: "btn btn-tiny btn-cancel", confirm: leave_edit_message - .file_content.code - %pre#editor= @blob.data - - .control-group.commit_message-group - = label_tag 'commit_message', class: "control-label" do - Commit message - .controls - = text_area_tag 'commit_message', '', placeholder: "Update #{@blob.name}", required: true, rows: 3 - .form-actions - = hidden_field_tag 'last_commit', @last_commit - = hidden_field_tag 'content', '', id: :file_content - .commit-button-annotation - = button_tag "Commit changes", class: 'btn commit-btn js-commit-button btn-primary' - .message - to branch - %strong= @ref - = link_to "Cancel", project_blob_path(@project, @id), class: "btn btn-cancel", confirm: leave_edit_message - -:javascript - ace.config.set("modePath", "#{Gitlab::Application.config.assets.prefix}/ace-src-noconflict") - var ace_mode = "#{@blob.language.try(:ace_mode)}"; - var editor = ace.edit("editor"); - if (ace_mode) { - editor.getSession().setMode('ace/mode/' + ace_mode); - } - - disableButtonIfEmptyField("#commit_message", ".js-commit-button"); - - $(".js-commit-button").click(function(){ - $("#file_content").val(editor.getValue()); - $(".file-editor form").submit(); - }); diff --git a/app/views/graphs/show.html.haml b/app/views/graphs/show.html.haml deleted file mode 100644 index 05bc1436e6d..00000000000 --- a/app/views/graphs/show.html.haml +++ /dev/null @@ -1,31 +0,0 @@ -.loading-graph - %center - .loading - %h3.page_title Building repository graph. Please wait a moment. - -.stat-graph - .header.clearfix - .pull-right - %select - %option{:value => "commits"} Commits - %option{:value => "additions"} Additions - %option{:value => "deletions"} Deletions - %h3#date_header.page_title - %input#brush_change{:type => "hidden"} - .graphs - #contributors-master - #contributors.clearfix - %ol.contributors-list.clearfix - -:javascript - $(".stat-graph").hide(); - - $.ajax({ - type: "GET", - url: location.href, - complete: function() { - $(".loading-graph").hide(); - $(".stat-graph").show(); - }, - dataType: "script" - }); diff --git a/app/views/graphs/show.js.haml b/app/views/graphs/show.js.haml deleted file mode 100644 index b7c9b4113e9..00000000000 --- a/app/views/graphs/show.js.haml +++ /dev/null @@ -1,16 +0,0 @@ -:plain - controller = new ContributorsStatGraph - controller.init(#{@log}) - - $("select").change( function () { - var field = $(this).val() - controller.set_current_field(field) - controller.redraw_master() - controller.redraw_authors() - }) - - $("#brush_change").change( function () { - controller.change_date_header() - controller.redraw_authors() - }) - diff --git a/app/views/groups/issues.html.haml b/app/views/groups/issues.html.haml index 6d642b65cbd..38dac634bf9 100644 --- a/app/views/groups/issues.html.haml +++ b/app/views/groups/issues.html.haml @@ -16,7 +16,7 @@ = link_to_project project %ul.well-list.issues-list - group[1].each do |issue| - = render issue + = render 'projects/issues/issue', issue: issue %hr = paginate @issues, theme: "gitlab" - else diff --git a/app/views/hooks/_data_ex.html.erb b/app/views/hooks/_data_ex.html.erb deleted file mode 100644 index b4281fa18c7..00000000000 --- a/app/views/hooks/_data_ex.html.erb +++ /dev/null @@ -1,43 +0,0 @@ -<% data_ex_str = < -
    - <%= raw Pygments::Lexer[:js].highlight(data_ex_str) %> -
    diff --git a/app/views/hooks/index.html.haml b/app/views/hooks/index.html.haml deleted file mode 100644 index 641ab082d8d..00000000000 --- a/app/views/hooks/index.html.haml +++ /dev/null @@ -1,34 +0,0 @@ -- if can? current_user, :admin_project, @project - .alert.alert-info - %span - Post receive hooks for binding events when someone push to repository. - %br - Read more about web hooks - %strong #{link_to "here", help_web_hooks_path, class: "vlink"} - -= form_for [@project, @hook], as: :hook, url: project_hooks_path(@project), html: { class: 'form-inline' } do |f| - -if @hook.errors.any? - .alert.alert-error - - @hook.errors.full_messages.each do |msg| - %p= msg - .clearfix - = f.label :url, "URL:" - .input - = f.text_field :url, class: "text_field xxlarge" -   - = f.submit "Add Web Hook", class: "btn btn-create" -%hr - --if @hooks.any? - .ui-box - %h5.title - Hooks (#{@hooks.count}) - %ul.well-list - - @hooks.each do |hook| - %li - %span.badge.badge-info POST - → - %span.monospace= hook.url - .pull-right - = link_to 'Test Hook', test_project_hook_path(@project, hook), class: "btn btn-small grouped" - = link_to 'Remove', project_hook_path(@project, hook), confirm: 'Are you sure?', method: :delete, class: "btn btn-remove btn-small grouped" diff --git a/app/views/issues/_filter.html.haml b/app/views/issues/_filter.html.haml deleted file mode 100644 index 8495c323cb8..00000000000 --- a/app/views/issues/_filter.html.haml +++ /dev/null @@ -1,23 +0,0 @@ -= form_tag project_issues_path(@project), method: 'get' do - %fieldset - %ul.nav.nav-pills.nav-stacked - %li{class: ("active" if !params[:status] || params[:status].blank?)} - = link_to project_issues_path(@project, status: nil) do - Open - %li{class: ("active" if params[:status] == 'assigned-to-me')} - = link_to project_issues_path(@project, status: 'assigned-to-me') do - Assigned to me - %li{class: ("active" if params[:status] == 'created-by-me')} - = link_to project_issues_path(@project, status: 'created-by-me') do - Created by me - %li{class: ("active" if params[:status] == 'closed')} - = link_to project_issues_path(@project, status: 'closed') do - Closed - %li{class: ("active" if params[:status] == 'all')} - = link_to project_issues_path(@project, status: 'all') do - All - - %fieldset - %hr - = link_to "Reset", project_issues_path(@project), class: 'btn pull-right' - diff --git a/app/views/issues/_form.html.haml b/app/views/issues/_form.html.haml deleted file mode 100644 index 38aea6f06dc..00000000000 --- a/app/views/issues/_form.html.haml +++ /dev/null @@ -1,95 +0,0 @@ -%div.issue-form-holder - %h3.page_title= @issue.new_record? ? "New Issue" : "Edit Issue ##{@issue.id}" - = form_for [@project, @issue] do |f| - -if @issue.errors.any? - .alert.alert-error - - @issue.errors.full_messages.each do |msg| - %span= msg - %br - .ui-box.ui-box-show - .ui-box-head - .clearfix - = f.label :title do - %strong= "Subject *" - .input - = f.text_field :title, maxlength: 255, class: "xxlarge js-gfm-input", autofocus: true, required: true - .ui-box-body - .clearfix - .issue_assignee.pull-left - = f.label :assignee_id do - %i.icon-user - Assign to - .input - .pull-left - = f.select(:assignee_id, @project.team.members.sort_by(&:name).map {|p| [ p.name, p.id ] }, { include_blank: "Select a user" }, {class: 'chosen'}) - .pull-right -   - = link_to 'Assign to me', '#', class: 'btn btn-small assign-to-me-link' - .issue_milestone.pull-left - = f.label :milestone_id do - %i.icon-time - Milestone - .input= f.select(:milestone_id, @project.milestones.active.all.collect {|p| [ p.title, p.id ] }, { include_blank: "Select milestone" }, {class: 'chosen'}) - - .ui-box-bottom - .clearfix - = f.label :label_list do - %i.icon-tag - Labels - .input - = f.text_field :label_list, maxlength: 2000, class: "xxlarge" - %p.hint Separate with comma. - - .clearfix - = f.label :description, "Details" - .input - = f.text_area :description, class: "xxlarge js-gfm-input", rows: 14 - %p.hint Issues are parsed with #{link_to "GitLab Flavored Markdown", help_markdown_path, target: '_blank'}. - - - .actions - - if @issue.new_record? - = f.submit 'Submit new issue', class: "btn btn-create" - -else - = f.submit 'Save changes', class: "btn-save btn" - - - cancel_path = @issue.new_record? ? project_issues_path(@project) : project_issue_path(@project, @issue) - = link_to "Cancel", cancel_path, class: 'btn btn-cancel' - - - - -:javascript - $("#issue_label_list") - .bind( "keydown", function( event ) { - if ( event.keyCode === $.ui.keyCode.TAB && - $( this ).data( "autocomplete" ).menu.active ) { - event.preventDefault(); - } - }) - .bind( "click", function( event ) { - $( this ).autocomplete("search", ""); - }) - .autocomplete({ - minLength: 0, - source: function( request, response ) { - response( $.ui.autocomplete.filter( - #{raw labels_autocomplete_source}, extractLast( request.term ) ) ); - }, - focus: function() { - return false; - }, - select: function(event, ui) { - var terms = split( this.value ); - terms.pop(); - terms.push( ui.item.value ); - terms.push( "" ); - this.value = terms.join( ", " ); - return false; - } - }); - - $('.assign-to-me-link').on('click', function(e){ - $('#issue_assignee_id').val("#{current_user.id}").trigger("liszt:updated"); - e.preventDefault(); - }); diff --git a/app/views/issues/_head.html.haml b/app/views/issues/_head.html.haml deleted file mode 100644 index 44d14d5cdf9..00000000000 --- a/app/views/issues/_head.html.haml +++ /dev/null @@ -1,10 +0,0 @@ -%ul.nav.nav-tabs - = nav_link(controller: :issues) do - = link_to 'Browse Issues', project_issues_path(@project), class: "tab" - = nav_link(controller: :milestones) do - = link_to 'Milestones', project_milestones_path(@project), class: "tab" - = nav_link(controller: :labels) do - = link_to 'Labels', project_labels_path(@project), class: "tab" - %li.pull-right - = link_to project_issues_path(@project, :atom, { private_token: current_user.private_token }) do - %i.icon-rss diff --git a/app/views/issues/_issue.html.haml b/app/views/issues/_issue.html.haml deleted file mode 100644 index f44c0a6c81f..00000000000 --- a/app/views/issues/_issue.html.haml +++ /dev/null @@ -1,44 +0,0 @@ -%li{ id: dom_id(issue), class: issue_css_classes(issue), url: project_issue_path(issue.project, issue) } - - if controller.controller_name == 'issues' - .issue-check - = check_box_tag dom_id(issue,"selected"), nil, false, 'data-id' => issue.id, class: "selected_issue", disabled: !can?(current_user, :modify_issue, issue) - - .issue-title - %span.light= "##{issue.id}" - = link_to_gfm truncate(issue.title, length: 100), project_issue_path(issue.project, issue), class: "row_title" - - .issue-info - - if issue.assignee - assigned to #{link_to_member(@project, issue.assignee)} - - else - unassigned - - if issue.votes_count > 0 - = render 'votes/votes_inline', votable: issue - - if issue.notes.any? - %span - %i.icon-comments - = issue.notes.count - - if issue.milestone_id? - %span - %i.icon-time - = issue.milestone.title - .pull-right - %small updated #{time_ago_in_words(issue.updated_at)} ago - - .issue-labels - - issue.labels.each do |label| - %span{class: "label #{label_css_class(label.name)}"} - %i.icon-tag - = label.name - - .issue-actions - - if can? current_user, :modify_issue, issue - - if issue.closed? - = link_to 'Reopen', project_issue_path(issue.project, issue, issue: {state_event: :reopen }, status_only: true), method: :put, class: "btn btn-small grouped reopen_issue", remote: true - - else - = link_to 'Close', project_issue_path(issue.project, issue, issue: {state_event: :close }, status_only: true), method: :put, class: "btn btn-small grouped close_issue", remote: true - = link_to edit_project_issue_path(issue.project, issue), class: "btn btn-small edit-issue-link grouped" do - %i.icon-edit - Edit - - diff --git a/app/views/issues/_issues.html.haml b/app/views/issues/_issues.html.haml deleted file mode 100644 index 68598684f90..00000000000 --- a/app/views/issues/_issues.html.haml +++ /dev/null @@ -1,94 +0,0 @@ -.ui-box - .title - = check_box_tag "check_all_issues", nil, false, class: "check_all_issues left" - .clearfix - .issues_bulk_update.hide - = form_tag bulk_update_project_issues_path(@project), method: :post do - %span.update_issues_text Update selected issues with   - .left - = select_tag('update[status]', options_for_select(['open', 'closed']), prompt: "Status") - = select_tag('update[assignee_id]', options_from_collection_for_select(@project.team.members, "id", "name", params[:assignee_id]), prompt: "Assignee") - = select_tag('update[milestone_id]', options_from_collection_for_select(issues_active_milestones, "id", "title", params[:milestone_id]), prompt: "Milestone") - = hidden_field_tag 'update[issues_ids]', [] - = hidden_field_tag :status, params[:status] - = button_tag "Save", class: "btn update_selected_issues btn-small btn-save" - .issues-filters - %span Filter by - .dropdown.inline.prepend-left-10 - %a.dropdown-toggle.btn.btn-small{href: '#', "data-toggle" => "dropdown"} - %i.icon-tags - %span.light labels: - - if params[:label_name].present? - %strong= params[:label_name] - - else - Any - %b.caret - %ul.dropdown-menu - %li - = link_to project_issues_with_filter_path(@project, label_name: nil) do - Any - - issue_label_names.each do |label_name| - %li - = link_to project_issues_with_filter_path(@project, label_name: label_name) do - %span{class: "label #{label_css_class(label_name)}"} - %i.icon-tag - = label_name - .dropdown.inline.prepend-left-10 - %a.dropdown-toggle.btn.btn-small{href: '#', "data-toggle" => "dropdown"} - %i.icon-user - %span.light assignee: - - if @assignee.present? - %strong= @assignee.name - - elsif params[:assignee_id] == "0" - Unassigned - - else - Any - %b.caret - %ul.dropdown-menu - %li - = link_to project_issues_with_filter_path(@project, assignee_id: nil) do - Any - = link_to project_issues_with_filter_path(@project, assignee_id: 0) do - Unassigned - - @project.team.members.sort_by(&:name).each do |user| - %li - = link_to project_issues_with_filter_path(@project, assignee_id: user.id) do - = image_tag gravatar_icon(user.email), class: "avatar s16" - = user.name - - .dropdown.inline.prepend-left-10 - %a.dropdown-toggle.btn.btn-small{href: '#', "data-toggle" => "dropdown"} - %i.icon-time - %span.light milestone: - - if @milestone.present? - %strong= @milestone.title - - elsif params[:milestone_id] == "0" - Unspecified - - else - Any - %b.caret - %ul.dropdown-menu - %li - = link_to project_issues_with_filter_path(@project, milestone_id: nil) do - Any - = link_to project_issues_with_filter_path(@project, milestone_id: 0) do - Unspecified - - issues_active_milestones.each do |milestone| - %li - = link_to project_issues_with_filter_path(@project, milestone_id: milestone.id) do - %strong= milestone.title - %small.light= milestone.expires_at - - - %ul.well-list.issues-list - = render @issues - - if @issues.blank? - %li - %h4.nothing_here_message Nothing to show here - -- if @issues.present? - .pull-right - %span.issue_counter #{@issues.total_count} - issues for this filter - - = paginate @issues, remote: true, theme: "gitlab" diff --git a/app/views/issues/edit.html.haml b/app/views/issues/edit.html.haml deleted file mode 100644 index b1bc3ba0eba..00000000000 --- a/app/views/issues/edit.html.haml +++ /dev/null @@ -1 +0,0 @@ -= render "form" diff --git a/app/views/issues/index.atom.builder b/app/views/issues/index.atom.builder deleted file mode 100644 index 00ddd4bf702..00000000000 --- a/app/views/issues/index.atom.builder +++ /dev/null @@ -1,23 +0,0 @@ -xml.instruct! -xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do - xml.title "#{@project.name} issues" - xml.link :href => project_issues_url(@project, :atom), :rel => "self", :type => "application/atom+xml" - xml.link :href => project_issues_url(@project), :rel => "alternate", :type => "text/html" - xml.id project_issues_url(@project) - xml.updated @issues.first.created_at.strftime("%Y-%m-%dT%H:%M:%SZ") if @issues.any? - - @issues.each do |issue| - xml.entry do - xml.id project_issue_url(@project, issue) - xml.link :href => project_issue_url(@project, issue) - xml.title truncate(issue.title, :length => 80) - xml.updated issue.created_at.strftime("%Y-%m-%dT%H:%M:%SZ") - xml.media :thumbnail, :width => "40", :height => "40", :url => gravatar_icon(issue.author_email) - xml.author do |author| - xml.name issue.author_name - xml.email issue.author_email - end - xml.summary issue.title - end - end -end diff --git a/app/views/issues/index.html.haml b/app/views/issues/index.html.haml deleted file mode 100644 index bf33769349a..00000000000 --- a/app/views/issues/index.html.haml +++ /dev/null @@ -1,25 +0,0 @@ -= render "issues/head" -.issues_content - %h3.page_title - Issues - %span (#{@issues.total_count}) - .pull-right - .span6 - - if can? current_user, :write_issue, @project - = link_to new_project_issue_path(@project, issue: { assignee_id: params[:assignee_id], milestone_id: params[:milestone_id]}), class: "btn btn-primary pull-right", title: "New Issue", id: "new_issue_link" do - %i.icon-plus - New Issue - = form_tag project_issues_path(@project), method: :get, remote: true, id: "issue_search_form", class: 'pull-right' do - = hidden_field_tag :status, params[:status], id: 'search_status' - = hidden_field_tag :assignee_id, params[:assignee_id], id: 'search_assignee_id' - = hidden_field_tag :milestone_id, params[:milestone_id], id: 'search_milestone_id' - = hidden_field_tag :label_name, params[:label_name], id: 'search_label_name' - = search_field_tag :issue_search, nil, { placeholder: 'Search', class: 'issue_search input-xlarge append-right-10 search-text-input' } - - .clearfix - -.row - .span3 - = render 'filter', entity: 'issue' - .span9.issues-holder - = render "issues" diff --git a/app/views/issues/index.js.haml b/app/views/issues/index.js.haml deleted file mode 100644 index 1be6a64f535..00000000000 --- a/app/views/issues/index.js.haml +++ /dev/null @@ -1,4 +0,0 @@ -:plain - $('.issues-holder').html("#{escape_javascript(render('issues'))}"); - History.replaceState({path: "#{request.url}"}, document.title, "#{request.url}"); - Issues.reload(); diff --git a/app/views/issues/new.html.haml b/app/views/issues/new.html.haml deleted file mode 100644 index b1bc3ba0eba..00000000000 --- a/app/views/issues/new.html.haml +++ /dev/null @@ -1 +0,0 @@ -= render "form" diff --git a/app/views/issues/show.html.haml b/app/views/issues/show.html.haml deleted file mode 100644 index 2e204b8240d..00000000000 --- a/app/views/issues/show.html.haml +++ /dev/null @@ -1,68 +0,0 @@ -%h3.page_title - Issue ##{@issue.id} - - %small - created at - = @issue.created_at.stamp("Aug 21, 2011") - - %span.pull-right - = link_to new_project_issue_path(@project), class: "btn grouped", title: "New Issue", id: "new_issue_link" do - %i.icon-plus - New Issue - - if can?(current_user, :modify_issue, @issue) - - if @issue.closed? - = link_to 'Reopen', project_issue_path(@project, @issue, issue: {state_event: :reopen }, status_only: true), method: :put, class: "btn grouped reopen_issue" - - else - = link_to 'Close', project_issue_path(@project, @issue, issue: {state_event: :close }, status_only: true), method: :put, class: "btn grouped close_issue", title: "Close Issue" - - = link_to edit_project_issue_path(@project, @issue), class: "btn grouped" do - %i.icon-edit - Edit - -.pull-right - .span3#votes= render 'votes/votes_block', votable: @issue - -.back_link - = link_to project_issues_path(@project) do - ← To issues list - - -.ui-box.ui-box-show - .ui-box-head - %h4.box-title - - if @issue.closed? - .error.status_info Closed - = gfm escape_once(@issue.title) - - .ui-box-body - %cite.cgray - Created by #{link_to_member(@project, @issue.author)} - - if @issue.assignee - \ and currently assigned to #{link_to_member(@project, @issue.assignee)} - - - if @issue.milestone - - milestone = @issue.milestone - %cite.cgray and attached to milestone - %strong= link_to_gfm truncate(milestone.title, length: 20), project_milestone_path(milestone.project, milestone) - - .pull-right - - @issue.labels.each do |label| - %span{class: "label #{label_css_class(label.name)}"} - %i.icon-tag - = label.name -   - - - if @issue.description.present? - .ui-box-bottom - .wiki - = preserve do - = markdown @issue.description - -- content_for :note_actions do - - if can?(current_user, :modify_issue, @issue) - - if @issue.closed? - = link_to 'Reopen Issue', project_issue_path(@project, @issue, issue: {state_event: :reopen }, status_only: true), method: :put, class: "btn grouped reopen_issue" - - else - = link_to 'Close Issue', project_issue_path(@project, @issue, issue: {state_event: :close }, status_only: true), method: :put, class: "btn grouped close_issue", title: "Close Issue" - -.voting_notes#notes= render "notes/notes_with_form" diff --git a/app/views/issues/update.js.haml b/app/views/issues/update.js.haml deleted file mode 100644 index 7f66022a2de..00000000000 --- a/app/views/issues/update.js.haml +++ /dev/null @@ -1,4 +0,0 @@ -- if params[:status_only] - - if @issue.valid? - :plain - $("##{dom_id(@issue)}").fadeOut(); diff --git a/app/views/labels/_label.html.haml b/app/views/labels/_label.html.haml deleted file mode 100644 index 2b1aafc546b..00000000000 --- a/app/views/labels/_label.html.haml +++ /dev/null @@ -1,15 +0,0 @@ -- frequency = @project.issues.tagged_with(label.name).count -%li - %strong - %span{class: "label #{label_css_class(label.name)}"} - %i.icon-tag - - if frequency.zero? - %span.light= label.name - - else - = label.name - .pull-right - - unless frequency.zero? - = link_to project_issues_path(label_name: label.name) do - %strong - = pluralize(frequency, 'issue') - = "»" diff --git a/app/views/labels/index.html.haml b/app/views/labels/index.html.haml deleted file mode 100644 index 53f411d932c..00000000000 --- a/app/views/labels/index.html.haml +++ /dev/null @@ -1,14 +0,0 @@ -= render "issues/head" - -%h3.page_title - Labels -%br - -- if @labels.present? - %ul.bordered-list.labels-table - - @labels.each do |label| - = render 'label', label: label - -- else - .light-well - %h3.nothing_here_message Add first label to your issues or #{link_to 'generate', generate_project_labels_path(@project), method: :post} default set of labels diff --git a/app/views/layouts/project_resource.html.haml b/app/views/layouts/project_resource.html.haml deleted file mode 100644 index 6d8bf9b710b..00000000000 --- a/app/views/layouts/project_resource.html.haml +++ /dev/null @@ -1,15 +0,0 @@ -!!! 5 -%html{ lang: "en"} - = render "layouts/head", title: @project.name_with_namespace - %body{class: "#{app_theme} project", :'data-page' => body_data_page, :'data-project-id' => @project.id } - = render "layouts/head_panel", title: project_title(@project) - = render "layouts/init_auto_complete" - = render "layouts/flash" - - if can?(current_user, :download_code, @project) - = render 'shared/no_ssh' - - %nav.main-nav - .container= render 'layouts/nav/project' - - .container - .content= yield diff --git a/app/views/layouts/projects.html.haml b/app/views/layouts/projects.html.haml new file mode 100644 index 00000000000..6d8bf9b710b --- /dev/null +++ b/app/views/layouts/projects.html.haml @@ -0,0 +1,15 @@ +!!! 5 +%html{ lang: "en"} + = render "layouts/head", title: @project.name_with_namespace + %body{class: "#{app_theme} project", :'data-page' => body_data_page, :'data-project-id' => @project.id } + = render "layouts/head_panel", title: project_title(@project) + = render "layouts/init_auto_complete" + = render "layouts/flash" + - if can?(current_user, :download_code, @project) + = render 'shared/no_ssh' + + %nav.main-nav + .container= render 'layouts/nav/project' + + .container + .content= yield diff --git a/app/views/merge_requests/_filter.html.haml b/app/views/merge_requests/_filter.html.haml deleted file mode 100644 index 4b48306ed05..00000000000 --- a/app/views/merge_requests/_filter.html.haml +++ /dev/null @@ -1,20 +0,0 @@ -= form_tag project_issues_path(@project), method: 'get' do - %fieldset - %ul.nav.nav-pills.nav-stacked - %li{class: ("active" if (params[:f] == 'open' || !params[:f]))} - = link_to project_merge_requests_path(@project, f: 'open', milestone_id: params[:milestone_id]) do - Open - %li{class: ("active" if params[:f] == "closed")} - = link_to project_merge_requests_path(@project, f: "closed", milestone_id: params[:milestone_id]) do - Closed - %li{class: ("active" if params[:f] == 'assigned-to-me')} - = link_to project_merge_requests_path(@project, f: 'assigned-to-me', milestone_id: params[:milestone_id]) do - Assigned To Me - %li{class: ("active" if params[:f] == 'all')} - = link_to project_merge_requests_path(@project, f: 'all', milestone_id: params[:milestone_id]) do - All - - %fieldset - %hr - = link_to "Reset", project_merge_requests_path(@project), class: 'btn pull-right' - diff --git a/app/views/merge_requests/_form.html.haml b/app/views/merge_requests/_form.html.haml deleted file mode 100644 index b3da15608e4..00000000000 --- a/app/views/merge_requests/_form.html.haml +++ /dev/null @@ -1,79 +0,0 @@ -= form_for [@project, @merge_request], html: { class: "#{controller.action_name}-merge-request form-horizontal" } do |f| - -if @merge_request.errors.any? - .alert.alert-error - %ul - - @merge_request.errors.full_messages.each do |msg| - %li= msg - - %fieldset - %legend 1. Select Branches - - .row - .span5 - .mr_branch_box - %h5.cgray From (Head Branch) - .body - .padded= f.select(:source_branch, @repository.branch_names, { include_blank: "Select branch" }, {class: 'chosen span4'}) - .mr_source_commit - - .span2 - %center= image_tag "merge.png", class: 'mr_direction_tip' - .span5 - .mr_branch_box - %h5.cgray To (Base Branch) - .body - .padded= f.select(:target_branch, @repository.branch_names, { include_blank: "Select branch" }, {class: 'chosen span4'}) - .mr_target_commit - - %fieldset - %legend 2. Fill info - - .ui-box.ui-box-show - .ui-box-head - .clearfix - = f.label :title do - %strong= "Title *" - .input= f.text_field :title, class: "input-xxlarge pad js-gfm-input", maxlength: 255, rows: 5, required: true - .ui-box-body - .clearfix - .left - = f.label :assignee_id do - %i.icon-user - Assign to - .input= f.select(:assignee_id, @project.team.members.sort_by(&:name).map {|p| [ p.name, p.id ] }, { include_blank: "Select user" }, {class: 'chosen span3'}) - .left - = f.label :milestone_id do - %i.icon-time - Milestone - .input= f.select(:milestone_id, @project.milestones.active.all.map {|p| [ p.title, p.id ] }, { include_blank: "Select milestone" }, {class: 'chosen'}) - - .control-group - - .form-actions - - if @merge_request.new_record? - = f.submit 'Submit merge request', class: "btn btn-create" - -else - = f.submit 'Save changes', class: "btn btn-save" - - if @merge_request.new_record? - = link_to project_merge_requests_path(@project), class: "btn btn-cancel" do - Cancel - - else - = link_to project_merge_request_path(@project, @merge_request), class: "btn btn-cancel" do - Cancel - -:javascript - disableButtonIfEmptyField("#merge_request_title", ".btn-save"); - - var source_branch = $("#merge_request_source_branch") - , target_branch = $("#merge_request_target_branch"); - - $.get("#{branch_from_project_merge_requests_path(@project)}", {ref: source_branch.val() }); - $.get("#{branch_to_project_merge_requests_path(@project)}", {ref: target_branch.val() }); - - source_branch.live("change", function() { - $.get("#{branch_from_project_merge_requests_path(@project)}", {ref: $(this).val() }); - }); - - target_branch.live("change", function() { - $.get("#{branch_to_project_merge_requests_path(@project)}", {ref: $(this).val() }); - }); diff --git a/app/views/merge_requests/_head.html.haml b/app/views/merge_requests/_head.html.haml deleted file mode 100644 index 35a86e6511c..00000000000 --- a/app/views/merge_requests/_head.html.haml +++ /dev/null @@ -1,5 +0,0 @@ -.top-tabs - = link_to project_merge_requests_path(@project), class: "tab #{'active' if current_page?(project_merge_requests_path(@project)) }" do - %span - Merge Requests - diff --git a/app/views/merge_requests/_merge_request.html.haml b/app/views/merge_requests/_merge_request.html.haml deleted file mode 100644 index ffc6b8fda1e..00000000000 --- a/app/views/merge_requests/_merge_request.html.haml +++ /dev/null @@ -1,29 +0,0 @@ -%li{ class: mr_css_classes(merge_request) } - .merge-request-title - %span.light= "##{merge_request.id}" - = link_to_gfm truncate(merge_request.title, length: 80), project_merge_request_path(merge_request.project, merge_request), class: "row_title" - - if merge_request.merged? - %small.pull-right - %i.icon-ok - = "MERGED" - - else - %span.pull-right - %i.icon-angle-right - = merge_request.target_branch - .merge-request-info - - if merge_request.author - authored by #{link_to_member(@project, merge_request.author)} - - if merge_request.votes_count > 0 - = render 'votes/votes_inline', votable: merge_request - - if merge_request.notes.any? - %span - %i.icon-comments - = merge_request.mr_and_commit_notes.count - - if merge_request.milestone_id? - %span - %i.icon-time - = merge_request.milestone.title - - - .pull-right - %small updated #{time_ago_in_words(merge_request.updated_at)} ago diff --git a/app/views/merge_requests/_show.html.haml b/app/views/merge_requests/_show.html.haml deleted file mode 100644 index d6e00ca9b8b..00000000000 --- a/app/views/merge_requests/_show.html.haml +++ /dev/null @@ -1,37 +0,0 @@ -.merge-request - = render "merge_requests/show/mr_title" - = render "merge_requests/show/how_to_merge" - = render "merge_requests/show/mr_box" - = render "merge_requests/show/mr_accept" - - if @project.gitlab_ci? - = render "merge_requests/show/mr_ci" - = render "merge_requests/show/commits" - - - if @commits.present? - %ul.nav.nav-tabs - %li.notes-tab{data: {action: 'notes'}} - = link_to project_merge_request_path(@project, @merge_request) do - %i.icon-comment - Discussion - %li.diffs-tab{data: {action: 'diffs'}} - = link_to diffs_project_merge_request_path(@project, @merge_request) do - %i.icon-list-alt - Diff - - .notes.tab-content.voting_notes#notes{ class: (controller.action_name == 'show') ? "" : "hide" } - = render "notes/notes_with_form" - .diffs.tab-content - = render "merge_requests/show/diffs" if @diffs - .status - -:javascript - var merge_request; - - merge_request = new MergeRequest({ - url_to_automerge_check: "#{automerge_check_project_merge_request_path(@project, @merge_request)}", - check_enable: #{@merge_request.unchecked? ? "true" : "false"}, - url_to_ci_check: "#{ci_status_project_merge_request_path(@project, @merge_request)}", - ci_enable: #{@project.gitlab_ci? ? "true" : "false"}, - current_status: "#{@merge_request.merge_status_name}", - action: "#{controller.action_name}" - }); diff --git a/app/views/merge_requests/automerge.js.haml b/app/views/merge_requests/automerge.js.haml deleted file mode 100644 index e01ff662e7d..00000000000 --- a/app/views/merge_requests/automerge.js.haml +++ /dev/null @@ -1,7 +0,0 @@ --if @status - :plain - location.reload(); --else - :plain - merge_request.alreadyOrCannotBeMerged() - diff --git a/app/views/merge_requests/branch_from.js.haml b/app/views/merge_requests/branch_from.js.haml deleted file mode 100644 index 0637fdcb72e..00000000000 --- a/app/views/merge_requests/branch_from.js.haml +++ /dev/null @@ -1,2 +0,0 @@ -:plain - $(".mr_source_commit").html("#{commit_to_html(@commit)}"); diff --git a/app/views/merge_requests/branch_to.js.haml b/app/views/merge_requests/branch_to.js.haml deleted file mode 100644 index 974100d1ba7..00000000000 --- a/app/views/merge_requests/branch_to.js.haml +++ /dev/null @@ -1,2 +0,0 @@ -:plain - $(".mr_target_commit").html("#{commit_to_html(@commit)}"); diff --git a/app/views/merge_requests/commits.js.haml b/app/views/merge_requests/commits.js.haml deleted file mode 100644 index 923b1ea032f..00000000000 --- a/app/views/merge_requests/commits.js.haml +++ /dev/null @@ -1,4 +0,0 @@ -:plain - merge_request.$(".commits").html("#{escape_javascript(render(partial: "commits"))}"); - - diff --git a/app/views/merge_requests/diffs.html.haml b/app/views/merge_requests/diffs.html.haml deleted file mode 100644 index 2a5b8b1441e..00000000000 --- a/app/views/merge_requests/diffs.html.haml +++ /dev/null @@ -1 +0,0 @@ -= render "show" diff --git a/app/views/merge_requests/diffs.js.haml b/app/views/merge_requests/diffs.js.haml deleted file mode 100644 index 266892c01ef..00000000000 --- a/app/views/merge_requests/diffs.js.haml +++ /dev/null @@ -1,2 +0,0 @@ -:plain - merge_request.$(".diffs").html("#{escape_javascript(render(partial: "merge_requests/show/diffs"))}"); diff --git a/app/views/merge_requests/edit.html.haml b/app/views/merge_requests/edit.html.haml deleted file mode 100644 index eee148994d7..00000000000 --- a/app/views/merge_requests/edit.html.haml +++ /dev/null @@ -1,4 +0,0 @@ -%h3.page_title - = "Edit merge request #{@merge_request.id}" -%hr -= render 'form' diff --git a/app/views/merge_requests/index.html.haml b/app/views/merge_requests/index.html.haml deleted file mode 100644 index b9e9096e3ae..00000000000 --- a/app/views/merge_requests/index.html.haml +++ /dev/null @@ -1,35 +0,0 @@ -- if can? current_user, :write_merge_request, @project - = link_to new_project_merge_request_path(@project), class: "pull-right btn btn-primary", title: "New Merge Request" do - %i.icon-plus - New Merge Request -%h3.page_title - Merge Requests - -%br - - -.row - .span3 - = render 'filter' - .span9 - .ui-box - .title - = form_tag project_merge_requests_path(@project), id: "merge_requests_search_form", method: :get, class: :left do - = select_tag(:assignee_id, options_from_collection_for_select([unassigned_filter] + @project.users.all, "id", "name", params[:assignee_id]), prompt: "Assignee") - = select_tag(:milestone_id, options_from_collection_for_select([unassigned_filter] + @project.milestones.order("id desc").all, "id", "title", params[:milestone_id]), prompt: "Milestone") - = hidden_field_tag :f, params[:f] - .clearfix - - %ul.well-list.mr-list - = render @merge_requests - - if @merge_requests.blank? - %li - %h4.nothing_here_message Nothing to show here - - if @merge_requests.present? - .pull-right - %span.cgray.pull-right #{@merge_requests.total_count} merge requests for this filter - - = paginate @merge_requests, theme: "gitlab" - -:javascript - $(merge_requestsPage); diff --git a/app/views/merge_requests/invalid.html.haml b/app/views/merge_requests/invalid.html.haml deleted file mode 100644 index a73bef9e80a..00000000000 --- a/app/views/merge_requests/invalid.html.haml +++ /dev/null @@ -1,17 +0,0 @@ -.merge-request - = render "merge_requests/show/mr_title" - = render "merge_requests/show/mr_box" - - .alert.alert-error - %h5 - %i.icon-exclamation-sign - We cannot find - %span.label-branch= @merge_request.source_branch - or - %span.label-branch= @merge_request.target_branch - branches in the repository. - %p - Maybe it was removed or never pushed. - %p - Please close Merge Request or change branches with existing one - diff --git a/app/views/merge_requests/new.html.haml b/app/views/merge_requests/new.html.haml deleted file mode 100644 index 594089995ea..00000000000 --- a/app/views/merge_requests/new.html.haml +++ /dev/null @@ -1,3 +0,0 @@ -%h3.page_title New Merge Request -%hr -= render 'form' diff --git a/app/views/merge_requests/show.html.haml b/app/views/merge_requests/show.html.haml deleted file mode 100644 index 2a5b8b1441e..00000000000 --- a/app/views/merge_requests/show.html.haml +++ /dev/null @@ -1 +0,0 @@ -= render "show" diff --git a/app/views/merge_requests/show.js.haml b/app/views/merge_requests/show.js.haml deleted file mode 100644 index 2ce6eb63290..00000000000 --- a/app/views/merge_requests/show.js.haml +++ /dev/null @@ -1,2 +0,0 @@ -:plain - merge_request.$(".notes").html("#{escape_javascript(render "notes/notes_with_form")}"); diff --git a/app/views/merge_requests/show/_commits.html.haml b/app/views/merge_requests/show/_commits.html.haml deleted file mode 100644 index eee786d71ef..00000000000 --- a/app/views/merge_requests/show/_commits.html.haml +++ /dev/null @@ -1,30 +0,0 @@ -- if @commits.present? - .ui-box - %h5.title - %i.icon-list - Commits (#{@commits.count}) - .commits - - if @commits.count > 8 - %ul.first-commits.well-list - - @commits.first(8).each do |commit| - = render "commits/commit", commit: commit - %li.bottom - 8 of #{@commits.count} commits displayed. - %strong - %a.show-all-commits Click here to show all - %ul.all-commits.hide.well-list - - @commits.each do |commit| - = render "commits/commit", commit: commit - - - else - %ul.well-list - - @commits.each do |commit| - = render "commits/commit", commit: commit - -- else - %h4.nothing_here_message - Nothing to merge from - %span.label-branch #{@merge_request.source_branch} - to - %span.label-branch #{@merge_request.target_branch} - %br diff --git a/app/views/merge_requests/show/_diffs.html.haml b/app/views/merge_requests/show/_diffs.html.haml deleted file mode 100644 index 033d66a4ad4..00000000000 --- a/app/views/merge_requests/show/_diffs.html.haml +++ /dev/null @@ -1,10 +0,0 @@ -- if @merge_request.valid_diffs? - = render "commits/diffs", diffs: @diffs -- elsif @merge_request.broken_diffs? - %h4.nothing_here_message - Can't load diff. - You can - = link_to "download it", project_merge_request_path(@project, @merge_request, format: :diff), class: "vlink" - instead. -- else - %h4.nothing_here_message Nothing to merge diff --git a/app/views/merge_requests/show/_how_to_merge.html.haml b/app/views/merge_requests/show/_how_to_merge.html.haml deleted file mode 100644 index 7f1e33418de..00000000000 --- a/app/views/merge_requests/show/_how_to_merge.html.haml +++ /dev/null @@ -1,19 +0,0 @@ -%div#modal_merge_info.modal.hide - .modal-header - %a.close{href: "#"} × - %h3 How To Merge - .modal-body - %p - %strong Step 1. - Checkout target branch and get recent objects from GitLab - %pre.dark - :preserve - git checkout #{@merge_request.target_branch} - git fetch origin - %p - %strong Step 2. - Merge source branch into target branch and push changes to GitLab - %pre.dark - :preserve - git merge origin/#{@merge_request.source_branch} - git push origin #{@merge_request.target_branch} diff --git a/app/views/merge_requests/show/_mr_accept.html.haml b/app/views/merge_requests/show/_mr_accept.html.haml deleted file mode 100644 index ac97f6327c0..00000000000 --- a/app/views/merge_requests/show/_mr_accept.html.haml +++ /dev/null @@ -1,52 +0,0 @@ -- unless @allowed_to_merge - .alert - %strong You don't have enough permissions to merge this MR - - -- if @show_merge_controls - .automerge_widget.can_be_merged{style: "display:none"} - .alert.alert-success - %span - = form_for [:automerge, @project, @merge_request], remote: true, method: :get do |f| - %p - You can accept this request automatically. - If you still want to do it manually - - %strong= link_to "click here", "#", class: "how_to_merge_link vlink", title: "How To Merge" - for instructions - .accept_group - = f.submit "Accept Merge Request", class: "btn success accept_merge_request" - - unless @project.root_ref? @merge_request.source_branch - .remove_branch_holder - = label_tag :should_remove_source_branch, class: "checkbox" do - = check_box_tag :should_remove_source_branch - Remove source-branch - .clearfix - - - .automerge_widget.no_satellite{style: "display:none"} - .alert.alert-error - %span - %strong This repository does not have satellite. Ask administrator to fix this issue - - .automerge_widget.cannot_be_merged{style: "display:none"} - .alert.alert-disabled - %span - = link_to "Show how to merge", "#", class: "how_to_merge_link btn btn-small padded", title: "How To Merge" -   - %strong This request can't be merged with GitLab. You should do it manually - - .automerge_widget.unchecked - .alert - %strong - %i.icon-refresh - Checking for ability to automatically merge… - - .automerge_widget.already_cannot_be_merged{style: "display:none"} - .alert.alert-info - %strong This merge request already can not be merged. Try to reload page. - - .merge-in-progress.hide - %span.cgray - %i.icon-refresh.icon-spin -   - Merge is in progress. Please wait. Page will be automatically reloaded.   diff --git a/app/views/merge_requests/show/_mr_box.html.haml b/app/views/merge_requests/show/_mr_box.html.haml deleted file mode 100644 index 594f4061c23..00000000000 --- a/app/views/merge_requests/show/_mr_box.html.haml +++ /dev/null @@ -1,36 +0,0 @@ -.ui-box.ui-box-show - .ui-box-head - %h4.box-title - = gfm escape_once(@merge_request.title) - - if @merge_request.merged? - .success.status_info - %i.icon-ok - Merged - - elsif @merge_request.closed? - .error.status_info Closed - - .ui-box-body - %div - %cite.cgray - Created at #{@merge_request.created_at.stamp("Aug 21, 2011")} by #{link_to_member(@project, @merge_request.author)} - - if @merge_request.assignee - \, currently assigned to #{link_to_member(@project, @merge_request.assignee)} - - if @merge_request.milestone - - milestone = @merge_request.milestone - %cite.cgray and attached to milestone - %strong= link_to_gfm truncate(milestone.title, length: 20), project_milestone_path(milestone.project, milestone) - - - - if @merge_request.closed? - .ui-box-bottom.alert-error - %span - %i.icon-remove - Closed by #{link_to_member(@project, @merge_request.closed_event.author)} - %small #{time_ago_in_words(@merge_request.closed_event.created_at)} ago. - - if @merge_request.merged? - .ui-box-bottom.alert-success - %span - %i.icon-ok - Merged by #{link_to_member(@project, @merge_request.merge_event.author)} - #{time_ago_in_words(@merge_request.merge_event.created_at)} ago. - diff --git a/app/views/merge_requests/show/_mr_ci.html.haml b/app/views/merge_requests/show/_mr_ci.html.haml deleted file mode 100644 index 9b15c4526e9..00000000000 --- a/app/views/merge_requests/show/_mr_ci.html.haml +++ /dev/null @@ -1,35 +0,0 @@ -- if @commits.any? - .ci_widget.ci-success{style: "display:none"} - .alert.alert-success - %i.icon-ok - %strong CI build passed - for #{@merge_request.last_commit_short_sha}. - = link_to "Build page", ci_build_details_path(@merge_request) - - - .ci_widget.ci-failed{style: "display:none"} - .alert.alert-error - %i.icon-remove - %strong CI build failed - for #{@merge_request.last_commit_short_sha}. - = link_to "Build page", ci_build_details_path(@merge_request) - - - [:running, :pending].each do |status| - .ci_widget{class: "ci-#{status}", style: "display:none"} - .alert - %i.icon-time - %strong CI build #{status} - for #{@merge_request.last_commit_short_sha}. - = link_to "Build page", ci_build_details_path(@merge_request) - - .ci_widget - .alert - %strong - %i.icon-refresh - Checking for CI status for #{@merge_request.last_commit_short_sha} - - .ci_widget.ci-error{style: "display:none"} - .alert.alert-error - %i.icon-remove - %strong Cannot connect to CI server. Please check your setting - diff --git a/app/views/merge_requests/show/_mr_title.html.haml b/app/views/merge_requests/show/_mr_title.html.haml deleted file mode 100644 index 24285c272a8..00000000000 --- a/app/views/merge_requests/show/_mr_title.html.haml +++ /dev/null @@ -1,31 +0,0 @@ -%h3.page_title - = "Merge Request ##{@merge_request.id}:" -   - %span.label-branch= @merge_request.source_branch - → - %span.label-branch= @merge_request.target_branch - - %span.pull-right - - if can?(current_user, :modify_merge_request, @merge_request) - - if @merge_request.opened? - .left.btn-group - %a.btn.grouped.dropdown-toggle{ data: {toggle: :dropdown} } - %i.icon-download-alt - Download as - %span.caret - %ul.dropdown-menu - %li= link_to "Email Patches", project_merge_request_path(@project, @merge_request, format: :patch) - %li= link_to "Plain Diff", project_merge_request_path(@project, @merge_request, format: :diff) - - = link_to 'Close', project_merge_request_path(@project, @merge_request, merge_request: {state_event: :close }), method: :put, class: "btn grouped btn-close", title: "Close merge request" - - = link_to edit_project_merge_request_path(@project, @merge_request), class: "btn grouped" do - %i.icon-edit - Edit - -.pull-right - .span3#votes= render 'votes/votes_block', votable: @merge_request - -.back_link - = link_to project_merge_requests_path(@project) do - ← To merge requests diff --git a/app/views/milestones/_form.html.haml b/app/views/milestones/_form.html.haml deleted file mode 100644 index 50e3e71b2c3..00000000000 --- a/app/views/milestones/_form.html.haml +++ /dev/null @@ -1,47 +0,0 @@ -%h3.page_title= @milestone.new_record? ? "New Milestone" : "Edit Milestone ##{@milestone.id}" -.back_link - = link_to project_milestones_path(@project) do - ← To milestones - -%hr - -= form_for [@project, @milestone], html: {class: "new_milestone form-horizontal"} do |f| - -if @milestone.errors.any? - .alert.alert-error - %ul - - @milestone.errors.full_messages.each do |msg| - %li= msg - .row - .span6 - .control-group - = f.label :title, "Title", class: "control-label" - .controls - = f.text_field :title, maxlength: 255, class: "input-xlarge" - %p.hint Required - .control-group - = f.label :description, "Description", class: "control-label" - .controls - = f.text_area :description, maxlength: 2000, class: "input-xlarge", rows: 10 - %p.hint Milestones are parsed with #{link_to "GitLab Flavored Markdown", help_markdown_path, target: '_blank'}. - .span6 - .control-group - = f.label :due_date, "Due Date", class: "control-label" - .input= f.hidden_field :due_date - .controls - .datepicker - - .form-actions - - if @milestone.new_record? - = f.submit 'Create milestone', class: "btn-save btn" - = link_to "Cancel", project_milestones_path(@project), class: "btn btn-cancel" - -else - = f.submit 'Save changes', class: "btn-save btn" - = link_to "Cancel", project_milestone_path(@project, @milestone), class: "btn btn-cancel" - - -:javascript - disableButtonIfEmptyField("#milestone_title", ".btn-save"); - $( ".datepicker" ).datepicker({ - dateFormat: "yy-mm-dd", - onSelect: function(dateText, inst) { $("#milestone_due_date").val(dateText) } - }).datepicker("setDate", $.datepicker.parseDate('yy-mm-dd', $('#milestone_due_date').val())); diff --git a/app/views/milestones/_issues.html.haml b/app/views/milestones/_issues.html.haml deleted file mode 100644 index eccf3ddbfa5..00000000000 --- a/app/views/milestones/_issues.html.haml +++ /dev/null @@ -1,11 +0,0 @@ -.ui-box - %h5.title= title - %ul.well-list - - issues.each do |issue| - %li - = link_to [@project, issue] do - %span.badge{class: issue.closed? ? 'badge-important' : 'badge-info'} ##{issue.id} - = link_to_gfm truncate(issue.title, length: 60), [@project, issue] - - if issue.assignee - .pull-right - = image_tag gravatar_icon(issue.assignee.email, 16), class: "avatar s16" diff --git a/app/views/milestones/_merge_request.html.haml b/app/views/milestones/_merge_request.html.haml deleted file mode 100644 index 7f815894069..00000000000 --- a/app/views/milestones/_merge_request.html.haml +++ /dev/null @@ -1,5 +0,0 @@ -%li - = link_to [@project, merge_request] do - %span.badge.badge-info ##{merge_request.id} - – - = link_to_gfm truncate(merge_request.title, length: 60), [@project, merge_request] diff --git a/app/views/milestones/_milestone.html.haml b/app/views/milestones/_milestone.html.haml deleted file mode 100644 index 894fa6c1133..00000000000 --- a/app/views/milestones/_milestone.html.haml +++ /dev/null @@ -1,28 +0,0 @@ -%li{class: "milestone milestone-#{milestone.closed? ? 'closed' : 'open'}", id: dom_id(milestone) } - .pull-right - - if can?(current_user, :admin_milestone, milestone.project) and milestone.active? - = link_to edit_project_milestone_path(milestone.project, milestone), class: "btn btn-small edit-milestone-link grouped" do - %i.icon-edit - Edit - - if milestone.can_be_closed? - = link_to 'Close', project_milestone_path(@project, milestone, milestone: {state_event: :close }), method: :put, remote: true, class: "btn btn-small btn-remove" - %h4 - = link_to_gfm truncate(milestone.title, length: 100), project_milestone_path(milestone.project, milestone) - - if milestone.expired? and not milestone.closed? - %span.cred (Expired) - %small - = milestone.expires_at - - if milestone.is_empty? - %span.muted Empty - - else - %div - %div - = link_to project_issues_path(milestone.project, milestone_id: milestone.id) do - = pluralize milestone.issues.count, 'Issue' -   - = link_to project_merge_requests_path(milestone.project, milestone_id: milestone.id) do - = pluralize milestone.merge_requests.count, 'Merge Request' -   - %span.light #{milestone.percent_complete}% complete - .progress.progress-info - .bar{style: "width: #{milestone.percent_complete}%;"} diff --git a/app/views/milestones/edit.html.haml b/app/views/milestones/edit.html.haml deleted file mode 100644 index b1bc3ba0eba..00000000000 --- a/app/views/milestones/edit.html.haml +++ /dev/null @@ -1 +0,0 @@ -= render "form" diff --git a/app/views/milestones/index.html.haml b/app/views/milestones/index.html.haml deleted file mode 100644 index fb7cbc41edf..00000000000 --- a/app/views/milestones/index.html.haml +++ /dev/null @@ -1,32 +0,0 @@ -= render "issues/head" -.milestones_content - %h3.page_title - Milestones - - if can? current_user, :admin_milestone, @project - = link_to new_project_milestone_path(@project), class: "pull-right btn btn-primary", title: "New Milestone" do - %i.icon-plus - New Milestone - %br - - .row - .span3 - %ul.nav.nav-pills.nav-stacked - %li{class: ("active" if (params[:f] == "active" || !params[:f]))} - = link_to project_milestones_path(@project, f: "active") do - Active - %li{class: ("active" if params[:f] == "closed")} - = link_to project_milestones_path(@project, f: "closed") do - Closed - %li{class: ("active" if params[:f] == "all")} - = link_to project_milestones_path(@project, f: "all") do - All - .span9 - .ui-box - %ul.well-list - = render @milestones - - - if @milestones.blank? - %li - %h3.nothing_here_message Nothing to show here - - = paginate @milestones, theme: "gitlab" diff --git a/app/views/milestones/new.html.haml b/app/views/milestones/new.html.haml deleted file mode 100644 index b1bc3ba0eba..00000000000 --- a/app/views/milestones/new.html.haml +++ /dev/null @@ -1 +0,0 @@ -= render "form" diff --git a/app/views/milestones/show.html.haml b/app/views/milestones/show.html.haml deleted file mode 100644 index de33ab363e6..00000000000 --- a/app/views/milestones/show.html.haml +++ /dev/null @@ -1,106 +0,0 @@ -= render "issues/head" -.row - .span6 - %h3.page_title - Milestone ##{@milestone.id} - %small - = @milestone.expires_at - .back_link - = link_to project_milestones_path(@project) do - ← To milestones list - .span6 - .pull-right - - unless @milestone.closed? - = link_to new_project_issue_path(@project, issue: { milestone_id: @milestone.id }), class: "btn btn-small grouped", title: "New Issue" do - %i.icon-plus - New Issue - = link_to 'Browse Issues', project_issues_path(@milestone.project, milestone_id: @milestone.id), class: "btn edit-milestone-link small grouped" - - if can?(current_user, :admin_milestone, @project) - = link_to edit_project_milestone_path(@project, @milestone), class: "btn btn-small grouped" do - %i.icon-edit - Edit - - - -- if @milestone.can_be_closed? - %hr - %p - %span All issues for this milestone are closed. You may close milestone now. - = link_to 'Close Milestone', project_milestone_path(@project, @milestone, milestone: {state_event: :close }), method: :put, class: "btn btn-small btn-remove" - -.ui-box.ui-box-show - .ui-box-head - %h4.box-title - - if @milestone.closed? - .error.status_info Closed - - elsif @milestone.expired? - .error.status_info Expired - - = gfm escape_once(@milestone.title) - - .ui-box-body - %p - Progress: - #{@milestone.closed_items_count} closed - – - #{@milestone.open_items_count} open - %span.pull-right= @milestone.expires_at - .progress.progress-info - .bar{style: "width: #{@milestone.percent_complete}%;"} - - - - if @milestone.description.present? - .ui-box-bottom - = preserve do - = markdown @milestone.description - - -%ul.nav.nav-tabs - %li.active - = link_to '#tab-issues', 'data-toggle' => 'tab' do - Issues - %span.badge= @issues.count - %li - = link_to '#tab-merge-requests', 'data-toggle' => 'tab' do - Merge Requests - %span.badge= @merge_requests.count - %li - = link_to '#tab-participants', 'data-toggle' => 'tab' do - Participants - %span.badge= @users.count - - -.tab-content - .tab-pane.active#tab-issues - .row - .span4 - = render('issues', title: 'Unstarted Issues (open and unassigned)', issues: @issues.opened.unassigned) - .span4 - = render('issues', title: 'Ongoing Issues (open and assigned)', issues: @issues.opened.assigned) - .span4 - = render('issues', title: 'Completed Issues (closed)', issues: @issues.closed) - - .tab-pane#tab-merge-requests - .row - .span6 - .ui-box - %h5.title Open - %ul.well-list - - @merge_requests.opened.each do |merge_request| - = render 'merge_request', merge_request: merge_request - .span6 - .ui-box - %h5.title Closed - %ul.well-list - - @merge_requests.closed.each do |merge_request| - = render 'merge_request', merge_request: merge_request - - .tab-pane#tab-participants - %ul.bordered-list - - @users.each do |user| - %li - = link_to user, title: user.name, class: "dark" do - = image_tag gravatar_icon(user.email, 32), class: "avatar s32" - %strong= truncate(user.name, lenght: 40) - %br - %small.cgray= user.username diff --git a/app/views/milestones/update.js.haml b/app/views/milestones/update.js.haml deleted file mode 100644 index 3ff84915e97..00000000000 --- a/app/views/milestones/update.js.haml +++ /dev/null @@ -1,2 +0,0 @@ -:plain - $('##{dom_id(@milestone)}').fadeOut(); diff --git a/app/views/network/_head.html.haml b/app/views/network/_head.html.haml deleted file mode 100644 index 62ab8b049ac..00000000000 --- a/app/views/network/_head.html.haml +++ /dev/null @@ -1,26 +0,0 @@ -%h3.page_title Project Network Graph -%hr - -.clearfix - .pull-left - = render partial: 'shared/ref_switcher', locals: {destination: 'graph'} - .pull-left - = form_tag project_network_path(@project, @id), method: :get do |f| - .control-group - = label_tag :filter_ref, "Show only selected ref", class: 'control-label light' - .controls - = check_box_tag :filter_ref, 1, @options[:filter_ref] - - @options.each do |key, value| - = hidden_field_tag(key, value, id: nil) unless key == "filter_ref" - - .search.pull-right - = form_tag project_network_path(@project, @id), method: :get do |f| - .control-group - = label_tag :search , "Looking for commit:", class: 'control-label light' - .controls - = text_field_tag :q, @options[:q], placeholder: "Input SHA", class: "search-input xlarge" - = button_tag type: 'submit', class: 'btn vtop' do - %i.icon-search - - @options.each do |key, value| - = hidden_field_tag(key, value, id: nil) unless key == "q" - diff --git a/app/views/network/show.html.haml b/app/views/network/show.html.haml deleted file mode 100644 index a480ceaf995..00000000000 --- a/app/views/network/show.html.haml +++ /dev/null @@ -1,18 +0,0 @@ -= render "head" -.graph_holder - %h4 - %small You can move around the graph by using the arrow keys. - #holder.graph - .loading.loading-gray - -:javascript - var branch_graph; - $("#filter_ref").click(function() { - $(this).closest('form').submit(); - }); - branch_graph = new BranchGraph($("#holder"), { - url: '#{project_network_path(@project, @ref, @options.merge(format: :json))}', - commit_url: '#{project_commit_path(@project, 'ae45ca32').gsub("ae45ca32", "%s")}', - ref: '#{@ref}', - commit_id: '#{@commit.id}' - }); diff --git a/app/views/network/show.json.erb b/app/views/network/show.json.erb deleted file mode 100644 index 9a62cdb3dc9..00000000000 --- a/app/views/network/show.json.erb +++ /dev/null @@ -1,23 +0,0 @@ -<% self.formats = ["html"] %> - -<%= raw( - { - days: @graph.days.compact.map { |d| [d.day, d.strftime("%b")] }, - commits: @graph.commits.map do |c| - { - parents: parents_zip_spaces(c.parents(@graph.map), c.parent_spaces), - author: { - name: c.author_name, - email: c.author_email, - icon: gravatar_icon(c.author_email, 20) - }, - time: c.time, - space: c.spaces.first, - refs: get_refs(c), - id: c.sha, - date: c.date, - message: c.message, - } - end - }.to_json -) %> diff --git a/app/views/notes/_diff_note_link.html.haml b/app/views/notes/_diff_note_link.html.haml deleted file mode 100644 index 377c926a204..00000000000 --- a/app/views/notes/_diff_note_link.html.haml +++ /dev/null @@ -1,10 +0,0 @@ -- note = @project.notes.new(@comments_target.merge({ line_code: line_code })) -= link_to "", - "javascript:;", - class: "add-diff-note js-add-diff-note-button", - data: { noteable_type: note.noteable_type, - noteable_id: note.noteable_id, - commit_id: note.commit_id, - line_code: note.line_code, - discussion_id: note.discussion_id }, - title: "Add a comment to this line" diff --git a/app/views/notes/_diff_notes_with_reply.html.haml b/app/views/notes/_diff_notes_with_reply.html.haml deleted file mode 100644 index 0808f86b090..00000000000 --- a/app/views/notes/_diff_notes_with_reply.html.haml +++ /dev/null @@ -1,11 +0,0 @@ -- note = notes.first # example note -%tr.notes_holder - %td.notes_line{ colspan: 2 } - %span.btn.disabled - %i.icon-comment - = notes.count - %td.notes_content - %ul.notes{ rel: note.discussion_id } - = render notes - - = render "notes/discussion_reply_button", note: note diff --git a/app/views/notes/_discussion.html.haml b/app/views/notes/_discussion.html.haml deleted file mode 100644 index eaefb442662..00000000000 --- a/app/views/notes/_discussion.html.haml +++ /dev/null @@ -1,63 +0,0 @@ -- note = discussion_notes.first -.discussion.js-details-container.js-toggler-container.open{ class: note.discussion_id } - .discussion-header - .discussion-actions - = link_to "javascript:;", class: "js-details-target turn-on js-toggler-target" do - %i.icon-eye-close - Hide discussion - = link_to "javascript:;", class: "js-details-target turn-off js-toggler-target" do - %i.icon-eye-open - Show discussion - = image_tag gravatar_icon(note.author_email), class: "avatar s32" - %div - = link_to_member(@project, note.author, avatar: false) - - if note.for_merge_request? - - if note.diff - started a discussion on this merge request diff - = link_to_merge_request_diff_line_note(note) - - else - started - %strong - %i.icon-remove - outdated - discussion on this merge request diff - - elsif note.for_commit? - started a discussion on commit - #{link_to note.noteable.short_id, project_commit_path(@project, note.noteable)} - = link_to_commit_diff_line_note(note) if note.for_diff_line? - - else - %cite.cgray started a discussion - %div - - last_note = discussion_notes.last - last updated by - = link_to_member(@project, last_note.author, avatar: false) - %span.discussion-last-update - = time_ago_in_words(last_note.updated_at) - ago - .discussion-body - - if note.for_diff_line? - - if note.diff - .content - .file= render "notes/discussion_diff", discussion_notes: discussion_notes, note: note - - else - = link_to 'show outdated discussion', '#', class: 'js-show-outdated-discussion' - %div.hide.outdated-discussion - .content - .notes{ rel: discussion_notes.first.discussion_id } - = render discussion_notes - - - - else - .content - .notes{ rel: discussion_notes.first.discussion_id } - = render discussion_notes - = render "notes/discussion_reply_button", note: discussion_notes.first - - -# will be shown when the other one is hidden - .discussion-hidden.content.hide - .note - %em Hidden discussion. - = link_to "javascript:;", class: "js-details-target js-toggler-target" do - %i.icon-eye-open - Show - diff --git a/app/views/notes/_discussion_diff.html.haml b/app/views/notes/_discussion_diff.html.haml deleted file mode 100644 index 20bdb3f3562..00000000000 --- a/app/views/notes/_discussion_diff.html.haml +++ /dev/null @@ -1,24 +0,0 @@ -- diff = note.diff -.header - - if diff.deleted_file - %span= diff.old_path - - else - %span= diff.new_path - - if diff.a_mode && diff.b_mode && diff.a_mode != diff.b_mode - %span.file-mode= "#{diff.a_mode} → #{diff.b_mode}" - %br/ -.content - %table - - each_diff_line_near(diff, note.diff_file_index, note.line_code) do |line, type, line_code, line_new, line_old| - %tr.line_holder{ id: line_code } - - if type == "match" - %td.old_line= "..." - %td.new_line= "..." - %td.line_content.matched= line - - else - %td.old_line= raw(type == "new" ? " " : line_old) - %td.new_line= raw(type == "old" ? " " : line_new) - %td.line_content{class: "noteable_line #{type} #{line_code}", "line_code" => line_code}= raw "#{line}  " - - - if line_code == note.line_code - = render "notes/diff_notes_with_reply", notes: discussion_notes diff --git a/app/views/notes/_discussion_reply_button.html.haml b/app/views/notes/_discussion_reply_button.html.haml deleted file mode 100644 index d1c5ccc29db..00000000000 --- a/app/views/notes/_discussion_reply_button.html.haml +++ /dev/null @@ -1,10 +0,0 @@ -= link_to "javascript:;", - class: "btn reply-btn js-discussion-reply-button", - data: { noteable_type: note.noteable_type, - noteable_id: note.noteable_id, - commit_id: note.commit_id, - line_code: note.line_code, - discussion_id: note.discussion_id }, - title: "Add a reply" do - %i.icon-comment - Reply diff --git a/app/views/notes/_form.html.haml b/app/views/notes/_form.html.haml deleted file mode 100644 index 7add2921830..00000000000 --- a/app/views/notes/_form.html.haml +++ /dev/null @@ -1,37 +0,0 @@ -= form_for [@project, @note], remote: true, html: { multipart: true, id: nil, class: "new_note js-new-note-form common-note-form" } do |f| - - = note_target_fields - = f.hidden_field :commit_id - = f.hidden_field :line_code - = f.hidden_field :noteable_id - = f.hidden_field :noteable_type - - .note_text_and_preview.js-toggler-container - %a.js-note-preview-button.js-toggler-target.turn-off{ href: "javascript:;", title: "Preview", data: {url: preview_project_notes_path(@project)} } - %i.icon-eye-open - %a.js-note-edit-button.js-toggler-target.turn-off{ href: "javascript:;", title: "Edit" } - %i.icon-edit - - = f.text_area :note, size: 255, class: 'note_text js-note-text js-gfm-input turn-on' - .note_preview.js-note-preview.turn-off - - .hint - .pull-right Comments are parsed with #{link_to "GitLab Flavored Markdown", help_markdown_path, target: '_blank'}. - .clearfix - - .note-form-actions - .buttons - = f.submit 'Add Comment', class: "btn comment-btn grouped js-comment-button" - = yield(:note_actions) - - %a.btn.grouped.js-close-discussion-note-form Cancel - - .note-form-option - %a.choose-btn.btn.btn-small.js-choose-note-attachment-button - %i.icon-paper-clip - %span Choose File ... -   - %span.file_name.js-attachment-filename File name... - = f.file_field :attachment, class: "js-note-attachment-input hide" - - .clearfix diff --git a/app/views/notes/_form_errors.html.haml b/app/views/notes/_form_errors.html.haml deleted file mode 100644 index 0851536f0da..00000000000 --- a/app/views/notes/_form_errors.html.haml +++ /dev/null @@ -1,3 +0,0 @@ -.error_message.js-errors - - note.errors.full_messages.each do |msg| - %div= msg diff --git a/app/views/notes/_note.html.haml b/app/views/notes/_note.html.haml deleted file mode 100644 index 6a1159bc8f0..00000000000 --- a/app/views/notes/_note.html.haml +++ /dev/null @@ -1,37 +0,0 @@ -%li{ id: dom_id(note), class: dom_class(note), data: { discussion: note.discussion_id } } - .note-header - .note-actions - = link_to "##{dom_id(note)}", name: dom_id(note) do - %i.icon-link - Link here -   - - if(note.author_id == current_user.id) || can?(current_user, :admin_note, @project) - = link_to project_note_path(@project, note), title: "Remove comment", method: :delete, confirm: 'Are you sure you want to remove comment?', remote: true, class: "danger js-note-delete" do - %i.icon-trash.cred - = image_tag gravatar_icon(note.author_email), class: "avatar s32" - = link_to_member(@project, note.author, avatar: false) - %span.note-last-update - = time_ago_in_words(note.updated_at) - ago - - - if note.upvote? - %span.vote.upvote.label.label-success - %i.icon-thumbs-up - \+1 - - if note.downvote? - %span.vote.downvote.label.label-error - %i.icon-thumbs-down - \-1 - - - .note-body - = preserve do - = markdown(note.note) - - if note.attachment.url - - if note.attachment.image? - = image_tag note.attachment.url, class: 'note-image-attach' - .attachment.pull-right - = link_to note.attachment.secure_url, target: "_blank" do - %i.icon-paper-clip - = note.attachment_identifier - .clear diff --git a/app/views/notes/_notes.html.haml b/app/views/notes/_notes.html.haml deleted file mode 100644 index 4904249aeff..00000000000 --- a/app/views/notes/_notes.html.haml +++ /dev/null @@ -1,11 +0,0 @@ -- if @discussions.present? - - @discussions.each do |discussion_notes| - - note = discussion_notes.first - - if note_for_main_target?(note) - = render discussion_notes - - else - = render 'discussion', discussion_notes: discussion_notes -- else - - @notes.each do |note| - - next unless note.author - = render 'note', note: note diff --git a/app/views/notes/_notes_with_form.html.haml b/app/views/notes/_notes_with_form.html.haml deleted file mode 100644 index 38d1a3c93c0..00000000000 --- a/app/views/notes/_notes_with_form.html.haml +++ /dev/null @@ -1,9 +0,0 @@ -%ul#notes-list.notes -.js-notes-busy - -.js-main-target-form -- if can? current_user, :write_note, @project - = render "notes/form" - -:javascript - NoteList.init("#{@target_id}", "#{@target_type}", "#{project_notes_path(@project)}"); diff --git a/app/views/notes/create.js.haml b/app/views/notes/create.js.haml deleted file mode 100644 index 43e79c69f11..00000000000 --- a/app/views/notes/create.js.haml +++ /dev/null @@ -1,18 +0,0 @@ -- if @note.valid? - var noteHtml = "#{escape_javascript(render "notes/note", note: @note)}"; - - - if note_for_main_target?(@note) - NoteList.appendNewNote(#{@note.id}, noteHtml); - - else - :plain - var firstDiscussionNoteHtml = "#{escape_javascript(render "notes/diff_notes_with_reply", notes: [@note])}"; - NoteList.appendNewDiscussionNote("#{@note.discussion_id}", - firstDiscussionNoteHtml, - noteHtml); - -- else - var errorsHtml = "#{escape_javascript(render 'notes/form_errors', note: @note)}"; - - if note_for_main_target?(@note) - NoteList.errorsOnForm(errorsHtml); - - else - NoteList.errorsOnForm(errorsHtml, "#{@note.discussion_id}"); diff --git a/app/views/notes/index.js.haml b/app/views/notes/index.js.haml deleted file mode 100644 index 826862b1a86..00000000000 --- a/app/views/notes/index.js.haml +++ /dev/null @@ -1,4 +0,0 @@ -- unless @notes.blank? - var notesHtml = "#{escape_javascript(render 'notes/notes')}"; - - new_note_ids = @notes.map(&:id) - NoteList.setContent(#{new_note_ids}, notesHtml); diff --git a/app/views/projects/blame/_head.html.haml b/app/views/projects/blame/_head.html.haml new file mode 100644 index 00000000000..3a883829562 --- /dev/null +++ b/app/views/projects/blame/_head.html.haml @@ -0,0 +1,2 @@ +%div.tree-ref-holder + = render 'shared/ref_switcher', destination: 'tree', path: params[:path] diff --git a/app/views/projects/blame/show.html.haml b/app/views/projects/blame/show.html.haml new file mode 100644 index 00000000000..3f68db659fc --- /dev/null +++ b/app/views/projects/blame/show.html.haml @@ -0,0 +1,49 @@ += render "head" + +#tree-holder.tree-holder + %ul.breadcrumb + %li + %i.icon-angle-right + = link_to project_tree_path(@project, @ref) do + = @project.name + - tree_breadcrumbs(@tree, 6) do |link| + \/ + %li= link + .clear + + .file_holder + .file_title + %i.icon-file + %span.file_name + = @blob.name + %small= number_to_human_size @blob.size + %span.options= render "projects/blob/actions" + .file_content.blame + %table + - current_line = 1 + - @blame.each do |commit, lines| + - commit = Commit.new(commit) + %tr + %td.blame-commit + %span.commit + = link_to commit.short_id(8), project_commit_path(@project, commit), class: "commit_short_id" +   + = commit_author_link(commit, avatar: true, size: 16) +   + = link_to_gfm truncate(commit.title, length: 20), project_commit_path(@project, commit.id), class: "row_title" + %td.lines.blame-numbers + %pre + - if lines.empty? + = current_line + - current_line += 1 + - else + - lines.each do |line| + = current_line + \ + - current_line += 1 + %td.lines + %pre + :erb + <% lines.each do |line| %> + <%= line %> + <% end %> diff --git a/app/views/projects/blob/_actions.html.haml b/app/views/projects/blob/_actions.html.haml new file mode 100644 index 00000000000..456c7432c94 --- /dev/null +++ b/app/views/projects/blob/_actions.html.haml @@ -0,0 +1,12 @@ +.btn-group.tree-btn-group + -# only show edit link for text files + - if @blob.text? + = link_to "edit", project_edit_tree_path(@project, @id), class: "btn btn-tiny", disabled: !allowed_tree_edit? + = link_to "raw", project_raw_path(@project, @id), class: "btn btn-tiny", target: "_blank" + -# only show normal/blame view links for text files + - if @blob.text? + - if current_page? project_blame_path(@project, @id) + = link_to "normal view", project_blob_path(@project, @id), class: "btn btn-tiny" + - else + = link_to "blame", project_blame_path(@project, @id), class: "btn btn-tiny" unless @blob.empty? + = link_to "history", project_commits_path(@project, @id), class: "btn btn-tiny" diff --git a/app/views/projects/blob/_blob.html.haml b/app/views/projects/blob/_blob.html.haml new file mode 100644 index 00000000000..68d6c06065c --- /dev/null +++ b/app/views/projects/blob/_blob.html.haml @@ -0,0 +1,32 @@ +%ul.breadcrumb + %li + %i.icon-angle-right + = link_to project_tree_path(@project, @ref) do + = @project.path + - tree_breadcrumbs(@tree, 6) do |title, path| + \/ + %li + - if path + - if path.end_with?(@path) + = link_to project_blob_path(@project, path) do + %span.cblue + = truncate(title, length: 40) + - else + = link_to truncate(title, length: 40), project_tree_path(@project, path) + - else + = link_to title, '#' + +%div#tree-content-holder.tree-content-holder + .file_holder + .file_title + %i.icon-file + %span.file_name + = blob.name + %small= number_to_human_size blob.size + %span.options= render "actions" + - if blob.text? + = render "text", blob: blob + - elsif blob.image? + = render "image", blob: blob + - else + = render "download", blob: blob diff --git a/app/views/projects/blob/_download.html.haml b/app/views/projects/blob/_download.html.haml new file mode 100644 index 00000000000..864c209db76 --- /dev/null +++ b/app/views/projects/blob/_download.html.haml @@ -0,0 +1,8 @@ +.file_content.blob_file + %center + = link_to project_blob_path(@project, @id) do + %div.padded + %h4 + %i.icon-download-alt + %br + Download (#{number_to_human_size blob.size}) diff --git a/app/views/projects/blob/_image.html.haml b/app/views/projects/blob/_image.html.haml new file mode 100644 index 00000000000..7b23f0c810c --- /dev/null +++ b/app/views/projects/blob/_image.html.haml @@ -0,0 +1,2 @@ +.file_content.image_file + %img{ src: "data:#{blob.mime_type};base64,#{Base64.encode64(blob.data)}"} diff --git a/app/views/projects/blob/_text.html.haml b/app/views/projects/blob/_text.html.haml new file mode 100644 index 00000000000..122e275219d --- /dev/null +++ b/app/views/projects/blob/_text.html.haml @@ -0,0 +1,14 @@ +- if gitlab_markdown?(blob.name) + .file_content.wiki + = preserve do + = markdown(blob.data) +- elsif markup?(blob.name) + .file_content.wiki + = raw GitHub::Markup.render(blob.name, blob.data) +- else + .file_content.code + - unless blob.empty? + %div{class: user_color_scheme_class} + = raw blob.colorize(formatter: :gitlab) + - else + %p.nothing_here_message Empty file diff --git a/app/views/projects/blob/show.html.haml b/app/views/projects/blob/show.html.haml new file mode 100644 index 00000000000..d96595bc7f0 --- /dev/null +++ b/app/views/projects/blob/show.html.haml @@ -0,0 +1,4 @@ +%div.tree-ref-holder + = render 'shared/ref_switcher', destination: 'blob', path: @path +%div#tree-holder.tree-holder + = render 'blob', blob: @blob diff --git a/app/views/projects/commit/_commit_box.html.haml b/app/views/projects/commit/_commit_box.html.haml new file mode 100644 index 00000000000..646791773b2 --- /dev/null +++ b/app/views/projects/commit/_commit_box.html.haml @@ -0,0 +1,50 @@ +.ui-box.ui-box-show + .ui-box-head + .pull-right + - if @notes_count > 0 + %span.btn.disabled.grouped + %i.icon-comment + = @notes_count + .left.btn-group + %a.btn.grouped.dropdown-toggle{ data: {toggle: :dropdown} } + %i.icon-download-alt + Download as + %span.caret + %ul.dropdown-menu + %li= link_to "Email Patches", project_commit_path(@project, @commit, format: :patch) + %li= link_to "Plain Diff", project_commit_path(@project, @commit, format: :diff) + = link_to project_tree_path(@project, @commit), class: "btn btn-primary grouped" do + %span Browse Code » + %h3.commit-title.page_title + = gfm escape_once(@commit.title) + - if @commit.description.present? + %pre.commit-description + = gfm escape_once(@commit.description) + .ui-box-body + .row + .span5 + .author + = commit_author_link(@commit, avatar: true, size: 32) + authored + %time{title: @commit.authored_date.stamp("Aug 21, 2011 9:23pm")} + #{time_ago_in_words(@commit.authored_date)} ago + - if @commit.different_committer? + .committer + → + = commit_committer_link(@commit) + committed + %time{title: @commit.committed_date.stamp("Aug 21, 2011 9:23pm")} + #{time_ago_in_words(@commit.committed_date)} ago + .span6.pull-right + .pull-right + .sha-block + %span.cgray commit + %span.label_commit= @commit.id + .clearfix + .pull-right + .sha-block + %span.cgray= pluralize(@commit.parents.count, "parent") + - @commit.parents.each do |parent| + = link_to parent.id[0...10], project_commit_path(@project, parent) + + diff --git a/app/views/projects/commit/huge_commit.html.haml b/app/views/projects/commit/huge_commit.html.haml new file mode 100644 index 00000000000..5d447d6cee5 --- /dev/null +++ b/app/views/projects/commit/huge_commit.html.haml @@ -0,0 +1,3 @@ += render "commit/commit_box" +.alert.alert-error + %h4 Commit diffs are too big to be displayed diff --git a/app/views/projects/commit/show.html.haml b/app/views/projects/commit/show.html.haml new file mode 100644 index 00000000000..603406202ca --- /dev/null +++ b/app/views/projects/commit/show.html.haml @@ -0,0 +1,11 @@ += render "commit_box" + +- unless @commit.has_zero_stats? + %p.pull-right.cgray + This commit has + %span.cgreen #{@commit.stats.additions} additions + and + %span.cred #{@commit.stats.deletions} deletions + += render "projects/commits/diffs", diffs: @commit.diffs += render "projects/notes/notes_with_form" diff --git a/app/views/projects/commits/_commit.html.haml b/app/views/projects/commits/_commit.html.haml new file mode 100644 index 00000000000..eba6c206c46 --- /dev/null +++ b/app/views/projects/commits/_commit.html.haml @@ -0,0 +1,21 @@ +%li.commit + .browse_code_link_holder + %p + %strong= link_to "Browse Code »", project_tree_path(@project, commit), class: "right" + %p + = link_to commit.short_id(8), project_commit_path(@project, commit), class: "commit_short_id" + = commit_author_link(commit, avatar: true, size: 24) +   + = link_to_gfm truncate(commit.title, length: 70), project_commit_path(@project, commit.id), class: "row_title" + + %time.committed_ago{ datetime: commit.committed_date, title: commit.committed_date.stamp("Aug 21, 2011 9:23pm") } + = time_ago_in_words(commit.committed_date) + ago +   + + %span.notes_count + - notes = @project.notes.for_commit_id(commit.id) + - if notes.any? + %span.badge.badge-info + %i.icon-comment + = notes.count diff --git a/app/views/projects/commits/_commits.html.haml b/app/views/projects/commits/_commits.html.haml new file mode 100644 index 00000000000..933780e4534 --- /dev/null +++ b/app/views/projects/commits/_commits.html.haml @@ -0,0 +1,9 @@ +- @commits.group_by { |c| c.committed_date.to_date }.sort.reverse.each do |day, commits| + %div.ui-box + %h5.title + %i.icon-calendar + %span= day.stamp("28 Aug, 2010") + + .pull-right + %small= pluralize(commits.count, 'commit') + %ul.well-list= render commits diff --git a/app/views/projects/commits/_diff_head.html.haml b/app/views/projects/commits/_diff_head.html.haml new file mode 100644 index 00000000000..5aa542287fe --- /dev/null +++ b/app/views/projects/commits/_diff_head.html.haml @@ -0,0 +1,26 @@ +%ul.bordered-list + - diffs.each_with_index do |diff, i| + %li + - if diff.deleted_file + %span.deleted-file + %a{href: "#diff-#{i}"} + %i.icon-minus + = diff.old_path + - elsif diff.renamed_file + %span.renamed-file + %a{href: "#diff-#{i}"} + %i.icon-minus + = diff.old_path + = "->" + = diff.new_path + - elsif diff.new_file + %span.new-file + %a{href: "#diff-#{i}"} + %i.icon-plus + = diff.new_path + - else + %span.edit-file + %a{href: "#diff-#{i}"} + %i.icon-adjust + = diff.new_path + diff --git a/app/views/projects/commits/_diffs.html.haml b/app/views/projects/commits/_diffs.html.haml new file mode 100644 index 00000000000..8e3cbff8f3e --- /dev/null +++ b/app/views/projects/commits/_diffs.html.haml @@ -0,0 +1,49 @@ +- if @suppress_diff + .alert.alert-block + %p + %strong Warning! Large commit with more than #{Commit::DIFF_SAFE_SIZE} files changed. + %p To prevent performance issue we rejected diff information. + %p + But if you still want to see diff + = link_to "click this link", project_commit_path(@project, @commit, force_show_diff: true), class: "underlined_link" + +%p.cgray + Showing #{pluralize(diffs.count, "changed file")} +.file-stats + = render "projects/commits/diff_head", diffs: diffs + +.files + - unless @suppress_diff + - diffs.each_with_index do |diff, i| + - next if diff.diff.empty? + - file = Gitlab::Git::Blob.new(@repository, @commit.id, @ref, diff.new_path) + - file = Gitlab::Git::Blob.new(@repository, @commit.parent_id, @ref, diff.old_path) unless file.exists? + - next unless file.exists? + .file{id: "diff-#{i}"} + .header + - if diff.deleted_file + %span= diff.old_path + + - if @commit.parent_ids.present? + = link_to project_blob_path(@project, tree_join(@commit.parent_id, diff.new_path)), {:class => 'btn btn-tiny pull-right view-file'} do + View file @ + %span.commit-short-id= @commit.short_id(6) + - else + %span= diff.new_path + - if diff.a_mode && diff.b_mode && diff.a_mode != diff.b_mode + %span.file-mode= "#{diff.a_mode} → #{diff.b_mode}" + + = link_to project_blob_path(@project, tree_join(@commit.id, diff.new_path)), {:class => 'btn btn-tiny pull-right view-file'} do + View file @ + %span.commit-short-id= @commit.short_id(6) + + .content + -# Skipp all non non-supported blobs + - next unless file.respond_to?('text?') + - if file.text? + = render "projects/commits/text_file", diff: diff, index: i + - elsif file.image? + - old_file = Gitlab::Git::Blob.new(@repository, @commit.parent_id, @ref, diff.old_path) if @commit.parent_id + = render "projects/commits/image", diff: diff, old_file: old_file, file: file, index: i + - else + %p.nothing_here_message No preview for this file type diff --git a/app/views/projects/commits/_head.html.haml b/app/views/projects/commits/_head.html.haml new file mode 100644 index 00000000000..20b9195c4c3 --- /dev/null +++ b/app/views/projects/commits/_head.html.haml @@ -0,0 +1,27 @@ +%ul.nav.nav-tabs + %li= render partial: 'shared/ref_switcher', locals: {destination: 'commits'} + + = nav_link(controller: [:commit, :commits]) do + = link_to 'Commits', project_commits_path(@project, @repository.root_ref) + = nav_link(controller: :compare) do + = link_to 'Compare', project_compare_index_path(@project) + + = nav_link(html_options: {class: branches_tab_class}) do + = link_to project_repository_path(@project) do + Branches + %span.badge= @repository.branches.length + + = nav_link(controller: :repositories, action: :tags) do + = link_to tags_project_repository_path(@project) do + Tags + %span.badge= @repository.tags.length + + = nav_link(controller: :repositories, action: :stats) do + = link_to stats_project_repository_path(@project) do + Stats + + + - if current_controller?(:commits) && current_user.private_token + %li.pull-right + = link_to project_commits_path(@project, @ref, {format: :atom, private_token: current_user.private_token}), title: "Feed" do + %i.icon-rss diff --git a/app/views/projects/commits/_image.html.haml b/app/views/projects/commits/_image.html.haml new file mode 100644 index 00000000000..db02fa333b9 --- /dev/null +++ b/app/views/projects/commits/_image.html.haml @@ -0,0 +1,63 @@ +- if diff.renamed_file || diff.new_file || diff.deleted_file + .image + %span.wrap + .frame{class: image_diff_class(diff)} + %img{src: "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"} + %p.image-info= "#{number_to_human_size file.size}" +- else + .image + %div.two-up.view + %span.wrap + .frame.deleted + %a{href: project_tree_path(@project, tree_join(@commit.id, diff.old_path))} + %img{src: "data:#{old_file.mime_type};base64,#{Base64.encode64(old_file.data)}"} + %p.image-info.hide + %span.meta-filesize= "#{number_to_human_size old_file.size}" + | + %b W: + %span.meta-width + | + %b H: + %span.meta-height + %span.wrap + .frame.added + %a{href: project_tree_path(@project, tree_join(@commit.id, diff.new_path))} + %img{src: "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"} + %p.image-info.hide + %span.meta-filesize= "#{number_to_human_size file.size}" + | + %b W: + %span.meta-width + | + %b H: + %span.meta-height + + %div.swipe.view.hide + .swipe-frame + .frame.deleted + %img{src: "data:#{old_file.mime_type};base64,#{Base64.encode64(old_file.data)}"} + .swipe-wrap + .frame.added + %img{src: "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"} + %span.swipe-bar + %span.top-handle + %span.bottom-handle + + %div.onion-skin.view.hide + .onion-skin-frame + .frame.deleted + %img{src: "data:#{old_file.mime_type};base64,#{Base64.encode64(old_file.data)}"} + .frame.added + %img{src: "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"} + .controls + .transparent + .drag-track + .dragger{:style => "left: 0px;"} + .opaque + + + .view-modes.hide + %ul.view-modes-menu + %li.two-up{data: {mode: 'two-up'}} 2-up + %li.swipe{data: {mode: 'swipe'}} Swipe + %li.onion-skin{data: {mode: 'onion-skin'}} Onion skin \ No newline at end of file diff --git a/app/views/projects/commits/_text_file.html.haml b/app/views/projects/commits/_text_file.html.haml new file mode 100644 index 00000000000..bfc3180a84c --- /dev/null +++ b/app/views/projects/commits/_text_file.html.haml @@ -0,0 +1,23 @@ +- too_big = diff.diff.lines.count > 1000 +- if too_big + %a.supp_diff_link Diff suppressed. Click to show + +%table.text-file{class: "#{'hide' if too_big}"} + - each_diff_line(diff, index) do |line, type, line_code, line_new, line_old| + %tr.line_holder{ id: line_code, class: "#{type}" } + - if type == "match" + %td.old_line= "..." + %td.new_line= "..." + %td.line_content.matched= line + - else + %td.old_line + = link_to raw(type == "new" ? " " : line_old), "##{line_code}", id: line_code + - if @comments_allowed + = render "projects/notes/diff_note_link", line_code: line_code + %td.new_line= link_to raw(type == "old" ? " " : line_new) , "##{line_code}", id: line_code + %td.line_content{class: "noteable_line #{type} #{line_code}", "line_code" => line_code}= raw diff_line_content(line) + + - if @reply_allowed + - comments = @line_notes.select { |n| n.line_code == line_code }.sort_by(&:created_at) + - unless comments.empty? + = render "projects/notes/diff_notes_with_reply", notes: comments diff --git a/app/views/projects/commits/show.atom.builder b/app/views/projects/commits/show.atom.builder new file mode 100644 index 00000000000..46f9838e84a --- /dev/null +++ b/app/views/projects/commits/show.atom.builder @@ -0,0 +1,23 @@ +xml.instruct! +xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do + xml.title "Recent commits to #{@project.name}:#{@ref}" + xml.link :href => project_commits_url(@project, @ref, format: :atom), :rel => "self", :type => "application/atom+xml" + xml.link :href => project_commits_url(@project, @ref), :rel => "alternate", :type => "text/html" + xml.id project_commits_url(@project) + xml.updated @commits.first.committed_date.strftime("%Y-%m-%dT%H:%M:%SZ") if @commits.any? + + @commits.each do |commit| + xml.entry do + xml.id project_commit_url(@project, :id => commit.id) + xml.link :href => project_commit_url(@project, :id => commit.id) + xml.title truncate(commit.title, :length => 80) + xml.updated commit.committed_date.strftime("%Y-%m-%dT%H:%M:%SZ") + xml.media :thumbnail, :width => "40", :height => "40", :url => gravatar_icon(commit.author_email) + xml.author do |author| + xml.name commit.author_name + xml.email commit.author_email + end + xml.summary gfm(commit.description) + end + end +end diff --git a/app/views/projects/commits/show.html.haml b/app/views/projects/commits/show.html.haml new file mode 100644 index 00000000000..cb9ef820d3e --- /dev/null +++ b/app/views/projects/commits/show.html.haml @@ -0,0 +1,15 @@ += render "head" + +- if @path.present? + %ul.breadcrumb + = commits_breadcrumbs + +%div{id: dom_id(@project)} + #commits-list= render "commits" +.clear +.loading{ style: "display:none;"} + +- if @commits.count == @limit + :javascript + CommitsList.init("#{@ref}", #{@limit}); + diff --git a/app/views/projects/commits/show.js.haml b/app/views/projects/commits/show.js.haml new file mode 100644 index 00000000000..797bc14cc1b --- /dev/null +++ b/app/views/projects/commits/show.js.haml @@ -0,0 +1,3 @@ +:plain + CommitsList.append(#{@commits.count}, "#{escape_javascript(render(partial: 'commits/commits'))}"); + diff --git a/app/views/projects/compare/_form.html.haml b/app/views/projects/compare/_form.html.haml new file mode 100644 index 00000000000..ccdd0fc98eb --- /dev/null +++ b/app/views/projects/compare/_form.html.haml @@ -0,0 +1,37 @@ +%div + - unless params[:to] + %p.slead + Fill input field with commit id like + %code.label-branch 4eedf23 + or branch/tag name like + %code.label-branch master + and press compare button for commits list, code diff. + + %br + + = form_tag project_compare_index_path(@project), method: :post do + .clearfix + .pull-left + - if params[:to] && params[:from] + = link_to 'switch', {from: params[:to], to: params[:from]}, {class: 'commits-compare-switch has_tooltip', title: 'Switch base of comparison'} + = text_field_tag :from, params[:from], placeholder: "master", class: "xlarge" + = "..." + = text_field_tag :to, params[:to], placeholder: "aa8b4ef", class: "xlarge" + .pull-left +   + = submit_tag "Compare", class: "btn btn-primary wide commits-compare-btn" + - if @refs_are_same + .alert + %span Refs are the same + + + +:javascript + var availableTags = #{@project.repository.ref_names.to_json}; + + $("#from, #to").autocomplete({ + source: availableTags, + minLength: 1 + }); + + disableButtonIfEmptyField('#to', '.commits-compare-btn'); diff --git a/app/views/projects/compare/index.html.haml b/app/views/projects/compare/index.html.haml new file mode 100644 index 00000000000..95cfb60d885 --- /dev/null +++ b/app/views/projects/compare/index.html.haml @@ -0,0 +1,7 @@ += render "projects/commits/head" + +%h3.page_title + Compare View +%hr + += render "form" diff --git a/app/views/projects/compare/show.html.haml b/app/views/projects/compare/show.html.haml new file mode 100644 index 00000000000..51e88d1c47d --- /dev/null +++ b/app/views/projects/compare/show.html.haml @@ -0,0 +1,23 @@ += render "projects/commits/head" + +%h3.page_title + Compare View +%hr + += render "form" + +- if @commits.size > 100 + .alert.alert-block + %p + %strong Warning! This comparison include 100+ commits. + %p To prevent performance issue we dont show diff information. + +- if @commits.present? + %div.ui-box + %h5.title + Commits (#{@commits.count}) + %ul.well-list= render Commit.decorate(@commits) + + - unless @diffs.empty? + %h4 Diff + = render "projects/commits/diffs", diffs: @diffs diff --git a/app/views/projects/deploy_keys/_deploy_key.html.haml b/app/views/projects/deploy_keys/_deploy_key.html.haml new file mode 100644 index 00000000000..45f80ecd556 --- /dev/null +++ b/app/views/projects/deploy_keys/_deploy_key.html.haml @@ -0,0 +1,25 @@ +%li + .pull-right + - if @available_keys.include?(deploy_key) + = link_to enable_project_deploy_key_path(@project, deploy_key), class: 'btn btn-small', method: :put do + %i.icon-plus + Enable + - else + - if deploy_key.projects.count > 1 + = link_to disable_project_deploy_key_path(@project, deploy_key), class: 'btn btn-small', method: :put do + %i.icon-off + Disable + - else + = link_to 'Remove', project_deploy_key_path(@project, deploy_key), confirm: 'You are going to remove deploy key. Are you sure?', method: :delete, class: "btn btn-remove delete-key btn-small pull-right" + + + = link_to project_deploy_key_path(deploy_key.projects.include?(@project) ? @project : deploy_key.projects.first, deploy_key) do + %i.icon-key + %strong= deploy_key.title + + %p.light.prepend-top-10 + - deploy_key.projects.map(&:name_with_namespace).each do |project_name| + %span.label= project_name + %small.pull-right + Created #{time_ago_in_words(deploy_key.created_at)} ago + diff --git a/app/views/projects/deploy_keys/_form.html.haml b/app/views/projects/deploy_keys/_form.html.haml new file mode 100644 index 00000000000..71bf309dd8b --- /dev/null +++ b/app/views/projects/deploy_keys/_form.html.haml @@ -0,0 +1,23 @@ +%div + = form_for [@project, @key], url: project_deploy_keys_path do |f| + -if @key.errors.any? + .alert.alert-error + %ul + - @key.errors.full_messages.each do |msg| + %li= msg + + .clearfix + = f.label :title + .input= f.text_field :title + .clearfix + = f.label :key + .input + = f.text_area :key, class: [:xxlarge, :thin_area] + %p.hint + Paste a machine public key here. Read more about how generate it + = link_to "here", help_ssh_path + + .actions + = f.submit 'Create', class: "btn-create btn" + = link_to "Cancel", project_deploy_keys_path(@project), class: "btn btn-cancel" + diff --git a/app/views/projects/deploy_keys/index.html.haml b/app/views/projects/deploy_keys/index.html.haml new file mode 100644 index 00000000000..a1fa3475a84 --- /dev/null +++ b/app/views/projects/deploy_keys/index.html.haml @@ -0,0 +1,30 @@ +%p.slead + Deploy keys allow read-only access to repository. They can be used for CI, staging or production servers + +%p + You can create a deploy key or add existing one + = link_to new_project_deploy_key_path(@project), class: "btn btn-primary pull-right", title: "New Deploy Key" do + %i.icon-plus + New Deploy Key + +%hr.clearfix + +.row + .span5.enabled-keys + %h5.cgreen + Enabled deploy keys + %small for this project + %ul.bordered-list + = render @enabled_keys + - if @enabled_keys.blank? + .light-well + %p.nothing_here_message Create #{link_to 'new deploy key', new_project_deploy_key_path(@project)} or add existing one + .span5.available-keys + %h5 + Available deploy keys + %small from projects you are able to manage + %ul.bordered-list + = render @available_keys + - if @available_keys.blank? + .light-well + %p.nothing_here_message All deploy keys created in projects you own will be displayed here diff --git a/app/views/projects/deploy_keys/new.html.haml b/app/views/projects/deploy_keys/new.html.haml new file mode 100644 index 00000000000..b0e2a8b2949 --- /dev/null +++ b/app/views/projects/deploy_keys/new.html.haml @@ -0,0 +1,4 @@ +%h3.page_title New Deploy key +%hr + += render 'form' diff --git a/app/views/projects/deploy_keys/show.html.haml b/app/views/projects/deploy_keys/show.html.haml new file mode 100644 index 00000000000..26fd7428b7e --- /dev/null +++ b/app/views/projects/deploy_keys/show.html.haml @@ -0,0 +1,13 @@ +%h3.page_title + Deploy key: + = @key.title + %small + created at + = @key.created_at.stamp("Aug 21, 2011") +.back_link + = link_to project_deploy_keys_path(@project) do + ← To keys list +%hr +%pre= @key.key +.pull-right + = link_to 'Remove', project_deploy_key_path(@project, @key), confirm: 'Are you sure?', method: :delete, class: "btn-remove btn delete-key" diff --git a/app/views/projects/edit_tree/show.html.haml b/app/views/projects/edit_tree/show.html.haml new file mode 100644 index 00000000000..101b479afed --- /dev/null +++ b/app/views/projects/edit_tree/show.html.haml @@ -0,0 +1,45 @@ +.file-editor + = form_tag(project_edit_tree_path(@project, @id), method: :put, class: "form-horizontal") do + .file_holder + .file_title + %i.icon-file + %span.file_name + = @path + %small + on + %strong= @ref + %span.options + .btn-group.tree-btn-group + = link_to "Cancel", project_blob_path(@project, @id), class: "btn btn-tiny btn-cancel", confirm: leave_edit_message + .file_content.code + %pre#editor= @blob.data + + .control-group.commit_message-group + = label_tag 'commit_message', class: "control-label" do + Commit message + .controls + = text_area_tag 'commit_message', '', placeholder: "Update #{@blob.name}", required: true, rows: 3 + .form-actions + = hidden_field_tag 'last_commit', @last_commit + = hidden_field_tag 'content', '', id: :file_content + .commit-button-annotation + = button_tag "Commit changes", class: 'btn commit-btn js-commit-button btn-primary' + .message + to branch + %strong= @ref + = link_to "Cancel", project_blob_path(@project, @id), class: "btn btn-cancel", confirm: leave_edit_message + +:javascript + ace.config.set("modePath", "#{Gitlab::Application.config.assets.prefix}/ace-src-noconflict") + var ace_mode = "#{@blob.language.try(:ace_mode)}"; + var editor = ace.edit("editor"); + if (ace_mode) { + editor.getSession().setMode('ace/mode/' + ace_mode); + } + + disableButtonIfEmptyField("#commit_message", ".js-commit-button"); + + $(".js-commit-button").click(function(){ + $("#file_content").val(editor.getValue()); + $(".file-editor form").submit(); + }); diff --git a/app/views/projects/graphs/show.html.haml b/app/views/projects/graphs/show.html.haml new file mode 100644 index 00000000000..05bc1436e6d --- /dev/null +++ b/app/views/projects/graphs/show.html.haml @@ -0,0 +1,31 @@ +.loading-graph + %center + .loading + %h3.page_title Building repository graph. Please wait a moment. + +.stat-graph + .header.clearfix + .pull-right + %select + %option{:value => "commits"} Commits + %option{:value => "additions"} Additions + %option{:value => "deletions"} Deletions + %h3#date_header.page_title + %input#brush_change{:type => "hidden"} + .graphs + #contributors-master + #contributors.clearfix + %ol.contributors-list.clearfix + +:javascript + $(".stat-graph").hide(); + + $.ajax({ + type: "GET", + url: location.href, + complete: function() { + $(".loading-graph").hide(); + $(".stat-graph").show(); + }, + dataType: "script" + }); diff --git a/app/views/projects/graphs/show.js.haml b/app/views/projects/graphs/show.js.haml new file mode 100644 index 00000000000..b7c9b4113e9 --- /dev/null +++ b/app/views/projects/graphs/show.js.haml @@ -0,0 +1,16 @@ +:plain + controller = new ContributorsStatGraph + controller.init(#{@log}) + + $("select").change( function () { + var field = $(this).val() + controller.set_current_field(field) + controller.redraw_master() + controller.redraw_authors() + }) + + $("#brush_change").change( function () { + controller.change_date_header() + controller.redraw_authors() + }) + diff --git a/app/views/projects/hooks/_data_ex.html.erb b/app/views/projects/hooks/_data_ex.html.erb new file mode 100644 index 00000000000..b4281fa18c7 --- /dev/null +++ b/app/views/projects/hooks/_data_ex.html.erb @@ -0,0 +1,43 @@ +<% data_ex_str = < +
    + <%= raw Pygments::Lexer[:js].highlight(data_ex_str) %> +
    diff --git a/app/views/projects/hooks/index.html.haml b/app/views/projects/hooks/index.html.haml new file mode 100644 index 00000000000..641ab082d8d --- /dev/null +++ b/app/views/projects/hooks/index.html.haml @@ -0,0 +1,34 @@ +- if can? current_user, :admin_project, @project + .alert.alert-info + %span + Post receive hooks for binding events when someone push to repository. + %br + Read more about web hooks + %strong #{link_to "here", help_web_hooks_path, class: "vlink"} + += form_for [@project, @hook], as: :hook, url: project_hooks_path(@project), html: { class: 'form-inline' } do |f| + -if @hook.errors.any? + .alert.alert-error + - @hook.errors.full_messages.each do |msg| + %p= msg + .clearfix + = f.label :url, "URL:" + .input + = f.text_field :url, class: "text_field xxlarge" +   + = f.submit "Add Web Hook", class: "btn btn-create" +%hr + +-if @hooks.any? + .ui-box + %h5.title + Hooks (#{@hooks.count}) + %ul.well-list + - @hooks.each do |hook| + %li + %span.badge.badge-info POST + → + %span.monospace= hook.url + .pull-right + = link_to 'Test Hook', test_project_hook_path(@project, hook), class: "btn btn-small grouped" + = link_to 'Remove', project_hook_path(@project, hook), confirm: 'Are you sure?', method: :delete, class: "btn btn-remove btn-small grouped" diff --git a/app/views/projects/issues/_filter.html.haml b/app/views/projects/issues/_filter.html.haml new file mode 100644 index 00000000000..8495c323cb8 --- /dev/null +++ b/app/views/projects/issues/_filter.html.haml @@ -0,0 +1,23 @@ += form_tag project_issues_path(@project), method: 'get' do + %fieldset + %ul.nav.nav-pills.nav-stacked + %li{class: ("active" if !params[:status] || params[:status].blank?)} + = link_to project_issues_path(@project, status: nil) do + Open + %li{class: ("active" if params[:status] == 'assigned-to-me')} + = link_to project_issues_path(@project, status: 'assigned-to-me') do + Assigned to me + %li{class: ("active" if params[:status] == 'created-by-me')} + = link_to project_issues_path(@project, status: 'created-by-me') do + Created by me + %li{class: ("active" if params[:status] == 'closed')} + = link_to project_issues_path(@project, status: 'closed') do + Closed + %li{class: ("active" if params[:status] == 'all')} + = link_to project_issues_path(@project, status: 'all') do + All + + %fieldset + %hr + = link_to "Reset", project_issues_path(@project), class: 'btn pull-right' + diff --git a/app/views/projects/issues/_form.html.haml b/app/views/projects/issues/_form.html.haml new file mode 100644 index 00000000000..38aea6f06dc --- /dev/null +++ b/app/views/projects/issues/_form.html.haml @@ -0,0 +1,95 @@ +%div.issue-form-holder + %h3.page_title= @issue.new_record? ? "New Issue" : "Edit Issue ##{@issue.id}" + = form_for [@project, @issue] do |f| + -if @issue.errors.any? + .alert.alert-error + - @issue.errors.full_messages.each do |msg| + %span= msg + %br + .ui-box.ui-box-show + .ui-box-head + .clearfix + = f.label :title do + %strong= "Subject *" + .input + = f.text_field :title, maxlength: 255, class: "xxlarge js-gfm-input", autofocus: true, required: true + .ui-box-body + .clearfix + .issue_assignee.pull-left + = f.label :assignee_id do + %i.icon-user + Assign to + .input + .pull-left + = f.select(:assignee_id, @project.team.members.sort_by(&:name).map {|p| [ p.name, p.id ] }, { include_blank: "Select a user" }, {class: 'chosen'}) + .pull-right +   + = link_to 'Assign to me', '#', class: 'btn btn-small assign-to-me-link' + .issue_milestone.pull-left + = f.label :milestone_id do + %i.icon-time + Milestone + .input= f.select(:milestone_id, @project.milestones.active.all.collect {|p| [ p.title, p.id ] }, { include_blank: "Select milestone" }, {class: 'chosen'}) + + .ui-box-bottom + .clearfix + = f.label :label_list do + %i.icon-tag + Labels + .input + = f.text_field :label_list, maxlength: 2000, class: "xxlarge" + %p.hint Separate with comma. + + .clearfix + = f.label :description, "Details" + .input + = f.text_area :description, class: "xxlarge js-gfm-input", rows: 14 + %p.hint Issues are parsed with #{link_to "GitLab Flavored Markdown", help_markdown_path, target: '_blank'}. + + + .actions + - if @issue.new_record? + = f.submit 'Submit new issue', class: "btn btn-create" + -else + = f.submit 'Save changes', class: "btn-save btn" + + - cancel_path = @issue.new_record? ? project_issues_path(@project) : project_issue_path(@project, @issue) + = link_to "Cancel", cancel_path, class: 'btn btn-cancel' + + + + +:javascript + $("#issue_label_list") + .bind( "keydown", function( event ) { + if ( event.keyCode === $.ui.keyCode.TAB && + $( this ).data( "autocomplete" ).menu.active ) { + event.preventDefault(); + } + }) + .bind( "click", function( event ) { + $( this ).autocomplete("search", ""); + }) + .autocomplete({ + minLength: 0, + source: function( request, response ) { + response( $.ui.autocomplete.filter( + #{raw labels_autocomplete_source}, extractLast( request.term ) ) ); + }, + focus: function() { + return false; + }, + select: function(event, ui) { + var terms = split( this.value ); + terms.pop(); + terms.push( ui.item.value ); + terms.push( "" ); + this.value = terms.join( ", " ); + return false; + } + }); + + $('.assign-to-me-link').on('click', function(e){ + $('#issue_assignee_id').val("#{current_user.id}").trigger("liszt:updated"); + e.preventDefault(); + }); diff --git a/app/views/projects/issues/_head.html.haml b/app/views/projects/issues/_head.html.haml new file mode 100644 index 00000000000..44d14d5cdf9 --- /dev/null +++ b/app/views/projects/issues/_head.html.haml @@ -0,0 +1,10 @@ +%ul.nav.nav-tabs + = nav_link(controller: :issues) do + = link_to 'Browse Issues', project_issues_path(@project), class: "tab" + = nav_link(controller: :milestones) do + = link_to 'Milestones', project_milestones_path(@project), class: "tab" + = nav_link(controller: :labels) do + = link_to 'Labels', project_labels_path(@project), class: "tab" + %li.pull-right + = link_to project_issues_path(@project, :atom, { private_token: current_user.private_token }) do + %i.icon-rss diff --git a/app/views/projects/issues/_issue.html.haml b/app/views/projects/issues/_issue.html.haml new file mode 100644 index 00000000000..f44c0a6c81f --- /dev/null +++ b/app/views/projects/issues/_issue.html.haml @@ -0,0 +1,44 @@ +%li{ id: dom_id(issue), class: issue_css_classes(issue), url: project_issue_path(issue.project, issue) } + - if controller.controller_name == 'issues' + .issue-check + = check_box_tag dom_id(issue,"selected"), nil, false, 'data-id' => issue.id, class: "selected_issue", disabled: !can?(current_user, :modify_issue, issue) + + .issue-title + %span.light= "##{issue.id}" + = link_to_gfm truncate(issue.title, length: 100), project_issue_path(issue.project, issue), class: "row_title" + + .issue-info + - if issue.assignee + assigned to #{link_to_member(@project, issue.assignee)} + - else + unassigned + - if issue.votes_count > 0 + = render 'votes/votes_inline', votable: issue + - if issue.notes.any? + %span + %i.icon-comments + = issue.notes.count + - if issue.milestone_id? + %span + %i.icon-time + = issue.milestone.title + .pull-right + %small updated #{time_ago_in_words(issue.updated_at)} ago + + .issue-labels + - issue.labels.each do |label| + %span{class: "label #{label_css_class(label.name)}"} + %i.icon-tag + = label.name + + .issue-actions + - if can? current_user, :modify_issue, issue + - if issue.closed? + = link_to 'Reopen', project_issue_path(issue.project, issue, issue: {state_event: :reopen }, status_only: true), method: :put, class: "btn btn-small grouped reopen_issue", remote: true + - else + = link_to 'Close', project_issue_path(issue.project, issue, issue: {state_event: :close }, status_only: true), method: :put, class: "btn btn-small grouped close_issue", remote: true + = link_to edit_project_issue_path(issue.project, issue), class: "btn btn-small edit-issue-link grouped" do + %i.icon-edit + Edit + + diff --git a/app/views/projects/issues/_issues.html.haml b/app/views/projects/issues/_issues.html.haml new file mode 100644 index 00000000000..68598684f90 --- /dev/null +++ b/app/views/projects/issues/_issues.html.haml @@ -0,0 +1,94 @@ +.ui-box + .title + = check_box_tag "check_all_issues", nil, false, class: "check_all_issues left" + .clearfix + .issues_bulk_update.hide + = form_tag bulk_update_project_issues_path(@project), method: :post do + %span.update_issues_text Update selected issues with   + .left + = select_tag('update[status]', options_for_select(['open', 'closed']), prompt: "Status") + = select_tag('update[assignee_id]', options_from_collection_for_select(@project.team.members, "id", "name", params[:assignee_id]), prompt: "Assignee") + = select_tag('update[milestone_id]', options_from_collection_for_select(issues_active_milestones, "id", "title", params[:milestone_id]), prompt: "Milestone") + = hidden_field_tag 'update[issues_ids]', [] + = hidden_field_tag :status, params[:status] + = button_tag "Save", class: "btn update_selected_issues btn-small btn-save" + .issues-filters + %span Filter by + .dropdown.inline.prepend-left-10 + %a.dropdown-toggle.btn.btn-small{href: '#', "data-toggle" => "dropdown"} + %i.icon-tags + %span.light labels: + - if params[:label_name].present? + %strong= params[:label_name] + - else + Any + %b.caret + %ul.dropdown-menu + %li + = link_to project_issues_with_filter_path(@project, label_name: nil) do + Any + - issue_label_names.each do |label_name| + %li + = link_to project_issues_with_filter_path(@project, label_name: label_name) do + %span{class: "label #{label_css_class(label_name)}"} + %i.icon-tag + = label_name + .dropdown.inline.prepend-left-10 + %a.dropdown-toggle.btn.btn-small{href: '#', "data-toggle" => "dropdown"} + %i.icon-user + %span.light assignee: + - if @assignee.present? + %strong= @assignee.name + - elsif params[:assignee_id] == "0" + Unassigned + - else + Any + %b.caret + %ul.dropdown-menu + %li + = link_to project_issues_with_filter_path(@project, assignee_id: nil) do + Any + = link_to project_issues_with_filter_path(@project, assignee_id: 0) do + Unassigned + - @project.team.members.sort_by(&:name).each do |user| + %li + = link_to project_issues_with_filter_path(@project, assignee_id: user.id) do + = image_tag gravatar_icon(user.email), class: "avatar s16" + = user.name + + .dropdown.inline.prepend-left-10 + %a.dropdown-toggle.btn.btn-small{href: '#', "data-toggle" => "dropdown"} + %i.icon-time + %span.light milestone: + - if @milestone.present? + %strong= @milestone.title + - elsif params[:milestone_id] == "0" + Unspecified + - else + Any + %b.caret + %ul.dropdown-menu + %li + = link_to project_issues_with_filter_path(@project, milestone_id: nil) do + Any + = link_to project_issues_with_filter_path(@project, milestone_id: 0) do + Unspecified + - issues_active_milestones.each do |milestone| + %li + = link_to project_issues_with_filter_path(@project, milestone_id: milestone.id) do + %strong= milestone.title + %small.light= milestone.expires_at + + + %ul.well-list.issues-list + = render @issues + - if @issues.blank? + %li + %h4.nothing_here_message Nothing to show here + +- if @issues.present? + .pull-right + %span.issue_counter #{@issues.total_count} + issues for this filter + + = paginate @issues, remote: true, theme: "gitlab" diff --git a/app/views/projects/issues/edit.html.haml b/app/views/projects/issues/edit.html.haml new file mode 100644 index 00000000000..b1bc3ba0eba --- /dev/null +++ b/app/views/projects/issues/edit.html.haml @@ -0,0 +1 @@ += render "form" diff --git a/app/views/projects/issues/index.atom.builder b/app/views/projects/issues/index.atom.builder new file mode 100644 index 00000000000..00ddd4bf702 --- /dev/null +++ b/app/views/projects/issues/index.atom.builder @@ -0,0 +1,23 @@ +xml.instruct! +xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do + xml.title "#{@project.name} issues" + xml.link :href => project_issues_url(@project, :atom), :rel => "self", :type => "application/atom+xml" + xml.link :href => project_issues_url(@project), :rel => "alternate", :type => "text/html" + xml.id project_issues_url(@project) + xml.updated @issues.first.created_at.strftime("%Y-%m-%dT%H:%M:%SZ") if @issues.any? + + @issues.each do |issue| + xml.entry do + xml.id project_issue_url(@project, issue) + xml.link :href => project_issue_url(@project, issue) + xml.title truncate(issue.title, :length => 80) + xml.updated issue.created_at.strftime("%Y-%m-%dT%H:%M:%SZ") + xml.media :thumbnail, :width => "40", :height => "40", :url => gravatar_icon(issue.author_email) + xml.author do |author| + xml.name issue.author_name + xml.email issue.author_email + end + xml.summary issue.title + end + end +end diff --git a/app/views/projects/issues/index.html.haml b/app/views/projects/issues/index.html.haml new file mode 100644 index 00000000000..d3fd9886d45 --- /dev/null +++ b/app/views/projects/issues/index.html.haml @@ -0,0 +1,25 @@ += render "head" +.issues_content + %h3.page_title + Issues + %span (#{@issues.total_count}) + .pull-right + .span6 + - if can? current_user, :write_issue, @project + = link_to new_project_issue_path(@project, issue: { assignee_id: params[:assignee_id], milestone_id: params[:milestone_id]}), class: "btn btn-primary pull-right", title: "New Issue", id: "new_issue_link" do + %i.icon-plus + New Issue + = form_tag project_issues_path(@project), method: :get, remote: true, id: "issue_search_form", class: 'pull-right' do + = hidden_field_tag :status, params[:status], id: 'search_status' + = hidden_field_tag :assignee_id, params[:assignee_id], id: 'search_assignee_id' + = hidden_field_tag :milestone_id, params[:milestone_id], id: 'search_milestone_id' + = hidden_field_tag :label_name, params[:label_name], id: 'search_label_name' + = search_field_tag :issue_search, nil, { placeholder: 'Search', class: 'issue_search input-xlarge append-right-10 search-text-input' } + + .clearfix + +.row + .span3 + = render 'filter', entity: 'issue' + .span9.issues-holder + = render "issues" diff --git a/app/views/projects/issues/index.js.haml b/app/views/projects/issues/index.js.haml new file mode 100644 index 00000000000..1be6a64f535 --- /dev/null +++ b/app/views/projects/issues/index.js.haml @@ -0,0 +1,4 @@ +:plain + $('.issues-holder').html("#{escape_javascript(render('issues'))}"); + History.replaceState({path: "#{request.url}"}, document.title, "#{request.url}"); + Issues.reload(); diff --git a/app/views/projects/issues/new.html.haml b/app/views/projects/issues/new.html.haml new file mode 100644 index 00000000000..b1bc3ba0eba --- /dev/null +++ b/app/views/projects/issues/new.html.haml @@ -0,0 +1 @@ += render "form" diff --git a/app/views/projects/issues/show.html.haml b/app/views/projects/issues/show.html.haml new file mode 100644 index 00000000000..138db92eac0 --- /dev/null +++ b/app/views/projects/issues/show.html.haml @@ -0,0 +1,68 @@ +%h3.page_title + Issue ##{@issue.id} + + %small + created at + = @issue.created_at.stamp("Aug 21, 2011") + + %span.pull-right + = link_to new_project_issue_path(@project), class: "btn grouped", title: "New Issue", id: "new_issue_link" do + %i.icon-plus + New Issue + - if can?(current_user, :modify_issue, @issue) + - if @issue.closed? + = link_to 'Reopen', project_issue_path(@project, @issue, issue: {state_event: :reopen }, status_only: true), method: :put, class: "btn grouped reopen_issue" + - else + = link_to 'Close', project_issue_path(@project, @issue, issue: {state_event: :close }, status_only: true), method: :put, class: "btn grouped close_issue", title: "Close Issue" + + = link_to edit_project_issue_path(@project, @issue), class: "btn grouped" do + %i.icon-edit + Edit + +.pull-right + .span3#votes= render 'votes/votes_block', votable: @issue + +.back_link + = link_to project_issues_path(@project) do + ← To issues list + + +.ui-box.ui-box-show + .ui-box-head + %h4.box-title + - if @issue.closed? + .error.status_info Closed + = gfm escape_once(@issue.title) + + .ui-box-body + %cite.cgray + Created by #{link_to_member(@project, @issue.author)} + - if @issue.assignee + \ and currently assigned to #{link_to_member(@project, @issue.assignee)} + + - if @issue.milestone + - milestone = @issue.milestone + %cite.cgray and attached to milestone + %strong= link_to_gfm truncate(milestone.title, length: 20), project_milestone_path(milestone.project, milestone) + + .pull-right + - @issue.labels.each do |label| + %span{class: "label #{label_css_class(label.name)}"} + %i.icon-tag + = label.name +   + + - if @issue.description.present? + .ui-box-bottom + .wiki + = preserve do + = markdown @issue.description + +- content_for :note_actions do + - if can?(current_user, :modify_issue, @issue) + - if @issue.closed? + = link_to 'Reopen Issue', project_issue_path(@project, @issue, issue: {state_event: :reopen }, status_only: true), method: :put, class: "btn grouped reopen_issue" + - else + = link_to 'Close Issue', project_issue_path(@project, @issue, issue: {state_event: :close }, status_only: true), method: :put, class: "btn grouped close_issue", title: "Close Issue" + +.voting_notes#notes= render "projects/notes/notes_with_form" diff --git a/app/views/projects/issues/update.js.haml b/app/views/projects/issues/update.js.haml new file mode 100644 index 00000000000..7f66022a2de --- /dev/null +++ b/app/views/projects/issues/update.js.haml @@ -0,0 +1,4 @@ +- if params[:status_only] + - if @issue.valid? + :plain + $("##{dom_id(@issue)}").fadeOut(); diff --git a/app/views/projects/labels/_label.html.haml b/app/views/projects/labels/_label.html.haml new file mode 100644 index 00000000000..2b1aafc546b --- /dev/null +++ b/app/views/projects/labels/_label.html.haml @@ -0,0 +1,15 @@ +- frequency = @project.issues.tagged_with(label.name).count +%li + %strong + %span{class: "label #{label_css_class(label.name)}"} + %i.icon-tag + - if frequency.zero? + %span.light= label.name + - else + = label.name + .pull-right + - unless frequency.zero? + = link_to project_issues_path(label_name: label.name) do + %strong + = pluralize(frequency, 'issue') + = "»" diff --git a/app/views/projects/labels/index.html.haml b/app/views/projects/labels/index.html.haml new file mode 100644 index 00000000000..b6a4b07b9ae --- /dev/null +++ b/app/views/projects/labels/index.html.haml @@ -0,0 +1,14 @@ += render "projects/issues/head" + +%h3.page_title + Labels +%br + +- if @labels.present? + %ul.bordered-list.labels-table + - @labels.each do |label| + = render 'label', label: label + +- else + .light-well + %h3.nothing_here_message Add first label to your issues or #{link_to 'generate', generate_project_labels_path(@project), method: :post} default set of labels diff --git a/app/views/projects/merge_requests/_filter.html.haml b/app/views/projects/merge_requests/_filter.html.haml new file mode 100644 index 00000000000..4b48306ed05 --- /dev/null +++ b/app/views/projects/merge_requests/_filter.html.haml @@ -0,0 +1,20 @@ += form_tag project_issues_path(@project), method: 'get' do + %fieldset + %ul.nav.nav-pills.nav-stacked + %li{class: ("active" if (params[:f] == 'open' || !params[:f]))} + = link_to project_merge_requests_path(@project, f: 'open', milestone_id: params[:milestone_id]) do + Open + %li{class: ("active" if params[:f] == "closed")} + = link_to project_merge_requests_path(@project, f: "closed", milestone_id: params[:milestone_id]) do + Closed + %li{class: ("active" if params[:f] == 'assigned-to-me')} + = link_to project_merge_requests_path(@project, f: 'assigned-to-me', milestone_id: params[:milestone_id]) do + Assigned To Me + %li{class: ("active" if params[:f] == 'all')} + = link_to project_merge_requests_path(@project, f: 'all', milestone_id: params[:milestone_id]) do + All + + %fieldset + %hr + = link_to "Reset", project_merge_requests_path(@project), class: 'btn pull-right' + diff --git a/app/views/projects/merge_requests/_form.html.haml b/app/views/projects/merge_requests/_form.html.haml new file mode 100644 index 00000000000..b3da15608e4 --- /dev/null +++ b/app/views/projects/merge_requests/_form.html.haml @@ -0,0 +1,79 @@ += form_for [@project, @merge_request], html: { class: "#{controller.action_name}-merge-request form-horizontal" } do |f| + -if @merge_request.errors.any? + .alert.alert-error + %ul + - @merge_request.errors.full_messages.each do |msg| + %li= msg + + %fieldset + %legend 1. Select Branches + + .row + .span5 + .mr_branch_box + %h5.cgray From (Head Branch) + .body + .padded= f.select(:source_branch, @repository.branch_names, { include_blank: "Select branch" }, {class: 'chosen span4'}) + .mr_source_commit + + .span2 + %center= image_tag "merge.png", class: 'mr_direction_tip' + .span5 + .mr_branch_box + %h5.cgray To (Base Branch) + .body + .padded= f.select(:target_branch, @repository.branch_names, { include_blank: "Select branch" }, {class: 'chosen span4'}) + .mr_target_commit + + %fieldset + %legend 2. Fill info + + .ui-box.ui-box-show + .ui-box-head + .clearfix + = f.label :title do + %strong= "Title *" + .input= f.text_field :title, class: "input-xxlarge pad js-gfm-input", maxlength: 255, rows: 5, required: true + .ui-box-body + .clearfix + .left + = f.label :assignee_id do + %i.icon-user + Assign to + .input= f.select(:assignee_id, @project.team.members.sort_by(&:name).map {|p| [ p.name, p.id ] }, { include_blank: "Select user" }, {class: 'chosen span3'}) + .left + = f.label :milestone_id do + %i.icon-time + Milestone + .input= f.select(:milestone_id, @project.milestones.active.all.map {|p| [ p.title, p.id ] }, { include_blank: "Select milestone" }, {class: 'chosen'}) + + .control-group + + .form-actions + - if @merge_request.new_record? + = f.submit 'Submit merge request', class: "btn btn-create" + -else + = f.submit 'Save changes', class: "btn btn-save" + - if @merge_request.new_record? + = link_to project_merge_requests_path(@project), class: "btn btn-cancel" do + Cancel + - else + = link_to project_merge_request_path(@project, @merge_request), class: "btn btn-cancel" do + Cancel + +:javascript + disableButtonIfEmptyField("#merge_request_title", ".btn-save"); + + var source_branch = $("#merge_request_source_branch") + , target_branch = $("#merge_request_target_branch"); + + $.get("#{branch_from_project_merge_requests_path(@project)}", {ref: source_branch.val() }); + $.get("#{branch_to_project_merge_requests_path(@project)}", {ref: target_branch.val() }); + + source_branch.live("change", function() { + $.get("#{branch_from_project_merge_requests_path(@project)}", {ref: $(this).val() }); + }); + + target_branch.live("change", function() { + $.get("#{branch_to_project_merge_requests_path(@project)}", {ref: $(this).val() }); + }); diff --git a/app/views/projects/merge_requests/_head.html.haml b/app/views/projects/merge_requests/_head.html.haml new file mode 100644 index 00000000000..35a86e6511c --- /dev/null +++ b/app/views/projects/merge_requests/_head.html.haml @@ -0,0 +1,5 @@ +.top-tabs + = link_to project_merge_requests_path(@project), class: "tab #{'active' if current_page?(project_merge_requests_path(@project)) }" do + %span + Merge Requests + diff --git a/app/views/projects/merge_requests/_merge_request.html.haml b/app/views/projects/merge_requests/_merge_request.html.haml new file mode 100644 index 00000000000..ffc6b8fda1e --- /dev/null +++ b/app/views/projects/merge_requests/_merge_request.html.haml @@ -0,0 +1,29 @@ +%li{ class: mr_css_classes(merge_request) } + .merge-request-title + %span.light= "##{merge_request.id}" + = link_to_gfm truncate(merge_request.title, length: 80), project_merge_request_path(merge_request.project, merge_request), class: "row_title" + - if merge_request.merged? + %small.pull-right + %i.icon-ok + = "MERGED" + - else + %span.pull-right + %i.icon-angle-right + = merge_request.target_branch + .merge-request-info + - if merge_request.author + authored by #{link_to_member(@project, merge_request.author)} + - if merge_request.votes_count > 0 + = render 'votes/votes_inline', votable: merge_request + - if merge_request.notes.any? + %span + %i.icon-comments + = merge_request.mr_and_commit_notes.count + - if merge_request.milestone_id? + %span + %i.icon-time + = merge_request.milestone.title + + + .pull-right + %small updated #{time_ago_in_words(merge_request.updated_at)} ago diff --git a/app/views/projects/merge_requests/_show.html.haml b/app/views/projects/merge_requests/_show.html.haml new file mode 100644 index 00000000000..987fb4bcc49 --- /dev/null +++ b/app/views/projects/merge_requests/_show.html.haml @@ -0,0 +1,37 @@ +.merge-request + = render "projects/merge_requests/show/mr_title" + = render "projects/merge_requests/show/how_to_merge" + = render "projects/merge_requests/show/mr_box" + = render "projects/merge_requests/show/mr_accept" + - if @project.gitlab_ci? + = render "projects/merge_requests/show/mr_ci" + = render "projects/merge_requests/show/commits" + + - if @commits.present? + %ul.nav.nav-tabs + %li.notes-tab{data: {action: 'notes'}} + = link_to project_merge_request_path(@project, @merge_request) do + %i.icon-comment + Discussion + %li.diffs-tab{data: {action: 'diffs'}} + = link_to diffs_project_merge_request_path(@project, @merge_request) do + %i.icon-list-alt + Diff + + .notes.tab-content.voting_notes#notes{ class: (controller.action_name == 'show') ? "" : "hide" } + = render "projects/notes/notes_with_form" + .diffs.tab-content + = render "projects/merge_requests/show/diffs" if @diffs + .status + +:javascript + var merge_request; + + merge_request = new MergeRequest({ + url_to_automerge_check: "#{automerge_check_project_merge_request_path(@project, @merge_request)}", + check_enable: #{@merge_request.unchecked? ? "true" : "false"}, + url_to_ci_check: "#{ci_status_project_merge_request_path(@project, @merge_request)}", + ci_enable: #{@project.gitlab_ci? ? "true" : "false"}, + current_status: "#{@merge_request.merge_status_name}", + action: "#{controller.action_name}" + }); diff --git a/app/views/projects/merge_requests/automerge.js.haml b/app/views/projects/merge_requests/automerge.js.haml new file mode 100644 index 00000000000..e01ff662e7d --- /dev/null +++ b/app/views/projects/merge_requests/automerge.js.haml @@ -0,0 +1,7 @@ +-if @status + :plain + location.reload(); +-else + :plain + merge_request.alreadyOrCannotBeMerged() + diff --git a/app/views/projects/merge_requests/branch_from.js.haml b/app/views/projects/merge_requests/branch_from.js.haml new file mode 100644 index 00000000000..0637fdcb72e --- /dev/null +++ b/app/views/projects/merge_requests/branch_from.js.haml @@ -0,0 +1,2 @@ +:plain + $(".mr_source_commit").html("#{commit_to_html(@commit)}"); diff --git a/app/views/projects/merge_requests/branch_to.js.haml b/app/views/projects/merge_requests/branch_to.js.haml new file mode 100644 index 00000000000..974100d1ba7 --- /dev/null +++ b/app/views/projects/merge_requests/branch_to.js.haml @@ -0,0 +1,2 @@ +:plain + $(".mr_target_commit").html("#{commit_to_html(@commit)}"); diff --git a/app/views/projects/merge_requests/commits.js.haml b/app/views/projects/merge_requests/commits.js.haml new file mode 100644 index 00000000000..923b1ea032f --- /dev/null +++ b/app/views/projects/merge_requests/commits.js.haml @@ -0,0 +1,4 @@ +:plain + merge_request.$(".commits").html("#{escape_javascript(render(partial: "commits"))}"); + + diff --git a/app/views/projects/merge_requests/diffs.html.haml b/app/views/projects/merge_requests/diffs.html.haml new file mode 100644 index 00000000000..2a5b8b1441e --- /dev/null +++ b/app/views/projects/merge_requests/diffs.html.haml @@ -0,0 +1 @@ += render "show" diff --git a/app/views/projects/merge_requests/diffs.js.haml b/app/views/projects/merge_requests/diffs.js.haml new file mode 100644 index 00000000000..2964f0ec462 --- /dev/null +++ b/app/views/projects/merge_requests/diffs.js.haml @@ -0,0 +1,2 @@ +:plain + merge_request.$(".diffs").html("#{escape_javascript(render(partial: "projects/merge_requests/show/diffs"))}"); diff --git a/app/views/projects/merge_requests/edit.html.haml b/app/views/projects/merge_requests/edit.html.haml new file mode 100644 index 00000000000..eee148994d7 --- /dev/null +++ b/app/views/projects/merge_requests/edit.html.haml @@ -0,0 +1,4 @@ +%h3.page_title + = "Edit merge request #{@merge_request.id}" +%hr += render 'form' diff --git a/app/views/projects/merge_requests/index.html.haml b/app/views/projects/merge_requests/index.html.haml new file mode 100644 index 00000000000..b9e9096e3ae --- /dev/null +++ b/app/views/projects/merge_requests/index.html.haml @@ -0,0 +1,35 @@ +- if can? current_user, :write_merge_request, @project + = link_to new_project_merge_request_path(@project), class: "pull-right btn btn-primary", title: "New Merge Request" do + %i.icon-plus + New Merge Request +%h3.page_title + Merge Requests + +%br + + +.row + .span3 + = render 'filter' + .span9 + .ui-box + .title + = form_tag project_merge_requests_path(@project), id: "merge_requests_search_form", method: :get, class: :left do + = select_tag(:assignee_id, options_from_collection_for_select([unassigned_filter] + @project.users.all, "id", "name", params[:assignee_id]), prompt: "Assignee") + = select_tag(:milestone_id, options_from_collection_for_select([unassigned_filter] + @project.milestones.order("id desc").all, "id", "title", params[:milestone_id]), prompt: "Milestone") + = hidden_field_tag :f, params[:f] + .clearfix + + %ul.well-list.mr-list + = render @merge_requests + - if @merge_requests.blank? + %li + %h4.nothing_here_message Nothing to show here + - if @merge_requests.present? + .pull-right + %span.cgray.pull-right #{@merge_requests.total_count} merge requests for this filter + + = paginate @merge_requests, theme: "gitlab" + +:javascript + $(merge_requestsPage); diff --git a/app/views/projects/merge_requests/invalid.html.haml b/app/views/projects/merge_requests/invalid.html.haml new file mode 100644 index 00000000000..c962811a3e4 --- /dev/null +++ b/app/views/projects/merge_requests/invalid.html.haml @@ -0,0 +1,17 @@ +.merge-request + = render "projects/merge_requests/show/mr_title" + = render "projects/merge_requests/show/mr_box" + + .alert.alert-error + %h5 + %i.icon-exclamation-sign + We cannot find + %span.label-branch= @merge_request.source_branch + or + %span.label-branch= @merge_request.target_branch + branches in the repository. + %p + Maybe it was removed or never pushed. + %p + Please close Merge Request or change branches with existing one + diff --git a/app/views/projects/merge_requests/new.html.haml b/app/views/projects/merge_requests/new.html.haml new file mode 100644 index 00000000000..594089995ea --- /dev/null +++ b/app/views/projects/merge_requests/new.html.haml @@ -0,0 +1,3 @@ +%h3.page_title New Merge Request +%hr += render 'form' diff --git a/app/views/projects/merge_requests/show.html.haml b/app/views/projects/merge_requests/show.html.haml new file mode 100644 index 00000000000..2a5b8b1441e --- /dev/null +++ b/app/views/projects/merge_requests/show.html.haml @@ -0,0 +1 @@ += render "show" diff --git a/app/views/projects/merge_requests/show.js.haml b/app/views/projects/merge_requests/show.js.haml new file mode 100644 index 00000000000..2ce6eb63290 --- /dev/null +++ b/app/views/projects/merge_requests/show.js.haml @@ -0,0 +1,2 @@ +:plain + merge_request.$(".notes").html("#{escape_javascript(render "notes/notes_with_form")}"); diff --git a/app/views/projects/merge_requests/show/_commits.html.haml b/app/views/projects/merge_requests/show/_commits.html.haml new file mode 100644 index 00000000000..8630f02d5d9 --- /dev/null +++ b/app/views/projects/merge_requests/show/_commits.html.haml @@ -0,0 +1,30 @@ +- if @commits.present? + .ui-box + %h5.title + %i.icon-list + Commits (#{@commits.count}) + .commits + - if @commits.count > 8 + %ul.first-commits.well-list + - @commits.first(8).each do |commit| + = render "projects/commits/commit", commit: commit + %li.bottom + 8 of #{@commits.count} commits displayed. + %strong + %a.show-all-commits Click here to show all + %ul.all-commits.hide.well-list + - @commits.each do |commit| + = render "projects/commits/commit", commit: commit + + - else + %ul.well-list + - @commits.each do |commit| + = render "projects/commits/commit", commit: commit + +- else + %h4.nothing_here_message + Nothing to merge from + %span.label-branch #{@merge_request.source_branch} + to + %span.label-branch #{@merge_request.target_branch} + %br diff --git a/app/views/projects/merge_requests/show/_diffs.html.haml b/app/views/projects/merge_requests/show/_diffs.html.haml new file mode 100644 index 00000000000..1d52e824fad --- /dev/null +++ b/app/views/projects/merge_requests/show/_diffs.html.haml @@ -0,0 +1,10 @@ +- if @merge_request.valid_diffs? + = render "projects/commits/diffs", diffs: @diffs +- elsif @merge_request.broken_diffs? + %h4.nothing_here_message + Can't load diff. + You can + = link_to "download it", project_merge_request_path(@project, @merge_request, format: :diff), class: "vlink" + instead. +- else + %h4.nothing_here_message Nothing to merge diff --git a/app/views/projects/merge_requests/show/_how_to_merge.html.haml b/app/views/projects/merge_requests/show/_how_to_merge.html.haml new file mode 100644 index 00000000000..7f1e33418de --- /dev/null +++ b/app/views/projects/merge_requests/show/_how_to_merge.html.haml @@ -0,0 +1,19 @@ +%div#modal_merge_info.modal.hide + .modal-header + %a.close{href: "#"} × + %h3 How To Merge + .modal-body + %p + %strong Step 1. + Checkout target branch and get recent objects from GitLab + %pre.dark + :preserve + git checkout #{@merge_request.target_branch} + git fetch origin + %p + %strong Step 2. + Merge source branch into target branch and push changes to GitLab + %pre.dark + :preserve + git merge origin/#{@merge_request.source_branch} + git push origin #{@merge_request.target_branch} diff --git a/app/views/projects/merge_requests/show/_mr_accept.html.haml b/app/views/projects/merge_requests/show/_mr_accept.html.haml new file mode 100644 index 00000000000..ac97f6327c0 --- /dev/null +++ b/app/views/projects/merge_requests/show/_mr_accept.html.haml @@ -0,0 +1,52 @@ +- unless @allowed_to_merge + .alert + %strong You don't have enough permissions to merge this MR + + +- if @show_merge_controls + .automerge_widget.can_be_merged{style: "display:none"} + .alert.alert-success + %span + = form_for [:automerge, @project, @merge_request], remote: true, method: :get do |f| + %p + You can accept this request automatically. + If you still want to do it manually - + %strong= link_to "click here", "#", class: "how_to_merge_link vlink", title: "How To Merge" + for instructions + .accept_group + = f.submit "Accept Merge Request", class: "btn success accept_merge_request" + - unless @project.root_ref? @merge_request.source_branch + .remove_branch_holder + = label_tag :should_remove_source_branch, class: "checkbox" do + = check_box_tag :should_remove_source_branch + Remove source-branch + .clearfix + + + .automerge_widget.no_satellite{style: "display:none"} + .alert.alert-error + %span + %strong This repository does not have satellite. Ask administrator to fix this issue + + .automerge_widget.cannot_be_merged{style: "display:none"} + .alert.alert-disabled + %span + = link_to "Show how to merge", "#", class: "how_to_merge_link btn btn-small padded", title: "How To Merge" +   + %strong This request can't be merged with GitLab. You should do it manually + + .automerge_widget.unchecked + .alert + %strong + %i.icon-refresh + Checking for ability to automatically merge… + + .automerge_widget.already_cannot_be_merged{style: "display:none"} + .alert.alert-info + %strong This merge request already can not be merged. Try to reload page. + + .merge-in-progress.hide + %span.cgray + %i.icon-refresh.icon-spin +   + Merge is in progress. Please wait. Page will be automatically reloaded.   diff --git a/app/views/projects/merge_requests/show/_mr_box.html.haml b/app/views/projects/merge_requests/show/_mr_box.html.haml new file mode 100644 index 00000000000..594f4061c23 --- /dev/null +++ b/app/views/projects/merge_requests/show/_mr_box.html.haml @@ -0,0 +1,36 @@ +.ui-box.ui-box-show + .ui-box-head + %h4.box-title + = gfm escape_once(@merge_request.title) + - if @merge_request.merged? + .success.status_info + %i.icon-ok + Merged + - elsif @merge_request.closed? + .error.status_info Closed + + .ui-box-body + %div + %cite.cgray + Created at #{@merge_request.created_at.stamp("Aug 21, 2011")} by #{link_to_member(@project, @merge_request.author)} + - if @merge_request.assignee + \, currently assigned to #{link_to_member(@project, @merge_request.assignee)} + - if @merge_request.milestone + - milestone = @merge_request.milestone + %cite.cgray and attached to milestone + %strong= link_to_gfm truncate(milestone.title, length: 20), project_milestone_path(milestone.project, milestone) + + + - if @merge_request.closed? + .ui-box-bottom.alert-error + %span + %i.icon-remove + Closed by #{link_to_member(@project, @merge_request.closed_event.author)} + %small #{time_ago_in_words(@merge_request.closed_event.created_at)} ago. + - if @merge_request.merged? + .ui-box-bottom.alert-success + %span + %i.icon-ok + Merged by #{link_to_member(@project, @merge_request.merge_event.author)} + #{time_ago_in_words(@merge_request.merge_event.created_at)} ago. + diff --git a/app/views/projects/merge_requests/show/_mr_ci.html.haml b/app/views/projects/merge_requests/show/_mr_ci.html.haml new file mode 100644 index 00000000000..9b15c4526e9 --- /dev/null +++ b/app/views/projects/merge_requests/show/_mr_ci.html.haml @@ -0,0 +1,35 @@ +- if @commits.any? + .ci_widget.ci-success{style: "display:none"} + .alert.alert-success + %i.icon-ok + %strong CI build passed + for #{@merge_request.last_commit_short_sha}. + = link_to "Build page", ci_build_details_path(@merge_request) + + + .ci_widget.ci-failed{style: "display:none"} + .alert.alert-error + %i.icon-remove + %strong CI build failed + for #{@merge_request.last_commit_short_sha}. + = link_to "Build page", ci_build_details_path(@merge_request) + + - [:running, :pending].each do |status| + .ci_widget{class: "ci-#{status}", style: "display:none"} + .alert + %i.icon-time + %strong CI build #{status} + for #{@merge_request.last_commit_short_sha}. + = link_to "Build page", ci_build_details_path(@merge_request) + + .ci_widget + .alert + %strong + %i.icon-refresh + Checking for CI status for #{@merge_request.last_commit_short_sha} + + .ci_widget.ci-error{style: "display:none"} + .alert.alert-error + %i.icon-remove + %strong Cannot connect to CI server. Please check your setting + diff --git a/app/views/projects/merge_requests/show/_mr_title.html.haml b/app/views/projects/merge_requests/show/_mr_title.html.haml new file mode 100644 index 00000000000..24285c272a8 --- /dev/null +++ b/app/views/projects/merge_requests/show/_mr_title.html.haml @@ -0,0 +1,31 @@ +%h3.page_title + = "Merge Request ##{@merge_request.id}:" +   + %span.label-branch= @merge_request.source_branch + → + %span.label-branch= @merge_request.target_branch + + %span.pull-right + - if can?(current_user, :modify_merge_request, @merge_request) + - if @merge_request.opened? + .left.btn-group + %a.btn.grouped.dropdown-toggle{ data: {toggle: :dropdown} } + %i.icon-download-alt + Download as + %span.caret + %ul.dropdown-menu + %li= link_to "Email Patches", project_merge_request_path(@project, @merge_request, format: :patch) + %li= link_to "Plain Diff", project_merge_request_path(@project, @merge_request, format: :diff) + + = link_to 'Close', project_merge_request_path(@project, @merge_request, merge_request: {state_event: :close }), method: :put, class: "btn grouped btn-close", title: "Close merge request" + + = link_to edit_project_merge_request_path(@project, @merge_request), class: "btn grouped" do + %i.icon-edit + Edit + +.pull-right + .span3#votes= render 'votes/votes_block', votable: @merge_request + +.back_link + = link_to project_merge_requests_path(@project) do + ← To merge requests diff --git a/app/views/projects/milestones/_form.html.haml b/app/views/projects/milestones/_form.html.haml new file mode 100644 index 00000000000..50e3e71b2c3 --- /dev/null +++ b/app/views/projects/milestones/_form.html.haml @@ -0,0 +1,47 @@ +%h3.page_title= @milestone.new_record? ? "New Milestone" : "Edit Milestone ##{@milestone.id}" +.back_link + = link_to project_milestones_path(@project) do + ← To milestones + +%hr + += form_for [@project, @milestone], html: {class: "new_milestone form-horizontal"} do |f| + -if @milestone.errors.any? + .alert.alert-error + %ul + - @milestone.errors.full_messages.each do |msg| + %li= msg + .row + .span6 + .control-group + = f.label :title, "Title", class: "control-label" + .controls + = f.text_field :title, maxlength: 255, class: "input-xlarge" + %p.hint Required + .control-group + = f.label :description, "Description", class: "control-label" + .controls + = f.text_area :description, maxlength: 2000, class: "input-xlarge", rows: 10 + %p.hint Milestones are parsed with #{link_to "GitLab Flavored Markdown", help_markdown_path, target: '_blank'}. + .span6 + .control-group + = f.label :due_date, "Due Date", class: "control-label" + .input= f.hidden_field :due_date + .controls + .datepicker + + .form-actions + - if @milestone.new_record? + = f.submit 'Create milestone', class: "btn-save btn" + = link_to "Cancel", project_milestones_path(@project), class: "btn btn-cancel" + -else + = f.submit 'Save changes', class: "btn-save btn" + = link_to "Cancel", project_milestone_path(@project, @milestone), class: "btn btn-cancel" + + +:javascript + disableButtonIfEmptyField("#milestone_title", ".btn-save"); + $( ".datepicker" ).datepicker({ + dateFormat: "yy-mm-dd", + onSelect: function(dateText, inst) { $("#milestone_due_date").val(dateText) } + }).datepicker("setDate", $.datepicker.parseDate('yy-mm-dd', $('#milestone_due_date').val())); diff --git a/app/views/projects/milestones/_issues.html.haml b/app/views/projects/milestones/_issues.html.haml new file mode 100644 index 00000000000..eccf3ddbfa5 --- /dev/null +++ b/app/views/projects/milestones/_issues.html.haml @@ -0,0 +1,11 @@ +.ui-box + %h5.title= title + %ul.well-list + - issues.each do |issue| + %li + = link_to [@project, issue] do + %span.badge{class: issue.closed? ? 'badge-important' : 'badge-info'} ##{issue.id} + = link_to_gfm truncate(issue.title, length: 60), [@project, issue] + - if issue.assignee + .pull-right + = image_tag gravatar_icon(issue.assignee.email, 16), class: "avatar s16" diff --git a/app/views/projects/milestones/_merge_request.html.haml b/app/views/projects/milestones/_merge_request.html.haml new file mode 100644 index 00000000000..7f815894069 --- /dev/null +++ b/app/views/projects/milestones/_merge_request.html.haml @@ -0,0 +1,5 @@ +%li + = link_to [@project, merge_request] do + %span.badge.badge-info ##{merge_request.id} + – + = link_to_gfm truncate(merge_request.title, length: 60), [@project, merge_request] diff --git a/app/views/projects/milestones/_milestone.html.haml b/app/views/projects/milestones/_milestone.html.haml new file mode 100644 index 00000000000..894fa6c1133 --- /dev/null +++ b/app/views/projects/milestones/_milestone.html.haml @@ -0,0 +1,28 @@ +%li{class: "milestone milestone-#{milestone.closed? ? 'closed' : 'open'}", id: dom_id(milestone) } + .pull-right + - if can?(current_user, :admin_milestone, milestone.project) and milestone.active? + = link_to edit_project_milestone_path(milestone.project, milestone), class: "btn btn-small edit-milestone-link grouped" do + %i.icon-edit + Edit + - if milestone.can_be_closed? + = link_to 'Close', project_milestone_path(@project, milestone, milestone: {state_event: :close }), method: :put, remote: true, class: "btn btn-small btn-remove" + %h4 + = link_to_gfm truncate(milestone.title, length: 100), project_milestone_path(milestone.project, milestone) + - if milestone.expired? and not milestone.closed? + %span.cred (Expired) + %small + = milestone.expires_at + - if milestone.is_empty? + %span.muted Empty + - else + %div + %div + = link_to project_issues_path(milestone.project, milestone_id: milestone.id) do + = pluralize milestone.issues.count, 'Issue' +   + = link_to project_merge_requests_path(milestone.project, milestone_id: milestone.id) do + = pluralize milestone.merge_requests.count, 'Merge Request' +   + %span.light #{milestone.percent_complete}% complete + .progress.progress-info + .bar{style: "width: #{milestone.percent_complete}%;"} diff --git a/app/views/projects/milestones/edit.html.haml b/app/views/projects/milestones/edit.html.haml new file mode 100644 index 00000000000..b1bc3ba0eba --- /dev/null +++ b/app/views/projects/milestones/edit.html.haml @@ -0,0 +1 @@ += render "form" diff --git a/app/views/projects/milestones/index.html.haml b/app/views/projects/milestones/index.html.haml new file mode 100644 index 00000000000..1bc359398ab --- /dev/null +++ b/app/views/projects/milestones/index.html.haml @@ -0,0 +1,32 @@ += render "projects/issues/head" +.milestones_content + %h3.page_title + Milestones + - if can? current_user, :admin_milestone, @project + = link_to new_project_milestone_path(@project), class: "pull-right btn btn-primary", title: "New Milestone" do + %i.icon-plus + New Milestone + %br + + .row + .span3 + %ul.nav.nav-pills.nav-stacked + %li{class: ("active" if (params[:f] == "active" || !params[:f]))} + = link_to project_milestones_path(@project, f: "active") do + Active + %li{class: ("active" if params[:f] == "closed")} + = link_to project_milestones_path(@project, f: "closed") do + Closed + %li{class: ("active" if params[:f] == "all")} + = link_to project_milestones_path(@project, f: "all") do + All + .span9 + .ui-box + %ul.well-list + = render @milestones + + - if @milestones.blank? + %li + %h3.nothing_here_message Nothing to show here + + = paginate @milestones, theme: "gitlab" diff --git a/app/views/projects/milestones/new.html.haml b/app/views/projects/milestones/new.html.haml new file mode 100644 index 00000000000..b1bc3ba0eba --- /dev/null +++ b/app/views/projects/milestones/new.html.haml @@ -0,0 +1 @@ += render "form" diff --git a/app/views/projects/milestones/show.html.haml b/app/views/projects/milestones/show.html.haml new file mode 100644 index 00000000000..d16de0da390 --- /dev/null +++ b/app/views/projects/milestones/show.html.haml @@ -0,0 +1,106 @@ += render "projects/issues/head" +.row + .span6 + %h3.page_title + Milestone ##{@milestone.id} + %small + = @milestone.expires_at + .back_link + = link_to project_milestones_path(@project) do + ← To milestones list + .span6 + .pull-right + - unless @milestone.closed? + = link_to new_project_issue_path(@project, issue: { milestone_id: @milestone.id }), class: "btn btn-small grouped", title: "New Issue" do + %i.icon-plus + New Issue + = link_to 'Browse Issues', project_issues_path(@milestone.project, milestone_id: @milestone.id), class: "btn edit-milestone-link small grouped" + - if can?(current_user, :admin_milestone, @project) + = link_to edit_project_milestone_path(@project, @milestone), class: "btn btn-small grouped" do + %i.icon-edit + Edit + + + +- if @milestone.can_be_closed? + %hr + %p + %span All issues for this milestone are closed. You may close milestone now. + = link_to 'Close Milestone', project_milestone_path(@project, @milestone, milestone: {state_event: :close }), method: :put, class: "btn btn-small btn-remove" + +.ui-box.ui-box-show + .ui-box-head + %h4.box-title + - if @milestone.closed? + .error.status_info Closed + - elsif @milestone.expired? + .error.status_info Expired + + = gfm escape_once(@milestone.title) + + .ui-box-body + %p + Progress: + #{@milestone.closed_items_count} closed + – + #{@milestone.open_items_count} open + %span.pull-right= @milestone.expires_at + .progress.progress-info + .bar{style: "width: #{@milestone.percent_complete}%;"} + + + - if @milestone.description.present? + .ui-box-bottom + = preserve do + = markdown @milestone.description + + +%ul.nav.nav-tabs + %li.active + = link_to '#tab-issues', 'data-toggle' => 'tab' do + Issues + %span.badge= @issues.count + %li + = link_to '#tab-merge-requests', 'data-toggle' => 'tab' do + Merge Requests + %span.badge= @merge_requests.count + %li + = link_to '#tab-participants', 'data-toggle' => 'tab' do + Participants + %span.badge= @users.count + + +.tab-content + .tab-pane.active#tab-issues + .row + .span4 + = render('issues', title: 'Unstarted Issues (open and unassigned)', issues: @issues.opened.unassigned) + .span4 + = render('issues', title: 'Ongoing Issues (open and assigned)', issues: @issues.opened.assigned) + .span4 + = render('issues', title: 'Completed Issues (closed)', issues: @issues.closed) + + .tab-pane#tab-merge-requests + .row + .span6 + .ui-box + %h5.title Open + %ul.well-list + - @merge_requests.opened.each do |merge_request| + = render 'merge_request', merge_request: merge_request + .span6 + .ui-box + %h5.title Closed + %ul.well-list + - @merge_requests.closed.each do |merge_request| + = render 'merge_request', merge_request: merge_request + + .tab-pane#tab-participants + %ul.bordered-list + - @users.each do |user| + %li + = link_to user, title: user.name, class: "dark" do + = image_tag gravatar_icon(user.email, 32), class: "avatar s32" + %strong= truncate(user.name, lenght: 40) + %br + %small.cgray= user.username diff --git a/app/views/projects/milestones/update.js.haml b/app/views/projects/milestones/update.js.haml new file mode 100644 index 00000000000..3ff84915e97 --- /dev/null +++ b/app/views/projects/milestones/update.js.haml @@ -0,0 +1,2 @@ +:plain + $('##{dom_id(@milestone)}').fadeOut(); diff --git a/app/views/projects/network/_head.html.haml b/app/views/projects/network/_head.html.haml new file mode 100644 index 00000000000..62ab8b049ac --- /dev/null +++ b/app/views/projects/network/_head.html.haml @@ -0,0 +1,26 @@ +%h3.page_title Project Network Graph +%hr + +.clearfix + .pull-left + = render partial: 'shared/ref_switcher', locals: {destination: 'graph'} + .pull-left + = form_tag project_network_path(@project, @id), method: :get do |f| + .control-group + = label_tag :filter_ref, "Show only selected ref", class: 'control-label light' + .controls + = check_box_tag :filter_ref, 1, @options[:filter_ref] + - @options.each do |key, value| + = hidden_field_tag(key, value, id: nil) unless key == "filter_ref" + + .search.pull-right + = form_tag project_network_path(@project, @id), method: :get do |f| + .control-group + = label_tag :search , "Looking for commit:", class: 'control-label light' + .controls + = text_field_tag :q, @options[:q], placeholder: "Input SHA", class: "search-input xlarge" + = button_tag type: 'submit', class: 'btn vtop' do + %i.icon-search + - @options.each do |key, value| + = hidden_field_tag(key, value, id: nil) unless key == "q" + diff --git a/app/views/projects/network/show.html.haml b/app/views/projects/network/show.html.haml new file mode 100644 index 00000000000..a480ceaf995 --- /dev/null +++ b/app/views/projects/network/show.html.haml @@ -0,0 +1,18 @@ += render "head" +.graph_holder + %h4 + %small You can move around the graph by using the arrow keys. + #holder.graph + .loading.loading-gray + +:javascript + var branch_graph; + $("#filter_ref").click(function() { + $(this).closest('form').submit(); + }); + branch_graph = new BranchGraph($("#holder"), { + url: '#{project_network_path(@project, @ref, @options.merge(format: :json))}', + commit_url: '#{project_commit_path(@project, 'ae45ca32').gsub("ae45ca32", "%s")}', + ref: '#{@ref}', + commit_id: '#{@commit.id}' + }); diff --git a/app/views/projects/network/show.json.erb b/app/views/projects/network/show.json.erb new file mode 100644 index 00000000000..9a62cdb3dc9 --- /dev/null +++ b/app/views/projects/network/show.json.erb @@ -0,0 +1,23 @@ +<% self.formats = ["html"] %> + +<%= raw( + { + days: @graph.days.compact.map { |d| [d.day, d.strftime("%b")] }, + commits: @graph.commits.map do |c| + { + parents: parents_zip_spaces(c.parents(@graph.map), c.parent_spaces), + author: { + name: c.author_name, + email: c.author_email, + icon: gravatar_icon(c.author_email, 20) + }, + time: c.time, + space: c.spaces.first, + refs: get_refs(c), + id: c.sha, + date: c.date, + message: c.message, + } + end + }.to_json +) %> diff --git a/app/views/projects/notes/_diff_note_link.html.haml b/app/views/projects/notes/_diff_note_link.html.haml new file mode 100644 index 00000000000..377c926a204 --- /dev/null +++ b/app/views/projects/notes/_diff_note_link.html.haml @@ -0,0 +1,10 @@ +- note = @project.notes.new(@comments_target.merge({ line_code: line_code })) += link_to "", + "javascript:;", + class: "add-diff-note js-add-diff-note-button", + data: { noteable_type: note.noteable_type, + noteable_id: note.noteable_id, + commit_id: note.commit_id, + line_code: note.line_code, + discussion_id: note.discussion_id }, + title: "Add a comment to this line" diff --git a/app/views/projects/notes/_diff_notes_with_reply.html.haml b/app/views/projects/notes/_diff_notes_with_reply.html.haml new file mode 100644 index 00000000000..5a1a945f399 --- /dev/null +++ b/app/views/projects/notes/_diff_notes_with_reply.html.haml @@ -0,0 +1,11 @@ +- note = notes.first # example note +%tr.notes_holder + %td.notes_line{ colspan: 2 } + %span.btn.disabled + %i.icon-comment + = notes.count + %td.notes_content + %ul.notes{ rel: note.discussion_id } + = render notes + + = render "projects/notes/discussion_reply_button", note: note diff --git a/app/views/projects/notes/_discussion.html.haml b/app/views/projects/notes/_discussion.html.haml new file mode 100644 index 00000000000..14d81bbb5ce --- /dev/null +++ b/app/views/projects/notes/_discussion.html.haml @@ -0,0 +1,63 @@ +- note = discussion_notes.first +.discussion.js-details-container.js-toggler-container.open{ class: note.discussion_id } + .discussion-header + .discussion-actions + = link_to "javascript:;", class: "js-details-target turn-on js-toggler-target" do + %i.icon-eye-close + Hide discussion + = link_to "javascript:;", class: "js-details-target turn-off js-toggler-target" do + %i.icon-eye-open + Show discussion + = image_tag gravatar_icon(note.author_email), class: "avatar s32" + %div + = link_to_member(@project, note.author, avatar: false) + - if note.for_merge_request? + - if note.diff + started a discussion on this merge request diff + = link_to_merge_request_diff_line_note(note) + - else + started + %strong + %i.icon-remove + outdated + discussion on this merge request diff + - elsif note.for_commit? + started a discussion on commit + #{link_to note.noteable.short_id, project_commit_path(@project, note.noteable)} + = link_to_commit_diff_line_note(note) if note.for_diff_line? + - else + %cite.cgray started a discussion + %div + - last_note = discussion_notes.last + last updated by + = link_to_member(@project, last_note.author, avatar: false) + %span.discussion-last-update + = time_ago_in_words(last_note.updated_at) + ago + .discussion-body + - if note.for_diff_line? + - if note.diff + .content + .file= render "projects/notes/discussion_diff", discussion_notes: discussion_notes, note: note + - else + = link_to 'show outdated discussion', '#', class: 'js-show-outdated-discussion' + %div.hide.outdated-discussion + .content + .notes{ rel: discussion_notes.first.discussion_id } + = render discussion_notes + + + - else + .content + .notes{ rel: discussion_notes.first.discussion_id } + = render discussion_notes + = render "projects/notes/discussion_reply_button", note: discussion_notes.first + + -# will be shown when the other one is hidden + .discussion-hidden.content.hide + .note + %em Hidden discussion. + = link_to "javascript:;", class: "js-details-target js-toggler-target" do + %i.icon-eye-open + Show + diff --git a/app/views/projects/notes/_discussion_diff.html.haml b/app/views/projects/notes/_discussion_diff.html.haml new file mode 100644 index 00000000000..c3f41a1b6b5 --- /dev/null +++ b/app/views/projects/notes/_discussion_diff.html.haml @@ -0,0 +1,24 @@ +- diff = note.diff +.header + - if diff.deleted_file + %span= diff.old_path + - else + %span= diff.new_path + - if diff.a_mode && diff.b_mode && diff.a_mode != diff.b_mode + %span.file-mode= "#{diff.a_mode} → #{diff.b_mode}" + %br/ +.content + %table + - each_diff_line_near(diff, note.diff_file_index, note.line_code) do |line, type, line_code, line_new, line_old| + %tr.line_holder{ id: line_code } + - if type == "match" + %td.old_line= "..." + %td.new_line= "..." + %td.line_content.matched= line + - else + %td.old_line= raw(type == "new" ? " " : line_old) + %td.new_line= raw(type == "old" ? " " : line_new) + %td.line_content{class: "noteable_line #{type} #{line_code}", "line_code" => line_code}= raw "#{line}  " + + - if line_code == note.line_code + = render "projects/notes/diff_notes_with_reply", notes: discussion_notes diff --git a/app/views/projects/notes/_discussion_reply_button.html.haml b/app/views/projects/notes/_discussion_reply_button.html.haml new file mode 100644 index 00000000000..d1c5ccc29db --- /dev/null +++ b/app/views/projects/notes/_discussion_reply_button.html.haml @@ -0,0 +1,10 @@ += link_to "javascript:;", + class: "btn reply-btn js-discussion-reply-button", + data: { noteable_type: note.noteable_type, + noteable_id: note.noteable_id, + commit_id: note.commit_id, + line_code: note.line_code, + discussion_id: note.discussion_id }, + title: "Add a reply" do + %i.icon-comment + Reply diff --git a/app/views/projects/notes/_form.html.haml b/app/views/projects/notes/_form.html.haml new file mode 100644 index 00000000000..7add2921830 --- /dev/null +++ b/app/views/projects/notes/_form.html.haml @@ -0,0 +1,37 @@ += form_for [@project, @note], remote: true, html: { multipart: true, id: nil, class: "new_note js-new-note-form common-note-form" } do |f| + + = note_target_fields + = f.hidden_field :commit_id + = f.hidden_field :line_code + = f.hidden_field :noteable_id + = f.hidden_field :noteable_type + + .note_text_and_preview.js-toggler-container + %a.js-note-preview-button.js-toggler-target.turn-off{ href: "javascript:;", title: "Preview", data: {url: preview_project_notes_path(@project)} } + %i.icon-eye-open + %a.js-note-edit-button.js-toggler-target.turn-off{ href: "javascript:;", title: "Edit" } + %i.icon-edit + + = f.text_area :note, size: 255, class: 'note_text js-note-text js-gfm-input turn-on' + .note_preview.js-note-preview.turn-off + + .hint + .pull-right Comments are parsed with #{link_to "GitLab Flavored Markdown", help_markdown_path, target: '_blank'}. + .clearfix + + .note-form-actions + .buttons + = f.submit 'Add Comment', class: "btn comment-btn grouped js-comment-button" + = yield(:note_actions) + + %a.btn.grouped.js-close-discussion-note-form Cancel + + .note-form-option + %a.choose-btn.btn.btn-small.js-choose-note-attachment-button + %i.icon-paper-clip + %span Choose File ... +   + %span.file_name.js-attachment-filename File name... + = f.file_field :attachment, class: "js-note-attachment-input hide" + + .clearfix diff --git a/app/views/projects/notes/_form_errors.html.haml b/app/views/projects/notes/_form_errors.html.haml new file mode 100644 index 00000000000..0851536f0da --- /dev/null +++ b/app/views/projects/notes/_form_errors.html.haml @@ -0,0 +1,3 @@ +.error_message.js-errors + - note.errors.full_messages.each do |msg| + %div= msg diff --git a/app/views/projects/notes/_note.html.haml b/app/views/projects/notes/_note.html.haml new file mode 100644 index 00000000000..6a1159bc8f0 --- /dev/null +++ b/app/views/projects/notes/_note.html.haml @@ -0,0 +1,37 @@ +%li{ id: dom_id(note), class: dom_class(note), data: { discussion: note.discussion_id } } + .note-header + .note-actions + = link_to "##{dom_id(note)}", name: dom_id(note) do + %i.icon-link + Link here +   + - if(note.author_id == current_user.id) || can?(current_user, :admin_note, @project) + = link_to project_note_path(@project, note), title: "Remove comment", method: :delete, confirm: 'Are you sure you want to remove comment?', remote: true, class: "danger js-note-delete" do + %i.icon-trash.cred + = image_tag gravatar_icon(note.author_email), class: "avatar s32" + = link_to_member(@project, note.author, avatar: false) + %span.note-last-update + = time_ago_in_words(note.updated_at) + ago + + - if note.upvote? + %span.vote.upvote.label.label-success + %i.icon-thumbs-up + \+1 + - if note.downvote? + %span.vote.downvote.label.label-error + %i.icon-thumbs-down + \-1 + + + .note-body + = preserve do + = markdown(note.note) + - if note.attachment.url + - if note.attachment.image? + = image_tag note.attachment.url, class: 'note-image-attach' + .attachment.pull-right + = link_to note.attachment.secure_url, target: "_blank" do + %i.icon-paper-clip + = note.attachment_identifier + .clear diff --git a/app/views/projects/notes/_notes.html.haml b/app/views/projects/notes/_notes.html.haml new file mode 100644 index 00000000000..ac8901fe704 --- /dev/null +++ b/app/views/projects/notes/_notes.html.haml @@ -0,0 +1,11 @@ +- if @discussions.present? + - @discussions.each do |discussion_notes| + - note = discussion_notes.first + - if note_for_main_target?(note) + = render discussion_notes + - else + = render 'discussion', discussion_notes: discussion_notes +- else + - @notes.each do |note| + - next unless note.author + = render note diff --git a/app/views/projects/notes/_notes_with_form.html.haml b/app/views/projects/notes/_notes_with_form.html.haml new file mode 100644 index 00000000000..ac28c7432ef --- /dev/null +++ b/app/views/projects/notes/_notes_with_form.html.haml @@ -0,0 +1,9 @@ +%ul#notes-list.notes +.js-notes-busy + +.js-main-target-form +- if can? current_user, :write_note, @project + = render "projects/notes/form" + +:javascript + NoteList.init("#{@target_id}", "#{@target_type}", "#{project_notes_path(@project)}"); diff --git a/app/views/projects/notes/create.js.haml b/app/views/projects/notes/create.js.haml new file mode 100644 index 00000000000..c113b3482ec --- /dev/null +++ b/app/views/projects/notes/create.js.haml @@ -0,0 +1,18 @@ +- if @note.valid? + var noteHtml = "#{escape_javascript(render @note)}"; + + - if note_for_main_target?(@note) + NoteList.appendNewNote(#{@note.id}, noteHtml); + - else + :plain + var firstDiscussionNoteHtml = "#{escape_javascript(render "projects/notes/diff_notes_with_reply", notes: [@note])}"; + NoteList.appendNewDiscussionNote("#{@note.discussion_id}", + firstDiscussionNoteHtml, + noteHtml); + +- else + var errorsHtml = "#{escape_javascript(render 'projects/notes/form_errors', note: @note)}"; + - if note_for_main_target?(@note) + NoteList.errorsOnForm(errorsHtml); + - else + NoteList.errorsOnForm(errorsHtml, "#{@note.discussion_id}"); diff --git a/app/views/projects/notes/index.js.haml b/app/views/projects/notes/index.js.haml new file mode 100644 index 00000000000..6c4ed203497 --- /dev/null +++ b/app/views/projects/notes/index.js.haml @@ -0,0 +1,4 @@ +- unless @notes.blank? + var notesHtml = "#{escape_javascript(render 'projects/notes/notes')}"; + - new_note_ids = @notes.map(&:id) + NoteList.setContent(#{new_note_ids}, notesHtml); diff --git a/app/views/projects/protected_branches/index.html.haml b/app/views/projects/protected_branches/index.html.haml new file mode 100644 index 00000000000..f741f2f0495 --- /dev/null +++ b/app/views/projects/protected_branches/index.html.haml @@ -0,0 +1,54 @@ += render "projects/commits/head" +.row + .span3 + = render "projects/repositories/filter" + .span9 + .alert + %p Protected branches designed to prevent push for all except #{link_to "masters", help_permissions_path, class: "vlink"}. + %p This ability allows: + %ul + %li keep stable branches secured + %li forced code review before merge to protected branches + %p Read more about project permissions #{link_to "here", help_permissions_path, class: "vlink"} + + - if can? current_user, :admin_project, @project + = form_for [@project, @protected_branch] do |f| + -if @protected_branch.errors.any? + .alert.alert-error + %ul + - @protected_branch.errors.full_messages.each do |msg| + %li= msg + + .entry.clearfix + = f.label :name, "Branch" + .span3 + = f.select(:name, @project.open_branches.map { |br| [br.name, br.name] } , {include_blank: "Select branch"}, {class: "chosen span3"}) +   + = f.submit 'Protect', class: "btn-primary btn" + + - unless @branches.empty? + %table + %thead + %tr + %th Name + %th Last commit + %th + %tbody + - @branches.each do |branch| + %tr + %td + = link_to project_commits_path(@project, branch.name) do + %strong= branch.name + - if @project.root_ref?(branch.name) + %span.label default + %td + - if branch.commit + = link_to project_commit_path(@project, branch.commit.id) do + = truncate branch.commit.id.to_s, length: 10 + = time_ago_in_words(branch.commit.committed_date) + ago + - else + (branch was removed from repository) + %td + - if can? current_user, :admin_project, @project + = link_to 'Unprotect', [@project, branch], confirm: 'Branch will be writable for developers. Are you sure?', method: :delete, class: "btn btn-remove btn-small" diff --git a/app/views/projects/refs/logs_tree.js.haml b/app/views/projects/refs/logs_tree.js.haml new file mode 100644 index 00000000000..1bea286a879 --- /dev/null +++ b/app/views/projects/refs/logs_tree.js.haml @@ -0,0 +1,8 @@ +- @logs.each do |content_data| + - file_name = content_data[:file_name] + - commit = content_data[:commit] + + :plain + var row = $("table.table_#{@hex_path} tr.file_#{hexdigest(file_name)}"); + row.find("td.tree_time_ago").html('#{escape_javascript time_ago_in_words(commit.committed_date)} ago'); + row.find("td.tree_commit").html('#{escape_javascript render("projects/tree/tree_commit_column", commit: commit)}'); diff --git a/app/views/projects/repositories/_branch.html.haml b/app/views/projects/repositories/_branch.html.haml new file mode 100644 index 00000000000..dd91e14b66b --- /dev/null +++ b/app/views/projects/repositories/_branch.html.haml @@ -0,0 +1,26 @@ +- commit = Commit.new(Gitlab::Git::Commit.new(branch.commit)) +%tr + %td + = link_to project_commits_path(@project, branch.name) do + - if @project.protected_branch? branch.name + %i.icon-lock + - else + %i.icon-unlock + %strong= truncate(branch.name, length: 60) + - if branch.name == @repository.root_ref + %span.label default + %td + = link_to project_commit_path(@project, commit.id), class: 'commit_short_id' do + = commit.short_id + = image_tag gravatar_icon(commit.author_email), class: "avatar s16" + %span.light + = gfm escape_once(truncate(commit.title, length: 40)) + %span + = time_ago_in_words(commit.committed_date) + ago + %td + - if can? current_user, :download_code, @project + = link_to archive_project_repository_path(@project, ref: branch.name) do + %i.icon-download-alt + Download + diff --git a/app/views/projects/repositories/_feed.html.haml b/app/views/projects/repositories/_feed.html.haml new file mode 100644 index 00000000000..6bb75265ffb --- /dev/null +++ b/app/views/projects/repositories/_feed.html.haml @@ -0,0 +1,19 @@ +- commit = update +%tr + %td + = link_to project_commits_path(@project, commit.head.name) do + %strong + = commit.head.name + - if @project.root_ref?(commit.head.name) + %span.label default + + %td + %div + = link_to project_commits_path(@project, commit.id) do + %code= commit.short_id + = image_tag gravatar_icon(commit.author_email), class: "", width: 16 + = gfm escape_once(truncate(commit.title, length: 40)) + %td + %span.pull-right.cgray + = time_ago_in_words(commit.committed_date) + ago diff --git a/app/views/projects/repositories/_filter.html.haml b/app/views/projects/repositories/_filter.html.haml new file mode 100644 index 00000000000..e718d48190a --- /dev/null +++ b/app/views/projects/repositories/_filter.html.haml @@ -0,0 +1,9 @@ +%ul.nav.nav-pills.nav-stacked + = nav_link(path: 'repositories#show') do + = link_to 'Recent', project_repository_path(@project) + = nav_link(path: 'protected_branches#index') do + = link_to project_protected_branches_path(@project) do + Protected + %i.icon-lock + = nav_link(path: 'repositories#branches') do + = link_to 'All branches', branches_project_repository_path(@project) diff --git a/app/views/projects/repositories/branches.html.haml b/app/views/projects/repositories/branches.html.haml new file mode 100644 index 00000000000..2bdd304cdac --- /dev/null +++ b/app/views/projects/repositories/branches.html.haml @@ -0,0 +1,15 @@ += render "projects/commits/head" +.row + .span3 + = render "filter" + .span9 + - unless @branches.empty? + %table + %thead + %tr + %th Name + %th Last commit + %th + %tbody + - @branches.each do |branch| + = render "projects/repositories/branch", branch: branch diff --git a/app/views/projects/repositories/show.html.haml b/app/views/projects/repositories/show.html.haml new file mode 100644 index 00000000000..84a32e62426 --- /dev/null +++ b/app/views/projects/repositories/show.html.haml @@ -0,0 +1,14 @@ += render "projects/commits/head" +.row + .span3 + = render "filter" + .span9 + %table + %thead + %tr + %th Name + %th Last commit + %th + - @activities.each do |update| + = render "branch", branch: update.head + diff --git a/app/views/projects/repositories/stats.html.haml b/app/views/projects/repositories/stats.html.haml new file mode 100644 index 00000000000..dfdbc898912 --- /dev/null +++ b/app/views/projects/repositories/stats.html.haml @@ -0,0 +1,33 @@ += render "projects/commits/head" +.row + .span6 + %div#activity-chart.chart + %hr + %p + %b Total commits: + %span= @stats.commits_count + %p + %b Total files in #{@repository.root_ref}: + %span= @stats.files_count + %p + %b Authors: + %span= @stats.authors_count + + + .span6 + %h4 Top 50 Committers: + %ol.styled + - @stats.authors[0...50].each do |author| + %li + = image_tag gravatar_icon(author.email, 16), class: 'avatar s16' + = author.name + %small.light= author.email + .pull-right + = author.commits + + +:javascript + var labels = [#{@graph.labels.to_json}]; + var commits = [#{@graph.commits.join(', ')}]; + var title = "Commit activity for last #{@graph.weeks} weeks"; + Chart.init(labels, commits, title); diff --git a/app/views/projects/repositories/tags.html.haml b/app/views/projects/repositories/tags.html.haml new file mode 100644 index 00000000000..5972ea6c531 --- /dev/null +++ b/app/views/projects/repositories/tags.html.haml @@ -0,0 +1,36 @@ += render "projects/commits/head" +- unless @tags.empty? + %ul.bordered-list + - @tags.each do |tag| + - commit = Commit.new(Gitlab::Git::Commit.new(tag.commit)) + %li + %h5 + = link_to project_commits_path(@project, tag.name), class: "" do + %i.icon-tag + = tag.name + %small + = truncate(tag.message || '', length: 70) + .pull-right + %span.light + = time_ago_in_words(commit.committed_date) + ago + %div.prepend-left-20 + = link_to commit.short_id(8), project_commit_path(@project, commit), class: "monospace" + – + = link_to_gfm truncate(commit.title, length: 70), project_commit_path(@project, commit.id), class: "cdark" + + - if can? current_user, :download_code, @project + .pull-right + = link_to archive_project_repository_path(@project, ref: tag.name) do + %i.icon-download-alt + Download + + +- else + %h3.nothing_here_message + Repository has no tags yet. + %br + %small + Use git tag command to add a new one: + %br + %span.monospace git tag -a v1.4 -m 'version 1.4' diff --git a/app/views/projects/services/_form.html.haml b/app/views/projects/services/_form.html.haml new file mode 100644 index 00000000000..ff6769531c4 --- /dev/null +++ b/app/views/projects/services/_form.html.haml @@ -0,0 +1,48 @@ +%h3.page_title + - if @service.activated? + %span.cgreen + %i.icon-circle + - else + %span.cgray + %i.icon-circle-blank + = @service.title + +%p= @service.description + +.back_link + = link_to project_services_path(@project) do + ← to services + +%hr + += form_for(@service, as: :service, url: project_service_path(@project, @service.to_param), method: :put) do |f| + - if @service.errors.any? + .alert.alert-error + %ul + - @service.errors.full_messages.each do |msg| + %li= msg + + + .control-group + = f.label :active, "Active", class: "control-label" + .controls + = f.check_box :active + + - @service.fields.each do |field| + - name = field[:name] + - type = field[:type] + - placeholder = field[:placeholder] + + .control-group + = f.label name, class: "control-label" + .controls + - if type == 'text' + = f.text_field name, class: "input-xlarge", placeholder: placeholder + - elsif type == 'checkbox' + = f.check_box name + + .form-actions + = f.submit 'Save', class: 'btn btn-save' +   + - if @service.valid? && @service.activated? + = link_to 'Test settings', test_project_service_path(@project, @service.to_param), class: 'btn btn-small' diff --git a/app/views/projects/services/edit.html.haml b/app/views/projects/services/edit.html.haml new file mode 100644 index 00000000000..bcc5832792f --- /dev/null +++ b/app/views/projects/services/edit.html.haml @@ -0,0 +1 @@ += render 'form' diff --git a/app/views/projects/services/index.html.haml b/app/views/projects/services/index.html.haml new file mode 100644 index 00000000000..6d254f66f1c --- /dev/null +++ b/app/views/projects/services/index.html.haml @@ -0,0 +1,16 @@ +%h3.page_title Services +%br + +%ul.bordered-list + - @services.each do |service| + %li + %h4 + - if service.activated? + %span.cgreen + %i.icon-circle + - else + %span.cgray + %i.icon-circle-blank + = link_to edit_project_service_path(@project, service.to_param) do + = service.title + %p= service.description diff --git a/app/views/projects/snippets/show.html.haml b/app/views/projects/snippets/show.html.haml index da93e4bdbb1..36161c5706c 100644 --- a/app/views/projects/snippets/show.html.haml +++ b/app/views/projects/snippets/show.html.haml @@ -10,4 +10,4 @@ = @snippet.author_name %br %div= render 'projects/snippets/blob' -%div#notes= render "notes/notes_with_form" +%div#notes= render "projects/notes/notes_with_form" diff --git a/app/views/projects/team_members/_form.html.haml b/app/views/projects/team_members/_form.html.haml new file mode 100644 index 00000000000..4e8f67702cf --- /dev/null +++ b/app/views/projects/team_members/_form.html.haml @@ -0,0 +1,24 @@ +%h3.page_title + = "New Team member(s)" +%hr += form_for @user_project_relation, as: :team_member, url: project_team_members_path(@project) do |f| + -if @user_project_relation.errors.any? + .alert.alert-error + %ul + - @user_project_relation.errors.full_messages.each do |msg| + %li= msg + + %h6 1. Choose people you want in the team + .clearfix + = f.label :user_ids, "People" + .input + = users_select_tag(:user_ids, multiple: true) + + %h6 2. Set access level for them + .clearfix + = f.label :project_access, "Project Access" + .input= select_tag :project_access, options_for_select(Project.access_options, @user_project_relation.project_access), class: "project-access-select chosen" + + .actions + = f.submit 'Add users', class: "btn btn-create" + = link_to "Cancel", project_team_index_path(@project), class: "btn btn-cancel" diff --git a/app/views/projects/team_members/_group_members.html.haml b/app/views/projects/team_members/_group_members.html.haml new file mode 100644 index 00000000000..7d9333d38e6 --- /dev/null +++ b/app/views/projects/team_members/_group_members.html.haml @@ -0,0 +1,10 @@ +.ui-box + %h5.title + %strong #{@group.name} Group + members (#{@group.users_groups.count}) + .pull-right + = link_to people_group_path(@group), class: 'btn btn-small' do + %i.icon-edit + %ul.well-list + - @group.users_groups.order('group_access DESC').each do |member| + = render 'users_groups/users_group', member: member, show_controls: false diff --git a/app/views/projects/team_members/_team.html.haml b/app/views/projects/team_members/_team.html.haml new file mode 100644 index 00000000000..99231e92152 --- /dev/null +++ b/app/views/projects/team_members/_team.html.haml @@ -0,0 +1,9 @@ +.team-table + - can_admin_project = (can? current_user, :admin_project, @project) + .ui-box + %h5.title + %strong #{@project.name} Project + members (#{members.count}) + %ul.well-list + - members.each do |team_member| + = render 'team_member', member: team_member, current_user_can_admin_project: can_admin_project diff --git a/app/views/projects/team_members/_team_member.html.haml b/app/views/projects/team_members/_team_member.html.haml new file mode 100644 index 00000000000..916cf2e7a87 --- /dev/null +++ b/app/views/projects/team_members/_team_member.html.haml @@ -0,0 +1,17 @@ +- user = member.user +%li{id: dom_id(user), class: "team_member_row access-#{member.human_access.downcase}"} + .pull-right + - if current_user_can_admin_project + - unless @project.personal? && user == current_user + .pull-left + = form_for(member, as: :team_member, url: project_team_member_path(@project, member.user)) do |f| + = f.select :project_access, options_for_select(UsersProject.access_roles, member.project_access), {}, class: "medium project-access-select span2 trigger-submit" +   + = link_to project_team_member_path(@project, user), confirm: remove_from_project_team_message(@project, user), method: :delete, class: "btn-tiny btn btn-remove", title: 'Remove user from team' do + %i.icon-minus.icon-white + = image_tag gravatar_icon(user.email, 32), class: "avatar s32" + %p + %strong= user.name + %span.cgray= user.username + + diff --git a/app/views/projects/team_members/import.html.haml b/app/views/projects/team_members/import.html.haml new file mode 100644 index 00000000000..2b22c917a16 --- /dev/null +++ b/app/views/projects/team_members/import.html.haml @@ -0,0 +1,15 @@ +%h3.page_title + = "Import team from another project" +%hr +%p.slead + Read more about project 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 btn-save" + = link_to "Cancel", project_team_index_path(@project), class: "btn btn-cancel" + diff --git a/app/views/projects/team_members/index.html.haml b/app/views/projects/team_members/index.html.haml new file mode 100644 index 00000000000..8f81390ca13 --- /dev/null +++ b/app/views/projects/team_members/index.html.haml @@ -0,0 +1,16 @@ +%h3.page_title + Users with access to this project + + - if can? current_user, :admin_team_member, @project + %span.pull-right + = link_to import_project_team_members_path(@project), class: "btn btn-small grouped", title: "Import team from another project" do + Import team from another project + = link_to new_project_team_member_path(@project), class: "btn btn-primary small grouped", title: "New Team Member" do + New Team Member + +%p.light + Read more about project permissions + %strong= link_to "here", help_permissions_path, class: "vlink" +- if @group + = render "group_members" += render "team", members: @users_projects diff --git a/app/views/projects/team_members/new.html.haml b/app/views/projects/team_members/new.html.haml new file mode 100644 index 00000000000..b1bc3ba0eba --- /dev/null +++ b/app/views/projects/team_members/new.html.haml @@ -0,0 +1 @@ += render "form" diff --git a/app/views/projects/team_members/update.js.haml b/app/views/projects/team_members/update.js.haml new file mode 100644 index 00000000000..c68fe9574a2 --- /dev/null +++ b/app/views/projects/team_members/update.js.haml @@ -0,0 +1,6 @@ +- if @user_project_relation.valid? + :plain + $("##{dom_id(@user_project_relation)}").effect("highlight", {color: "#529214"}, 1000);; +- else + :plain + $("##{dom_id(@user_project_relation)}").effect("highlight", {color: "#D12F19"}, 1000);; diff --git a/app/views/projects/tree/_blob_item.html.haml b/app/views/projects/tree/_blob_item.html.haml new file mode 100644 index 00000000000..ec15b608f85 --- /dev/null +++ b/app/views/projects/tree/_blob_item.html.haml @@ -0,0 +1,9 @@ +%tr{ class: "tree-item #{tree_hex_class(blob_item)}" } + %td.tree-item-file-name + = tree_icon(type) + %strong= link_to truncate(blob_item.name, length: 40), project_blob_path(@project, tree_join(@id || @commit.id, blob_item.name)) + %td.tree_time_ago.cgray + %span.log_loading.hide + Loading commit data... + = image_tag "ajax_loader_tree.gif", width: 14 + %td.tree_commit{ colspan: 2 } diff --git a/app/views/projects/tree/_readme.html.haml b/app/views/projects/tree/_readme.html.haml new file mode 100644 index 00000000000..e9bb112745b --- /dev/null +++ b/app/views/projects/tree/_readme.html.haml @@ -0,0 +1,13 @@ +.file_holder#README + .file_title + %i.icon-file + = readme.name + .file_content.wiki + - if gitlab_markdown?(readme.name) + = preserve do + = markdown(readme.data) + - elsif plain_text_readme?(readme.name) + %pre.clean + = readme.data + - else + = raw GitHub::Markup.render(readme.name, readme.data) diff --git a/app/views/projects/tree/_submodule_item.html.haml b/app/views/projects/tree/_submodule_item.html.haml new file mode 100644 index 00000000000..092a024afbc --- /dev/null +++ b/app/views/projects/tree/_submodule_item.html.haml @@ -0,0 +1,11 @@ +- url = submodule_item.url(@ref) rescue '' +- name = submodule_item.basename +- return '' unless url +%tr{ class: "tree-item", url: url } + %td.tree-item-file-name + = image_tag "submodule.png" + %strong= truncate(name, length: 40) + %td + %code= submodule_item.id[0..10] + %td{ colspan: 2 } + = link_to truncate(url, length: 40), url diff --git a/app/views/projects/tree/_tree.html.haml b/app/views/projects/tree/_tree.html.haml new file mode 100644 index 00000000000..0b1148b3e74 --- /dev/null +++ b/app/views/projects/tree/_tree.html.haml @@ -0,0 +1,51 @@ +%ul.breadcrumb + %li + %i.icon-angle-right + = link_to project_tree_path(@project, @ref) do + = @project.path + - tree_breadcrumbs(tree, 6) do |title, path| + \/ + %li + - if path + = link_to truncate(title, length: 40), project_tree_path(@project, path) + - else + = link_to title, '#' + +%div#tree-content-holder.tree-content-holder + %table#tree-slider{class: "table_#{@hex_path} tree-table" } + %thead + %tr + %th Name + %th Last Update + %th + Last Commit +   + %i.icon-angle-right +   + %small.light + = link_to @commit.short_id, project_commit_path(@project, @commit) + – + = truncate(@commit.title, length: 50) + %th= link_to "history", project_commits_path(@project, @id), class: "btn btn-tiny pull-right" + + - if tree.up_dir? + %tr.tree-item + %td.tree-item-file-name + = image_tag "file_empty.png", size: '16x16' + = link_to "..", project_tree_path(@project, up_dir_path(tree)) + %td + %td + %td + + = render_tree(tree) + + - if tree.readme + = render "projects/tree/readme", readme: tree.readme + +%div.tree_progress + +:javascript + // Load last commit log for each file in tree + $('#tree-slider').waitForImages(function() { + ajaxGet('#{@logs_path}'); + }); diff --git a/app/views/projects/tree/_tree_commit_column.html.haml b/app/views/projects/tree/_tree_commit_column.html.haml new file mode 100644 index 00000000000..7ae2582c130 --- /dev/null +++ b/app/views/projects/tree/_tree_commit_column.html.haml @@ -0,0 +1,2 @@ +%span.tree_author= commit_author_link(commit, avatar: true) += link_to_gfm truncate(commit.title, length: 80), project_commit_path(@project, commit.id), class: "tree-commit-link" diff --git a/app/views/projects/tree/_tree_item.html.haml b/app/views/projects/tree/_tree_item.html.haml new file mode 100644 index 00000000000..0a76d5c21b6 --- /dev/null +++ b/app/views/projects/tree/_tree_item.html.haml @@ -0,0 +1,9 @@ +%tr{ class: "tree-item #{tree_hex_class(tree_item)}" } + %td.tree-item-file-name + = tree_icon(type) + %strong= link_to truncate(tree_item.name, length: 40), project_tree_path(@project, tree_join(@id || @commit.id, tree_item.name)) + %td.tree_time_ago.cgray + %span.log_loading.hide + Loading commit data... + = image_tag "ajax_loader_tree.gif", width: 14 + %td.tree_commit{ colspan: 2 } diff --git a/app/views/projects/tree/show.html.haml b/app/views/projects/tree/show.html.haml new file mode 100644 index 00000000000..0f7692aba7f --- /dev/null +++ b/app/views/projects/tree/show.html.haml @@ -0,0 +1,4 @@ +%div.tree-ref-holder + = render 'shared/ref_switcher', destination: 'tree', path: @path +%div#tree-holder.tree-holder + = render "tree", tree: @tree diff --git a/app/views/projects/walls/show.html.haml b/app/views/projects/walls/show.html.haml new file mode 100644 index 00000000000..88aecee0815 --- /dev/null +++ b/app/views/projects/walls/show.html.haml @@ -0,0 +1,23 @@ +%div.wall-page + %ul.notes + + - if can? current_user, :write_note, @project + .note-form-holder + = form_for [@project, @note], remote: true, html: { multipart: true, id: nil, class: "new_note wall-note-form" } do |f| + = note_target_fields + .note_text_and_preview + = f.text_area :note, size: 255, class: 'note_text js-note-text js-gfm-input turn-on' + .note-form-actions + .buttons + = f.submit 'Add Comment', class: "btn comment-btn grouped js-comment-button" + + .note-form-option + %a.choose-btn.btn.btn-small.js-choose-note-attachment-button + %i.icon-paper-clip + %span Choose File ... +   + %span.file_name.js-attachment-filename File name... + = f.file_field :attachment, class: "js-note-attachment-input hide" + + .hint.pull-right CTRL + Enter to send message + .clearfix diff --git a/app/views/projects/wikis/_form.html.haml b/app/views/projects/wikis/_form.html.haml new file mode 100644 index 00000000000..7cf08815f78 --- /dev/null +++ b/app/views/projects/wikis/_form.html.haml @@ -0,0 +1,36 @@ += form_for [@project, @wiki] do |f| + -if @wiki.errors.any? + #error_explanation + %h2= "#{pluralize(@wiki.errors.count, "error")} prohibited this wiki from being saved:" + %ul + - @wiki.errors.full_messages.each do |msg| + %li= msg + + .ui-box.ui-box-show + .ui-box-head + %h3.page_title + .edit-wiki-header + = @wiki.title.titleize + = f.hidden_field :title, value: @wiki.title + = f.select :format, options_for_select(GollumWiki::MARKUPS, {selected: @wiki.format}), {}, class: "pull-right input-medium" + = f.label :format, class: "pull-right", style: "padding-right: 20px;" + .ui-box-body + .input + %span.cgray + Wiki content is parsed with #{link_to "GitLab Flavored Markdown", help_markdown_path, target: '_blank'}. + To link to a (new) page you can just type + %code [Link Title](page-slug) + \. + + .ui-box-bottom + = f.label :content + .input= f.text_area :content, class: 'span8 js-gfm-input' + .ui-box-bottom + = f.label :commit_message + .input= f.text_field :message, class: 'span8' + .actions + = f.submit 'Save', class: "btn-save btn" + - if @wiki && @wiki.persisted? + = link_to "Cancel", project_wiki_path(@project, @wiki), class: "btn btn-cancel" + - else + = link_to "Cancel", project_wiki_path(@project, :home), class: "btn btn-cancel" diff --git a/app/views/projects/wikis/_main_links.html.haml b/app/views/projects/wikis/_main_links.html.haml new file mode 100644 index 00000000000..cb8ccf81c7b --- /dev/null +++ b/app/views/projects/wikis/_main_links.html.haml @@ -0,0 +1,8 @@ +%span.pull-right + - if (@wiki && @wiki.persisted?) + = link_to history_project_wiki_path(@project, @wiki), class: "btn btn-small grouped" do + Page History + - if can?(current_user, :write_wiki, @project) + = link_to edit_project_wiki_path(@project, @wiki), class: "btn btn-small grouped" do + %i.icon-edit + Edit diff --git a/app/views/projects/wikis/_nav.html.haml b/app/views/projects/wikis/_nav.html.haml new file mode 100644 index 00000000000..d62b46a7e5b --- /dev/null +++ b/app/views/projects/wikis/_nav.html.haml @@ -0,0 +1,19 @@ +%ul.nav.nav-tabs + = nav_link(html_options: {class: params[:id] == 'home' ? 'active' : '' }) do + = link_to 'Home', project_wiki_path(@project, :home) + + = nav_link(path: 'wikis#pages') do + = link_to 'Pages', pages_project_wikis_path(@project) + + = nav_link(path: 'wikis#git_access') do + = link_to git_access_project_wikis_path(@project) do + %i.icon-download-alt + Git Access + + - if can?(current_user, :write_wiki, @project) + .pull-right + = link_to '#', class: "add-new-wiki btn btn-small btn-primary" do + %i.icon-plus + New Page + += render 'projects/wikis/new' diff --git a/app/views/projects/wikis/_new.html.haml b/app/views/projects/wikis/_new.html.haml new file mode 100644 index 00000000000..ca8e7c1b4b4 --- /dev/null +++ b/app/views/projects/wikis/_new.html.haml @@ -0,0 +1,12 @@ +%div#modal-new-wiki.modal.hide + .modal-header + %a.close{href: "#"} × + %h3.page_title New Wiki Page + .modal-body + = label_tag :new_wiki_path do + %span Page slug + = text_field_tag :new_wiki_path, nil, placeholder: 'how-to-setup', class: 'input-xlarge', required: true, :'data-wikis-path' => project_wikis_path(@project) + %p.hint + Please dont use spaces and slashes + .modal-footer + = link_to 'Build', '#', class: 'build-new-wiki btn btn-create' diff --git a/app/views/projects/wikis/edit.html.haml b/app/views/projects/wikis/edit.html.haml new file mode 100644 index 00000000000..4e318c92db3 --- /dev/null +++ b/app/views/projects/wikis/edit.html.haml @@ -0,0 +1,10 @@ += render 'nav' +%h3.page_title + Editing page + = render 'main_links' += render 'form' + +.pull-right + - if @wiki.persisted? && can?(current_user, :admin_wiki, @project) + = link_to project_wiki_path(@project, @wiki), confirm: "Are you sure you want to delete this page?", method: :delete, class: "btn btn-small btn-remove" do + Delete this page diff --git a/app/views/projects/wikis/empty.html.haml b/app/views/projects/wikis/empty.html.haml new file mode 100644 index 00000000000..08b59f0328b --- /dev/null +++ b/app/views/projects/wikis/empty.html.haml @@ -0,0 +1,4 @@ +%h3.page_title Empty page +%hr +.error_message + You are not allowed to create wiki pages diff --git a/app/views/projects/wikis/git_access.html.haml b/app/views/projects/wikis/git_access.html.haml new file mode 100644 index 00000000000..71e2b48d370 --- /dev/null +++ b/app/views/projects/wikis/git_access.html.haml @@ -0,0 +1,37 @@ += render 'nav' +%h3.page_title + Git Access + %strong= @gollum_wiki.path_with_namespace + = render 'main_links' + +%br +.content + .project_clone_panel + .row + .span7 + .form-horizontal + .input-prepend.project_clone_holder + %button{class: "btn active", :"data-clone" => @gollum_wiki.ssh_url_to_repo} SSH + %button{class: "btn", :"data-clone" => @gollum_wiki.http_url_to_repo}= Gitlab.config.gitlab.protocol.upcase + = text_field_tag :project_clone, @gollum_wiki.url_to_repo, class: "one_click_select input-xxlarge", readonly: true + .git-empty + %fieldset + %legend Install Gollum: + %pre.dark + :preserve + gem install gollum + + %legend Clone Your Wiki: + %pre.dark + :preserve + git clone #{@gollum_wiki.ssh_url_to_repo} + cd #{@gollum_wiki.path} + + %legend Start Gollum And Edit Locally: + %pre.dark + :preserve + gollum + == Sinatra/1.3.5 has taken the stage on 4567 for development with backup from Thin + >> Thin web server (v1.5.0 codename Knife) + >> Maximum connections set to 1024 + >> Listening on 0.0.0.0:4567, CTRL+C to stop diff --git a/app/views/projects/wikis/history.html.haml b/app/views/projects/wikis/history.html.haml new file mode 100644 index 00000000000..138c384353d --- /dev/null +++ b/app/views/projects/wikis/history.html.haml @@ -0,0 +1,31 @@ += render 'nav' +%h3.page_title + %span.light History for + = @wiki.title.titleize + = render 'main_links' +%br +%table + %thead + %tr + %th Page version + %th Author + %th Commit Message + %th Last updated + %th Format + %tbody + - @wiki.versions.each do |version| + - commit = version + %tr + %td + = link_to project_wiki_path(@project, @wiki, version_id: commit.id) do + = commit.short_id + %td + = commit_author_link(commit, avatar: true, size: 24) + %td + = commit.title + %td + = time_ago_in_words(version.date) + ago + %td + %strong + = @wiki.page.wiki.page(@wiki.page.name, commit.id).try(:format) diff --git a/app/views/projects/wikis/pages.html.haml b/app/views/projects/wikis/pages.html.haml new file mode 100644 index 00000000000..07e942ec62f --- /dev/null +++ b/app/views/projects/wikis/pages.html.haml @@ -0,0 +1,25 @@ += render 'nav' +%h3.page_title + All Pages + = render 'main_links' +%br +%table + %thead + %tr + %th Title + %th Format + %th Last updated + %th Updated by + %tbody + - @wiki_pages.each do |wiki_page| + %tr + %td + %strong= link_to wiki_page.title.titleize, project_wiki_path(@project, wiki_page) + %td + %strong= wiki_page.format + %td + = wiki_page.created_at.to_s(:short) do + (#{time_ago_in_words(wiki_page.created_at)} + ago) + %td + = commit_author_link(wiki_page.version, avatar: true, size: 24) diff --git a/app/views/projects/wikis/show.html.haml b/app/views/projects/wikis/show.html.haml new file mode 100644 index 00000000000..d9d57e2d8be --- /dev/null +++ b/app/views/projects/wikis/show.html.haml @@ -0,0 +1,16 @@ += render 'nav' +%h3.page_title + = @wiki.title.titleize + = render 'main_links' +%br +- if @wiki.historical? + .warning_message + This is an old version of this page. + You can view the #{link_to "most recent version", project_wiki_path(@project, @wiki)} or browse the #{link_to "history", history_project_wiki_path(@project, @wiki)}. + +.file_holder + .file_content.wiki + = preserve do + = render_wiki_content(@wiki) + +%p.time Last edited by #{commit_author_link(@wiki.version, avatar: true, size: 16)} #{time_ago_in_words @wiki.created_at} ago diff --git a/app/views/protected_branches/index.html.haml b/app/views/protected_branches/index.html.haml deleted file mode 100644 index a338344c52d..00000000000 --- a/app/views/protected_branches/index.html.haml +++ /dev/null @@ -1,54 +0,0 @@ -= render "commits/head" -.row - .span3 - = render "repositories/filter" - .span9 - .alert - %p Protected branches designed to prevent push for all except #{link_to "masters", help_permissions_path, class: "vlink"}. - %p This ability allows: - %ul - %li keep stable branches secured - %li forced code review before merge to protected branches - %p Read more about project permissions #{link_to "here", help_permissions_path, class: "vlink"} - - - if can? current_user, :admin_project, @project - = form_for [@project, @protected_branch] do |f| - -if @protected_branch.errors.any? - .alert.alert-error - %ul - - @protected_branch.errors.full_messages.each do |msg| - %li= msg - - .entry.clearfix - = f.label :name, "Branch" - .span3 - = f.select(:name, @project.open_branches.map { |br| [br.name, br.name] } , {include_blank: "Select branch"}, {class: "chosen span3"}) -   - = f.submit 'Protect', class: "btn-primary btn" - - - unless @branches.empty? - %table - %thead - %tr - %th Name - %th Last commit - %th - %tbody - - @branches.each do |branch| - %tr - %td - = link_to project_commits_path(@project, branch.name) do - %strong= branch.name - - if @project.root_ref?(branch.name) - %span.label default - %td - - if branch.commit - = link_to project_commit_path(@project, branch.commit.id) do - = truncate branch.commit.id.to_s, length: 10 - = time_ago_in_words(branch.commit.committed_date) - ago - - else - (branch was removed from repository) - %td - - if can? current_user, :admin_project, @project - = link_to 'Unprotect', [@project, branch], confirm: 'Branch will be writable for developers. Are you sure?', method: :delete, class: "btn btn-remove btn-small" diff --git a/app/views/refs/logs_tree.js.haml b/app/views/refs/logs_tree.js.haml deleted file mode 100644 index 0b517327139..00000000000 --- a/app/views/refs/logs_tree.js.haml +++ /dev/null @@ -1,8 +0,0 @@ -- @logs.each do |content_data| - - file_name = content_data[:file_name] - - commit = content_data[:commit] - - :plain - var row = $("table.table_#{@hex_path} tr.file_#{hexdigest(file_name)}"); - row.find("td.tree_time_ago").html('#{escape_javascript time_ago_in_words(commit.committed_date)} ago'); - row.find("td.tree_commit").html('#{escape_javascript render("tree/tree_commit_column", commit: commit)}'); diff --git a/app/views/repositories/_branch.html.haml b/app/views/repositories/_branch.html.haml deleted file mode 100644 index dd91e14b66b..00000000000 --- a/app/views/repositories/_branch.html.haml +++ /dev/null @@ -1,26 +0,0 @@ -- commit = Commit.new(Gitlab::Git::Commit.new(branch.commit)) -%tr - %td - = link_to project_commits_path(@project, branch.name) do - - if @project.protected_branch? branch.name - %i.icon-lock - - else - %i.icon-unlock - %strong= truncate(branch.name, length: 60) - - if branch.name == @repository.root_ref - %span.label default - %td - = link_to project_commit_path(@project, commit.id), class: 'commit_short_id' do - = commit.short_id - = image_tag gravatar_icon(commit.author_email), class: "avatar s16" - %span.light - = gfm escape_once(truncate(commit.title, length: 40)) - %span - = time_ago_in_words(commit.committed_date) - ago - %td - - if can? current_user, :download_code, @project - = link_to archive_project_repository_path(@project, ref: branch.name) do - %i.icon-download-alt - Download - diff --git a/app/views/repositories/_feed.html.haml b/app/views/repositories/_feed.html.haml deleted file mode 100644 index 6bb75265ffb..00000000000 --- a/app/views/repositories/_feed.html.haml +++ /dev/null @@ -1,19 +0,0 @@ -- commit = update -%tr - %td - = link_to project_commits_path(@project, commit.head.name) do - %strong - = commit.head.name - - if @project.root_ref?(commit.head.name) - %span.label default - - %td - %div - = link_to project_commits_path(@project, commit.id) do - %code= commit.short_id - = image_tag gravatar_icon(commit.author_email), class: "", width: 16 - = gfm escape_once(truncate(commit.title, length: 40)) - %td - %span.pull-right.cgray - = time_ago_in_words(commit.committed_date) - ago diff --git a/app/views/repositories/_filter.html.haml b/app/views/repositories/_filter.html.haml deleted file mode 100644 index e718d48190a..00000000000 --- a/app/views/repositories/_filter.html.haml +++ /dev/null @@ -1,9 +0,0 @@ -%ul.nav.nav-pills.nav-stacked - = nav_link(path: 'repositories#show') do - = link_to 'Recent', project_repository_path(@project) - = nav_link(path: 'protected_branches#index') do - = link_to project_protected_branches_path(@project) do - Protected - %i.icon-lock - = nav_link(path: 'repositories#branches') do - = link_to 'All branches', branches_project_repository_path(@project) diff --git a/app/views/repositories/branches.html.haml b/app/views/repositories/branches.html.haml deleted file mode 100644 index 14b5082e44e..00000000000 --- a/app/views/repositories/branches.html.haml +++ /dev/null @@ -1,15 +0,0 @@ -= render "commits/head" -.row - .span3 - = render "filter" - .span9 - - unless @branches.empty? - %table - %thead - %tr - %th Name - %th Last commit - %th - %tbody - - @branches.each do |branch| - = render "repositories/branch", branch: branch diff --git a/app/views/repositories/show.html.haml b/app/views/repositories/show.html.haml deleted file mode 100644 index e58e16f8bf1..00000000000 --- a/app/views/repositories/show.html.haml +++ /dev/null @@ -1,14 +0,0 @@ -= render "commits/head" -.row - .span3 - = render "filter" - .span9 - %table - %thead - %tr - %th Name - %th Last commit - %th - - @activities.each do |update| - = render "repositories/branch", branch: update.head - diff --git a/app/views/repositories/stats.html.haml b/app/views/repositories/stats.html.haml deleted file mode 100644 index 6d1fb4686ea..00000000000 --- a/app/views/repositories/stats.html.haml +++ /dev/null @@ -1,33 +0,0 @@ -= render "commits/head" -.row - .span6 - %div#activity-chart.chart - %hr - %p - %b Total commits: - %span= @stats.commits_count - %p - %b Total files in #{@repository.root_ref}: - %span= @stats.files_count - %p - %b Authors: - %span= @stats.authors_count - - - .span6 - %h4 Top 50 Committers: - %ol.styled - - @stats.authors[0...50].each do |author| - %li - = image_tag gravatar_icon(author.email, 16), class: 'avatar s16' - = author.name - %small.light= author.email - .pull-right - = author.commits - - -:javascript - var labels = [#{@graph.labels.to_json}]; - var commits = [#{@graph.commits.join(', ')}]; - var title = "Commit activity for last #{@graph.weeks} weeks"; - Chart.init(labels, commits, title); diff --git a/app/views/repositories/tags.html.haml b/app/views/repositories/tags.html.haml deleted file mode 100644 index bef5cd0841b..00000000000 --- a/app/views/repositories/tags.html.haml +++ /dev/null @@ -1,36 +0,0 @@ -= render "commits/head" -- unless @tags.empty? - %ul.bordered-list - - @tags.each do |tag| - - commit = Commit.new(Gitlab::Git::Commit.new(tag.commit)) - %li - %h5 - = link_to project_commits_path(@project, tag.name), class: "" do - %i.icon-tag - = tag.name - %small - = truncate(tag.message || '', length: 70) - .pull-right - %span.light - = time_ago_in_words(commit.committed_date) - ago - %div.prepend-left-20 - = link_to commit.short_id(8), project_commit_path(@project, commit), class: "monospace" - – - = link_to_gfm truncate(commit.title, length: 70), project_commit_path(@project, commit.id), class: "cdark" - - - if can? current_user, :download_code, @project - .pull-right - = link_to archive_project_repository_path(@project, ref: tag.name) do - %i.icon-download-alt - Download - - -- else - %h3.nothing_here_message - Repository has no tags yet. - %br - %small - Use git tag command to add a new one: - %br - %span.monospace git tag -a v1.4 -m 'version 1.4' diff --git a/app/views/services/_form.html.haml b/app/views/services/_form.html.haml deleted file mode 100644 index ff6769531c4..00000000000 --- a/app/views/services/_form.html.haml +++ /dev/null @@ -1,48 +0,0 @@ -%h3.page_title - - if @service.activated? - %span.cgreen - %i.icon-circle - - else - %span.cgray - %i.icon-circle-blank - = @service.title - -%p= @service.description - -.back_link - = link_to project_services_path(@project) do - ← to services - -%hr - -= form_for(@service, as: :service, url: project_service_path(@project, @service.to_param), method: :put) do |f| - - if @service.errors.any? - .alert.alert-error - %ul - - @service.errors.full_messages.each do |msg| - %li= msg - - - .control-group - = f.label :active, "Active", class: "control-label" - .controls - = f.check_box :active - - - @service.fields.each do |field| - - name = field[:name] - - type = field[:type] - - placeholder = field[:placeholder] - - .control-group - = f.label name, class: "control-label" - .controls - - if type == 'text' - = f.text_field name, class: "input-xlarge", placeholder: placeholder - - elsif type == 'checkbox' - = f.check_box name - - .form-actions - = f.submit 'Save', class: 'btn btn-save' -   - - if @service.valid? && @service.activated? - = link_to 'Test settings', test_project_service_path(@project, @service.to_param), class: 'btn btn-small' diff --git a/app/views/services/edit.html.haml b/app/views/services/edit.html.haml deleted file mode 100644 index bcc5832792f..00000000000 --- a/app/views/services/edit.html.haml +++ /dev/null @@ -1 +0,0 @@ -= render 'form' diff --git a/app/views/services/index.html.haml b/app/views/services/index.html.haml deleted file mode 100644 index 6d254f66f1c..00000000000 --- a/app/views/services/index.html.haml +++ /dev/null @@ -1,16 +0,0 @@ -%h3.page_title Services -%br - -%ul.bordered-list - - @services.each do |service| - %li - %h4 - - if service.activated? - %span.cgreen - %i.icon-circle - - else - %span.cgray - %i.icon-circle-blank - = link_to edit_project_service_path(@project, service.to_param) do - = service.title - %p= service.description diff --git a/app/views/shared/_merge_requests.html.haml b/app/views/shared/_merge_requests.html.haml index a2800b11d8d..a7037d5987a 100644 --- a/app/views/shared/_merge_requests.html.haml +++ b/app/views/shared/_merge_requests.html.haml @@ -6,7 +6,7 @@ = link_to_project project %ul.well-list.mr-list - group[1].each do |merge_request| - = render(partial: 'merge_requests/merge_request', locals: {merge_request: merge_request}) + = render 'projects/merge_requests/merge_request', merge_request: merge_request %hr = paginate @merge_requests, theme: "gitlab" diff --git a/app/views/team_members/_form.html.haml b/app/views/team_members/_form.html.haml deleted file mode 100644 index 4e8f67702cf..00000000000 --- a/app/views/team_members/_form.html.haml +++ /dev/null @@ -1,24 +0,0 @@ -%h3.page_title - = "New Team member(s)" -%hr -= form_for @user_project_relation, as: :team_member, url: project_team_members_path(@project) do |f| - -if @user_project_relation.errors.any? - .alert.alert-error - %ul - - @user_project_relation.errors.full_messages.each do |msg| - %li= msg - - %h6 1. Choose people you want in the team - .clearfix - = f.label :user_ids, "People" - .input - = users_select_tag(:user_ids, multiple: true) - - %h6 2. Set access level for them - .clearfix - = f.label :project_access, "Project Access" - .input= select_tag :project_access, options_for_select(Project.access_options, @user_project_relation.project_access), class: "project-access-select chosen" - - .actions - = f.submit 'Add users', class: "btn btn-create" - = link_to "Cancel", project_team_index_path(@project), class: "btn btn-cancel" diff --git a/app/views/team_members/_group_members.html.haml b/app/views/team_members/_group_members.html.haml deleted file mode 100644 index 7d9333d38e6..00000000000 --- a/app/views/team_members/_group_members.html.haml +++ /dev/null @@ -1,10 +0,0 @@ -.ui-box - %h5.title - %strong #{@group.name} Group - members (#{@group.users_groups.count}) - .pull-right - = link_to people_group_path(@group), class: 'btn btn-small' do - %i.icon-edit - %ul.well-list - - @group.users_groups.order('group_access DESC').each do |member| - = render 'users_groups/users_group', member: member, show_controls: false diff --git a/app/views/team_members/_team.html.haml b/app/views/team_members/_team.html.haml deleted file mode 100644 index 2a663bd9941..00000000000 --- a/app/views/team_members/_team.html.haml +++ /dev/null @@ -1,9 +0,0 @@ -.team-table - - can_admin_project = (can? current_user, :admin_project, @project) - .ui-box - %h5.title - %strong #{@project.name} Project - members (#{members.count}) - %ul.well-list - - members.each do |team_member| - = render 'team_members/team_member', member: team_member, current_user_can_admin_project: can_admin_project diff --git a/app/views/team_members/_team_member.html.haml b/app/views/team_members/_team_member.html.haml deleted file mode 100644 index 916cf2e7a87..00000000000 --- a/app/views/team_members/_team_member.html.haml +++ /dev/null @@ -1,17 +0,0 @@ -- user = member.user -%li{id: dom_id(user), class: "team_member_row access-#{member.human_access.downcase}"} - .pull-right - - if current_user_can_admin_project - - unless @project.personal? && user == current_user - .pull-left - = form_for(member, as: :team_member, url: project_team_member_path(@project, member.user)) do |f| - = f.select :project_access, options_for_select(UsersProject.access_roles, member.project_access), {}, class: "medium project-access-select span2 trigger-submit" -   - = link_to project_team_member_path(@project, user), confirm: remove_from_project_team_message(@project, user), method: :delete, class: "btn-tiny btn btn-remove", title: 'Remove user from team' do - %i.icon-minus.icon-white - = image_tag gravatar_icon(user.email, 32), class: "avatar s32" - %p - %strong= user.name - %span.cgray= user.username - - diff --git a/app/views/team_members/import.html.haml b/app/views/team_members/import.html.haml deleted file mode 100644 index 2b22c917a16..00000000000 --- a/app/views/team_members/import.html.haml +++ /dev/null @@ -1,15 +0,0 @@ -%h3.page_title - = "Import team from another project" -%hr -%p.slead - Read more about project 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 btn-save" - = link_to "Cancel", project_team_index_path(@project), class: "btn btn-cancel" - diff --git a/app/views/team_members/index.html.haml b/app/views/team_members/index.html.haml deleted file mode 100644 index 59c65a66794..00000000000 --- a/app/views/team_members/index.html.haml +++ /dev/null @@ -1,16 +0,0 @@ -%h3.page_title - Users with access to this project - - - if can? current_user, :admin_team_member, @project - %span.pull-right - = link_to import_project_team_members_path(@project), class: "btn btn-small grouped", title: "Import team from another project" do - Import team from another project - = link_to new_project_team_member_path(@project), class: "btn btn-primary small grouped", title: "New Team Member" do - New Team Member - -%p.light - Read more about project permissions - %strong= link_to "here", help_permissions_path, class: "vlink" -- if @group - = render "team_members/group_members" -= render "team_members/team", members: @users_projects diff --git a/app/views/team_members/new.html.haml b/app/views/team_members/new.html.haml deleted file mode 100644 index 4f70fb4b046..00000000000 --- a/app/views/team_members/new.html.haml +++ /dev/null @@ -1 +0,0 @@ -= render "team_members/form" diff --git a/app/views/team_members/update.js.haml b/app/views/team_members/update.js.haml deleted file mode 100644 index c68fe9574a2..00000000000 --- a/app/views/team_members/update.js.haml +++ /dev/null @@ -1,6 +0,0 @@ -- if @user_project_relation.valid? - :plain - $("##{dom_id(@user_project_relation)}").effect("highlight", {color: "#529214"}, 1000);; -- else - :plain - $("##{dom_id(@user_project_relation)}").effect("highlight", {color: "#D12F19"}, 1000);; diff --git a/app/views/tree/_blob_item.html.haml b/app/views/tree/_blob_item.html.haml deleted file mode 100644 index ec15b608f85..00000000000 --- a/app/views/tree/_blob_item.html.haml +++ /dev/null @@ -1,9 +0,0 @@ -%tr{ class: "tree-item #{tree_hex_class(blob_item)}" } - %td.tree-item-file-name - = tree_icon(type) - %strong= link_to truncate(blob_item.name, length: 40), project_blob_path(@project, tree_join(@id || @commit.id, blob_item.name)) - %td.tree_time_ago.cgray - %span.log_loading.hide - Loading commit data... - = image_tag "ajax_loader_tree.gif", width: 14 - %td.tree_commit{ colspan: 2 } diff --git a/app/views/tree/_readme.html.haml b/app/views/tree/_readme.html.haml deleted file mode 100644 index e9bb112745b..00000000000 --- a/app/views/tree/_readme.html.haml +++ /dev/null @@ -1,13 +0,0 @@ -.file_holder#README - .file_title - %i.icon-file - = readme.name - .file_content.wiki - - if gitlab_markdown?(readme.name) - = preserve do - = markdown(readme.data) - - elsif plain_text_readme?(readme.name) - %pre.clean - = readme.data - - else - = raw GitHub::Markup.render(readme.name, readme.data) diff --git a/app/views/tree/_submodule_item.html.haml b/app/views/tree/_submodule_item.html.haml deleted file mode 100644 index 092a024afbc..00000000000 --- a/app/views/tree/_submodule_item.html.haml +++ /dev/null @@ -1,11 +0,0 @@ -- url = submodule_item.url(@ref) rescue '' -- name = submodule_item.basename -- return '' unless url -%tr{ class: "tree-item", url: url } - %td.tree-item-file-name - = image_tag "submodule.png" - %strong= truncate(name, length: 40) - %td - %code= submodule_item.id[0..10] - %td{ colspan: 2 } - = link_to truncate(url, length: 40), url diff --git a/app/views/tree/_tree.html.haml b/app/views/tree/_tree.html.haml deleted file mode 100644 index cc45faa1459..00000000000 --- a/app/views/tree/_tree.html.haml +++ /dev/null @@ -1,51 +0,0 @@ -%ul.breadcrumb - %li - %i.icon-angle-right - = link_to project_tree_path(@project, @ref) do - = @project.path - - tree_breadcrumbs(tree, 6) do |title, path| - \/ - %li - - if path - = link_to truncate(title, length: 40), project_tree_path(@project, path) - - else - = link_to title, '#' - -%div#tree-content-holder.tree-content-holder - %table#tree-slider{class: "table_#{@hex_path} tree-table" } - %thead - %tr - %th Name - %th Last Update - %th - Last Commit -   - %i.icon-angle-right -   - %small.light - = link_to @commit.short_id, project_commit_path(@project, @commit) - – - = truncate(@commit.title, length: 50) - %th= link_to "history", project_commits_path(@project, @id), class: "btn btn-tiny pull-right" - - - if tree.up_dir? - %tr.tree-item - %td.tree-item-file-name - = image_tag "file_empty.png", size: '16x16' - = link_to "..", project_tree_path(@project, up_dir_path(tree)) - %td - %td - %td - - = render_tree(tree) - - - if tree.readme - = render "tree/readme", readme: tree.readme - -%div.tree_progress - -:javascript - // Load last commit log for each file in tree - $('#tree-slider').waitForImages(function() { - ajaxGet('#{@logs_path}'); - }); diff --git a/app/views/tree/_tree_commit_column.html.haml b/app/views/tree/_tree_commit_column.html.haml deleted file mode 100644 index 7ae2582c130..00000000000 --- a/app/views/tree/_tree_commit_column.html.haml +++ /dev/null @@ -1,2 +0,0 @@ -%span.tree_author= commit_author_link(commit, avatar: true) -= link_to_gfm truncate(commit.title, length: 80), project_commit_path(@project, commit.id), class: "tree-commit-link" diff --git a/app/views/tree/_tree_item.html.haml b/app/views/tree/_tree_item.html.haml deleted file mode 100644 index 0a76d5c21b6..00000000000 --- a/app/views/tree/_tree_item.html.haml +++ /dev/null @@ -1,9 +0,0 @@ -%tr{ class: "tree-item #{tree_hex_class(tree_item)}" } - %td.tree-item-file-name - = tree_icon(type) - %strong= link_to truncate(tree_item.name, length: 40), project_tree_path(@project, tree_join(@id || @commit.id, tree_item.name)) - %td.tree_time_ago.cgray - %span.log_loading.hide - Loading commit data... - = image_tag "ajax_loader_tree.gif", width: 14 - %td.tree_commit{ colspan: 2 } diff --git a/app/views/tree/show.html.haml b/app/views/tree/show.html.haml deleted file mode 100644 index 0f7692aba7f..00000000000 --- a/app/views/tree/show.html.haml +++ /dev/null @@ -1,4 +0,0 @@ -%div.tree-ref-holder - = render 'shared/ref_switcher', destination: 'tree', path: @path -%div#tree-holder.tree-holder - = render "tree", tree: @tree diff --git a/app/views/walls/show.html.haml b/app/views/walls/show.html.haml deleted file mode 100644 index 88aecee0815..00000000000 --- a/app/views/walls/show.html.haml +++ /dev/null @@ -1,23 +0,0 @@ -%div.wall-page - %ul.notes - - - if can? current_user, :write_note, @project - .note-form-holder - = form_for [@project, @note], remote: true, html: { multipart: true, id: nil, class: "new_note wall-note-form" } do |f| - = note_target_fields - .note_text_and_preview - = f.text_area :note, size: 255, class: 'note_text js-note-text js-gfm-input turn-on' - .note-form-actions - .buttons - = f.submit 'Add Comment', class: "btn comment-btn grouped js-comment-button" - - .note-form-option - %a.choose-btn.btn.btn-small.js-choose-note-attachment-button - %i.icon-paper-clip - %span Choose File ... -   - %span.file_name.js-attachment-filename File name... - = f.file_field :attachment, class: "js-note-attachment-input hide" - - .hint.pull-right CTRL + Enter to send message - .clearfix diff --git a/app/views/wikis/_form.html.haml b/app/views/wikis/_form.html.haml deleted file mode 100644 index 7cf08815f78..00000000000 --- a/app/views/wikis/_form.html.haml +++ /dev/null @@ -1,36 +0,0 @@ -= form_for [@project, @wiki] do |f| - -if @wiki.errors.any? - #error_explanation - %h2= "#{pluralize(@wiki.errors.count, "error")} prohibited this wiki from being saved:" - %ul - - @wiki.errors.full_messages.each do |msg| - %li= msg - - .ui-box.ui-box-show - .ui-box-head - %h3.page_title - .edit-wiki-header - = @wiki.title.titleize - = f.hidden_field :title, value: @wiki.title - = f.select :format, options_for_select(GollumWiki::MARKUPS, {selected: @wiki.format}), {}, class: "pull-right input-medium" - = f.label :format, class: "pull-right", style: "padding-right: 20px;" - .ui-box-body - .input - %span.cgray - Wiki content is parsed with #{link_to "GitLab Flavored Markdown", help_markdown_path, target: '_blank'}. - To link to a (new) page you can just type - %code [Link Title](page-slug) - \. - - .ui-box-bottom - = f.label :content - .input= f.text_area :content, class: 'span8 js-gfm-input' - .ui-box-bottom - = f.label :commit_message - .input= f.text_field :message, class: 'span8' - .actions - = f.submit 'Save', class: "btn-save btn" - - if @wiki && @wiki.persisted? - = link_to "Cancel", project_wiki_path(@project, @wiki), class: "btn btn-cancel" - - else - = link_to "Cancel", project_wiki_path(@project, :home), class: "btn btn-cancel" diff --git a/app/views/wikis/_main_links.html.haml b/app/views/wikis/_main_links.html.haml deleted file mode 100644 index cb8ccf81c7b..00000000000 --- a/app/views/wikis/_main_links.html.haml +++ /dev/null @@ -1,8 +0,0 @@ -%span.pull-right - - if (@wiki && @wiki.persisted?) - = link_to history_project_wiki_path(@project, @wiki), class: "btn btn-small grouped" do - Page History - - if can?(current_user, :write_wiki, @project) - = link_to edit_project_wiki_path(@project, @wiki), class: "btn btn-small grouped" do - %i.icon-edit - Edit diff --git a/app/views/wikis/_nav.html.haml b/app/views/wikis/_nav.html.haml deleted file mode 100644 index 09a1986e105..00000000000 --- a/app/views/wikis/_nav.html.haml +++ /dev/null @@ -1,19 +0,0 @@ -%ul.nav.nav-tabs - = nav_link(html_options: {class: params[:id] == 'home' ? 'active' : '' }) do - = link_to 'Home', project_wiki_path(@project, :home) - - = nav_link(path: 'wikis#pages') do - = link_to 'Pages', pages_project_wikis_path(@project) - - = nav_link(path: 'wikis#git_access') do - = link_to git_access_project_wikis_path(@project) do - %i.icon-download-alt - Git Access - - - if can?(current_user, :write_wiki, @project) - .pull-right - = link_to '#', class: "add-new-wiki btn btn-small btn-primary" do - %i.icon-plus - New Page - -= render 'wikis/new' diff --git a/app/views/wikis/_new.html.haml b/app/views/wikis/_new.html.haml deleted file mode 100644 index ca8e7c1b4b4..00000000000 --- a/app/views/wikis/_new.html.haml +++ /dev/null @@ -1,12 +0,0 @@ -%div#modal-new-wiki.modal.hide - .modal-header - %a.close{href: "#"} × - %h3.page_title New Wiki Page - .modal-body - = label_tag :new_wiki_path do - %span Page slug - = text_field_tag :new_wiki_path, nil, placeholder: 'how-to-setup', class: 'input-xlarge', required: true, :'data-wikis-path' => project_wikis_path(@project) - %p.hint - Please dont use spaces and slashes - .modal-footer - = link_to 'Build', '#', class: 'build-new-wiki btn btn-create' diff --git a/app/views/wikis/edit.html.haml b/app/views/wikis/edit.html.haml deleted file mode 100644 index cd74a738f8b..00000000000 --- a/app/views/wikis/edit.html.haml +++ /dev/null @@ -1,10 +0,0 @@ -= render 'wikis/nav' -%h3.page_title - Editing page - = render 'main_links' -= render 'form' - -.pull-right - - if @wiki.persisted? && can?(current_user, :admin_wiki, @project) - = link_to project_wiki_path(@project, @wiki), confirm: "Are you sure you want to delete this page?", method: :delete, class: "btn btn-small btn-remove" do - Delete this page diff --git a/app/views/wikis/empty.html.haml b/app/views/wikis/empty.html.haml deleted file mode 100644 index 08b59f0328b..00000000000 --- a/app/views/wikis/empty.html.haml +++ /dev/null @@ -1,4 +0,0 @@ -%h3.page_title Empty page -%hr -.error_message - You are not allowed to create wiki pages diff --git a/app/views/wikis/git_access.html.haml b/app/views/wikis/git_access.html.haml deleted file mode 100644 index 0b363cbb8c9..00000000000 --- a/app/views/wikis/git_access.html.haml +++ /dev/null @@ -1,37 +0,0 @@ -= render 'wikis/nav' -%h3.page_title - Git Access - %strong= @gollum_wiki.path_with_namespace - = render 'main_links' - -%br -.content - .project_clone_panel - .row - .span7 - .form-horizontal - .input-prepend.project_clone_holder - %button{class: "btn active", :"data-clone" => @gollum_wiki.ssh_url_to_repo} SSH - %button{class: "btn", :"data-clone" => @gollum_wiki.http_url_to_repo}= Gitlab.config.gitlab.protocol.upcase - = text_field_tag :project_clone, @gollum_wiki.url_to_repo, class: "one_click_select input-xxlarge", readonly: true - .git-empty - %fieldset - %legend Install Gollum: - %pre.dark - :preserve - gem install gollum - - %legend Clone Your Wiki: - %pre.dark - :preserve - git clone #{@gollum_wiki.ssh_url_to_repo} - cd #{@gollum_wiki.path} - - %legend Start Gollum And Edit Locally: - %pre.dark - :preserve - gollum - == Sinatra/1.3.5 has taken the stage on 4567 for development with backup from Thin - >> Thin web server (v1.5.0 codename Knife) - >> Maximum connections set to 1024 - >> Listening on 0.0.0.0:4567, CTRL+C to stop diff --git a/app/views/wikis/history.html.haml b/app/views/wikis/history.html.haml deleted file mode 100644 index 243c5c7c2c3..00000000000 --- a/app/views/wikis/history.html.haml +++ /dev/null @@ -1,31 +0,0 @@ -= render 'wikis/nav' -%h3.page_title - %span.light History for - = @wiki.title.titleize - = render 'main_links' -%br -%table - %thead - %tr - %th Page version - %th Author - %th Commit Message - %th Last updated - %th Format - %tbody - - @wiki.versions.each do |version| - - commit = version - %tr - %td - = link_to project_wiki_path(@project, @wiki, version_id: commit.id) do - = commit.short_id - %td - = commit_author_link(commit, avatar: true, size: 24) - %td - = commit.title - %td - = time_ago_in_words(version.date) - ago - %td - %strong - = @wiki.page.wiki.page(@wiki.page.name, commit.id).try(:format) diff --git a/app/views/wikis/pages.html.haml b/app/views/wikis/pages.html.haml deleted file mode 100644 index 48c11b8e395..00000000000 --- a/app/views/wikis/pages.html.haml +++ /dev/null @@ -1,25 +0,0 @@ -= render 'wikis/nav' -%h3.page_title - All Pages - = render 'main_links' -%br -%table - %thead - %tr - %th Title - %th Format - %th Last updated - %th Updated by - %tbody - - @wiki_pages.each do |wiki_page| - %tr - %td - %strong= link_to wiki_page.title.titleize, project_wiki_path(@project, wiki_page) - %td - %strong= wiki_page.format - %td - = wiki_page.created_at.to_s(:short) do - (#{time_ago_in_words(wiki_page.created_at)} - ago) - %td - = commit_author_link(wiki_page.version, avatar: true, size: 24) diff --git a/app/views/wikis/show.html.haml b/app/views/wikis/show.html.haml deleted file mode 100644 index b40bbcb4923..00000000000 --- a/app/views/wikis/show.html.haml +++ /dev/null @@ -1,16 +0,0 @@ -= render 'wikis/nav' -%h3.page_title - = @wiki.title.titleize - = render 'main_links' -%br -- if @wiki.historical? - .warning_message - This is an old version of this page. - You can view the #{link_to "most recent version", project_wiki_path(@project, @wiki)} or browse the #{link_to "history", history_project_wiki_path(@project, @wiki)}. - -.file_holder - .file_content.wiki - = preserve do - = render_wiki_content(@wiki) - -%p.time Last edited by #{commit_author_link(@wiki.version, avatar: true, size: 16)} #{time_ago_in_words @wiki.created_at} ago diff --git a/config/routes.rb b/config/routes.rb index 3b6a861b668..a59e6b7ce5b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -160,135 +160,135 @@ Gitlab::Application.routes.draw do get :autocomplete_sources end - resources :blob, only: [:show], constraints: {id: /.+/} - resources :raw, only: [:show], constraints: {id: /.+/} - resources :tree, only: [:show], constraints: {id: /.+/, format: /(html|js)/ } - resources :edit_tree, only: [:show, :update], constraints: {id: /.+/}, path: 'edit' - resources :commit, only: [:show], constraints: {id: /[[:alnum:]]{6,40}/} - resources :commits, only: [:show], constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/} - resources :compare, only: [:index, :create] - resources :blame, only: [:show], constraints: {id: /.+/} - resources :network, only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/} - resources :graphs, only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/} - match "/compare/:from...:to" => "compare#show", as: "compare", via: [:get, :post], constraints: {from: /.+/, to: /.+/} - scope module: :projects do - resources :snippets do - member do - get "raw" + resources :blob, only: [:show], constraints: {id: /.+/} + resources :raw, only: [:show], constraints: {id: /.+/} + resources :tree, only: [:show], constraints: {id: /.+/, format: /(html|js)/ } + resources :edit_tree, only: [:show, :update], constraints: {id: /.+/}, path: 'edit' + resources :commit, only: [:show], constraints: {id: /[[:alnum:]]{6,40}/} + resources :commits, only: [:show], constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/} + resources :compare, only: [:index, :create] + resources :blame, only: [:show], constraints: {id: /.+/} + resources :network, only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/} + resources :graphs, only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/} + match "/compare/:from...:to" => "compare#show", as: "compare", via: [:get, :post], constraints: {from: /.+/, to: /.+/} + + resources :snippets do + member do + get "raw" + end end - end - end - resources :wikis, only: [:show, :edit, :destroy, :create] do - collection do - get :pages - put ':id' => 'wikis#update' - get :git_access - end + resources :wikis, only: [:show, :edit, :destroy, :create] do + collection do + get :pages + put ':id' => 'wikis#update' + get :git_access + end - member do - get "history" + member do + get "history" + end end - end - resource :wall, only: [:show] do - member do - get 'notes' + resource :wall, only: [:show] do + member do + get 'notes' + end end - end - resource :repository, only: [:show] do - member do - get "branches" - get "tags" - get "stats" - get "archive" + resource :repository, only: [:show] do + member do + get "branches" + get "tags" + get "stats" + get "archive" + end end - end - resources :services, constraints: { id: /[^\/]+/ }, only: [:index, :edit, :update] do - member do - get :test + resources :services, constraints: { id: /[^\/]+/ }, only: [:index, :edit, :update] do + member do + get :test + end end - end - resources :deploy_keys do - member do - put :enable - put :disable + resources :deploy_keys do + member do + put :enable + put :disable + end end - end - resources :protected_branches, only: [:index, :create, :destroy] + resources :protected_branches, only: [:index, :create, :destroy] - resources :refs, only: [] do - collection do - get "switch" - end + resources :refs, only: [] do + collection do + get "switch" + end - member do - # tree viewer logs - get "logs_tree", constraints: { id: /[a-zA-Z.\/0-9_\-#%+]+/ } - get "logs_tree/:path" => "refs#logs_tree", - as: :logs_file, - constraints: { - id: /[a-zA-Z.0-9\/_\-#%+]+/, - path: /.*/ - } + member do + # tree viewer logs + get "logs_tree", constraints: { id: /[a-zA-Z.\/0-9_\-#%+]+/ } + get "logs_tree/:path" => "refs#logs_tree", + as: :logs_file, + constraints: { + id: /[a-zA-Z.0-9\/_\-#%+]+/, + path: /.*/ + } + end end - end - resources :merge_requests, constraints: {id: /\d+/}, except: [:destroy] do - member do - get :diffs - get :automerge - get :automerge_check - get :ci_status - end + resources :merge_requests, constraints: {id: /\d+/}, except: [:destroy] do + member do + get :diffs + get :automerge + get :automerge_check + get :ci_status + end - collection do - get :branch_from - get :branch_to + collection do + get :branch_from + get :branch_to + end end - end - resources :hooks, only: [:index, :create, :destroy] do - member do - get :test + resources :hooks, only: [:index, :create, :destroy] do + member do + get :test + end end - end - resources :team, controller: 'team_members', only: [:index] - resources :milestones, except: [:destroy] + resources :team, controller: 'team_members', only: [:index] + resources :milestones, except: [:destroy] - resources :labels, only: [:index] do - collection do - post :generate + resources :labels, only: [:index] do + collection do + post :generate + end end - end - resources :issues, except: [:destroy] do - collection do - post :bulk_update + resources :issues, except: [:destroy] do + collection do + post :bulk_update + end end - end - resources :team_members, except: [:index, :edit] do - collection do + resources :team_members, except: [:index, :edit] do + collection do - # Used for import team - # from another project - get :import - post :apply_import + # Used for import team + # from another project + get :import + post :apply_import + end end - end - resources :notes, only: [:index, :create, :destroy] do - collection do - post :preview + resources :notes, only: [:index, :create, :destroy] do + collection do + post :preview + end + end end - end end root to: "dashboard#show" -- cgit v1.2.1 From 40bca5246b6e1cea36932c5e0eae89a63d8f0a03 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sun, 23 Jun 2013 20:25:06 +0300 Subject: Fix routing/controller specs for refactored controllers --- spec/controllers/blob_controller_spec.rb | 2 +- spec/controllers/commit_controller_spec.rb | 2 +- spec/controllers/commits_controller_spec.rb | 2 +- spec/controllers/merge_requests_controller_spec.rb | 4 +- spec/controllers/tree_controller_spec.rb | 2 +- spec/routing/project_routing_spec.rb | 188 ++++++++++----------- 6 files changed, 100 insertions(+), 100 deletions(-) diff --git a/spec/controllers/blob_controller_spec.rb b/spec/controllers/blob_controller_spec.rb index fe113459470..05d16f35545 100644 --- a/spec/controllers/blob_controller_spec.rb +++ b/spec/controllers/blob_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe BlobController do +describe Projects::BlobController do let(:project) { create(:project_with_code) } let(:user) { create(:user) } diff --git a/spec/controllers/commit_controller_spec.rb b/spec/controllers/commit_controller_spec.rb index 5fffbf0e5f3..87c54143a05 100644 --- a/spec/controllers/commit_controller_spec.rb +++ b/spec/controllers/commit_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe CommitController do +describe Projects::CommitController do let(:project) { create(:project_with_code) } let(:user) { create(:user) } let(:commit) { project.repository.last_commit_for("master") } diff --git a/spec/controllers/commits_controller_spec.rb b/spec/controllers/commits_controller_spec.rb index ce4029173a5..c9931a19622 100644 --- a/spec/controllers/commits_controller_spec.rb +++ b/spec/controllers/commits_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe CommitsController do +describe Projects::CommitsController do let(:project) { create(:project_with_code) } let(:user) { create(:user) } diff --git a/spec/controllers/merge_requests_controller_spec.rb b/spec/controllers/merge_requests_controller_spec.rb index 796de23bfe3..51ba6ca5945 100644 --- a/spec/controllers/merge_requests_controller_spec.rb +++ b/spec/controllers/merge_requests_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe MergeRequestsController do +describe Projects::MergeRequestsController do let(:project) { create(:project_with_code) } let(:user) { create(:user) } let(:merge_request) { create(:merge_request_with_diffs, project: project, target_branch: "bcf03b5d~3", source_branch: "bcf03b5d") } @@ -8,7 +8,7 @@ describe MergeRequestsController do before do sign_in(user) project.team << [user, :master] - MergeRequestsController.any_instance.stub(validates_merge_request: true) + Projects::MergeRequestsController.any_instance.stub(validates_merge_request: true) end describe "#show" do diff --git a/spec/controllers/tree_controller_spec.rb b/spec/controllers/tree_controller_spec.rb index f9fe4fe2010..3e41b406c4f 100644 --- a/spec/controllers/tree_controller_spec.rb +++ b/spec/controllers/tree_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe TreeController do +describe Projects::TreeController do let(:project) { create(:project_with_code) } let(:user) { create(:user) } diff --git a/spec/routing/project_routing_spec.rb b/spec/routing/project_routing_spec.rb index 7f88029de52..2a1f780f0f4 100644 --- a/spec/routing/project_routing_spec.rb +++ b/spec/routing/project_routing_spec.rb @@ -25,31 +25,31 @@ shared_examples "RESTful project resources" do let(:actions) { [:index, :create, :new, :edit, :show, :update, :destroy] } it "to #index" do - get("/gitlabhq/#{controller}").should route_to("#{controller}#index", project_id: 'gitlabhq') if actions.include?(:index) + get("/gitlabhq/#{controller}").should route_to("projects/#{controller}#index", project_id: 'gitlabhq') if actions.include?(:index) end it "to #create" do - post("/gitlabhq/#{controller}").should route_to("#{controller}#create", project_id: 'gitlabhq') if actions.include?(:create) + post("/gitlabhq/#{controller}").should route_to("projects/#{controller}#create", project_id: 'gitlabhq') if actions.include?(:create) end it "to #new" do - get("/gitlabhq/#{controller}/new").should route_to("#{controller}#new", project_id: 'gitlabhq') if actions.include?(:new) + get("/gitlabhq/#{controller}/new").should route_to("projects/#{controller}#new", project_id: 'gitlabhq') if actions.include?(:new) end it "to #edit" do - get("/gitlabhq/#{controller}/1/edit").should route_to("#{controller}#edit", project_id: 'gitlabhq', id: '1') if actions.include?(:edit) + get("/gitlabhq/#{controller}/1/edit").should route_to("projects/#{controller}#edit", project_id: 'gitlabhq', id: '1') if actions.include?(:edit) end it "to #show" do - get("/gitlabhq/#{controller}/1").should route_to("#{controller}#show", project_id: 'gitlabhq', id: '1') if actions.include?(:show) + get("/gitlabhq/#{controller}/1").should route_to("projects/#{controller}#show", project_id: 'gitlabhq', id: '1') if actions.include?(:show) end it "to #update" do - put("/gitlabhq/#{controller}/1").should route_to("#{controller}#update", project_id: 'gitlabhq', id: '1') if actions.include?(:update) + put("/gitlabhq/#{controller}/1").should route_to("projects/#{controller}#update", project_id: 'gitlabhq', id: '1') if actions.include?(:update) end it "to #destroy" do - delete("/gitlabhq/#{controller}/1").should route_to("#{controller}#destroy", project_id: 'gitlabhq', id: '1') if actions.include?(:destroy) + delete("/gitlabhq/#{controller}/1").should route_to("projects/#{controller}#destroy", project_id: 'gitlabhq', id: '1') if actions.include?(:destroy) end end @@ -76,7 +76,7 @@ describe ProjectsController, "routing" do end it "to #wall" do - get("/gitlabhq/wall").should route_to('walls#show', project_id: 'gitlabhq') + get("/gitlabhq/wall").should route_to('projects/walls#show', project_id: 'gitlabhq') end it "to #edit" do @@ -100,19 +100,19 @@ describe ProjectsController, "routing" do end end -# pages_project_wikis GET /:project_id/wikis/pages(.:format) wikis#pages -# history_project_wiki GET /:project_id/wikis/:id/history(.:format) wikis#history -# project_wikis POST /:project_id/wikis(.:format) wikis#create -# edit_project_wiki GET /:project_id/wikis/:id/edit(.:format) wikis#edit -# project_wiki GET /:project_id/wikis/:id(.:format) wikis#show -# DELETE /:project_id/wikis/:id(.:format) wikis#destroy -describe WikisController, "routing" do +# pages_project_wikis GET /:project_id/wikis/pages(.:format) projects/wikis#pages +# history_project_wiki GET /:project_id/wikis/:id/history(.:format) projects/wikis#history +# project_wikis POST /:project_id/wikis(.:format) projects/wikis#create +# edit_project_wiki GET /:project_id/wikis/:id/edit(.:format) projects/wikis#edit +# project_wiki GET /:project_id/wikis/:id(.:format) projects/wikis#show +# DELETE /:project_id/wikis/:id(.:format) projects/wikis#destroy +describe Projects::WikisController, "routing" do it "to #pages" do - get("/gitlabhq/wikis/pages").should route_to('wikis#pages', project_id: 'gitlabhq') + get("/gitlabhq/wikis/pages").should route_to('projects/wikis#pages', project_id: 'gitlabhq') end it "to #history" do - get("/gitlabhq/wikis/1/history").should route_to('wikis#history', project_id: 'gitlabhq', id: '1') + get("/gitlabhq/wikis/1/history").should route_to('projects/wikis#history', project_id: 'gitlabhq', id: '1') end it_behaves_like "RESTful project resources" do @@ -121,25 +121,25 @@ describe WikisController, "routing" do end end -# branches_project_repository GET /:project_id/repository/branches(.:format) repositories#branches -# tags_project_repository GET /:project_id/repository/tags(.:format) repositories#tags -# archive_project_repository GET /:project_id/repository/archive(.:format) repositories#archive -# edit_project_repository GET /:project_id/repository/edit(.:format) repositories#edit -describe RepositoriesController, "routing" do +# branches_project_repository GET /:project_id/repository/branches(.:format) projects/repositories#branches +# tags_project_repository GET /:project_id/repository/tags(.:format) projects/repositories#tags +# archive_project_repository GET /:project_id/repository/archive(.:format) projects/repositories#archive +# edit_project_repository GET /:project_id/repository/edit(.:format) projects/repositories#edit +describe Projects::RepositoriesController, "routing" do it "to #branches" do - get("/gitlabhq/repository/branches").should route_to('repositories#branches', project_id: 'gitlabhq') + get("/gitlabhq/repository/branches").should route_to('projects/repositories#branches', project_id: 'gitlabhq') end it "to #tags" do - get("/gitlabhq/repository/tags").should route_to('repositories#tags', project_id: 'gitlabhq') + get("/gitlabhq/repository/tags").should route_to('projects/repositories#tags', project_id: 'gitlabhq') end it "to #archive" do - get("/gitlabhq/repository/archive").should route_to('repositories#archive', project_id: 'gitlabhq') + get("/gitlabhq/repository/archive").should route_to('projects/repositories#archive', project_id: 'gitlabhq') end it "to #show" do - get("/gitlabhq/repository").should route_to('repositories#show', project_id: 'gitlabhq') + get("/gitlabhq/repository").should route_to('projects/repositories#show', project_id: 'gitlabhq') end end @@ -150,7 +150,7 @@ end # project_deploy_key GET /:project_id/deploy_keys/:id(.:format) deploy_keys#show # PUT /:project_id/deploy_keys/:id(.:format) deploy_keys#update # DELETE /:project_id/deploy_keys/:id(.:format) deploy_keys#destroy -describe DeployKeysController, "routing" do +describe Projects::DeployKeysController, "routing" do it_behaves_like "RESTful project resources" do let(:controller) { 'deploy_keys' } end @@ -159,7 +159,7 @@ end # project_protected_branches GET /:project_id/protected_branches(.:format) protected_branches#index # POST /:project_id/protected_branches(.:format) protected_branches#create # project_protected_branch DELETE /:project_id/protected_branches/:id(.:format) protected_branches#destroy -describe ProtectedBranchesController, "routing" do +describe Projects::ProtectedBranchesController, "routing" do it_behaves_like "RESTful project resources" do let(:actions) { [:index, :create, :destroy] } let(:controller) { 'protected_branches' } @@ -169,58 +169,58 @@ end # switch_project_refs GET /:project_id/refs/switch(.:format) refs#switch # logs_tree_project_ref GET /:project_id/refs/:id/logs_tree(.:format) refs#logs_tree # logs_file_project_ref GET /:project_id/refs/:id/logs_tree/:path(.:format) refs#logs_tree -describe RefsController, "routing" do +describe Projects::RefsController, "routing" do it "to #switch" do - get("/gitlabhq/refs/switch").should route_to('refs#switch', project_id: 'gitlabhq') + get("/gitlabhq/refs/switch").should route_to('projects/refs#switch', project_id: 'gitlabhq') end it "to #logs_tree" do - get("/gitlabhq/refs/stable/logs_tree").should route_to('refs#logs_tree', project_id: 'gitlabhq', id: 'stable') - get("/gitlabhq/refs/feature%2345/logs_tree").should route_to('refs#logs_tree', project_id: 'gitlabhq', id: 'feature#45') - get("/gitlabhq/refs/feature%2B45/logs_tree").should route_to('refs#logs_tree', project_id: 'gitlabhq', id: 'feature+45') - get("/gitlabhq/refs/stable/logs_tree/foo/bar/baz").should route_to('refs#logs_tree', project_id: 'gitlabhq', id: 'stable', path: 'foo/bar/baz') - get("/gitlabhq/refs/feature%2345/logs_tree/foo/bar/baz").should route_to('refs#logs_tree', project_id: 'gitlabhq', id: 'feature#45', path: 'foo/bar/baz') - get("/gitlabhq/refs/feature%2B45/logs_tree/foo/bar/baz").should route_to('refs#logs_tree', project_id: 'gitlabhq', id: 'feature+45', path: 'foo/bar/baz') - get("/gitlab/gitlabhq/refs/stable/logs_tree/files.scss").should route_to('refs#logs_tree', project_id: 'gitlab/gitlabhq', id: 'stable', path: 'files.scss') + get("/gitlabhq/refs/stable/logs_tree").should route_to('projects/refs#logs_tree', project_id: 'gitlabhq', id: 'stable') + get("/gitlabhq/refs/feature%2345/logs_tree").should route_to('projects/refs#logs_tree', project_id: 'gitlabhq', id: 'feature#45') + get("/gitlabhq/refs/feature%2B45/logs_tree").should route_to('projects/refs#logs_tree', project_id: 'gitlabhq', id: 'feature+45') + get("/gitlabhq/refs/stable/logs_tree/foo/bar/baz").should route_to('projects/refs#logs_tree', project_id: 'gitlabhq', id: 'stable', path: 'foo/bar/baz') + get("/gitlabhq/refs/feature%2345/logs_tree/foo/bar/baz").should route_to('projects/refs#logs_tree', project_id: 'gitlabhq', id: 'feature#45', path: 'foo/bar/baz') + get("/gitlabhq/refs/feature%2B45/logs_tree/foo/bar/baz").should route_to('projects/refs#logs_tree', project_id: 'gitlabhq', id: 'feature+45', path: 'foo/bar/baz') + get("/gitlab/gitlabhq/refs/stable/logs_tree/files.scss").should route_to('projects/refs#logs_tree', project_id: 'gitlab/gitlabhq', id: 'stable', path: 'files.scss') end end -# diffs_project_merge_request GET /:project_id/merge_requests/:id/diffs(.:format) merge_requests#diffs -# automerge_project_merge_request GET /:project_id/merge_requests/:id/automerge(.:format) merge_requests#automerge -# automerge_check_project_merge_request GET /:project_id/merge_requests/:id/automerge_check(.:format) merge_requests#automerge_check -# branch_from_project_merge_requests GET /:project_id/merge_requests/branch_from(.:format) merge_requests#branch_from -# branch_to_project_merge_requests GET /:project_id/merge_requests/branch_to(.:format) merge_requests#branch_to -# project_merge_requests GET /:project_id/merge_requests(.:format) merge_requests#index -# POST /:project_id/merge_requests(.:format) merge_requests#create -# new_project_merge_request GET /:project_id/merge_requests/new(.:format) merge_requests#new -# edit_project_merge_request GET /:project_id/merge_requests/:id/edit(.:format) merge_requests#edit -# project_merge_request GET /:project_id/merge_requests/:id(.:format) merge_requests#show -# PUT /:project_id/merge_requests/:id(.:format) merge_requests#update -# DELETE /:project_id/merge_requests/:id(.:format) merge_requests#destroy -describe MergeRequestsController, "routing" do +# diffs_project_merge_request GET /:project_id/merge_requests/:id/diffs(.:format) projects/merge_requests#diffs +# automerge_project_merge_request GET /:project_id/merge_requests/:id/automerge(.:format) projects/merge_requests#automerge +# automerge_check_project_merge_request GET /:project_id/merge_requests/:id/automerge_check(.:format) projects/merge_requests#automerge_check +# branch_from_project_merge_requests GET /:project_id/merge_requests/branch_from(.:format) projects/merge_requests#branch_from +# branch_to_project_merge_requests GET /:project_id/merge_requests/branch_to(.:format) projects/merge_requests#branch_to +# project_merge_requests GET /:project_id/merge_requests(.:format) projects/merge_requests#index +# POST /:project_id/merge_requests(.:format) projects/merge_requests#create +# new_project_merge_request GET /:project_id/merge_requests/new(.:format) projects/merge_requests#new +# edit_project_merge_request GET /:project_id/merge_requests/:id/edit(.:format) projects/merge_requests#edit +# project_merge_request GET /:project_id/merge_requests/:id(.:format) projects/merge_requests#show +# PUT /:project_id/merge_requests/:id(.:format) projects/merge_requests#update +# DELETE /:project_id/merge_requests/:id(.:format) projects/merge_requests#destroy +describe Projects::MergeRequestsController, "routing" do it "to #diffs" do - get("/gitlabhq/merge_requests/1/diffs").should route_to('merge_requests#diffs', project_id: 'gitlabhq', id: '1') + get("/gitlabhq/merge_requests/1/diffs").should route_to('projects/merge_requests#diffs', project_id: 'gitlabhq', id: '1') end it "to #automerge" do - get("/gitlabhq/merge_requests/1/automerge").should route_to('merge_requests#automerge', project_id: 'gitlabhq', id: '1') + get("/gitlabhq/merge_requests/1/automerge").should route_to('projects/merge_requests#automerge', project_id: 'gitlabhq', id: '1') end it "to #automerge_check" do - get("/gitlabhq/merge_requests/1/automerge_check").should route_to('merge_requests#automerge_check', project_id: 'gitlabhq', id: '1') + get("/gitlabhq/merge_requests/1/automerge_check").should route_to('projects/merge_requests#automerge_check', project_id: 'gitlabhq', id: '1') end it "to #branch_from" do - get("/gitlabhq/merge_requests/branch_from").should route_to('merge_requests#branch_from', project_id: 'gitlabhq') + get("/gitlabhq/merge_requests/branch_from").should route_to('projects/merge_requests#branch_from', project_id: 'gitlabhq') end it "to #branch_to" do - get("/gitlabhq/merge_requests/branch_to").should route_to('merge_requests#branch_to', project_id: 'gitlabhq') + get("/gitlabhq/merge_requests/branch_to").should route_to('projects/merge_requests#branch_to', project_id: 'gitlabhq') end it "to #show" do - get("/gitlabhq/merge_requests/1.diff").should route_to('merge_requests#show', project_id: 'gitlabhq', id: '1', format: 'diff') - get("/gitlabhq/merge_requests/1.patch").should route_to('merge_requests#show', project_id: 'gitlabhq', id: '1', format: 'patch') + get("/gitlabhq/merge_requests/1.diff").should route_to('projects/merge_requests#show', project_id: 'gitlabhq', id: '1', format: 'diff') + get("/gitlabhq/merge_requests/1.patch").should route_to('projects/merge_requests#show', project_id: 'gitlabhq', id: '1', format: 'patch') end it_behaves_like "RESTful project resources" do @@ -275,9 +275,9 @@ end # project_hooks GET /:project_id/hooks(.:format) hooks#index # POST /:project_id/hooks(.:format) hooks#create # project_hook DELETE /:project_id/hooks/:id(.:format) hooks#destroy -describe HooksController, "routing" do +describe Projects::HooksController, "routing" do it "to #test" do - get("/gitlabhq/hooks/1/test").should route_to('hooks#test', project_id: 'gitlabhq', id: '1') + get("/gitlabhq/hooks/1/test").should route_to('projects/hooks#test', project_id: 'gitlabhq', id: '1') end it_behaves_like "RESTful project resources" do @@ -287,12 +287,12 @@ describe HooksController, "routing" do end # project_commit GET /:project_id/commit/:id(.:format) commit#show {id: /[[:alnum:]]{6,40}/, project_id: /[^\/]+/} -describe CommitController, "routing" do +describe Projects::CommitController, "routing" do it "to #show" do - get("/gitlabhq/commit/4246fb").should route_to('commit#show', project_id: 'gitlabhq', id: '4246fb') - get("/gitlabhq/commit/4246fb.diff").should route_to('commit#show', project_id: 'gitlabhq', id: '4246fb', format: 'diff') - get("/gitlabhq/commit/4246fb.patch").should route_to('commit#show', project_id: 'gitlabhq', id: '4246fb', format: 'patch') - get("/gitlabhq/commit/4246fbd13872934f72a8fd0d6fb1317b47b59cb5").should route_to('commit#show', project_id: 'gitlabhq', id: '4246fbd13872934f72a8fd0d6fb1317b47b59cb5') + get("/gitlabhq/commit/4246fb").should route_to('projects/commit#show', project_id: 'gitlabhq', id: '4246fb') + get("/gitlabhq/commit/4246fb.diff").should route_to('projects/commit#show', project_id: 'gitlabhq', id: '4246fb', format: 'diff') + get("/gitlabhq/commit/4246fb.patch").should route_to('projects/commit#show', project_id: 'gitlabhq', id: '4246fb', format: 'patch') + get("/gitlabhq/commit/4246fbd13872934f72a8fd0d6fb1317b47b59cb5").should route_to('projects/commit#show', project_id: 'gitlabhq', id: '4246fbd13872934f72a8fd0d6fb1317b47b59cb5') end end @@ -300,14 +300,14 @@ end # project_commits GET /:project_id/commits(.:format) commits#index # POST /:project_id/commits(.:format) commits#create # project_commit GET /:project_id/commits/:id(.:format) commits#show -describe CommitsController, "routing" do +describe Projects::CommitsController, "routing" do it_behaves_like "RESTful project resources" do let(:actions) { [:show] } let(:controller) { 'commits' } end it "to #show" do - get("/gitlab/gitlabhq/commits/master.atom").should route_to('commits#show', project_id: 'gitlab/gitlabhq', id: "master", format: "atom") + get("/gitlab/gitlabhq/commits/master.atom").should route_to('projects/commits#show', project_id: 'gitlab/gitlabhq', id: "master", format: "atom") end end @@ -318,7 +318,7 @@ end # project_team_member GET /:project_id/team_members/:id(.:format) team_members#show # PUT /:project_id/team_members/:id(.:format) team_members#update # DELETE /:project_id/team_members/:id(.:format) team_members#destroy -describe TeamMembersController, "routing" do +describe Projects::TeamMembersController, "routing" do it_behaves_like "RESTful project resources" do let(:actions) { [:new, :create, :update, :destroy] } let(:controller) { 'team_members' } @@ -332,7 +332,7 @@ end # project_milestone GET /:project_id/milestones/:id(.:format) milestones#show # PUT /:project_id/milestones/:id(.:format) milestones#update # DELETE /:project_id/milestones/:id(.:format) milestones#destroy -describe MilestonesController, "routing" do +describe Projects::MilestonesController, "routing" do it_behaves_like "RESTful project resources" do let(:controller) { 'milestones' } let(:actions) { [:index, :create, :new, :edit, :show, :update] } @@ -340,9 +340,9 @@ describe MilestonesController, "routing" do end # project_labels GET /:project_id/labels(.:format) labels#index -describe LabelsController, "routing" do +describe Projects::LabelsController, "routing" do it "to #index" do - get("/gitlabhq/labels").should route_to('labels#index', project_id: 'gitlabhq') + get("/gitlabhq/labels").should route_to('projects/labels#index', project_id: 'gitlabhq') end end @@ -356,9 +356,9 @@ end # project_issue GET /:project_id/issues/:id(.:format) issues#show # PUT /:project_id/issues/:id(.:format) issues#update # DELETE /:project_id/issues/:id(.:format) issues#destroy -describe IssuesController, "routing" do +describe Projects::IssuesController, "routing" do it "to #bulk_update" do - post("/gitlabhq/issues/bulk_update").should route_to('issues#bulk_update', project_id: 'gitlabhq') + post("/gitlabhq/issues/bulk_update").should route_to('projects/issues#bulk_update', project_id: 'gitlabhq') end it_behaves_like "RESTful project resources" do @@ -371,9 +371,9 @@ end # project_notes GET /:project_id/notes(.:format) notes#index # POST /:project_id/notes(.:format) notes#create # project_note DELETE /:project_id/notes/:id(.:format) notes#destroy -describe NotesController, "routing" do +describe Projects::NotesController, "routing" do it "to #preview" do - post("/gitlabhq/notes/preview").should route_to('notes#preview', project_id: 'gitlabhq') + post("/gitlabhq/notes/preview").should route_to('projects/notes#preview', project_id: 'gitlabhq') end it_behaves_like "RESTful project resources" do @@ -383,57 +383,57 @@ describe NotesController, "routing" do end # project_blame GET /:project_id/blame/:id(.:format) blame#show {id: /.+/, project_id: /[^\/]+/} -describe BlameController, "routing" do +describe Projects::BlameController, "routing" do it "to #show" do - get("/gitlabhq/blame/master/app/models/project.rb").should route_to('blame#show', project_id: 'gitlabhq', id: 'master/app/models/project.rb') - get("/gitlab/gitlabhq/blame/master/files.scss").should route_to('blame#show', project_id: 'gitlab/gitlabhq', id: 'master/files.scss') + get("/gitlabhq/blame/master/app/models/project.rb").should route_to('projects/blame#show', project_id: 'gitlabhq', id: 'master/app/models/project.rb') + get("/gitlab/gitlabhq/blame/master/files.scss").should route_to('projects/blame#show', project_id: 'gitlab/gitlabhq', id: 'master/files.scss') end end # project_blob GET /:project_id/blob/:id(.:format) blob#show {id: /.+/, project_id: /[^\/]+/} -describe BlobController, "routing" do +describe Projects::BlobController, "routing" do it "to #show" do - get("/gitlabhq/blob/master/app/models/project.rb").should route_to('blob#show', project_id: 'gitlabhq', id: 'master/app/models/project.rb') - get("/gitlabhq/blob/master/app/models/compare.rb").should route_to('blob#show', project_id: 'gitlabhq', id: 'master/app/models/compare.rb') - get("/gitlab/gitlabhq/blob/master/files.scss").should route_to('blob#show', project_id: 'gitlab/gitlabhq', id: 'master/files.scss') + get("/gitlabhq/blob/master/app/models/project.rb").should route_to('projects/blob#show', project_id: 'gitlabhq', id: 'master/app/models/project.rb') + get("/gitlabhq/blob/master/app/models/compare.rb").should route_to('projects/blob#show', project_id: 'gitlabhq', id: 'master/app/models/compare.rb') + get("/gitlab/gitlabhq/blob/master/files.scss").should route_to('projects/blob#show', project_id: 'gitlab/gitlabhq', id: 'master/files.scss') end end # project_tree GET /:project_id/tree/:id(.:format) tree#show {id: /.+/, project_id: /[^\/]+/} -describe TreeController, "routing" do +describe Projects::TreeController, "routing" do it "to #show" do - get("/gitlabhq/tree/master/app/models/project.rb").should route_to('tree#show', project_id: 'gitlabhq', id: 'master/app/models/project.rb') - get("/gitlab/gitlabhq/tree/master/files.scss").should route_to('tree#show', project_id: 'gitlab/gitlabhq', id: 'master/files.scss') + get("/gitlabhq/tree/master/app/models/project.rb").should route_to('projects/tree#show', project_id: 'gitlabhq', id: 'master/app/models/project.rb') + get("/gitlab/gitlabhq/tree/master/files.scss").should route_to('projects/tree#show', project_id: 'gitlab/gitlabhq', id: 'master/files.scss') end end # project_compare_index GET /:project_id/compare(.:format) compare#index {id: /[^\/]+/, project_id: /[^\/]+/} # POST /:project_id/compare(.:format) compare#create {id: /[^\/]+/, project_id: /[^\/]+/} # project_compare /:project_id/compare/:from...:to(.:format) compare#show {from: /.+/, to: /.+/, id: /[^\/]+/, project_id: /[^\/]+/} -describe CompareController, "routing" do +describe Projects::CompareController, "routing" do it "to #index" do - get("/gitlabhq/compare").should route_to('compare#index', project_id: 'gitlabhq') + get("/gitlabhq/compare").should route_to('projects/compare#index', project_id: 'gitlabhq') end it "to #compare" do - post("/gitlabhq/compare").should route_to('compare#create', project_id: 'gitlabhq') + post("/gitlabhq/compare").should route_to('projects/compare#create', project_id: 'gitlabhq') end it "to #show" do - get("/gitlabhq/compare/master...stable").should route_to('compare#show', project_id: 'gitlabhq', from: 'master', to: 'stable') - get("/gitlabhq/compare/issue/1234...stable").should route_to('compare#show', project_id: 'gitlabhq', from: 'issue/1234', to: 'stable') + get("/gitlabhq/compare/master...stable").should route_to('projects/compare#show', project_id: 'gitlabhq', from: 'master', to: 'stable') + get("/gitlabhq/compare/issue/1234...stable").should route_to('projects/compare#show', project_id: 'gitlabhq', from: 'issue/1234', to: 'stable') end end -describe NetworkController, "routing" do +describe Projects::NetworkController, "routing" do it "to #show" do - get("/gitlabhq/network/master").should route_to('network#show', project_id: 'gitlabhq', id: 'master') - get("/gitlabhq/network/master.json").should route_to('network#show', project_id: 'gitlabhq', id: 'master', format: "json") + get("/gitlabhq/network/master").should route_to('projects/network#show', project_id: 'gitlabhq', id: 'master') + get("/gitlabhq/network/master.json").should route_to('projects/network#show', project_id: 'gitlabhq', id: 'master', format: "json") end end -describe GraphsController, "routing" do +describe Projects::GraphsController, "routing" do it "to #show" do - get("/gitlabhq/graphs/master").should route_to('graphs#show', project_id: 'gitlabhq', id: 'master') + get("/gitlabhq/graphs/master").should route_to('projects/graphs#show', project_id: 'gitlabhq', id: 'master') end end -- cgit v1.2.1 From 3e09e6f7b8032859a82266282dfd35715b3b3727 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 24 Jun 2013 18:24:14 +0300 Subject: Move Profile related controllers under Profiles:: module --- app/controllers/keys_controller.rb | 35 ------------- app/controllers/notifications_controller.rb | 26 ---------- app/controllers/passwords_controller.rb | 38 -------------- app/controllers/profiles/keys_controller.rb | 35 +++++++++++++ .../profiles/notifications_controller.rb | 26 ++++++++++ app/controllers/profiles/passwords_controller.rb | 38 ++++++++++++++ app/helpers/application_helper.rb | 2 +- app/views/keys/_form.html.haml | 24 --------- app/views/keys/_show.html.haml | 12 ----- app/views/keys/edit.html.haml | 7 --- app/views/keys/index.html.haml | 22 -------- app/views/keys/new.html.haml | 14 ----- app/views/keys/show.html.haml | 14 ----- app/views/layouts/nav/_profile.html.haml | 2 +- app/views/notifications/_settings.html.haml | 29 ----------- app/views/notifications/show.html.haml | 60 ---------------------- app/views/notifications/update.js.haml | 6 --- app/views/passwords/new.html.haml | 22 -------- app/views/profiles/keys/_form.html.haml | 24 +++++++++ app/views/profiles/keys/_key.html.haml | 12 +++++ app/views/profiles/keys/edit.html.haml | 7 +++ app/views/profiles/keys/index.html.haml | 21 ++++++++ app/views/profiles/keys/new.html.haml | 14 +++++ app/views/profiles/keys/show.html.haml | 14 +++++ .../profiles/notifications/_settings.html.haml | 29 +++++++++++ app/views/profiles/notifications/show.html.haml | 60 ++++++++++++++++++++++ app/views/profiles/notifications/update.js.haml | 6 +++ app/views/profiles/passwords/new.html.haml | 22 ++++++++ app/views/profiles/show.html.haml | 4 +- config/routes.rb | 8 +-- features/steps/profile/profile_ssh_keys.rb | 4 +- features/steps/shared/paths.rb | 2 +- spec/routing/notifications_routing_spec.rb | 6 +-- spec/routing/routing_spec.rb | 16 +++--- 34 files changed, 331 insertions(+), 330 deletions(-) delete mode 100644 app/controllers/keys_controller.rb delete mode 100644 app/controllers/notifications_controller.rb delete mode 100644 app/controllers/passwords_controller.rb create mode 100644 app/controllers/profiles/keys_controller.rb create mode 100644 app/controllers/profiles/notifications_controller.rb create mode 100644 app/controllers/profiles/passwords_controller.rb delete mode 100644 app/views/keys/_form.html.haml delete mode 100644 app/views/keys/_show.html.haml delete mode 100644 app/views/keys/edit.html.haml delete mode 100644 app/views/keys/index.html.haml delete mode 100644 app/views/keys/new.html.haml delete mode 100644 app/views/keys/show.html.haml delete mode 100644 app/views/notifications/_settings.html.haml delete mode 100644 app/views/notifications/show.html.haml delete mode 100644 app/views/notifications/update.js.haml delete mode 100644 app/views/passwords/new.html.haml create mode 100644 app/views/profiles/keys/_form.html.haml create mode 100644 app/views/profiles/keys/_key.html.haml create mode 100644 app/views/profiles/keys/edit.html.haml create mode 100644 app/views/profiles/keys/index.html.haml create mode 100644 app/views/profiles/keys/new.html.haml create mode 100644 app/views/profiles/keys/show.html.haml create mode 100644 app/views/profiles/notifications/_settings.html.haml create mode 100644 app/views/profiles/notifications/show.html.haml create mode 100644 app/views/profiles/notifications/update.js.haml create mode 100644 app/views/profiles/passwords/new.html.haml diff --git a/app/controllers/keys_controller.rb b/app/controllers/keys_controller.rb deleted file mode 100644 index 1a25d834e12..00000000000 --- a/app/controllers/keys_controller.rb +++ /dev/null @@ -1,35 +0,0 @@ -class KeysController < ApplicationController - layout "profile" - respond_to :js, :html - - def index - @keys = current_user.keys.all - end - - def show - @key = current_user.keys.find(params[:id]) - end - - def new - @key = current_user.keys.new - - respond_with(@key) - end - - def create - @key = current_user.keys.new(params[:key]) - @key.save - - respond_with(@key) - end - - def destroy - @key = current_user.keys.find(params[:id]) - @key.destroy - - respond_to do |format| - format.html { redirect_to keys_url } - format.js { render nothing: true } - end - end -end diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb deleted file mode 100644 index 370bdaa2fa1..00000000000 --- a/app/controllers/notifications_controller.rb +++ /dev/null @@ -1,26 +0,0 @@ -class NotificationsController < ApplicationController - layout 'profile' - - def show - @notification = current_user.notification - @users_projects = current_user.users_projects - @users_groups = current_user.users_groups - end - - def update - type = params[:notification_type] - - @saved = if type == 'global' - current_user.notification_level = params[:notification_level] - current_user.save - elsif type == 'group' - users_group = current_user.users_groups.find(params[:notification_id]) - users_group.notification_level = params[:notification_level] - users_group.save - else - users_project = current_user.users_projects.find(params[:notification_id]) - users_project.notification_level = params[:notification_level] - users_project.save - end - end -end diff --git a/app/controllers/passwords_controller.rb b/app/controllers/passwords_controller.rb deleted file mode 100644 index 0e5b42178a7..00000000000 --- a/app/controllers/passwords_controller.rb +++ /dev/null @@ -1,38 +0,0 @@ -class PasswordsController < ApplicationController - layout 'navless' - - skip_before_filter :check_password_expiration - - before_filter :set_user - before_filter :set_title - - def new - end - - def create - new_password = params[:user][:password] - new_password_confirmation = params[:user][:password_confirmation] - - result = @user.update_attributes( - password: new_password, - password_confirmation: new_password_confirmation - ) - - if result - @user.update_attributes(password_expires_at: nil) - redirect_to root_path, notice: 'Password successfully changed' - else - render :new - end - end - - private - - def set_user - @user = current_user - end - - def set_title - @title = "New password" - end -end diff --git a/app/controllers/profiles/keys_controller.rb b/app/controllers/profiles/keys_controller.rb new file mode 100644 index 00000000000..24a01040f52 --- /dev/null +++ b/app/controllers/profiles/keys_controller.rb @@ -0,0 +1,35 @@ +class Profiles::KeysController < ApplicationController + layout "profile" + + def index + @keys = current_user.keys.all + end + + def show + @key = current_user.keys.find(params[:id]) + end + + def new + @key = current_user.keys.new + end + + def create + @key = current_user.keys.new(params[:key]) + + if @key.save + redirect_to profile_key_path(@key) + else + render 'new' + end + end + + def destroy + @key = current_user.keys.find(params[:id]) + @key.destroy + + respond_to do |format| + format.html { redirect_to profile_keys_url } + format.js { render nothing: true } + end + end +end diff --git a/app/controllers/profiles/notifications_controller.rb b/app/controllers/profiles/notifications_controller.rb new file mode 100644 index 00000000000..5c492aeb49d --- /dev/null +++ b/app/controllers/profiles/notifications_controller.rb @@ -0,0 +1,26 @@ +class Profiles::NotificationsController < ApplicationController + layout 'profile' + + def show + @notification = current_user.notification + @users_projects = current_user.users_projects + @users_groups = current_user.users_groups + end + + def update + type = params[:notification_type] + + @saved = if type == 'global' + current_user.notification_level = params[:notification_level] + current_user.save + elsif type == 'group' + users_group = current_user.users_groups.find(params[:notification_id]) + users_group.notification_level = params[:notification_level] + users_group.save + else + users_project = current_user.users_projects.find(params[:notification_id]) + users_project.notification_level = params[:notification_level] + users_project.save + end + end +end diff --git a/app/controllers/profiles/passwords_controller.rb b/app/controllers/profiles/passwords_controller.rb new file mode 100644 index 00000000000..432899f857d --- /dev/null +++ b/app/controllers/profiles/passwords_controller.rb @@ -0,0 +1,38 @@ +class Profiles::PasswordsController < ApplicationController + layout 'navless' + + skip_before_filter :check_password_expiration + + before_filter :set_user + before_filter :set_title + + def new + end + + def create + new_password = params[:user][:password] + new_password_confirmation = params[:user][:password_confirmation] + + result = @user.update_attributes( + password: new_password, + password_confirmation: new_password_confirmation + ) + + if result + @user.update_attributes(password_expires_at: nil) + redirect_to root_path, notice: 'Password successfully changed' + else + render :new + end + end + + private + + def set_user + @user = current_user + end + + def set_title + @title = "New password" + end +end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 8ccb2380d62..4ab8cc87f75 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -95,7 +95,7 @@ module ApplicationHelper default_nav = [ { label: "My Profile", url: profile_path }, - { label: "My SSH Keys", url: keys_path }, + { label: "My SSH Keys", url: profile_keys_path }, { label: "My Dashboard", url: root_path }, { label: "Admin Section", url: admin_root_path }, ] diff --git a/app/views/keys/_form.html.haml b/app/views/keys/_form.html.haml deleted file mode 100644 index fe26216b1d5..00000000000 --- a/app/views/keys/_form.html.haml +++ /dev/null @@ -1,24 +0,0 @@ -%div - = form_for @key do |f| - -if @key.errors.any? - .alert.alert-error - %ul - - @key.errors.full_messages.each do |msg| - %li= msg - - .clearfix - = f.label :title - .input= f.text_field :title - .clearfix - = f.label :key - .input - = f.text_area :key, class: [:xxlarge, :thin_area] - %p.hint - Paste your public key here. Read more about how generate it - = link_to "here", help_ssh_path - - - .actions - = f.submit 'Save', class: "btn btn-save" - = link_to "Cancel", keys_path, class: "btn btn-cancel" - diff --git a/app/views/keys/_show.html.haml b/app/views/keys/_show.html.haml deleted file mode 100644 index 52bbea6fc7b..00000000000 --- a/app/views/keys/_show.html.haml +++ /dev/null @@ -1,12 +0,0 @@ -%tr - %td - = link_to key_path(key) do - %strong= key.title - %td - %span.cgray - Added - = time_ago_in_words(key.created_at) - ago - %td - = link_to 'Remove', key, confirm: 'Are you sure?', method: :delete, class: "btn btn-small btn-remove delete-key pull-right" - diff --git a/app/views/keys/edit.html.haml b/app/views/keys/edit.html.haml deleted file mode 100644 index 60a3afedddc..00000000000 --- a/app/views/keys/edit.html.haml +++ /dev/null @@ -1,7 +0,0 @@ -%h1 Editing key - -= render 'form' - -= link_to 'Show', @key -\| -= link_to 'Back', keys_path diff --git a/app/views/keys/index.html.haml b/app/views/keys/index.html.haml deleted file mode 100644 index 7730b344a7d..00000000000 --- a/app/views/keys/index.html.haml +++ /dev/null @@ -1,22 +0,0 @@ -%h3.page_title - SSH Keys - = link_to "Add new", new_key_path, class: "btn pull-right" - -%hr -%p.slead - SSH key allows you to establish a secure connection between your computer and GitLab - - -%table#keys-table - %thead - %tr - %th Name - %th Added - %th - - @keys.each do |key| - = render(partial: 'show', locals: {key: key}) - - if @keys.blank? - %tr - %td{colspan: 3} - %p.nothing_here_message There are no SSH keys with access to your account. - diff --git a/app/views/keys/new.html.haml b/app/views/keys/new.html.haml deleted file mode 100644 index fff3805890e..00000000000 --- a/app/views/keys/new.html.haml +++ /dev/null @@ -1,14 +0,0 @@ -%h3.page_title Add an SSH Key -%hr -= render 'form' - -:javascript - $('#key_key').on('keyup', function(){ - var title = $('#key_title'), - val = $('#key_key').val(), - key_mail = val.match(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+|\.[a-zA-Z0-9._-]+)/gi); - - if( key_mail && key_mail.length > 0 && title.val() == '' ){ - $('#key_title').val( key_mail ); - } - }); diff --git a/app/views/keys/show.html.haml b/app/views/keys/show.html.haml deleted file mode 100644 index 059fe5e5806..00000000000 --- a/app/views/keys/show.html.haml +++ /dev/null @@ -1,14 +0,0 @@ -%h3.page_title - Public key: - = @key.title - %small - created at - = @key.created_at.stamp("Aug 21, 2011") -.back_link - = link_to keys_path do - ← To keys list -%hr - -%pre= @key.key -.pull-right - = link_to 'Remove', @key, confirm: 'Are you sure?', method: :delete, class: "btn btn-remove delete-key" diff --git a/app/views/layouts/nav/_profile.html.haml b/app/views/layouts/nav/_profile.html.haml index e5e4b27c665..c2db7067e44 100644 --- a/app/views/layouts/nav/_profile.html.haml +++ b/app/views/layouts/nav/_profile.html.haml @@ -7,7 +7,7 @@ = nav_link(controller: :notifications) do = link_to "Notifications", profile_notifications_path = nav_link(controller: :keys) do - = link_to keys_path do + = link_to profile_keys_path do SSH Keys %span.count= current_user.keys.count = nav_link(path: 'profiles#design') do diff --git a/app/views/notifications/_settings.html.haml b/app/views/notifications/_settings.html.haml deleted file mode 100644 index 1a4a4a9f916..00000000000 --- a/app/views/notifications/_settings.html.haml +++ /dev/null @@ -1,29 +0,0 @@ -%li - .row - .span4 - %span - - if membership.kind_of? UsersGroup - = link_to membership.group.name, membership.group - - else - = link_to_project(membership.project) - .span7 - = form_tag profile_notifications_path, method: :put, remote: true, class: 'update-notifications' do - = hidden_field_tag :notification_type, type, id: dom_id(membership, 'notification_type') - = hidden_field_tag :notification_id, membership.id, id: dom_id(membership, 'notification_id') - - = label_tag do - = radio_button_tag :notification_level, Notification::N_GLOBAL, notification.global?, id: dom_id(membership, 'notification_level'), class: 'trigger-submit' - %span Use global setting - - = label_tag do - = radio_button_tag :notification_level, Notification::N_DISABLED, notification.disabled?, id: dom_id(membership, 'notification_level'), class: 'trigger-submit' - %span Disabled - - = label_tag do - = radio_button_tag :notification_level, Notification::N_PARTICIPATING, notification.participating?, id: dom_id(membership, 'notification_level'), class: 'trigger-submit' - %span Participating - - = label_tag do - = radio_button_tag :notification_level, Notification::N_WATCH, notification.watch?, id: dom_id(membership, 'notification_level'), class: 'trigger-submit' - %span Watch - diff --git a/app/views/notifications/show.html.haml b/app/views/notifications/show.html.haml deleted file mode 100644 index 069747097c5..00000000000 --- a/app/views/notifications/show.html.haml +++ /dev/null @@ -1,60 +0,0 @@ -%h3.page_title Setup your notification level - -%br - -%p.light - %strong Disabled - – You will not get any notifications via email -%p.light - %strong Participating - – You will receive only notifications from related resources(ex. from assigned issue or your commit) -%p.light - %strong Watch - – You will receive all notifications from projects in which you participate -%hr - -.row - .span4 - %h5 Global setting - .span7 - = form_tag profile_notifications_path, method: :put, remote: true, class: 'update-notifications' do - = hidden_field_tag :notification_type, 'global' - - = label_tag do - = radio_button_tag :notification_level, Notification::N_DISABLED, @notification.disabled?, class: 'trigger-submit' - %span Disabled - - = label_tag do - = radio_button_tag :notification_level, Notification::N_PARTICIPATING, @notification.participating?, class: 'trigger-submit' - %span Participating - - = label_tag do - = radio_button_tag :notification_level, Notification::N_WATCH, @notification.watch?, class: 'trigger-submit' - %span Watch - -%hr -= link_to '#', class: 'js-toggle-visibility-link' do - %h6.btn.btn-tiny - %i.icon-chevron-down - %span Advanced notifications settings -.js-toggle-visibility-container.hide - %h5 Groups: - %ul.well-list - - @users_groups.each do |users_group| - - notification = Notification.new(users_group) - = render 'settings', type: 'group', membership: users_group, notification: notification - - %h5 Projects: - %ul.well-list - - @users_projects.each do |users_project| - - notification = Notification.new(users_project) - = render 'settings', type: 'project', membership: users_project, notification: notification - - -.save-status-fixed - %span.update-success.cgreen.hide - %i.icon-ok - Saved - %span.update-failed.cred.hide - %i.icon-remove - Failed diff --git a/app/views/notifications/update.js.haml b/app/views/notifications/update.js.haml deleted file mode 100644 index 88e74d50671..00000000000 --- a/app/views/notifications/update.js.haml +++ /dev/null @@ -1,6 +0,0 @@ -- if @saved - :plain - $('.save-status-fixed .update-success').showAndHide(); -- else - :plain - $('.save-status-fixed .update-failed').showAndHide(); diff --git a/app/views/passwords/new.html.haml b/app/views/passwords/new.html.haml deleted file mode 100644 index c92424160b3..00000000000 --- a/app/views/passwords/new.html.haml +++ /dev/null @@ -1,22 +0,0 @@ -= form_for @user, url: profile_password_path, method: :post do |f| - .light-well.padded - %p.slead - Please set new password before proceed. - %br - After successful password update you will be redirected to login screen - -if @user.errors.any? - .alert.alert-error - %ul - - @user.errors.full_messages.each do |msg| - %li= msg - - .clearfix - = f.label :password - .input= f.password_field :password, required: true - .clearfix - = f.label :password_confirmation - .input - = f.password_field :password_confirmation, required: true - .clearfix - .input - = f.submit 'Set new password', class: "btn btn-create" diff --git a/app/views/profiles/keys/_form.html.haml b/app/views/profiles/keys/_form.html.haml new file mode 100644 index 00000000000..59808d60022 --- /dev/null +++ b/app/views/profiles/keys/_form.html.haml @@ -0,0 +1,24 @@ +%div + = form_for [:profile, @key] do |f| + - if @key.errors.any? + .alert.alert-error + %ul + - @key.errors.full_messages.each do |msg| + %li= msg + + .clearfix + = f.label :title + .input= f.text_field :title + .clearfix + = f.label :key + .input + = f.text_area :key, class: [:xxlarge, :thin_area] + %p.hint + Paste your public key here. Read more about how generate it + = link_to "here", help_ssh_path + + + .actions + = f.submit 'Save', class: "btn btn-save" + = link_to "Cancel", profile_keys_path, class: "btn btn-cancel" + diff --git a/app/views/profiles/keys/_key.html.haml b/app/views/profiles/keys/_key.html.haml new file mode 100644 index 00000000000..a71ad6295cd --- /dev/null +++ b/app/views/profiles/keys/_key.html.haml @@ -0,0 +1,12 @@ +%tr + %td + = link_to profile_key_path(key) do + %strong= key.title + %td + %span.cgray + Added + = time_ago_in_words(key.created_at) + ago + %td + = link_to 'Remove', profile_key_path(key), confirm: 'Are you sure?', method: :delete, class: "btn btn-small btn-remove delete-key pull-right" + diff --git a/app/views/profiles/keys/edit.html.haml b/app/views/profiles/keys/edit.html.haml new file mode 100644 index 00000000000..08c5a3dfe1e --- /dev/null +++ b/app/views/profiles/keys/edit.html.haml @@ -0,0 +1,7 @@ +%h1 Editing key + += render 'form' + += link_to 'Show', profile_keys_path(key) +\| += link_to 'Back', profile_keys_path diff --git a/app/views/profiles/keys/index.html.haml b/app/views/profiles/keys/index.html.haml new file mode 100644 index 00000000000..b22805bc862 --- /dev/null +++ b/app/views/profiles/keys/index.html.haml @@ -0,0 +1,21 @@ +%h3.page_title + SSH Keys + = link_to "Add new", new_profile_key_path, class: "btn pull-right" + +%hr +%p.slead + SSH key allows you to establish a secure connection between your computer and GitLab + + +%table#keys-table + %thead + %tr + %th Name + %th Added + %th + = render @keys + - if @keys.blank? + %tr + %td{colspan: 3} + %p.nothing_here_message There are no SSH keys with access to your account. + diff --git a/app/views/profiles/keys/new.html.haml b/app/views/profiles/keys/new.html.haml new file mode 100644 index 00000000000..fff3805890e --- /dev/null +++ b/app/views/profiles/keys/new.html.haml @@ -0,0 +1,14 @@ +%h3.page_title Add an SSH Key +%hr += render 'form' + +:javascript + $('#key_key').on('keyup', function(){ + var title = $('#key_title'), + val = $('#key_key').val(), + key_mail = val.match(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+|\.[a-zA-Z0-9._-]+)/gi); + + if( key_mail && key_mail.length > 0 && title.val() == '' ){ + $('#key_title').val( key_mail ); + } + }); diff --git a/app/views/profiles/keys/show.html.haml b/app/views/profiles/keys/show.html.haml new file mode 100644 index 00000000000..64c6621ea5f --- /dev/null +++ b/app/views/profiles/keys/show.html.haml @@ -0,0 +1,14 @@ +%h3.page_title + Public key: + = @key.title + %small + created at + = @key.created_at.stamp("Aug 21, 2011") +.back_link + = link_to profile_keys_path do + ← To keys list +%hr + +%pre= @key.key +.pull-right + = link_to 'Remove', profile_key_path(@key), confirm: 'Are you sure?', method: :delete, class: "btn btn-remove delete-key" diff --git a/app/views/profiles/notifications/_settings.html.haml b/app/views/profiles/notifications/_settings.html.haml new file mode 100644 index 00000000000..1a4a4a9f916 --- /dev/null +++ b/app/views/profiles/notifications/_settings.html.haml @@ -0,0 +1,29 @@ +%li + .row + .span4 + %span + - if membership.kind_of? UsersGroup + = link_to membership.group.name, membership.group + - else + = link_to_project(membership.project) + .span7 + = form_tag profile_notifications_path, method: :put, remote: true, class: 'update-notifications' do + = hidden_field_tag :notification_type, type, id: dom_id(membership, 'notification_type') + = hidden_field_tag :notification_id, membership.id, id: dom_id(membership, 'notification_id') + + = label_tag do + = radio_button_tag :notification_level, Notification::N_GLOBAL, notification.global?, id: dom_id(membership, 'notification_level'), class: 'trigger-submit' + %span Use global setting + + = label_tag do + = radio_button_tag :notification_level, Notification::N_DISABLED, notification.disabled?, id: dom_id(membership, 'notification_level'), class: 'trigger-submit' + %span Disabled + + = label_tag do + = radio_button_tag :notification_level, Notification::N_PARTICIPATING, notification.participating?, id: dom_id(membership, 'notification_level'), class: 'trigger-submit' + %span Participating + + = label_tag do + = radio_button_tag :notification_level, Notification::N_WATCH, notification.watch?, id: dom_id(membership, 'notification_level'), class: 'trigger-submit' + %span Watch + diff --git a/app/views/profiles/notifications/show.html.haml b/app/views/profiles/notifications/show.html.haml new file mode 100644 index 00000000000..069747097c5 --- /dev/null +++ b/app/views/profiles/notifications/show.html.haml @@ -0,0 +1,60 @@ +%h3.page_title Setup your notification level + +%br + +%p.light + %strong Disabled + – You will not get any notifications via email +%p.light + %strong Participating + – You will receive only notifications from related resources(ex. from assigned issue or your commit) +%p.light + %strong Watch + – You will receive all notifications from projects in which you participate +%hr + +.row + .span4 + %h5 Global setting + .span7 + = form_tag profile_notifications_path, method: :put, remote: true, class: 'update-notifications' do + = hidden_field_tag :notification_type, 'global' + + = label_tag do + = radio_button_tag :notification_level, Notification::N_DISABLED, @notification.disabled?, class: 'trigger-submit' + %span Disabled + + = label_tag do + = radio_button_tag :notification_level, Notification::N_PARTICIPATING, @notification.participating?, class: 'trigger-submit' + %span Participating + + = label_tag do + = radio_button_tag :notification_level, Notification::N_WATCH, @notification.watch?, class: 'trigger-submit' + %span Watch + +%hr += link_to '#', class: 'js-toggle-visibility-link' do + %h6.btn.btn-tiny + %i.icon-chevron-down + %span Advanced notifications settings +.js-toggle-visibility-container.hide + %h5 Groups: + %ul.well-list + - @users_groups.each do |users_group| + - notification = Notification.new(users_group) + = render 'settings', type: 'group', membership: users_group, notification: notification + + %h5 Projects: + %ul.well-list + - @users_projects.each do |users_project| + - notification = Notification.new(users_project) + = render 'settings', type: 'project', membership: users_project, notification: notification + + +.save-status-fixed + %span.update-success.cgreen.hide + %i.icon-ok + Saved + %span.update-failed.cred.hide + %i.icon-remove + Failed diff --git a/app/views/profiles/notifications/update.js.haml b/app/views/profiles/notifications/update.js.haml new file mode 100644 index 00000000000..88e74d50671 --- /dev/null +++ b/app/views/profiles/notifications/update.js.haml @@ -0,0 +1,6 @@ +- if @saved + :plain + $('.save-status-fixed .update-success').showAndHide(); +- else + :plain + $('.save-status-fixed .update-failed').showAndHide(); diff --git a/app/views/profiles/passwords/new.html.haml b/app/views/profiles/passwords/new.html.haml new file mode 100644 index 00000000000..c92424160b3 --- /dev/null +++ b/app/views/profiles/passwords/new.html.haml @@ -0,0 +1,22 @@ += form_for @user, url: profile_password_path, method: :post do |f| + .light-well.padded + %p.slead + Please set new password before proceed. + %br + After successful password update you will be redirected to login screen + -if @user.errors.any? + .alert.alert-error + %ul + - @user.errors.full_messages.each do |msg| + %li= msg + + .clearfix + = f.label :password + .input= f.password_field :password, required: true + .clearfix + = f.label :password_confirmation + .input + = f.password_field :password_confirmation, required: true + .clearfix + .input + = f.submit 'Set new password', class: "btn btn-create" diff --git a/app/views/profiles/show.html.haml b/app/views/profiles/show.html.haml index 7ca2546afdf..7ca7583cd32 100644 --- a/app/views/profiles/show.html.haml +++ b/app/views/profiles/show.html.haml @@ -83,9 +83,9 @@ %legend SSH public keys: %span.pull-right - = link_to pluralize(current_user.keys.count, 'key'), keys_path + = link_to pluralize(current_user.keys.count, 'key'), profile_keys_path .padded - = link_to "Add Public Key", new_key_path, class: "btn btn-small" + = link_to "Add Public Key", new_profile_key_path, class: "btn btn-small" .form-actions = f.submit 'Save', class: "btn btn-save" diff --git a/config/routes.rb b/config/routes.rb index a59e6b7ce5b..c6b25e460cd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -113,11 +113,13 @@ Gitlab::Application.routes.draw do put :update_username end - resource :notifications, only: [:show, :update] - resource :password, only: [:new, :create] + scope module: :profiles do + resource :notifications, only: [:show, :update] + resource :password, only: [:new, :create] + resources :keys + end end - resources :keys match "/u/:username" => "users#show", as: :user, constraints: { username: /.*/ } diff --git a/features/steps/profile/profile_ssh_keys.rb b/features/steps/profile/profile_ssh_keys.rb index a280ce6f89c..7871eabcb5d 100644 --- a/features/steps/profile/profile_ssh_keys.rb +++ b/features/steps/profile/profile_ssh_keys.rb @@ -21,7 +21,7 @@ class ProfileSshKeys < Spinach::FeatureSteps key = Key.find_by_title("Laptop") page.should have_content(key.title) page.should have_content(key.key) - current_path.should == key_path(key) + current_path.should == profile_key_path(key) end Given 'I click link "Work"' do @@ -33,7 +33,7 @@ class ProfileSshKeys < Spinach::FeatureSteps end Then 'I visit profile keys page' do - visit keys_path + visit profile_keys_path end And 'I should not see "Work" ssh key' do diff --git a/features/steps/shared/paths.rb b/features/steps/shared/paths.rb index 21b6159bce3..b2c23cf11c9 100644 --- a/features/steps/shared/paths.rb +++ b/features/steps/shared/paths.rb @@ -70,7 +70,7 @@ module SharedPaths end step 'I visit profile SSH keys page' do - visit keys_path + visit profile_keys_path end step 'I visit profile design page' do diff --git a/spec/routing/notifications_routing_spec.rb b/spec/routing/notifications_routing_spec.rb index 6880d2819d1..112b825e023 100644 --- a/spec/routing/notifications_routing_spec.rb +++ b/spec/routing/notifications_routing_spec.rb @@ -1,13 +1,13 @@ require "spec_helper" -describe NotificationsController do +describe Profiles::NotificationsController do describe "routing" do it "routes to #show" do - get("/profile/notifications").should route_to("notifications#show") + get("/profile/notifications").should route_to("profiles/notifications#show") end it "routes to #update" do - put("/profile/notifications").should route_to("notifications#update") + put("/profile/notifications").should route_to("profiles/notifications#update") end end end diff --git a/spec/routing/routing_spec.rb b/spec/routing/routing_spec.rb index aa3952f74b6..cc2a141c454 100644 --- a/spec/routing/routing_spec.rb +++ b/spec/routing/routing_spec.rb @@ -155,33 +155,33 @@ end # key GET /keys/:id(.:format) keys#show # PUT /keys/:id(.:format) keys#update # DELETE /keys/:id(.:format) keys#destroy -describe KeysController, "routing" do +describe Profiles::KeysController, "routing" do it "to #index" do - get("/keys").should route_to('keys#index') + get("/profile/keys").should route_to('profiles/keys#index') end it "to #create" do - post("/keys").should route_to('keys#create') + post("/profile/keys").should route_to('profiles/keys#create') end it "to #new" do - get("/keys/new").should route_to('keys#new') + get("/profile/keys/new").should route_to('profiles/keys#new') end it "to #edit" do - get("/keys/1/edit").should route_to('keys#edit', id: '1') + get("/profile/keys/1/edit").should route_to('profiles/keys#edit', id: '1') end it "to #show" do - get("/keys/1").should route_to('keys#show', id: '1') + get("/profile/keys/1").should route_to('profiles/keys#show', id: '1') end it "to #update" do - put("/keys/1").should route_to('keys#update', id: '1') + put("/profile/keys/1").should route_to('profiles/keys#update', id: '1') end it "to #destroy" do - delete("/keys/1").should route_to('keys#destroy', id: '1') + delete("/profile/keys/1").should route_to('profiles/keys#destroy', id: '1') end end -- cgit v1.2.1 From afc9d548198ac2b405fbf3a268cdc0c2ffd35995 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 24 Jun 2013 18:26:57 +0300 Subject: Fix new ssh key link from shared partial --- app/views/shared/_no_ssh.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/shared/_no_ssh.html.haml b/app/views/shared/_no_ssh.html.haml index 5fdcea850b2..f8c2ea1eed3 100644 --- a/app/views/shared/_no_ssh.html.haml +++ b/app/views/shared/_no_ssh.html.haml @@ -1,3 +1,3 @@ - if current_user.require_ssh_key? %p.error_message.centered - You won't be able to pull or push project code via SSH until you #{link_to 'add an SSH key', new_key_path} to your profile + You won't be able to pull or push project code via SSH until you #{link_to 'add an SSH key', new_profile_key_path} to your profile -- cgit v1.2.1 From 15f62fcc27235b3c8012c80f0517ecf5c27aa205 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 24 Jun 2013 19:24:27 +0300 Subject: Fix profile emails with new key route --- app/views/notify/new_ssh_key_email.html.haml | 2 +- app/views/notify/new_ssh_key_email.text.erb | 2 +- spec/features/security/profile_access_spec.rb | 4 ++-- spec/mailers/notify_spec.rb | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/views/notify/new_ssh_key_email.html.haml b/app/views/notify/new_ssh_key_email.html.haml index eff197ce0f4..deb0822d8f2 100644 --- a/app/views/notify/new_ssh_key_email.html.haml +++ b/app/views/notify/new_ssh_key_email.html.haml @@ -7,4 +7,4 @@ %code= @key.title %p If this key was added in error, you can remove it here: - = link_to "SSH Keys", keys_url + = link_to "SSH Keys", profile_keys_url diff --git a/app/views/notify/new_ssh_key_email.text.erb b/app/views/notify/new_ssh_key_email.text.erb index 2b1f8a06858..5f0080c2b76 100644 --- a/app/views/notify/new_ssh_key_email.text.erb +++ b/app/views/notify/new_ssh_key_email.text.erb @@ -4,4 +4,4 @@ A new public key was added to your account: title.................. <%= @key.title %> -If this key was added in error, you can remove it here: <%= keys_url %> +If this key was added in error, you can remove it here: <%= profile_keys_url %> diff --git a/spec/features/security/profile_access_spec.rb b/spec/features/security/profile_access_spec.rb index f854f3fb066..52130b3f8c6 100644 --- a/spec/features/security/profile_access_spec.rb +++ b/spec/features/security/profile_access_spec.rb @@ -10,8 +10,8 @@ describe "Users Security" do it { new_user_session_path.should_not be_404_for :visitor } end - describe "GET /keys" do - subject { keys_path } + describe "GET /profile/keys" do + subject { profile_keys_path } it { should be_allowed_for @u1 } it { should be_allowed_for :admin } diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb index 7290e2b739d..e7e8bc5b028 100644 --- a/spec/mailers/notify_spec.rb +++ b/spec/mailers/notify_spec.rb @@ -86,7 +86,7 @@ describe Notify do end it 'includes a link to ssh keys page' do - should have_body_text /#{keys_path}/ + should have_body_text /#{profile_keys_path}/ end end -- cgit v1.2.1 From 05a7e8b9c0b1ebdc01470a31f933b7526ca2cd08 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 24 Jun 2013 19:25:10 +0300 Subject: Better design for SSH keys page --- .../stylesheets/gitlab_bootstrap/common.scss | 7 +++++ app/controllers/profiles/keys_controller.rb | 2 +- app/views/profiles/keys/_form.html.haml | 7 +++-- app/views/profiles/keys/_key.html.haml | 19 ++++++------- app/views/profiles/keys/edit.html.haml | 7 ----- app/views/profiles/keys/index.html.haml | 31 ++++++++++++---------- app/views/profiles/keys/show.html.haml | 27 +++++++++++-------- 7 files changed, 52 insertions(+), 48 deletions(-) delete mode 100644 app/views/profiles/keys/edit.html.haml diff --git a/app/assets/stylesheets/gitlab_bootstrap/common.scss b/app/assets/stylesheets/gitlab_bootstrap/common.scss index d2460c5f022..4a77e166e67 100644 --- a/app/assets/stylesheets/gitlab_bootstrap/common.scss +++ b/app/assets/stylesheets/gitlab_bootstrap/common.scss @@ -87,3 +87,10 @@ fieldset legend { font-size: 17px; } color: #333; text-shadow: 0 1px 1px #FFF; } + +pre.well-pre { + border: 1px solid #EEE; + background: #f9f9f9; + border-radius: 0; + color: #555; +} diff --git a/app/controllers/profiles/keys_controller.rb b/app/controllers/profiles/keys_controller.rb index 24a01040f52..c36dae2abd3 100644 --- a/app/controllers/profiles/keys_controller.rb +++ b/app/controllers/profiles/keys_controller.rb @@ -2,7 +2,7 @@ class Profiles::KeysController < ApplicationController layout "profile" def index - @keys = current_user.keys.all + @keys = current_user.keys.order('id DESC').all end def show diff --git a/app/views/profiles/keys/_form.html.haml b/app/views/profiles/keys/_form.html.haml index 59808d60022..7ba8e20a44f 100644 --- a/app/views/profiles/keys/_form.html.haml +++ b/app/views/profiles/keys/_form.html.haml @@ -12,13 +12,12 @@ .clearfix = f.label :key .input + %p.light + Paste your public key here. Read more about how generate it #{link_to "here", help_ssh_path} = f.text_area :key, class: [:xxlarge, :thin_area] - %p.hint - Paste your public key here. Read more about how generate it - = link_to "here", help_ssh_path .actions - = f.submit 'Save', class: "btn btn-save" + = f.submit 'Add key', class: "btn btn-create" = link_to "Cancel", profile_keys_path, class: "btn btn-cancel" diff --git a/app/views/profiles/keys/_key.html.haml b/app/views/profiles/keys/_key.html.haml index a71ad6295cd..cf4d80ad894 100644 --- a/app/views/profiles/keys/_key.html.haml +++ b/app/views/profiles/keys/_key.html.haml @@ -1,12 +1,9 @@ -%tr - %td - = link_to profile_key_path(key) do - %strong= key.title - %td - %span.cgray - Added - = time_ago_in_words(key.created_at) - ago - %td - = link_to 'Remove', profile_key_path(key), confirm: 'Are you sure?', method: :delete, class: "btn btn-small btn-remove delete-key pull-right" +%li + = link_to profile_key_path(key) do + %strong= key.title + %span.cgray + added + = time_ago_in_words(key.created_at) + ago + = link_to 'Remove', profile_key_path(key), confirm: 'Are you sure?', method: :delete, class: "btn btn-small btn-remove delete-key pull-right" diff --git a/app/views/profiles/keys/edit.html.haml b/app/views/profiles/keys/edit.html.haml deleted file mode 100644 index 08c5a3dfe1e..00000000000 --- a/app/views/profiles/keys/edit.html.haml +++ /dev/null @@ -1,7 +0,0 @@ -%h1 Editing key - -= render 'form' - -= link_to 'Show', profile_keys_path(key) -\| -= link_to 'Back', profile_keys_path diff --git a/app/views/profiles/keys/index.html.haml b/app/views/profiles/keys/index.html.haml index b22805bc862..05c481ded23 100644 --- a/app/views/profiles/keys/index.html.haml +++ b/app/views/profiles/keys/index.html.haml @@ -1,21 +1,24 @@ %h3.page_title SSH Keys - = link_to "Add new", new_profile_key_path, class: "btn pull-right" + = link_to "Add SSH Key", new_profile_key_path, class: "btn pull-right btn-primary" -%hr -%p.slead +%br +%p.light SSH key allows you to establish a secure connection between your computer and GitLab +%p.light + Before you can add ssh key you need to + = link_to "generate it", help_ssh_path -%table#keys-table - %thead - %tr - %th Name - %th Added - %th - = render @keys - - if @keys.blank? - %tr - %td{colspan: 3} - %p.nothing_here_message There are no SSH keys with access to your account. + +.ui-box + %h5.title + SSH Keys (#{@keys.count}) + .pull-right + %ul.well-list#keys-table + = render @keys + - if @keys.blank? + %li + %h3.nothing_here_message There are no SSH keys with access to your account. + diff --git a/app/views/profiles/keys/show.html.haml b/app/views/profiles/keys/show.html.haml index 64c6621ea5f..fc292f23066 100644 --- a/app/views/profiles/keys/show.html.haml +++ b/app/views/profiles/keys/show.html.haml @@ -1,14 +1,19 @@ -%h3.page_title - Public key: - = @key.title - %small - created at - = @key.created_at.stamp("Aug 21, 2011") -.back_link - = link_to profile_keys_path do - ← To keys list -%hr +.row + .span4 + .ui-box + %h5.title + SSH Key + %ul.well-list + %li + %span.light Title: + %strong= @key.title + %li + %span.light Created at: + %strong= @key.created_at.stamp("Aug 21, 2011") + + .span8 + %pre.well-pre + = @key.key -%pre= @key.key .pull-right = link_to 'Remove', profile_key_path(@key), confirm: 'Are you sure?', method: :delete, class: "btn btn-remove delete-key" -- cgit v1.2.1 From 113d2ff525b6005e1cc7ff86a5a0189c4ab3d0e4 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 24 Jun 2013 20:07:21 +0300 Subject: store and display public key fingerprint --- app/models/key.rb | 40 +++++++++++++++++----- app/views/profiles/keys/_key.html.haml | 4 ++- app/views/profiles/keys/show.html.haml | 3 ++ .../20130624162710_add_fingerprint_to_key.rb | 6 ++++ db/schema.rb | 5 ++- lib/tasks/migrate/migrate_keys.rake | 15 ++++++++ 6 files changed, 60 insertions(+), 13 deletions(-) create mode 100644 db/migrate/20130624162710_add_fingerprint_to_key.rb create mode 100644 lib/tasks/migrate/migrate_keys.rake diff --git a/app/models/key.rb b/app/models/key.rb index a87ea4943e9..0f2fc45abc9 100644 --- a/app/models/key.rb +++ b/app/models/key.rb @@ -15,6 +15,8 @@ require 'digest/md5' class Key < ActiveRecord::Base + include Gitlab::Popen + belongs_to :user attr_accessible :key, :title @@ -34,16 +36,10 @@ class Key < ActiveRecord::Base def fingerprintable_key return true unless key # Don't test if there is no key. - file = Tempfile.new('key_file') - begin - file.puts key - file.rewind - fingerprint_output = `ssh-keygen -lf #{file.path} 2>&1` # Catch stderr. - ensure - file.close - file.unlink # deletes the temp file + unless generate_fingerpint + errors.add(:key, "can't be fingerprinted") + false end - errors.add(:key, "can't be fingerprinted") if $?.exitstatus != 0 end # projects that has this key @@ -54,4 +50,30 @@ class Key < ActiveRecord::Base def shell_id "key-#{id}" end + + private + + def generate_fingerpint + cmd_status = 0 + cmd_output = '' + file = Tempfile.new('gitlab_key_file') + + begin + file.puts key + file.rewind + cmd_output, cmd_status = popen("ssh-keygen -lf #{file.path}", '/tmp') + ensure + file.close + file.unlink # deletes the temp file + end + + if cmd_status.zero? + cmd_output.gsub /([\d\h]{2}:)+[\d\h]{2}/ do |match| + self.fingerprint = match + end + true + else + false + end + end end diff --git a/app/views/profiles/keys/_key.html.haml b/app/views/profiles/keys/_key.html.haml index cf4d80ad894..d0a3fe32c35 100644 --- a/app/views/profiles/keys/_key.html.haml +++ b/app/views/profiles/keys/_key.html.haml @@ -1,9 +1,11 @@ %li = link_to profile_key_path(key) do %strong= key.title + %span + (#{key.fingerprint}) %span.cgray added = time_ago_in_words(key.created_at) ago - = link_to 'Remove', profile_key_path(key), confirm: 'Are you sure?', method: :delete, class: "btn btn-small btn-remove delete-key pull-right" + = link_to 'Remove', profile_key_path(key), confirm: 'Are you sure?', method: :delete, class: "btn btn-small btn-remove delete-key pull-right" diff --git a/app/views/profiles/keys/show.html.haml b/app/views/profiles/keys/show.html.haml index fc292f23066..735e9d1f936 100644 --- a/app/views/profiles/keys/show.html.haml +++ b/app/views/profiles/keys/show.html.haml @@ -12,6 +12,9 @@ %strong= @key.created_at.stamp("Aug 21, 2011") .span8 + %p + %span.light Fingerprint: + %strong= @key.fingerprint %pre.well-pre = @key.key diff --git a/db/migrate/20130624162710_add_fingerprint_to_key.rb b/db/migrate/20130624162710_add_fingerprint_to_key.rb new file mode 100644 index 00000000000..544a8366727 --- /dev/null +++ b/db/migrate/20130624162710_add_fingerprint_to_key.rb @@ -0,0 +1,6 @@ +class AddFingerprintToKey < ActiveRecord::Migration + def change + add_column :keys, :fingerprint, :string + remove_column :keys, :identifier + end +end diff --git a/db/schema.rb b/db/schema.rb index 4076c1b37d7..3208e8c2354 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20130622115340) do +ActiveRecord::Schema.define(:version => 20130624162710) do create_table "deploy_keys_projects", :force => true do |t| t.integer "deploy_key_id", :null => false @@ -77,11 +77,10 @@ ActiveRecord::Schema.define(:version => 20130622115340) do t.datetime "updated_at" t.text "key" t.string "title" - t.string "identifier" t.string "type" + t.string "fingerprint" end - add_index "keys", ["identifier"], :name => "index_keys_on_identifier" add_index "keys", ["user_id"], :name => "index_keys_on_user_id" create_table "merge_requests", :force => true do |t| diff --git a/lib/tasks/migrate/migrate_keys.rake b/lib/tasks/migrate/migrate_keys.rake new file mode 100644 index 00000000000..b13d984907b --- /dev/null +++ b/lib/tasks/migrate/migrate_keys.rake @@ -0,0 +1,15 @@ +desc "GITLAB | Migrate SSH Keys" +task migrate_keys: :environment do + puts "This will add fingerprint to ssh keys in db" + ask_to_continue + + Key.find_each(batch_size: 20) do |key| + if key.valid? && key.save + print '.' + else + print 'F' + end + end +end + + -- cgit v1.2.1 From b4a9cab7f0eaac8a29d82c0c70293f866e1d6b01 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 24 Jun 2013 20:47:59 +0300 Subject: Fix ssh key test --- features/steps/profile/profile_ssh_keys.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/steps/profile/profile_ssh_keys.rb b/features/steps/profile/profile_ssh_keys.rb index 7871eabcb5d..8c5ca7a28b6 100644 --- a/features/steps/profile/profile_ssh_keys.rb +++ b/features/steps/profile/profile_ssh_keys.rb @@ -8,7 +8,7 @@ class ProfileSshKeys < Spinach::FeatureSteps end Given 'I click link "Add new"' do - click_link "Add new" + click_link "Add SSH Key" end And 'I submit new ssh key "Laptop"' do -- cgit v1.2.1 From 89a1e7e1f5cdfe4c5ebc076ed39d37aea0e543fc Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 24 Jun 2013 21:00:33 +0300 Subject: Fix ssh key test --- features/steps/profile/profile_ssh_keys.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/steps/profile/profile_ssh_keys.rb b/features/steps/profile/profile_ssh_keys.rb index 8c5ca7a28b6..65bfc505d85 100644 --- a/features/steps/profile/profile_ssh_keys.rb +++ b/features/steps/profile/profile_ssh_keys.rb @@ -14,7 +14,7 @@ class ProfileSshKeys < Spinach::FeatureSteps And 'I submit new ssh key "Laptop"' do fill_in "key_title", with: "Laptop" fill_in "key_key", with: "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAzrEJUIR6Y03TCE9rIJ+GqTBvgb8t1jI9h5UBzCLuK4VawOmkLornPqLDrGbm6tcwM/wBrrLvVOqi2HwmkKEIecVO0a64A4rIYScVsXIniHRS6w5twyn1MD3sIbN+socBDcaldECQa2u1dI3tnNVcs8wi77fiRe7RSxePsJceGoheRQgC8AZ510UdIlO+9rjIHUdVN7LLyz512auAfYsgx1OfablkQ/XJcdEwDNgi9imI6nAXhmoKUm1IPLT2yKajTIC64AjLOnE0YyCh6+7RFMpiMyu1qiOCpdjYwTgBRiciNRZCH8xIedyCoAmiUgkUT40XYHwLuwiPJICpkAzp7Q== user@laptop" - click_button "Save" + click_button "Add key" end Then 'I should see new ssh key "Laptop"' do -- cgit v1.2.1 From 106764ab3b42f9d81a6ad81f2611ea1d78d7ae05 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 24 Jun 2013 22:03:32 +0300 Subject: update gems. remove console.log --- Gemfile | 4 +- Gemfile.lock | 124 ++++++++++++++-------------- app/assets/javascripts/dispatcher.js.coffee | 2 - 3 files changed, 65 insertions(+), 65 deletions(-) diff --git a/Gemfile b/Gemfile index 63b64b62421..e9c62e5c5b4 100644 --- a/Gemfile +++ b/Gemfile @@ -76,7 +76,7 @@ gem "github-markup", "~> 0.7.4", require: 'github/markup' gem "asciidoctor" # Servers -gem "puma", '~> 2.0.1' +gem "puma", '~> 2.1.1' # State machine gem "state_machine" @@ -168,7 +168,7 @@ group :development, :test do gem 'factory_girl_rails' # Prevent occasions where minitest is not bundled in packaged versions of ruby (see #3826) - gem 'minitest' + gem 'minitest', '~> 4.7.0' # Generate Fake data gem "ffaker" diff --git a/Gemfile.lock b/Gemfile.lock index 8063ae184e3..2ced4eef514 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,8 +1,8 @@ GIT remote: https://github.com/ctran/annotate_models.git - revision: 8bd159c7a484093fde84beaa9e6398f25ddacf09 + revision: 18a4e2eb77c8f3ef695b563e4a7ca45dfede819b specs: - annotate (2.6.0.beta1) + annotate (2.6.0.beta2) activerecord (>= 2.3.0) rake (>= 0.8.7) @@ -42,20 +42,20 @@ GEM activesupport (3.2.13) i18n (= 0.6.1) multi_json (~> 1.0) - acts-as-taggable-on (2.4.0) - rails (~> 3.0) + acts-as-taggable-on (2.4.1) + rails (>= 3, < 5) addressable (2.3.4) arel (3.0.2) asciidoctor (0.1.3) awesome_print (1.1.0) - backports (2.6.7) + backports (3.3.2) bcrypt-ruby (3.0.1) - better_errors (0.8.0) + better_errors (0.9.0) coderay (>= 1.0.0) erubis (>= 2.6.6) - binding_of_caller (0.7.1) + binding_of_caller (0.7.2) debug_inspector (>= 0.0.1) - bootstrap-sass (2.3.1.0) + bootstrap-sass (2.3.2.0) sass (~> 3.2) builder (3.0.4) capybara (2.1.0) @@ -67,7 +67,7 @@ GEM carrierwave (0.8.0) activemodel (>= 3.2.0) activesupport (>= 3.2.0) - celluloid (0.14.0) + celluloid (0.14.1) timers (>= 1.0.0) charlock_holmes (0.6.9.4) childprocess (0.3.9) @@ -75,7 +75,7 @@ GEM chosen-rails (0.9.8) railties (~> 3.0) thor (~> 0.14) - code_analyzer (0.3.1) + code_analyzer (0.3.2) sexp_processor coderay (1.0.9) coffee-rails (3.2.2) @@ -87,15 +87,16 @@ GEM coffee-script-source (1.6.2) colored (1.2) colorize (0.5.8) - connection_pool (1.0.0) + connection_pool (1.1.0) coveralls (0.6.7) colorize multi_json (~> 1.3) rest-client simplecov (>= 0.7) thor - crack (0.3.2) - d3_rails (3.1.4) + crack (0.4.0) + safe_yaml (~> 0.9.0) + d3_rails (3.1.10) railties (>= 3.1.0) daemons (1.1.9) database_cleaner (1.0.1) @@ -107,11 +108,11 @@ GEM railties (~> 3.1) warden (~> 1.2.1) diff-lcs (1.2.4) - dotenv (0.7.0) + dotenv (0.8.0) email_spec (1.4.0) launchy (~> 2.1) mail (~> 2.2) - enumerize (0.5.1) + enumerize (0.6.1) activesupport (>= 3.2) erubis (2.7.0) escape_utils (0.2.4) @@ -129,8 +130,8 @@ GEM faraday (>= 0.7.4, < 0.9) faye-websocket (0.4.7) eventmachine (>= 0.12.0) - ffaker (1.16.0) - ffi (1.8.1) + ffaker (1.16.1) + ffi (1.9.0) font-awesome-rails (3.1.1.3) railties (>= 3.2, < 5.0) foreman (0.63.0) @@ -174,7 +175,7 @@ GEM omniauth (~> 1.0) pyu-ruby-sasl (~> 0.0.3.1) rubyntlm (~> 0.1.1) - gon (4.1.0) + gon (4.1.1) actionpack (>= 2.3.0) json grape (0.4.1) @@ -191,19 +192,19 @@ GEM activesupport multi_json (>= 1.3.2) growl (1.0.3) - guard (1.8.0) + guard (1.8.1) formatador (>= 0.2.4) listen (>= 1.0.0) lumberjack (>= 1.0.2) pry (>= 0.9.10) thor (>= 0.14.6) - guard-rspec (3.0.0) + guard-rspec (3.0.2) guard (>= 1.8) rspec (~> 2.13) guard-spinach (0.0.2) guard (>= 1.1) spinach - haml (4.0.2) + haml (4.0.3) tilt haml-rails (0.4) actionpack (>= 3.1, < 4.1) @@ -211,9 +212,10 @@ GEM haml (>= 3.1, < 4.1) railties (>= 3.1, < 4.1) hashie (1.2.0) - hike (1.2.2) + hike (1.2.3) hipchat (0.9.0) httparty + httparty http_parser.rb (0.5.3) httparty (0.11.0) multi_json (~> 1.0) @@ -243,18 +245,17 @@ GEM kaminari (0.14.1) actionpack (>= 3.0.0) activesupport (>= 3.0.0) - launchy (2.2.0) + launchy (2.3.0) addressable (~> 2.3) - letter_opener (1.1.0) - launchy (~> 2.2.0) + letter_opener (1.1.1) + launchy (~> 2.2) libv8 (3.11.8.17) - listen (1.1.3) + listen (1.2.2) rb-fsevent (>= 0.9.3) rb-inotify (>= 0.9) rb-kqueue (>= 0.2) lumberjack (1.0.3) - mail (2.5.3) - i18n (>= 0.4.0) + mail (2.5.4) mime-types (~> 1.16) treetop (~> 1.4.8) method_source (0.8.1) @@ -262,12 +263,12 @@ GEM minitest (4.7.4) modernizr (2.6.2) sprockets (~> 2.0) - multi_json (1.7.3) - multi_xml (0.5.3) + multi_json (1.7.7) + multi_xml (0.5.4) multipart-post (1.2.0) mysql2 (0.3.11) net-ldap (0.3.1) - nokogiri (1.5.9) + nokogiri (1.5.10) oauth (0.4.7) oauth2 (0.8.1) faraday (~> 0.8) @@ -281,7 +282,7 @@ GEM omniauth-github (1.1.0) omniauth (~> 1.0) omniauth-oauth2 (~> 1.1) - omniauth-google-oauth2 (0.1.17) + omniauth-google-oauth2 (0.1.19) omniauth (~> 1.0) omniauth-oauth2 omniauth-oauth (1.0.1) @@ -290,7 +291,7 @@ GEM omniauth-oauth2 (1.1.1) oauth2 (~> 0.8.0) omniauth (~> 1.0) - omniauth-twitter (0.0.16) + omniauth-twitter (0.0.17) multi_json (~> 1.3) omniauth-oauth (~> 1.0) orm_adapter (0.4.0) @@ -305,7 +306,7 @@ GEM coderay (~> 1.0.5) method_source (~> 0.8) slop (~> 3.4) - puma (2.0.1) + puma (2.1.1) rack (>= 1.1, < 2.0) pygments.rb (0.4.2) posix-spawn (~> 0.3.6) @@ -339,7 +340,7 @@ GEM rails-dev-tweaks (0.6.1) actionpack (~> 3.1) railties (~> 3.1) - rails_best_practices (1.13.4) + rails_best_practices (1.13.8) activesupport awesome_print code_analyzer @@ -354,7 +355,7 @@ GEM rake (>= 0.8.7) rdoc (~> 3.4) thor (>= 0.14.6, < 2.0) - rake (10.0.4) + rake (10.1.0) rb-fsevent (0.9.3) rb-inotify (0.9.0) ffi (>= 0.5.0) @@ -382,7 +383,7 @@ GEM redis-store (~> 1.1.0) redis-store (1.1.3) redis (>= 2.2.0) - ref (1.0.4) + ref (1.0.5) rest-client (1.6.7) mime-types (>= 1.16) rspec (2.13.0) @@ -393,16 +394,17 @@ GEM rspec-expectations (2.13.0) diff-lcs (>= 1.1.3, < 2.0) rspec-mocks (2.13.1) - rspec-rails (2.13.1) + rspec-rails (2.13.2) actionpack (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) rspec-core (~> 2.13.0) rspec-expectations (~> 2.13.0) rspec-mocks (~> 2.13.0) - ruby-progressbar (1.0.2) + ruby-progressbar (1.1.1) rubyntlm (0.1.1) rubyzip (0.9.9) + safe_yaml (0.9.3) sanitize (2.0.3) nokogiri (>= 1.4.4, < 1.6) sass (3.2.9) @@ -416,10 +418,10 @@ GEM seed-fu (2.2.0) activerecord (~> 3.1) activesupport (~> 3.1) - select2-rails (3.3.1) - sass-rails (>= 3.2) + select2-rails (3.4.2) + sass-rails thor (~> 0.14) - selenium-webdriver (2.32.1) + selenium-webdriver (2.33.0) childprocess (>= 0.2.5) multi_json (~> 1.0) rubyzip @@ -428,8 +430,8 @@ GEM sexp_processor (4.2.1) shoulda-matchers (2.1.0) activesupport (>= 3.0.0) - sidekiq (2.12.0) - celluloid (>= 0.14.0) + sidekiq (2.12.4) + celluloid (>= 0.14.1) connection_pool (>= 1.0.0) json redis (>= 3.0) @@ -439,23 +441,23 @@ GEM multi_json (~> 1.0) simplecov-html (~> 0.7.1) simplecov-html (0.7.1) - sinatra (1.3.6) + sinatra (1.4.3) rack (~> 1.4) - rack-protection (~> 1.3) - tilt (~> 1.3, >= 1.3.3) + rack-protection (~> 1.4) + tilt (~> 1.3, >= 1.3.4) six (0.2.0) - slim (1.3.8) - temple (~> 0.6.3) - tilt (~> 1.3.3) + slim (2.0.0) + temple (~> 0.6.5) + tilt (~> 1.3, >= 1.3.3) slop (3.4.5) - spinach (0.8.2) + spinach (0.8.3) colorize (= 0.5.8) gherkin-ruby (~> 0.3.0) spinach-rails (0.2.1) capybara (>= 2.0.0) railties (>= 3) spinach (>= 0.4) - spork (1.0.0rc3) + spork (1.0.0rc2) sprockets (2.2.2) hike (~> 1.2) multi_json (~> 1.0) @@ -464,7 +466,7 @@ GEM stamp (0.5.0) state_machine (1.2.0) stringex (1.5.1) - temple (0.6.4) + temple (0.6.5) test_after_commit (0.2.0) therubyracer (0.11.4) libv8 (~> 3.11.8.12) @@ -474,7 +476,7 @@ GEM eventmachine (>= 0.12.6) rack (>= 1.0.0) thor (0.18.1) - tilt (1.3.7) + tilt (1.4.1) timers (1.1.0) tinder (1.9.2) eventmachine (~> 1.0) @@ -485,22 +487,22 @@ GEM mime-types (~> 1.19) multi_json (~> 1.5) twitter-stream (~> 0.1) - treetop (1.4.12) + treetop (1.4.14) polyglot polyglot (>= 0.3.1) - turbolinks (1.1.1) + turbolinks (1.2.0) coffee-rails twitter-stream (0.1.16) eventmachine (>= 0.12.8) http_parser.rb (~> 0.5.1) simple_oauth (~> 0.1.4) tzinfo (0.3.37) - uglifier (2.0.1) + uglifier (2.1.1) execjs (>= 0.3.0) multi_json (~> 1.0, >= 1.0.2) underscore-rails (1.4.4) - virtus (0.5.4) - backports (~> 2.6.1) + virtus (0.5.5) + backports (~> 3.3) descendants_tracker (~> 0.0.1) warden (1.2.1) rack (>= 1.0) @@ -564,7 +566,7 @@ DEPENDENCIES kaminari (~> 0.14.1) launchy letter_opener - minitest + minitest (~> 4.7.0) modernizr (= 2.6.2) mysql2 omniauth (~> 1.1.3) @@ -574,7 +576,7 @@ DEPENDENCIES pg poltergeist (~> 1.3.0) pry - puma (~> 2.0.1) + puma (~> 2.1.1) quiet_assets (~> 1.0.1) rack-mini-profiler rails (= 3.2.13) diff --git a/app/assets/javascripts/dispatcher.js.coffee b/app/assets/javascripts/dispatcher.js.coffee index 8ce13e6851e..245b707626d 100644 --- a/app/assets/javascripts/dispatcher.js.coffee +++ b/app/assets/javascripts/dispatcher.js.coffee @@ -10,8 +10,6 @@ class Dispatcher page = $('body').attr('data-page') project_id = $('body').attr('data-project-id') - console.log(page) - unless page return false -- cgit v1.2.1 From d40e6bc228ce68cb3e77161e1ef62b039b41fef5 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 25 Jun 2013 12:02:10 +0300 Subject: Fix key observer --- app/observers/key_observer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/observers/key_observer.rb b/app/observers/key_observer.rb index 28fef55abf9..c013594e787 100644 --- a/app/observers/key_observer.rb +++ b/app/observers/key_observer.rb @@ -1,5 +1,5 @@ class KeyObserver < BaseObserver - def after_save(key) + def after_create(key) GitlabShellWorker.perform_async( :add_key, key.shell_id, -- cgit v1.2.1 From 8fb84104e4c50c77d1ec66ebf207b057fa58f043 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 25 Jun 2013 12:39:58 +0300 Subject: Use graph ticks to make axis more readable --- app/assets/javascripts/stat_graph_contributors_graph.js.coffee | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/stat_graph_contributors_graph.js.coffee b/app/assets/javascripts/stat_graph_contributors_graph.js.coffee index e7a120fb572..15cf68ff31b 100644 --- a/app/assets/javascripts/stat_graph_contributors_graph.js.coffee +++ b/app/assets/javascripts/stat_graph_contributors_graph.js.coffee @@ -71,7 +71,7 @@ class window.ContributorsMasterGraph extends ContributorsGraph super @width, @height create_axes: -> @x_axis = d3.svg.axis().scale(@x).orient("bottom") - @y_axis = d3.svg.axis().scale(@y).orient("left") + @y_axis = d3.svg.axis().scale(@y).orient("left").ticks(5) create_svg: -> @svg = d3.select("#contributors-master").append("svg") .attr("width", @width + @MARGIN.left + @MARGIN.right) @@ -130,8 +130,8 @@ class window.ContributorsAuthorGraph extends ContributorsGraph create_scale: -> super @width, @height create_axes: -> - @x_axis = d3.svg.axis().scale(@x).orient("bottom").tickFormat(d3.time.format("%m/%d")); - @y_axis = d3.svg.axis().scale(@y).orient("left") + @x_axis = d3.svg.axis().scale(@x).orient("bottom").ticks(8) + @y_axis = d3.svg.axis().scale(@y).orient("left").ticks(5) create_area: (x, y) -> @area = d3.svg.area().x((d) -> parseDate = d3.time.format("%Y-%m-%d").parse @@ -148,7 +148,7 @@ class window.ContributorsAuthorGraph extends ContributorsGraph .append("g") .attr("transform", "translate(" + @MARGIN.left + "," + @MARGIN.top + ")") draw_path: (data) -> - @svg.append("path").datum(data).attr("class", "area-contributor").attr("d", @area); + @svg.append("path").datum(data).attr("class", "area-contributor").attr("d", @area) draw: -> @create_scale() @create_axes() -- cgit v1.2.1 From 746ffcfcbdd28a0965ab7d15860aa07977bc4c2f Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 25 Jun 2013 13:15:07 +0300 Subject: Make group settings menu looks similar to project settings menu --- app/views/groups/edit.html.haml | 63 +++++++++++++++++++++++---------------- app/views/projects/edit.html.haml | 4 ++- 2 files changed, 41 insertions(+), 26 deletions(-) diff --git a/app/views/groups/edit.html.haml b/app/views/groups/edit.html.haml index aaedcc585c1..eeaa4767cf9 100644 --- a/app/views/groups/edit.html.haml +++ b/app/views/groups/edit.html.haml @@ -1,38 +1,26 @@ .row - .span3 - %ul.nav.nav-pills.nav-stacked + .span2 + %ul.nav.nav-pills.nav-stacked.nav-stacked-menu %li.active - = link_to 'Projects', '#tab-projects', 'data-toggle' => 'tab' + = link_to '#tab-edit', 'data-toggle' => 'tab' do + %i.icon-edit + Edit Group %li - = link_to 'Edit Group', '#tab-edit', 'data-toggle' => 'tab' + = link_to '#tab-projects', 'data-toggle' => 'tab' do + %i.icon-folder-close + Projects %li = link_to 'Transfer', '#tab-transfer', 'data-toggle' => 'tab' %li = link_to 'Remove', '#tab-remove', 'data-toggle' => 'tab' - .span9 + .span10 .tab-content - .tab-pane.active#tab-projects + .tab-pane.active#tab-edit .ui-box - %h5.title Projects - %ul.well-list - - @group.projects.each do |project| - %li - - if project.public - = public_icon - - else - = private_icon - = link_to project.name_with_namespace, project - .pull-right - = link_to 'Team', project_team_index_path(project), id: "edit_#{dom_id(project)}", class: "btn btn-small" - = link_to 'Edit', edit_project_path(project), id: "edit_#{dom_id(project)}", class: "btn btn-small" - = link_to 'Remove', project, confirm: remove_project_message(project), method: :delete, class: "btn btn-small btn-remove" - - if @group.projects.blank? - %p.nothing_here_message This group has no projects yet - - .tab-pane#tab-edit - .ui-box - %h5.title Edit Group + %h5.title + %strong= @group.name + Group Settings: %div.form-holder = form_for @group do |f| - if @group.errors.any? @@ -52,6 +40,31 @@ .form-actions = f.submit 'Save group', class: "btn btn-save" + .tab-pane#tab-projects + .ui-box + %h5.title + %strong= @group.name + Projects: + - if can? current_user, :manage_group, @group + %span.pull-right + = link_to new_project_path(namespace_id: @group.id), class: "btn btn-tiny" do + %i.icon-plus + New Project + %ul.well-list + - @group.projects.each do |project| + %li + - if project.public + = public_icon + - else + = private_icon + = link_to project.name_with_namespace, project + .pull-right + = link_to 'Team', project_team_index_path(project), id: "edit_#{dom_id(project)}", class: "btn btn-small" + = link_to 'Edit', edit_project_path(project), id: "edit_#{dom_id(project)}", class: "btn btn-small" + = link_to 'Remove', project, confirm: remove_project_message(project), method: :delete, class: "btn btn-small btn-remove" + - if @group.projects.blank? + %p.nothing_here_message This group has no projects yet + .tab-pane#tab-transfer .ui-box.ui-box-danger %h5.title Transfer group diff --git a/app/views/projects/edit.html.haml b/app/views/projects/edit.html.haml index 562e4e3ae79..5d399da661d 100644 --- a/app/views/projects/edit.html.haml +++ b/app/views/projects/edit.html.haml @@ -2,7 +2,9 @@ .project-edit-errors .project-edit-content .ui-box.white - %h5.title Settings: + %h5.title + %strong= @project.name + Project Settings: .form-holder = form_for(@project, remote: true) do |f| %fieldset -- cgit v1.2.1 From c71697abc9dd5cf8ddc45f2972fbb51ee80db62d Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 25 Jun 2013 13:16:08 +0300 Subject: Make nav menu a bit higher --- app/assets/stylesheets/sections/nav.scss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/sections/nav.scss b/app/assets/stylesheets/sections/nav.scss index 7b7bcf807b5..25a327425de 100644 --- a/app/assets/stylesheets/sections/nav.scss +++ b/app/assets/stylesheets/sections/nav.scss @@ -5,7 +5,7 @@ ul { margin: auto; - height: 39px; + height: 41px; position: relative; top: 3px; overflow: hidden; @@ -54,7 +54,7 @@ display: block; text-align: center; font-weight: normal; - height: 36px; + height: 38px; line-height: 34px; color: #777; text-shadow: 0 1px 1px white; -- cgit v1.2.1 From 367a5d1b32c154baea584c0ffe85253869bee415 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 25 Jun 2013 13:41:49 +0300 Subject: remove text decoration for nav --- app/assets/stylesheets/sections/nav.scss | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/assets/stylesheets/sections/nav.scss b/app/assets/stylesheets/sections/nav.scss index 25a327425de..1caaefd87f0 100644 --- a/app/assets/stylesheets/sections/nav.scss +++ b/app/assets/stylesheets/sections/nav.scss @@ -40,6 +40,12 @@ } } + &:hover { + a { + color: $style_color; + } + } + &.home { a { i { @@ -59,6 +65,7 @@ color: #777; text-shadow: 0 1px 1px white; padding: 0 10px; + text-decoration: none; } } } -- cgit v1.2.1 From dc917552641f88defa77f3ac7d68312ccccd21c4 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 25 Jun 2013 13:55:03 +0300 Subject: Cache graph log --- app/controllers/projects/graphs_controller.rb | 14 +++++++++--- app/models/repository.rb | 8 +++++++ app/views/projects/graphs/show.js.haml | 31 +++++++++++++++------------ 3 files changed, 36 insertions(+), 17 deletions(-) diff --git a/app/controllers/projects/graphs_controller.rb b/app/controllers/projects/graphs_controller.rb index 5ff330ba6ca..252d47d939e 100644 --- a/app/controllers/projects/graphs_controller.rb +++ b/app/controllers/projects/graphs_controller.rb @@ -8,10 +8,18 @@ class Projects::GraphsController < Projects::ApplicationController respond_to do |format| format.html format.js do - @repo = @project.repository - @stats = Gitlab::Git::GitStats.new(@repo.raw, @repo.root_ref) - @log = @stats.parsed_log.to_json rescue [] + fetch_graph end end end + + private + + def fetch_graph + @log = @project.repository.graph_log.to_json + @success = true + rescue => ex + @log = [] + @success = false + end end diff --git a/app/models/repository.rb b/app/models/repository.rb index daf176576ad..4b8dee4829b 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -61,6 +61,14 @@ class Repository Rails.cache.delete(cache_key(:size)) Rails.cache.delete(cache_key(:branch_names)) Rails.cache.delete(cache_key(:tag_names)) + Rails.cache.delete(cache_key(:graph_log)) + end + + def graph_log + Rails.cache.fetch(cache_key(:graph)) do + stats = Gitlab::Git::GitStats.new(raw, root_ref) + stats.parsed_log + end end def cache_key(type) diff --git a/app/views/projects/graphs/show.js.haml b/app/views/projects/graphs/show.js.haml index b7c9b4113e9..43e776e5330 100644 --- a/app/views/projects/graphs/show.js.haml +++ b/app/views/projects/graphs/show.js.haml @@ -1,16 +1,19 @@ -:plain - controller = new ContributorsStatGraph - controller.init(#{@log}) +- if @success + :plain + controller = new ContributorsStatGraph + controller.init(#{@log}) - $("select").change( function () { - var field = $(this).val() - controller.set_current_field(field) - controller.redraw_master() - controller.redraw_authors() - }) - - $("#brush_change").change( function () { - controller.change_date_header() - controller.redraw_authors() - }) + $("select").change( function () { + var field = $(this).val() + controller.set_current_field(field) + controller.redraw_master() + controller.redraw_authors() + }) + $("#brush_change").change( function () { + controller.change_date_header() + controller.redraw_authors() + }) +- else + :plain + $('.stat-graph').replaceWith('
    Failed to load graph
    ') -- cgit v1.2.1 From 11c9b06f7cf412cc61883e61899525fca33c7f1b Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 25 Jun 2013 14:12:38 +0300 Subject: Fix key observer spec --- spec/observers/key_observer_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/observers/key_observer_spec.rb b/spec/observers/key_observer_spec.rb index 452844cbedd..b304bf1fcb7 100644 --- a/spec/observers/key_observer_spec.rb +++ b/spec/observers/key_observer_spec.rb @@ -7,10 +7,10 @@ describe KeyObserver do @observer = KeyObserver.instance end - context :after_save do + context :after_create do it do GitlabShellWorker.should_receive(:perform_async).with(:add_key, @key.shell_id, @key.key) - @observer.after_save(@key) + @observer.after_create(@key) end end -- cgit v1.2.1 From d0529ad21df0bb2e67b17ac71a27aa47dbf5339f Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 25 Jun 2013 14:19:33 +0300 Subject: Fixed cache key difference for graph --- app/models/repository.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/repository.rb b/app/models/repository.rb index 4b8dee4829b..33b7c556658 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -65,7 +65,7 @@ class Repository end def graph_log - Rails.cache.fetch(cache_key(:graph)) do + Rails.cache.fetch(cache_key(:graph_log)) do stats = Gitlab::Git::GitStats.new(raw, root_ref) stats.parsed_log end -- cgit v1.2.1 From 0705a7a5070dfa74db1f51e71aa74376bc000f11 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 25 Jun 2013 16:49:27 +0300 Subject: Changelog updated. Added migrate docs for 6.0 --- CHANGELOG | 18 ++++++++++++ doc/update/5.4-to-6.0.md | 71 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 doc/update/5.4-to-6.0.md diff --git a/CHANGELOG b/CHANGELOG index 7d1ada97c57..c6b141afc3e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,21 @@ +v 6.0.0 + - Epic: Replace teams with group membership + - Add project filter on dashboard + - cache project graph + - Drop support of root namespaces + - Redesign project settings navigation + - Restlyed login screen + - Default theme is classic now + - Cache result of methods like authorize_projects, project.team.members etc + - Remove $.ready events + - Fix onclick events being double binded + - Add notification level to group membership + - Move all project controllers/views under Projects:: module + - Move all profile controllers/views under Profiles:: module + - Redesign ssh keys page + - Generate fingerprint for ssh keys + + v 5.3.0 - Refactored services - Campfire service added diff --git a/doc/update/5.4-to-6.0.md b/doc/update/5.4-to-6.0.md new file mode 100644 index 00000000000..d241b422c66 --- /dev/null +++ b/doc/update/5.4-to-6.0.md @@ -0,0 +1,71 @@ +# From 5.4 to 6.0 + +### 0. Backup + +It's useful to make a backup just in case things go south: +(With MySQL, this may require granting "LOCK TABLES" privileges to the GitLab user on the database version) + +```bash +cd /home/git/gitlab +sudo -u git -H RAILS_ENV=production bundle exec rake gitlab:backup:create +``` + +### 1. Stop server + + sudo service gitlab stop + +### 2. Get latest code + +```bash +cd /home/git/gitlab +sudo -u git -H git fetch +sudo -u git -H git checkout 6-0-dev +``` + +### 3. Install libs, migrations, etc. + +```bash +cd /home/git/gitlab + +# MySQL +sudo -u git -H bundle install --without development test postgres --deployment + +#PostgreSQL +sudo -u git -H bundle install --without development test mysql --deployment + +sudo -u git -H bundle exec rake db:migrate RAILS_ENV=production +sudo -u git -H bundle exec rake migrate_groups RAILS_ENV=production +sudo -u git -H bundle exec rake migrate_global_projects RAILS_ENV=production +sudo -u git -H bundle exec rake migrate_global_keys RAILS_ENV=production + +``` + +### 4. Update config files + +* Make `/home/git/gitlab/config/gitlab.yml` same as https://github.com/gitlabhq/gitlabhq/blob/5-3-stable/config/gitlab.yml.example but with your settings. +* Make `/home/git/gitlab/config/puma.rb` same as https://github.com/gitlabhq/gitlabhq/blob/5-3-stable/config/puma.rb.example but with your settings. + +### 5. Update Init script + +```bash +sudo rm /etc/init.d/gitlab +sudo curl --output /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlabhq/5-3-stable/lib/support/init.d/gitlab +sudo chmod +x /etc/init.d/gitlab +``` + +### 6. Start application + + sudo service gitlab start + sudo service nginx restart + +### 7. Check application status + +Check if GitLab and its environment are configured correctly: + + sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production + +To make sure you didn't miss anything run a more thorough check with: + + sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production + +If all items are green, then congratulations upgrade complete! -- cgit v1.2.1 From 58427749fd553ce802f037a7bdbbfd30f9df232a Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 25 Jun 2013 17:05:39 +0300 Subject: Update repository head when change default project branch --- app/observers/project_observer.rb | 6 ++++++ lib/gitlab/backend/shell.rb | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/app/observers/project_observer.rb b/app/observers/project_observer.rb index 3d4d161a1a2..c1a4611536d 100644 --- a/app/observers/project_observer.rb +++ b/app/observers/project_observer.rb @@ -13,6 +13,12 @@ class ProjectObserver < BaseObserver def after_update(project) project.send_move_instructions if project.namespace_id_changed? project.rename_repo if project.path_changed? + + GitlabShellWorker.perform_async( + :update_repository_head, + project.path_with_namespace, + project.default_branch + ) if project.default_branch_changed? end def before_destroy(project) diff --git a/lib/gitlab/backend/shell.rb b/lib/gitlab/backend/shell.rb index 991648f3f79..8bced609e08 100644 --- a/lib/gitlab/backend/shell.rb +++ b/lib/gitlab/backend/shell.rb @@ -36,6 +36,18 @@ module Gitlab system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "mv-project", "#{path}.git", "#{new_path}.git" end + # Update HEAD for repository + # + # path - project path with namespace + # branch - repository branch name + # + # Ex. + # update_repository_head("gitlab/gitlab-ci", "3-1-stable") + # + def update_repository_head(path, branch) + system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "update-head", "#{path}.git", branch + end + # Fork repository to new namespace # # path - project path with namespace -- cgit v1.2.1 From 0a0cdc6c61007675f92ff474d605dcf7b617a6be Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 25 Jun 2013 17:34:50 +0300 Subject: Limit amount of contributors at graph to 100 persons --- app/assets/javascripts/stat_graph_contributors.js.coffee | 3 ++- app/views/projects/graphs/show.html.haml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/stat_graph_contributors.js.coffee b/app/assets/javascripts/stat_graph_contributors.js.coffee index 6cf6f1f022a..5b4b3dae411 100644 --- a/app/assets/javascripts/stat_graph_contributors.js.coffee +++ b/app/assets/javascripts/stat_graph_contributors.js.coffee @@ -12,7 +12,8 @@ class window.ContributorsStatGraph @master_graph.draw() add_authors_graph: (author_data) -> @authors = [] - _.each(author_data, (d) => + limited_author_data = author_data.slice(0, 100) + _.each(limited_author_data, (d) => author_header = @create_author_header(d) $(".contributors-list").append(author_header) @authors[d.author] = author_graph = new ContributorsAuthorGraph(d.dates) diff --git a/app/views/projects/graphs/show.html.haml b/app/views/projects/graphs/show.html.haml index 05bc1436e6d..6593319af27 100644 --- a/app/views/projects/graphs/show.html.haml +++ b/app/views/projects/graphs/show.html.haml @@ -24,8 +24,8 @@ type: "GET", url: location.href, complete: function() { + $(".stat-graph").fadeIn(); $(".loading-graph").hide(); - $(".stat-graph").show(); }, dataType: "script" }); -- cgit v1.2.1 From db03bfa86838020d5add006f8e7714d4a0823c32 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 26 Jun 2013 14:41:03 +0300 Subject: Apply user project limit only for personal projects. We should not include group projects for user limit --- app/models/user.rb | 4 ++-- app/views/profiles/show.html.haml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index cf42d736058..ccb21a8b204 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -294,12 +294,12 @@ class User < ActiveRecord::Base end def projects_limit_left - projects_limit - owned_projects.count + projects_limit - personal_projects.count end def projects_limit_percent return 100 if projects_limit.zero? - (owned_projects.count.to_f / projects_limit) * 100 + (personal_projects.count.to_f / projects_limit) * 100 end def recent_push project_id = nil diff --git a/app/views/profiles/show.html.haml b/app/views/profiles/show.html.haml index 7ca7583cd32..1ce2556ed09 100644 --- a/app/views/profiles/show.html.haml +++ b/app/views/profiles/show.html.haml @@ -70,9 +70,9 @@ - unless current_user.projects_limit_left > 100 %fieldset %legend - Owned projects: + Personal projects: %small.pull-right - %span= current_user.owned_projects.count + %span= current_user.personal_projects.count of %span= current_user.projects_limit .padded -- cgit v1.2.1 From a5dbe353549ad71ce2868d67dee5226ad8d46e63 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 26 Jun 2013 14:51:57 +0300 Subject: Improve change group ownership logic --- app/controllers/admin/groups_controller.rb | 2 +- app/models/group.rb | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/controllers/admin/groups_controller.rb b/app/controllers/admin/groups_controller.rb index 31d25377b76..a2201f732e6 100644 --- a/app/controllers/admin/groups_controller.rb +++ b/app/controllers/admin/groups_controller.rb @@ -34,7 +34,7 @@ class Admin::GroupsController < Admin::ApplicationController owner_id =group_params.delete(:owner_id) if owner_id - @group.owner = User.find(owner_id) + @group.change_owner(User.find(owner_id)) end if @group.update_attributes(group_params) diff --git a/app/models/group.rb b/app/models/group.rb index 0593d9cd4bb..1c8eb98e0f2 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -32,6 +32,17 @@ class Group < Namespace end end + def change_owner(user) + self.owner = user + membership = users_groups.where(user_id: user.id).first + + if membership + membership.update_attributes(group_access: UsersGroup::OWNER) + else + add_owner + end + end + private def add_owner -- cgit v1.2.1 From 112e919823a3286fe7224b01ee3cd87b48c66304 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 26 Jun 2013 15:02:28 +0300 Subject: Remove unnecessary namespaced resource --- app/controllers/admin/members_controller.rb | 9 +++++++++ .../admin/projects/application_controller.rb | 11 ----------- app/controllers/admin/projects/members_controller.rb | 17 ----------------- config/routes.rb | 4 +--- 4 files changed, 10 insertions(+), 31 deletions(-) create mode 100644 app/controllers/admin/members_controller.rb delete mode 100644 app/controllers/admin/projects/application_controller.rb delete mode 100644 app/controllers/admin/projects/members_controller.rb diff --git a/app/controllers/admin/members_controller.rb b/app/controllers/admin/members_controller.rb new file mode 100644 index 00000000000..d9201930501 --- /dev/null +++ b/app/controllers/admin/members_controller.rb @@ -0,0 +1,9 @@ +class Admin::MembersController < Admin::ApplicationController + def destroy + user = User.find_by_username(params[:id]) + project = Project.find_with_namespace(params[:project_id]) + project.users_projects.where(user_id: user).first.destroy + + redirect_to :back + end +end diff --git a/app/controllers/admin/projects/application_controller.rb b/app/controllers/admin/projects/application_controller.rb deleted file mode 100644 index b3f1539f387..00000000000 --- a/app/controllers/admin/projects/application_controller.rb +++ /dev/null @@ -1,11 +0,0 @@ -# Provides a base class for Admin controllers to subclass -# -# Automatically sets the layout and ensures an administrator is logged in -class Admin::Projects::ApplicationController < Admin::ApplicationController - - protected - - def project - @project ||= Project.find_with_namespace(params[:project_id]) - end -end diff --git a/app/controllers/admin/projects/members_controller.rb b/app/controllers/admin/projects/members_controller.rb deleted file mode 100644 index c7546fb6d67..00000000000 --- a/app/controllers/admin/projects/members_controller.rb +++ /dev/null @@ -1,17 +0,0 @@ -class Admin::Projects::MembersController < Admin::Projects::ApplicationController - def destroy - team_member_relation.destroy - - redirect_to :back - end - - private - - def team_member - @member ||= project.users.find_by_username(params[:id]) - end - - def team_member_relation - team_member.users_projects.find_by_project_id(project) - end -end diff --git a/config/routes.rb b/config/routes.rb index c6b25e460cd..0e6454f00e7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -88,9 +88,7 @@ Gitlab::Application.routes.draw do resource :background_jobs, controller: 'background_jobs', only: [:show] resources :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }, only: [:index, :show] do - scope module: :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ } do - resources :members, only: [:destroy] - end + resources :members, only: [:destroy] end root to: "dashboard#index" -- cgit v1.2.1 From a064060096aa99403f626544acaa307dea709e2d Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 26 Jun 2013 15:09:17 +0300 Subject: Test admin:group#index --- features/admin/groups.feature | 3 +++ features/steps/admin/admin_groups.rb | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/features/admin/groups.feature b/features/admin/groups.feature index 054dccfd64c..6fed9a34869 100644 --- a/features/admin/groups.feature +++ b/features/admin/groups.feature @@ -5,6 +5,9 @@ Feature: Admin Groups And Create gitlab user "John" And I visit admin groups page + Scenario: See group list + Then I should be all groups + Scenario: Create a group When I click new group link And submit form with new group info diff --git a/features/steps/admin/admin_groups.rb b/features/steps/admin/admin_groups.rb index c463d379d78..b4591f227e3 100644 --- a/features/steps/admin/admin_groups.rb +++ b/features/steps/admin/admin_groups.rb @@ -55,6 +55,12 @@ class AdminGroups < Spinach::FeatureSteps end end + step 'I should be all groups' do + Group.all.each do |group| + page.should have_content group.name + end + end + protected def current_group -- cgit v1.2.1 From 21f7c99c25615961f6eed870b38ba8fba558b879 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 26 Jun 2013 15:32:09 +0300 Subject: group add_users spec --- spec/models/group_spec.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index 5d4674e3a9f..78c39548eb4 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -17,7 +17,11 @@ require 'spec_helper' describe Group do let!(:group) { create(:group) } - it { should have_many :projects } + describe "Associations" do + it { should have_many :projects } + it { should have_many :users_groups } + end + it { should validate_presence_of :name } it { should validate_uniqueness_of(:name) } it { should validate_presence_of :path } @@ -31,4 +35,11 @@ describe Group do describe :human_name do it { group.human_name.should == group.name } end + + describe :add_users do + let(:user) { create(:user) } + before { group.add_users([user.id], UsersGroup::MASTER) } + + it { group.users_groups.masters.map(&:user).should include(user) } + end end -- cgit v1.2.1 From 1dd80d22a58d6407951e89eedcdbf21d340f9261 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 26 Jun 2013 15:57:02 +0300 Subject: Prevent confusion in naming user variable at admin area --- app/controllers/admin/users_controller.rb | 52 +++++++++++++++---------------- app/models/project_team.rb | 4 +-- app/views/admin/users/_form.html.haml | 20 ++++++------ app/views/admin/users/edit.html.haml | 2 +- app/views/admin/users/index.html.haml | 6 ++-- app/views/admin/users/show.html.haml | 48 ++++++++++++++-------------- 6 files changed, 66 insertions(+), 66 deletions(-) diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index fefd2594880..62b9fe08091 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -1,27 +1,27 @@ class Admin::UsersController < Admin::ApplicationController - before_filter :admin_user, only: [:show, :edit, :update, :destroy] + before_filter :user, only: [:show, :edit, :update, :destroy] def index - @admin_users = User.scoped - @admin_users = @admin_users.filter(params[:filter]) - @admin_users = @admin_users.search(params[:name]) if params[:name].present? - @admin_users = @admin_users.alphabetically.page(params[:page]) + @users = User.scoped + @users = @users.filter(params[:filter]) + @users = @users.search(params[:name]) if params[:name].present? + @users = @users.alphabetically.page(params[:page]) end def show - @projects = admin_user.authorized_projects + @projects = user.authorized_projects end def new - @admin_user = User.new.with_defaults + @user = User.new.with_defaults end def edit - admin_user + user end def block - if admin_user.block + if user.block redirect_to :back, alert: "Successfully blocked" else redirect_to :back, alert: "Error occured. User was not blocked" @@ -29,7 +29,7 @@ class Admin::UsersController < Admin::ApplicationController end def unblock - if admin_user.activate + if user.activate redirect_to :back, alert: "Successfully unblocked" else redirect_to :back, alert: "Error occured. User was not unblocked" @@ -44,17 +44,17 @@ class Admin::UsersController < Admin::ApplicationController password_expires_at: Time.now } - @admin_user = User.new(params[:user].merge(opts), as: :admin) - @admin_user.admin = (admin && admin.to_i > 0) - @admin_user.created_by_id = current_user.id + @user = User.new(params[:user].merge(opts), as: :admin) + @user.admin = (admin && admin.to_i > 0) + @user.created_by_id = current_user.id respond_to do |format| - if @admin_user.save - format.html { redirect_to [:admin, @admin_user], notice: 'User was successfully created.' } - format.json { render json: @admin_user, status: :created, location: @admin_user } + if @user.save + format.html { redirect_to [:admin, @user], notice: 'User was successfully created.' } + format.json { render json: @user, status: :created, location: @user } else format.html { render "new" } - format.json { render json: @admin_user.errors, status: :unprocessable_entity } + format.json { render json: @user.errors, status: :unprocessable_entity } end end end @@ -67,26 +67,26 @@ class Admin::UsersController < Admin::ApplicationController params[:user].delete(:password_confirmation) end - admin_user.admin = (admin && admin.to_i > 0) + user.admin = (admin && admin.to_i > 0) respond_to do |format| - if admin_user.update_attributes(params[:user], as: :admin) - format.html { redirect_to [:admin, admin_user], notice: 'User was successfully updated.' } + if user.update_attributes(params[:user], as: :admin) + format.html { redirect_to [:admin, user], notice: 'User was successfully updated.' } format.json { head :ok } else # restore username to keep form action url. - admin_user.username = params[:id] + user.username = params[:id] format.html { render "edit" } - format.json { render json: admin_user.errors, status: :unprocessable_entity } + format.json { render json: user.errors, status: :unprocessable_entity } end end end def destroy - if admin_user.personal_projects.count > 0 + if user.personal_projects.count > 0 redirect_to admin_users_path, alert: "User is a project owner and can't be removed." and return end - admin_user.destroy + user.destroy respond_to do |format| format.html { redirect_to admin_users_path } @@ -96,7 +96,7 @@ class Admin::UsersController < Admin::ApplicationController protected - def admin_user - @admin_user ||= User.find_by_username!(params[:id]) + def user + @user ||= User.find_by_username!(params[:id]) end end diff --git a/app/models/project_team.rb b/app/models/project_team.rb index 09b866376b1..c797c36882f 100644 --- a/app/models/project_team.rb +++ b/app/models/project_team.rb @@ -21,7 +21,7 @@ class ProjectTeam end end - def find user_id + def find(user_id) user = project.users.find_by_id(user_id) if group @@ -31,7 +31,7 @@ class ProjectTeam user end - def get_tm user_id + def find_tm(user_id) project.users_projects.find_by_user_id(user_id) end diff --git a/app/views/admin/users/_form.html.haml b/app/views/admin/users/_form.html.haml index fdf37965091..4f7f05c84f1 100644 --- a/app/views/admin/users/_form.html.haml +++ b/app/views/admin/users/_form.html.haml @@ -1,9 +1,9 @@ .user_new - = form_for [:admin, @admin_user] do |f| - -if @admin_user.errors.any? + = form_for [:admin, @user] do |f| + -if @user.errors.any? #error_explanation %ul.unstyled.alert.alert-error - - @admin_user.errors.full_messages.each do |msg| + - @user.errors.full_messages.each do |msg| %li= msg %fieldset @@ -24,7 +24,7 @@ = f.text_field :email, required: true, autocomplete: "off" %span.help-inline * required - - if @admin_user.new_record? + - if @user.new_record? %fieldset %legend Password .clearfix @@ -65,14 +65,14 @@ %strong.cred Administrator .input= f.check_box :admin .span4 - - unless @admin_user.new_record? + - unless @user.new_record? .alert.alert-error - - if @admin_user.blocked? + - if @user.blocked? %p This user is blocked and is not able to login to GitLab - = link_to 'Unblock User', unblock_admin_user_path(@admin_user), method: :put, class: "btn btn-small" + = link_to 'Unblock User', unblock_admin_user_path(@user), method: :put, class: "btn btn-small" - else %p Blocked users will be removed from all projects & will not be able to login to GitLab. - = link_to 'Block User', block_admin_user_path(@admin_user), confirm: 'USER WILL BE BLOCKED! Are you sure?', method: :put, class: "btn btn-small btn-remove" + = link_to 'Block User', block_admin_user_path(@user), confirm: 'USER WILL BE BLOCKED! Are you sure?', method: :put, class: "btn btn-small btn-remove" %fieldset %legend Profile .clearfix @@ -86,9 +86,9 @@ .input= f.text_field :twitter .actions - - if @admin_user.new_record? + - if @user.new_record? = f.submit 'Create user', class: "btn btn-create" = link_to 'Cancel', admin_users_path, class: "btn btn-cancel" - else = f.submit 'Save changes', class: "btn btn-save" - = link_to 'Cancel', admin_user_path(@admin_user), class: "btn btn-cancel" + = link_to 'Cancel', admin_user_path(@user), class: "btn btn-cancel" diff --git a/app/views/admin/users/edit.html.haml b/app/views/admin/users/edit.html.haml index f8ff77b8f53..0e31a0ba332 100644 --- a/app/views/admin/users/edit.html.haml +++ b/app/views/admin/users/edit.html.haml @@ -1,5 +1,5 @@ %h3.page_title - #{@admin_user.name} → + #{@user.name} → %i.icon-edit Edit user %hr diff --git a/app/views/admin/users/index.html.haml b/app/views/admin/users/index.html.haml index 3657f660c9b..0f74e8f68f4 100644 --- a/app/views/admin/users/index.html.haml +++ b/app/views/admin/users/index.html.haml @@ -33,9 +33,9 @@ .span9 .ui-box %h5.title - Users (#{@admin_users.total_count}) + Users (#{@users.total_count}) %ul.well-list - - @admin_users.each do |user| + - @users.each do |user| %li - if user.blocked? %i.icon-lock.cred @@ -58,4 +58,4 @@ - else = link_to 'Block', block_admin_user_path(user), confirm: 'USER WILL BE BLOCKED! Are you sure?', method: :put, class: "btn btn-small btn-remove" = link_to 'Destroy', [:admin, user], confirm: "USER #{user.name} WILL BE REMOVED! Are you sure?", method: :delete, class: "btn btn-small btn-remove" - = paginate @admin_users, theme: "gitlab" + = paginate @users, theme: "gitlab" diff --git a/app/views/admin/users/show.html.haml b/app/views/admin/users/show.html.haml index d0d2cc7ff4d..eaa7ebc3f49 100644 --- a/app/views/admin/users/show.html.haml +++ b/app/views/admin/users/show.html.haml @@ -1,21 +1,21 @@ %h3.page_title User: - = @admin_user.name - - if @admin_user.blocked? + = @user.name + - if @user.blocked? %span.cred (Blocked) - - if @admin_user.admin + - if @user.admin %span.cred (Admin) .pull-right - = link_to edit_admin_user_path(@admin_user), class: "btn grouped btn-small" do + = link_to edit_admin_user_path(@user), class: "btn grouped btn-small" do %i.icon-edit Edit - - unless @admin_user == current_user - - if @admin_user.blocked? - = link_to 'Unblock', unblock_admin_user_path(@admin_user), method: :put, class: "btn grouped btn-small success" + - unless @user == current_user + - if @user.blocked? + = link_to 'Unblock', unblock_admin_user_path(@user), method: :put, class: "btn grouped btn-small success" - else - = link_to 'Block', block_admin_user_path(@admin_user), confirm: 'USER WILL BE BLOCKED! Are you sure?', method: :put, class: "btn grouped btn-small btn-remove" - = link_to 'Destroy', [:admin, @admin_user], confirm: "USER #{@admin_user.name} WILL BE REMOVED! Are you sure?", method: :delete, class: "btn grouped btn-small btn-remove" + = link_to 'Block', block_admin_user_path(@user), confirm: 'USER WILL BE BLOCKED! Are you sure?', method: :put, class: "btn grouped btn-small btn-remove" + = link_to 'Destroy', [:admin, @user], confirm: "USER #{@user.name} WILL BE REMOVED! Are you sure?", method: :delete, class: "btn grouped btn-small btn-remove" %hr .row @@ -24,50 +24,50 @@ %h5.title Account: .pull-right - = image_tag gravatar_icon(@admin_user.email, 32), class: "avatar s32" + = image_tag gravatar_icon(@user.email, 32), class: "avatar s32" %ul.well-list %li %span.light Name: - %strong= @admin_user.name + %strong= @user.name %li %span.light Username: %strong - = @admin_user.username + = @user.username %li %span.light Email: %strong - = mail_to @admin_user.email + = mail_to @user.email %li %span.light Member since: %strong - = @admin_user.created_at.stamp("Nov 12, 2031") + = @user.created_at.stamp("Nov 12, 2031") %li %span.light Last sign-in at: %strong - - if @admin_user.last_sign_in_at - = @admin_user.last_sign_in_at.stamp("Nov 12, 2031") + - if @user.last_sign_in_at + = @user.last_sign_in_at.stamp("Nov 12, 2031") - else never - - if @admin_user.ldap_user? + - if @user.ldap_user? %li %span.light LDAP uid: %strong - = @admin_user.extern_uid + = @user.extern_uid - - if @admin_user.created_by + - if @user.created_by %li %span.light Created by: %strong - = link_to @admin_user.created_by.name, [:admin, @admin_user.created_by] + = link_to @user.created_by.name, [:admin, @user.created_by] - - if @admin_user.users_groups.present? + - if @user.users_groups.present? .ui-box %h5.title Groups: %ul.well-list - - @admin_user.users_groups.each do |user_group| + - @user.users_groups.each do |user_group| - group = user_group.group %li %strong= link_to group.name, admin_group_path(group) @@ -79,7 +79,7 @@ %h5.title Projects (#{@projects.count}) %ul.well-list - @projects.sort_by(&:name_with_namespace).each do |project| - - tm = project.team.get_tm(@admin_user.id) + - tm = project.team.find_tm(@user.id) %li = link_to admin_project_path(project), class: dom_class(project) do - if project.namespace @@ -91,5 +91,5 @@ - if tm .pull-right %span.light= tm.human_access - = link_to admin_project_member_path(project, tm.user), confirm: remove_from_project_team_message(project, @admin_user), method: :delete, class: "btn btn-small btn-remove" do + = link_to admin_project_member_path(project, tm.user), confirm: remove_from_project_team_message(project, @user), method: :delete, class: "btn btn-small btn-remove" do %i.icon-remove -- cgit v1.2.1 From f50cb7fc9fe7150337fef9b85e628dc540adc516 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 26 Jun 2013 16:58:56 +0300 Subject: Add keyboard nav for tree view. Refactor tree-view coffee --- app/assets/javascripts/blob.js.coffee | 24 +++++++++++ app/assets/javascripts/dispatcher.js.coffee | 4 ++ app/assets/javascripts/tree.js.coffee | 64 ++++++++++++++++++----------- app/assets/stylesheets/sections/tree.scss | 8 ++++ 4 files changed, 75 insertions(+), 25 deletions(-) create mode 100644 app/assets/javascripts/blob.js.coffee diff --git a/app/assets/javascripts/blob.js.coffee b/app/assets/javascripts/blob.js.coffee new file mode 100644 index 00000000000..03e280f8976 --- /dev/null +++ b/app/assets/javascripts/blob.js.coffee @@ -0,0 +1,24 @@ +class BlobView + constructor: -> + # See if there are lines selected + # "#L12" and "#L34-56" supported + highlightBlobLines = -> + if window.location.hash isnt "" + matches = window.location.hash.match(/\#L(\d+)(\-(\d+))?/) + first_line = parseInt(matches?[1]) + last_line = parseInt(matches?[3]) + + unless isNaN first_line + last_line = first_line if isNaN(last_line) + $("#tree-content-holder .highlight .line").removeClass("hll") + $("#LC#{line}").addClass("hll") for line in [first_line..last_line] + $("#L#{first_line}").ScrollTo() + + # Highlight the correct lines on load + highlightBlobLines() + + # Highlight the correct lines when the hash part of the URL changes + $(window).on 'hashchange', highlightBlobLines + + +@BlobView = BlobView diff --git a/app/assets/javascripts/dispatcher.js.coffee b/app/assets/javascripts/dispatcher.js.coffee index fdbc35d6893..890b6a0ade2 100644 --- a/app/assets/javascripts/dispatcher.js.coffee +++ b/app/assets/javascripts/dispatcher.js.coffee @@ -32,6 +32,10 @@ class Dispatcher new TeamMembers() when 'groups:people' new GroupMembers() + when 'projects:tree:show' + new TreeView() + when 'projects:blob:show' + new BlobView() switch path.first() when 'admin' then new Admin() diff --git a/app/assets/javascripts/tree.js.coffee b/app/assets/javascripts/tree.js.coffee index fdc82ff6668..4852e879b68 100644 --- a/app/assets/javascripts/tree.js.coffee +++ b/app/assets/javascripts/tree.js.coffee @@ -1,29 +1,43 @@ -# Code browser tree slider -# Make the entire tree-item row clickable, but not if clicking another link (like a commit message) -$(".tree-content-holder .tree-item").live 'click', (e) -> - if (e.target.nodeName != "A") - path = $('.tree-item-file-name a', this).attr('href') - Turbolinks.visit(path) +class TreeView + constructor: -> + @initKeyNav() -$ -> - # Show the "Loading commit data" for only the first element - $('span.log_loading:first').removeClass('hide') + # Code browser tree slider + # Make the entire tree-item row clickable, but not if clicking another link (like a commit message) + $(".tree-content-holder .tree-item").on 'click', (e) -> + if (e.target.nodeName != "A") + path = $('.tree-item-file-name a', this).attr('href') + Turbolinks.visit(path) - # See if there are lines selected - # "#L12" and "#L34-56" supported - highlightBlobLines = -> - if window.location.hash isnt "" - matches = window.location.hash.match(/\#L(\d+)(\-(\d+))?/) - first_line = parseInt(matches?[1]) - last_line = parseInt(matches?[3]) + # Show the "Loading commit data" for only the first element + $('span.log_loading:first').removeClass('hide') - unless isNaN first_line - last_line = first_line if isNaN(last_line) - $("#tree-content-holder .highlight .line").removeClass("hll") - $("#LC#{line}").addClass("hll") for line in [first_line..last_line] - $("#L#{first_line}").ScrollTo() + initKeyNav: -> + li = $("tr.tree-item") + liSelected = null + $('body').keydown (e) -> + if e.which is 40 + if liSelected + next = liSelected.next() + if next.length > 0 + liSelected.removeClass "selected" + liSelected = next.addClass("selected") + else + liSelected = li.eq(0).addClass("selected") - # Highlight the correct lines on load - highlightBlobLines() - # Highlight the correct lines when the hash part of the URL changes - $(window).on 'hashchange', highlightBlobLines + $(liSelected).focus() + else if e.which is 38 + if liSelected + next = liSelected.prev() + if next.length > 0 + liSelected.removeClass "selected" + liSelected = next.addClass("selected") + else + liSelected = li.last().addClass("selected") + + $(liSelected).focus() + else if e.which is 13 + path = $('.tree-item.selected .tree-item-file-name a').attr('href') + Turbolinks.visit(path) + +@TreeView = TreeView diff --git a/app/assets/stylesheets/sections/tree.scss b/app/assets/stylesheets/sections/tree.scss index ffde6aa3fa6..d8f32e49c2d 100644 --- a/app/assets/stylesheets/sections/tree.scss +++ b/app/assets/stylesheets/sections/tree.scss @@ -23,6 +23,14 @@ } cursor: pointer; } + + &.selected { + td { + background: $hover; + border-top: 1px solid #ADF; + border-bottom: 1px solid #ADF; + } + } } } -- cgit v1.2.1 From 9f087fb9e7d1891cd12ced9d40141a6d32510160 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 26 Jun 2013 18:15:50 +0300 Subject: more entries in changelog --- CHANGELOG | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index c6b141afc3e..2afa50a4ba0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -14,7 +14,8 @@ v 6.0.0 - Move all profile controllers/views under Profiles:: module - Redesign ssh keys page - Generate fingerprint for ssh keys - + - You an use arrows to navigate at tree view + - Apply user project limit only for personal projects v 5.3.0 - Refactored services -- cgit v1.2.1 From 3c4689c23c9d6f50e9facb48a8dc0a7344764ebf Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 26 Jun 2013 18:35:32 +0300 Subject: Store satellites lock files inside satellites dir --- lib/gitlab/satellite/satellite.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/gitlab/satellite/satellite.rb b/lib/gitlab/satellite/satellite.rb index 668de75f663..4c7be04246c 100644 --- a/lib/gitlab/satellite/satellite.rb +++ b/lib/gitlab/satellite/satellite.rb @@ -64,7 +64,8 @@ module Gitlab end def lock_file - Rails.root.join("tmp", "satellite_#{project.id}.lock") + create_locks_dir unless File.exists?(lock_files_dir) + File.join(lock_files_dir, "satellite_#{project.id}.lock") end def path @@ -114,6 +115,16 @@ module Gitlab def update_from_source! repo.git.fetch({timeout: true}, :origin) end + + # Create directory for stroing + # satellites lock files + def create_locks_dir + FileUtils.mkdir_p(lock_files_dir) + end + + def lock_files_dir + @lock_files_dir ||= File.join(Gitlab.config.satellites.path, "tmp") + end end end end -- cgit v1.2.1 From 01cf474fa1be16f1d342963829c775a4cb8a848b Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 26 Jun 2013 19:13:29 +0300 Subject: Fix spinach test --- spec/support/test_env.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/support/test_env.rb b/spec/support/test_env.rb index cf80d4901b8..3230301eead 100644 --- a/spec/support/test_env.rb +++ b/spec/support/test_env.rb @@ -42,6 +42,7 @@ module TestEnv add_repository: true, mv_repository: true, remove_repository: true, + update_repository_head: true, add_key: true, remove_key: true ) -- cgit v1.2.1 From 467e7c10b5a9176509b50d5b5552bfeb0c86b587 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 26 Jun 2013 19:25:07 +0300 Subject: Add more autocomplete options to project search --- app/helpers/application_helper.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 4ab8cc87f75..9b10d90fecb 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -115,13 +115,15 @@ module ApplicationHelper project_nav = [] if @project && @project.repository.exists? && @project.repository.root_ref project_nav = [ - { label: "#{simple_sanitize(@project.name_with_namespace)} - Issues", url: project_issues_path(@project) }, + { label: "#{simple_sanitize(@project.name_with_namespace)} - Files", url: project_tree_path(@project, @ref || @project.repository.root_ref) }, { label: "#{simple_sanitize(@project.name_with_namespace)} - Commits", url: project_commits_path(@project, @ref || @project.repository.root_ref) }, + { label: "#{simple_sanitize(@project.name_with_namespace)} - Network", url: project_network_path(@project, @ref || @project.repository.root_ref) }, + { label: "#{simple_sanitize(@project.name_with_namespace)} - Graph", url: project_graph_path(@project, @ref || @project.repository.root_ref) }, + { label: "#{simple_sanitize(@project.name_with_namespace)} - Issues", url: project_issues_path(@project) }, { label: "#{simple_sanitize(@project.name_with_namespace)} - Merge Requests", url: project_merge_requests_path(@project) }, { label: "#{simple_sanitize(@project.name_with_namespace)} - Milestones", url: project_milestones_path(@project) }, { label: "#{simple_sanitize(@project.name_with_namespace)} - Snippets", url: project_snippets_path(@project) }, { label: "#{simple_sanitize(@project.name_with_namespace)} - Team", url: project_team_index_path(@project) }, - { label: "#{simple_sanitize(@project.name_with_namespace)} - Tree", url: project_tree_path(@project, @ref || @project.repository.root_ref) }, { label: "#{simple_sanitize(@project.name_with_namespace)} - Wall", url: project_wall_path(@project) }, { label: "#{simple_sanitize(@project.name_with_namespace)} - Wiki", url: project_wikis_path(@project) }, ] -- cgit v1.2.1 From 6642709faa090107e13ab8ad5aa74f2949e73faf Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 26 Jun 2013 20:17:07 +0300 Subject: Fix route specs --- spec/routing/admin_routing_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/routing/admin_routing_spec.rb b/spec/routing/admin_routing_spec.rb index de5e831c4b4..bd76148043c 100644 --- a/spec/routing/admin_routing_spec.rb +++ b/spec/routing/admin_routing_spec.rb @@ -76,9 +76,9 @@ describe Admin::ProjectsController, "routing" do end # DELETE /admin/projects/:project_id/members/:id(.:format) admin/projects/members#destroy {id: /[^\/]+/, project_id: /[^\/]+/} -describe Admin::Projects::MembersController, "routing" do +describe Admin::MembersController, "routing" do it "to #destroy" do - delete("/admin/projects/test/members/1").should route_to('admin/projects/members#destroy', project_id: 'test', id: '1') + delete("/admin/projects/test/members/1").should route_to('admin/members#destroy', project_id: 'test', id: '1') end end -- cgit v1.2.1 From 318b50a0b3df4842cc33a15ff2019c948af15359 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 26 Jun 2013 20:54:51 +0300 Subject: Add profile notification spinach --- features/profile/notifications.feature | 8 ++++++++ features/steps/profile/profile_notifications.rb | 13 +++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 features/profile/notifications.feature create mode 100644 features/steps/profile/profile_notifications.rb diff --git a/features/profile/notifications.feature b/features/profile/notifications.feature new file mode 100644 index 00000000000..e7937953c1b --- /dev/null +++ b/features/profile/notifications.feature @@ -0,0 +1,8 @@ +Feature: Profile Notifications + Background: + Given I sign in as a user + And I own project "Shop" + + Scenario: I visit notifications tab + When I visit profile notifications page + Then I should see global notifications settings diff --git a/features/steps/profile/profile_notifications.rb b/features/steps/profile/profile_notifications.rb new file mode 100644 index 00000000000..54b02605689 --- /dev/null +++ b/features/steps/profile/profile_notifications.rb @@ -0,0 +1,13 @@ +class ProfileNotifications < Spinach::FeatureSteps + include SharedAuthentication + include SharedProject + + step 'I visit profile notifications page' do + visit profile_notifications_path + end + + step 'I should see global notifications settings' do + page.should have_content "Setup your notification level" + page.should have_content "Global setting" + end +end -- cgit v1.2.1 From 6c0fd9f29ad92b0f4b1cdea82a33d485622d0fd5 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 26 Jun 2013 21:34:20 +0300 Subject: Add scenario for expired password --- features/profile/profile.feature | 7 ++++++ features/steps/profile/profile.rb | 48 +++++++++++++++++++++++++++------------ 2 files changed, 40 insertions(+), 15 deletions(-) diff --git a/features/profile/profile.feature b/features/profile/profile.feature index 95b85a9f911..6d3dd7841fd 100644 --- a/features/profile/profile.feature +++ b/features/profile/profile.feature @@ -16,6 +16,13 @@ Feature: Profile Then I change my password And I should be redirected to sign in page + Scenario: My password is expired + Given my password is expired + And I visit profile account page + Then I redirected to expired password page + And I submit new password + And I redirected to sign in page + Scenario: I unsuccessfully change my password Given I visit profile account page When I unsuccessfully change my password diff --git a/features/steps/profile/profile.rb b/features/steps/profile/profile.rb index c1fe00c8e65..4c33fb7f9fc 100644 --- a/features/steps/profile/profile.rb +++ b/features/steps/profile/profile.rb @@ -2,13 +2,13 @@ class Profile < Spinach::FeatureSteps include SharedAuthentication include SharedPaths - Then 'I should see my profile info' do + step 'I should see my profile info' do page.should have_content "Profile" page.should have_content @user.name page.should have_content @user.email end - Then 'I change my contact info' do + step 'I change my contact info' do fill_in "user_skype", with: "testskype" fill_in "user_linkedin", with: "testlinkedin" fill_in "user_twitter", with: "testtwitter" @@ -16,13 +16,13 @@ class Profile < Spinach::FeatureSteps @user.reload end - And 'I should see new contact info' do + step 'I should see new contact info' do @user.skype.should == 'testskype' @user.linkedin.should == 'testlinkedin' @user.twitter.should == 'testtwitter' end - Then 'I change my password' do + step 'I change my password' do within '.update-password' do fill_in "user_password", with: "222333" fill_in "user_password_confirmation", with: "222333" @@ -30,7 +30,7 @@ class Profile < Spinach::FeatureSteps end end - When 'I unsuccessfully change my password' do + step 'I unsuccessfully change my password' do within '.update-password' do fill_in "user_password", with: "password" fill_in "user_password_confirmation", with: "confirmation" @@ -38,52 +38,70 @@ class Profile < Spinach::FeatureSteps end end - Then "I should see a password error message" do + step "I should see a password error message" do page.should have_content "Password doesn't match confirmation" end - And 'I should be redirected to sign in page' do + step 'I should be redirected to sign in page' do current_path.should == new_user_session_path end - Then 'I reset my token' do + step 'I reset my token' do within '.update-token' do @old_token = @user.private_token click_button "Reset" end end - And 'I should see new token' do + step 'I should see new token' do find("#token").value.should_not == @old_token find("#token").value.should == @user.reload.private_token end - Given 'I have activity' do + step 'I have activity' do create(:closed_issue_event, author: current_user) end - Then 'I should see my activity' do + step 'I should see my activity' do page.should have_content "#{current_user.name} closed issue" end - When "I change my application theme" do + step "I change my application theme" do within '.application-theme' do choose "Violet" end end - When "I change my code preview theme" do + step "I change my code preview theme" do within '.code-preview-theme' do choose "Solarized dark" end end - Then "I should see the theme change immediately" do + step "I should see the theme change immediately" do page.should have_selector('body.ui_color') page.should_not have_selector('body.ui_basic') end - Then "I should receive feedback that the changes were saved" do + step "I should receive feedback that the changes were saved" do page.should have_content("Saved") end + + step 'my password is expired' do + current_user.update_attributes(password_expires_at: Time.now - 1.hour) + end + + step 'I redirected to expired password page' do + current_path.should == new_profile_password_path + end + + step 'I submit new password' do + fill_in :user_password, with: '12345678' + fill_in :user_password_confirmation, with: '12345678' + click_button "Set new password" + end + + step 'I redirected to sign in page' do + current_path.should == new_user_session_path + end end -- cgit v1.2.1 From 49fcbdbd1e0c7405c819cecedf54029b4541fcc2 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 26 Jun 2013 21:50:47 +0300 Subject: Test user page with spinach --- app/views/layouts/_head_panel.html.haml | 2 +- features/profile/profile.feature | 5 +++++ features/steps/profile/profile.rb | 12 ++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/views/layouts/_head_panel.html.haml b/app/views/layouts/_head_panel.html.haml index f0b001f6efc..e59528897d1 100644 --- a/app/views/layouts/_head_panel.html.haml +++ b/app/views/layouts/_head_panel.html.haml @@ -36,6 +36,6 @@ = link_to destroy_user_session_path, class: "logout", method: :delete, title: "Logout", class: 'has_bottom_tooltip', 'data-original-title' => 'Logout' do %i.icon-signout %li - = link_to current_user, class: "profile-pic" do + = link_to current_user, class: "profile-pic", id: 'profile-pic' do = image_tag gravatar_icon(current_user.email, 26) diff --git a/features/profile/profile.feature b/features/profile/profile.feature index 6d3dd7841fd..53a93b0f908 100644 --- a/features/profile/profile.feature +++ b/features/profile/profile.feature @@ -38,6 +38,11 @@ Feature: Profile When I visit profile history page Then I should see my activity + Scenario: I visit my user page + When I visit profile page + And I click on my profile picture + Then I should see my user page + @javascript Scenario: I change my application theme Given I visit profile design page diff --git a/features/steps/profile/profile.rb b/features/steps/profile/profile.rb index 4c33fb7f9fc..5ff4e8af1cd 100644 --- a/features/steps/profile/profile.rb +++ b/features/steps/profile/profile.rb @@ -104,4 +104,16 @@ class Profile < Spinach::FeatureSteps step 'I redirected to sign in page' do current_path.should == new_user_session_path end + + step 'I click on my profile picture' do + click_link 'profile-pic' + end + + step 'I should see my user page' do + page.should have_content "User Activity" + + within '.navbar-gitlab' do + page.should have_content current_user.name + end + end end -- cgit v1.2.1 From b143976bfa1ef73aef3dd81a6691c9d6d411c372 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 26 Jun 2013 23:00:15 +0300 Subject: Fixed showing files, commits tabs for empty project --- app/helpers/projects_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 39290ec05bb..77b2f25ae8d 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -62,7 +62,7 @@ module ProjectsHelper def get_project_nav_tabs(project, current_user) nav_tabs = [:home] - if project.repo_exists? && can?(current_user, :download_code, project) + if !project.empty_repo? && can?(current_user, :download_code, project) nav_tabs << [:files, :commits, :network, :graphs] end -- cgit v1.2.1 From f15e8a0cfe2a977cd9925332e15ef2405170fbd3 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 28 Jun 2013 23:11:27 +0300 Subject: better align for main-nav --- app/assets/stylesheets/sections/nav.scss | 3 ++- app/assets/stylesheets/themes/ui_mars.scss | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/sections/nav.scss b/app/assets/stylesheets/sections/nav.scss index 1caaefd87f0..f14fc527a0d 100644 --- a/app/assets/stylesheets/sections/nav.scss +++ b/app/assets/stylesheets/sections/nav.scss @@ -1,6 +1,7 @@ .main-nav { margin: 30px 0; - margin-top: 10px; + margin-top: 0; + padding-top: 4px; border-bottom: 1px solid #E1E1E1; ul { diff --git a/app/assets/stylesheets/themes/ui_mars.scss b/app/assets/stylesheets/themes/ui_mars.scss index a2b8c21ea11..66232292d7e 100644 --- a/app/assets/stylesheets/themes/ui_mars.scss +++ b/app/assets/stylesheets/themes/ui_mars.scss @@ -31,4 +31,8 @@ border-left: 1px solid #666; } } + + .main-nav { + background: #f5f5f5; + } } -- cgit v1.2.1 From 3e4de1ded4343f66b4d7036129b80684b2f46d38 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 28 Jun 2013 23:33:14 +0300 Subject: Use triangle for current tab highlight --- app/assets/stylesheets/sections/nav.scss | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/app/assets/stylesheets/sections/nav.scss b/app/assets/stylesheets/sections/nav.scss index f14fc527a0d..c92c63d1db0 100644 --- a/app/assets/stylesheets/sections/nav.scss +++ b/app/assets/stylesheets/sections/nav.scss @@ -6,9 +6,7 @@ ul { margin: auto; - height: 41px; - position: relative; - top: 3px; + height: 42px; overflow: hidden; .count { font-weight: normal; @@ -34,10 +32,23 @@ display: table-cell; width: 1%; &.active { - border-bottom: 3px solid #777; a { color: $style_color; font-weight: bolder; + + &:after { + content: ''; + display: block; + position: relative; + bottom: 8px; + left: 50%; + width: 0; + height: 0; + border-color: transparent transparent #777 transparent; + border-style: solid; + border-width: 6px; + margin-left: -6px; + } } } @@ -67,6 +78,7 @@ text-shadow: 0 1px 1px white; padding: 0 10px; text-decoration: none; + padding-top: 4px; } } } -- cgit v1.2.1 From 28d517f58e7acf331f8f85ada1b06eb393d5291d Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 29 Jun 2013 08:35:52 +0300 Subject: Reduce the size of main nav --- app/assets/stylesheets/sections/nav.scss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/sections/nav.scss b/app/assets/stylesheets/sections/nav.scss index c92c63d1db0..fc1f1bc79b4 100644 --- a/app/assets/stylesheets/sections/nav.scss +++ b/app/assets/stylesheets/sections/nav.scss @@ -6,7 +6,7 @@ ul { margin: auto; - height: 42px; + height: 40px; overflow: hidden; .count { font-weight: normal; @@ -78,7 +78,7 @@ text-shadow: 0 1px 1px white; padding: 0 10px; text-decoration: none; - padding-top: 4px; + padding-top: 2px; } } } -- cgit v1.2.1 From 0904cc485c23385e4ac0628ddce5e1c842909af4 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 29 Jun 2013 09:05:26 +0300 Subject: Classic theme: Dark color for header links. White color for loading spinner --- app/assets/stylesheets/themes/ui_mars.scss | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/assets/stylesheets/themes/ui_mars.scss b/app/assets/stylesheets/themes/ui_mars.scss index 66232292d7e..d40a02206e7 100644 --- a/app/assets/stylesheets/themes/ui_mars.scss +++ b/app/assets/stylesheets/themes/ui_mars.scss @@ -23,8 +23,12 @@ background-color: #373D47; } } + .nav > li > a { color: #AAA; } } } + .turbolink-spinner { + color: #FFF; + } .separator { background: #31363E; -- cgit v1.2.1 From a54f2d512a84a328ef4dfb1a3d8a1915579b8bfc Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sun, 30 Jun 2013 19:14:27 +0300 Subject: Update gitlab_git version --- Gemfile | 4 ++-- Gemfile.lock | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Gemfile b/Gemfile index e9c62e5c5b4..c38cede758d 100644 --- a/Gemfile +++ b/Gemfile @@ -23,7 +23,7 @@ gem 'omniauth-github' # Extracting information from a git repository # Provide access to Gitlab::Git library -gem 'gitlab_git', '~> 1.3.0' +gem 'gitlab_git', '~> 1.4.1' # Ruby/Rack Git Smart-HTTP Server Handler gem 'gitlab-grack', '~> 1.0.1', require: 'grack' @@ -35,7 +35,7 @@ gem 'gitlab_omniauth-ldap', '1.0.3', require: "omniauth-ldap" gem "gitlab-pygments.rb", '~> 0.3.2', require: 'pygments.rb' # Git Wiki -gem "gitlab-gollum-lib", "~> 1.0.0", require: 'gollum-lib' +gem "gitlab-gollum-lib", "~> 1.0.1", require: 'gollum-lib' # Language detection gem "github-linguist", require: "linguist" diff --git a/Gemfile.lock b/Gemfile.lock index 2ced4eef514..369be882e14 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -147,17 +147,17 @@ GEM pygments.rb (>= 0.2.13) github-markdown (0.5.3) github-markup (0.7.5) - gitlab-gollum-lib (1.0.0) + gitlab-gollum-lib (1.0.1) github-markdown (~> 0.5.3) github-markup (>= 0.7.5, < 1.0.0) - gitlab-grit (~> 2.5.1) + gitlab-grit (>= 2.5.1) nokogiri (~> 1.5.9) pygments.rb (~> 0.4.2) sanitize (~> 2.0.3) stringex (~> 1.5.1) gitlab-grack (1.0.1) rack (~> 1.4.1) - gitlab-grit (2.5.1) + gitlab-grit (2.6.0) charlock_holmes (~> 0.6.9) diff-lcs (~> 1.1) mime-types (~> 1.15) @@ -165,10 +165,10 @@ GEM gitlab-pygments.rb (0.3.2) posix-spawn (~> 0.3.6) yajl-ruby (~> 1.1.0) - gitlab_git (1.3.0) + gitlab_git (1.4.1) activesupport (~> 3.2.13) github-linguist (~> 2.3.4) - gitlab-grit (~> 2.5.1) + gitlab-grit (~> 2.6.0) gitlab_meta (6.0) gitlab_omniauth-ldap (1.0.3) net-ldap (~> 0.3.1) @@ -543,10 +543,10 @@ DEPENDENCIES gemoji (~> 1.2.1) github-linguist github-markup (~> 0.7.4) - gitlab-gollum-lib (~> 1.0.0) + gitlab-gollum-lib (~> 1.0.1) gitlab-grack (~> 1.0.1) gitlab-pygments.rb (~> 0.3.2) - gitlab_git (~> 1.3.0) + gitlab_git (~> 1.4.1) gitlab_meta (= 6.0) gitlab_omniauth-ldap (= 1.0.3) gon -- cgit v1.2.1 From 0f84833c33174e4c8cd72690e93bba5444d9e25f Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sun, 30 Jun 2013 19:19:06 +0300 Subject: Remove capistrano files since its very problematic to deploy gitlab with it --- Capfile.example | 4 --- config/deploy.rb.example | 72 ------------------------------------------------ 2 files changed, 76 deletions(-) delete mode 100644 Capfile.example delete mode 100644 config/deploy.rb.example diff --git a/Capfile.example b/Capfile.example deleted file mode 100644 index 8863835da4a..00000000000 --- a/Capfile.example +++ /dev/null @@ -1,4 +0,0 @@ -load 'deploy' -load 'deploy/assets' -require 'bundler/capistrano' -load 'config/deploy' diff --git a/config/deploy.rb.example b/config/deploy.rb.example deleted file mode 100644 index ddce4671b58..00000000000 --- a/config/deploy.rb.example +++ /dev/null @@ -1,72 +0,0 @@ -set :domain, 'set application domain here' -set :db_adapter, 'mysql' # or postgres -set :mount_point, '/' -set :application, 'gitlabhq' -set :user, 'git' -set :rails_env, 'production' -set :deploy_to, "/home/#{user}/apps/#{application}" -set :bundle_without, %w[development test] + (%w[mysql postgres] - [db_adapter]) -set :asset_env, "RAILS_GROUPS=assets RAILS_RELATIVE_URL_ROOT=#{mount_point.sub /\/+\Z/, ''}" - -set :use_sudo, false -default_run_options[:pty] = true - -# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none` -set :scm, :git -set :repository, "git@#{domain}:#{application}.git" -set :deploy_via, :remote_cache - -# Alternatively, you can deploy via copy, if you don't have gitlab in git -#set :scm, :none -#set :repository, '.' -#set :deploy_via, :copy - -server domain, :app, :web, :db, primary: true - -namespace :foreman do - desc 'Export the Procfile to Ubuntu upstart scripts' - task :export, roles: :app do - foreman_export = "foreman export upstart /etc/init -f Procfile -a #{application} -u #{user} -l #{shared_path}/log/foreman" - run "cd #{release_path} && #{sudo} #{fetch :bundle_cmd, 'bundle'} exec #{foreman_export}" - end - - desc 'Start the application services' - task :start, roles: :app do - run "#{sudo} service #{application} start" - end - - desc 'Stop the application services' - task :stop, roles: :app do - run "#{sudo} service #{application} stop" - end - - desc 'Restart the application services' - task :restart, roles: :app do - run "#{sudo} service #{application} restart" - end -end - -namespace :deploy do - desc 'Start the application services' - task :start, roles: :app do - foreman.start - end - - desc 'Stop the application services' - task :stop, roles: :app do - foreman.stop - end - - desc 'Restart the application services' - task :restart, roles: :app do - foreman.restart - end -end - -after 'deploy:cold' do - run "cd #{release_path} && #{rake} gitlab:setup force=yes RAILS_ENV=#{rails_env}" - deploy.restart -end - -after 'deploy:update', 'foreman:export' # Export foreman scripts -#after 'deploy:update', 'foreman:restart' # Restart application scripts -- cgit v1.2.1 From 6e550af150958d0c88bf21f206c2309dc0b5c78d Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sun, 30 Jun 2013 22:10:52 +0300 Subject: Show shotcut dialog on ? --- app/assets/javascripts/main.js.coffee | 3 +++ app/assets/javascripts/shortcuts.js.coffee | 11 +++++++++++ app/controllers/help_controller.rb | 3 +++ app/views/help/_shortcuts.html.haml | 14 ++++++++++++++ app/views/help/shortcuts.js.haml | 3 +++ app/views/layouts/_head_panel.html.haml | 1 - config/routes.rb | 1 + 7 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 app/assets/javascripts/shortcuts.js.coffee create mode 100644 app/views/help/_shortcuts.html.haml create mode 100644 app/views/help/shortcuts.js.haml diff --git a/app/assets/javascripts/main.js.coffee b/app/assets/javascripts/main.js.coffee index b96ef65af93..cb9678d4839 100644 --- a/app/assets/javascripts/main.js.coffee +++ b/app/assets/javascripts/main.js.coffee @@ -67,6 +67,9 @@ $ -> $('.appear-data').fadeIn() e.preventDefault() + $('body').keydown (e) -> + if e.which is 191 + new Shortcuts() # Initialize chosen selects $('select.chosen').chosen() diff --git a/app/assets/javascripts/shortcuts.js.coffee b/app/assets/javascripts/shortcuts.js.coffee new file mode 100644 index 00000000000..e7e40a066ec --- /dev/null +++ b/app/assets/javascripts/shortcuts.js.coffee @@ -0,0 +1,11 @@ +class Shortcuts + constructor: -> + if $('#modal-shortcuts').length > 0 + $('#modal-shortcuts').modal('show') + else + $.ajax( + url: '/help/shortcuts', + dataType: "script" + ) + +@Shortcuts = Shortcuts diff --git a/app/controllers/help_controller.rb b/app/controllers/help_controller.rb index 2958367e0f8..051cbdfaf05 100644 --- a/app/controllers/help_controller.rb +++ b/app/controllers/help_controller.rb @@ -12,4 +12,7 @@ class HelpController < ApplicationController not_found! end end + + def shortcuts + end end diff --git a/app/views/help/_shortcuts.html.haml b/app/views/help/_shortcuts.html.haml new file mode 100644 index 00000000000..7cbe5fc45ff --- /dev/null +++ b/app/views/help/_shortcuts.html.haml @@ -0,0 +1,14 @@ +#modal-shortcuts.modal.hide + .modal-header + %a.close{href: "#"} × + %h3 Keyboard Shortcuts + .modal-body + %h5 Global Shortcuts + %p + %span.label.label-inverse s + – + Focus Search + %p + %span.label.label-inverse ? + – + Show this dialog diff --git a/app/views/help/shortcuts.js.haml b/app/views/help/shortcuts.js.haml new file mode 100644 index 00000000000..99ed042ea3b --- /dev/null +++ b/app/views/help/shortcuts.js.haml @@ -0,0 +1,3 @@ +:plain + $("body").append("#{escape_javascript(render('shortcuts'))}"); + $("#modal-shortcuts").modal(); diff --git a/app/views/layouts/_head_panel.html.haml b/app/views/layouts/_head_panel.html.haml index e59528897d1..2fbac5fff37 100644 --- a/app/views/layouts/_head_panel.html.haml +++ b/app/views/layouts/_head_panel.html.haml @@ -38,4 +38,3 @@ %li = link_to current_user, class: "profile-pic", id: 'profile-pic' do = image_tag gravatar_icon(current_user.email, 26) - diff --git a/config/routes.rb b/config/routes.rb index 0e6454f00e7..4e0c010840f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -38,6 +38,7 @@ Gitlab::Application.routes.draw do get 'help/system_hooks' => 'help#system_hooks' get 'help/web_hooks' => 'help#web_hooks' get 'help/workflow' => 'help#workflow' + get 'help/shortcuts' # # Global snippets -- cgit v1.2.1 From f49fb5dca1ecf2b1ae6415920de09b4d95c14bb1 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 1 Jul 2013 19:01:19 +0300 Subject: Fix error when reassign issue/merge_request from non-assigned. Fixes #3201 --- app/mailers/emails/issues.rb | 2 +- app/mailers/emails/merge_requests.rb | 2 +- app/views/notify/reassigned_issue_email.html.haml | 6 ++++-- app/views/notify/reassigned_issue_email.text.erb | 4 +--- app/views/notify/reassigned_merge_request_email.html.haml | 6 ++++-- app/views/notify/reassigned_merge_request_email.text.erb | 2 +- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/app/mailers/emails/issues.rb b/app/mailers/emails/issues.rb index 79731b60f45..c1112a98f92 100644 --- a/app/mailers/emails/issues.rb +++ b/app/mailers/emails/issues.rb @@ -8,7 +8,7 @@ module Emails def reassigned_issue_email(recipient_id, issue_id, previous_assignee_id) @issue = Issue.find(issue_id) - @previous_assignee ||= User.find(previous_assignee_id) + @previous_assignee = User.find_by_id(previous_assignee_id) if previous_assignee_id @project = @issue.project mail(to: recipient(recipient_id), subject: subject("changed issue ##{@issue.id}", @issue.title)) end diff --git a/app/mailers/emails/merge_requests.rb b/app/mailers/emails/merge_requests.rb index 806f1b01b72..de47903c0d4 100644 --- a/app/mailers/emails/merge_requests.rb +++ b/app/mailers/emails/merge_requests.rb @@ -8,7 +8,7 @@ module Emails def reassigned_merge_request_email(recipient_id, merge_request_id, previous_assignee_id) @merge_request = MergeRequest.find(merge_request_id) - @previous_assignee ||= User.find(previous_assignee_id) + @previous_assignee = User.find_by_id(previous_assignee_id) if previous_assignee_id @project = @merge_request.project mail(to: recipient(recipient_id), subject: subject("changed merge request !#{@merge_request.id}", @merge_request.title)) end diff --git a/app/views/notify/reassigned_issue_email.html.haml b/app/views/notify/reassigned_issue_email.html.haml index 018f20bf708..6d332af3d70 100644 --- a/app/views/notify/reassigned_issue_email.html.haml +++ b/app/views/notify/reassigned_issue_email.html.haml @@ -2,8 +2,10 @@ = "Reassigned Issue ##{@issue.id}" = link_to_gfm truncate(@issue.title, length: 30), project_issue_url(@issue.project, @issue) %p - Assignee changed from - %strong #{@previous_assignee.name} + Assignee changed + - if @previous_assignee + from + %strong #{@previous_assignee.name} to %strong #{@issue.assignee_name} diff --git a/app/views/notify/reassigned_issue_email.text.erb b/app/views/notify/reassigned_issue_email.text.erb index 497044184dc..867c4d01da5 100644 --- a/app/views/notify/reassigned_issue_email.text.erb +++ b/app/views/notify/reassigned_issue_email.text.erb @@ -2,6 +2,4 @@ Reassigned Issue <%= @issue.id %> <%= url_for(project_issue_url(@issue.project, @issue)) %> - -Assignee changed from <%= @previous_assignee.name %> to <%= @issue.assignee_name %> - +Assignee changed <%= "from #{@previous_assignee.name}" if @previous_assignee %> to <%= @issue.assignee_name %> diff --git a/app/views/notify/reassigned_merge_request_email.html.haml b/app/views/notify/reassigned_merge_request_email.html.haml index 9039bc8b12d..5ad72764e38 100644 --- a/app/views/notify/reassigned_merge_request_email.html.haml +++ b/app/views/notify/reassigned_merge_request_email.html.haml @@ -2,7 +2,9 @@ = "Reassigned Merge Request !#{@merge_request.id}" = link_to_gfm truncate(@merge_request.title, length: 30), project_merge_request_url(@merge_request.project, @merge_request) %p - Assignee changed from - %strong #{@previous_assignee.name} + Assignee changed + - if @previous_assignee + from + %strong #{@previous_assignee.name} to %strong #{@merge_request.assignee_name} diff --git a/app/views/notify/reassigned_merge_request_email.text.erb b/app/views/notify/reassigned_merge_request_email.text.erb index 1af4ab559f6..25b2a43fcdd 100644 --- a/app/views/notify/reassigned_merge_request_email.text.erb +++ b/app/views/notify/reassigned_merge_request_email.text.erb @@ -3,5 +3,5 @@ Reassigned Merge Request <%= @merge_request.id %> <%= url_for(project_merge_request_url(@merge_request.project, @merge_request)) %> -Assignee changed from <%= @previous_assignee.name %> to <%= @merge_request.assignee_name %> +Assignee changed <%= "from #{@previous_assignee.name}" if @previous_assignee %> to <%= @merge_request.assignee_name %> -- cgit v1.2.1 From 15bc1223c79a8cfbc558b2eaaca06994e0272333 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 2 Jul 2013 14:06:25 +0300 Subject: Work on themes a bit --- app/assets/stylesheets/sections/header.scss | 6 +++++- app/assets/stylesheets/sections/nav.scss | 1 + app/assets/stylesheets/sections/themes.scss | 6 +++--- app/assets/stylesheets/themes/ui_basic.scss | 4 ++++ app/assets/stylesheets/themes/ui_color.scss | 8 ++++---- app/assets/stylesheets/themes/ui_gray.scss | 8 ++++---- app/assets/stylesheets/themes/ui_mars.scss | 8 -------- app/assets/stylesheets/themes/ui_modern.scss | 8 ++++---- app/views/profiles/design.html.haml | 2 +- 9 files changed, 26 insertions(+), 25 deletions(-) diff --git a/app/assets/stylesheets/sections/header.scss b/app/assets/stylesheets/sections/header.scss index ba92e8554cb..98c010ed72d 100644 --- a/app/assets/stylesheets/sections/header.scss +++ b/app/assets/stylesheets/sections/header.scss @@ -120,7 +120,7 @@ header { border-bottom: 1px solid #AAA; .nav > li > a { - color: #DDD; + color: #AAA; text-shadow: 0 1px 0 #444; &:hover { @@ -130,6 +130,10 @@ header { } } + .turbolink-spinner { + color: #FFF; + } + .search { .search-input { background-color: #D2D5DA; diff --git a/app/assets/stylesheets/sections/nav.scss b/app/assets/stylesheets/sections/nav.scss index fc1f1bc79b4..7d09f548589 100644 --- a/app/assets/stylesheets/sections/nav.scss +++ b/app/assets/stylesheets/sections/nav.scss @@ -1,4 +1,5 @@ .main-nav { + background: #f5f5f5; margin: 30px 0; margin-top: 0; padding-top: 4px; diff --git a/app/assets/stylesheets/sections/themes.scss b/app/assets/stylesheets/sections/themes.scss index 4e5eaf575ae..c5487f9f40c 100644 --- a/app/assets/stylesheets/sections/themes.scss +++ b/app/assets/stylesheets/sections/themes.scss @@ -27,15 +27,15 @@ } &.modern { - background: #567; + background: #345; } &.gray { - background: #708090; + background: #373737; } &.violet { - background: #657; + background: #547; } } } diff --git a/app/assets/stylesheets/themes/ui_basic.scss b/app/assets/stylesheets/themes/ui_basic.scss index b0ee94ef34a..30f0bbaf4c8 100644 --- a/app/assets/stylesheets/themes/ui_basic.scss +++ b/app/assets/stylesheets/themes/ui_basic.scss @@ -8,4 +8,8 @@ background: #F9F9F9; border-left: 1px solid #DDD; } + + .main-nav { + background: #FFF; + } } diff --git a/app/assets/stylesheets/themes/ui_color.scss b/app/assets/stylesheets/themes/ui_color.scss index d7a554ff9e5..07e854b73d8 100644 --- a/app/assets/stylesheets/themes/ui_color.scss +++ b/app/assets/stylesheets/themes/ui_color.scss @@ -16,15 +16,15 @@ @extend .header-dark; &.navbar-gitlab { .navbar-inner { - background: #657; + background: #547; .app_logo { &:hover { - background-color: #6A5A7A; + background-color: #435; } } .separator { - background: #546; - border-left: 1px solid #706080; + background: #435; + border-left: 1px solid #658; } } } diff --git a/app/assets/stylesheets/themes/ui_gray.scss b/app/assets/stylesheets/themes/ui_gray.scss index f0547c72157..4f88c631e4d 100644 --- a/app/assets/stylesheets/themes/ui_gray.scss +++ b/app/assets/stylesheets/themes/ui_gray.scss @@ -16,15 +16,15 @@ @extend .header-dark; &.navbar-gitlab { .navbar-inner { - background: #708090; + background: #373737; .app_logo { &:hover { - background-color: #6A7A8A; + background-color: #272727; } } .separator { - background: #607080; - border-left: 1px solid #8090A0; + background: #272727; + border-left: 1px solid #474747; } } } diff --git a/app/assets/stylesheets/themes/ui_mars.scss b/app/assets/stylesheets/themes/ui_mars.scss index d40a02206e7..a2b8c21ea11 100644 --- a/app/assets/stylesheets/themes/ui_mars.scss +++ b/app/assets/stylesheets/themes/ui_mars.scss @@ -23,20 +23,12 @@ background-color: #373D47; } } - .nav > li > a { color: #AAA; } } } - .turbolink-spinner { - color: #FFF; - } .separator { background: #31363E; border-left: 1px solid #666; } } - - .main-nav { - background: #f5f5f5; - } } diff --git a/app/assets/stylesheets/themes/ui_modern.scss b/app/assets/stylesheets/themes/ui_modern.scss index a5bf414c443..68318f93016 100644 --- a/app/assets/stylesheets/themes/ui_modern.scss +++ b/app/assets/stylesheets/themes/ui_modern.scss @@ -16,15 +16,15 @@ @extend .header-dark; &.navbar-gitlab { .navbar-inner { - background: #567; + background: #345; .app_logo { &:hover { - background-color: #516171; + background-color: #234; } } .separator { - background: #456; - border-left: 1px solid #678; + background: #234; + border-left: 1px solid #456; } } } diff --git a/app/views/profiles/design.html.haml b/app/views/profiles/design.html.haml index 9ada69c9d5d..9b6cace4e89 100644 --- a/app/views/profiles/design.html.haml +++ b/app/views/profiles/design.html.haml @@ -24,7 +24,7 @@ = label_tag do .prev.gray = f.radio_button :theme_id, 4 - SlateGray + Gray = label_tag do .prev.violet -- cgit v1.2.1 From 3802ae0cfa17dbe33d09e3d006b162fa9ab1c256 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 2 Jul 2013 14:26:13 +0300 Subject: Prevent tree log crash if commit missing --- app/views/projects/refs/logs_tree.js.haml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/projects/refs/logs_tree.js.haml b/app/views/projects/refs/logs_tree.js.haml index 1bea286a879..213c54f5f75 100644 --- a/app/views/projects/refs/logs_tree.js.haml +++ b/app/views/projects/refs/logs_tree.js.haml @@ -1,6 +1,7 @@ - @logs.each do |content_data| - file_name = content_data[:file_name] - commit = content_data[:commit] + - next unless commit :plain var row = $("table.table_#{@hex_path} tr.file_#{hexdigest(file_name)}"); -- cgit v1.2.1 From 44ac961b8d7e07f794330b6e527c50b437923fb5 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 3 Jul 2013 20:10:27 +0300 Subject: group filter from dashboard. Design improvements of dashboard --- app/assets/javascripts/dashboard.js.coffee | 9 ++++---- app/assets/stylesheets/sections/dashboard.scss | 31 ++++++++++++++++++++++---- app/assets/stylesheets/sections/events.scss | 4 ++-- app/views/dashboard/_groups.html.haml | 10 ++++----- app/views/dashboard/_projects.html.haml | 4 ++-- 5 files changed, 40 insertions(+), 18 deletions(-) diff --git a/app/assets/javascripts/dashboard.js.coffee b/app/assets/javascripts/dashboard.js.coffee index 57ede4ca598..8db53039e98 100644 --- a/app/assets/javascripts/dashboard.js.coffee +++ b/app/assets/javascripts/dashboard.js.coffee @@ -8,15 +8,16 @@ class Dashboard @toggleFilter($(event.currentTarget)) @reloadActivities() - $(".dash-projects-filter").keyup -> + $(".dash-filter").keyup -> terms = $(this).val() + uiBox = $(this).parents('.ui-box').first() if terms == "" || terms == undefined - $(".dash-projects-list li").show() + uiBox.find(".dash-list li").show() else - $(".dash-projects-list li").each (index) -> + uiBox.find(".dash-list li").each (index) -> name = $(this).find(".well-title").text() - if name.search(terms) == -1 + if name.toLowerCase().search(terms.toLowerCase()) == -1 $(this).hide() else $(this).show() diff --git a/app/assets/stylesheets/sections/dashboard.scss b/app/assets/stylesheets/sections/dashboard.scss index 2e5c93134a7..57088e55079 100644 --- a/app/assets/stylesheets/sections/dashboard.scss +++ b/app/assets/stylesheets/sections/dashboard.scss @@ -7,7 +7,9 @@ @extend .pull-right; .ui-box { - margin: 3px; + margin: 0px; + box-shadow: none; + > .title { padding: 2px 15px; } @@ -28,7 +30,6 @@ } } } - @extend .ui-box; } } } @@ -47,7 +48,7 @@ } .dashboard { - .dash-projects-filter { + .dash-filter { margin: 0; padding: 4px 6px; width: 202px; @@ -58,7 +59,29 @@ } @media (max-width: 1200px) { - .dashboard .dash-projects-filter { + .dashboard .dash-filter { width: 132px; } } + +.dash-sidebar-tabs { + margin-bottom: 2px; + border: none; + margin: 0; + + li { + &.active { + a { + @include linear-gradient(#f5f5f5, #eee); + border-bottom: 1px solid #EEE !important; + &:hover { + background: #eee; + } + } + } + + a { + border-color: #CCC !important; + } + } +} diff --git a/app/assets/stylesheets/sections/events.scss b/app/assets/stylesheets/sections/events.scss index d057bcf669c..b4e4c3fd8b6 100644 --- a/app/assets/stylesheets/sections/events.scss +++ b/app/assets/stylesheets/sections/events.scss @@ -51,7 +51,7 @@ .event-note { color: #555; margin-top: 5px; - margin-left: 40px; + margin-left: 35px; pre { border: none; @@ -95,7 +95,7 @@ } } ul { - margin-left: 50px; + margin-left: 35px; margin-bottom: 5px; .avatar { width: 18px; diff --git a/app/views/dashboard/_groups.html.haml b/app/views/dashboard/_groups.html.haml index 2fedf87a9ba..e138b42be47 100644 --- a/app/views/dashboard/_groups.html.haml +++ b/app/views/dashboard/_groups.html.haml @@ -1,14 +1,12 @@ .ui-box - %h5.title - Groups - %span.light - (#{groups.count}) + %h5.title.clearfix + = search_field_tag :filter_group, nil, placeholder: 'Filter by name', class: 'dash-filter' - if current_user.can_create_group? %span.pull-right - = link_to new_group_path, class: "btn btn-small" do + = link_to new_group_path, class: "btn" do %i.icon-plus New Group - %ul.well-list + %ul.well-list.dash-list - groups.each do |group| %li = link_to group_path(id: group.path), class: dom_class(group) do diff --git a/app/views/dashboard/_projects.html.haml b/app/views/dashboard/_projects.html.haml index 9d9d77b30d7..ae1e2e36391 100644 --- a/app/views/dashboard/_projects.html.haml +++ b/app/views/dashboard/_projects.html.haml @@ -1,13 +1,13 @@ .ui-box %h5.title.clearfix - = search_field_tag :filter_projects, nil, placeholder: 'Filter by name', class: 'dash-projects-filter' + = search_field_tag :filter_projects, nil, placeholder: 'Filter by name', class: 'dash-filter' - if current_user.can_create_project? %span.pull-right = link_to new_project_path, class: "btn" do %i.icon-plus New Project - %ul.well-list.dash-projects-list + %ul.well-list.dash-list - projects.each do |project| %li = link_to project_path(project), class: dom_class(project) do -- cgit v1.2.1 From 5f0b50db7aaa3d10bf2b49d5fb7ca55d6f3ccd10 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 4 Jul 2013 14:32:02 +0300 Subject: Discover default branch on project creationg --- app/contexts/projects/create_context.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/contexts/projects/create_context.rb b/app/contexts/projects/create_context.rb index a8c8effa79e..aee3c1c566c 100644 --- a/app/contexts/projects/create_context.rb +++ b/app/contexts/projects/create_context.rb @@ -48,6 +48,7 @@ module Projects # Import project from cloneable resource if @project.valid? && @project.import_url.present? shell = Gitlab::Shell.new + if shell.import_repository(@project.path_with_namespace, @project.import_url) # We should create satellite for imported repo @project.satellite.create unless @project.satellite.exists? @@ -58,8 +59,12 @@ module Projects end end - if @project.save && !@project.group - @project.users_projects.create(project_access: UsersProject::MASTER, user: current_user) + if @project.save + unless @project.group + @project.users_projects.create(project_access: UsersProject::MASTER, user: current_user) + end + + @project.discover_default_branch end @project -- cgit v1.2.1 From 5067e9dc88b5bf4d1aae06a8c12bb05d082f4f74 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 4 Jul 2013 17:10:34 +0300 Subject: Minor UI improve for dashboard events --- app/assets/stylesheets/common.scss | 13 ++++++++----- app/assets/stylesheets/sections/events.scss | 9 +++++++-- app/views/projects/notes/_form_errors.html.haml | 2 +- app/views/shared/_no_ssh.html.haml | 2 +- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/common.scss index 8c76b4baa22..1551af2d697 100644 --- a/app/assets/stylesheets/common.scss +++ b/app/assets/stylesheets/common.scss @@ -311,14 +311,17 @@ li.note { } } -.error_message { - @extend .cred; - border-left: 4px solid #E99; +.error-message { padding: 10px; - margin-bottom: 10px; - background: #FEE; + background: #C67; padding-left: 20px; + margin: 0; + color: #FFF; + a { + color: #fff; + text-decoration: underline; + } &.centered { text-align: center; } diff --git a/app/assets/stylesheets/sections/events.scss b/app/assets/stylesheets/sections/events.scss index b4e4c3fd8b6..0c75ddb8bc8 100644 --- a/app/assets/stylesheets/sections/events.scss +++ b/app/assets/stylesheets/sections/events.scss @@ -99,7 +99,7 @@ margin-bottom: 5px; .avatar { width: 18px; - margin-top: 3px; + margin: 2px 4px; } } @@ -118,7 +118,12 @@ } &.commits-stat { display: block; - margin-top: 5px; + padding: 3px; + margin-top: 3px; + + &:hover { + background: none; + } } } } diff --git a/app/views/projects/notes/_form_errors.html.haml b/app/views/projects/notes/_form_errors.html.haml index 0851536f0da..0b68bf243f0 100644 --- a/app/views/projects/notes/_form_errors.html.haml +++ b/app/views/projects/notes/_form_errors.html.haml @@ -1,3 +1,3 @@ -.error_message.js-errors +.error-message.js-errors - note.errors.full_messages.each do |msg| %div= msg diff --git a/app/views/shared/_no_ssh.html.haml b/app/views/shared/_no_ssh.html.haml index f8c2ea1eed3..82bf00aa280 100644 --- a/app/views/shared/_no_ssh.html.haml +++ b/app/views/shared/_no_ssh.html.haml @@ -1,3 +1,3 @@ - if current_user.require_ssh_key? - %p.error_message.centered + %p.error-message.centered You won't be able to pull or push project code via SSH until you #{link_to 'add an SSH key', new_profile_key_path} to your profile -- cgit v1.2.1 From 96448d1b7b48820a10bd0fff0ba95de56117e7e8 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 5 Jul 2013 15:19:31 +0300 Subject: Fix shortcuts popup --- app/assets/javascripts/main.js.coffee | 8 ++++---- app/views/help/_shortcuts.html.haml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/main.js.coffee b/app/assets/javascripts/main.js.coffee index cb9678d4839..0e7e0a4de13 100644 --- a/app/assets/javascripts/main.js.coffee +++ b/app/assets/javascripts/main.js.coffee @@ -67,10 +67,6 @@ $ -> $('.appear-data').fadeIn() e.preventDefault() - $('body').keydown (e) -> - if e.which is 191 - new Shortcuts() - # Initialize chosen selects $('select.chosen').chosen() @@ -114,6 +110,10 @@ $ -> when 115 $("#search").focus() e.preventDefault() + when 63 + new Shortcuts() + e.preventDefault() + # Commit show suppressed diff $(".supp_diff_link").bind "click", -> diff --git a/app/views/help/_shortcuts.html.haml b/app/views/help/_shortcuts.html.haml index 7cbe5fc45ff..793cb450c98 100644 --- a/app/views/help/_shortcuts.html.haml +++ b/app/views/help/_shortcuts.html.haml @@ -1,6 +1,6 @@ #modal-shortcuts.modal.hide .modal-header - %a.close{href: "#"} × + %a.close{href: "#", "data-dismiss" => "modal"} × %h3 Keyboard Shortcuts .modal-body %h5 Global Shortcuts -- cgit v1.2.1 From 7ee53643cfb10ad9620041d9e47cdb13f3bc2538 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 6 Jul 2013 10:58:33 +0300 Subject: Fix commit pagination --- app/views/projects/commits/show.js.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/projects/commits/show.js.haml b/app/views/projects/commits/show.js.haml index 797bc14cc1b..045c9dd83d7 100644 --- a/app/views/projects/commits/show.js.haml +++ b/app/views/projects/commits/show.js.haml @@ -1,3 +1,3 @@ :plain - CommitsList.append(#{@commits.count}, "#{escape_javascript(render(partial: 'commits/commits'))}"); + CommitsList.append(#{@commits.count}, "#{escape_javascript(render('projects/commits/commits'))}"); -- cgit v1.2.1 From 2643ee72a9c1735fd045d751f0f56a286ea0759c Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 6 Jul 2013 10:59:00 +0300 Subject: docs to ruby 2.0 --- doc/install/installation.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/install/installation.md b/doc/install/installation.md index 47faab407e3..ed58d5ccbb0 100644 --- a/doc/install/installation.md +++ b/doc/install/installation.md @@ -86,8 +86,8 @@ Remove the old Ruby 1.8 if present Download Ruby and compile it: mkdir /tmp/ruby && cd /tmp/ruby - curl --progress http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p392.tar.gz | tar xz - cd ruby-1.9.3-p392 + curl --progress ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p247.tar.gz | tar xz + cd ruby-2.0.0-p247 ./configure make sudo make install -- cgit v1.2.1 From 1738c17f331ca84700e028b653c3c4cb5b1eb7a8 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 6 Jul 2013 12:13:28 +0300 Subject: Update puma --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index c38cede758d..d6037d87067 100644 --- a/Gemfile +++ b/Gemfile @@ -76,7 +76,7 @@ gem "github-markup", "~> 0.7.4", require: 'github/markup' gem "asciidoctor" # Servers -gem "puma", '~> 2.1.1' +gem "puma", '~> 2.3.0' # State machine gem "state_machine" diff --git a/Gemfile.lock b/Gemfile.lock index 369be882e14..c0cc4cf415b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -306,7 +306,7 @@ GEM coderay (~> 1.0.5) method_source (~> 0.8) slop (~> 3.4) - puma (2.1.1) + puma (2.3.0) rack (>= 1.1, < 2.0) pygments.rb (0.4.2) posix-spawn (~> 0.3.6) @@ -576,7 +576,7 @@ DEPENDENCIES pg poltergeist (~> 1.3.0) pry - puma (~> 2.1.1) + puma (~> 2.3.0) quiet_assets (~> 1.0.1) rack-mini-profiler rails (= 3.2.13) -- cgit v1.2.1 From db11c1fd88660c3cf49ddb737f2b709981c0f554 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 8 Jul 2013 07:38:19 +0300 Subject: Puma to 2.3.1 --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index d6037d87067..3810073c260 100644 --- a/Gemfile +++ b/Gemfile @@ -76,7 +76,7 @@ gem "github-markup", "~> 0.7.4", require: 'github/markup' gem "asciidoctor" # Servers -gem "puma", '~> 2.3.0' +gem "puma", '~> 2.3.1' # State machine gem "state_machine" diff --git a/Gemfile.lock b/Gemfile.lock index c0cc4cf415b..f259f908a22 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -306,7 +306,7 @@ GEM coderay (~> 1.0.5) method_source (~> 0.8) slop (~> 3.4) - puma (2.3.0) + puma (2.3.1) rack (>= 1.1, < 2.0) pygments.rb (0.4.2) posix-spawn (~> 0.3.6) @@ -576,7 +576,7 @@ DEPENDENCIES pg poltergeist (~> 1.3.0) pry - puma (~> 2.3.0) + puma (~> 2.3.1) quiet_assets (~> 1.0.1) rack-mini-profiler rails (= 3.2.13) -- cgit v1.2.1 From 2882d16e7a244d6627d9f6d9436651a38bf11bad Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 8 Jul 2013 07:55:16 +0300 Subject: cleanup puma config a bit --- config/puma.rb.example | 38 +++----------------------------------- 1 file changed, 3 insertions(+), 35 deletions(-) diff --git a/config/puma.rb.example b/config/puma.rb.example index ad5e3e23501..025ff7f3f05 100644 --- a/config/puma.rb.example +++ b/config/puma.rb.example @@ -8,47 +8,12 @@ # ENV['RAILS_RELATIVE_URL_ROOT'] = "/gitlab" application_path = '/home/git/gitlab' - -# The directory to operate out of. -# -# The default is the current directory. -# directory application_path - -# Set the environment in which the rack's app will run. -# -# The default is “development”. -# environment 'production' - -# Daemonize the server into the background. Highly suggest that -# this be combined with “pidfile” and “stdout_redirect”. -# -# The default is “false”. -# daemonize true - -# Store the pid of the server in the file at “path”. -# pidfile "#{application_path}/tmp/pids/puma.pid" - -# Use “path” as the file to store the server info state. This is -# used by “pumactl” to query and control the server. -# state_path "#{application_path}/tmp/pids/puma.state" - -# Redirect STDOUT and STDERR to files specified. The 3rd parameter -# (“append”) specifies whether the output is appended, the default is -# “false”. -# stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" -# stdout_redirect '/u/apps/lolcat/log/stdout', '/u/apps/lolcat/log/stderr', true - -# Disable request logging. -# -# The default is “false”. -# -# quiet # Configure “min” to be the minimum number of threads to use to answer # requests and “max” the maximum. @@ -63,6 +28,9 @@ stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/ # The default is “tcp://0.0.0.0:9292”. # # bind 'tcp://0.0.0.0:9292' +# bind 'unix:///var/run/puma.sock' +# bind 'unix:///var/run/puma.sock?umask=0777' +# bind 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert' bind "unix://#{application_path}/tmp/sockets/gitlab.socket" # Instead of “bind 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert'” you -- cgit v1.2.1 From fe4601361d0d713451a3ad6c398f45e8c7bd6211 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 8 Jul 2013 16:05:09 +0300 Subject: Milestone page: reduce truncate length to prevent issue title overflow --- app/views/projects/milestones/_issues.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/projects/milestones/_issues.html.haml b/app/views/projects/milestones/_issues.html.haml index eccf3ddbfa5..67a7bf819fe 100644 --- a/app/views/projects/milestones/_issues.html.haml +++ b/app/views/projects/milestones/_issues.html.haml @@ -5,7 +5,7 @@ %li = link_to [@project, issue] do %span.badge{class: issue.closed? ? 'badge-important' : 'badge-info'} ##{issue.id} - = link_to_gfm truncate(issue.title, length: 60), [@project, issue] + = link_to_gfm truncate(issue.title, length: 40), [@project, issue] - if issue.assignee .pull-right = image_tag gravatar_icon(issue.assignee.email, 16), class: "avatar s16" -- cgit v1.2.1 From 66d6c809662980041fce66d182489c025475e7a7 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 8 Jul 2013 18:24:02 +0300 Subject: Disable threadsafety --- config/environments/production.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index 7e02c75e562..2e2d46c4161 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -52,7 +52,7 @@ Gitlab::Application.configure do # config.action_mailer.raise_delivery_errors = false # Enable threaded mode - config.threadsafe! unless $rails_rake_task + # config.threadsafe! unless $rails_rake_task # Enable locale fallbacks for I18n (makes lookups for any locale fall back to # the I18n.default_locale when a translation can not be found) -- cgit v1.2.1 From 87f4e1f153ef763bbdbd614f3c9e1f2ea4798830 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 8 Jul 2013 18:28:40 +0300 Subject: init.d script for unicorn --- lib/support/init.d/gitlab_unicorn | 138 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 lib/support/init.d/gitlab_unicorn diff --git a/lib/support/init.d/gitlab_unicorn b/lib/support/init.d/gitlab_unicorn new file mode 100644 index 00000000000..2b26a962a8a --- /dev/null +++ b/lib/support/init.d/gitlab_unicorn @@ -0,0 +1,138 @@ +#! /bin/bash + +# GITLAB +# Maintainer: @randx +# App Version: 6.0 + +### BEGIN INIT INFO +# Provides: gitlab +# Required-Start: $local_fs $remote_fs $network $syslog redis-server +# Required-Stop: $local_fs $remote_fs $network $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: GitLab git repository management +# Description: GitLab git repository management +### END INIT INFO + + +APP_ROOT="/home/git/gitlab" +APP_USER="git" +DAEMON_OPTS="-C $APP_ROOT/config/unicorn.rb -E production" +PID_PATH="$APP_ROOT/tmp/pids" +SOCKET_PATH="$APP_ROOT/tmp/sockets" +WEB_SERVER_PID="$PID_PATH/unicorn.pid" +SIDEKIQ_PID="$PID_PATH/sidekiq.pid" +STOP_SIDEKIQ="RAILS_ENV=production bundle exec rake sidekiq:stop" +START_SIDEKIQ="RAILS_ENV=production bundle exec rake sidekiq:start" +NAME="gitlab" +DESC="GitLab service" + +check_pid(){ + if [ -f $WEB_SERVER_PID ]; then + PID=`cat $WEB_SERVER_PID` + SPID=`cat $SIDEKIQ_PID` + STATUS=`ps aux | grep $PID | grep -v grep | wc -l` + else + STATUS=0 + PID=0 + fi +} + +execute() { + sudo -u $APP_USER -H bash -l -c "$1" +} + +start() { + cd $APP_ROOT + check_pid + if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then + # Program is running, exit with error code 1. + echo "Error! $DESC $NAME is currently running!" + exit 1 + else + if [ `whoami` = root ]; then + execute "rm -f $SOCKET_PATH/gitlab.socket" + execute "RAILS_ENV=production bundle exec unicorn_rails $DAEMON_OPTS > /dev/null 2>&1 &" + execute "mkdir -p $PID_PATH && $START_SIDEKIQ > /dev/null 2>&1 &" + echo "$DESC started" + fi + fi +} + +stop() { + cd $APP_ROOT + check_pid + if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then + ## Program is running, stop it. + kill -QUIT `cat $WEB_SERVER_PID` + execute "mkdir -p $PID_PATH && $STOP_SIDEKIQ > /dev/null 2>&1 &" + rm "$WEB_SERVER_PID" >> /dev/null + echo "$DESC stopped" + else + ## Program is not running, exit with error. + echo "Error! $DESC not started!" + exit 1 + fi +} + +restart() { + cd $APP_ROOT + check_pid + if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then + echo "Restarting $DESC..." + kill -USR2 `cat $WEB_SERVER_PID` + execute "mkdir -p $PID_PATH && $STOP_SIDEKIQ > /dev/null 2>&1 &" + if [ `whoami` = root ]; then + execute "mkdir -p $PID_PATH && $START_SIDEKIQ > /dev/null 2>&1 &" + fi + echo "$DESC restarted." + else + echo "Error, $NAME not running!" + exit 1 + fi +} + +status() { + cd $APP_ROOT + check_pid + if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then + echo "$DESC / Puma with PID $PID is running." + echo "$DESC / Sidekiq with PID $SPID is running." + else + echo "$DESC is not running." + exit 1 + fi +} + +## Check to see if we are running as root first. +## Found at http://www.cyberciti.biz/tips/shell-root-user-check-script.html +if [ "$(id -u)" != "0" ]; then + echo "This script must be run as root" + exit 1 +fi + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart) + restart + ;; + reload|force-reload) + echo -n "Reloading $NAME configuration: " + kill -HUP `cat $PID` + echo "done." + ;; + status) + status + ;; + *) + echo "Usage: sudo service gitlab {start|stop|restart|reload}" >&2 + exit 1 + ;; +esac + +exit 0 -- cgit v1.2.1 From 967d42e0c8701c82d7d7494b1fd1d96cd4f2973f Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 8 Jul 2013 19:28:59 +0300 Subject: Fix unicorn init and config --- config/unicorn.rb.example | 2 +- lib/support/init.d/gitlab_unicorn | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/unicorn.rb.example b/config/unicorn.rb.example index 00c509dd829..e010de6d6a9 100644 --- a/config/unicorn.rb.example +++ b/config/unicorn.rb.example @@ -21,7 +21,7 @@ worker_processes 2 # Help ensure your application will always spawn in the symlinked # "current" directory that Capistrano sets up. -working_directory "/home/git/gitlab/current" # available in 0.94.0+ +working_directory "/home/git/gitlab" # available in 0.94.0+ # listen on both a Unix domain socket and a TCP port, # we use a shorter backlog for quicker failover when busy diff --git a/lib/support/init.d/gitlab_unicorn b/lib/support/init.d/gitlab_unicorn index 2b26a962a8a..219776c8684 100644 --- a/lib/support/init.d/gitlab_unicorn +++ b/lib/support/init.d/gitlab_unicorn @@ -17,7 +17,7 @@ APP_ROOT="/home/git/gitlab" APP_USER="git" -DAEMON_OPTS="-C $APP_ROOT/config/unicorn.rb -E production" +DAEMON_OPTS="-c $APP_ROOT/config/unicorn.rb -E production" PID_PATH="$APP_ROOT/tmp/pids" SOCKET_PATH="$APP_ROOT/tmp/sockets" WEB_SERVER_PID="$PID_PATH/unicorn.pid" -- cgit v1.2.1 From 63e532eff01ac927e7fa39781d9ebd61503c9a3e Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 8 Jul 2013 20:12:35 +0300 Subject: Cache MR diffs result. Improve diff output --- Procfile | 2 +- app/controllers/projects/merge_requests_controller.rb | 1 - app/models/merge_request.rb | 4 +++- app/views/projects/merge_requests/_show.html.haml | 3 ++- app/views/projects/merge_requests/show/_diffs.html.haml | 2 +- doc/install/installation.md | 6 +++--- 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Procfile b/Procfile index fade88bd3a3..9003369c938 100644 --- a/Procfile +++ b/Procfile @@ -1,2 +1,2 @@ -web: bundle exec puma -p $PORT +web: bundle exec unicorn_rails -p $PORT -E development worker: bundle exec sidekiq -q post_receive,mailer,system_hook,project_web_hook,common,default,gitlab_shell diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index 0aa8bc8a6df..33c1a1feff7 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -30,7 +30,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController end def diffs - @diffs = @merge_request.diffs @commit = @merge_request.last_commit @comments_allowed = @reply_allowed = true diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index c45af9f713e..2a476355404 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -116,7 +116,7 @@ class MergeRequest < ActiveRecord::Base end def diffs - load_diffs(st_diffs) || [] + @diffs ||= (load_diffs(st_diffs) || []) end def reloaded_diffs @@ -128,6 +128,8 @@ class MergeRequest < ActiveRecord::Base def broken_diffs? diffs == broken_diffs + rescue + true end def valid_diffs? diff --git a/app/views/projects/merge_requests/_show.html.haml b/app/views/projects/merge_requests/_show.html.haml index 987fb4bcc49..8df12644fa1 100644 --- a/app/views/projects/merge_requests/_show.html.haml +++ b/app/views/projects/merge_requests/_show.html.haml @@ -21,7 +21,8 @@ .notes.tab-content.voting_notes#notes{ class: (controller.action_name == 'show') ? "" : "hide" } = render "projects/notes/notes_with_form" .diffs.tab-content - = render "projects/merge_requests/show/diffs" if @diffs + - if current_page?(action: 'diffs') + = render "projects/merge_requests/show/diffs" .status :javascript diff --git a/app/views/projects/merge_requests/show/_diffs.html.haml b/app/views/projects/merge_requests/show/_diffs.html.haml index 1d52e824fad..3c1d14572aa 100644 --- a/app/views/projects/merge_requests/show/_diffs.html.haml +++ b/app/views/projects/merge_requests/show/_diffs.html.haml @@ -1,5 +1,5 @@ - if @merge_request.valid_diffs? - = render "projects/commits/diffs", diffs: @diffs + = render "projects/commits/diffs", diffs: @merge_request.diffs - elsif @merge_request.broken_diffs? %h4.nothing_here_message Can't load diff. diff --git a/doc/install/installation.md b/doc/install/installation.md index 09b09c2aa45..9200d597259 100644 --- a/doc/install/installation.md +++ b/doc/install/installation.md @@ -184,11 +184,11 @@ You can change `5-3-stable` to `master` if you want the *bleeding edge* version, sudo chmod -R u+rwX public/uploads # Copy the example Puma config - sudo -u git -H cp config/puma.rb.example config/puma.rb + sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb # Enable cluster mode if you expect to have a high load instance # Ex. change amount of workers to 3 for 2GB RAM server - sudo -u git -H vim config/puma.rb + sudo -u git -H vim config/unicorn.rb # Configure Git global settings for git user, useful when editing via web # Edit user.email according to what is set in gitlab.yml @@ -196,7 +196,7 @@ You can change `5-3-stable` to `master` if you want the *bleeding edge* version, sudo -u git -H git config --global user.email "gitlab@localhost" **Important Note:** -Make sure to edit both `gitlab.yml` and `puma.rb` to match your setup. +Make sure to edit both `gitlab.yml` and `unicorn.rb` to match your setup. ## Configure GitLab DB settings -- cgit v1.2.1 From 5baac66992a1a4e3df4f9873632a9a083e52b92c Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 9 Jul 2013 10:44:47 +0300 Subject: More info (like 10 branches, 5 tags) at project show page --- app/models/repository.rb | 23 +++++++++++++++++++++-- app/views/projects/show.html.haml | 23 ++++++++++++++++++++--- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/app/models/repository.rb b/app/models/repository.rb index 33b7c556658..b18e98bdf47 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -33,6 +33,18 @@ class Repository commits end + def round_commit_count + if commit_count > 10000 + '10000+' + elsif commit_count > 5000 + '5000+' + elsif commit_count > 1000 + '1000+' + else + commit_count + end + end + def branch_names Rails.cache.fetch(cache_key(:branch_names)) do raw_repository.branch_names @@ -45,8 +57,10 @@ class Repository end end - def method_missing(m, *args, &block) - raw_repository.send(m, *args, &block) + def commit_count + Rails.cache.fetch(cache_key(:commit_count)) do + raw_repository.raw.commit_count + end end # Return repo size in megabytes @@ -61,6 +75,7 @@ class Repository Rails.cache.delete(cache_key(:size)) Rails.cache.delete(cache_key(:branch_names)) Rails.cache.delete(cache_key(:tag_names)) + Rails.cache.delete(cache_key(:commit_count)) Rails.cache.delete(cache_key(:graph_log)) end @@ -75,6 +90,10 @@ class Repository "#{type}:#{path_with_namespace}" end + def method_missing(m, *args, &block) + raw_repository.send(m, *args, &block) + end + def respond_to?(method) return true if raw_repository.respond_to?(method) diff --git a/app/views/projects/show.html.haml b/app/views/projects/show.html.haml index 7d708ce7b8f..11067234406 100644 --- a/app/views/projects/show.html.haml +++ b/app/views/projects/show.html.haml @@ -37,9 +37,18 @@ %hr %p - %p Repo Size: #{@project.repository.size} MB - %p Created on: #{@project.created_at.stamp('Aug 22, 2013')} - %p Owner: #{link_to @project.owner_name, @project.owner} + %p + %span.light Repo size is + #{@project.repository.size} MB + %p + %span.light Created at + #{@project.created_at.stamp('Aug 22, 2013')} + %p + %span.light Owned by + - if @project.group + #{link_to @project.group.name, @project.group} Group + - else + #{link_to @project.owner_name, @project.owner} - if @project.forked_from_project %p %i.icon-code-fork @@ -50,3 +59,11 @@ %hr = link_to @project.gitlab_ci_service.builds_path do = image_tag @project.gitlab_ci_service.status_img_path, alt: "build status" + + %hr + %p + = link_to pluralize(@repository.round_commit_count, 'commit'), project_commits_path(@project) + %p + = link_to pluralize(@repository.branch_names.count, 'branch'), project_repository_path(@project) + %p + = link_to pluralize(@repository.tag_names.count, 'tag'), tags_project_repository_path(@project) -- cgit v1.2.1 From f63cd42bab1afe48c795cf28e4d73ecfe156b6c0 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 9 Jul 2013 17:44:35 +0300 Subject: Better control placement on project page --- app/views/projects/_clone_panel.html.haml | 29 ++++++++++++++++++++----- app/views/projects/show.html.haml | 36 ++++++------------------------- 2 files changed, 31 insertions(+), 34 deletions(-) diff --git a/app/views/projects/_clone_panel.html.haml b/app/views/projects/_clone_panel.html.haml index ebce06edf74..4aee2b16bdb 100644 --- a/app/views/projects/_clone_panel.html.haml +++ b/app/views/projects/_clone_panel.html.haml @@ -17,9 +17,28 @@ - if can? current_user, :download_code, @project = link_to archive_project_repository_path(@project), class: "btn grouped" do %i.icon-download-alt - Download - - = link_to tags_project_repository_path(@project), class: "btn grouped only-wide", title: 'Git Tags' do - %i.icon-tags - Tags + %span.only-wide Download + .dropdown.pull-right + %a.dropdown-toggle.btn{href: '#', "data-toggle" => "dropdown"} + %i.icon-plus-sign-alt + %span.only-wide New + %b.caret + %ul.dropdown-menu + - if @project.issues_enabled && can?(current_user, :write_issue, @project) + %li + = link_to url_for_new_issue, title: "New Issue" do + Issue + - if @project.merge_requests_enabled && can?(current_user, :write_merge_request, @project) + %li + = link_to new_project_merge_request_path(@project), title: "New Merge Request" do + Merge Request + - if @project.snippets_enabled && can?(current_user, :write_snippet, @project) + %li + = link_to new_project_snippet_path(@project), title: "New Snippet" do + Snippet + - if can?(current_user, :admin_team_member, @project) + %li.divider + %li + = link_to new_project_team_member_path(@project), title: "New Team member" do + Team member diff --git a/app/views/projects/show.html.haml b/app/views/projects/show.html.haml index 11067234406..b36b56415aa 100644 --- a/app/views/projects/show.html.haml +++ b/app/views/projects/show.html.haml @@ -7,29 +7,6 @@ .loading.hide .span3 .light-well - .dropdown.pull-right - %a.dropdown-toggle.btn.btn-small{href: '#', "data-toggle" => "dropdown"} - %i.icon-plus-sign-alt - %b.caret - %ul.dropdown-menu - - if @project.issues_enabled && can?(current_user, :write_issue, @project) - %li - = link_to url_for_new_issue, title: "New Issue" do - Issue - - if @project.merge_requests_enabled && can?(current_user, :write_merge_request, @project) - %li - = link_to new_project_merge_request_path(@project), title: "New Merge Request" do - Merge Request - - if @project.snippets_enabled && can?(current_user, :write_snippet, @project) - %li - = link_to new_project_snippet_path(@project), title: "New Snippet" do - Snippet - - if can?(current_user, :admin_team_member, @project) - %li.divider - %li - = link_to new_project_team_member_path(@project), title: "New Team member" do - Team member - %h3.page_title = @project.name - if @project.description.present? @@ -55,15 +32,16 @@ Forked from: = link_to @project.forked_from_project.name_with_namespace, project_path(@project.forked_from_project) - - if @project.gitlab_ci? - %hr - = link_to @project.gitlab_ci_service.builds_path do - = image_tag @project.gitlab_ci_service.status_img_path, alt: "build status" - %hr %p - = link_to pluralize(@repository.round_commit_count, 'commit'), project_commits_path(@project) + = link_to pluralize(@repository.round_commit_count, 'commit'), project_commits_path(@project, @ref || @repository.root_ref) %p = link_to pluralize(@repository.branch_names.count, 'branch'), project_repository_path(@project) %p = link_to pluralize(@repository.tag_names.count, 'tag'), tags_project_repository_path(@project) + + - if @project.gitlab_ci? + %hr + = link_to @project.gitlab_ci_service.builds_path do + = image_tag @project.gitlab_ci_service.status_img_path, alt: "build status" + -- cgit v1.2.1 From b8c3f9a628d6830282743b4b419aaf4c37e060e9 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 9 Jul 2013 18:34:44 +0300 Subject: Extend shortcuts list modal. Mention it at help page --- app/views/help/_shortcuts.html.haml | 16 ++++++++++++++++ app/views/help/index.html.haml | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/app/views/help/_shortcuts.html.haml b/app/views/help/_shortcuts.html.haml index 793cb450c98..e979e7c0d07 100644 --- a/app/views/help/_shortcuts.html.haml +++ b/app/views/help/_shortcuts.html.haml @@ -12,3 +12,19 @@ %span.label.label-inverse ? – Show this dialog + + %h5 Project Files browsing + %p + %span.label.label-inverse + %i.icon-arrow-up + – + Move selection up + %p + %span.label.label-inverse + %i.icon-arrow-down + – + Move selection down + %p + %span.label.label-inverse Enter + – + Open selection diff --git a/app/views/help/index.html.haml b/app/views/help/index.html.haml index 80ddc05b503..6529da7ddd5 100644 --- a/app/views/help/index.html.haml +++ b/app/views/help/index.html.haml @@ -24,6 +24,9 @@ Use the = link_to "search bar", '#', onclick: "$('#search').focus();" on the top of this page + %li + Use + = link_to "shortcuts", '#', onclick: "new Shortcuts()" %li Ask in our = link_to "mailing list", "https://groups.google.com/forum/#!forum/gitlabhq" @@ -32,6 +35,7 @@ %li Browse our = link_to "issue tracker", "https://github.com/gitlabhq/gitlabhq/issues" + .span4 .ui-box .title -- cgit v1.2.1 From 03586c6c79e093046d46379885821ba9083a0d73 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 9 Jul 2013 20:51:49 +0300 Subject: Fix User#can_create_project? --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index ccb21a8b204..443ad565219 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -262,7 +262,7 @@ class User < ActiveRecord::Base end def can_create_project? - projects_limit > owned_projects.count + projects_limit_left > 0 end def can_create_group? -- cgit v1.2.1 From 3dcc441916e3d51ea29e292d7446ac9a1a4787cb Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 9 Jul 2013 20:52:06 +0300 Subject: Cleaner dashboard sidebar --- app/assets/stylesheets/common.scss | 11 ------ app/assets/stylesheets/sections/dashboard.scss | 47 +++++++++++++++++--------- app/assets/stylesheets/sections/events.scss | 8 ++--- app/views/dashboard/_groups.html.haml | 12 +++---- app/views/dashboard/_projects.html.haml | 19 ++++++----- app/views/groups/_projects.html.haml | 19 +++++------ 6 files changed, 58 insertions(+), 58 deletions(-) diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/common.scss index 1551af2d697..16d14a3c9e2 100644 --- a/app/assets/stylesheets/common.scss +++ b/app/assets/stylesheets/common.scss @@ -206,17 +206,6 @@ p.time { } } -.arrow{ - background: #E3E5EA; - padding: 5px; - margin-top: 5px; - @include border-radius(5px); - text-shadow: none; - color: #999; - line-height: 16px; - font-weight: bold; -} - .thin_area{ height: 150px; } diff --git a/app/assets/stylesheets/sections/dashboard.scss b/app/assets/stylesheets/sections/dashboard.scss index 57088e55079..cab6dd807de 100644 --- a/app/assets/stylesheets/sections/dashboard.scss +++ b/app/assets/stylesheets/sections/dashboard.scss @@ -14,22 +14,6 @@ padding: 2px 15px; } .nav-projects-tabs li { padding: 0; } - .well-list { - li { padding: 15px; } - .arrow { - float: right; - padding: 10px; - margin: 0; - } - .last_activity { - padding-top: 5px; - display: block; - span, strong { - font-size: 12px; - color: #666; - } - } - } } } } @@ -85,3 +69,34 @@ } } } + +.project-row, .group-row { + padding: 15px !important; + + .namespace-name { + color: #666; + font-weight: bold; + } + + .project-name, .group-name { + font-size: 16px; + } + + + .arrow { + float: right; + padding: 10px 5px; + margin: 0; + font-size: 20px; + color: #666; + } + + .last-activity, .owner-info { + color: #AAA; + display: block; + margin-top: 5px; + .date, .owner { + color: #777; + } + } +} diff --git a/app/assets/stylesheets/sections/events.scss b/app/assets/stylesheets/sections/events.scss index 0c75ddb8bc8..b1dc597f201 100644 --- a/app/assets/stylesheets/sections/events.scss +++ b/app/assets/stylesheets/sections/events.scss @@ -41,6 +41,8 @@ } } .event-body { + margin-left: 35px; + .commit p { color: #666; padding-top: 5px; @@ -51,7 +53,6 @@ .event-note { color: #555; margin-top: 5px; - margin-left: 35px; pre { border: none; @@ -77,10 +78,6 @@ margin-right: 5px; } } - .avatar { - position: relative; - top: -3px; - } .event_icon { position: relative; float: right; @@ -95,7 +92,6 @@ } } ul { - margin-left: 35px; margin-bottom: 5px; .avatar { width: 18px; diff --git a/app/views/dashboard/_groups.html.haml b/app/views/dashboard/_groups.html.haml index e138b42be47..a072641a074 100644 --- a/app/views/dashboard/_groups.html.haml +++ b/app/views/dashboard/_groups.html.haml @@ -8,15 +8,15 @@ New Group %ul.well-list.dash-list - groups.each do |group| - %li + %li.group-row = link_to group_path(id: group.path), class: dom_class(group) do - %strong.well-title + %span.group-name = truncate(group.name, length: 35) %span.arrow - → - %span.last_activity - %strong Owner: - %span= group.owner_name + %i.icon-angle-right + %span.owner-info + %span Owner: + %span.owner= group.owner_name - if groups.blank? %li %h3.nothing_here_message You have no groups yet. diff --git a/app/views/dashboard/_projects.html.haml b/app/views/dashboard/_projects.html.haml index ae1e2e36391..d52f10fa759 100644 --- a/app/views/dashboard/_projects.html.haml +++ b/app/views/dashboard/_projects.html.haml @@ -9,18 +9,19 @@ %ul.well-list.dash-list - projects.each do |project| - %li + %li.project-row = link_to project_path(project), class: dom_class(project) do - - if project.namespace - = project.namespace.human_name - \/ - %strong.well-title + %span.namespace-name + - if project.namespace + = project.namespace.human_name + \/ + %span.project-name = truncate(project.name, length: 25) %span.arrow - → - %span.last_activity - %strong Last activity: - %span= project_last_activity(project) + %i.icon-angle-right + %span.last-activity + %span Last activity: + %span.date= project_last_activity(project) - if projects.blank? %li %h3.nothing_here_message There are no projects here. diff --git a/app/views/groups/_projects.html.haml b/app/views/groups/_projects.html.haml index bf1a624b48f..ff6b71b9ec0 100644 --- a/app/views/groups/_projects.html.haml +++ b/app/views/groups/_projects.html.haml @@ -1,22 +1,21 @@ .ui-box %h5.title - Projects - %small - (#{projects.count}) + Projects (#{projects.count}) - if can? current_user, :manage_group, @group %span.pull-right - = link_to new_project_path(namespace_id: @group.id), class: "btn btn-tiny info" do + = link_to new_project_path(namespace_id: @group.id), class: "btn" do %i.icon-plus New Project %ul.well-list - if projects.blank? %p.nothing_here_message This groups has no projects yet - projects.each do |project| - %li + %li.project-row = link_to project_path(project), class: dom_class(project) do - %strong.well-title= truncate(project.name, length: 25) + %span.project-name + = truncate(project.name, length: 25) %span.arrow - → - %span.last_activity - %strong Last activity: - %span= project_last_activity(project) + %i.icon-angle-right + %span.last-activity + %span Last activity: + %span.date= project_last_activity(project) -- cgit v1.2.1 From 223d26405128a64f624b78e7d4b03565d1e85a69 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 10 Jul 2013 13:48:03 +0300 Subject: Sanitize user attrs on model level --- Gemfile | 3 +++ Gemfile.lock | 1 + app/controllers/profiles_controller.rb | 15 +-------------- app/models/user.rb | 10 ++++++++++ 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Gemfile b/Gemfile index 26b2b358d80..28cfc90ad73 100644 --- a/Gemfile +++ b/Gemfile @@ -118,6 +118,9 @@ gem "d3_rails", "~> 3.1.4" # underscore-rails gem "underscore-rails", "~> 1.4.4" +# Sanitize user input +gem "sanitize" + group :assets do gem "sass-rails" gem "coffee-rails" diff --git a/Gemfile.lock b/Gemfile.lock index 4866f9585d1..5d13837b61f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -610,6 +610,7 @@ DEPENDENCIES redcarpet (~> 2.2.2) redis-rails rspec-rails + sanitize sass-rails sdoc seed-fu diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb index 686edd8af80..6fa635d0e36 100644 --- a/app/controllers/profiles_controller.rb +++ b/app/controllers/profiles_controller.rb @@ -17,7 +17,7 @@ class ProfilesController < ApplicationController end def update - if @user.update_attributes(user_attributes) + if @user.update_attributes(params[:user]) flash[:notice] = "Profile was successfully updated" else flash[:alert] = "Failed to update profile" @@ -69,19 +69,6 @@ class ProfilesController < ApplicationController @user = current_user end - def user_attributes - user_attributes = params[:user] - - # Sanitize user input because we dont have strict - # validation for this fields - %w(name skype linkedin twitter bio).each do |attr| - value = user_attributes[attr] - user_attributes[attr] = sanitize(strip_tags(value)) if value.present? - end - - user_attributes - end - def authorize_change_password! return render_404 if @user.ldap_user? end diff --git a/app/models/user.rb b/app/models/user.rb index 443ad565219..193349c95fc 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -114,7 +114,10 @@ class User < ActiveRecord::Base validate :namespace_uniq, if: ->(user) { user.username_changed? } before_validation :generate_password, on: :create + before_validation :sanitize_attrs + before_save :ensure_authentication_token + alias_attribute :private_token, :authentication_token delegate :path, to: :namespace, allow_nil: true, prefix: true @@ -356,4 +359,11 @@ class User < ActiveRecord::Base def created_by User.find_by_id(created_by_id) if created_by_id end + + def sanitize_attrs + %w(name username skype linkedin twitter bio).each do |attr| + value = self.send(attr) + self.send("#{attr}=", Sanitize.clean(value)) if value.present? + end + end end -- cgit v1.2.1 From 7ab2130cabe0ba4a1190324b79cb18f87669ff08 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 10 Jul 2013 19:09:48 +0300 Subject: Remove randomly failing test --- spec/features/notes_on_merge_requests_spec.rb | 6 ------ 1 file changed, 6 deletions(-) diff --git a/spec/features/notes_on_merge_requests_spec.rb b/spec/features/notes_on_merge_requests_spec.rb index d7bc66dd9c8..4aa8937926c 100644 --- a/spec/features/notes_on_merge_requests_spec.rb +++ b/spec/features/notes_on_merge_requests_spec.rb @@ -66,12 +66,6 @@ describe "On a merge request", js: true do within(".js-main-target-form") { should have_css(".js-note-preview", visible: false) } within(".js-main-target-form") { should have_css(".js-note-text", visible: true) } end - - it "should be removable" do - find('.note').hover - find(".js-note-delete").click - should_not have_css(".note") - end end describe "when editing a note", js: true do -- cgit v1.2.1 From 4da48868e57fdf5bfd41b680f5452450807c23f5 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 10 Jul 2013 19:29:54 +0300 Subject: Fix multiple trigger on button attachment --- app/assets/javascripts/notes.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/assets/javascripts/notes.js b/app/assets/javascripts/notes.js index 85d86f3f0bd..6dfe722a5e8 100644 --- a/app/assets/javascripts/notes.js +++ b/app/assets/javascripts/notes.js @@ -23,6 +23,12 @@ var NoteList = { $(document).off("click", ".js-note-attachment-input"); $(document).off("click", ".js-close-discussion-note-form"); $(document).off("click", ".js-note-delete"); + $(document).off("click", ".js-note-edit"); + $(document).off("click", ".js-note-edit-cancel"); + $(document).off("click", ".js-note-attachment-delete"); + $(document).off("click", ".js-choose-note-attachment-button"); + $(document).off("click", ".js-show-outdated-discussion"); + $(document).off("ajax:complete", ".js-main-target-form"); -- cgit v1.2.1 From e49ec46461ef033fb54c717378628a31bd33248b Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 11 Jul 2013 09:19:19 +0300 Subject: Open note image attachment in new tab --- app/views/events/event/_note.html.haml | 7 ++++--- app/views/projects/notes/_note.html.haml | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/views/events/event/_note.html.haml b/app/views/events/event/_note.html.haml index 9dd0767e896..8384bbecd06 100644 --- a/app/views/events/event/_note.html.haml +++ b/app/views/events/event/_note.html.haml @@ -13,9 +13,10 @@ = sanitize(markdown(truncate(event.target.note, length: 150)), tags: %w(a img b pre p)) - note = event.target - if note.attachment.url - = link_to note.attachment.secure_url, target: "_blank", class: 'note-file-attach' do - - if note.attachment.image? + - if note.attachment.image? + = link_to note.attachment.url, target: '_blank' do = image_tag note.attachment.url, class: 'note-image-attach' - - else + - else + = link_to note.attachment.secure_url, target: "_blank", class: 'note-file-attach' do %i.icon-paper-clip = note.attachment_identifier diff --git a/app/views/projects/notes/_note.html.haml b/app/views/projects/notes/_note.html.haml index 6fa7a1c3c78..1389d899310 100644 --- a/app/views/projects/notes/_note.html.haml +++ b/app/views/projects/notes/_note.html.haml @@ -51,7 +51,8 @@ - if note.attachment.url .note-attachment - if note.attachment.image? - = image_tag note.attachment.url, class: 'note-image-attach' + = link_to note.attachment.url, target: '_blank' do + = image_tag note.attachment.url, class: 'note-image-attach' .attachment.pull-right = link_to note.attachment.secure_url, target: "_blank" do %i.icon-paper-clip -- cgit v1.2.1