Skip to content
代码片段 群组 项目
未验证 提交 93f2ac6e 编辑于 作者: Payton Burdette's avatar Payton Burdette 提交者: GitLab
浏览文件

Remove merge_trains_viz flag

Removes the feature flag and introduces
the merge trains viz feature to the product.

Changelog: added
EE: true
上级 789deb30
No related branches found
No related tags found
无相关合并请求
显示
50 个添加144 个删除
...@@ -145,7 +145,7 @@ To add a merge request to a merge train: ...@@ -145,7 +145,7 @@ To add a merge request to a merge train:
- When a pipeline is running, [**Set to auto-merge**](../../user/project/merge_requests/auto_merge.md). - When a pipeline is running, [**Set to auto-merge**](../../user/project/merge_requests/auto_merge.md).
The merge request's merge train status displays under the pipeline widget with a The merge request's merge train status displays under the pipeline widget with a
message similar to `Added to the merge train. There are 2 merge requests waiting to be merged.` message similar to `This merge request is 2 of 3 in queue.`
Each merge train can run a maximum of twenty pipelines in parallel. If you add more than Each merge train can run a maximum of twenty pipelines in parallel. If you add more than
twenty merge requests to the merge train, the extra merge requests are queued, waiting twenty merge requests to the merge train, the extra merge requests are queued, waiting
......
...@@ -3,14 +3,12 @@ import { isNumber } from 'lodash'; ...@@ -3,14 +3,12 @@ import { isNumber } from 'lodash';
import { GlLink } from '@gitlab/ui'; import { GlLink } from '@gitlab/ui';
import { s__, sprintf } from '~/locale'; import { s__, sprintf } from '~/locale';
import { STATUS_OPEN } from '~/issues/constants'; import { STATUS_OPEN } from '~/issues/constants';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
export default { export default {
name: 'MergeTrainPositionIndicator', name: 'MergeTrainPositionIndicator',
components: { components: {
GlLink, GlLink,
}, },
mixins: [glFeatureFlagsMixin()],
props: { props: {
mergeRequestState: { mergeRequestState: {
type: String, type: String,
...@@ -34,9 +32,6 @@ export default { ...@@ -34,9 +32,6 @@ export default {
}, },
}, },
computed: { computed: {
mergeTrainsVizEnabled() {
return this.glFeatures.mergeTrainsViz;
},
isMergeRequestOpen() { isMergeRequestOpen() {
return this.mergeRequestState === STATUS_OPEN; return this.mergeRequestState === STATUS_OPEN;
}, },
...@@ -47,23 +42,12 @@ export default { ...@@ -47,23 +42,12 @@ export default {
); );
} }
if (this.mergeTrainsVizEnabled) { if (isNumber(this.mergeTrainIndex) && isNumber(this.mergeTrainsCount)) {
if (isNumber(this.mergeTrainIndex) && isNumber(this.mergeTrainsCount)) {
return sprintf(
s__('mrWidget|This merge request is #%{mergeTrainPosition} of %{total} in queue.'),
{
mergeTrainPosition: this.mergeTrainIndex + 1,
total: this.mergeTrainsCount,
},
);
}
} else if (isNumber(this.mergeTrainIndex)) {
return sprintf( return sprintf(
s__( s__('mrWidget|This merge request is #%{mergeTrainPosition} of %{total} in queue.'),
'mrWidget|Added to the merge train. There are %{mergeTrainPosition} merge requests waiting to be merged',
),
{ {
mergeTrainPosition: this.mergeTrainIndex + 1, mergeTrainPosition: this.mergeTrainIndex + 1,
total: this.mergeTrainsCount,
}, },
); );
} }
...@@ -92,7 +76,7 @@ export default { ...@@ -92,7 +76,7 @@ export default {
<div v-if="message" class="pt-2 pb-2 pl-3 plr-3 merge-train-position-indicator"> <div v-if="message" class="pt-2 pb-2 pl-3 plr-3 merge-train-position-indicator">
<div class="media-body gl-text-secondary"> <div class="media-body gl-text-secondary">
{{ message }} {{ message }}
<gl-link v-if="mergeTrainsVizEnabled && mergeTrainsPath" :href="mergeTrainsPath"> <gl-link v-if="mergeTrainsPath" :href="mergeTrainsPath">
{{ s__('mrWidget|View merge train details.') }} {{ s__('mrWidget|View merge train details.') }}
</gl-link> </gl-link>
</div> </div>
......
...@@ -11,7 +11,6 @@ module MergeRequestsController ...@@ -11,7 +11,6 @@ module MergeRequestsController
before_action only: [:show] do before_action only: [:show] do
push_frontend_feature_flag(:merge_trains_skip_train, @project) push_frontend_feature_flag(:merge_trains_skip_train, @project)
push_frontend_feature_flag(:merge_trains_viz, @project)
end end
before_action :authorize_read_pipeline!, only: [:metrics_reports] before_action :authorize_read_pipeline!, only: [:metrics_reports]
......
...@@ -3,16 +3,19 @@ ...@@ -3,16 +3,19 @@
module Projects module Projects
class MergeTrainsController < Projects::ApplicationController class MergeTrainsController < Projects::ApplicationController
feature_category :merge_trains feature_category :merge_trains
before_action :authorize_read_merge_train! before_action :authorize_read_merge_train!
before_action :check_enabled! before_action :authorize!
def index; end def index; end
private private
def check_enabled! def authorize!
render_404 unless Feature.enabled?(:merge_trains_viz, project) render_404 unless current_user && merge_trains_available?
end
def merge_trains_available?
project.licensed_feature_available?(:merge_trains)
end end
end end
end end
...@@ -29,7 +29,7 @@ def resolve(car_id:) ...@@ -29,7 +29,7 @@ def resolve(car_id:)
private private
def ensure_feature_available! def ensure_feature_available!
return if Feature.enabled?(:merge_trains_viz, project) && merge_trains_available? return if merge_trains_available?
raise_resource_not_available_error! raise_resource_not_available_error!
end end
......
...@@ -31,7 +31,7 @@ def resolve(status: nil, target_branches: []) ...@@ -31,7 +31,7 @@ def resolve(status: nil, target_branches: [])
private private
def ensure_feature_available def ensure_feature_available
(Feature.enabled?(:merge_trains_viz, project) && merge_trains_available?) || raise_resource_not_available_error! merge_trains_available? || raise_resource_not_available_error!
end end
def merge_trains_available? def merge_trains_available?
......
---
name: merge_trains_viz
feature_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/454179
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/149025
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/455342
milestone: '16.11'
group: group::pipeline execution
type: wip
default_enabled: false
...@@ -10,17 +10,12 @@ describe('MergeTrainPositionIndicator', () => { ...@@ -10,17 +10,12 @@ describe('MergeTrainPositionIndicator', () => {
const findLink = () => wrapper.findComponent(GlLink); const findLink = () => wrapper.findComponent(GlLink);
const createComponent = (props, mergeTrainsViz = false) => { const createComponent = (props) => {
wrapper = shallowMount(MergeTrainPositionIndicator, { wrapper = shallowMount(MergeTrainPositionIndicator, {
propsData: { propsData: {
mergeTrainsPath: 'namespace/project/-/merge_trains', mergeTrainsPath: 'namespace/project/-/merge_trains',
...props, ...props,
}, },
provide: {
glFeatures: {
mergeTrainsViz,
},
},
mocks: { mocks: {
$toast: { $toast: {
show: mockToast, show: mockToast,
...@@ -29,74 +24,37 @@ describe('MergeTrainPositionIndicator', () => { ...@@ -29,74 +24,37 @@ describe('MergeTrainPositionIndicator', () => {
}); });
}; };
describe('with mergeTrainsViz enabled', () => { it('should show message when position is higher than 1', () => {
it('should show message when position is higher than 1', () => { createComponent({
createComponent( mergeTrainIndex: 3,
{ mergeTrainsCount: 5,
mergeTrainIndex: 3,
mergeTrainsCount: 5,
},
true,
);
expect(trimText(wrapper.text())).toBe(
'This merge request is #4 of 5 in queue. View merge train details.',
);
expect(findLink().attributes('href')).toBe('namespace/project/-/merge_trains');
}); });
it('should show message when the position is 1', () => { expect(trimText(wrapper.text())).toBe(
createComponent({ mergeTrainIndex: 0, mergeTrainsCount: 0 }, true); 'This merge request is #4 of 5 in queue. View merge train details.',
);
expect(trimText(wrapper.text())).toBe( expect(findLink().attributes('href')).toBe('namespace/project/-/merge_trains');
'A new merge train has started and this merge request is the first of the queue. View merge train details.',
);
expect(findLink().attributes('href')).toBe('namespace/project/-/merge_trains');
});
it('should not render when merge request is not in train', () => {
createComponent(
{
mergeTrainIndex: null,
mergeTrainsCount: 1,
},
true,
);
expect(wrapper.text()).toBe('');
});
}); });
describe('with mergeTrainsViz disabled', () => { it('should show message when the position is 1', () => {
it('should show message when position is higher than 1', () => { createComponent({ mergeTrainIndex: 0, mergeTrainsCount: 0 }, true);
createComponent({ mergeTrainIndex: 3 });
expect(trimText(wrapper.text())).toBe(
'Added to the merge train. There are 4 merge requests waiting to be merged',
);
expect(findLink().exists()).toBe(false);
});
it('should show message when the position is 1', () => { expect(trimText(wrapper.text())).toBe(
createComponent({ mergeTrainIndex: 0 }); 'A new merge train has started and this merge request is the first of the queue. View merge train details.',
);
expect(trimText(wrapper.text())).toBe( expect(findLink().attributes('href')).toBe('namespace/project/-/merge_trains');
'A new merge train has started and this merge request is the first of the queue.', });
);
expect(findLink().exists()).toBe(false);
});
it('should not render when merge request is not in train', () => { it('should not render when merge request is not in train', () => {
createComponent( createComponent(
{ {
mergeTrainIndex: null, mergeTrainIndex: null,
mergeTrainsCount: 1, mergeTrainsCount: 1,
}, },
true, true,
); );
expect(wrapper.text()).toBe(''); expect(wrapper.text()).toBe('');
});
}); });
describe('when position in the train changes', () => { describe('when position in the train changes', () => {
......
...@@ -130,20 +130,6 @@ ...@@ -130,20 +130,6 @@
end end
context 'when the user has the right permissions' do context 'when the user has the right permissions' do
context 'when the feature is disabled' do
before do
stub_feature_flags(merge_trains_viz: false)
end
it 'returns a resource not available error' do
post_query
expect_graphql_errors_to_include(
"The resource that you are attempting to access does not exist " \
"or you don't have permission to perform this action"
)
end
end
context 'when only the project is provided' do context 'when only the project is provided' do
it_behaves_like 'fetches the requested trains' do it_behaves_like 'fetches the requested trains' do
let(:expected_branches) { %w[master feature-1] } let(:expected_branches) { %w[master feature-1] }
......
...@@ -90,20 +90,6 @@ ...@@ -90,20 +90,6 @@
end end
end end
context 'when the feature is disabled' do
before do
stub_feature_flags(merge_trains_viz: false)
post_mutation
end
it 'returns a resource not available error' do
expect_graphql_errors_to_include(
"The resource that you are attempting to access does not exist " \
"or you don't have permission to perform this action"
)
end
end
context 'when the car does not exist' do context 'when the car does not exist' do
let(:target_car_id) { build(:merge_train_car, id: non_existing_record_iid).to_gid } let(:target_car_id) { build(:merge_train_car, id: non_existing_record_iid).to_gid }
......
...@@ -13,27 +13,29 @@ ...@@ -13,27 +13,29 @@
project.add_maintainer(user) project.add_maintainer(user)
end end
before do context 'when feature is enabled' do
sign_in(user) before do
end stub_licensed_features(merge_trains: true)
sign_in(user)
context 'when feature flag "merge_trains_viz" is enabled' do
it 'renders the merge trains index template' do
request request
end
it 'renders the merge trains index template' do
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template('projects/merge_trains/index') expect(response).to render_template('projects/merge_trains/index')
end end
end end
context 'when feature flag "merge_trains_viz" is disabled' do context 'when feature is disabled' do
before do before do
stub_feature_flags(merge_trains_viz: false) stub_licensed_features(merge_trains: false)
end sign_in(user)
it 'returns "not found response"' do
request request
end
it 'returns "not found response"' do
expect(response).to have_gitlab_http_status(:not_found) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
......
...@@ -63541,9 +63541,6 @@ msgstr "" ...@@ -63541,9 +63541,6 @@ msgstr ""
msgid "mrWidget|Added to the merge train by %{merge_author}" msgid "mrWidget|Added to the merge train by %{merge_author}"
msgstr "" msgstr ""
   
msgid "mrWidget|Added to the merge train. There are %{mergeTrainPosition} merge requests waiting to be merged"
msgstr ""
msgid "mrWidget|An error occurred while removing your approval." msgid "mrWidget|An error occurred while removing your approval."
msgstr "" msgstr ""
   
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册