diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-26 18:08:56 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-26 18:08:56 +0300 |
commit | 17ab40ca089e1aef61a83f77ab6df62a72f6ce06 (patch) | |
tree | 8eb149293eee90ec2750b6ac5e46a111a806424e /app/controllers/projects/performance_monitoring | |
parent | 66d4203791a01fdedf668a78818a229ea2c07aad (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/controllers/projects/performance_monitoring')
-rw-r--r-- | app/controllers/projects/performance_monitoring/dashboards_controller.rb | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/app/controllers/projects/performance_monitoring/dashboards_controller.rb b/app/controllers/projects/performance_monitoring/dashboards_controller.rb index 2d872b78096..ec5a33f5dd6 100644 --- a/app/controllers/projects/performance_monitoring/dashboards_controller.rb +++ b/app/controllers/projects/performance_monitoring/dashboards_controller.rb @@ -22,6 +22,16 @@ module Projects end end + def update + result = ::Metrics::Dashboard::UpdateDashboardService.new(project, current_user, dashboard_params.merge(file_content_params)).execute + + if result[:status] == :success + respond_update_success(result) + else + respond_error(result) + end + end + private def respond_success(result) @@ -43,6 +53,19 @@ module Projects flash[:notice] = message.html_safe end + def respond_update_success(result) + set_web_ide_link_update_notice(result.dig(:dashboard, :path)) + respond_to do |format| + format.json { render status: result.delete(:http_status), json: result } + end + end + + def set_web_ide_link_update_notice(new_dashboard_path) + web_ide_link_start = "<a href=\"#{ide_edit_path(project, redirect_safe_branch_name, new_dashboard_path)}\">" + message = _("Your dashboard has been updated. You can %{web_ide_link_start}edit it here%{web_ide_link_end}.") % { web_ide_link_start: web_ide_link_start, web_ide_link_end: "</a>" } + flash[:notice] = message.html_safe + end + def validate_required_params! params.require(%i(branch file_name dashboard commit_message)) end @@ -54,6 +77,31 @@ module Projects def dashboard_params params.permit(%i(branch file_name dashboard commit_message)).to_h end + + def file_content_params + params.permit( + file_content: [ + :dashboard, + panel_groups: [ + :group, + :priority, + panels: [ + :type, + :title, + :y_label, + :weight, + metrics: [ + :id, + :unit, + :label, + :query, + :query_range + ] + ] + ] + ] + ) + end end end end |