Commit 6cdfd863 authored by Payton Burdette's avatar Payton Burdette Committed by Nicolò Maria Mezzopera

Use job name for primary identifier on ci header

parent 95cd8700
...@@ -5,7 +5,7 @@ import { throttle, isEmpty } from 'lodash'; ...@@ -5,7 +5,7 @@ import { throttle, isEmpty } from 'lodash';
import { mapGetters, mapState, mapActions } from 'vuex'; import { mapGetters, mapState, mapActions } from 'vuex';
import CodeQualityWalkthrough from '~/code_quality_walkthrough/components/step.vue'; import CodeQualityWalkthrough from '~/code_quality_walkthrough/components/step.vue';
import { isScrolledToBottom } from '~/lib/utils/scroll_utils'; import { isScrolledToBottom } from '~/lib/utils/scroll_utils';
import { sprintf } from '~/locale'; import { __, sprintf } from '~/locale';
import CiHeader from '~/vue_shared/components/header_ci_component.vue'; import CiHeader from '~/vue_shared/components/header_ci_component.vue';
import delayedJobMixin from '../mixins/delayed_job_mixin'; import delayedJobMixin from '../mixins/delayed_job_mixin';
import EmptyState from './empty_state.vue'; import EmptyState from './empty_state.vue';
...@@ -126,6 +126,9 @@ export default { ...@@ -126,6 +126,9 @@ export default {
shouldRenderCodeQualityWalkthrough() { shouldRenderCodeQualityWalkthrough() {
return this.job.status.group === 'failed-with-warnings'; return this.job.status.group === 'failed-with-warnings';
}, },
itemName() {
return sprintf(__('Job %{jobName}'), { jobName: this.job.name });
},
}, },
watch: { watch: {
// Once the job log is loaded, // Once the job log is loaded,
...@@ -205,12 +208,11 @@ export default { ...@@ -205,12 +208,11 @@ export default {
<div class="build-header top-area"> <div class="build-header top-area">
<ci-header <ci-header
:status="job.status" :status="job.status"
:item-id="job.id"
:time="headerTime" :time="headerTime"
:user="job.user" :user="job.user"
:has-sidebar-button="true" :has-sidebar-button="true"
:should-render-triggered-label="shouldRenderTriggeredLabel" :should-render-triggered-label="shouldRenderTriggeredLabel"
:item-name="__('Job')" :item-name="itemName"
@clickedSidebarButton="toggleSidebar" @clickedSidebarButton="toggleSidebar"
/> />
</div> </div>
......
...@@ -218,7 +218,7 @@ export default { ...@@ -218,7 +218,7 @@ export default {
:status="pipeline.detailedStatus" :status="pipeline.detailedStatus"
:time="pipeline.createdAt" :time="pipeline.createdAt"
:user="pipeline.user" :user="pipeline.user"
:item-id="Number(pipelineId)" :item-id="pipelineId"
item-name="Pipeline" item-name="Pipeline"
> >
<gl-button <gl-button
......
...@@ -37,8 +37,9 @@ export default { ...@@ -37,8 +37,9 @@ export default {
required: true, required: true,
}, },
itemId: { itemId: {
type: Number, type: String,
required: true, required: false,
default: '',
}, },
time: { time: {
type: String, type: String,
...@@ -86,6 +87,13 @@ export default { ...@@ -86,6 +87,13 @@ export default {
message() { message() {
return this.user?.status?.message; return this.user?.status?.message;
}, },
item() {
if (this.itemId) {
return `${this.itemName} #${this.itemId}`;
}
return this.itemName;
},
}, },
methods: { methods: {
...@@ -106,7 +114,7 @@ export default { ...@@ -106,7 +114,7 @@ export default {
<section class="header-main-content gl-mr-3"> <section class="header-main-content gl-mr-3">
<ci-icon-badge :status="status" /> <ci-icon-badge :status="status" />
<strong data-testid="ci-header-item-text"> {{ itemName }} #{{ itemId }} </strong> <strong data-testid="ci-header-item-text">{{ item }}</strong>
<template v-if="shouldRenderTriggeredLabel">{{ __('triggered') }}</template> <template v-if="shouldRenderTriggeredLabel">{{ __('triggered') }}</template>
<template v-else>{{ __('created') }}</template> <template v-else>{{ __('created') }}</template>
......
...@@ -19351,6 +19351,9 @@ msgstr "" ...@@ -19351,6 +19351,9 @@ msgstr ""
msgid "Job" msgid "Job"
msgstr "" msgstr ""
msgid "Job %{jobName}"
msgstr ""
msgid "Job Failed #%{build_id}" msgid "Job Failed #%{build_id}"
msgstr "" msgstr ""
......
...@@ -90,7 +90,7 @@ RSpec.describe 'Project Jobs Permissions' do ...@@ -90,7 +90,7 @@ RSpec.describe 'Project Jobs Permissions' do
it_behaves_like 'recent job page details responds with status', 200 do it_behaves_like 'recent job page details responds with status', 200 do
it 'renders job details', :js do it 'renders job details', :js do
expect(page).to have_content "Job ##{job.id}" expect(page).to have_content "Job #{job.name}"
expect(page).to have_css '.log-line' expect(page).to have_css '.log-line'
end end
end end
......
...@@ -21,7 +21,7 @@ RSpec.describe 'User browses a job', :js do ...@@ -21,7 +21,7 @@ RSpec.describe 'User browses a job', :js do
it 'erases the job log', :js do it 'erases the job log', :js do
wait_for_requests wait_for_requests
expect(page).to have_content("Job ##{build.id}") expect(page).to have_content("Job #{build.name}")
expect(page).to have_css('.job-log') expect(page).to have_css('.job-log')
# scroll to the top of the page first # scroll to the top of the page first
......
...@@ -140,7 +140,7 @@ describe('Job App', () => { ...@@ -140,7 +140,7 @@ describe('Job App', () => {
it('should render provided job information', () => { it('should render provided job information', () => {
expect(wrapper.find('.header-main-content').text().replace(/\s+/g, ' ').trim()).toContain( expect(wrapper.find('.header-main-content').text().replace(/\s+/g, ' ').trim()).toContain(
'passed Job #4757 triggered 1 year ago by Root', 'passed Job test triggered 1 year ago by Root',
); );
}); });
...@@ -154,7 +154,7 @@ describe('Job App', () => { ...@@ -154,7 +154,7 @@ describe('Job App', () => {
setupAndMount().then(() => { setupAndMount().then(() => {
expect( expect(
wrapper.find('.header-main-content').text().replace(/\s+/g, ' ').trim(), wrapper.find('.header-main-content').text().replace(/\s+/g, ' ').trim(),
).toContain('passed Job #4757 created 3 weeks ago by Root'); ).toContain('passed Job test created 3 weeks ago by Root');
})); }));
}); });
}); });
......
...@@ -24,7 +24,7 @@ describe('Pipeline details header', () => { ...@@ -24,7 +24,7 @@ describe('Pipeline details header', () => {
const findLoadingIcon = () => wrapper.find(GlLoadingIcon); const findLoadingIcon = () => wrapper.find(GlLoadingIcon);
const defaultProvideOptions = { const defaultProvideOptions = {
pipelineId: 14, pipelineId: '14',
pipelineIid: 1, pipelineIid: 1,
paths: { paths: {
pipelinesPath: '/namespace/my-project/-/pipelines', pipelinesPath: '/namespace/my-project/-/pipelines',
......
...@@ -16,8 +16,6 @@ describe('Header CI Component', () => { ...@@ -16,8 +16,6 @@ describe('Header CI Component', () => {
text: 'failed', text: 'failed',
details_path: 'path', details_path: 'path',
}, },
itemName: 'job',
itemId: 123,
time: '2017-05-08T14:57:39.781Z', time: '2017-05-08T14:57:39.781Z',
user: { user: {
web_url: 'path', web_url: 'path',
...@@ -55,17 +53,13 @@ describe('Header CI Component', () => { ...@@ -55,17 +53,13 @@ describe('Header CI Component', () => {
describe('render', () => { describe('render', () => {
beforeEach(() => { beforeEach(() => {
createComponent(); createComponent({ itemName: 'Pipeline' });
}); });
it('should render status badge', () => { it('should render status badge', () => {
expect(findIconBadge().exists()).toBe(true); expect(findIconBadge().exists()).toBe(true);
}); });
it('should render item name and id', () => {
expect(findHeaderItemText().text()).toBe('job #123');
});
it('should render timeago date', () => { it('should render timeago date', () => {
expect(findTimeAgo().exists()).toBe(true); expect(findTimeAgo().exists()).toBe(true);
}); });
...@@ -83,9 +77,29 @@ describe('Header CI Component', () => { ...@@ -83,9 +77,29 @@ describe('Header CI Component', () => {
}); });
}); });
describe('with item id', () => {
beforeEach(() => {
createComponent({ itemName: 'Pipeline', itemId: '123' });
});
it('should render item name and id', () => {
expect(findHeaderItemText().text()).toBe('Pipeline #123');
});
});
describe('without item id', () => {
beforeEach(() => {
createComponent({ itemName: 'Job build_job' });
});
it('should render item name', () => {
expect(findHeaderItemText().text()).toBe('Job build_job');
});
});
describe('slot', () => { describe('slot', () => {
it('should render header action buttons', () => { it('should render header action buttons', () => {
createComponent({}, { slots: { default: 'Test Actions' } }); createComponent({ itemName: 'Job build_job' }, { slots: { default: 'Test Actions' } });
expect(findActionButtons().exists()).toBe(true); expect(findActionButtons().exists()).toBe(true);
expect(findActionButtons().text()).toBe('Test Actions'); expect(findActionButtons().text()).toBe('Test Actions');
...@@ -94,7 +108,7 @@ describe('Header CI Component', () => { ...@@ -94,7 +108,7 @@ describe('Header CI Component', () => {
describe('shouldRenderTriggeredLabel', () => { describe('shouldRenderTriggeredLabel', () => {
it('should render created keyword when the shouldRenderTriggeredLabel is false', () => { it('should render created keyword when the shouldRenderTriggeredLabel is false', () => {
createComponent({ shouldRenderTriggeredLabel: false }); createComponent({ shouldRenderTriggeredLabel: false, itemName: 'Job build_job' });
expect(wrapper.text()).toContain('created'); expect(wrapper.text()).toContain('created');
expect(wrapper.text()).not.toContain('triggered'); expect(wrapper.text()).not.toContain('triggered');
......
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