Commit d72d6cb3 authored by André Luís's avatar André Luís Committed by Paul Slaughter

Put Batched Suggestions behind a Feature Flag default to false

https://gitlab.com/gitlab-org/gitlab/-/merge_requests/34782
parent ce62970d
...@@ -2,10 +2,12 @@ ...@@ -2,10 +2,12 @@
import { GlDeprecatedButton, GlLoadingIcon, GlTooltipDirective } from '@gitlab/ui'; import { GlDeprecatedButton, GlLoadingIcon, GlTooltipDirective } from '@gitlab/ui';
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
import { __ } from '~/locale'; import { __ } from '~/locale';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
export default { export default {
components: { Icon, GlDeprecatedButton, GlLoadingIcon }, components: { Icon, GlDeprecatedButton, GlLoadingIcon },
directives: { 'gl-tooltip': GlTooltipDirective }, directives: { 'gl-tooltip': GlTooltipDirective },
mixins: [glFeatureFlagsMixin()],
props: { props: {
batchSuggestionsCount: { batchSuggestionsCount: {
type: Number, type: Number,
...@@ -43,6 +45,9 @@ export default { ...@@ -43,6 +45,9 @@ export default {
}; };
}, },
computed: { computed: {
canBeBatched() {
return Boolean(this.glFeatures.batchSuggestions);
},
isApplying() { isApplying() {
return this.isApplyingSingle || this.isApplyingBatch; return this.isApplyingSingle || this.isApplyingBatch;
}, },
...@@ -51,6 +56,11 @@ export default { ...@@ -51,6 +56,11 @@ export default {
? __('This also resolves the discussion') ? __('This also resolves the discussion')
: __("Can't apply as this line has changed or the suggestion already matches its content."); : __("Can't apply as this line has changed or the suggestion already matches its content.");
}, },
tooltipMessageBatch() {
return !this.canBeBatched
? __("Suggestions that change line count can't be added to batches, yet.")
: this.tooltipMessage;
},
isDisableButton() { isDisableButton() {
return this.isApplying || !this.canApply; return this.isApplying || !this.canApply;
}, },
...@@ -97,7 +107,7 @@ export default { ...@@ -97,7 +107,7 @@ export default {
<gl-loading-icon class="d-flex-center mr-2" /> <gl-loading-icon class="d-flex-center mr-2" />
<span>{{ applyingSuggestionsMessage }}</span> <span>{{ applyingSuggestionsMessage }}</span>
</div> </div>
<div v-else-if="canApply && isBatched" class="d-flex align-items-center"> <div v-else-if="canApply && canBeBatched && isBatched" class="d-flex align-items-center">
<gl-deprecated-button <gl-deprecated-button
class="btn-inverted js-remove-from-batch-btn btn-grouped" class="btn-inverted js-remove-from-batch-btn btn-grouped"
:disabled="isApplying" :disabled="isApplying"
...@@ -119,13 +129,15 @@ export default { ...@@ -119,13 +129,15 @@ export default {
</gl-deprecated-button> </gl-deprecated-button>
</div> </div>
<div v-else class="d-flex align-items-center"> <div v-else class="d-flex align-items-center">
<gl-deprecated-button <span v-if="canBeBatched" v-gl-tooltip.viewport="tooltipMessageBatch" tabindex="0">
class="btn-inverted js-add-to-batch-btn btn-grouped" <gl-deprecated-button
:disabled="isDisableButton" class="btn-inverted js-add-to-batch-btn btn-grouped"
@click="addSuggestionToBatch" :disabled="isDisableButton"
> @click="addSuggestionToBatch"
{{ __('Add suggestion to batch') }} >
</gl-deprecated-button> {{ __('Add suggestion to batch') }}
</gl-deprecated-button>
</span>
<span v-gl-tooltip.viewport="tooltipMessage" tabindex="0"> <span v-gl-tooltip.viewport="tooltipMessage" tabindex="0">
<gl-deprecated-button <gl-deprecated-button
class="btn-inverted js-apply-btn btn-grouped" class="btn-inverted js-apply-btn btn-grouped"
......
...@@ -35,6 +35,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo ...@@ -35,6 +35,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
push_frontend_feature_flag(:mr_commit_neighbor_nav, @project, default_enabled: true) push_frontend_feature_flag(:mr_commit_neighbor_nav, @project, default_enabled: true)
push_frontend_feature_flag(:multiline_comments, @project) push_frontend_feature_flag(:multiline_comments, @project)
push_frontend_feature_flag(:file_identifier_hash) push_frontend_feature_flag(:file_identifier_hash)
push_frontend_feature_flag(:batch_suggestions, @project)
end end
before_action do before_action do
......
...@@ -21877,6 +21877,9 @@ msgstr "" ...@@ -21877,6 +21877,9 @@ msgstr ""
msgid "Suggestions must all be on the same branch." msgid "Suggestions must all be on the same branch."
msgstr "" msgstr ""
msgid "Suggestions that change line count can't be added to batches, yet."
msgstr ""
msgid "Suggestions:" msgid "Suggestions:"
msgstr "" msgstr ""
......
...@@ -14,12 +14,18 @@ const DEFAULT_PROPS = { ...@@ -14,12 +14,18 @@ const DEFAULT_PROPS = {
describe('Suggestion Diff component', () => { describe('Suggestion Diff component', () => {
let wrapper; let wrapper;
const createComponent = props => { const createComponent = (props, glFeatures = {}) => {
wrapper = shallowMount(SuggestionDiffHeader, { wrapper = shallowMount(SuggestionDiffHeader, {
propsData: { propsData: {
...DEFAULT_PROPS, ...DEFAULT_PROPS,
...props, ...props,
}, },
provide: {
glFeatures: {
batchSuggestions: true,
...glFeatures,
},
},
}); });
}; };
...@@ -204,6 +210,18 @@ describe('Suggestion Diff component', () => { ...@@ -204,6 +210,18 @@ describe('Suggestion Diff component', () => {
}); });
}); });
describe('batchSuggestions feature flag is set to false', () => {
beforeEach(() => {
createComponent({}, { batchSuggestions: false });
});
it('disables add to batch buttons but keeps apply suggestion enabled', () => {
expect(findApplyButton().exists()).toBe(true);
expect(findAddToBatchButton().exists()).toBe(false);
expect(findApplyButton().attributes('disabled')).not.toBe('true');
});
});
describe('canApply is set to false', () => { describe('canApply is set to false', () => {
beforeEach(() => { beforeEach(() => {
createComponent({ canApply: false }); createComponent({ canApply: false });
......
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