diff options
author | Linus G Thiel <linus@yesbabyyes.se> | 2016-10-05 22:58:34 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2016-10-24 13:14:00 +0300 |
commit | 036fac06d18e82f0d0696bd1b350548bb47125e8 (patch) | |
tree | 039a3699aaa03d00f68795586e4fece71bb937fe /app/controllers/projects/project_members_controller.rb | |
parent | 9dbd5b3cfad10b214ae5ef27c39246bbb74a5077 (diff) |
Gracefully handle adding of no users to projects and groups
- Disable {project, group} members submit button if no users
If no users are selected, the submit button should be disabled.
- Alert user when no users were added to {project, group}.
When no users were selected for adding, an alert message is
flashed that no users were added.
- Also, this commit adds a feedback when users were actually added to a
project, in symmetry with how group members are handled.
Closes #22967, #23270.
Diffstat (limited to 'app/controllers/projects/project_members_controller.rb')
-rw-r--r-- | app/controllers/projects/project_members_controller.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/app/controllers/projects/project_members_controller.rb b/app/controllers/projects/project_members_controller.rb index 2a07d154853..2bac48c5490 100644 --- a/app/controllers/projects/project_members_controller.rb +++ b/app/controllers/projects/project_members_controller.rb @@ -25,6 +25,10 @@ class Projects::ProjectMembersController < Projects::ApplicationController end def create + if params[:user_ids].empty? + return redirect_to namespace_project_project_members_path(@project.namespace, @project), alert: 'No users specified.' + end + @project.team.add_users( params[:user_ids].split(','), params[:access_level], @@ -32,7 +36,7 @@ class Projects::ProjectMembersController < Projects::ApplicationController current_user: current_user ) - redirect_to namespace_project_project_members_path(@project.namespace, @project) + redirect_to namespace_project_project_members_path(@project.namespace, @project), notice: 'Users were successfully added.' end def update |