diff --git a/app/components/pipeline/settings/preferences/component.js b/app/components/pipeline/settings/preferences/component.js index 9a27c7b65..03e2bd5e7 100644 --- a/app/components/pipeline/settings/preferences/component.js +++ b/app/components/pipeline/settings/preferences/component.js @@ -46,7 +46,7 @@ export default class PipelineSettingsPreferencesComponent extends Component { this.isFilterEventsForNoBuilds = !!settings?.filterEventsForNoBuilds; this.userSettings = this.settings.getSettingsForPipeline(this.pipeline.id); - this.isShowPrJobs = this.userSettings?.showPRJobs || false; + this.isShowPrJobs = this.userSettings?.showPRJobs ?? true; this.isUserSettingsDisabled = false; } diff --git a/app/components/pipeline/workflow/component.js b/app/components/pipeline/workflow/component.js index 5dec76fd0..ababd45fd 100644 --- a/app/components/pipeline/workflow/component.js +++ b/app/components/pipeline/workflow/component.js @@ -54,6 +54,7 @@ export default class PipelineWorkflowComponent extends Component { @tracked collapsedStages; + workflowGraph; workflowGraphWithDownstreamTriggers; diff --git a/app/components/pipeline/workflow/graph/component.js b/app/components/pipeline/workflow/graph/component.js index 79a3ea0bc..0f6471a8c 100644 --- a/app/components/pipeline/workflow/graph/component.js +++ b/app/components/pipeline/workflow/graph/component.js @@ -3,7 +3,7 @@ import Component from '@glimmer/component'; import { action } from '@ember/object'; import { service } from '@ember/service'; import { isSkipped } from 'screwdriver-ui/utils/pipeline/event'; -import { decorateGraph } from 'screwdriver-ui/utils/graph-tools'; +import { decorateGraph, removeBranch } from 'screwdriver-ui/utils/graph-tools'; import { addEdges, addJobIcons, @@ -22,7 +22,9 @@ import { import { nodeCanShowTooltip } from 'screwdriver-ui/utils/pipeline/graph/tooltip'; export default class PipelineWorkflowGraphComponent extends Component { - @service pipelinePageState; + @service('pipeline-page-state') pipelinePageState; + + @service('settings') settings; event; @@ -36,6 +38,8 @@ export default class PipelineWorkflowGraphComponent extends Component { graphSvg; + showPRJobs; + constructor() { super(...arguments); this.event = this.args.event; @@ -43,6 +47,11 @@ export default class PipelineWorkflowGraphComponent extends Component { this.stageBuilds = this.args.stageBuilds; this.collapsedStages = this.args.collapsedStages; + this.showPRJobs = + this.settings.getSettingsForPipeline( + this.pipelinePageState.getPipelineId() + ).showPRJobs ?? true; + this.getDecoratedGraph( this.args.workflowGraph, this.args.builds, @@ -59,6 +68,14 @@ export default class PipelineWorkflowGraphComponent extends Component { event, collapsedStages ) { + // remove jobs that starts from ~pr + + if (event.prNum === undefined && !this.showPRJobs) { + const prNode = workflowGraph.nodes.findBy('name', '~pr'); + + removeBranch(prNode, workflowGraph); + } + this.decoratedGraph = decorateGraph({ inputGraph: workflowGraph, builds, diff --git a/tests/integration/components/pipeline/workflow/graph/component-test.js b/tests/integration/components/pipeline/workflow/graph/component-test.js index a3b7f69e0..743af4c53 100644 --- a/tests/integration/components/pipeline/workflow/graph/component-test.js +++ b/tests/integration/components/pipeline/workflow/graph/component-test.js @@ -12,9 +12,14 @@ module('Integration | Component | pipeline/workflow/graph', function (hooks) { hooks.beforeEach(function () { const pipelinePageState = this.owner.lookup('service:pipeline-page-state'); + const settings = this.owner.lookup('service:settings'); sinon.stub(pipelinePageState, 'getStages').returns(stages); sinon.stub(pipelinePageState, 'getJobs').returns(jobs); + sinon.stub(pipelinePageState, 'getPipelineId').returns(1); + sinon + .stub(settings, 'getSettingsForPipeline') + .returns({ showPRJobs: false }); jobs.push({ id: 1 }); }); @@ -211,7 +216,7 @@ module('Integration | Component | pipeline/workflow/graph', function (hooks) { { src: 'first', dest: 'second' } ] }, - event: { startFrom: '~pr' }, + event: { startFrom: '~pr', prNum: 1 }, builds: [{ id: 1, jobId: 1, status: 'SUCCESS' }], collapsedStages: new Set([]), displayJobNameLength: 20