diff options
author | Nick Thomas <nick@gitlab.com> | 2017-06-23 13:00:46 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2017-06-23 13:00:46 +0300 |
commit | 30672c53028dc79fb7a048c85fa51ce7e7dbf6d9 (patch) | |
tree | ac1187ab1939f054554c7b142a5508e66e0b7ee3 /app/controllers | |
parent | 378a040bcb70f6ad38f2c817d68eb7df6d2f0c5f (diff) | |
parent | 801cf92310e9f6950dddba848ef1e6a3d1e48ef0 (diff) |
Merge remote-tracking branch 'ce/master' into ce-to-ee-2017-06-23
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/application_controller.rb | 4 | ||||
-rw-r--r-- | app/controllers/projects/application_controller.rb | 8 | ||||
-rw-r--r-- | app/controllers/projects/deploy_keys_controller.rb | 4 | ||||
-rw-r--r-- | app/controllers/projects/deployments_controller.rb | 16 | ||||
-rw-r--r-- | app/controllers/projects/discussions_controller.rb | 6 | ||||
-rw-r--r-- | app/controllers/projects/environments_controller.rb | 12 | ||||
-rw-r--r-- | app/controllers/projects/issues_controller.rb | 7 | ||||
-rw-r--r-- | app/controllers/projects/labels_controller.rb | 8 | ||||
-rw-r--r-- | app/controllers/projects/merge_requests_controller.rb | 20 | ||||
-rw-r--r-- | app/controllers/projects/milestones_controller.rb | 8 | ||||
-rw-r--r-- | app/controllers/projects/prometheus_controller.rb | 24 | ||||
-rw-r--r-- | app/controllers/projects/snippets_controller.rb | 6 |
12 files changed, 88 insertions, 35 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index a7faec22946..0e79c796f16 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -40,6 +40,10 @@ class ApplicationController < ActionController::Base render_404 end + rescue_from(ActionController::UnknownFormat) do + render_404 + end + rescue_from Gitlab::Access::AccessDeniedError do |exception| render_403 end diff --git a/app/controllers/projects/application_controller.rb b/app/controllers/projects/application_controller.rb index dff48dda351..df963aacfec 100644 --- a/app/controllers/projects/application_controller.rb +++ b/app/controllers/projects/application_controller.rb @@ -57,6 +57,14 @@ class Projects::ApplicationController < ApplicationController render_404 unless project.feature_available?(feature, current_user) end +<<<<<<< HEAD +======= + def check_issuables_available! + render_404 unless project.feature_available?(:issues, current_user) || + project.feature_available?(:merge_requests, current_user) + end + +>>>>>>> ce/master def method_missing(method_sym, *arguments, &block) case method_sym.to_s when /\Aauthorize_(.*)!\z/ diff --git a/app/controllers/projects/deploy_keys_controller.rb b/app/controllers/projects/deploy_keys_controller.rb index 8e64332f9d9..3e1f1e710e1 100644 --- a/app/controllers/projects/deploy_keys_controller.rb +++ b/app/controllers/projects/deploy_keys_controller.rb @@ -6,7 +6,7 @@ class Projects::DeployKeysController < Projects::ApplicationController before_action :authorize_admin_project! before_action :authorize_update_deploy_key!, only: [:edit, :update] - layout "project_settings" + layout 'project_settings' def index respond_to do |format| @@ -73,7 +73,7 @@ class Projects::DeployKeysController < Projects::ApplicationController protected def deploy_key - @deploy_key ||= @project.deploy_keys.find(params[:id]) + @deploy_key ||= DeployKey.find(params[:id]) end def create_params diff --git a/app/controllers/projects/deployments_controller.rb b/app/controllers/projects/deployments_controller.rb index 6644deb49c9..47c312ffddf 100644 --- a/app/controllers/projects/deployments_controller.rb +++ b/app/controllers/projects/deployments_controller.rb @@ -22,6 +22,22 @@ class Projects::DeploymentsController < Projects::ApplicationController render_404 end + def additional_metrics + return render_404 unless deployment.has_additional_metrics? + + respond_to do |format| + format.json do + metrics = deployment.additional_metrics + + if metrics.any? + render json: metrics + else + head :no_content + end + end + end + end + private def deployment diff --git a/app/controllers/projects/discussions_controller.rb b/app/controllers/projects/discussions_controller.rb index f4a18a5e8f7..2e6ab7903b8 100644 --- a/app/controllers/projects/discussions_controller.rb +++ b/app/controllers/projects/discussions_controller.rb @@ -1,5 +1,5 @@ class Projects::DiscussionsController < Projects::ApplicationController - before_action :module_enabled + before_action :check_merge_requests_available! before_action :merge_request before_action :discussion before_action :authorize_resolve_discussion! @@ -34,8 +34,4 @@ class Projects::DiscussionsController < Projects::ApplicationController def authorize_resolve_discussion! access_denied! unless discussion.can_resolve?(current_user) end - - def module_enabled - render_404 unless @project.feature_available?(:merge_requests, current_user) - end end diff --git a/app/controllers/projects/environments_controller.rb b/app/controllers/projects/environments_controller.rb index 8bd221d4698..0bfd3abaec3 100644 --- a/app/controllers/projects/environments_controller.rb +++ b/app/controllers/projects/environments_controller.rb @@ -16,8 +16,6 @@ class Projects::EnvironmentsController < Projects::ApplicationController respond_to do |format| format.html format.json do - Gitlab::PollingInterval.set_header(response, interval: 3_000) - render json: { environments: EnvironmentSerializer .new(project: @project, current_user: @current_user) @@ -132,6 +130,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController end end +<<<<<<< HEAD # The rollout status of an enviroment def status unless @environment.deployment_service_ready? @@ -148,6 +147,15 @@ class Projects::EnvironmentsController < Projects::ApplicationController else serializer = RolloutStatusSerializer.new(project: @project, current_user: @current_user) render json: serializer.represent(rollout_status) +======= + def additional_metrics + respond_to do |format| + format.json do + additional_metrics = environment.additional_metrics || {} + + render json: additional_metrics, status: additional_metrics.any? ? :ok : :no_content + end +>>>>>>> ce/master end end diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb index 81f131a792c..1463855a90a 100644 --- a/app/controllers/projects/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -11,8 +11,13 @@ class Projects::IssuesController < Projects::ApplicationController prepend_before_action :authenticate_user!, only: [:new, :export_csv] before_action :redirect_to_external_issue_tracker, only: [:index, :new] +<<<<<<< HEAD before_action :module_enabled before_action :issue, except: [:index, :new, :create, :bulk_update, :export_csv] +======= + before_action :check_issues_available! + before_action :issue, except: [:index, :new, :create, :bulk_update] +>>>>>>> ce/master # Allow write(create) issue before_action :authorize_create_issue!, only: [:new, :create] @@ -253,7 +258,7 @@ class Projects::IssuesController < Projects::ApplicationController return render_404 unless can?(current_user, :push_code, @project) && @issue.can_be_worked_on?(current_user) end - def module_enabled + def check_issues_available! return render_404 unless @project.feature_available?(:issues, current_user) && @project.default_issues_tracker? end diff --git a/app/controllers/projects/labels_controller.rb b/app/controllers/projects/labels_controller.rb index 1beac202efe..daa973c9281 100644 --- a/app/controllers/projects/labels_controller.rb +++ b/app/controllers/projects/labels_controller.rb @@ -1,7 +1,7 @@ class Projects::LabelsController < Projects::ApplicationController include ToggleSubscriptionAction - before_action :module_enabled + before_action :check_issuables_available! before_action :label, only: [:edit, :update, :destroy, :promote] before_action :find_labels, only: [:index, :set_priorities, :remove_priority, :toggle_subscription] before_action :authorize_read_label! @@ -135,12 +135,6 @@ class Projects::LabelsController < Projects::ApplicationController protected - def module_enabled - unless @project.feature_available?(:issues, current_user) || @project.feature_available?(:merge_requests, current_user) - return render_404 - end - end - def label_params params.require(:label).permit(:title, :description, :color) end diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index 229be2ac8f6..96594bfd3c2 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -7,7 +7,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController include ToggleAwardEmoji include IssuableCollections - before_action :module_enabled + before_action :check_merge_requests_available! before_action :merge_request, only: [ :edit, :update, :show, :diffs, :commits, :conflicts, :conflict_for_path, :pipelines, :merge, :pipeline_status, :ci_environments_status, :toggle_subscription, :cancel_merge_when_pipeline_succeeds, @@ -520,10 +520,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController return render_404 unless @conflicts_list.can_be_resolved_by?(current_user) end - def module_enabled - return render_404 unless @project.feature_available?(:merge_requests, current_user) - end - def validates_merge_request # Show git not found page # if there is no saved commits between source & target branch @@ -647,10 +643,14 @@ class Projects::MergeRequestsController < Projects::ApplicationController def merge_request_params params.require(:merge_request) +<<<<<<< HEAD .permit(merge_request_params_ce << merge_request_params_ee) +======= + .permit(merge_request_params_attributes) +>>>>>>> ce/master end - def merge_request_params_ce + def merge_request_params_attributes [ :assignee_id, :description, @@ -695,7 +695,15 @@ class Projects::MergeRequestsController < Projects::ApplicationController end def merge_params +<<<<<<< HEAD params.permit(:should_remove_source_branch, :commit_message, :squash) +======= + params.permit(merge_params_attributes) + end + + def merge_params_attributes + [:should_remove_source_branch, :commit_message] +>>>>>>> ce/master end # Make sure merge requests created before 8.0 diff --git a/app/controllers/projects/milestones_controller.rb b/app/controllers/projects/milestones_controller.rb index 1da92748ba3..094ca277551 100644 --- a/app/controllers/projects/milestones_controller.rb +++ b/app/controllers/projects/milestones_controller.rb @@ -1,7 +1,7 @@ class Projects::MilestonesController < Projects::ApplicationController include MilestoneActions - before_action :module_enabled + before_action :check_issuables_available! before_action :milestone, only: [:edit, :update, :destroy, :show, :merge_requests, :participants, :labels] # Allow read any milestone @@ -96,12 +96,6 @@ class Projects::MilestonesController < Projects::ApplicationController return render_404 unless can?(current_user, :admin_milestone, @project) end - def module_enabled - unless @project.feature_available?(:issues, current_user) || @project.feature_available?(:merge_requests, current_user) - return render_404 - end - end - def milestone_params params.require(:milestone).permit(:title, :description, :start_date, :due_date, :state_event) end diff --git a/app/controllers/projects/prometheus_controller.rb b/app/controllers/projects/prometheus_controller.rb new file mode 100644 index 00000000000..507468d7102 --- /dev/null +++ b/app/controllers/projects/prometheus_controller.rb @@ -0,0 +1,24 @@ +class Projects::PrometheusController < Projects::ApplicationController + before_action :authorize_read_project! + before_action :require_prometheus_metrics! + + def active_metrics + respond_to do |format| + format.json do + matched_metrics = project.prometheus_service.matched_metrics || {} + + if matched_metrics.any? + render json: matched_metrics + else + head :no_content + end + end + end + end + + private + + def require_prometheus_metrics! + render_404 unless project.prometheus_service.present? + end +end diff --git a/app/controllers/projects/snippets_controller.rb b/app/controllers/projects/snippets_controller.rb index 8a8f8d6a27d..98dd307bd9d 100644 --- a/app/controllers/projects/snippets_controller.rb +++ b/app/controllers/projects/snippets_controller.rb @@ -5,7 +5,7 @@ class Projects::SnippetsController < Projects::ApplicationController include SnippetsActions include RendersBlob - before_action :module_enabled + before_action :check_snippets_available! before_action :snippet, only: [:show, :edit, :destroy, :update, :raw, :toggle_award_emoji, :mark_as_spam] # Allow read any snippet @@ -102,10 +102,6 @@ class Projects::SnippetsController < Projects::ApplicationController return render_404 unless can?(current_user, :admin_project_snippet, @snippet) end - def module_enabled - return render_404 unless @project.feature_available?(:snippets, current_user) - end - def snippet_params params.require(:project_snippet).permit(:title, :content, :file_name, :private, :visibility_level, :description) end |