summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/assets/stylesheets/framework/common.scss2
-rw-r--r--app/controllers/autocomplete_controller.rb49
-rw-r--r--app/models/project_services/drone_ci_service.rb2
3 files changed, 25 insertions, 28 deletions
diff --git a/app/assets/stylesheets/framework/common.scss b/app/assets/stylesheets/framework/common.scss
index 40f4beb1968..61689aff57e 100644
--- a/app/assets/stylesheets/framework/common.scss
+++ b/app/assets/stylesheets/framework/common.scss
@@ -64,7 +64,7 @@ pre {
.dropdown-menu > li > a:hover,
.dropdown-menu > li > a:focus {
background: $gl-primary;
- color: #FFF
+ color: #FFF;
}
.str-truncated {
diff --git a/app/controllers/autocomplete_controller.rb b/app/controllers/autocomplete_controller.rb
index 202e9da9eee..aa0268b8d62 100644
--- a/app/controllers/autocomplete_controller.rb
+++ b/app/controllers/autocomplete_controller.rb
@@ -1,34 +1,8 @@
class AutocompleteController < ApplicationController
skip_before_action :authenticate_user!, only: [:users]
+ before_action :find_users, only: [:users]
def users
- begin
- @users =
- if params[:project_id].present?
- project = Project.find(params[:project_id])
-
- if can?(current_user, :read_project, project)
- project.team.users
- end
- elsif params[:group_id]
- group = Group.find(params[:group_id])
-
- if can?(current_user, :read_group, group)
- group.users
- end
- elsif current_user
- User.all
- end
- rescue ActiveRecord::RecordNotFound
- if current_user
- return render json: {}, status: 404
- end
- end
-
- if @users.nil? && current_user.nil?
- authenticate_user!
- end
-
@users ||= User.none
@users = @users.search(params[:search]) if params[:search].present?
@users = @users.active
@@ -49,4 +23,25 @@ class AutocompleteController < ApplicationController
@user = User.find(params[:id])
render json: @user, only: [:name, :username, :id], methods: [:avatar_url]
end
+
+ private
+
+ def find_users
+ @users =
+ if params[:project_id].present?
+ project = Project.find(params[:project_id])
+ return render_404 unless can?(current_user, :read_project, project)
+
+ project.team.users
+ elsif params[:group_id].present?
+ group = Group.find(params[:group_id])
+ return render_404 unless can?(current_user, :read_group, group)
+
+ group.users
+ elsif current_user
+ User.all
+ else
+ User.none
+ end
+ end
end
diff --git a/app/models/project_services/drone_ci_service.rb b/app/models/project_services/drone_ci_service.rb
index c240213200d..127684bd274 100644
--- a/app/models/project_services/drone_ci_service.rb
+++ b/app/models/project_services/drone_ci_service.rb
@@ -32,6 +32,8 @@ class DroneCiService < CiService
def compose_service_hook
hook = service_hook || build_service_hook
+ # If using a service template, project may not be available
+ hook.url = [drone_url, "/api/hook", "?owner=#{project.namespace.path}", "&name=#{project.path}", "&access_token=#{token}"].join if project
hook.enable_ssl_verification = enable_ssl_verification
hook.save
end