Skip to content

Commit 3e75b27

Browse files
author
OpenShift Bot
authored
Merge pull request #953 from jwforres/no-pipelines
Merged by openshift-bot
2 parents 14fe437 + 482ae3a commit 3e75b27

File tree

5 files changed

+69
-25
lines changed

5 files changed

+69
-25
lines changed

app/scripts/constants.js

+5
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ window.OPENSHIFT_CONSTANTS = {
7373
pipelines: true
7474
},
7575

76+
SAMPLE_PIPELINE_TEMPLATE: {
77+
name: "jenkins-pipeline-example",
78+
namespace: "openshift"
79+
},
80+
7681
// href's will be prefixed with /project/{{projectName}} unless they are absolute URLs
7782
PROJECT_NAVIGATION: [
7883
{

app/scripts/controllers/pipelines.js

+12
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ angular.module('openshiftConsole')
1111
.controller('PipelinesController', function ($filter,
1212
$routeParams,
1313
$scope,
14+
Constants,
15+
Navigate,
1416
AlertMessageService,
1517
BuildsService,
1618
DataService,
@@ -106,11 +108,21 @@ angular.module('openshiftConsole')
106108
update();
107109
}));
108110

111+
var checkedForSampleTemplate = false;
109112
watches.push(DataService.watch("buildconfigs", context, function(buildConfigData) {
110113
$scope.buildConfigsLoaded = true;
111114
// Filter on the client until the server supports fieldSelector on spec.strategy.type.
112115
// Use _.pick instead of _.filter to keep $scope.buildConfigs a map
113116
$scope.buildConfigs = _.pick(buildConfigData.by("metadata.name"), isPipeline);
117+
if (_.isEmpty($scope.buildConfigs) && !checkedForSampleTemplate) {
118+
checkedForSampleTemplate = true;
119+
var sampleName = Constants.SAMPLE_PIPELINE_TEMPLATE.name;
120+
var sampleNamespace = Constants.SAMPLE_PIPELINE_TEMPLATE.namespace;
121+
DataService.get("templates", sampleName, {namespace: sampleNamespace}, {errorNotification: false}).then(
122+
function() {
123+
$scope.createSampleURL = Navigate.fromTemplateURL($scope.projectName, sampleName, sampleNamespace);
124+
});
125+
}
114126
update();
115127
}));
116128

app/views/pipelines.html

+8-3
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,15 @@ <h2>No pipelines.</h2>
2727
<div ng-if="project.metadata.name | canIAddToProject">
2828
<p>
2929
No pipelines have been added to project {{projectName}}.
30+
<br>
31+
Learn more about
32+
<a ng-href="{{ 'pipeline-builds' | helpLink}}" target="_blank">Pipeline Builds</a>
33+
and the
34+
<a ng-href="{{ 'pipeline-plugin' | helpLink}}" target="_blank">OpenShift Pipeline Plugin</a>.
3035
</p>
31-
<p ng-if="project.metadata.name | canIAddToProject">
32-
<a ng-href="project/{{projectName}}/create" class="btn btn-lg btn-primary">
33-
Add to Project
36+
<p ng-if="(project.metadata.name | canIAddToProject) && createSampleURL">
37+
<a ng-href="{{createSampleURL}}" class="btn btn-lg btn-primary">
38+
Create Sample Pipeline
3439
</a>
3540
</p>
3641
</div>

dist/scripts/scripts.js

+36-19
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ AVAILABLE_KINDS_BLACKLIST:[ "Binding", "Ingress", "DeploymentConfigRollback" ],
5050
ENABLE_TECH_PREVIEW_FEATURE:{
5151
pipelines:!0
5252
},
53+
SAMPLE_PIPELINE_TEMPLATE:{
54+
name:"jenkins-pipeline-example",
55+
namespace:"openshift"
56+
},
5357
PROJECT_NAVIGATION:[ {
5458
label:"Overview",
5559
iconClass:"fa fa-dashboard",
@@ -5200,47 +5204,60 @@ b.buildConfigs = a.select(b.unfilteredBuildConfigs), j(), m();
52005204
d.unwatchAll(l);
52015205
});
52025206
}));
5203-
} ]), angular.module("openshiftConsole").controller("PipelinesController", [ "$filter", "$routeParams", "$scope", "AlertMessageService", "BuildsService", "DataService", "Logger", "ProjectsService", function(a, b, c, d, e, f, g, h) {
5204-
c.projectName = b.project, c.alerts = c.alerts || {}, c.buildConfigs = {}, d.getAlerts().forEach(function(a) {
5207+
} ]), angular.module("openshiftConsole").controller("PipelinesController", [ "$filter", "$routeParams", "$scope", "Constants", "Navigate", "AlertMessageService", "BuildsService", "DataService", "Logger", "ProjectsService", function(a, b, c, d, e, f, g, h, i, j) {
5208+
c.projectName = b.project, c.alerts = c.alerts || {}, c.buildConfigs = {}, f.getAlerts().forEach(function(a) {
52055209
c.alerts[a.name] = a.data;
5206-
}), d.clearAlerts();
5207-
var i = [];
5208-
h.get(b.project).then(_.spread(function(b, d) {
5210+
}), f.clearAlerts();
5211+
var k = [];
5212+
j.get(b.project).then(_.spread(function(b, f) {
52095213
c.project = b;
5210-
var g = {}, h = a("buildConfigForBuild"), j = a("isIncompleteBuild"), k = a("isJenkinsPipelineStrategy"), l = a("isNewerResource"), m = function(a, b) {
5211-
if (!j(b)) {
5214+
var i = {}, j = a("buildConfigForBuild"), l = a("isIncompleteBuild"), m = a("isJenkinsPipelineStrategy"), n = a("isNewerResource"), o = function(a, b) {
5215+
if (!l(b)) {
52125216
c.statsByConfig[a] || (c.statsByConfig[a] = {
52135217
count:0,
52145218
totalDuration:0
52155219
});
52165220
var d = c.statsByConfig[a];
5217-
d.count++, d.totalDuration += e.getDuration(b), d.avgDuration = _.round(d.totalDuration / d.count);
5221+
d.count++, d.totalDuration += g.getDuration(b), d.avgDuration = _.round(d.totalDuration / d.count);
52185222
}
5219-
}, n = function() {
5223+
}, p = function() {
52205224
var a = {}, b = {};
5221-
c.statsByConfig = {}, _.each(g, function(d) {
5222-
if (k(d)) {
5223-
var e = h(d) || "";
5224-
c.buildConfigs[e] || (c.buildConfigs[e] = null), j(d) ? _.set(a, [ e, d.metadata.name ], d) :l(d, b[e]) && (b[e] = d), m(e, d);
5225+
c.statsByConfig = {}, _.each(i, function(d) {
5226+
if (m(d)) {
5227+
var e = j(d) || "";
5228+
c.buildConfigs[e] || (c.buildConfigs[e] = null), l(d) ? _.set(a, [ e, d.metadata.name ], d) :n(d, b[e]) && (b[e] = d), o(e, d);
52255229
}
52265230
}), _.each(b, function(b, c) {
52275231
_.set(a, [ c, b.metadata.name ], b);
52285232
}), c.interestingBuildsByConfig = a;
52295233
};
5230-
i.push(f.watch("builds", d, function(a) {
5231-
c.buildsLoaded = !0, g = a.by("metadata.name"), n();
5232-
})), i.push(f.watch("buildconfigs", d, function(a) {
5233-
c.buildConfigsLoaded = !0, c.buildConfigs = _.pick(a.by("metadata.name"), k), n();
5234+
k.push(h.watch("builds", f, function(a) {
5235+
c.buildsLoaded = !0, i = a.by("metadata.name"), p();
5236+
}));
5237+
var q = !1;
5238+
k.push(h.watch("buildconfigs", f, function(a) {
5239+
if (c.buildConfigsLoaded = !0, c.buildConfigs = _.pick(a.by("metadata.name"), m), _.isEmpty(c.buildConfigs) && !q) {
5240+
q = !0;
5241+
var b = d.SAMPLE_PIPELINE_TEMPLATE.name, f = d.SAMPLE_PIPELINE_TEMPLATE.namespace;
5242+
h.get("templates", b, {
5243+
namespace:f
5244+
}, {
5245+
errorNotification:!1
5246+
}).then(function() {
5247+
c.createSampleURL = e.fromTemplateURL(c.projectName, b, f);
5248+
});
5249+
}
5250+
p();
52345251
})), c.startBuild = function(b) {
5235-
e.startBuild(b, d).then(_.noop, function(b) {
5252+
g.startBuild(b, f).then(_.noop, function(b) {
52365253
c.alerts["start-build"] = {
52375254
type:"error",
52385255
message:"An error occurred while starting the build.",
52395256
details:a("getErrorDetails")(b)
52405257
};
52415258
});
52425259
}, c.$on("$destroy", function() {
5243-
f.unwatchAll(i);
5260+
h.unwatchAll(k);
52445261
});
52455262
}));
52465263
} ]), angular.module("openshiftConsole").controller("BuildConfigController", [ "$scope", "$filter", "$routeParams", "AlertMessageService", "APIService", "BuildsService", "ImagesService", "DataService", "LabelFilter", "ModalsService", "ProjectsService", "keyValueEditorUtils", function(a, b, c, d, e, f, g, h, i, j, k, l) {

dist/scripts/templates.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -10622,10 +10622,15 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
1062210622
"<div ng-if=\"project.metadata.name | canIAddToProject\">\n" +
1062310623
"<p>\n" +
1062410624
"No pipelines have been added to project {{projectName}}.\n" +
10625+
"<br>\n" +
10626+
"Learn more about\n" +
10627+
"<a ng-href=\"{{ 'pipeline-builds' | helpLink}}\" target=\"_blank\">Pipeline Builds</a>\n" +
10628+
"and the\n" +
10629+
"<a ng-href=\"{{ 'pipeline-plugin' | helpLink}}\" target=\"_blank\">OpenShift Pipeline Plugin</a>.\n" +
1062510630
"</p>\n" +
10626-
"<p ng-if=\"project.metadata.name | canIAddToProject\">\n" +
10627-
"<a ng-href=\"project/{{projectName}}/create\" class=\"btn btn-lg btn-primary\">\n" +
10628-
"Add to Project\n" +
10631+
"<p ng-if=\"(project.metadata.name | canIAddToProject) && createSampleURL\">\n" +
10632+
"<a ng-href=\"{{createSampleURL}}\" class=\"btn btn-lg btn-primary\">\n" +
10633+
"Create Sample Pipeline\n" +
1062910634
"</a>\n" +
1063010635
"</p>\n" +
1063110636
"</div>\n" +

0 commit comments

Comments
 (0)