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
Jérome Perrin
gitlab-ce
Commits
f22f75b7
Commit
f22f75b7
authored
Sep 22, 2017
by
Fatih Acet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix rendering double note issue.
parent
92173ac5
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
19 deletions
+47
-19
app/assets/javascripts/notes/components/issue_comment_form.vue
...ssets/javascripts/notes/components/issue_comment_form.vue
+5
-0
app/assets/javascripts/notes/stores/actions.js
app/assets/javascripts/notes/stores/actions.js
+8
-0
app/assets/javascripts/notes/stores/mutations.js
app/assets/javascripts/notes/stores/mutations.js
+13
-9
spec/javascripts/notes/stores/actions_spec.js
spec/javascripts/notes/stores/actions_spec.js
+0
-1
spec/javascripts/notes/stores/mutation_spec.js
spec/javascripts/notes/stores/mutation_spec.js
+21
-9
No files found.
app/assets/javascripts/notes/components/issue_comment_form.vue
View file @
f22f75b7
...
@@ -97,6 +97,8 @@
...
@@ -97,6 +97,8 @@
methods
:
{
methods
:
{
...
mapActions
([
...
mapActions
([
'
saveNote
'
,
'
saveNote
'
,
'
stopPolling
'
,
'
restartPolling
'
,
'
removePlaceholderNotes
'
,
'
removePlaceholderNotes
'
,
]),
]),
setIsSubmitButtonDisabled
(
note
,
isSubmitting
)
{
setIsSubmitButtonDisabled
(
note
,
isSubmitting
)
{
...
@@ -126,10 +128,13 @@
...
@@ -126,10 +128,13 @@
this
.
isSubmitting
=
true
;
this
.
isSubmitting
=
true
;
this
.
note
=
''
;
// Empty textarea while being requested. Repopulate in catch
this
.
note
=
''
;
// Empty textarea while being requested. Repopulate in catch
this
.
resizeTextarea
();
this
.
resizeTextarea
();
this
.
stopPolling
();
this
.
saveNote
(
noteData
)
this
.
saveNote
(
noteData
)
.
then
((
res
)
=>
{
.
then
((
res
)
=>
{
this
.
isSubmitting
=
false
;
this
.
isSubmitting
=
false
;
this
.
restartPolling
();
if
(
res
.
errors
)
{
if
(
res
.
errors
)
{
if
(
res
.
errors
.
commands_only
)
{
if
(
res
.
errors
.
commands_only
)
{
this
.
discard
();
this
.
discard
();
...
...
app/assets/javascripts/notes/stores/actions.js
View file @
f22f75b7
...
@@ -187,6 +187,14 @@ export const poll = ({ commit, state, getters }) => {
...
@@ -187,6 +187,14 @@ export const poll = ({ commit, state, getters }) => {
});
});
};
};
export
const
stopPolling
=
()
=>
{
eTagPoll
.
stop
();
};
export
const
restartPolling
=
()
=>
{
eTagPoll
.
restart
();
};
export
const
fetchData
=
({
commit
,
state
,
getters
})
=>
{
export
const
fetchData
=
({
commit
,
state
,
getters
})
=>
{
const
requestData
=
{
endpoint
:
state
.
notesData
.
notesPath
,
lastFetchedAt
:
state
.
lastFetchedAt
};
const
requestData
=
{
endpoint
:
state
.
notesData
.
notesPath
,
lastFetchedAt
:
state
.
lastFetchedAt
};
...
...
app/assets/javascripts/notes/stores/mutations.js
View file @
f22f75b7
...
@@ -5,6 +5,9 @@ import * as constants from '../constants';
...
@@ -5,6 +5,9 @@ import * as constants from '../constants';
export
default
{
export
default
{
[
types
.
ADD_NEW_NOTE
](
state
,
note
)
{
[
types
.
ADD_NEW_NOTE
](
state
,
note
)
{
const
{
discussion_id
,
type
}
=
note
;
const
{
discussion_id
,
type
}
=
note
;
const
[
exists
]
=
state
.
notes
.
filter
(
n
=>
n
.
id
===
note
.
discussion_id
);
if
(
!
exists
)
{
const
noteData
=
{
const
noteData
=
{
expanded
:
true
,
expanded
:
true
,
id
:
discussion_id
,
id
:
discussion_id
,
...
@@ -14,6 +17,7 @@ export default {
...
@@ -14,6 +17,7 @@ export default {
};
};
state
.
notes
.
push
(
noteData
);
state
.
notes
.
push
(
noteData
);
}
},
},
[
types
.
ADD_NEW_REPLY_TO_DISCUSSION
](
state
,
note
)
{
[
types
.
ADD_NEW_REPLY_TO_DISCUSSION
](
state
,
note
)
{
...
...
spec/javascripts/notes/stores/actions_spec.js
View file @
f22f75b7
import
*
as
actions
from
'
~/notes/stores/actions
'
;
import
*
as
actions
from
'
~/notes/stores/actions
'
;
import
testAction
from
'
./helpers
'
;
import
testAction
from
'
./helpers
'
;
import
{
discussionMock
,
notesDataMock
,
userDataMock
,
issueDataMock
,
individualNote
}
from
'
../mock_data
'
;
import
{
discussionMock
,
notesDataMock
,
userDataMock
,
issueDataMock
,
individualNote
}
from
'
../mock_data
'
;
...
...
spec/javascripts/notes/stores/mutation_spec.js
View file @
f22f75b7
...
@@ -3,19 +3,31 @@ import { note, discussionMock, notesDataMock, userDataMock, issueDataMock, indiv
...
@@ -3,19 +3,31 @@ import { note, discussionMock, notesDataMock, userDataMock, issueDataMock, indiv
describe
(
'
Mutation Notes Store
'
,
()
=>
{
describe
(
'
Mutation Notes Store
'
,
()
=>
{
describe
(
'
ADD_NEW_NOTE
'
,
()
=>
{
describe
(
'
ADD_NEW_NOTE
'
,
()
=>
{
it
(
'
should add a new note to an array of notes
'
,
()
=>
{
let
state
;
const
state
=
{
notes
:
[]
};
let
noteData
;
mutations
.
ADD_NEW_NOTE
(
state
,
note
);
expect
(
state
).
toEqual
({
beforeEach
(()
=>
{
notes
:
[{
state
=
{
notes
:
[]
};
noteData
=
{
expanded
:
true
,
expanded
:
true
,
id
:
note
.
discussion_id
,
id
:
note
.
discussion_id
,
individual_note
:
true
,
individual_note
:
true
,
notes
:
[
note
],
notes
:
[
note
],
reply_id
:
note
.
discussion_id
,
reply_id
:
note
.
discussion_id
,
}],
};
mutations
.
ADD_NEW_NOTE
(
state
,
note
);
});
it
(
'
should add a new note to an array of notes
'
,
()
=>
{
expect
(
state
).
toEqual
({
notes
:
[
noteData
],
});
});
expect
(
state
.
notes
.
length
).
toBe
(
1
);
});
it
(
'
should not add the same note to the notes array
'
,
()
=>
{
mutations
.
ADD_NEW_NOTE
(
state
,
note
);
expect
(
state
.
notes
.
length
).
toBe
(
1
);
});
});
});
});
...
...
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