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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
a3eb39a1
Commit
a3eb39a1
authored
Sep 16, 2016
by
Alfredo Sumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace textarea with Ace editor
parent
26f658de
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
8 deletions
+30
-8
app/assets/javascripts/merge_conflicts/components/diff_file_editor.js.es6
...cripts/merge_conflicts/components/diff_file_editor.js.es6
+20
-7
app/assets/stylesheets/pages/merge_conflicts.scss
app/assets/stylesheets/pages/merge_conflicts.scss
+7
-0
app/views/projects/merge_requests/conflicts.html.haml
app/views/projects/merge_requests/conflicts.html.haml
+2
-0
app/views/projects/merge_requests/conflicts/components/_diff_file_editor.html.haml
...requests/conflicts/components/_diff_file_editor.html.haml
+1
-1
No files found.
app/assets/javascripts/merge_conflicts/components/diff_file_editor.js.es6
View file @
a3eb39a1
...
...
@@ -4,7 +4,7 @@
template: '#diff-file-editor',
data() {
return {
original
State
: '',
original
Content
: '',
saved: false,
loading: false,
fileLoaded: false
...
...
@@ -23,6 +23,8 @@
loadFile(val) {
const self = this;
this.resetEditorContent();
if (!val || this.fileLoaded || this.loading) {
return
}
...
...
@@ -31,10 +33,19 @@
$.get(this.file.content_path)
.done((file) => {
$(self.$el).find('textarea').val(file.content);
self.originalState = file.content;
let content = self.$el.querySelector('pre');
let fileContent = document.createTextNode(file.content);
content.textContent = fileContent.textContent;
self.originalContent = file.content;
self.fileLoaded = true;
self.editor = ace.edit(content);
self.editor.$blockScrolling = Infinity; // Turn off annoying warning
self.editor.on('change', () => {
self.saveDiffResolution();
});
self.saveDiffResolution();
})
.fail(() => {
...
...
@@ -50,12 +61,14 @@
this.saved = true;
// This probably be better placed in the data provider
this.file.content = this.
$el.querySelector('textarea').value
;
this.file.resolveEditChanged = this.file.content !== this.original
State
;
this.file.content = this.
editor.getValue()
;
this.file.resolveEditChanged = this.file.content !== this.original
Content
;
this.file.promptDiscardConfirmation = false;
},
onInput() {
this.saveDiffResolution();
resetEditorContent() {
if (this.fileLoaded) {
this.editor.setValue(this.originalContent, -1);
}
}
}
});
...
...
app/assets/stylesheets/pages/merge_conflicts.scss
View file @
a3eb39a1
...
...
@@ -255,6 +255,13 @@ $colors: (
.editor
{
border-top
:
solid
1px
yellow
;
pre
{
height
:
350px
;
border
:
none
;
border-radius
:
0
;
margin-bottom
:
0
;
}
}
.loading-text
{
...
...
app/views/projects/merge_requests/conflicts.html.haml
View file @
a3eb39a1
...
...
@@ -6,6 +6,8 @@
'unselected': line.isUnselected }"
-
page_title
"Merge Conflicts"
,
"
#{
@merge_request
.
title
}
(
#{
@merge_request
.
to_reference
}
"
,
"Merge Requests"
-
content_for
:page_specific_javascripts
do
=
page_specific_javascript_tag
(
'lib/ace.js'
)
=
render
"projects/merge_requests/show/mr_title"
.merge-request-details.issuable-details
...
...
app/views/projects/merge_requests/conflicts/components/_diff_file_editor.html.haml
View file @
a3eb39a1
...
...
@@ -3,4 +3,4 @@
.editor-wrap
{
":class"
=>
"classObject"
}
%p
.loading-text
Loading...
.editor
%
textarea
{
"@input"
=>
"onInput"
,
cols:
'80'
,
rows:
'20'
}
%
pre
{
"style"
=>
"height: 350px"
}
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