Commit c8f53f0e authored by Alfredo Sumaran's avatar Alfredo Sumaran

Merge branch 'didemacet-ci-lint-page' into 'master'

Change CI template linter textarea with Ace Editor

Closes #24179 and #19701

See merge request !8452
parents 1792528a 8032df64
(() => {
window.gl = window.gl || {};
class CILintEditor {
constructor() {
this.editor = window.ace.edit('ci-editor');
this.textarea = document.querySelector('#content');
this.editor.getSession().setMode('ace/mode/yaml');
this.editor.on('input', () => {
const content = this.editor.getSession().getValue();
this.textarea.value = content;
});
}
}
gl.CILintEditor = CILintEditor;
})();
......@@ -273,6 +273,10 @@
case 'projects:variables:index':
new gl.ProjectVariables();
break;
case 'ci:lints:create':
case 'ci:lints:show':
new gl.CILintEditor();
break;
}
switch (path.first()) {
case 'admin':
......
......@@ -9,3 +9,13 @@
color: $lint-correct-color;
}
}
.ci-linter {
.ci-editor {
height: 400px;
}
.ci-template pre {
white-space: pre-wrap;
}
}
- page_title "CI Lint"
- page_description "Validate your GitLab CI configuration file"
- content_for :page_specific_javascripts do
= page_specific_javascript_tag('lib/ace.js')
%h2 Check your .gitlab-ci.yml
%hr
.row
= form_tag ci_lint_path, method: :post do
.form-group
= label_tag(:content, 'Content of .gitlab-ci.yml', class: 'control-label text-nowrap')
.ci-linter
.row
= form_tag ci_lint_path, method: :post do
.form-group
.col-sm-12
.file-holder
.file-title.clearfix
Content of .gitlab-ci.yml
#ci-editor.ci-editor #{@content}
= text_area_tag(:content, @content, class: 'hidden form-control span1', rows: 7, require: true)
.col-sm-12
= text_area_tag(:content, @content, class: 'form-control span1', rows: 7, require: true)
.col-sm-12
.pull-left.prepend-top-10
= submit_tag('Validate', class: 'btn btn-success submit-yml')
.pull-left.prepend-top-10
= submit_tag('Validate', class: 'btn btn-success submit-yml')
.row.prepend-top-20
.col-sm-12
.results
= render partial: 'create' if defined?(@status)
.row.prepend-top-20
.col-sm-12
.results.ci-template
= render partial: 'create' if defined?(@status)
---
title: Change CI template linter textarea with Ace Editor
merge_request: 8452
author: Didem Acet
require 'spec_helper'
describe 'CI Lint' do
describe 'CI Lint', js: true do
before do
login_as :user
end
......@@ -8,7 +8,10 @@ describe 'CI Lint' do
describe 'YAML parsing' do
before do
visit ci_lint_path
fill_in 'content', with: yaml_content
# Ace editor updates a hidden textarea and it happens asynchronously
# `sleep 0.1` is actually needed here because of this
execute_script("ace.edit('ci-editor').setValue(" + yaml_content.to_json + ");")
sleep 0.1
click_on 'Validate'
end
......@@ -40,7 +43,7 @@ describe 'CI Lint' do
let(:yaml_content) { 'my yaml content' }
it 'loads previous YAML content after validation' do
expect(page).to have_field('content', with: 'my yaml content', type: 'textarea')
expect(page).to have_field('content', with: 'my yaml content', visible: false, type: 'textarea')
end
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