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 @@
import { GlDeprecatedButton, GlLoadingIcon, GlTooltipDirective } from '@gitlab/ui';
import Icon from '~/vue_shared/components/icon.vue';
import { __ } from '~/locale';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
export default {
components: { Icon, GlDeprecatedButton, GlLoadingIcon },
directives: { 'gl-tooltip': GlTooltipDirective },
mixins: [glFeatureFlagsMixin()],
props: {
batchSuggestionsCount: {
type: Number,
......@@ -43,6 +45,9 @@ export default {
};
},
computed: {
canBeBatched() {
return Boolean(this.glFeatures.batchSuggestions);
},
isApplying() {
return this.isApplyingSingle || this.isApplyingBatch;
},
......@@ -51,6 +56,11 @@ export default {
? __('This also resolves the discussion')
: __("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() {
return this.isApplying || !this.canApply;
},
......@@ -97,7 +107,7 @@ export default {
<gl-loading-icon class="d-flex-center mr-2" />
<span>{{ applyingSuggestionsMessage }}</span>
</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
class="btn-inverted js-remove-from-batch-btn btn-grouped"
:disabled="isApplying"
......@@ -119,13 +129,15 @@ export default {
</gl-deprecated-button>
</div>
<div v-else class="d-flex align-items-center">
<gl-deprecated-button
class="btn-inverted js-add-to-batch-btn btn-grouped"
:disabled="isDisableButton"
@click="addSuggestionToBatch"
>
{{ __('Add suggestion to batch') }}
</gl-deprecated-button>
<span v-if="canBeBatched" v-gl-tooltip.viewport="tooltipMessageBatch" tabindex="0">
<gl-deprecated-button
class="btn-inverted js-add-to-batch-btn btn-grouped"
:disabled="isDisableButton"
@click="addSuggestionToBatch"
>
{{ __('Add suggestion to batch') }}
</gl-deprecated-button>
</span>
<span v-gl-tooltip.viewport="tooltipMessage" tabindex="0">
<gl-deprecated-button
class="btn-inverted js-apply-btn btn-grouped"
......
......@@ -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(:multiline_comments, @project)
push_frontend_feature_flag(:file_identifier_hash)
push_frontend_feature_flag(:batch_suggestions, @project)
end
before_action do
......
......@@ -21877,6 +21877,9 @@ msgstr ""
msgid "Suggestions must all be on the same branch."
msgstr ""
msgid "Suggestions that change line count can't be added to batches, yet."
msgstr ""
msgid "Suggestions:"
msgstr ""
......
......@@ -14,12 +14,18 @@ const DEFAULT_PROPS = {
describe('Suggestion Diff component', () => {
let wrapper;
const createComponent = props => {
const createComponent = (props, glFeatures = {}) => {
wrapper = shallowMount(SuggestionDiffHeader, {
propsData: {
...DEFAULT_PROPS,
...props,
},
provide: {
glFeatures: {
batchSuggestions: true,
...glFeatures,
},
},
});
};
......@@ -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', () => {
beforeEach(() => {
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