Commit 0c04320b authored by Andrew Fontaine's avatar Andrew Fontaine

Merge branch '223029-squash-commit-tooltip-mr-widget' into 'master'

Add tooltip to MR widget for  "Squash commits" option when at disabled state

Closes #223029

See merge request gitlab-org/gitlab!35081
parents 19d30f82 dd7d8c50
<script> <script>
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
import tooltip from '~/vue_shared/directives/tooltip'; import tooltip from '~/vue_shared/directives/tooltip';
import { __ } from '~/locale';
export default { export default {
components: { components: {
...@@ -25,12 +26,22 @@ export default { ...@@ -25,12 +26,22 @@ export default {
default: false, default: false,
}, },
}, },
computed: {
tooltipTitle() {
return this.isDisabled ? __('Required in this project.') : false;
},
},
}; };
</script> </script>
<template> <template>
<div class="inline"> <div class="inline">
<label :class="{ 'gl-text-gray-600': isDisabled }" data-testid="squashLabel"> <label
v-tooltip
:class="{ 'gl-text-gray-600': isDisabled }"
data-testid="squashLabel"
:data-title="tooltipTitle"
>
<input <input
:checked="value" :checked="value"
:disabled="isDisabled" :disabled="isDisabled"
......
...@@ -19531,6 +19531,9 @@ msgstr "" ...@@ -19531,6 +19531,9 @@ msgstr ""
msgid "Required approvals (%{approvals_given} given, you've approved)" msgid "Required approvals (%{approvals_given} given, you've approved)"
msgstr "" msgstr ""
msgid "Required in this project."
msgstr ""
msgid "Requirement" msgid "Requirement"
msgstr "" msgstr ""
......
...@@ -19,6 +19,8 @@ describe('Squash before merge component', () => { ...@@ -19,6 +19,8 @@ describe('Squash before merge component', () => {
wrapper.destroy(); wrapper.destroy();
}); });
const findLabel = () => wrapper.find('[data-testid="squashLabel"]');
describe('checkbox', () => { describe('checkbox', () => {
const findCheckbox = () => wrapper.find('.js-squash-checkbox'); const findCheckbox = () => wrapper.find('.js-squash-checkbox');
...@@ -64,8 +66,6 @@ describe('Squash before merge component', () => { ...@@ -64,8 +66,6 @@ describe('Squash before merge component', () => {
}); });
describe('label', () => { describe('label', () => {
const findLabel = () => wrapper.find('[data-testid="squashLabel"]');
describe.each` describe.each`
isDisabled | expectation isDisabled | expectation
${true} | ${'grays out text if it is true'} ${true} | ${'grays out text if it is true'}
...@@ -84,6 +84,27 @@ describe('Squash before merge component', () => { ...@@ -84,6 +84,27 @@ describe('Squash before merge component', () => {
}); });
}); });
describe('tooltip', () => {
const tooltipTitle = () => findLabel().element.dataset.title;
it('does not render when isDisabled is false', () => {
createComponent({
value: true,
isDisabled: false,
});
expect(tooltipTitle()).toBeUndefined();
});
it('display message when when isDisabled is true', () => {
createComponent({
value: true,
isDisabled: true,
});
expect(tooltipTitle()).toBe('Required in this project.');
});
});
describe('about link', () => { describe('about link', () => {
it('is not rendered if no help path is passed', () => { it('is not rendered if no help path is passed', () => {
createComponent({ createComponent({
......
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