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
Léo-Paul Géneau
gitlab-ce
Commits
4e734a90
Commit
4e734a90
authored
Jun 22, 2018
by
Fatih Acet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement MR diff notes autosave feature.
parent
c1fa6f7c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
2 deletions
+41
-2
app/assets/javascripts/diffs/components/diff_line_note_form.vue
...sets/javascripts/diffs/components/diff_line_note_form.vue
+22
-1
app/assets/javascripts/diffs/constants.js
app/assets/javascripts/diffs/constants.js
+1
-0
spec/javascripts/diffs/components/diff_line_note_form_spec.js
.../javascripts/diffs/components/diff_line_note_form_spec.js
+18
-1
No files found.
app/assets/javascripts/diffs/components/diff_line_note_form.vue
View file @
4e734a90
<
script
>
import
$
from
'
jquery
'
;
import
{
mapState
,
mapGetters
,
mapActions
}
from
'
vuex
'
;
import
createFlash
from
'
~/flash
'
;
import
{
s__
}
from
'
~/locale
'
;
import
noteForm
from
'
../../notes/components/note_form.vue
'
;
import
{
getNoteFormData
}
from
'
../store/utils
'
;
import
Autosave
from
'
../../autosave
'
;
import
{
DIFF_NOTE_TYPE
,
NOTE_TYPE
}
from
'
../constants
'
;
export
default
{
components
:
{
...
...
@@ -37,11 +40,29 @@ export default {
noteableData
:
state
=>
state
.
notes
.
noteableData
,
diffViewType
:
state
=>
state
.
diffs
.
diffViewType
,
}),
...
mapGetters
([
'
noteableType
'
,
'
getNotesDataByProp
'
]),
...
mapGetters
([
'
isLoggedIn
'
,
'
noteableType
'
,
'
getNoteableData
'
,
'
getNotesDataByProp
'
]),
},
mounted
()
{
if
(
this
.
isLoggedIn
)
{
const
textarea
=
this
.
$el
.
querySelector
(
'
.js-note-text
'
);
const
noteableData
=
this
.
getNoteableData
;
const
keys
=
[
NOTE_TYPE
,
this
.
noteableType
,
noteableData
.
id
,
noteableData
.
diff_head_sha
,
DIFF_NOTE_TYPE
,
noteableData
.
source_project_id
,
this
.
line
.
lineCode
,
];
this
.
autosave
=
new
Autosave
(
$
(
textarea
),
keys
);
}
},
methods
:
{
...
mapActions
([
'
cancelCommentForm
'
,
'
saveNote
'
,
'
fetchDiscussions
'
]),
handleCancelCommentForm
()
{
this
.
autosave
.
reset
();
this
.
cancelCommentForm
({
lineCode
:
this
.
line
.
lineCode
,
});
...
...
app/assets/javascripts/diffs/constants.js
View file @
4e734a90
...
...
@@ -7,6 +7,7 @@ export const CONTEXT_LINE_TYPE = 'context';
export
const
EMPTY_CELL_TYPE
=
'
empty-cell
'
;
export
const
COMMENT_FORM_TYPE
=
'
commentForm
'
;
export
const
DIFF_NOTE_TYPE
=
'
DiffNote
'
;
export
const
NOTE_TYPE
=
'
Note
'
;
export
const
NEW_LINE_TYPE
=
'
new
'
;
export
const
OLD_LINE_TYPE
=
'
old
'
;
export
const
TEXT_DIFF_POSITION_TYPE
=
'
text
'
;
...
...
spec/javascripts/diffs/components/diff_line_note_form_spec.js
View file @
4e734a90
...
...
@@ -19,7 +19,15 @@ describe('DiffLineNoteForm', () => {
diffLines
,
line
:
diffLines
[
0
],
noteTargetLine
:
diffLines
[
0
],
}).
$mount
();
});
Object
.
defineProperty
(
component
,
'
isLoggedIn
'
,
{
get
()
{
return
true
;
},
});
component
.
$mount
();
});
describe
(
'
methods
'
,
()
=>
{
...
...
@@ -56,6 +64,15 @@ describe('DiffLineNoteForm', () => {
});
});
describe
(
'
mounted
'
,
()
=>
{
it
(
'
should init autosave
'
,
()
=>
{
const
key
=
'
autosave/Note/issue///DiffNote//1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_1_1
'
;
expect
(
component
.
autosave
).
toBeDefined
();
expect
(
component
.
autosave
.
key
).
toEqual
(
key
);
});
});
describe
(
'
template
'
,
()
=>
{
it
(
'
should have note form
'
,
()
=>
{
const
{
$el
}
=
component
;
...
...
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