Skip to content

Commit 89739a6

Browse files
authored
fix(3433): PR jobs displayed even when “Show PR Jobs” is enabled (#1510)
1 parent c949618 commit 89739a6

File tree

4 files changed

+27
-4
lines changed

4 files changed

+27
-4
lines changed

app/components/pipeline/settings/preferences/component.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export default class PipelineSettingsPreferencesComponent extends Component {
4646
this.isFilterEventsForNoBuilds = !!settings?.filterEventsForNoBuilds;
4747

4848
this.userSettings = this.settings.getSettingsForPipeline(this.pipeline.id);
49-
this.isShowPrJobs = this.userSettings?.showPRJobs || false;
49+
this.isShowPrJobs = this.userSettings?.showPRJobs ?? true;
5050

5151
this.isUserSettingsDisabled = false;
5252
}

app/components/pipeline/workflow/component.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export default class PipelineWorkflowComponent extends Component {
5454

5555
@tracked collapsedStages;
5656

57+
5758
workflowGraph;
5859

5960
workflowGraphWithDownstreamTriggers;

app/components/pipeline/workflow/graph/component.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Component from '@glimmer/component';
33
import { action } from '@ember/object';
44
import { service } from '@ember/service';
55
import { isSkipped } from 'screwdriver-ui/utils/pipeline/event';
6-
import { decorateGraph } from 'screwdriver-ui/utils/graph-tools';
6+
import { decorateGraph, removeBranch } from 'screwdriver-ui/utils/graph-tools';
77
import {
88
addEdges,
99
addJobIcons,
@@ -22,7 +22,9 @@ import {
2222
import { nodeCanShowTooltip } from 'screwdriver-ui/utils/pipeline/graph/tooltip';
2323

2424
export default class PipelineWorkflowGraphComponent extends Component {
25-
@service pipelinePageState;
25+
@service('pipeline-page-state') pipelinePageState;
26+
27+
@service('settings') settings;
2628

2729
event;
2830

@@ -36,13 +38,20 @@ export default class PipelineWorkflowGraphComponent extends Component {
3638

3739
graphSvg;
3840

41+
showPRJobs;
42+
3943
constructor() {
4044
super(...arguments);
4145
this.event = this.args.event;
4246
this.builds = this.args.builds;
4347
this.stageBuilds = this.args.stageBuilds;
4448
this.collapsedStages = this.args.collapsedStages;
4549

50+
this.showPRJobs =
51+
this.settings.getSettingsForPipeline(
52+
this.pipelinePageState.getPipelineId()
53+
).showPRJobs ?? true;
54+
4655
this.getDecoratedGraph(
4756
this.args.workflowGraph,
4857
this.args.builds,
@@ -59,6 +68,14 @@ export default class PipelineWorkflowGraphComponent extends Component {
5968
event,
6069
collapsedStages
6170
) {
71+
// remove jobs that starts from ~pr
72+
73+
if (event.prNum === undefined && !this.showPRJobs) {
74+
const prNode = workflowGraph.nodes.findBy('name', '~pr');
75+
76+
removeBranch(prNode, workflowGraph);
77+
}
78+
6279
this.decoratedGraph = decorateGraph({
6380
inputGraph: workflowGraph,
6481
builds,

tests/integration/components/pipeline/workflow/graph/component-test.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,14 @@ module('Integration | Component | pipeline/workflow/graph', function (hooks) {
1212

1313
hooks.beforeEach(function () {
1414
const pipelinePageState = this.owner.lookup('service:pipeline-page-state');
15+
const settings = this.owner.lookup('service:settings');
1516

1617
sinon.stub(pipelinePageState, 'getStages').returns(stages);
1718
sinon.stub(pipelinePageState, 'getJobs').returns(jobs);
19+
sinon.stub(pipelinePageState, 'getPipelineId').returns(1);
20+
sinon
21+
.stub(settings, 'getSettingsForPipeline')
22+
.returns({ showPRJobs: false });
1823

1924
jobs.push({ id: 1 });
2025
});
@@ -211,7 +216,7 @@ module('Integration | Component | pipeline/workflow/graph', function (hooks) {
211216
{ src: 'first', dest: 'second' }
212217
]
213218
},
214-
event: { startFrom: '~pr' },
219+
event: { startFrom: '~pr', prNum: 1 },
215220
builds: [{ id: 1, jobId: 1, status: 'SUCCESS' }],
216221
collapsedStages: new Set([]),
217222
displayJobNameLength: 20

0 commit comments

Comments
 (0)