Always sort consul-gateway to bottom sources list

This commit is contained in:
Michael Klein 2022-10-13 16:03:03 +02:00
parent 5ac1bc9cc0
commit f06001352a
2 changed files with 18 additions and 8 deletions

View File

@ -134,7 +134,14 @@
<BlockSlot @name='options'>
{{#let components.Option as |Option|}}
{{#if (gt @sources.length 0)}}
{{#each @sources as |source|}}
<Option
class='consul'
@value='consul'
@selected={{includes 'consul' @filter.source.value}}
>
{{t 'common.brand.consul'}}
</Option>
{{#each this.sortedSources as |source|}}
<Option
class={{source}}
@value={{source}}
@ -143,13 +150,6 @@
{{t (concat 'common.brand.' source)}}
</Option>
{{/each}}
<Option
class='consul'
@value='consul'
@selected={{includes 'consul' @filter.source.value}}
>
{{t 'common.brand.consul'}}
</Option>
{{/if}}
{{/let}}
</BlockSlot>

View File

@ -8,4 +8,14 @@ export default class ConsulServiceSearchBar extends Component {
return ['passing', 'warning', 'critical', 'empty'];
}
}
get sortedSources() {
const sources = this.args.sources || [];
if (sources.includes('consul-api-gateway')) {
return [...sources.filter((s) => s !== 'consul-api-gateway'), 'consul-api-gateway'];
} else {
return sources;
}
}
}