Commit 6ffc0491 authored by Olena Horal-Koretska's avatar Olena Horal-Koretska

Merge branch 'tomquirk/341710-consolidate-external-issue-constants' into 'master'

Consolidate constants for external issues

See merge request gitlab-org/gitlab!72751
parents f9725402 7239abdf
import { __ } from '~/locale';
export const issueStates = {
OPENED: 'opened',
CLOSED: 'closed',
};
export const issueStateLabels = {
[issueStates.OPENED]: __('Open'),
[issueStates.CLOSED]: __('Closed'),
};
export const labelsFilterParam = 'labels'; export const labelsFilterParam = 'labels';
...@@ -11,7 +11,7 @@ import Note from 'ee/external_issues_show/components/note.vue'; ...@@ -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 { 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 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 createFlash from '~/flash';
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';
...@@ -50,13 +50,13 @@ export default { ...@@ -50,13 +50,13 @@ export default {
}, },
computed: { computed: {
isIssueOpen() { isIssueOpen() {
return this.issue.state === issueStates.OPENED; return this.issue.state === IssuableStatus.Open;
}, },
statusBadgeClass() { statusBadgeClass() {
return this.isIssueOpen ? 'status-box-open' : 'status-box-issue-closed'; return this.isIssueOpen ? 'status-box-open' : 'status-box-issue-closed';
}, },
statusBadgeText() { statusBadgeText() {
return issueStateLabels[this.issue.state]; return IssuableStatusText[this.issue.state];
}, },
statusIcon() { statusIcon() {
return this.isIssueOpen ? 'issue-open-m' : 'mobile-issue-close'; return this.isIssueOpen ? 'issue-open-m' : 'mobile-issue-close';
......
...@@ -11,7 +11,7 @@ import { ...@@ -11,7 +11,7 @@ import {
import Note from 'ee/external_issues_show/components/note.vue'; import Note from 'ee/external_issues_show/components/note.vue';
import { fetchIssue } from 'ee/integrations/zentao/issues_show/api'; 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 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 IssuableShow from '~/issuable_show/components/issuable_show_root.vue';
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
...@@ -46,13 +46,13 @@ export default { ...@@ -46,13 +46,13 @@ export default {
}, },
computed: { computed: {
isIssueOpen() { isIssueOpen() {
return this.issue.state === issueStates.OPENED; return this.issue.state === IssuableStatus.Open;
}, },
statusBadgeClass() { statusBadgeClass() {
return this.isIssueOpen ? 'status-box-open' : 'status-box-issue-closed'; return this.isIssueOpen ? 'status-box-open' : 'status-box-issue-closed';
}, },
statusBadgeText() { statusBadgeText() {
return issueStateLabels[this.issue?.state]; return IssuableStatusText[this.issue?.state];
}, },
statusIcon() { statusIcon() {
return this.isIssueOpen ? 'issue-open-m' : 'mobile-issue-close'; return this.isIssueOpen ? 'issue-open-m' : 'mobile-issue-close';
......
...@@ -5,7 +5,7 @@ import MockAdapter from 'axios-mock-adapter'; ...@@ -5,7 +5,7 @@ import MockAdapter from 'axios-mock-adapter';
import * as JiraIssuesShowApi from 'ee/integrations/jira/issues_show/api'; 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 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 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 waitForPromises from 'helpers/wait_for_promises';
import IssuableHeader from '~/issuable_show/components/issuable_header.vue'; import IssuableHeader from '~/issuable_show/components/issuable_header.vue';
import IssuableShow from '~/issuable_show/components/issuable_show_root.vue'; import IssuableShow from '~/issuable_show/components/issuable_show_root.vue';
...@@ -88,9 +88,9 @@ describe('JiraIssuesShow', () => { ...@@ -88,9 +88,9 @@ describe('JiraIssuesShow', () => {
}); });
describe.each` describe.each`
state | statusIcon | statusBadgeClass | badgeText state | statusIcon | statusBadgeClass | badgeText
${issueStates.OPENED} | ${'issue-open-m'} | ${'status-box-open'} | ${'Open'} ${IssuableStatus.Open} | ${'issue-open-m'} | ${'status-box-open'} | ${'Open'}
${issueStates.CLOSED} | ${'mobile-issue-close'} | ${'status-box-issue-closed'} | ${'Closed'} ${IssuableStatus.Closed} | ${'mobile-issue-close'} | ${'status-box-issue-closed'} | ${'Closed'}
`('when issue state is `$state`', ({ state, statusIcon, statusBadgeClass, badgeText }) => { `('when issue state is `$state`', ({ state, statusIcon, statusBadgeClass, badgeText }) => {
beforeEach(async () => { beforeEach(async () => {
mockAxios.onGet(mockJiraIssuesShowPath).replyOnce(200, { ...mockJiraIssue, state }); mockAxios.onGet(mockJiraIssuesShowPath).replyOnce(200, { ...mockJiraIssue, state });
......
import { GlAlert, GlLoadingIcon, GlBadge } from '@gitlab/ui'; import { GlAlert, GlLoadingIcon, GlBadge } from '@gitlab/ui';
import MockAdapter from 'axios-mock-adapter'; 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 ZentaoIssuesShow from 'ee/integrations/zentao/issues_show/components/zentao_issues_show_root.vue';
import waitForPromises from 'helpers/wait_for_promises'; import waitForPromises from 'helpers/wait_for_promises';
...@@ -108,9 +108,9 @@ describe('ZentaoIssuesShow', () => { ...@@ -108,9 +108,9 @@ describe('ZentaoIssuesShow', () => {
}); });
describe.each` describe.each`
state | statusIcon | statusBadgeClass | badgeText state | statusIcon | statusBadgeClass | badgeText
${issueStates.OPENED} | ${'issue-open-m'} | ${'status-box-open'} | ${'Open'} ${IssuableStatus.Open} | ${'issue-open-m'} | ${'status-box-open'} | ${'Open'}
${issueStates.CLOSED} | ${'mobile-issue-close'} | ${'status-box-issue-closed'} | ${'Closed'} ${IssuableStatus.Closed} | ${'mobile-issue-close'} | ${'status-box-issue-closed'} | ${'Closed'}
`('when issue state is `$state`', ({ state, statusIcon, statusBadgeClass, badgeText }) => { `('when issue state is `$state`', ({ state, statusIcon, statusBadgeClass, badgeText }) => {
beforeEach(async () => { beforeEach(async () => {
mockAxios 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