Commit da9a0533 authored by Thong Kuah's avatar Thong Kuah

Merge branch 'pb-add-merge-train-label' into 'master'

Add merge train badge to pipelines

See merge request gitlab-org/gitlab!52137
parents 6bc4dbcb cbab03af
......@@ -76,6 +76,15 @@ export default {
data-testid="pipeline-url-latest"
>{{ __('latest') }}</gl-badge
>
<gl-badge
v-if="pipeline.flags.merge_train_pipeline"
v-gl-tooltip
:title="__('This is a merge train pipeline')"
variant="info"
size="sm"
data-testid="pipeline-url-train"
>{{ __('train') }}</gl-badge
>
<gl-badge
v-if="pipeline.flags.yaml_errors"
v-gl-tooltip
......
......@@ -120,3 +120,5 @@ class Ci::PipelineEntity < Grape::Entity
end
end
end
Ci::PipelineEntity.prepend_if_ee('EE::Ci::PipelineEntity')
......@@ -28,6 +28,9 @@
- if @pipeline.latest?
%span.js-pipeline-url-latest.badge.badge-pill.gl-badge.sm.badge-success.has-tooltip{ title: _("Latest pipeline for the most recent commit on this branch") }
latest
- if @pipeline.merge_train_pipeline?
%span.js-pipeline-url-train.badge.badge-pill.gl-badge.sm.badge-info.has-tooltip{ title: _("This is a merge train pipeline") }
train
- if @pipeline.has_yaml_errors?
%span.js-pipeline-url-yaml.badge.badge-pill.gl-badge.sm.badge-danger.has-tooltip{ title: @pipeline.yaml_errors }
yaml invalid
......
# frozen_string_literal: true
module EE
module Ci
module PipelineEntity
extend ActiveSupport::Concern
prepended do
expose :flags do
expose :merge_train_pipeline?, as: :merge_train_pipeline
end
end
end
end
end
---
title: Display train badge for pipelines that are merge trains
merge_request: 52137
author:
type: added
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::PipelineEntity do
let(:user) { build_stubbed(:user) }
let(:pipeline) { build_stubbed(:ci_empty_pipeline) }
let(:request) { double('request', current_user: user) }
let(:entity) { described_class.represent(pipeline, request: request) }
describe '#as_json' do
subject { entity.as_json }
it 'contains flags' do
expect(subject).to include :flags
expect(subject[:flags]).to include :merge_train_pipeline
end
end
end
......@@ -29051,6 +29051,9 @@ msgstr ""
msgid "This is a list of devices that have logged into your account. Revoke any sessions that you do not recognize."
msgstr ""
msgid "This is a merge train pipeline"
msgstr ""
msgid "This is a security log of important events involving your account."
msgstr ""
......@@ -34579,6 +34582,9 @@ msgstr ""
msgid "toggle collapse"
msgstr ""
msgid "train"
msgstr ""
msgid "triggered"
msgstr ""
......
......@@ -17,6 +17,7 @@ describe('Pipeline Url Component', () => {
const findStuckTag = () => wrapper.find('[data-testid="pipeline-url-stuck"]');
const findDetachedTag = () => wrapper.find('[data-testid="pipeline-url-detached"]');
const findForkTag = () => wrapper.find('[data-testid="pipeline-url-fork"]');
const findTrainTag = () => wrapper.find('[data-testid="pipeline-url-train"]');
const defaultProps = {
pipeline: {
......@@ -141,6 +142,7 @@ describe('Pipeline Url Component', () => {
expect(findScheduledTag().exists()).toBe(true);
expect(findScheduledTag().text()).toContain('Scheduled');
});
it('should render the fork badge when the pipeline was run in a fork', () => {
createComponent({
pipeline: {
......@@ -152,4 +154,28 @@ describe('Pipeline Url Component', () => {
expect(findForkTag().exists()).toBe(true);
expect(findForkTag().text()).toBe('fork');
});
it('should render the train badge when the pipeline is a merge train pipeline', () => {
createComponent({
pipeline: {
flags: {
merge_train_pipeline: true,
},
},
});
expect(findTrainTag().text()).toContain('train');
});
it('should not render the train badge when the pipeline is not a merge train pipeline', () => {
createComponent({
pipeline: {
flags: {
merge_train_pipeline: false,
},
},
});
expect(findTrainTag().exists()).toBe(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