Commit 31fc73f0 authored by Douwe Maan's avatar Douwe Maan
Browse files

Use `project_member` instead of `team_member`.

parent 22012f06b739
......@@ -127,7 +127,7 @@ class Dispatcher
new DropzoneInput($('.wiki-form'))
when 'snippets', 'labels', 'graphs'
shortcut_handler = new ShortcutsNavigation()
when 'team_members', 'deploy_keys', 'hooks', 'services', 'protected_branches'
when 'project_members', 'deploy_keys', 'hooks', 'services', 'protected_branches'
shortcut_handler = new ShortcutsNavigation()
new UsersSelect()
......
......@@ -167,7 +167,7 @@ li.note {
background-color: inherit;
}
.team_member_show {
.project_member_show {
td:first-child {
color: #aaa;
}
......
......@@ -156,7 +156,7 @@ ul.nav.nav-projects-tabs {
}
}
.team_member_row form {
.project_member_row form {
margin: 0px;
}
......
class Admin::GroupsController < Admin::ApplicationController
before_filter :group, only: [:edit, :show, :update, :destroy, :project_update, :project_teams_update]
before_filter :group, only: [:edit, :show, :update, :destroy, :project_update, :members_update]
def index
@groups = Group.all
......@@ -40,7 +40,7 @@ def update
end
end
def project_teams_update
def members_update
@group.add_users(params[:user_ids].split(','), params[:access_level])
redirect_to [:admin, @group], notice: 'Users were successfully added.'
......
class Projects::TeamMembersController < Projects::ApplicationController
class Projects::ProjectMembersController < Projects::ApplicationController
# Authorize
before_filter :authorize_admin_project!, except: :leave
layout "project_settings"
def index
@project_members = @project.project_members
if params[:search].present?
users = @project.users.search(params[:search]).to_a
@project_members = @project_members.where(user_id: users)
end
@project_members = @project_members.order('access_level DESC')
@group = @project.group
@project_members = @project.project_members.order('access_level DESC')
if @group
@group_members = @group.group_members
if params[:search].present?
users = @group.users.search(params[:search]).to_a
@group_members = @group_members.where(user_id: users)
end
@group_members = @group_members.order('access_level DESC').limit(20)
end
@project_member = @project.project_members.new
end
def new
@user_project_relation = @project.project_members.new
@project_member = @project.project_members.new
end
def create
users = User.where(id: params[:user_ids].split(','))
@project.team << [users, params[:access_level]]
redirect_to namespace_project_team_index_path(@project.namespace, @project)
redirect_to namespace_project_project_members_path(@project.namespace, @project)
end
def update
@user_project_relation = @project.project_members.find_by(user_id: member)
@user_project_relation.update_attributes(member_params)
unless @user_project_relation.valid?
flash[:alert] = "User should have at least one role"
end
redirect_to namespace_project_team_index_path(@project.namespace, @project)
@project_member = @project.project_members.find_by(user_id: member)
@project_member.update_attributes(member_params)
end
def destroy
@user_project_relation = @project.project_members.find_by(user_id: member)
@user_project_relation.destroy
@project_member = @project.project_members.find_by(user_id: member)
@project_member.destroy
respond_to do |format|
format.html do
redirect_to namespace_project_team_index_path(@project.namespace,
redirect_to namespace_project_project_members_path(@project.namespace,
@project)
end
format.js { render nothing: true }
......@@ -57,7 +72,7 @@ def apply_import
status = @project.team.import(giver)
notice = status ? "Successfully imported" : "Import failed"
redirect_to(namespace_project_team_index_path(project.namespace, project),
redirect_to(namespace_project_project_members_path(project.namespace, project),
notice: notice)
end
......
......@@ -60,7 +60,7 @@ def project_autocomplete
{ label: "#{prefix} - Merge Requests", url: namespace_project_merge_requests_path(@project.namespace, @project) },
{ label: "#{prefix} - Milestones", url: namespace_project_milestones_path(@project.namespace, @project) },
{ label: "#{prefix} - Snippets", url: namespace_project_snippets_path(@project.namespace, @project) },
{ label: "#{prefix} - Team", url: namespace_project_team_index_path(@project.namespace, @project) },
{ label: "#{prefix} - Members", url: namespace_project_project_members_path(@project.namespace, @project) },
{ label: "#{prefix} - Wiki", url: namespace_project_wikis_path(@project.namespace, @project) },
]
else
......
......@@ -89,7 +89,7 @@ def current_path?(path)
def project_tab_class
return "active" if current_page?(controller: "/projects", action: :edit, id: @project)
if ['services', 'hooks', 'deploy_keys', 'team_members', 'protected_branches'].include? controller.controller_name
if ['services', 'hooks', 'deploy_keys', 'project_members', 'protected_branches'].include? controller.controller_name
"active"
end
end
......
......@@ -37,7 +37,7 @@ def not_auth_abilities(user, subject)
:read_issue,
:read_milestone,
:read_project_snippet,
:read_team_member,
:read_project_member,
:read_merge_request,
:read_note,
:download_code
......@@ -119,7 +119,7 @@ def project_guest_rules
:read_issue,
:read_milestone,
:read_project_snippet,
:read_team_member,
:read_project_member,
:read_merge_request,
:read_note,
:write_project,
......@@ -166,7 +166,7 @@ def project_master_rules
:admin_issue,
:admin_milestone,
:admin_project_snippet,
:admin_team_member,
:admin_project_member,
:admin_merge_request,
:admin_note,
:admin_wiki,
......
......@@ -116,14 +116,14 @@ def owner?
def post_create_hook
unless owner?
event_service.join_project(self.project, self.user)
notification_service.new_team_member(self)
notification_service.new_project_member(self)
end
system_hook_service.execute_hooks_for(self, :create)
end
def post_update_hook
notification_service.update_team_member(self) if self.access_level_changed?
notification_service.update_project_member(self) if self.access_level_changed?
end
def post_destroy_hook
......
......@@ -445,13 +445,13 @@ def owner
end
end
def team_member_by_name_or_email(name = nil, email = nil)
def project_member_by_name_or_email(name = nil, email = nil)
user = users.where('name like ? or email like ?', name, email).first
project_members.where(user: user) if user
end
# Get Team Member record by user id
def team_member_by_id(user_id)
def project_member_by_id(user_id)
project_members.find_by(user_id: user_id)
end
......
......@@ -169,11 +169,8 @@ class User < ActiveRecord::Base
scope :admins, -> { where(admin: true) }
scope :blocked, -> { with_state(:blocked) }
scope :active, -> { with_state(:active) }
scope :in_team, ->(team){ where(id: team.member_ids) }
scope :not_in_team, ->(team){ where('users.id NOT IN (:ids)', ids: team.member_ids) }
scope :not_in_project, ->(project) { project.users.present? ? where("id not in (:ids)", ids: project.users.map(&:id) ) : all }
scope :without_projects, -> { where('id NOT IN (SELECT DISTINCT(user_id) FROM members)') }
scope :potential_team_members, ->(team) { team.members.any? ? active.not_in_team(team) : active }
#
# Class methods
......@@ -407,7 +404,7 @@ def name_with_username
end
def tm_of(project)
project.team_member_by_id(self.id)
project.project_member_by_id(self.id)
end
def already_forked?(project)
......
......@@ -162,20 +162,20 @@ def new_note(note)
end
end
def new_team_member(project_member)
def new_project_member(project_member)
mailer.project_access_granted_email(project_member.id)
end
def update_team_member(project_member)
def update_project_member(project_member)
mailer.project_access_granted_email(project_member.id)
end
def new_group_member(users_group)
mailer.group_access_granted_email(users_group.id)
def new_group_member(group_member)
mailer.group_access_granted_email(group_member.id)
end
def update_group_member(users_group)
mailer.group_access_granted_email(users_group.id)
def update_group_member(group_member)
mailer.group_access_granted_email(group_member.id)
end
def project_was_moved(project)
......
......@@ -12,8 +12,8 @@ def execute(note_type, note_id)
else
[]
end
team_members = sorted(@project.team.members)
participants = all_members + groups + team_members + participating
project_members = sorted(@project.team.members)
participants = all_members + groups + project_members + participating
participants.uniq
end
......
......@@ -58,7 +58,7 @@
Read more about project permissions
%strong= link_to "here", help_page_path("permissions", "permissions"), class: "vlink"
= form_tag project_teams_update_admin_group_path(@group), id: "new_team_member", class: "bulk_import", method: :put do
= form_tag members_update_admin_group_path(@group), id: "new_project_member", class: "bulk_import", method: :put do
%div
= users_select_tag(:user_ids, multiple: true)
%div.prepend-top-10
......
......@@ -114,7 +114,7 @@
= link_to namespace_project_team_index_path(@project.namespace, @project), class: "btn btn-xs" do
%i.fa.fa-pencil-square-o
Manage Access
%ul.well-list.team_members
%ul.well-list.project_members
- @project_members.each do |project_member|
- user = project_member.user
%li.project_member
......@@ -126,7 +126,7 @@
%span.light Owner
- else
%span.light= project_member.human_access
= link_to namespace_project_team_member_path(@project.namespace, @project, user), data: { confirm: remove_from_project_team_message(@project, user)}, method: :delete, remote: true, class: "btn btn-sm btn-remove" do
= link_to namespace_project_project_member_path(@project.namespace, @project, user), data: { confirm: remove_from_project_team_message(@project, user)}, method: :delete, remote: true, class: "btn btn-sm btn-remove" do
%i.fa.fa-times
.panel-footer
= paginate @project_members, param_name: 'project_members_page', theme: 'gitlab'
......@@ -16,7 +16,7 @@
%span.label.label-gray
= repository_size(project)
.pull-right
= link_to 'Members', namespace_project_team_index_path(project.namespace, project), id: "edit_#{dom_id(project)}", class: "btn btn-sm"
= link_to 'Members', namespace_project_project_members_path(project.namespace, project), id: "edit_#{dom_id(project)}", class: "btn btn-sm"
= link_to 'Edit', edit_namespace_project_path(project.namespace, project), id: "edit_#{dom_id(project)}", class: "btn btn-sm"
= link_to 'Remove', project, data: { confirm: remove_project_message(project)}, method: :delete, class: "btn btn-sm btn-remove"
- if @projects.blank?
......
......@@ -15,7 +15,7 @@
%li
= link_to new_namespace_project_snippet_path(@project.namespace, @project), title: "New Snippet" do
New snippet
- if can?(current_user, :admin_team_member, @project)
- if can?(current_user, :admin_project_member, @project)
%li
= link_to new_namespace_project_team_member_path(@project.namespace, @project), title: "New project member" do
New project member
......
......@@ -4,8 +4,8 @@
%i.fa.fa-pencil-square-o
%span
Project
= nav_link(controller: [:team_members, :teams]) do
= link_to namespace_project_team_index_path(@project.namespace, @project), title: 'Members', class: "team-tab tab" do
= nav_link(controller: [:project_members, :teams]) do
%i.fa.fa-users
%span
Members
......
......@@ -136,7 +136,7 @@
resources :groups, constraints: { id: /[^\/]+/ } do
member do
put :project_teams_update
put :members_update
end
end
......@@ -445,7 +445,7 @@
end
end
resources :team_members, except: [:index, :edit], constraints: { id: /[a-zA-Z.\/0-9_\-#%+]+/ } do
resources :project_members, except: [:new, :edit], constraints: { id: /[a-zA-Z.\/0-9_\-#%+]+/ } do
collection do
delete :leave
......
......@@ -38,7 +38,7 @@ class Spinach::Features::AdminGroups < Spinach::FeatureSteps
When 'I select user "John Doe" from user list as "Reporter"' do
select2(user_john.id, from: "#user_ids", multiple: true)
within "#new_team_member" do
within "#new_project_member" do
select "Reporter", from: "access_level"
end
click_button "Add users to group"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment