Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-10-24 21:11:45 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-10-24 21:11:45 +0300
commit4bb797f25563205cf495f4dd5366e037e88831ab (patch)
treea345ddbd0e2464067323d3c6fd34960607ef4f44 /app/controllers
parent40a4f37126bb1a1dd6b6f4b3c0ebb414a3e3908a (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/projects/group_links_controller.rb51
1 files changed, 34 insertions, 17 deletions
diff --git a/app/controllers/projects/group_links_controller.rb b/app/controllers/projects/group_links_controller.rb
index 60300f78bbb..5f8bf423219 100644
--- a/app/controllers/projects/group_links_controller.rb
+++ b/app/controllers/projects/group_links_controller.rb
@@ -9,30 +9,47 @@ class Projects::GroupLinksController < Projects::ApplicationController
feature_category :groups_and_projects
def update
- Projects::GroupLinks::UpdateService.new(group_link, current_user).execute(group_link_params)
+ result = Projects::GroupLinks::UpdateService.new(group_link, current_user).execute(group_link_params)
- if group_link.expires?
- render json: {
- expires_in: helpers.time_ago_with_tooltip(group_link.expires_at),
- expires_soon: group_link.expires_soon?
- }
- else
- render json: {}
+ if result.success?
+ if group_link.expires?
+ render json: {
+ expires_in: helpers.time_ago_with_tooltip(group_link.expires_at),
+ expires_soon: group_link.expires_soon?
+ }
+ else
+ render json: {}
+ end
+ elsif result.reason == :not_found
+ render json: { message: result.message }, status: :not_found
end
end
def destroy
- ::Projects::GroupLinks::DestroyService.new(project, current_user).execute(group_link)
-
- respond_to do |format|
- format.html do
- if can?(current_user, :admin_group, group_link.group)
- redirect_to group_path(group_link.group), status: :found
- elsif can?(current_user, :admin_project, group_link.project)
- redirect_to project_project_members_path(project), status: :found
+ result = ::Projects::GroupLinks::DestroyService.new(project, current_user).execute(group_link)
+
+ if result.success?
+ respond_to do |format|
+ format.html do
+ if can?(current_user, :admin_group, group_link.group)
+ redirect_to group_path(group_link.group), status: :found
+ elsif can?(current_user, :admin_project, group_link.project)
+ redirect_to project_project_members_path(project), status: :found
+ end
+ end
+ format.js { head :ok }
+ end
+ else
+ respond_to do |format|
+ format.html do
+ redirect_to project_project_members_path(project, tab: :groups), status: :found,
+ alert: _('The project-group link could not be removed.')
+ end
+
+ format.js do
+ render json: { message: result.message }, status: :not_found if result.reason == :not_found
end
end
- format.js { head :ok }
end
end