Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2021-01-15 15:10:31 +00:00
parent 0e11c62b96
commit 39a5262a05
24 changed files with 225 additions and 127 deletions

View File

@ -1,5 +1,5 @@
<script>
import { GlTooltipDirective, GlButton, GlLink, GlLoadingIcon } from '@gitlab/ui';
import { GlTooltipDirective, GlButton, GlLink, GlLoadingIcon, GlBadge } from '@gitlab/ui';
import CiStatus from '~/vue_shared/components/ci_icon.vue';
import { __, sprintf } from '~/locale';
import { accessValue } from './accessors';
@ -15,6 +15,7 @@ export default {
GlButton,
GlLink,
GlLoadingIcon,
GlBadge,
},
inject: {
dataMethod: {
@ -172,7 +173,9 @@ export default {
</div>
</div>
<div class="gl-pt-2">
<span class="badge badge-primary" data-testid="downstream-pipeline-label">{{ label }}</span>
<gl-badge size="sm" variant="info" data-testid="downstream-pipeline-label">
{{ label }}
</gl-badge>
</div>
<gl-button
:id="buttonId"

View File

@ -45,6 +45,7 @@ export default {
...mapState({
modalTitle: (state) => state.modal.title || '',
modalData: (state) => state.modal.data || {},
modalOpen: (state) => state.modal.open || false,
}),
...mapGetters(['summaryStatus']),
groupedSummaryText() {
@ -76,7 +77,7 @@ export default {
this.fetchReports();
},
methods: {
...mapActions(['setEndpoint', 'fetchReports']),
...mapActions(['setEndpoint', 'fetchReports', 'closeModal']),
reportText(report) {
const { name, summary } = report || {};
@ -170,8 +171,12 @@ export default {
class="report-block-group-list"
/>
</template>
<modal :title="modalTitle" :modal-data="modalData" />
<modal
:visible="modalOpen"
:title="modalTitle"
:modal-data="modalData"
@hide="closeModal"
/>
</div>
</template>
</report-section>

View File

@ -1,15 +1,21 @@
<script>
// import { sprintf, __ } from '~/locale';
import DeprecatedModal2 from '~/vue_shared/components/deprecated_modal_2.vue';
import { GlModal, GlLink, GlSprintf } from '@gitlab/ui';
import CodeBlock from '~/vue_shared/components/code_block.vue';
import { fieldTypes } from '../constants';
export default {
components: {
Modal: DeprecatedModal2,
CodeBlock,
GlModal,
GlLink,
GlSprintf,
},
props: {
visible: {
type: Boolean,
required: true,
},
title: {
type: String,
required: true,
@ -23,39 +29,43 @@ export default {
};
</script>
<template>
<modal
id="modal-mrwidget-reports"
:header-title-text="title"
class="modal-security-report-dast modal-hide-footer"
<gl-modal
:visible="visible"
modal-id="modal-mrwidget-reports"
:title="title"
:hide-footer="true"
@hide="$emit('hide')"
>
<slot>
<div
v-for="(field, key, index) in modalData"
v-if="field.value"
:key="index"
class="row gl-mt-3 gl-mb-3"
>
<strong class="col-sm-3 text-right"> {{ field.text }}: </strong>
<div
v-for="(field, key, index) in modalData"
v-if="field.value"
:key="index"
class="row gl-mt-3 gl-mb-3"
>
<strong class="col-sm-3 text-right"> {{ field.text }}: </strong>
<div class="col-sm-9 text-secondary">
<code-block v-if="field.type === $options.fieldTypes.codeBock" :code="field.value" />
<div class="col-sm-9 text-secondary">
<code-block v-if="field.type === $options.fieldTypes.codeBock" :code="field.value" />
<template v-else-if="field.type === $options.fieldTypes.link">
<a :href="field.value" target="_blank" rel="noopener noreferrer" class="js-modal-link">
{{ field.value }}
</a>
</template>
<gl-link
v-else-if="field.type === $options.fieldTypes.link"
:href="field.value"
target="_blank"
>
{{ field.value }}
</gl-link>
<template v-else-if="field.type === $options.fieldTypes.seconds">{{
sprintf(__('%{value} s'), { value: field.value })
}}</template>
<gl-sprintf
v-else-if="field.type === $options.fieldTypes.seconds"
:message="__('%{value} s')"
>
<template #value>{{ field.value }}</template>
</gl-sprintf>
<template v-else-if="field.type === $options.fieldTypes.text">
{{ field.value }}
</template>
</div>
<template v-else-if="field.type === $options.fieldTypes.text">
{{ field.value }}
</template>
</div>
</slot>
<div slot="footer"></div>
</modal>
</div>
</gl-modal>
</template>

View File

@ -1,5 +1,4 @@
import Visibility from 'visibilityjs';
import $ from 'jquery';
import axios from '../../lib/utils/axios_utils';
import Poll from '../../lib/utils/poll';
import * as types from './mutation_types';
@ -78,10 +77,6 @@ export const receiveReportsSuccess = ({ commit }, response) => {
export const receiveReportsError = ({ commit }) => commit(types.RECEIVE_REPORTS_ERROR);
export const openModal = ({ dispatch }, payload) => {
dispatch('setModalData', payload);
export const openModal = ({ commit }, payload) => commit(types.SET_ISSUE_MODAL_DATA, payload);
$('#modal-mrwidget-reports').modal('show');
};
export const setModalData = ({ commit }, payload) => commit(types.SET_ISSUE_MODAL_DATA, payload);
export const closeModal = ({ commit }, payload) => commit(types.RESET_ISSUE_MODAL_DATA, payload);

View File

@ -4,3 +4,4 @@ export const REQUEST_REPORTS = 'REQUEST_REPORTS';
export const RECEIVE_REPORTS_SUCCESS = 'RECEIVE_REPORTS_SUCCESS';
export const RECEIVE_REPORTS_ERROR = 'RECEIVE_REPORTS_ERROR';
export const SET_ISSUE_MODAL_DATA = 'SET_ISSUE_MODAL_DATA';
export const RESET_ISSUE_MODAL_DATA = 'RESET_ISSUE_MODAL_DATA';

View File

@ -52,5 +52,19 @@ export default {
};
}
});
state.modal.open = true;
},
[types.RESET_ISSUE_MODAL_DATA](state) {
state.modal.open = false;
// Resetting modal data
state.modal.title = null;
Object.keys(state.modal.data).forEach((key) => {
state.modal.data[key] = {
...state.modal.data[key],
value: null,
};
});
},
};

View File

@ -38,6 +38,7 @@ export default () => ({
modal: {
title: null,
open: false,
data: {
class: {

View File

@ -51,7 +51,7 @@ module Milestoneable
# Overridden on EE module
#
def supports_milestone?
respond_to?(:milestone_id) && !incident?
respond_to?(:milestone_id)
end
end

View File

@ -14,23 +14,23 @@
%span= _('Runners can be:')
%ul
%li
%span.badge.badge-success shared
%span.badge.badge-pill.gl-badge.sm.badge-success shared
\-
= _('Runs jobs from all unassigned projects.')
%li
%span.badge.badge-success group
%span.badge.badge-pill.gl-badge.sm.badge-success group
\-
= _('Runs jobs from all unassigned projects in its group.')
%li
%span.badge.badge-info specific
%span.badge.badge-pill.gl-badge.sm.badge-info specific
\-
= _('Runs jobs from assigned projects.')
%li
%span.badge.badge-warning locked
%span.badge.badge-pill.gl-badge.sm.badge-warning locked
\-
= _('Cannot be assigned to other projects.')
%li
%span.badge.badge-danger paused
%span.badge.badge-pill.gl-badge.sm.badge-danger paused
\-
= _('Not available to run jobs.')

View File

@ -43,16 +43,16 @@
.label-container
- if job.tags.any?
- job.tags.each do |tag|
%span.badge.badge-primary
%span.badge.badge-pill.gl-badge.sm.badge-primary
= tag
- if job.try(:trigger_request)
%span.badge.badge-info= _('triggered')
%span.badge.badge-pill.gl-badge.sm.badge-info= _('triggered')
- if job.try(:allow_failure) && !job.success?
%span.badge.badge-warning= _('allowed to fail')
%span.badge.badge-pill.gl-badge.sm.badge-warning= _('allowed to fail')
- if job.schedulable?
%span.badge.badge-info= s_('DelayedJobs|delayed')
%span.badge.badge-pill.gl-badge.sm.badge-info= s_('DelayedJobs|delayed')
- elsif job.action?
%span.badge.badge-info= _('manual')
%span.badge.badge-pill.gl-badge.sm.badge-info= _('manual')
- if pipeline_link
%td

View File

@ -21,24 +21,24 @@
.icon-container
= sprite_icon('flag')
- if @pipeline.child?
%span.js-pipeline-child.badge.badge-primary.has-tooltip{ title: s_("Pipelines|This is a child pipeline within the parent pipeline") }
%span.js-pipeline-child.badge.badge-pill.gl-badge.sm.badge-primary.has-tooltip{ title: s_("Pipelines|This is a child pipeline within the parent pipeline") }
= s_('Pipelines|Child pipeline')
= surround '(', ')' do
= link_to s_('Pipelines|parent'), pipeline_path(@pipeline.triggered_by_pipeline), class: 'text-white text-underline'
- if @pipeline.latest?
%span.js-pipeline-url-latest.badge.badge-success.has-tooltip{ title: _("Latest pipeline for the most recent commit on this branch") }
%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.has_yaml_errors?
%span.js-pipeline-url-yaml.badge.badge-danger.has-tooltip{ title: @pipeline.yaml_errors }
%span.js-pipeline-url-yaml.badge.badge-pill.gl-badge.sm.badge-danger.has-tooltip{ title: @pipeline.yaml_errors }
yaml invalid
- if @pipeline.failure_reason?
%span.js-pipeline-url-failure.badge.badge-danger.has-tooltip{ title: @pipeline.failure_reason }
%span.js-pipeline-url-failure.badge.badge-pill.gl-badge.sm.badge-danger.has-tooltip{ title: @pipeline.failure_reason }
error
- if @pipeline.auto_devops_source?
- popover_title_text = html_escape(_('This pipeline makes use of a predefined CI/CD configuration enabled by %{b_open}Auto DevOps.%{b_close}')) % { b_open: '<b>'.html_safe, b_close: '</b>'.html_safe }
- popover_content_url = help_page_path('topics/autodevops/index.md')
- popover_content_text = _('Learn more about Auto DevOps')
%a.js-pipeline-url-autodevops.badge.badge-info.autodevops-badge{ href: "#", tabindex: "0", role: "button", data: { container: "body",
%a.js-pipeline-url-autodevops.badge.badge-pill.gl-badge.sm.badge-info.autodevops-badge{ href: "#", tabindex: "0", role: "button", data: { container: "body",
toggle: "popover",
placement: "top",
html: "true",
@ -48,10 +48,10 @@
} }
Auto DevOps
- if @pipeline.detached_merge_request_pipeline?
%span.js-pipeline-url-mergerequest.badge.badge-info.has-tooltip{ title: _('Pipelines for merge requests are configured. A detached pipeline runs in the context of the merge request, and not against the merged result. Learn more in the documentation for Pipelines for Merged Results.') }
%span.js-pipeline-url-mergerequest.badge.badge-pill.gl-badge.sm.badge-info.has-tooltip{ title: _('Pipelines for merge requests are configured. A detached pipeline runs in the context of the merge request, and not against the merged result. Learn more in the documentation for Pipelines for Merged Results.') }
detached
- if @pipeline.stuck?
%span.js-pipeline-url-stuck.badge.badge-warning
%span.js-pipeline-url-stuck.badge.badge-pill.gl-badge.sm.badge-warning
stuck
.well-segment.branch-info

View File

@ -58,7 +58,7 @@
.selectbox.hide-collapsed
= f.hidden_field 'milestone_id', value: milestone[:id], id: nil
= dropdown_tag('Milestone', options: { title: _('Assign milestone'), toggle_class: 'js-milestone-select js-extra-options', filter: true, dropdown_class: 'dropdown-menu-selectable', placeholder: _('Search milestones'), data: { show_no: true, field_name: "#{issuable_type}[milestone_id]", project_id: issuable_sidebar[:project_id], issuable_id: issuable_sidebar[:id], ability_name: issuable_type, issue_update: issuable_sidebar[:issuable_json_path], use_id: true, default_no: true, selected: milestone[:title], null_default: true, display: 'static' }})
- if @project.group.present?
- if @project.group.present? && issuable_sidebar[:supports_iterations]
= render_if_exists 'shared/issuable/iteration_select', can_edit: can_edit_issuable, group_path: @project.group.full_path, project_path: issuable_sidebar[:project_full_path], issue_iid: issuable_sidebar[:iid], issuable_type: issuable_type
- if issuable_sidebar[:supports_time_tracking]

View File

@ -5,8 +5,8 @@
%div
%ul
%li
%span.badge.badge-success active
%span.badge.badge-pill.gl-badge.sm.badge-success active
= _('- Available to run jobs.')
%li
%span.badge.badge-danger paused
%span.badge.badge-pill.gl-badge.sm.badge-danger paused
= _('- Not available to run jobs.')

View File

@ -0,0 +1,5 @@
---
title: 'Update Issue Incidents to allow the milestones feature to be used in the sidebar and quick actions'
merge_request: 51456
author:
type: changed

View File

@ -0,0 +1,5 @@
---
title: Add gl-badge to CI badges
merge_request: 51547
author: Yogi (@yo)
type: other

View File

@ -0,0 +1,5 @@
---
title: Add gl-badge to CI runners
merge_request: 51548
author: Yogi (@yo)
type: other

View File

@ -45,7 +45,7 @@ RSpec.describe 'Incident details', :js do
expect(page).to have_selector('.right-sidebar[data-issuable-type="issue"]')
expect(sidebar).to have_selector('.incident-severity')
expect(sidebar).not_to have_selector('.milestone')
expect(sidebar).to have_selector('.milestone')
end
end
end

View File

@ -223,8 +223,8 @@ RSpec.describe "User creates issue" do
expect(page).not_to have_selector('.epic-dropdown-container')
end
it 'hides the milestone select' do
expect(page).not_to have_selector('.qa-issuable-milestone-dropdown')
it 'shows the milestone select' do
expect(page).to have_selector('.qa-issuable-milestone-dropdown')
end
it 'hides the weight input' do

View File

@ -605,11 +605,14 @@ RSpec.describe 'Merge request > User sees merge widget', :js do
within(".js-report-section-container") do
click_button 'addTest'
expect(page).to have_content('6.66')
expect(page).to have_content(sample_java_failed_message.gsub(/\s+/, ' ').strip)
end
end
within("#modal-mrwidget-reports") do
expect(page).to have_content('addTest')
expect(page).to have_content('6.66')
expect(page).to have_content(sample_java_failed_message.gsub(/\s+/, ' ').strip)
end
end
end
end
@ -650,11 +653,14 @@ RSpec.describe 'Merge request > User sees merge widget', :js do
within(".js-report-section-container") do
click_button 'Test#sum when a is 1 and b is 3 returns summary'
expect(page).to have_content('2.22')
expect(page).to have_content(sample_rspec_failed_message.gsub(/\s+/, ' ').strip)
end
end
within("#modal-mrwidget-reports") do
expect(page).to have_content('Test#sum when a is 1 and b is 3 returns summary')
expect(page).to have_content('2.22')
expect(page).to have_content(sample_rspec_failed_message.gsub(/\s+/, ' ').strip)
end
end
end
end
@ -694,10 +700,13 @@ RSpec.describe 'Merge request > User sees merge widget', :js do
within(".js-report-section-container") do
click_button 'addTest'
expect(page).to have_content('5.55')
end
end
within("#modal-mrwidget-reports") do
expect(page).to have_content('addTest')
expect(page).to have_content('5.55')
end
end
end
end
@ -738,10 +747,13 @@ RSpec.describe 'Merge request > User sees merge widget', :js do
within(".js-report-section-container") do
click_button 'addTest'
expect(page).to have_content('8.88')
end
end
within("#modal-mrwidget-reports") do
expect(page).to have_content('addTest')
expect(page).to have_content('8.88')
end
end
end
end
@ -782,10 +794,13 @@ RSpec.describe 'Merge request > User sees merge widget', :js do
within(".js-report-section-container") do
click_button 'Test#sum when a is 4 and b is 4 returns summary'
expect(page).to have_content('4.44')
end
end
within("#modal-mrwidget-reports") do
expect(page).to have_content('Test#sum when a is 4 and b is 4 returns summary')
expect(page).to have_content('4.44')
end
end
end
end
@ -825,10 +840,13 @@ RSpec.describe 'Merge request > User sees merge widget', :js do
within(".js-report-section-container") do
click_button 'addTest'
expect(page).to have_content('5.55')
end
end
within("#modal-mrwidget-reports") do
expect(page).to have_content('addTest')
expect(page).to have_content('5.55')
end
end
end
end

View File

@ -1,54 +1,63 @@
import Vue from 'vue';
import mountComponent from 'helpers/vue_mount_component_helper';
import { trimText } from 'helpers/text_helper';
import component from '~/reports/components/modal.vue';
import { GlLink, GlSprintf } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import CodeBlock from '~/vue_shared/components/code_block.vue';
import ReportsModal from '~/reports/components/modal.vue';
import state from '~/reports/store/state';
const StubbedGlModal = { template: '<div><slot></slot></div>', name: 'GlModal', props: ['title'] };
describe('Grouped Test Reports Modal', () => {
const Component = Vue.extend(component);
const modalDataStructure = state().modal.data;
const title = 'Test#sum when a is 1 and b is 2 returns summary';
// populate data
modalDataStructure.execution_time.value = 0.009411;
modalDataStructure.system_output.value = 'Failure/Error: is_expected.to eq(3)\n\n';
modalDataStructure.class.value = 'link';
let vm;
let wrapper;
beforeEach(() => {
vm = mountComponent(Component, {
title: 'Test#sum when a is 1 and b is 2 returns summary',
modalData: modalDataStructure,
});
wrapper = extendedWrapper(
shallowMount(ReportsModal, {
propsData: {
title,
modalData: modalDataStructure,
visible: true,
},
stubs: { GlModal: StubbedGlModal, GlSprintf },
}),
);
});
afterEach(() => {
vm.$destroy();
wrapper.destroy();
});
it('renders code block', () => {
expect(vm.$el.querySelector('code').textContent).toEqual(
modalDataStructure.system_output.value,
);
expect(wrapper.find(CodeBlock).props().code).toEqual(modalDataStructure.system_output.value);
});
it('renders link', () => {
expect(vm.$el.querySelector('.js-modal-link').getAttribute('href')).toEqual(
modalDataStructure.class.value,
);
const link = wrapper.findComponent(GlLink);
expect(trimText(vm.$el.querySelector('.js-modal-link').textContent)).toEqual(
modalDataStructure.class.value,
);
expect(link.attributes().href).toEqual(modalDataStructure.class.value);
expect(link.text()).toEqual(modalDataStructure.class.value);
});
it('renders seconds', () => {
expect(vm.$el.textContent).toContain(`${modalDataStructure.execution_time.value} s`);
expect(wrapper.text()).toContain(`${modalDataStructure.execution_time.value} s`);
});
it('render title', () => {
expect(trimText(vm.$el.querySelector('.modal-title').textContent)).toEqual(
'Test#sum when a is 1 and b is 2 returns summary',
);
expect(wrapper.findComponent(StubbedGlModal).props().title).toEqual(title);
});
it('re-emits hide event', () => {
wrapper.findComponent(StubbedGlModal).vm.$emit('hide');
expect(wrapper.emitted().hide).toEqual([[]]);
});
});

View File

@ -11,7 +11,7 @@ import {
receiveReportsSuccess,
receiveReportsError,
openModal,
setModalData,
closeModal,
} from '~/reports/store/actions';
import state from '~/reports/store/state';
import * as types from '~/reports/store/mutation_types';
@ -144,22 +144,9 @@ describe('Reports Store Actions', () => {
});
describe('openModal', () => {
it('should dispatch setModalData', (done) => {
testAction(
openModal,
{ name: 'foo' },
mockedState,
[],
[{ type: 'setModalData', payload: { name: 'foo' } }],
done,
);
});
});
describe('setModalData', () => {
it('should commit SET_ISSUE_MODAL_DATA', (done) => {
testAction(
setModalData,
openModal,
{ name: 'foo' },
mockedState,
[{ type: types.SET_ISSUE_MODAL_DATA, payload: { name: 'foo' } }],
@ -168,4 +155,17 @@ describe('Reports Store Actions', () => {
);
});
});
describe('closeModal', () => {
it('should commit RESET_ISSUE_MODAL_DATA', (done) => {
testAction(
closeModal,
{},
mockedState,
[{ type: types.RESET_ISSUE_MODAL_DATA, payload: {} }],
[],
done,
);
});
});
});

View File

@ -127,5 +127,32 @@ describe('Reports Store Mutations', () => {
expect(stateCopy.modal.data.execution_time.value).toEqual(issue.execution_time);
expect(stateCopy.modal.data.system_output.value).toEqual(issue.system_output);
});
it('should open modal', () => {
expect(stateCopy.modal.open).toEqual(true);
});
});
describe('RESET_ISSUE_MODAL_DATA', () => {
beforeEach(() => {
mutations[types.SET_ISSUE_MODAL_DATA](stateCopy, {
issue,
});
mutations[types.RESET_ISSUE_MODAL_DATA](stateCopy);
});
it('should reset modal title', () => {
expect(stateCopy.modal.title).toEqual(null);
});
it('should reset modal data', () => {
expect(stateCopy.modal.data.execution_time.value).toEqual(null);
expect(stateCopy.modal.data.system_output.value).toEqual(null);
});
it('should close modal', () => {
expect(stateCopy.modal.open).toEqual(false);
});
});
});

View File

@ -104,8 +104,8 @@ RSpec.describe Milestoneable do
context "for incidents" do
let(:incident) { build(:incident) }
it 'returns false' do
expect(incident.supports_milestone?).to be_falsy
it 'returns true' do
expect(incident.supports_milestone?).to be_truthy
end
end
end

View File

@ -153,8 +153,8 @@ RSpec.describe Notes::QuickActionsService do
expect(execute(note)).to be_empty
end
it 'does not assign the milestone' do
expect { execute(note) }.not_to change { issue.reload.milestone }
it 'assigns the milestone' do
expect { execute(note) }.to change { issue.reload.milestone }.from(nil).to(milestone)
end
end
@ -195,8 +195,8 @@ RSpec.describe Notes::QuickActionsService do
expect(execute(note)).to be_empty
end
it 'does not remove the milestone' do
expect { execute(note) }.not_to change { issue.reload.milestone }
it 'removes the milestone' do
expect { execute(note) }.to change { issue.reload.milestone }.from(milestone).to(nil)
end
end