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
686f7f5f
Commit
686f7f5f
authored
Apr 08, 2021
by
Thomas Randolph
Committed by
Phil Hughes
Apr 08, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass a pseudo Diff File from the notes app to the noteable discussion component
parent
6cd65aa2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
139 additions
and
17 deletions
+139
-17
app/assets/javascripts/notes/components/discussion_notes.vue
app/assets/javascripts/notes/components/discussion_notes.vue
+2
-0
app/assets/javascripts/notes/components/noteable_note.vue
app/assets/javascripts/notes/components/noteable_note.vue
+13
-2
changelogs/unreleased/tor-defect-overview-placeholder-message-overview-file-source.yml
...ect-overview-placeholder-message-overview-file-source.yml
+6
-0
spec/frontend/notes/components/noteable_note_spec.js
spec/frontend/notes/components/noteable_note_spec.js
+118
-15
No files found.
app/assets/javascripts/notes/components/discussion_notes.vue
View file @
686f7f5f
...
...
@@ -121,6 +121,7 @@ export default {
:is=
"componentName(firstNote)"
:note=
"componentData(firstNote)"
:line=
"line || diffLine"
:discussion-file=
"discussion.diff_file"
:commit=
"commit"
:help-page-path=
"helpPagePath"
:show-reply-button=
"userCanReply"
...
...
@@ -167,6 +168,7 @@ export default {
v-for=
"(note, index) in discussion.notes"
:key=
"note.id"
:note=
"componentData(note)"
:discussion-file=
"discussion.diff_file"
:help-page-path=
"helpPagePath"
:line=
"diffLine"
:discussion-root=
"index === 0"
...
...
app/assets/javascripts/notes/components/noteable_note.vue
View file @
686f7f5f
...
...
@@ -48,6 +48,11 @@ export default {
required
:
false
,
default
:
null
,
},
discussionFile
:
{
type
:
Object
,
required
:
false
,
default
:
null
,
},
helpPagePath
:
{
type
:
String
,
required
:
false
,
...
...
@@ -167,12 +172,18 @@ export default {
return
commentLineOptions
(
lines
,
this
.
commentLineStart
,
this
.
line
.
line_code
);
},
diffFile
()
{
let
fileResolvedFromAvailableSource
;
if
(
this
.
commentLineStart
.
line_code
)
{
const
lineCode
=
this
.
commentLineStart
.
line_code
.
split
(
'
_
'
)[
0
];
return
this
.
getDiffFileByHash
(
lineCode
);
fileResolvedFromAvailableSource
=
this
.
getDiffFileByHash
(
lineCode
);
}
if
(
!
fileResolvedFromAvailableSource
&&
this
.
discussionFile
)
{
fileResolvedFromAvailableSource
=
this
.
discussionFile
;
}
return
null
;
return
fileResolvedFromAvailableSource
||
null
;
},
},
created
()
{
...
...
changelogs/unreleased/tor-defect-overview-placeholder-message-overview-file-source.yml
0 → 100644
View file @
686f7f5f
---
title
:
Fill in all placeholder values in the apply suggestion commit message placeholder
text
merge_request
:
58136
author
:
type
:
other
spec/frontend/notes/components/noteable_note_spec.js
View file @
686f7f5f
import
{
mount
,
createLocalVue
}
from
'
@vue/test-utils
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
escape
}
from
'
lodash
'
;
import
Vue
from
'
vue
'
;
import
Vuex
from
'
vuex
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
DiffsModule
from
'
~/diffs/store/modules
'
;
import
NoteActions
from
'
~/notes/components/note_actions.vue
'
;
import
NoteBody
from
'
~/notes/components/note_body.vue
'
;
import
NoteHeader
from
'
~/notes/components/note_header.vue
'
;
import
issueNote
from
'
~/notes/components/noteable_note.vue
'
;
import
createStore
from
'
~/notes/stores
'
;
import
NotesModule
from
'
~/notes/stores/modules
'
;
import
UserAvatarLink
from
'
~/vue_shared/components/user_avatar/user_avatar_link.vue
'
;
import
{
noteableDataMock
,
notesDataMock
,
note
}
from
'
../mock_data
'
;
Vue
.
use
(
Vuex
);
const
singleLineNotePosition
=
{
line_range
:
{
start
:
{
line_code
:
'
abc_1_1
'
,
type
:
null
,
old_line
:
'
1
'
,
new_line
:
'
1
'
,
},
end
:
{
line_code
:
'
abc_1_1
'
,
type
:
null
,
old_line
:
'
1
'
,
new_line
:
'
1
'
,
},
},
};
describe
(
'
issue_note
'
,
()
=>
{
let
store
;
let
wrapper
;
const
findMultilineComment
=
()
=>
wrapper
.
find
(
'
[data-testid="multiline-comment"]
'
);
const
createWrapper
=
(
props
=
{})
=>
{
store
=
createStore
();
const
createWrapper
=
(
props
=
{},
storeUpdater
=
(
s
)
=>
s
)
=>
{
store
=
new
Vuex
.
Store
(
storeUpdater
({
modules
:
{
notes
:
NotesModule
(),
diffs
:
DiffsModule
(),
},
}),
);
store
.
dispatch
(
'
setNoteableData
'
,
noteableDataMock
);
store
.
dispatch
(
'
setNotesData
'
,
notesDataMock
);
const
localVue
=
createLocalVue
();
wrapper
=
mount
(
localVue
.
extend
(
issueNote
),
{
wrapper
=
mount
(
issueNote
,
{
store
,
propsData
:
{
note
,
...
props
,
},
localVue
,
stubs
:
[
'
note-header
'
,
'
user-avatar-link
'
,
...
...
@@ -216,9 +249,13 @@ describe('issue_note', () => {
const
noteBodyComponent
=
wrapper
.
findComponent
(
NoteBody
);
store
.
hotUpdate
({
actions
:
{
updateNote
()
{},
setSelectedCommentPositionHover
()
{},
modules
:
{
notes
:
{
actions
:
{
updateNote
()
{},
setSelectedCommentPositionHover
()
{},
},
},
},
});
...
...
@@ -238,8 +275,12 @@ describe('issue_note', () => {
it
(
'
restores content of updated note
'
,
async
()
=>
{
const
updatedText
=
'
updated note text
'
;
store
.
hotUpdate
({
actions
:
{
updateNote
()
{},
modules
:
{
notes
:
{
actions
:
{
updateNote
()
{},
},
},
},
});
const
noteBody
=
wrapper
.
findComponent
(
NoteBody
);
...
...
@@ -267,9 +308,13 @@ describe('issue_note', () => {
const
updateActions
=
()
=>
{
store
.
hotUpdate
({
actions
:
{
updateNote
,
setSelectedCommentPositionHover
()
{},
modules
:
{
notes
:
{
actions
:
{
updateNote
,
setSelectedCommentPositionHover
()
{},
},
},
},
});
};
...
...
@@ -299,4 +344,62 @@ describe('issue_note', () => {
expect
(
updateNote
.
mock
.
calls
[
0
][
1
].
note
.
note
.
position
).
toBe
(
expectation
);
});
});
describe
(
'
diffFile
'
,
()
=>
{
it
.
each
`
scenario | files | noteDef
${
'
the note has no position
'
}
|
${
undefined
}
|
${
note
}
${
'
the Diffs store has no data
'
}
|
${[]}
|
${{
...
note
,
position
:
singleLineNotePosition
}
}
`
(
'
returns `null` when $scenario and no diff file is provided as a prop
'
,
({
noteDef
,
diffs
})
=>
{
const
storeUpdater
=
(
rawStore
)
=>
{
const
updatedStore
=
{
...
rawStore
};
if
(
diffs
)
{
updatedStore
.
modules
.
diffs
.
state
.
diffFiles
=
diffs
;
}
return
updatedStore
;
};
createWrapper
({
note
:
noteDef
,
discussionFile
:
null
},
storeUpdater
);
expect
(
wrapper
.
vm
.
diffFile
).
toBe
(
null
);
},
);
it
(
"
returns the correct diff file from the Diffs store if it's available
"
,
()
=>
{
createWrapper
(
{
note
:
{
...
note
,
position
:
singleLineNotePosition
},
},
(
rawStore
)
=>
{
const
updatedStore
=
{
...
rawStore
};
updatedStore
.
modules
.
diffs
.
state
.
diffFiles
=
[
{
file_hash
:
'
abc
'
,
testId
:
'
diffFileTest
'
},
];
return
updatedStore
;
},
);
expect
(
wrapper
.
vm
.
diffFile
.
testId
).
toBe
(
'
diffFileTest
'
);
});
it
(
'
returns the provided diff file if the more robust getters fail
'
,
()
=>
{
createWrapper
(
{
note
:
{
...
note
,
position
:
singleLineNotePosition
},
discussionFile
:
{
testId
:
'
diffFileTest
'
},
},
(
rawStore
)
=>
{
const
updatedStore
=
{
...
rawStore
};
updatedStore
.
modules
.
diffs
.
state
.
diffFiles
=
[];
return
updatedStore
;
},
);
expect
(
wrapper
.
vm
.
diffFile
.
testId
).
toBe
(
'
diffFileTest
'
);
});
});
});
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