Commit 93e72e3b authored by Justin Ho Tuan Duong's avatar Justin Ho Tuan Duong Committed by Natalia Tepluhina

Add status to Jira issues

- Expose Jira status from backend
- Show Jira status in place of GitLab's "closed" status
parent 8f694b38
...@@ -97,6 +97,9 @@ export default { ...@@ -97,6 +97,9 @@ export default {
isJiraIssue() { isJiraIssue() {
return this.issuable.external_tracker === 'jira'; return this.issuable.external_tracker === 'jira';
}, },
linkTarget() {
return this.isJiraIssue ? '_blank' : null;
},
issueCreatedToday() { issueCreatedToday() {
return getDayDifference(new Date(this.issuable.created_at), new Date()) < 1; return getDayDifference(new Date(this.issuable.created_at), new Date()) < 1;
}, },
...@@ -239,11 +242,7 @@ export default { ...@@ -239,11 +242,7 @@ export default {
:title="$options.confidentialTooltipText" :title="$options.confidentialTooltipText"
:aria-label="$options.confidentialTooltipText" :aria-label="$options.confidentialTooltipText"
/> />
<gl-link <gl-link :href="issuable.web_url" :target="linkTarget" data-testid="issuable-title">
:href="issuable.web_url"
:target="isJiraIssue ? '_blank' : null"
data-testid="issuable-title"
>
{{ issuable.title }} {{ issuable.title }}
<gl-icon <gl-icon
v-if="isJiraIssue" v-if="isJiraIssue"
...@@ -281,6 +280,7 @@ export default { ...@@ -281,6 +280,7 @@ export default {
ref="openedAgoByContainer" ref="openedAgoByContainer"
v-bind="popoverDataAttrs" v-bind="popoverDataAttrs"
:href="issuableAuthor.web_url" :href="issuableAuthor.web_url"
:target="linkTarget"
> >
{{ issuableAuthor.name }} {{ issuableAuthor.name }}
</gl-link> </gl-link>
...@@ -340,8 +340,8 @@ export default { ...@@ -340,8 +340,8 @@ export default {
<!-- Issuable meta --> <!-- Issuable meta -->
<div class="flex-shrink-0 d-flex flex-column align-items-end justify-content-center"> <div class="flex-shrink-0 d-flex flex-column align-items-end justify-content-center">
<div class="controls d-flex"> <div class="controls d-flex">
<span v-if="isJiraIssue">&nbsp;</span> <span v-if="isJiraIssue" data-testid="issuable-status">{{ issuable.status }}</span>
<span v-if="isClosed" class="issuable-status">{{ __('CLOSED') }}</span> <span v-else-if="isClosed" class="issuable-status">{{ __('CLOSED') }}</span>
<issue-assignees <issue-assignees
:assignees="issuable.assignees" :assignees="issuable.assignees"
......
...@@ -23,6 +23,10 @@ module Integrations ...@@ -23,6 +23,10 @@ module Integrations
jira_issue.resolutiondate&.to_datetime&.utc jira_issue.resolutiondate&.to_datetime&.utc
end end
expose :status do |jira_issue|
jira_issue.status.name
end
expose :labels do |jira_issue| expose :labels do |jira_issue|
jira_issue.labels.map do |name| jira_issue.labels.map do |name|
{ {
......
...@@ -23,7 +23,8 @@ RSpec.describe Integrations::Jira::IssueEntity do ...@@ -23,7 +23,8 @@ RSpec.describe Integrations::Jira::IssueEntity do
assignee: double('displayName' => 'assignee'), assignee: double('displayName' => 'assignee'),
project: double(key: 'GL'), project: double(key: 'GL'),
key: 'GL-5', key: 'GL-5',
client: double(options: { site: 'http://jira.com/' }) client: double(options: { site: 'http://jira.com/' }),
status: double(name: 'To Do')
) )
end end
...@@ -36,6 +37,7 @@ RSpec.describe Integrations::Jira::IssueEntity do ...@@ -36,6 +37,7 @@ RSpec.describe Integrations::Jira::IssueEntity do
created_at: '2020-06-25T15:39:30.000+0000'.to_datetime.utc, created_at: '2020-06-25T15:39:30.000+0000'.to_datetime.utc,
updated_at: '2020-06-26T15:38:32.000+0000'.to_datetime.utc, updated_at: '2020-06-26T15:38:32.000+0000'.to_datetime.utc,
closed_at: '2020-06-27T13:23:51.000+0000'.to_datetime.utc, closed_at: '2020-06-27T13:23:51.000+0000'.to_datetime.utc,
status: 'To Do',
labels: [ labels: [
{ {
name: 'backend', name: 'backend',
......
...@@ -80,6 +80,7 @@ describe('Issuable component', () => { ...@@ -80,6 +80,7 @@ describe('Issuable component', () => {
wrapper.findAll(GlIcon).wrappers.some(iconWrapper => iconWrapper.props('name') === 'eye-slash'); wrapper.findAll(GlIcon).wrappers.some(iconWrapper => iconWrapper.props('name') === 'eye-slash');
const findTaskStatus = () => wrapper.find('.task-status'); const findTaskStatus = () => wrapper.find('.task-status');
const findOpenedAgoContainer = () => wrapper.find('[data-testid="openedByMessage"]'); const findOpenedAgoContainer = () => wrapper.find('[data-testid="openedByMessage"]');
const findAuthor = () => wrapper.find({ ref: 'openedAgoByContainer' });
const findMilestone = () => wrapper.find('.js-milestone'); const findMilestone = () => wrapper.find('.js-milestone');
const findMilestoneTooltip = () => findMilestone().attributes('title'); const findMilestoneTooltip = () => findMilestone().attributes('title');
const findDueDate = () => wrapper.find('.js-due-date'); const findDueDate = () => wrapper.find('.js-due-date');
...@@ -94,6 +95,7 @@ describe('Issuable component', () => { ...@@ -94,6 +95,7 @@ describe('Issuable component', () => {
const findScopedLabels = () => findLabels().filter(w => isScopedLabel({ title: w.text() })); const findScopedLabels = () => findLabels().filter(w => isScopedLabel({ title: w.text() }));
const findUnscopedLabels = () => findLabels().filter(w => !isScopedLabel({ title: w.text() })); const findUnscopedLabels = () => findLabels().filter(w => !isScopedLabel({ title: w.text() }));
const findIssuableTitle = () => wrapper.find('[data-testid="issuable-title"]'); const findIssuableTitle = () => wrapper.find('[data-testid="issuable-title"]');
const findIssuableStatus = () => wrapper.find('[data-testid="issuable-status"]');
const containsJiraLogo = () => wrapper.contains('[data-testid="jira-logo"]'); const containsJiraLogo = () => wrapper.contains('[data-testid="jira-logo"]');
describe('when mounted', () => { describe('when mounted', () => {
...@@ -235,6 +237,24 @@ describe('Issuable component', () => { ...@@ -235,6 +237,24 @@ describe('Issuable component', () => {
it('opens issuable in a new tab', () => { it('opens issuable in a new tab', () => {
expect(findIssuableTitle().props('target')).toBe('_blank'); expect(findIssuableTitle().props('target')).toBe('_blank');
}); });
it('opens author in a new tab', () => {
expect(findAuthor().props('target')).toBe('_blank');
});
describe('with Jira status', () => {
const expectedStatus = 'In Progress';
beforeEach(() => {
issuable.status = expectedStatus;
factory({ issuable });
});
it('renders the Jira status', () => {
expect(findIssuableStatus().text()).toBe(expectedStatus);
});
});
}); });
describe('with task status', () => { describe('with task status', () => {
......
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