diff --git a/app/components/container/form-ports/template.hbs b/app/components/container/form-ports/template.hbs index 5066282ba..6e17d95b2 100644 --- a/app/components/container/form-ports/template.hbs +++ b/app/components/container/form-ports/template.hbs @@ -65,7 +65,7 @@ {{else if port.sourcePort}} {{port.sourcePort}} {{else}} - {{t 'generic.random'}} + {{t (if (eq port.kind "ClusterIP") 'formPorts.sourcePort.clusterIpDefault' 'generic.random')}} {{/if}} {{else if (eq port.kind "HostPort")}}
diff --git a/app/container/controller.js b/app/container/controller.js index 9f0b9a32d..8844dcc17 100644 --- a/app/container/controller.js +++ b/app/container/controller.js @@ -23,4 +23,10 @@ export default Controller.extend({ }); return envs; }), + + podStateDidChange: observer('model.state', function () { + if ( get(this, 'model.state') === 'removed') { + this.transitionToRoute('authenticated.project.index'); + } + }), }); diff --git a/app/container/route.js b/app/container/route.js index c183e46c7..39b96f5c6 100644 --- a/app/container/route.js +++ b/app/container/route.js @@ -3,6 +3,10 @@ import Route from '@ember/routing/route'; export default Route.extend({ model: function (params) { - return get(this, 'store').find('pod', params.container_id); + const pod = get(this, 'store').find('pod', params.container_id); + if ( !pod ) { + this.replaceWith('authenticated.project.index'); + } + return pod; }, }); diff --git a/lib/shared/addon/mixins/endpoint-ports.js b/lib/shared/addon/mixins/endpoint-ports.js index ef9223368..995bb3f31 100644 --- a/lib/shared/addon/mixins/endpoint-ports.js +++ b/lib/shared/addon/mixins/endpoint-ports.js @@ -6,7 +6,7 @@ export default Mixin.create({ displayEndpoints: function () { let parts = []; - const endpoints = (get(this, 'publicEndpoints') || []); + const endpoints = (get(this, 'publicEndpoints') || []).sort(Util.compareDisplayEndpoint); endpoints.forEach((endpoint) => { if ( !get(endpoint, 'isReady') ){ diff --git a/lib/shared/addon/utils/util.js b/lib/shared/addon/utils/util.js index d5dccb757..1a9762378 100644 --- a/lib/shared/addon/utils/util.js +++ b/lib/shared/addon/utils/util.js @@ -14,6 +14,46 @@ export function arrayIntersect(a, b) { }); } +export function compareDisplayEndpoint(i1, i2) { + if ( !i1 ) { + return 1; + } + + if ( !i2 ) { + return -1; + } + + const in1 = i1.displayEndpoint; + const in2 = i2.displayEndpoint; + if ( !in1 ) { + return 1; + } + + if ( !in2 ) { + return -1; + } + + if ( in1.startsWith('/') && !in2.startsWith('/') ) { + return -1; + } else if ( !in1.startsWith('/') && in2.startsWith('/') ) { + return 1; + } + + if ( in1 === '80/http' && in2 !== '80/http' ) { + return -1; + } else if ( in1 !== '80/http' && in2 === '80/http' ) { + return 1; + } + + if ( in1 === '443/https' && in2 !== '443/https' ) { + return -1; + } else if ( in1 !== '443/https' && in2 === '443/https' ) { + return 1; + } + + return in1.localeCompare(in2); +} + export function filterByValues(ary,field,values) { return ary.filter((obj) => { return values.includes(obj.get(field)); @@ -403,6 +443,7 @@ var Util = { addQueryParams: addQueryParams, arrayDiff: arrayDiff, arrayIntersect: arrayIntersect, + compareDisplayEndpoint: compareDisplayEndpoint, camelToTitle: camelToTitle, camelToUnderline: camelToUnderline, constructUrl: constructUrl,