Commit 743050ce authored by Phil Hughes's avatar Phil Hughes

Merge branch '37860-pipelines-page' into 'master'

Make pipelines table in MR view usable

See merge request gitlab-org/gitlab-ce!14941
parents f94c3917 c2d943a7
...@@ -25,6 +25,11 @@ ...@@ -25,6 +25,11 @@
type: String, type: String,
required: true, required: true,
}, },
viewType: {
type: String,
required: false,
default: 'child',
},
}, },
mixins: [ mixins: [
pipelinesMixin, pipelinesMixin,
...@@ -110,6 +115,7 @@ ...@@ -110,6 +115,7 @@
:pipelines="state.pipelines" :pipelines="state.pipelines"
:update-graph-dropdown="updateGraphDropdown" :update-graph-dropdown="updateGraphDropdown"
:auto-devops-help-path="autoDevopsHelpPath" :auto-devops-help-path="autoDevopsHelpPath"
:view-type="viewType"
/> />
</div> </div>
</div> </div>
......
...@@ -12,6 +12,15 @@ ...@@ -12,6 +12,15 @@
type: Object, type: Object,
required: true, required: true,
}, },
// Can be rendered in 3 different places, with some visual differences
// Accepts root | child
// `root` -> main view
// `child` -> rendered inside MR or Commit View
viewType: {
type: String,
required: false,
default: 'root',
},
}, },
components: { components: {
tablePagination, tablePagination,
...@@ -206,6 +215,7 @@ ...@@ -206,6 +215,7 @@
:pipelines="state.pipelines" :pipelines="state.pipelines"
:update-graph-dropdown="updateGraphDropdown" :update-graph-dropdown="updateGraphDropdown"
:auto-devops-help-path="autoDevopsPath" :auto-devops-help-path="autoDevopsPath"
:view-type="viewType"
/> />
</div> </div>
......
...@@ -21,6 +21,10 @@ ...@@ -21,6 +21,10 @@
type: String, type: String,
required: true, required: true,
}, },
viewType: {
type: String,
required: true,
},
}, },
components: { components: {
pipelinesTableRowComponent, pipelinesTableRowComponent,
...@@ -59,6 +63,7 @@ ...@@ -59,6 +63,7 @@
:pipeline="model" :pipeline="model"
:update-graph-dropdown="updateGraphDropdown" :update-graph-dropdown="updateGraphDropdown"
:auto-devops-help-path="autoDevopsHelpPath" :auto-devops-help-path="autoDevopsHelpPath"
:view-type="viewType"
/> />
</div> </div>
</template> </template>
...@@ -29,6 +29,10 @@ export default { ...@@ -29,6 +29,10 @@ export default {
type: String, type: String,
required: true, required: true,
}, },
viewType: {
type: String,
required: true,
},
}, },
components: { components: {
asyncButtonComponent, asyncButtonComponent,
...@@ -207,6 +211,10 @@ export default { ...@@ -207,6 +211,10 @@ export default {
this.pipeline.details.manual_actions.length || this.pipeline.details.manual_actions.length ||
this.pipeline.details.artifacts.length; this.pipeline.details.artifacts.length;
}, },
isChildView() {
return this.viewType === 'child';
},
}, },
}; };
</script> </script>
...@@ -218,7 +226,10 @@ export default { ...@@ -218,7 +226,10 @@ export default {
Status Status
</div> </div>
<div class="table-mobile-content"> <div class="table-mobile-content">
<ci-badge :status="pipelineStatus"/> <ci-badge
:status="pipelineStatus"
:show-text="!isChildView"
/>
</div> </div>
</div> </div>
...@@ -240,7 +251,9 @@ export default { ...@@ -240,7 +251,9 @@ export default {
:commit-url="commitUrl" :commit-url="commitUrl"
:short-sha="commitShortSha" :short-sha="commitShortSha"
:title="commitTitle" :title="commitTitle"
:author="commitAuthor"/> :author="commitAuthor"
:show-branch="!isChildView"
/>
</div> </div>
</div> </div>
......
<script> <script>
import ciIcon from './ci_icon.vue'; import ciIcon from './ci_icon.vue';
/** import tooltip from '../directives/tooltip';
/**
* Renders CI Badge link with CI icon and status text based on * Renders CI Badge link with CI icon and status text based on
* API response shared between all places where it is used. * API response shared between all places where it is used.
* *
...@@ -21,32 +22,43 @@ import ciIcon from './ci_icon.vue'; ...@@ -21,32 +22,43 @@ import ciIcon from './ci_icon.vue';
* - MR widget * - MR widget
*/ */
export default { export default {
props: { props: {
status: { status: {
type: Object, type: Object,
required: true, required: true,
}, },
showText: {
type: Boolean,
required: false,
default: true,
},
}, },
components: { components: {
ciIcon, ciIcon,
}, },
directives: {
tooltip,
},
computed: { computed: {
cssClass() { cssClass() {
const className = this.status.group; const className = this.status.group;
return className ? `ci-status ci-${this.status.group}` : 'ci-status'; return className ? `ci-status ci-${className}` : 'ci-status';
}, },
}, },
}; };
</script> </script>
<template> <template>
<a <a
:href="status.details_path" :href="status.details_path"
:class="cssClass"> :class="cssClass"
v-tooltip
:title="!showText ? status.text : ''">
<ci-icon :status="status" /> <ci-icon :status="status" />
<template v-if="showText">
{{status.text}} {{status.text}}
</template>
</a> </a>
</template> </template>
...@@ -63,14 +63,17 @@ ...@@ -63,14 +63,17 @@
required: false, required: false,
default: () => ({}), default: () => ({}),
}, },
showBranch: {
type: Boolean,
required: false,
default: true,
},
}, },
computed: { computed: {
/** /**
* Used to verify if all the properties needed to render the commit * Used to verify if all the properties needed to render the commit
* ref section were provided. * ref section were provided.
* *
* TODO: Improve this! Use lodash _.has when we have it.
*
* @returns {Boolean} * @returns {Boolean}
*/ */
hasCommitRef() { hasCommitRef() {
...@@ -80,8 +83,6 @@ ...@@ -80,8 +83,6 @@
* Used to verify if all the properties needed to render the commit * Used to verify if all the properties needed to render the commit
* author section were provided. * author section were provided.
* *
* TODO: Improve this! Use lodash _.has when we have it.
*
* @returns {Boolean} * @returns {Boolean}
*/ */
hasAuthor() { hasAuthor() {
...@@ -114,8 +115,8 @@ ...@@ -114,8 +115,8 @@
</script> </script>
<template> <template>
<div class="branch-commit"> <div class="branch-commit">
<template v-if="hasCommitRef && showBranch">
<div <div
v-if="hasCommitRef"
class="icon-container hidden-xs"> class="icon-container hidden-xs">
<i <i
v-if="tag" v-if="tag"
...@@ -130,7 +131,6 @@ ...@@ -130,7 +131,6 @@
</div> </div>
<a <a
v-if="hasCommitRef"
class="ref-name hidden-xs" class="ref-name hidden-xs"
:href="commitRef.ref_url" :href="commitRef.ref_url"
v-tooltip v-tooltip
...@@ -138,7 +138,7 @@ ...@@ -138,7 +138,7 @@
:title="commitRef.name"> :title="commitRef.name">
{{commitRef.name}} {{commitRef.name}}
</a> </a>
</template>
<div <div
v-html="commitIconSvg" v-html="commitIconSvg"
class="commit-icon js-commit-icon"> class="commit-icon js-commit-icon">
......
...@@ -83,7 +83,6 @@ feature 'Merge request created from fork' do ...@@ -83,7 +83,6 @@ feature 'Merge request created from fork' do
page.within('.merge-request-tabs') { click_link 'Pipelines' } page.within('.merge-request-tabs') { click_link 'Pipelines' }
page.within('.ci-table') do page.within('.ci-table') do
expect(page).to have_content pipeline.status
expect(page).to have_content pipeline.id expect(page).to have_content pipeline.id
end end
end end
......
...@@ -20,7 +20,6 @@ feature 'project commit pipelines', :js do ...@@ -20,7 +20,6 @@ feature 'project commit pipelines', :js do
visit pipelines_project_commit_path(project, project.commit.sha) visit pipelines_project_commit_path(project, project.commit.sha)
page.within('.table-holder') do page.within('.table-holder') do
expect(page).to have_content project.pipelines[0].status # pipeline status
expect(page).to have_content project.pipelines[0].id # pipeline ids expect(page).to have_content project.pipelines[0].id # pipeline ids
end end
end end
......
...@@ -10,6 +10,7 @@ describe('Pipelines Table Row', () => { ...@@ -10,6 +10,7 @@ describe('Pipelines Table Row', () => {
propsData: { propsData: {
pipeline, pipeline,
autoDevopsHelpPath: 'foo', autoDevopsHelpPath: 'foo',
viewType: 'root',
}, },
}).$mount(); }).$mount();
}; };
......
...@@ -23,6 +23,7 @@ describe('Pipelines Table', () => { ...@@ -23,6 +23,7 @@ describe('Pipelines Table', () => {
propsData: { propsData: {
pipelines: [], pipelines: [],
autoDevopsHelpPath: 'foo', autoDevopsHelpPath: 'foo',
viewType: 'root',
}, },
}).$mount(); }).$mount();
}); });
...@@ -49,6 +50,7 @@ describe('Pipelines Table', () => { ...@@ -49,6 +50,7 @@ describe('Pipelines Table', () => {
propsData: { propsData: {
pipelines: [], pipelines: [],
autoDevopsHelpPath: 'foo', autoDevopsHelpPath: 'foo',
viewType: 'root',
}, },
}).$mount(); }).$mount();
expect(component.$el.querySelectorAll('.commit.gl-responsive-table-row').length).toEqual(0); expect(component.$el.querySelectorAll('.commit.gl-responsive-table-row').length).toEqual(0);
...@@ -61,6 +63,7 @@ describe('Pipelines Table', () => { ...@@ -61,6 +63,7 @@ describe('Pipelines Table', () => {
propsData: { propsData: {
pipelines: [pipeline], pipelines: [pipeline],
autoDevopsHelpPath: 'foo', autoDevopsHelpPath: 'foo',
viewType: 'root',
}, },
}).$mount(); }).$mount();
......
import Vue from 'vue'; import Vue from 'vue';
import ciBadge from '~/vue_shared/components/ci_badge_link.vue'; import ciBadge from '~/vue_shared/components/ci_badge_link.vue';
import mountComponent from '../../helpers/vue_mount_component_helper';
describe('CI Badge Link Component', () => { describe('CI Badge Link Component', () => {
let CIBadge; let CIBadge;
let vm;
const statuses = { const statuses = {
canceled: { canceled: {
...@@ -70,15 +72,17 @@ describe('CI Badge Link Component', () => { ...@@ -70,15 +72,17 @@ describe('CI Badge Link Component', () => {
}, },
}; };
it('should render each status badge', () => { beforeEach(() => {
CIBadge = Vue.extend(ciBadge); CIBadge = Vue.extend(ciBadge);
Object.keys(statuses).map((status) => { });
const vm = new CIBadge({
propsData: { afterEach(() => {
status: statuses[status], vm.$destroy();
}, });
}).$mount();
it('should render each status badge', () => {
Object.keys(statuses).map((status) => {
vm = mountComponent(CIBadge, { status: statuses[status] });
expect(vm.$el.getAttribute('href')).toEqual(statuses[status].details_path); expect(vm.$el.getAttribute('href')).toEqual(statuses[status].details_path);
expect(vm.$el.textContent.trim()).toEqual(statuses[status].text); expect(vm.$el.textContent.trim()).toEqual(statuses[status].text);
expect(vm.$el.getAttribute('class')).toEqual(`ci-status ci-${statuses[status].group}`); expect(vm.$el.getAttribute('class')).toEqual(`ci-status ci-${statuses[status].group}`);
...@@ -86,4 +90,9 @@ describe('CI Badge Link Component', () => { ...@@ -86,4 +90,9 @@ describe('CI Badge Link Component', () => {
return vm; return vm;
}); });
}); });
it('should not render label', () => {
vm = mountComponent(CIBadge, { status: statuses.canceled, showText: false });
expect(vm.$el.textContent.trim()).toEqual('');
});
}); });
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