Commit 89bf6d66 authored by Phil Hughes's avatar Phil Hughes

Merge branch '219455-fe-inapplicable-tooltip-message' into 'master'

Add inapplicable reason in MR suggestion Tooltip

Closes #219455

See merge request gitlab-org/gitlab!35276
parents 5bca4b28 50dd9cb8
......@@ -68,6 +68,7 @@ export default {
:is-applying-batch="suggestion.is_applying_batch"
:batch-suggestions-count="batchSuggestionsCount"
:help-page-path="helpPagePath"
:inapplicable-reason="suggestion.inapplicable_reason"
@apply="applySuggestion"
@applyBatch="applySuggestionBatch"
@addToBatch="addSuggestionToBatch"
......
......@@ -38,6 +38,11 @@ export default {
type: String,
required: true,
},
inapplicableReason: {
type: String,
required: false,
default: null,
},
},
data() {
return {
......@@ -52,9 +57,7 @@ export default {
return this.isApplyingSingle || this.isApplyingBatch;
},
tooltipMessage() {
return this.canApply
? __('This also resolves this thread')
: __("Can't apply as this line has changed or the suggestion already matches its content.");
return this.canApply ? __('This also resolves this thread') : this.inapplicableReason;
},
isDisableButton() {
return this.isApplying || !this.canApply;
......
---
title: Add inapplicable reason in MR suggestion Tooltip
merge_request: 35276
author:
type: changed
......@@ -4060,9 +4060,6 @@ msgstr ""
msgid "Can't apply as the source branch was deleted."
msgstr ""
msgid "Can't apply as this line has changed or the suggestion already matches its content."
msgstr ""
msgid "Can't apply this suggestion."
msgstr ""
......
......@@ -69,11 +69,6 @@ describe('Suggestion Diff component', () => {
expect(addToBatchBtn.html().includes('Add suggestion to batch')).toBe(true);
});
it('renders correct tooltip message for apply button', () => {
createComponent();
expect(wrapper.vm.tooltipMessage).toBe('This also resolves this thread');
});
describe('when apply suggestion is clicked', () => {
beforeEach(() => {
createComponent();
......@@ -232,11 +227,18 @@ describe('Suggestion Diff component', () => {
expect(findAddToBatchButton().exists()).toBe(false);
expect(findApplyButton().attributes('disabled')).toBe('true');
});
});
describe('tooltip message for apply button', () => {
it('renders correct tooltip message when button is applicable', () => {
createComponent();
expect(wrapper.vm.tooltipMessage).toBe('This also resolves this thread');
});
it('renders correct tooltip message for apply button', () => {
expect(wrapper.vm.tooltipMessage).toBe(
"Can't apply as this line has changed or the suggestion already matches its content.",
);
it('renders the inapplicable reason in the tooltip when button is not applicable', () => {
const inapplicableReason = 'lorem';
createComponent({ canApply: false, inapplicableReason });
expect(wrapper.vm.tooltipMessage).toBe(inapplicableReason);
});
});
});
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