diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2019-01-07 22:30:09 +0300 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2019-01-07 22:30:09 +0300 |
commit | 329725c2bd2fe024239707878c2d936f07fca05c (patch) | |
tree | d3f21efa3ded17780f93275f4c282f359c413454 /app | |
parent | 97b365058272ceea69d4cfc6eeb7d4f6bd945b3c (diff) | |
parent | 6710c87434e6d2508dc6b2553594258e77d23723 (diff) |
Merge branch '55177-sentry-configuration' into 'master'
Resolve "Sentry Configuration"
See merge request gitlab-org/gitlab-ce!23724
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/projects/settings/operations_controller.rb | 9 | ||||
-rw-r--r-- | app/helpers/projects_helper.rb | 3 | ||||
-rw-r--r-- | app/models/project.rb | 2 | ||||
-rw-r--r-- | app/services/projects/operations/update_service.rb | 2 | ||||
-rw-r--r-- | app/views/projects/settings/operations/_error_tracking.html.haml | 30 | ||||
-rw-r--r-- | app/views/projects/settings/operations/show.html.haml | 1 |
6 files changed, 44 insertions, 3 deletions
diff --git a/app/controllers/projects/settings/operations_controller.rb b/app/controllers/projects/settings/operations_controller.rb index ae8ac61ad46..521ec2acebb 100644 --- a/app/controllers/projects/settings/operations_controller.rb +++ b/app/controllers/projects/settings/operations_controller.rb @@ -6,6 +6,8 @@ module Projects before_action :check_license before_action :authorize_update_environment! + helper_method :error_tracking_setting + def show end @@ -22,13 +24,18 @@ module Projects private + def error_tracking_setting + @error_tracking_setting ||= project.error_tracking_setting || + project.build_error_tracking_setting + end + def update_params params.require(:project).permit(permitted_project_params) end # overridden in EE def permitted_project_params - {} + { error_tracking_setting_attributes: [:enabled, :api_url, :token] } end def check_license diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index af7a262e32c..e67c327f7f8 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -285,7 +285,7 @@ module ProjectsHelper # overridden in EE def settings_operations_available? - false + Feature.enabled?(:error_tracking, @project) && can?(current_user, :read_environment, @project) end private @@ -549,6 +549,7 @@ module ProjectsHelper services#edit repository#show ci_cd#show + operations#show badges#index pages#show ] diff --git a/app/models/project.rb b/app/models/project.rb index 9d0348d848a..d57098407d0 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -296,6 +296,8 @@ class Project < ActiveRecord::Base allow_destroy: true, reject_if: ->(attrs) { attrs[:id].blank? && attrs[:url].blank? } + accepts_nested_attributes_for :error_tracking_setting, update_only: true + delegate :name, to: :owner, allow_nil: true, prefix: true delegate :members, to: :team, prefix: true delegate :add_user, :add_users, to: :team diff --git a/app/services/projects/operations/update_service.rb b/app/services/projects/operations/update_service.rb index 7ff0599ee95..abd6d8de750 100644 --- a/app/services/projects/operations/update_service.rb +++ b/app/services/projects/operations/update_service.rb @@ -12,7 +12,7 @@ module Projects private def project_update_params - {} + params.slice(:error_tracking_setting_attributes) end end end diff --git a/app/views/projects/settings/operations/_error_tracking.html.haml b/app/views/projects/settings/operations/_error_tracking.html.haml new file mode 100644 index 00000000000..71335e4dfd0 --- /dev/null +++ b/app/views/projects/settings/operations/_error_tracking.html.haml @@ -0,0 +1,30 @@ +- return unless Feature.enabled?(:error_tracking, @project) && can?(current_user, :read_environment, @project) + +- setting = error_tracking_setting + +%section.settings.expanded.border-0.no-animate + .settings-header + %h4 + = _('Error Tracking') + %p + = _('To link Sentry to GitLab, enter your Sentry URL and Auth Token.') + .settings-content + = form_for @project, url: project_settings_operations_path(@project), method: :patch do |f| + = form_errors(@project) + .form-group + = f.fields_for :error_tracking_setting_attributes, setting do |form| + .form-check.form-group + = form.check_box :enabled, class: 'form-check-input' + = form.label :enabled, _('Active'), class: 'form-check-label' + .form-group + = form.label :api_url, _('Sentry API URL'), class: 'label-bold' + = form.url_field :api_url, class: 'form-control', placeholder: _('http://<sentry-host>/api/0/projects/{organization_slug}/{project_slug}/issues/') + %p.form-text.text-muted + = _('Enter your Sentry API URL') + .form-group + = form.label :token, _('Auth Token'), class: 'label-bold' + = form.text_field :token, class: 'form-control' + %p.form-text.text-muted + = _('Find and manage Auth Tokens in your Sentry account settings page.') + + = f.submit _('Save changes'), class: 'btn btn-success' diff --git a/app/views/projects/settings/operations/show.html.haml b/app/views/projects/settings/operations/show.html.haml index 0782029dbcd..b36fa9a5f51 100644 --- a/app/views/projects/settings/operations/show.html.haml +++ b/app/views/projects/settings/operations/show.html.haml @@ -1,4 +1,5 @@ - @content_class = 'limit-container-width' unless fluid_layout - page_title _('Operations') += render 'projects/settings/operations/error_tracking', expanded: true = render_if_exists 'projects/settings/operations/tracing' |