Commit 34431d8e authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'move-ci-settings' into 'master'

Move CI project settings page to CE project settings area
Signed-off-by: Dmitriy Zaporozhets's avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>

Part of #2594 

See merge request !1465
parents 2e8a3e39 87240e98
......@@ -16,6 +16,7 @@ v 8.1.0 (unreleased)
- Move CI runners page to project settings area
- Move CI variables page to project settings area
- Move CI triggers page to project settings area
- Move CI project settings page to CE project settings area
v 8.0.3
- Fix URL shown in Slack notifications
......
......@@ -2,9 +2,9 @@ module Ci
class ProjectsController < Ci::ApplicationController
before_action :authenticate_user!, except: [:build, :badge, :show]
before_action :authenticate_public_page!, only: :show
before_action :project, only: [:build, :show, :badge, :edit, :update, :destroy, :toggle_shared_runners, :dumped_yaml]
before_action :project, only: [:build, :show, :badge, :toggle_shared_runners, :dumped_yaml]
before_action :authorize_access_project!, except: [:build, :badge, :show, :new, :disabled]
before_action :authorize_manage_project!, only: [:edit, :update, :destroy, :toggle_shared_runners, :dumped_yaml]
before_action :authorize_manage_project!, only: [:toggle_shared_runners, :dumped_yaml]
before_action :authenticate_token!, only: [:build]
before_action :no_cache, only: [:badge]
skip_before_action :check_enable_flag!, only: [:disabled]
......@@ -23,28 +23,6 @@ module Ci
@commits = @commits.page(params[:page]).per(20)
end
def edit
end
def update
if project.update_attributes(project_params)
Ci::EventService.new.change_project_settings(current_user, project)
redirect_to :back, notice: 'Project was successfully updated.'
else
render action: "edit"
end
end
def destroy
project.gl_project.gitlab_ci_service.update_attributes(active: false)
project.destroy
Ci::EventService.new.remove_project(current_user, project)
redirect_to ci_projects_url
end
# Project status badge
# Image with build status for sha or ref
def badge
......@@ -74,12 +52,5 @@ module Ci
response.headers["Pragma"] = "no-cache"
response.headers["Expires"] = "Fri, 01 Jan 1990 00:00:00 GMT"
end
def project_params
params.require(:project).permit(:path, :timeout, :timeout_in_minutes, :default_ref, :always_build,
:polling_interval, :public, :ssh_url_to_repo, :allow_git_fetch, :email_recipients,
:email_add_pusher, :email_only_broken_builds, :coverage_regex, :shared_runners_enabled, :token,
{ variables_attributes: [:id, :key, :value, :_destroy] })
end
end
end
......@@ -33,6 +33,6 @@ class Projects::ApplicationController < ApplicationController
end
def ci_project
@ci_project ||= @project.gitlab_ci_project
@ci_project ||= @project.ensure_gitlab_ci_project
end
end
class Projects::CiSettingsController < Projects::ApplicationController
before_action :ci_project
before_action :authorize_admin_project!
layout "project_settings"
def edit
end
def update
if ci_project.update_attributes(project_params)
Ci::EventService.new.change_project_settings(current_user, ci_project)
redirect_to edit_namespace_project_ci_settings_path(project.namespace, project), notice: 'Project was successfully updated.'
else
render action: "edit"
end
end
def destroy
ci_project.destroy
Ci::EventService.new.remove_project(current_user, ci_project)
project.gitlab_ci_service.update_attributes(active: false)
redirect_to project_path(project), notice: "CI was disabled for this project"
end
protected
def project_params
params.require(:project).permit(:path, :timeout, :timeout_in_minutes, :default_ref, :always_build,
:polling_interval, :public, :ssh_url_to_repo, :allow_git_fetch, :email_recipients,
:email_add_pusher, :email_only_broken_builds, :coverage_regex, :shared_runners_enabled, :token,
{ variables_attributes: [:id, :key, :value, :_destroy] })
end
end
......@@ -27,9 +27,9 @@ module Ci
commits = project.commits
if commits.any? && commits.last.push_data[:ci_yaml_file]
"#{@project.gitlab_url}/edit/master/.gitlab-ci.yml"
"#{project.gitlab_url}/edit/master/.gitlab-ci.yml"
else
"#{@project.gitlab_url}/new/master"
"#{project.gitlab_url}/new/master"
end
end
end
......
......@@ -26,9 +26,3 @@
= icon('book fw')
%span
Events
%li.separate-item
= nav_link path: 'projects#edit' do
= link_to edit_ci_project_path(@project) do
= icon('cogs fw')
%span
Settings
......@@ -50,3 +50,8 @@
= icon('retweet fw')
%span
Triggers
= nav_link path: 'ci_settings#edit' do
= link_to edit_namespace_project_ci_settings_path(@project.namespace, @project) do
= icon('building fw')
%span
CI Settings
%h3.page-title
CI settings
%hr
.bs-callout.help-callout
%p
If you want to test your .gitlab-ci.yml, you can use special tool - #{link_to "Lint", ci_lint_path}
%p
Edit your
#{link_to ".gitlab-ci.yml using web-editor", yaml_web_editor_link(@project)}
Edit your
#{link_to ".gitlab-ci.yml using web-editor", yaml_web_editor_link(@ci_project)}
= nested_form_for [:ci, @project], html: { class: 'form-horizontal' } do |f|
- if @project.errors.any?
= nested_form_for @ci_project, url: namespace_project_ci_settings_path(@project.namespace, @project), html: { class: 'form-horizontal' } do |f|
- if @ci_project.errors.any?
#error_explanation
%p.lead= "#{pluralize(@project.errors.count, "error")} prohibited this project from being saved:"
%p.lead= "#{pluralize(@ci_project.errors.count, "error")} prohibited this project from being saved:"
.alert.alert-error
%ul
- @project.errors.full_messages.each do |msg|
- @ci_project.errors.full_messages.each do |msg|
%li= msg
%fieldset
......@@ -93,8 +96,8 @@
= f.label :token, "CI token", class: 'control-label'
.col-sm-10
= f.text_field :token, class: 'form-control', placeholder: 'xEeFCaDAB89'
.form-actions
= f.submit 'Save changes', class: 'btn btn-save'
- unless @project.new_record?
= link_to 'Remove Project', ci_project_path(@project), method: :delete, data: { confirm: 'Project will be removed. Are you sure?' }, class: 'btn btn-danger pull-right'
- unless @ci_project.new_record?
= link_to 'Remove Project', ci_project_path(@ci_project), method: :delete, data: { confirm: 'Project will be removed. Are you sure?' }, class: 'btn btn-danger pull-right'
- if @project.generated_yaml_config
- if @ci_project.generated_yaml_config
%p.alert.alert-danger
CI Jobs are deprecated now, you can #{link_to "download", dumped_yaml_ci_project_path(@project)}
CI Jobs are deprecated now, you can #{link_to "download", dumped_yaml_ci_project_path(@ci_project)}
or
%a.preview-yml{:href => "#yaml-content", "data-toggle" => "modal"} preview
yaml file which is based on your old jobs.
......@@ -8,7 +8,7 @@
= render 'form'
- if @project.generated_yaml_config
- if @ci_project.generated_yaml_config
#yaml-content.modal.fade{"aria-hidden" => "true", "aria-labelledby" => ".gitlab-ci.yml", :role => "dialog", :tabindex => "-1"}
.modal-dialog
.modal-content
......@@ -16,6 +16,6 @@
%button.close{"aria-hidden" => "true", "data-dismiss" => "modal", :type => "button"} ×
%h4.modal-title Content of .gitlab-ci.yml
.modal-body
= text_area_tag :yaml, @project.generated_yaml_config, size: "70x25", class: "form-control"
= text_area_tag :yaml, @ci_project.generated_yaml_config, size: "70x25", class: "form-control"
.modal-footer
%button.btn.btn-default{"data-dismiss" => "modal", :type => "button"} Close
......@@ -590,6 +590,7 @@ Gitlab::Application.routes.draw do
resources :protected_branches, only: [:index, :create, :update, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex }
resource :variables, only: [:show, :update]
resources :triggers, only: [:index, :create, :destroy]
resource :ci_settings, only: [:edit, :update, :destroy]
resources :hooks, only: [:index, :create, :destroy], constraints: { id: /\d+/ } do
member do
......
......@@ -17,22 +17,4 @@ describe "Projects" do
it { expect(page).to have_content @project.name }
it { expect(page).to have_content 'All commits' }
end
describe "GET /ci/projects/:id/edit" do
before do
visit edit_ci_project_path(@project)
end
it { expect(page).to have_content @project.name }
it { expect(page).to have_content 'Build Schedule' }
it "updates configuration" do
fill_in 'Timeout', with: '70'
click_button 'Save changes'
expect(page).to have_content 'was successfully updated'
expect(find_field('Timeout').value).to eq '70'
end
end
end
require 'spec_helper'
describe "CI settings" do
let(:user) { create(:user) }
before { login_as(user) }
before do
@project = FactoryGirl.create :ci_project
@gl_project = @project.gl_project
@gl_project.team << [user, :master]
visit edit_namespace_project_ci_settings_path(@gl_project.namespace, @gl_project)
end
it { expect(page).to have_content 'Build Schedule' }
it "updates configuration" do
fill_in 'Timeout', with: '70'
click_button 'Save changes'
expect(page).to have_content 'was successfully updated'
expect(find_field('Timeout').value).to eq '70'
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment