Commit 93cb0599 authored by Jonston Chan's avatar Jonston Chan

Update references to "issuable_vue_app:change" to use constant

parent 50f16077
export const EVENT_ISSUABLE_VUE_APP_CHANGE = 'issuable_vue_app:change';
...@@ -2,13 +2,11 @@ import $ from 'jquery'; ...@@ -2,13 +2,11 @@ import $ from 'jquery';
import { joinPaths } from '~/lib/utils/url_utility'; import { joinPaths } from '~/lib/utils/url_utility';
import CreateMergeRequestDropdown from './create_merge_request_dropdown'; import CreateMergeRequestDropdown from './create_merge_request_dropdown';
import { deprecatedCreateFlash as flash } from './flash'; import { deprecatedCreateFlash as flash } from './flash';
import { EVENT_ISSUABLE_VUE_APP_CHANGE } from './issuable/constants';
import axios from './lib/utils/axios_utils'; import axios from './lib/utils/axios_utils';
import { addDelimiter } from './lib/utils/text_utility'; import { addDelimiter } from './lib/utils/text_utility';
import { __ } from './locale'; import { __ } from './locale';
// TODO: Update all references of "issuable_vue_app:change" https://gitlab.com/gitlab-org/gitlab/-/issues/322760
export const EVENT_ISSUABLE_VUE_APP_CHANGE = 'issuable_vue_app:change';
export default class Issue { export default class Issue {
constructor() { constructor() {
if ($('.js-alert-moved-from-service-desk-warning').length) { if ($('.js-alert-moved-from-service-desk-warning').length) {
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import { GlButton, GlDropdown, GlDropdownItem, GlIcon, GlLink, GlModal } from '@gitlab/ui'; import { GlButton, GlDropdown, GlDropdownItem, GlIcon, GlLink, GlModal } from '@gitlab/ui';
import { mapActions, mapGetters, mapState } from 'vuex'; import { mapActions, mapGetters, mapState } from 'vuex';
import createFlash, { FLASH_TYPES } from '~/flash'; import createFlash, { FLASH_TYPES } from '~/flash';
import { EVENT_ISSUABLE_VUE_APP_CHANGE } from '~/issuable/constants';
import { IssuableType } from '~/issuable_show/constants'; import { IssuableType } from '~/issuable_show/constants';
import { IssuableStatus, IssueStateEvent } from '~/issue_show/constants'; import { IssuableStatus, IssueStateEvent } from '~/issue_show/constants';
import { capitalizeFirstCharacter } from '~/lib/utils/text_utility'; import { capitalizeFirstCharacter } from '~/lib/utils/text_utility';
...@@ -148,7 +149,7 @@ export default { ...@@ -148,7 +149,7 @@ export default {
}; };
// Dispatch event which updates open/close state, shared among the issue show page // Dispatch event which updates open/close state, shared among the issue show page
document.dispatchEvent(new CustomEvent('issuable_vue_app:change', payload)); document.dispatchEvent(new CustomEvent(EVENT_ISSUABLE_VUE_APP_CHANGE, payload));
}) })
.catch(() => createFlash({ message: __('Error occurred while updating the issue status') })) .catch(() => createFlash({ message: __('Error occurred while updating the issue status') }))
.finally(() => { .finally(() => {
......
...@@ -2,6 +2,7 @@ import $ from 'jquery'; ...@@ -2,6 +2,7 @@ import $ from 'jquery';
import Visibility from 'visibilityjs'; import Visibility from 'visibilityjs';
import Vue from 'vue'; import Vue from 'vue';
import Api from '~/api'; import Api from '~/api';
import { EVENT_ISSUABLE_VUE_APP_CHANGE } from '~/issuable/constants';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { __, sprintf } from '~/locale'; import { __, sprintf } from '~/locale';
import { confidentialWidget } from '~/sidebar/components/confidential/sidebar_confidentiality_widget.vue'; import { confidentialWidget } from '~/sidebar/components/confidential/sidebar_confidentiality_widget.vue';
...@@ -267,7 +268,7 @@ export const toggleStateButtonLoading = ({ commit }, value) => ...@@ -267,7 +268,7 @@ export const toggleStateButtonLoading = ({ commit }, value) =>
commit(types.TOGGLE_STATE_BUTTON_LOADING, value); commit(types.TOGGLE_STATE_BUTTON_LOADING, value);
export const emitStateChangedEvent = ({ getters }, data) => { export const emitStateChangedEvent = ({ getters }, data) => {
const event = new CustomEvent('issuable_vue_app:change', { const event = new CustomEvent(EVENT_ISSUABLE_VUE_APP_CHANGE, {
detail: { detail: {
data, data,
isClosed: getters.openState === constants.CLOSED, isClosed: getters.openState === constants.CLOSED,
......
<script> <script>
import { GlButton, GlIcon, GlTooltipDirective } from '@gitlab/ui'; import { GlButton, GlIcon, GlTooltipDirective } from '@gitlab/ui';
import { mapState, mapGetters, mapActions } from 'vuex'; import { mapState, mapGetters, mapActions } from 'vuex';
import { EVENT_ISSUABLE_VUE_APP_CHANGE } from '~/issuable/constants';
import { __ } from '~/locale'; import { __ } from '~/locale';
...@@ -58,7 +59,7 @@ export default { ...@@ -58,7 +59,7 @@ export default {
* across the UI so we directly call `requestEpicStatusChangeSuccess` action * across the UI so we directly call `requestEpicStatusChangeSuccess` action
* to update store state. * to update store state.
*/ */
epicUtils.bindDocumentEvent('issuable_vue_app:change', (e, isClosed) => { epicUtils.bindDocumentEvent(EVENT_ISSUABLE_VUE_APP_CHANGE, (e, isClosed) => {
const isEpicOpen = e.detail ? !e.detail.isClosed : !isClosed; const isEpicOpen = e.detail ? !e.detail.isClosed : !isClosed;
this.requestEpicStatusChangeSuccess({ this.requestEpicStatusChangeSuccess({
state: isEpicOpen ? statusType.open : statusType.close, state: isEpicOpen ? statusType.open : statusType.close,
......
import epicDetailsQuery from 'shared_queries/epic/epic_details.query.graphql'; import epicDetailsQuery from 'shared_queries/epic/epic_details.query.graphql';
import { deprecatedCreateFlash as flash } from '~/flash'; import { deprecatedCreateFlash as flash } from '~/flash';
import { EVENT_ISSUABLE_VUE_APP_CHANGE } from '~/issuable/constants';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { visitUrl } from '~/lib/utils/url_utility'; import { visitUrl } from '~/lib/utils/url_utility';
...@@ -60,7 +61,7 @@ export const triggerIssuableEvent = (_, { isEpicOpen }) => { ...@@ -60,7 +61,7 @@ export const triggerIssuableEvent = (_, { isEpicOpen }) => {
// comment form (part of Notes app) We've wrapped // comment form (part of Notes app) We've wrapped
// call to `$(document).trigger` within `triggerDocumentEvent` // call to `$(document).trigger` within `triggerDocumentEvent`
// for ease of testing // for ease of testing
epicUtils.triggerDocumentEvent('issuable_vue_app:change', isEpicOpen); epicUtils.triggerDocumentEvent(EVENT_ISSUABLE_VUE_APP_CHANGE, isEpicOpen);
epicUtils.triggerDocumentEvent('issuable:change', isEpicOpen); epicUtils.triggerDocumentEvent('issuable:change', isEpicOpen);
}; };
......
...@@ -6,6 +6,7 @@ import defaultState from 'ee/epic/store/state'; ...@@ -6,6 +6,7 @@ import defaultState from 'ee/epic/store/state';
import epicUtils from 'ee/epic/utils/epic_utils'; import epicUtils from 'ee/epic/utils/epic_utils';
import testAction from 'helpers/vuex_action_helper'; import testAction from 'helpers/vuex_action_helper';
import { EVENT_ISSUABLE_VUE_APP_CHANGE } from '~/issuable/constants';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { mockEpicMeta, mockEpicData } from '../mock_data'; import { mockEpicMeta, mockEpicData } from '../mock_data';
...@@ -216,7 +217,7 @@ describe('Epic Store Actions', () => { ...@@ -216,7 +217,7 @@ describe('Epic Store Actions', () => {
actions.triggerIssuableEvent({}, data); actions.triggerIssuableEvent({}, data);
expect(epicUtils.triggerDocumentEvent).toHaveBeenCalledWith( expect(epicUtils.triggerDocumentEvent).toHaveBeenCalledWith(
'issuable_vue_app:change', EVENT_ISSUABLE_VUE_APP_CHANGE,
data.isEpicOpen, data.isEpicOpen,
); );
......
import { getByText } from '@testing-library/dom'; import { getByText } from '@testing-library/dom';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import Issue, { EVENT_ISSUABLE_VUE_APP_CHANGE } from '~/issue'; import { EVENT_ISSUABLE_VUE_APP_CHANGE } from '~/issuable/constants';
import Issue from '~/issue';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
describe('Issue', () => { describe('Issue', () => {
......
...@@ -3,6 +3,7 @@ import testAction from 'helpers/vuex_action_helper'; ...@@ -3,6 +3,7 @@ import testAction from 'helpers/vuex_action_helper';
import { TEST_HOST } from 'spec/test_constants'; import { TEST_HOST } from 'spec/test_constants';
import Api from '~/api'; import Api from '~/api';
import { deprecatedCreateFlash as Flash } from '~/flash'; import { deprecatedCreateFlash as Flash } from '~/flash';
import { EVENT_ISSUABLE_VUE_APP_CHANGE } from '~/issuable/constants';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import * as notesConstants from '~/notes/constants'; import * as notesConstants from '~/notes/constants';
import createStore from '~/notes/stores'; import createStore from '~/notes/stores';
...@@ -202,7 +203,7 @@ describe('Actions Notes Store', () => { ...@@ -202,7 +203,7 @@ describe('Actions Notes Store', () => {
describe('emitStateChangedEvent', () => { describe('emitStateChangedEvent', () => {
it('emits an event on the document', () => { it('emits an event on the document', () => {
document.addEventListener('issuable_vue_app:change', (event) => { document.addEventListener(EVENT_ISSUABLE_VUE_APP_CHANGE, (event) => {
expect(event.detail.data).toEqual({ id: '1', state: 'closed' }); expect(event.detail.data).toEqual({ id: '1', state: 'closed' });
expect(event.detail.isClosed).toEqual(false); expect(event.detail.isClosed).toEqual(false);
}); });
......
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