Commit 7239abdf authored by Tom Quirk's avatar Tom Quirk

Consolidate constants for external issues

This commit removes some duplicated constants used in both
external_issues and the older issues_show. We now favor the issues_show
constants.
parent cbf57cea
import { __ } from '~/locale';
export const issueStates = {
OPENED: 'opened',
CLOSED: 'closed',
};
export const issueStateLabels = {
[issueStates.OPENED]: __('Open'),
[issueStates.CLOSED]: __('Closed'),
};
export const labelsFilterParam = 'labels';
......@@ -11,7 +11,7 @@ import Note from 'ee/external_issues_show/components/note.vue';
import { fetchIssue, fetchIssueStatuses, updateIssue } from 'ee/integrations/jira/issues_show/api';
import JiraIssueSidebar from 'ee/integrations/jira/issues_show/components/sidebar/jira_issues_sidebar_root.vue';
import { issueStates, issueStateLabels } from 'ee/external_issues_show/constants';
import { IssuableStatus, IssuableStatusText } from '~/issue_show/constants';
import createFlash from '~/flash';
import IssuableShow from '~/issuable_show/components/issuable_show_root.vue';
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
......@@ -50,13 +50,13 @@ export default {
},
computed: {
isIssueOpen() {
return this.issue.state === issueStates.OPENED;
return this.issue.state === IssuableStatus.Open;
},
statusBadgeClass() {
return this.isIssueOpen ? 'status-box-open' : 'status-box-issue-closed';
},
statusBadgeText() {
return issueStateLabels[this.issue.state];
return IssuableStatusText[this.issue.state];
},
statusIcon() {
return this.isIssueOpen ? 'issue-open-m' : 'mobile-issue-close';
......
......@@ -11,7 +11,7 @@ import {
import Note from 'ee/external_issues_show/components/note.vue';
import { fetchIssue } from 'ee/integrations/zentao/issues_show/api';
import ZentaoIssueSidebar from 'ee/integrations/zentao/issues_show/components/sidebar/zentao_issues_sidebar_root.vue';
import { issueStates, issueStateLabels } from 'ee/external_issues_show/constants';
import { IssuableStatus, IssuableStatusText } from '~/issue_show/constants';
import IssuableShow from '~/issuable_show/components/issuable_show_root.vue';
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
......@@ -46,13 +46,13 @@ export default {
},
computed: {
isIssueOpen() {
return this.issue.state === issueStates.OPENED;
return this.issue.state === IssuableStatus.Open;
},
statusBadgeClass() {
return this.isIssueOpen ? 'status-box-open' : 'status-box-issue-closed';
},
statusBadgeText() {
return issueStateLabels[this.issue?.state];
return IssuableStatusText[this.issue?.state];
},
statusIcon() {
return this.isIssueOpen ? 'issue-open-m' : 'mobile-issue-close';
......
......@@ -5,7 +5,7 @@ import MockAdapter from 'axios-mock-adapter';
import * as JiraIssuesShowApi from 'ee/integrations/jira/issues_show/api';
import JiraIssuesShow from 'ee/integrations/jira/issues_show/components/jira_issues_show_root.vue';
import JiraIssueSidebar from 'ee/integrations/jira/issues_show/components/sidebar/jira_issues_sidebar_root.vue';
import { issueStates } from 'ee/external_issues_show/constants';
import { IssuableStatus } from '~/issue_show/constants';
import waitForPromises from 'helpers/wait_for_promises';
import IssuableHeader from '~/issuable_show/components/issuable_header.vue';
import IssuableShow from '~/issuable_show/components/issuable_show_root.vue';
......@@ -88,9 +88,9 @@ describe('JiraIssuesShow', () => {
});
describe.each`
state | statusIcon | statusBadgeClass | badgeText
${issueStates.OPENED} | ${'issue-open-m'} | ${'status-box-open'} | ${'Open'}
${issueStates.CLOSED} | ${'mobile-issue-close'} | ${'status-box-issue-closed'} | ${'Closed'}
state | statusIcon | statusBadgeClass | badgeText
${IssuableStatus.Open} | ${'issue-open-m'} | ${'status-box-open'} | ${'Open'}
${IssuableStatus.Closed} | ${'mobile-issue-close'} | ${'status-box-issue-closed'} | ${'Closed'}
`('when issue state is `$state`', ({ state, statusIcon, statusBadgeClass, badgeText }) => {
beforeEach(async () => {
mockAxios.onGet(mockJiraIssuesShowPath).replyOnce(200, { ...mockJiraIssue, state });
......
import { GlAlert, GlLoadingIcon, GlBadge } from '@gitlab/ui';
import MockAdapter from 'axios-mock-adapter';
import { issueStates } from 'ee/external_issues_show/constants';
import { IssuableStatus } from '~/issue_show/constants';
import ZentaoIssuesShow from 'ee/integrations/zentao/issues_show/components/zentao_issues_show_root.vue';
import waitForPromises from 'helpers/wait_for_promises';
......@@ -108,9 +108,9 @@ describe('ZentaoIssuesShow', () => {
});
describe.each`
state | statusIcon | statusBadgeClass | badgeText
${issueStates.OPENED} | ${'issue-open-m'} | ${'status-box-open'} | ${'Open'}
${issueStates.CLOSED} | ${'mobile-issue-close'} | ${'status-box-issue-closed'} | ${'Closed'}
state | statusIcon | statusBadgeClass | badgeText
${IssuableStatus.Open} | ${'issue-open-m'} | ${'status-box-open'} | ${'Open'}
${IssuableStatus.Closed} | ${'mobile-issue-close'} | ${'status-box-issue-closed'} | ${'Closed'}
`('when issue state is `$state`', ({ state, statusIcon, statusBadgeClass, badgeText }) => {
beforeEach(async () => {
mockAxios
......
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