diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-07 15:09:34 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-07 15:09:34 +0300 |
commit | 903ccf7c93eb9490c76857bffe744249cc07de09 (patch) | |
tree | 603a3162e91999160e4efc74f351f9405f422d61 /app/controllers/projects | |
parent | 41cb558299b483b44b45351730ee4c0e9fe4ca2c (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/controllers/projects')
3 files changed, 98 insertions, 2 deletions
diff --git a/app/controllers/projects/import/jira_controller.rb b/app/controllers/projects/import/jira_controller.rb index 6af630a9528..c8f53cef5b2 100644 --- a/app/controllers/projects/import/jira_controller.rb +++ b/app/controllers/projects/import/jira_controller.rb @@ -7,6 +7,8 @@ module Projects before_action :jira_integration_configured? def show + return if Feature.enabled?(:jira_issue_import_vue, @project) + unless @project.import_state&.in_progress? jira_client = @project.jira_service.client jira_projects = jira_client.Project.all diff --git a/app/controllers/projects/prometheus/metrics_controller.rb b/app/controllers/projects/prometheus/metrics_controller.rb index c9c7ba1253f..0340cb5beb0 100644 --- a/app/controllers/projects/prometheus/metrics_controller.rb +++ b/app/controllers/projects/prometheus/metrics_controller.rb @@ -20,6 +20,85 @@ module Projects end end + def validate_query + respond_to do |format| + format.json do + result = prometheus_adapter.query(:validate, params[:query]) + + if result + render json: result + else + head :accepted + end + end + end + end + + def new + @metric = project.prometheus_metrics.new + end + + def index + respond_to do |format| + format.json do + metrics = ::PrometheusMetricsFinder.new( + project: project, + ordered: true + ).execute.to_a + + response = {} + if metrics.any? + response[:metrics] = ::PrometheusMetricSerializer + .new(project: project) + .represent(metrics) + end + + render json: response + end + end + end + + def create + @metric = project.prometheus_metrics.create( + metrics_params.to_h.symbolize_keys + ) + + if @metric.persisted? + redirect_to edit_project_service_path(project, ::PrometheusService), + notice: _('Metric was successfully added.') + else + render 'new' + end + end + + def update + @metric = update_metrics_service(prometheus_metric).execute + + if @metric.persisted? + redirect_to edit_project_service_path(project, ::PrometheusService), + notice: _('Metric was successfully updated.') + else + render 'edit' + end + end + + def edit + @metric = prometheus_metric + end + + def destroy + destroy_metrics_service(prometheus_metric).execute + + respond_to do |format| + format.html do + redirect_to edit_project_service_path(project, ::PrometheusService), status: :see_other + end + format.json do + head :ok + end + end + end + private def prometheus_adapter @@ -29,8 +108,22 @@ module Projects def require_prometheus_metrics! render_404 unless prometheus_adapter&.can_query? end + + def prometheus_metric + @prometheus_metric ||= ::PrometheusMetricsFinder.new(id: params[:id]).execute.first + end + + def update_metrics_service(metric) + ::Projects::Prometheus::Metrics::UpdateService.new(metric, metrics_params) + end + + def destroy_metrics_service(metric) + ::Projects::Prometheus::Metrics::DestroyService.new(metric) + end + + def metrics_params + params.require(:prometheus_metric).permit(:title, :query, :y_label, :unit, :legend, :group) + end end end end - -Projects::Prometheus::MetricsController.prepend_if_ee('EE::Projects::Prometheus::MetricsController') diff --git a/app/controllers/projects/registry/repositories_controller.rb b/app/controllers/projects/registry/repositories_controller.rb index 8852ae04d5e..2418ea97409 100644 --- a/app/controllers/projects/registry/repositories_controller.rb +++ b/app/controllers/projects/registry/repositories_controller.rb @@ -28,6 +28,7 @@ module Projects end def destroy + image.delete_scheduled! DeleteContainerRepositoryWorker.perform_async(current_user.id, image.id) # rubocop:disable CodeReuse/Worker track_event(:delete_repository) |