Commit 2691bf0a authored by Phil Hughes's avatar Phil Hughes

Merge branch...

Merge branch '229005-replace-vue_shared-tooltip-with-gitlab-ui-s-tooltip-in-app-assets-javascripts' into 'master'

Migrate MR widget squash tooltips to GitLab UI

See merge request gitlab-org/gitlab!43536
parents e275fdd0 2bfac09d
<script> <script>
import { GlIcon } from '@gitlab/ui'; import { GlIcon, GlTooltipDirective } from '@gitlab/ui';
import tooltip from '~/vue_shared/directives/tooltip'; import { SQUASH_BEFORE_MERGE } from '../../i18n';
import { __ } from '~/locale';
export default { export default {
components: { components: {
GlIcon, GlIcon,
}, },
directives: { directives: {
tooltip, GlTooltip: GlTooltipDirective,
},
i18n: {
...SQUASH_BEFORE_MERGE,
}, },
props: { props: {
value: { value: {
...@@ -28,7 +30,10 @@ export default { ...@@ -28,7 +30,10 @@ export default {
}, },
computed: { computed: {
tooltipTitle() { tooltipTitle() {
return this.isDisabled ? __('Required in this project.') : false; return this.isDisabled ? this.$options.i18n.tooltipTitle : null;
},
tooltipFocusable() {
return this.isDisabled ? '0' : null;
}, },
}, },
}; };
...@@ -37,10 +42,11 @@ export default { ...@@ -37,10 +42,11 @@ export default {
<template> <template>
<div class="inline"> <div class="inline">
<label <label
v-tooltip v-gl-tooltip
:class="{ 'gl-text-gray-400': isDisabled }" :class="{ 'gl-text-gray-400': isDisabled }"
:tabindex="tooltipFocusable"
data-testid="squashLabel" data-testid="squashLabel"
:data-title="tooltipTitle" :title="tooltipTitle"
> >
<input <input
:checked="value" :checked="value"
...@@ -50,19 +56,20 @@ export default { ...@@ -50,19 +56,20 @@ export default {
class="qa-squash-checkbox js-squash-checkbox" class="qa-squash-checkbox js-squash-checkbox"
@change="$emit('input', $event.target.checked)" @change="$emit('input', $event.target.checked)"
/> />
{{ __('Squash commits') }} {{ $options.i18n.checkboxLabel }}
</label> </label>
<a <a
v-if="helpPath" v-if="helpPath"
v-tooltip v-gl-tooltip
:href="helpPath" :href="helpPath"
data-title="About this feature" :title="$options.i18n.helpLabel"
data-placement="bottom"
target="_blank" target="_blank"
rel="noopener noreferrer nofollow" rel="noopener noreferrer nofollow"
data-container="body"
> >
<gl-icon name="question" /> <gl-icon name="question" />
<span class="sr-only">
{{ $options.i18n.helpLabel }}
</span>
</a> </a>
</div> </div>
</template> </template>
import { __ } from '~/locale';
export const SQUASH_BEFORE_MERGE = {
tooltipTitle: __('Required in this project.'),
checkboxLabel: __('Squash commits'),
helpLabel: __('What is squashing?'),
};
...@@ -29096,6 +29096,9 @@ msgstr "" ...@@ -29096,6 +29096,9 @@ msgstr ""
msgid "What describes you best?" msgid "What describes you best?"
msgstr "" msgstr ""
msgid "What is squashing?"
msgstr ""
msgid "What's new at GitLab" msgid "What's new at GitLab"
msgstr "" msgstr ""
......
import { createLocalVue, shallowMount } from '@vue/test-utils'; import { createLocalVue, shallowMount } from '@vue/test-utils';
import SquashBeforeMerge from '~/vue_merge_request_widget/components/states/squash_before_merge.vue'; import SquashBeforeMerge from '~/vue_merge_request_widget/components/states/squash_before_merge.vue';
import { SQUASH_BEFORE_MERGE } from '~/vue_merge_request_widget/i18n';
const localVue = createLocalVue(); const localVue = createLocalVue();
...@@ -85,7 +86,7 @@ describe('Squash before merge component', () => { ...@@ -85,7 +86,7 @@ describe('Squash before merge component', () => {
}); });
describe('tooltip', () => { describe('tooltip', () => {
const tooltipTitle = () => findLabel().element.dataset.title; const tooltipTitle = () => findLabel().attributes('title');
it('does not render when isDisabled is false', () => { it('does not render when isDisabled is false', () => {
createComponent({ createComponent({
...@@ -101,7 +102,7 @@ describe('Squash before merge component', () => { ...@@ -101,7 +102,7 @@ describe('Squash before merge component', () => {
isDisabled: true, isDisabled: true,
}); });
expect(tooltipTitle()).toBe('Required in this project.'); expect(tooltipTitle()).toBe(SQUASH_BEFORE_MERGE.tooltipTitle);
}); });
}); });
......
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