Commit 69782a3e authored by Kev's avatar Kev Committed by Andrew Fontaine

Replace bootstrap event strings with constants

This replaces the usage of the following bootstrap event names with
constants defined in ~/lib/utils/constants.js.

| Event Name           | Constant           |
| -------------------- | ------------------ |
| `bv::hide:tooltip`   | `BV_HIDE_TOOLTIP`  |
| `bv::dropdown::show` | `BV_DROPDOWN_SHOW` |
| `bv::dropdown::hide` | `BV_DROPDOWN_HIDE` |
parent ae1b9ca4
...@@ -3,6 +3,7 @@ import { Sortable, MultiDrag } from 'sortablejs'; ...@@ -3,6 +3,7 @@ import { Sortable, MultiDrag } from 'sortablejs';
import { GlLoadingIcon } from '@gitlab/ui'; import { GlLoadingIcon } from '@gitlab/ui';
import { sprintf, __ } from '~/locale'; import { sprintf, __ } from '~/locale';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import { deprecatedCreateFlash as createFlash } from '~/flash';
import { BV_HIDE_TOOLTIP } from '~/lib/utils/constants';
import eventHub from '../eventhub'; import eventHub from '../eventhub';
import boardsStore from '../stores/boards_store'; import boardsStore from '../stores/boards_store';
import { import {
...@@ -167,7 +168,7 @@ export default { ...@@ -167,7 +168,7 @@ export default {
boardsStore.startMoving(list, issue); boardsStore.startMoving(list, issue);
this.$root.$emit('bv::hide::tooltip'); this.$root.$emit(BV_HIDE_TOOLTIP);
sortableStart(); sortableStart();
}, },
......
...@@ -13,6 +13,7 @@ import { n__, s__, __ } from '~/locale'; ...@@ -13,6 +13,7 @@ import { n__, s__, __ } from '~/locale';
import sidebarEventHub from '~/sidebar/event_hub'; import sidebarEventHub from '~/sidebar/event_hub';
import { isScopedLabel } from '~/lib/utils/common_utils'; import { isScopedLabel } from '~/lib/utils/common_utils';
import { isListDraggable } from '~/boards/boards_util'; import { isListDraggable } from '~/boards/boards_util';
import { BV_HIDE_TOOLTIP } from '~/lib/utils/constants';
import { inactiveId, LIST, ListType } from '../constants'; import { inactiveId, LIST, ListType } from '../constants';
import eventHub from '../eventhub'; import eventHub from '../eventhub';
import AccessorUtilities from '../../lib/utils/accessor'; import AccessorUtilities from '../../lib/utils/accessor';
...@@ -158,7 +159,7 @@ export default { ...@@ -158,7 +159,7 @@ export default {
// When expanding/collapsing, the tooltip on the caret button sometimes stays open. // When expanding/collapsing, the tooltip on the caret button sometimes stays open.
// Close all tooltips manually to prevent dangling tooltips. // Close all tooltips manually to prevent dangling tooltips.
this.$root.$emit('bv::hide::tooltip'); this.$root.$emit(BV_HIDE_TOOLTIP);
}, },
addToLocalStorage() { addToLocalStorage() {
if (AccessorUtilities.isLocalStorageAccessSafe()) { if (AccessorUtilities.isLocalStorageAccessSafe()) {
......
...@@ -17,6 +17,7 @@ import boardsStore from '../stores/boards_store'; ...@@ -17,6 +17,7 @@ import boardsStore from '../stores/boards_store';
import eventHub from '../eventhub'; import eventHub from '../eventhub';
import { inactiveId, LIST, ListType } from '../constants'; import { inactiveId, LIST, ListType } from '../constants';
import IssueCount from './issue_count.vue'; import IssueCount from './issue_count.vue';
import { BV_HIDE_TOOLTIP } from '~/lib/utils/constants';
// This component is being replaced in favor of './board_list_header.vue' for GraphQL boards // This component is being replaced in favor of './board_list_header.vue' for GraphQL boards
...@@ -142,7 +143,7 @@ export default { ...@@ -142,7 +143,7 @@ export default {
// When expanding/collapsing, the tooltip on the caret button sometimes stays open. // When expanding/collapsing, the tooltip on the caret button sometimes stays open.
// Close all tooltips manually to prevent dangling tooltips. // Close all tooltips manually to prevent dangling tooltips.
this.$root.$emit('bv::hide::tooltip'); this.$root.$emit(BV_HIDE_TOOLTIP);
}, },
addToLocalStorage() { addToLocalStorage() {
if (AccessorUtilities.isLocalStorageAccessSafe()) { if (AccessorUtilities.isLocalStorageAccessSafe()) {
......
...@@ -10,6 +10,7 @@ import { ...@@ -10,6 +10,7 @@ import {
} from '@gitlab/ui'; } from '@gitlab/ui';
import BoardEditableItem from '~/boards/components/sidebar/board_editable_item.vue'; import BoardEditableItem from '~/boards/components/sidebar/board_editable_item.vue';
import createFlash from '~/flash'; import createFlash from '~/flash';
import { BV_DROPDOWN_HIDE } from '~/lib/utils/constants';
import { __, s__ } from '~/locale'; import { __, s__ } from '~/locale';
import projectMilestones from '../../graphql/project_milestones.query.graphql'; import projectMilestones from '../../graphql/project_milestones.query.graphql';
...@@ -73,7 +74,7 @@ export default { ...@@ -73,7 +74,7 @@ export default {
}, },
}, },
mounted() { mounted() {
this.$root.$on('bv::dropdown::hide', () => { this.$root.$on(BV_DROPDOWN_HIDE, () => {
this.$refs.sidebarItem.collapse(); this.$refs.sidebarItem.collapse();
}); });
}, },
......
...@@ -11,6 +11,7 @@ import { ...@@ -11,6 +11,7 @@ import {
CONFLICT_THEIR, CONFLICT_THEIR,
CONFLICT_MARKER, CONFLICT_MARKER,
} from '../constants'; } from '../constants';
import { BV_HIDE_TOOLTIP } from '~/lib/utils/constants';
import DiffGutterAvatars from './diff_gutter_avatars.vue'; import DiffGutterAvatars from './diff_gutter_avatars.vue';
import * as utils from './diff_row_utils'; import * as utils from './diff_row_utils';
...@@ -162,7 +163,7 @@ export default { ...@@ -162,7 +163,7 @@ export default {
this.$emit('enterdragging', { ...line, index }); this.$emit('enterdragging', { ...line, index });
}, },
onDragStart(line) { onDragStart(line) {
this.$root.$emit('bv::hide::tooltip'); this.$root.$emit(BV_HIDE_TOOLTIP);
this.dragging = true; this.dragging = true;
this.$emit('startdragging', line); this.$emit('startdragging', line);
}, },
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
import { GlTooltipDirective, GlButton, GlModalDirective } from '@gitlab/ui'; import { GlTooltipDirective, GlButton, GlModalDirective } from '@gitlab/ui';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import { BV_HIDE_TOOLTIP } from '~/lib/utils/constants';
import eventHub from '../event_hub'; import eventHub from '../event_hub';
export default { export default {
...@@ -40,7 +41,7 @@ export default { ...@@ -40,7 +41,7 @@ export default {
}, },
methods: { methods: {
onClick() { onClick() {
this.$root.$emit('bv::hide::tooltip', this.$options.deleteEnvironmentTooltipId); this.$root.$emit(BV_HIDE_TOOLTIP, this.$options.deleteEnvironmentTooltipId);
eventHub.$emit('requestDeleteEnvironment', this.environment); eventHub.$emit('requestDeleteEnvironment', this.environment);
}, },
onDeleteEnvironment(environment) { onDeleteEnvironment(environment) {
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
import { GlTooltipDirective, GlButton, GlModalDirective } from '@gitlab/ui'; import { GlTooltipDirective, GlButton, GlModalDirective } from '@gitlab/ui';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import { BV_HIDE_TOOLTIP } from '~/lib/utils/constants';
import eventHub from '../event_hub'; import eventHub from '../event_hub';
export default { export default {
...@@ -40,7 +41,7 @@ export default { ...@@ -40,7 +41,7 @@ export default {
}, },
methods: { methods: {
onClick() { onClick() {
this.$root.$emit('bv::hide::tooltip', this.$options.stopEnvironmentTooltipId); this.$root.$emit(BV_HIDE_TOOLTIP, this.$options.stopEnvironmentTooltipId);
eventHub.$emit('requestStopEnvironment', this.environment); eventHub.$emit('requestStopEnvironment', this.environment);
}, },
onStopEnvironment(environment) { onStopEnvironment(environment) {
......
<script> <script>
import { mapActions, mapState } from 'vuex'; import { mapActions, mapState } from 'vuex';
import { GlIcon, GlTooltipDirective } from '@gitlab/ui'; import { GlIcon, GlTooltipDirective } from '@gitlab/ui';
import { BV_HIDE_TOOLTIP } from '~/lib/utils/constants';
import { leftSidebarViews } from '../constants'; import { leftSidebarViews } from '../constants';
export default { export default {
...@@ -20,7 +21,7 @@ export default { ...@@ -20,7 +21,7 @@ export default {
this.updateActivityBarView(view); this.updateActivityBarView(view);
this.$root.$emit('bv::hide::tooltip'); this.$root.$emit(BV_HIDE_TOOLTIP);
}, },
}, },
leftSidebarViews, leftSidebarViews,
......
<script> <script>
import { GlTooltipDirective, GlIcon } from '@gitlab/ui'; import { GlTooltipDirective, GlIcon } from '@gitlab/ui';
import { BV_HIDE_TOOLTIP } from '~/lib/utils/constants';
import { otherSide } from '../utils'; import { otherSide } from '../utils';
import { SIDE_RIGHT } from '../constants'; import { SIDE_RIGHT } from '../constants';
...@@ -50,7 +51,7 @@ export default { ...@@ -50,7 +51,7 @@ export default {
}, },
clickTab(e, tab) { clickTab(e, tab) {
e.currentTarget.blur(); e.currentTarget.blur();
this.$root.$emit('bv::hide::tooltip'); this.$root.$emit(BV_HIDE_TOOLTIP);
if (this.isActiveTab(tab)) { if (this.isActiveTab(tab)) {
this.$emit('close'); this.$emit('close');
......
...@@ -13,3 +13,6 @@ export const DATETIME_RANGE_TYPES = { ...@@ -13,3 +13,6 @@ export const DATETIME_RANGE_TYPES = {
export const BV_SHOW_MODAL = 'bv::show::modal'; export const BV_SHOW_MODAL = 'bv::show::modal';
export const BV_HIDE_MODAL = 'bv::hide::modal'; export const BV_HIDE_MODAL = 'bv::hide::modal';
export const BV_HIDE_TOOLTIP = 'bv::hide::tooltip';
export const BV_DROPDOWN_SHOW = 'bv::dropdown::show';
export const BV_DROPDOWN_HIDE = 'bv::dropdown::hide';
...@@ -6,6 +6,7 @@ import resolvedStatusMixin from '~/batch_comments/mixins/resolved_status'; ...@@ -6,6 +6,7 @@ import resolvedStatusMixin from '~/batch_comments/mixins/resolved_status';
import eventHub from '~/sidebar/event_hub'; import eventHub from '~/sidebar/event_hub';
import Api from '~/api'; import Api from '~/api';
import { deprecatedCreateFlash as flash } from '~/flash'; import { deprecatedCreateFlash as flash } from '~/flash';
import { BV_HIDE_TOOLTIP } from '~/lib/utils/constants';
import { splitCamelCase } from '../../lib/utils/text_utility'; import { splitCamelCase } from '../../lib/utils/text_utility';
import ReplyButton from './note_actions/reply_button.vue'; import ReplyButton from './note_actions/reply_button.vue';
...@@ -193,7 +194,7 @@ export default { ...@@ -193,7 +194,7 @@ export default {
}, },
closeTooltip() { closeTooltip() {
this.$nextTick(() => { this.$nextTick(() => {
this.$root.$emit('bv::hide::tooltip'); this.$root.$emit(BV_HIDE_TOOLTIP);
}); });
}, },
handleAssigneeUpdate(assignees) { handleAssigneeUpdate(assignees) {
......
...@@ -3,6 +3,7 @@ import { GlTooltipDirective, GlButton, GlLoadingIcon, GlIcon } from '@gitlab/ui' ...@@ -3,6 +3,7 @@ import { GlTooltipDirective, GlButton, GlLoadingIcon, GlIcon } from '@gitlab/ui'
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { dasherize } from '~/lib/utils/text_utility'; import { dasherize } from '~/lib/utils/text_utility';
import { __ } from '~/locale'; import { __ } from '~/locale';
import { BV_HIDE_TOOLTIP } from '~/lib/utils/constants';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import { deprecatedCreateFlash as createFlash } from '~/flash';
import { reportToSentry } from './utils'; import { reportToSentry } from './utils';
...@@ -62,7 +63,7 @@ export default { ...@@ -62,7 +63,7 @@ export default {
* *
*/ */
onClickAction() { onClickAction() {
this.$root.$emit('bv::hide::tooltip', `js-ci-action-${this.link}`); this.$root.$emit(BV_HIDE_TOOLTIP, `js-ci-action-${this.link}`);
this.isDisabled = true; this.isDisabled = true;
this.isLoading = true; this.isLoading = true;
......
...@@ -4,6 +4,7 @@ import { sprintf } from '~/locale'; ...@@ -4,6 +4,7 @@ import { sprintf } from '~/locale';
import delayedJobMixin from '~/jobs/mixins/delayed_job_mixin'; import delayedJobMixin from '~/jobs/mixins/delayed_job_mixin';
import ActionComponent from './action_component.vue'; import ActionComponent from './action_component.vue';
import JobNameComponent from './job_name_component.vue'; import JobNameComponent from './job_name_component.vue';
import { BV_HIDE_TOOLTIP } from '~/lib/utils/constants';
import { accessValue } from './accessors'; import { accessValue } from './accessors';
import { REST } from './constants'; import { REST } from './constants';
import { reportToSentry } from './utils'; import { reportToSentry } from './utils';
...@@ -144,7 +145,7 @@ export default { ...@@ -144,7 +145,7 @@ export default {
}, },
methods: { methods: {
hideTooltips() { hideTooltips() {
this.$root.$emit('bv::hide::tooltip'); this.$root.$emit(BV_HIDE_TOOLTIP);
}, },
pipelineActionRequestComplete() { pipelineActionRequestComplete() {
this.$emit('pipelineActionRequestComplete'); this.$emit('pipelineActionRequestComplete');
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import { GlTooltipDirective, GlButton, GlLink, GlLoadingIcon, GlBadge } from '@gitlab/ui'; import { GlTooltipDirective, GlButton, GlLink, GlLoadingIcon, GlBadge } from '@gitlab/ui';
import CiStatus from '~/vue_shared/components/ci_icon.vue'; import CiStatus from '~/vue_shared/components/ci_icon.vue';
import { __, sprintf } from '~/locale'; import { __, sprintf } from '~/locale';
import { BV_HIDE_TOOLTIP } from '~/lib/utils/constants';
import { accessValue } from './accessors'; import { accessValue } from './accessors';
import { DOWNSTREAM, REST, UPSTREAM } from './constants'; import { DOWNSTREAM, REST, UPSTREAM } from './constants';
import { reportToSentry } from './utils'; import { reportToSentry } from './utils';
...@@ -126,7 +127,7 @@ export default { ...@@ -126,7 +127,7 @@ export default {
this.$emit('pipelineExpandToggle', this.sourceJobName, !this.expanded); this.$emit('pipelineExpandToggle', this.sourceJobName, !this.expanded);
}, },
hideTooltips() { hideTooltips() {
this.$root.$emit('bv::hide::tooltip'); this.$root.$emit(BV_HIDE_TOOLTIP);
}, },
onDownstreamHovered() { onDownstreamHovered() {
this.$emit('downstreamHovered', this.sourceJobName); this.$emit('downstreamHovered', this.sourceJobName);
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import { GlButton, GlTooltipDirective } from '@gitlab/ui'; import { GlButton, GlTooltipDirective } from '@gitlab/ui';
import Clipboard from 'clipboard'; import Clipboard from 'clipboard';
import { uniqueId } from 'lodash'; import { uniqueId } from 'lodash';
import { BV_HIDE_TOOLTIP } from '~/lib/utils/constants';
export default { export default {
components: { components: {
...@@ -76,7 +77,7 @@ export default { ...@@ -76,7 +77,7 @@ export default {
}); });
this.clipboard this.clipboard
.on('success', (e) => { .on('success', (e) => {
this.$root.$emit('bv::hide::tooltip', this.id); this.$root.$emit(BV_HIDE_TOOLTIP, this.id);
this.$emit('success', e); this.$emit('success', e);
// Clear the selection and blur the trigger so it loses its border // Clear the selection and blur the trigger so it loses its border
e.clearSelection(); e.clearSelection();
......
---
title: Replace bootstrap event strings with constants
merge_request: 52777
author: Kev @KevSlashNull
type: other
...@@ -3,6 +3,7 @@ import { GlIcon } from '@gitlab/ui'; ...@@ -3,6 +3,7 @@ import { GlIcon } from '@gitlab/ui';
import { createMockDirective, getBinding } from 'helpers/vue_mock_directive'; import { createMockDirective, getBinding } from 'helpers/vue_mock_directive';
import IdeSidebarNav from '~/ide/components/ide_sidebar_nav.vue'; import IdeSidebarNav from '~/ide/components/ide_sidebar_nav.vue';
import { SIDE_RIGHT, SIDE_LEFT } from '~/ide/constants'; import { SIDE_RIGHT, SIDE_LEFT } from '~/ide/constants';
import { BV_HIDE_TOOLTIP } from '~/lib/utils/constants';
const TEST_TABS = [ const TEST_TABS = [
{ {
...@@ -74,7 +75,7 @@ describe('ide/components/ide_sidebar_nav', () => { ...@@ -74,7 +75,7 @@ describe('ide/components/ide_sidebar_nav', () => {
createComponent({ isOpen, side }); createComponent({ isOpen, side });
bsTooltipHide = jest.fn(); bsTooltipHide = jest.fn();
wrapper.vm.$root.$on('bv::hide::tooltip', bsTooltipHide); wrapper.vm.$root.$on(BV_HIDE_TOOLTIP, bsTooltipHide);
}); });
it('renders buttons', () => { it('renders buttons', () => {
......
...@@ -6,6 +6,7 @@ import { GlDropdown, GlDropdownItem } from '@gitlab/ui'; ...@@ -6,6 +6,7 @@ import { GlDropdown, GlDropdownItem } from '@gitlab/ui';
import { GlBreakpointInstance as bp } from '@gitlab/ui/dist/utils'; import { GlBreakpointInstance as bp } from '@gitlab/ui/dist/utils';
import waitForPromises from 'helpers/wait_for_promises'; import waitForPromises from 'helpers/wait_for_promises';
import RoleDropdown from '~/members/components/table/role_dropdown.vue'; import RoleDropdown from '~/members/components/table/role_dropdown.vue';
import { BV_DROPDOWN_SHOW } from '~/lib/utils/constants';
import { member } from '../../mock_data'; import { member } from '../../mock_data';
const localVue = createLocalVue(); const localVue = createLocalVue();
...@@ -67,7 +68,7 @@ describe('RoleDropdown', () => { ...@@ -67,7 +68,7 @@ describe('RoleDropdown', () => {
createComponent(); createComponent();
findDropdownToggle().trigger('click'); findDropdownToggle().trigger('click');
wrapper.vm.$root.$on('bv::dropdown::shown', () => { wrapper.vm.$root.$on(BV_DROPDOWN_SHOW, () => {
done(); done();
}); });
}); });
......
...@@ -6,6 +6,7 @@ import createStore from '~/notes/stores'; ...@@ -6,6 +6,7 @@ import createStore from '~/notes/stores';
import noteActions from '~/notes/components/note_actions.vue'; import noteActions from '~/notes/components/note_actions.vue';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { userDataMock } from '../mock_data'; import { userDataMock } from '../mock_data';
import { BV_HIDE_TOOLTIP } from '~/lib/utils/constants';
describe('noteActions', () => { describe('noteActions', () => {
let wrapper; let wrapper;
...@@ -135,7 +136,7 @@ describe('noteActions', () => { ...@@ -135,7 +136,7 @@ describe('noteActions', () => {
.then(() => { .then(() => {
const emitted = Object.keys(rootWrapper.emitted()); const emitted = Object.keys(rootWrapper.emitted());
expect(emitted).toEqual(['bv::hide::tooltip']); expect(emitted).toEqual([BV_HIDE_TOOLTIP]);
done(); done();
}) })
.catch(done.fail); .catch(done.fail);
......
...@@ -4,6 +4,7 @@ import LinkedPipelineComponent from '~/pipelines/components/graph/linked_pipelin ...@@ -4,6 +4,7 @@ import LinkedPipelineComponent from '~/pipelines/components/graph/linked_pipelin
import CiStatus from '~/vue_shared/components/ci_icon.vue'; import CiStatus from '~/vue_shared/components/ci_icon.vue';
import { UPSTREAM, DOWNSTREAM } from '~/pipelines/components/graph/constants'; import { UPSTREAM, DOWNSTREAM } from '~/pipelines/components/graph/constants';
import mockData from './linked_pipelines_mock_data'; import mockData from './linked_pipelines_mock_data';
import { BV_HIDE_TOOLTIP } from '~/lib/utils/constants';
const mockPipeline = mockData.triggered[0]; const mockPipeline = mockData.triggered[0];
const validTriggeredPipelineId = mockPipeline.project.id; const validTriggeredPipelineId = mockPipeline.project.id;
...@@ -212,11 +213,11 @@ describe('Linked pipeline', () => { ...@@ -212,11 +213,11 @@ describe('Linked pipeline', () => {
expect(wrapper.emitted().pipelineClicked).toBeTruthy(); expect(wrapper.emitted().pipelineClicked).toBeTruthy();
}); });
it('should emit `bv::hide::tooltip` to close the tooltip', () => { it(`should emit ${BV_HIDE_TOOLTIP} to close the tooltip`, () => {
jest.spyOn(wrapper.vm.$root, '$emit'); jest.spyOn(wrapper.vm.$root, '$emit');
findButton().trigger('click'); findButton().trigger('click');
expect(wrapper.vm.$root.$emit.mock.calls[0]).toEqual(['bv::hide::tooltip']); expect(wrapper.vm.$root.$emit.mock.calls[0]).toEqual([BV_HIDE_TOOLTIP]);
}); });
it('should emit downstreamHovered with job name on mouseover', () => { it('should emit downstreamHovered with job name on mouseover', () => {
......
import { shallowMount, createWrapper } from '@vue/test-utils'; import { shallowMount, createWrapper } from '@vue/test-utils';
import ModalCopyButton from '~/vue_shared/components/modal_copy_button.vue'; import ModalCopyButton from '~/vue_shared/components/modal_copy_button.vue';
import { BV_HIDE_TOOLTIP } from '~/lib/utils/constants';
describe('modal copy button', () => { describe('modal copy button', () => {
let wrapper; let wrapper;
...@@ -31,7 +32,7 @@ describe('modal copy button', () => { ...@@ -31,7 +32,7 @@ describe('modal copy button', () => {
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted().success).not.toBeEmpty(); expect(wrapper.emitted().success).not.toBeEmpty();
expect(document.execCommand).toHaveBeenCalledWith('copy'); expect(document.execCommand).toHaveBeenCalledWith('copy');
expect(root.emitted('bv::hide::tooltip')).toEqual([['test-id']]); expect(root.emitted(BV_HIDE_TOOLTIP)).toEqual([['test-id']]);
}); });
}); });
it("should propagate the clipboard error event if execCommand doesn't work", () => { it("should propagate the clipboard error event if execCommand doesn't work", () => {
......
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