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