mirror of https://github.com/rancher/ui.git
Prioritize display endpoints
https://github.com/rancher/rancher/issues/13694
This commit is contained in:
parent
b0363bb03b
commit
ce867bcbe9
|
|
@ -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') ){
|
||||
|
|
|
|||
|
|
@ -13,6 +13,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));
|
||||
|
|
@ -352,6 +392,7 @@ var Util = {
|
|||
addQueryParams: addQueryParams,
|
||||
arrayDiff: arrayDiff,
|
||||
arrayIntersect: arrayIntersect,
|
||||
compareDisplayEndpoint: compareDisplayEndpoint,
|
||||
camelToTitle: camelToTitle,
|
||||
constructUrl: constructUrl,
|
||||
download: download,
|
||||
|
|
|
|||
Loading…
Reference in New Issue