Commit e5dc3a07 authored by Tom Quirk's avatar Tom Quirk

Render comments on Jira issues within Gitlab

- updates shape of IssueDetailEntity comments
- extends issuable_show to support a description slot
- renders Jira comments
parent e012f293
<script>
export default {
name: 'IssuableDiscussion',
};
</script>
<template>
<section class="issuable-discussion">
<div>
<ul class="notes main-notes-list timeline">
<slot name="discussion"></slot>
</ul>
</div>
</section>
</template>
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import IssuableSidebar from '~/issuable_sidebar/components/issuable_sidebar_root.vue'; import IssuableSidebar from '~/issuable_sidebar/components/issuable_sidebar_root.vue';
import IssuableBody from './issuable_body.vue'; import IssuableBody from './issuable_body.vue';
import IssuableDiscussion from './issuable_discussion.vue';
import IssuableHeader from './issuable_header.vue'; import IssuableHeader from './issuable_header.vue';
export default { export default {
...@@ -9,6 +10,7 @@ export default { ...@@ -9,6 +10,7 @@ export default {
IssuableSidebar, IssuableSidebar,
IssuableHeader, IssuableHeader,
IssuableBody, IssuableBody,
IssuableDiscussion,
}, },
props: { props: {
issuable: { issuable: {
...@@ -89,6 +91,7 @@ export default { ...@@ -89,6 +91,7 @@ export default {
<slot name="header-actions"></slot> <slot name="header-actions"></slot>
</template> </template>
</issuable-header> </issuable-header>
<issuable-body <issuable-body
:issuable="issuable" :issuable="issuable"
:status-badge-class="statusBadgeClass" :status-badge-class="statusBadgeClass"
...@@ -111,6 +114,13 @@ export default { ...@@ -111,6 +114,13 @@ export default {
<slot name="edit-form-actions" v-bind="actionsProps"></slot> <slot name="edit-form-actions" v-bind="actionsProps"></slot>
</template> </template>
</issuable-body> </issuable-body>
<issuable-discussion>
<template #discussion>
<slot name="discussion"></slot>
</template>
</issuable-discussion>
<issuable-sidebar @sidebar-toggle="$emit('sidebar-toggle', $event)"> <issuable-sidebar @sidebar-toggle="$emit('sidebar-toggle', $event)">
<template #right-sidebar-items="sidebarProps"> <template #right-sidebar-items="sidebarProps">
<slot name="right-sidebar-items" v-bind="sidebarProps"></slot> <slot name="right-sidebar-items" v-bind="sidebarProps"></slot>
......
<script> <script>
import { GlAlert, GlSprintf, GlLink } from '@gitlab/ui'; import { GlAlert, GlSprintf, GlLink, GlBadge, GlTooltipDirective as GlTooltip } from '@gitlab/ui';
import { fetchIssue } from 'ee/integrations/jira/issues_show/api'; import { fetchIssue } from 'ee/integrations/jira/issues_show/api';
import JiraIssueSidebar from 'ee/integrations/jira/issues_show/components/sidebar/jira_issues_sidebar_root.vue'; import JiraIssueSidebar from 'ee/integrations/jira/issues_show/components/sidebar/jira_issues_sidebar_root.vue';
import { issueStates, issueStateLabels } from 'ee/integrations/jira/issues_show/constants'; import { issueStates, issueStateLabels } from 'ee/integrations/jira/issues_show/constants';
import IssuableShow from '~/issuable_show/components/issuable_show_root.vue'; import IssuableShow from '~/issuable_show/components/issuable_show_root.vue';
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
import Note from './note.vue';
export default { export default {
name: 'JiraIssuesShow', name: 'JiraIssuesShow',
...@@ -12,8 +13,13 @@ export default { ...@@ -12,8 +13,13 @@ export default {
GlAlert, GlAlert,
GlSprintf, GlSprintf,
GlLink, GlLink,
GlBadge,
IssuableShow, IssuableShow,
JiraIssueSidebar, JiraIssueSidebar,
Note,
},
directives: {
GlTooltip,
}, },
inject: { inject: {
issuesShowPath: { issuesShowPath: {
...@@ -46,6 +52,11 @@ export default { ...@@ -46,6 +52,11 @@ export default {
}); });
this.isLoading = false; this.isLoading = false;
}, },
methods: {
jiraIssueCommentId(id) {
return `jira_note_${id}`;
},
},
}; };
</script> </script>
...@@ -82,6 +93,26 @@ export default { ...@@ -82,6 +93,26 @@ export default {
<template #right-sidebar-items="{ sidebarExpanded }"> <template #right-sidebar-items="{ sidebarExpanded }">
<jira-issue-sidebar :sidebar-expanded="sidebarExpanded" :issue="issue" /> <jira-issue-sidebar :sidebar-expanded="sidebarExpanded" :issue="issue" />
</template> </template>
<template #discussion>
<note
v-for="comment in issue.comments"
:id="jiraIssueCommentId(comment.id)"
:key="comment.id"
:author-avatar-url="comment.author.avatarUrl"
:author-web-url="comment.author.webUrl"
:author-name="comment.author.name"
:author-username="comment.author.username"
:note-body-html="comment.bodyHtml"
:note-created-at="comment.createdAt"
>
<template #badges>
<gl-badge v-gl-tooltip="{ title: __('This is a Jira user.') }">
{{ __('Jira user') }}
</gl-badge>
</template>
</note>
</template>
</issuable-show> </issuable-show>
</div> </div>
</template> </template>
...@@ -18,11 +18,13 @@ module Integrations ...@@ -18,11 +18,13 @@ module Integrations
expose :comments do |jira_issue| expose :comments do |jira_issue|
jira_issue.renderedFields['comment']['comments'].map do |comment| jira_issue.renderedFields['comment']['comments'].map do |comment|
jira_user(comment['author']).merge( {
note: Banzai::Pipeline::JiraGfmPipeline.call(comment['body'], project: project)[:output].to_html, id: comment['id'],
body_html: Banzai::Pipeline::JiraGfmPipeline.call(comment['body'], project: project)[:output].to_html,
created_at: comment['created'].to_datetime.utc, created_at: comment['created'].to_datetime.utc,
updated_at: comment['updated'].to_datetime.utc updated_at: comment['updated'].to_datetime.utc,
) author: jira_user(comment['author'])
}
end end
end end
end end
......
...@@ -101,10 +101,12 @@ RSpec.describe Integrations::Jira::IssueDetailEntity do ...@@ -101,10 +101,12 @@ RSpec.describe Integrations::Jira::IssueDetailEntity do
external_tracker: 'jira', external_tracker: 'jira',
comments: [ comments: [
hash_including( hash_including(
name: 'comment_author', author: hash_including({
username: 'comment@author.com', name: 'comment_author',
avatar_url: 'http://comment_author.avatar', username: 'comment@author.com',
note: "<p dir=\"auto\">Comment</p>", avatar_url: 'http://comment_author.avatar'
}),
body_html: "<p dir=\"auto\">Comment</p>",
created_at: '2020-06-25T15:50:00.000+0000'.to_datetime.utc, created_at: '2020-06-25T15:50:00.000+0000'.to_datetime.utc,
updated_at: '2020-06-25T15:51:00.000+0000'.to_datetime.utc updated_at: '2020-06-25T15:51:00.000+0000'.to_datetime.utc
) )
...@@ -116,7 +118,7 @@ RSpec.describe Integrations::Jira::IssueDetailEntity do ...@@ -116,7 +118,7 @@ RSpec.describe Integrations::Jira::IssueDetailEntity do
it 'returns the Jira Server profile URL' do it 'returns the Jira Server profile URL' do
expect(subject[:author]).to include(web_url: 'http://jira.com/secure/ViewProfile.jspa?name=reporter@reporter.com') expect(subject[:author]).to include(web_url: 'http://jira.com/secure/ViewProfile.jspa?name=reporter@reporter.com')
expect(subject[:assignees].first).to include(web_url: 'http://jira.com/secure/ViewProfile.jspa?name=assignee@assignee.com') expect(subject[:assignees].first).to include(web_url: 'http://jira.com/secure/ViewProfile.jspa?name=assignee@assignee.com')
expect(subject[:comments].first).to include(web_url: 'http://jira.com/secure/ViewProfile.jspa?name=comment@author.com') expect(subject[:comments].first[:author]).to include(web_url: 'http://jira.com/secure/ViewProfile.jspa?name=comment@author.com')
end end
context 'with only url' do context 'with only url' do
...@@ -142,7 +144,7 @@ RSpec.describe Integrations::Jira::IssueDetailEntity do ...@@ -142,7 +144,7 @@ RSpec.describe Integrations::Jira::IssueDetailEntity do
it 'returns the Jira Cloud profile URL' do it 'returns the Jira Cloud profile URL' do
expect(subject[:author]).to include(web_url: 'http://jira.com/people/12345') expect(subject[:author]).to include(web_url: 'http://jira.com/people/12345')
expect(subject[:assignees].first).to include(web_url: 'http://jira.com/people/67890') expect(subject[:assignees].first).to include(web_url: 'http://jira.com/people/67890')
expect(subject[:comments].first).to include(web_url: 'http://jira.com/people/54321') expect(subject[:comments].first[:author]).to include(web_url: 'http://jira.com/people/54321')
end end
end end
......
...@@ -30565,6 +30565,9 @@ msgstr "" ...@@ -30565,6 +30565,9 @@ msgstr ""
msgid "This is a \"Ghost User\", created to hold all issues authored by users that have since been deleted. This user cannot be removed." msgid "This is a \"Ghost User\", created to hold all issues authored by users that have since been deleted. This user cannot be removed."
msgstr "" msgstr ""
msgid "This is a Jira user."
msgstr ""
msgid "This is a Premium feature" msgid "This is a Premium feature"
msgstr "" msgstr ""
......
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