Merge pull request #1971 from loganhz/fix3

Fix remove pod issue and sort display endpoints
This commit is contained in:
Westly Wright 2018-06-18 10:04:59 -07:00 committed by GitHub
commit 35edfc63a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 54 additions and 3 deletions

View File

@ -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")}}
<div class="row">

View File

@ -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');
}
}),
});

View File

@ -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;
},
});

View File

@ -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') ){

View File

@ -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,