Merge pull request #14973 from hashicorp/ui/chore/consol-api-gateway-bottom-sources-filter

ui: Always sort consul-gateway to bottom sources list
This commit is contained in:
Michael Klein 2022-10-13 18:34:45 +02:00 committed by GitHub
commit 3872a36d93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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;
}
}
}