Skip to content

Commit 7f87b32

Browse files
author
OpenShift Bot
authored
Merge pull request #2161 from benjaminapetersen/bpetersen/trello/api-groups-create-route
Merged by openshift-bot
2 parents a188b94 + bf111da commit 7f87b32

File tree

2 files changed

+31
-27
lines changed

2 files changed

+31
-27
lines changed

app/scripts/controllers/createRoute.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ angular.module('openshiftConsole')
1313
$routeParams,
1414
$scope,
1515
$window,
16+
APIService,
1617
ApplicationGenerator,
1718
AuthorizationService,
1819
DataService,
@@ -42,6 +43,9 @@ angular.module('openshiftConsole')
4243
}
4344
];
4445

46+
var routesVersion = APIService.getPreferredVersion('routes');
47+
var servicesVersion = APIService.getPreferredVersion('services');
48+
4549
var hideErrorNotifications = function() {
4650
NotificationsService.hideNotification("create-route-error");
4751
};
@@ -57,7 +61,7 @@ angular.module('openshiftConsole')
5761
.then(_.spread(function(project, context) {
5862
$scope.project = project;
5963

60-
if (!AuthorizationService.canI('routes', 'create', $routeParams.project)) {
64+
if (!AuthorizationService.canI(routesVersion, 'create', $routeParams.project)) {
6165
Navigate.toErrorPage('You do not have authority to create routes in project ' + $routeParams.project + '.', 'access_denied');
6266
return;
6367
}
@@ -97,7 +101,7 @@ angular.module('openshiftConsole')
97101
});
98102
};
99103

100-
DataService.list("services", context).then(function(serviceData) {
104+
DataService.list(servicesVersion, context).then(function(serviceData) {
101105
servicesByName = serviceData.by("metadata.name");
102106
$scope.services = orderByDisplayName(servicesByName);
103107
// Wait until the services load before trying to copy service labels.
@@ -124,7 +128,7 @@ angular.module('openshiftConsole')
124128
});
125129
}
126130

127-
DataService.create('routes', null, route, context)
131+
DataService.create(routesVersion, null, route, context)
128132
.then(function() { // Success
129133
NotificationsService.addNotification({
130134
type: "success",

dist/scripts/scripts.js

+24-24
Original file line numberDiff line numberDiff line change
@@ -8319,7 +8319,7 @@ details: n("getErrorDetails")(t)
83198319
}
83208320
});
83218321
}));
8322-
} ]), angular.module("openshiftConsole").controller("CreateRouteController", [ "$filter", "$routeParams", "$scope", "$window", "ApplicationGenerator", "AuthorizationService", "DataService", "Navigate", "NotificationsService", "ProjectsService", "keyValueEditorUtils", function(e, t, n, a, r, o, i, s, c, l, u) {
8322+
} ]), angular.module("openshiftConsole").controller("CreateRouteController", [ "$filter", "$routeParams", "$scope", "$window", "APIService", "ApplicationGenerator", "AuthorizationService", "DataService", "Navigate", "NotificationsService", "ProjectsService", "keyValueEditorUtils", function(e, t, n, a, r, o, i, s, c, l, u, d) {
83238323
n.renderOptions = {
83248324
hideFilterWidget: !0
83258325
}, n.projectName = t.project, n.serviceName = t.service, n.labels = [], n.routing = {
@@ -8330,53 +8330,53 @@ link: "project/" + n.projectName + "/browse/routes"
83308330
}, {
83318331
title: "Create Route"
83328332
} ];
8333-
var d = function() {
8334-
c.hideNotification("create-route-error");
8333+
var p = r.getPreferredVersion("routes"), m = r.getPreferredVersion("services"), f = function() {
8334+
l.hideNotification("create-route-error");
83358335
};
8336-
n.$on("$destroy", d);
8337-
var p = function() {
8336+
n.$on("$destroy", f);
8337+
var g = function() {
83388338
a.history.back();
83398339
};
8340-
n.cancel = p, l.get(t.project).then(_.spread(function(a, l) {
8341-
if (n.project = a, o.canI("routes", "create", t.project)) {
8342-
var m, f = e("orderByDisplayName");
8340+
n.cancel = g, u.get(t.project).then(_.spread(function(a, r) {
8341+
if (n.project = a, i.canI(p, "create", t.project)) {
8342+
var u, h = e("orderByDisplayName");
83438343
n.routing.to = {
83448344
kind: "Service",
83458345
name: n.serviceName,
83468346
weight: 1
83478347
};
8348-
var g, h = function() {
8349-
var e = g, t = _.get(n, "routing.to.name");
8350-
g = _.get(m, [ t, "metadata", "labels" ], {});
8351-
var a = u.mapEntries(u.compactEntries(n.labels)), r = _.assign(a, g);
8348+
var v, y = function() {
8349+
var e = v, t = _.get(n, "routing.to.name");
8350+
v = _.get(u, [ t, "metadata", "labels" ], {});
8351+
var a = d.mapEntries(d.compactEntries(n.labels)), r = _.assign(a, v);
83528352
e && (r = _.omitBy(r, function(t, n) {
8353-
return e[n] && !g[n];
8353+
return e[n] && !v[n];
83548354
})), n.labels = _.map(r, function(e, t) {
83558355
return {
83568356
name: t,
83578357
value: e
83588358
};
83598359
});
83608360
};
8361-
i.list("services", l).then(function(e) {
8362-
m = e.by("metadata.name"), n.services = f(m), n.$watch("routing.to.name", h);
8361+
s.list(m, r).then(function(e) {
8362+
u = e.by("metadata.name"), n.services = h(u), n.$watch("routing.to.name", y);
83638363
}), n.createRoute = function() {
83648364
if (n.createRouteForm.$valid) {
8365-
d(), n.disableInputs = !0;
8366-
var t = n.routing.to.name, a = u.mapEntries(u.compactEntries(n.labels)), o = r.createRoute(n.routing, t, a), s = _.get(n, "routing.alternateServices", []);
8367-
_.isEmpty(s) || (o.spec.to.weight = _.get(n, "routing.to.weight"), o.spec.alternateBackends = _.map(s, function(e) {
8365+
f(), n.disableInputs = !0;
8366+
var t = n.routing.to.name, a = d.mapEntries(d.compactEntries(n.labels)), i = o.createRoute(n.routing, t, a), c = _.get(n, "routing.alternateServices", []);
8367+
_.isEmpty(c) || (i.spec.to.weight = _.get(n, "routing.to.weight"), i.spec.alternateBackends = _.map(c, function(e) {
83688368
return {
83698369
kind: "Service",
83708370
name: e.name,
83718371
weight: e.weight
83728372
};
8373-
})), i.create("routes", null, o, l).then(function() {
8374-
c.addNotification({
8373+
})), s.create(p, null, i, r).then(function() {
8374+
l.addNotification({
83758375
type: "success",
8376-
message: "Route " + o.metadata.name + " was successfully created."
8377-
}), p();
8376+
message: "Route " + i.metadata.name + " was successfully created."
8377+
}), g();
83788378
}, function(t) {
8379-
n.disableInputs = !1, c.addNotification({
8379+
n.disableInputs = !1, l.addNotification({
83808380
type: "error",
83818381
id: "create-route-error",
83828382
message: "An error occurred creating the route.",
@@ -8385,7 +8385,7 @@ details: e("getErrorDetails")(t)
83858385
});
83868386
}
83878387
};
8388-
} else s.toErrorPage("You do not have authority to create routes in project " + t.project + ".", "access_denied");
8388+
} else c.toErrorPage("You do not have authority to create routes in project " + t.project + ".", "access_denied");
83898389
}));
83908390
} ]), angular.module("openshiftConsole").controller("AttachPVCController", [ "$filter", "$routeParams", "$scope", "$window", "APIService", "AuthorizationService", "BreadcrumbsService", "DataService", "QuotaService", "Navigate", "NotificationsService", "ProjectsService", "StorageService", "RELATIVE_PATH_PATTERN", function(e, t, n, a, r, o, i, s, c, l, u, d, p, m) {
83918391
if (t.kind && t.name) {

0 commit comments

Comments
 (0)