Commit ee1d23fa authored by Fatih Acet's avatar Fatih Acet

Merge branch 'winh-merge-request-commit-discussion' into 'master'

Display commit ID for commit diff discussion on merge request

See merge request gitlab-org/gitlab-ce!23370
parents ed3e9197 ac1badb4
<script> <script>
import _ from 'underscore';
import { mapActions, mapGetters } from 'vuex'; import { mapActions, mapGetters } from 'vuex';
import { GlTooltipDirective } from '@gitlab/ui'; import { GlTooltipDirective } from '@gitlab/ui';
import { truncateSha } from '~/lib/utils/text_utility'; import { truncateSha } from '~/lib/utils/text_utility';
import { s__, __ } from '~/locale'; import { s__, __, sprintf } from '~/locale';
import systemNote from '~/vue_shared/components/notes/system_note.vue'; import systemNote from '~/vue_shared/components/notes/system_note.vue';
import icon from '~/vue_shared/components/icon.vue'; import icon from '~/vue_shared/components/icon.vue';
import Flash from '../../flash'; import Flash from '../../flash';
...@@ -156,6 +157,37 @@ export default { ...@@ -156,6 +157,37 @@ export default {
(!discussion.diff_discussion && resolved && hasReplies && !isRepliesToggledByUser) || false (!discussion.diff_discussion && resolved && hasReplies && !isRepliesToggledByUser) || false
); );
}, },
actionText() {
const commitId = this.discussion.commit_id ? truncateSha(this.discussion.commit_id) : '';
const linkStart = `<a href="${_.escape(this.discussion.discussion_path)}">`;
const linkEnd = '</a>';
let text = s__('MergeRequests|started a discussion');
if (this.discussion.for_commit) {
text = s__(
'MergeRequests|started a discussion on commit %{linkStart}%{commitId}%{linkEnd}',
);
} else if (this.discussion.diff_discussion) {
if (this.discussion.active) {
text = s__('MergeRequests|started a discussion on %{linkStart}the diff%{linkEnd}');
} else {
text = s__(
'MergeRequests|started a discussion on %{linkStart}an old version of the diff%{linkEnd}',
);
}
}
return sprintf(
text,
{
commitId,
linkStart,
linkEnd,
},
false,
);
},
}, },
watch: { watch: {
isReplying() { isReplying() {
...@@ -291,24 +323,7 @@ Please check your network connection and try again.`; ...@@ -291,24 +323,7 @@ Please check your network connection and try again.`;
:expanded="discussion.expanded" :expanded="discussion.expanded"
@toggleHandler="toggleDiscussionHandler" @toggleHandler="toggleDiscussionHandler"
> >
<template v-if="discussion.diff_discussion"> <span v-html="actionText"></span>
started a discussion on
<a :href="discussion.discussion_path">
<template v-if="discussion.active"
>the diff</template
>
<template v-else
>an old version of the diff</template
>
</a>
</template>
<template v-else-if="discussion.for_commit">
started a discussion on commit
<a :href="discussion.discussion_path">{{ truncateSha(discussion.commit_id) }}</a>
</template>
<template v-else
>started a discussion</template
>
</note-header> </note-header>
<note-edited-text <note-edited-text
v-if="discussion.resolved" v-if="discussion.resolved"
......
---
title: Display commit ID for commit diff discussion on merge request
merge_request: 23370
author:
type: fixed
...@@ -4016,6 +4016,18 @@ msgstr "" ...@@ -4016,6 +4016,18 @@ msgstr ""
msgid "MergeRequests|View replaced file @ %{commitId}" msgid "MergeRequests|View replaced file @ %{commitId}"
msgstr "" msgstr ""
msgid "MergeRequests|started a discussion"
msgstr ""
msgid "MergeRequests|started a discussion on %{linkStart}an old version of the diff%{linkEnd}"
msgstr ""
msgid "MergeRequests|started a discussion on %{linkStart}the diff%{linkEnd}"
msgstr ""
msgid "MergeRequests|started a discussion on commit %{linkStart}%{commitId}%{linkEnd}"
msgstr ""
msgid "MergeRequest| %{paragraphStart}changed the description %{descriptionChangedTimes} times %{timeDifferenceMinutes}%{paragraphEnd}" msgid "MergeRequest| %{paragraphStart}changed the description %{descriptionChangedTimes} times %{timeDifferenceMinutes}%{paragraphEnd}"
msgstr "" msgstr ""
......
...@@ -53,13 +53,11 @@ describe 'Merge request > User sees discussions', :js do ...@@ -53,13 +53,11 @@ describe 'Merge request > User sees discussions', :js do
shared_examples 'a functional discussion' do shared_examples 'a functional discussion' do
let(:discussion_id) { note.discussion_id(merge_request) } let(:discussion_id) { note.discussion_id(merge_request) }
# TODO: https://gitlab.com/gitlab-org/gitlab-ce/issues/48034 it 'is displayed' do
xit 'is displayed' do
expect(page).to have_css(".discussion[data-discussion-id='#{discussion_id}']") expect(page).to have_css(".discussion[data-discussion-id='#{discussion_id}']")
end end
# TODO: https://gitlab.com/gitlab-org/gitlab-ce/issues/48034 it 'can be replied to' do
xit 'can be replied to' do
within(".discussion[data-discussion-id='#{discussion_id}']") do within(".discussion[data-discussion-id='#{discussion_id}']") do
click_button 'Reply...' click_button 'Reply...'
fill_in 'note[note]', with: 'Test!' fill_in 'note[note]', with: 'Test!'
...@@ -74,16 +72,21 @@ describe 'Merge request > User sees discussions', :js do ...@@ -74,16 +72,21 @@ describe 'Merge request > User sees discussions', :js do
visit project_merge_request_path(project, merge_request) visit project_merge_request_path(project, merge_request)
end end
context 'a regular commit comment' do # TODO: https://gitlab.com/gitlab-org/gitlab-ce/issues/48034
let(:note) { create(:note_on_commit, project: project) } # context 'a regular commit comment' do
# let(:note) { create(:note_on_commit, project: project) }
it_behaves_like 'a functional discussion' #
end # it_behaves_like 'a functional discussion'
# end
context 'a commit diff comment' do context 'a commit diff comment' do
let(:note) { create(:diff_note_on_commit, project: project) } let(:note) { create(:diff_note_on_commit, project: project) }
it_behaves_like 'a functional discussion' it_behaves_like 'a functional discussion'
it 'displays correct header' do
expect(page).to have_content "started a discussion on commit #{note.commit_id[0...7]}"
end
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment