Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
d4e232ae
Commit
d4e232ae
authored
Feb 08, 2018
by
Lin Jen-Shin
Committed by
Clement Ho
Feb 08, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added 'clear' button to ci lint editor
parent
d16802ff
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
8 deletions
+39
-8
app/assets/javascripts/pages/ci/lints/ci_lint_editor.js
app/assets/javascripts/pages/ci/lints/ci_lint_editor.js
+7
-0
app/views/ci/lints/show.html.haml
app/views/ci/lints/show.html.haml
+2
-0
changelogs/unreleased/feature-26598-clear-button-ci-lint.yml
changelogs/unreleased/feature-26598-clear-button-ci-lint.yml
+4
-0
spec/features/ci_lint_spec.rb
spec/features/ci_lint_spec.rb
+26
-8
No files found.
app/assets/javascripts/pages/ci/lints/ci_lint_editor.js
View file @
d4e232ae
...
@@ -2,11 +2,18 @@ export default class CILintEditor {
...
@@ -2,11 +2,18 @@ export default class CILintEditor {
constructor
()
{
constructor
()
{
this
.
editor
=
window
.
ace
.
edit
(
'
ci-editor
'
);
this
.
editor
=
window
.
ace
.
edit
(
'
ci-editor
'
);
this
.
textarea
=
document
.
querySelector
(
'
#content
'
);
this
.
textarea
=
document
.
querySelector
(
'
#content
'
);
this
.
clearYml
=
document
.
querySelector
(
'
.clear-yml
'
);
this
.
editor
.
getSession
().
setMode
(
'
ace/mode/yaml
'
);
this
.
editor
.
getSession
().
setMode
(
'
ace/mode/yaml
'
);
this
.
editor
.
on
(
'
input
'
,
()
=>
{
this
.
editor
.
on
(
'
input
'
,
()
=>
{
const
content
=
this
.
editor
.
getSession
().
getValue
();
const
content
=
this
.
editor
.
getSession
().
getValue
();
this
.
textarea
.
value
=
content
;
this
.
textarea
.
value
=
content
;
});
});
this
.
clearYml
.
addEventListener
(
'
click
'
,
this
.
clear
.
bind
(
this
));
}
clear
()
{
this
.
editor
.
setValue
(
''
);
}
}
}
}
app/views/ci/lints/show.html.haml
View file @
d4e232ae
...
@@ -18,6 +18,8 @@
...
@@ -18,6 +18,8 @@
.col-sm-12
.col-sm-12
.pull-left.prepend-top-10
.pull-left.prepend-top-10
=
submit_tag
(
'Validate'
,
class:
'btn btn-success submit-yml'
)
=
submit_tag
(
'Validate'
,
class:
'btn btn-success submit-yml'
)
.pull-right.prepend-top-10
=
button_tag
(
'Clear'
,
type:
'button'
,
class:
'btn btn-default clear-yml'
)
.row.prepend-top-20
.row.prepend-top-20
.col-sm-12
.col-sm-12
...
...
changelogs/unreleased/feature-26598-clear-button-ci-lint.yml
0 → 100644
View file @
d4e232ae
---
title
:
Added clear button to ci lint editor
merge_request
:
author
:
Michael Robinson
spec/features/ci_lint_spec.rb
View file @
d4e232ae
...
@@ -3,16 +3,19 @@ require 'spec_helper'
...
@@ -3,16 +3,19 @@ require 'spec_helper'
describe
'CI Lint'
,
:js
do
describe
'CI Lint'
,
:js
do
before
do
before
do
sign_in
(
create
(
:user
))
sign_in
(
create
(
:user
))
visit
ci_lint_path
find
(
'#ci-editor'
)
execute_script
(
"ace.edit('ci-editor').setValue(
#{
yaml_content
.
to_json
}
);"
)
# Ace editor updates a hidden textarea and it happens asynchronously
wait_for
(
'YAML content'
)
do
find
(
'.ace_content'
).
text
.
present?
end
end
end
describe
'YAML parsing'
do
describe
'YAML parsing'
do
before
do
before
do
visit
ci_lint_path
# Ace editor updates a hidden textarea and it happens asynchronously
# `sleep 0.1` is actually needed here because of this
find
(
'#ci-editor'
)
execute_script
(
"ace.edit('ci-editor').setValue("
+
yaml_content
.
to_json
+
");"
)
sleep
0.1
click_on
'Validate'
click_on
'Validate'
end
end
...
@@ -32,11 +35,10 @@ describe 'CI Lint', :js do
...
@@ -32,11 +35,10 @@ describe 'CI Lint', :js do
end
end
context
'YAML is incorrect'
do
context
'YAML is incorrect'
do
let
(
:yaml_content
)
{
''
}
let
(
:yaml_content
)
{
'
value: cannot have :
'
}
it
'displays information about an error'
do
it
'displays information about an error'
do
expect
(
page
).
to
have_content
(
'Status: syntax is incorrect'
)
expect
(
page
).
to
have_content
(
'Status: syntax is incorrect'
)
expect
(
page
).
to
have_content
(
'Error: Please provide content of .gitlab-ci.yml'
)
end
end
end
end
...
@@ -48,4 +50,20 @@ describe 'CI Lint', :js do
...
@@ -48,4 +50,20 @@ describe 'CI Lint', :js do
end
end
end
end
end
end
describe
'YAML clearing'
do
before
do
click_on
'Clear'
end
context
'YAML is present'
do
let
(
:yaml_content
)
do
File
.
read
(
Rails
.
root
.
join
(
'spec/support/gitlab_stubs/gitlab_ci.yml'
))
end
it
'YAML content is cleared'
do
expect
(
page
).
to
have_field
(
'content'
,
with:
''
,
visible:
false
,
type:
'textarea'
)
end
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment