Expose a getOrderedManagers() function for use elsewhere
This commit is contained in:
parent
8493887ceb
commit
470295ad14
1 changed files with 18 additions and 12 deletions
|
@ -144,10 +144,8 @@ export class IntegrationManagers {
|
||||||
return this._managers.length > 0;
|
return this._managers.length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
getPrimaryManager(): IntegrationManagerInstance {
|
getOrderedManagers(): IntegrationManagerInstance[] {
|
||||||
if (this.hasManager()) {
|
const ordered = [];
|
||||||
if (this._primaryManager) return this._primaryManager;
|
|
||||||
|
|
||||||
for (const kind of KIND_PREFERENCE) {
|
for (const kind of KIND_PREFERENCE) {
|
||||||
const managers = this._managers.filter(m => m.kind === kind);
|
const managers = this._managers.filter(m => m.kind === kind);
|
||||||
if (!managers || !managers.length) continue;
|
if (!managers || !managers.length) continue;
|
||||||
|
@ -157,9 +155,17 @@ export class IntegrationManagers {
|
||||||
managers.sort((a, b) => a.id.localeCompare(b.id));
|
managers.sort((a, b) => a.id.localeCompare(b.id));
|
||||||
}
|
}
|
||||||
|
|
||||||
this._primaryManager = managers[0];
|
ordered.push(...managers);
|
||||||
return this._primaryManager;
|
|
||||||
}
|
}
|
||||||
|
return ordered;
|
||||||
|
}
|
||||||
|
|
||||||
|
getPrimaryManager(): IntegrationManagerInstance {
|
||||||
|
if (this.hasManager()) {
|
||||||
|
if (this._primaryManager) return this._primaryManager;
|
||||||
|
|
||||||
|
this._primaryManager = this.getOrderedManagers()[0];
|
||||||
|
return this._primaryManager;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue