ui: add peers to node search (#13875)

* Make nodes searchable by peer

* fix only surface peer filter on service search when feature is on
This commit is contained in:
Michael Klein 2022-07-25 18:46:47 +02:00 committed by GitHub
parent dfd50d68ed
commit f7f26220ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 28 additions and 5 deletions

View File

@ -0,0 +1,16 @@
import Controller from '@ember/controller';
import { inject as service } from '@ember/service';
export default class PeeredResourceController extends Controller {
@service abilities;
get _searchProperties() {
const { searchProperties } = this;
if (!this.abilities.can('use peers')) {
return searchProperties.filter(propertyName => propertyName !== 'PeerName');
} else {
return searchProperties;
}
}
}

View File

@ -0,0 +1,3 @@
import PeeredResourceController from 'consul-ui/controllers/_peered-resource';
export default class DcNodesController extends PeeredResourceController {}

View File

@ -0,0 +1,3 @@
import PeeredResourceController from 'consul-ui/controllers/_peered-resource';
export default class DcServicesController extends PeeredResourceController {}

View File

@ -1,5 +1,6 @@
export default {
Node: item => item.Node,
Address: item => item.Address,
PeerName: item => item.PeerName,
Meta: item => Object.entries(item.Meta || {}).reduce((prev, entry) => prev.concat(entry), []),
};

View File

@ -44,10 +44,10 @@ as |route|>
searchproperty=(hash
value=(if (not-eq searchproperty undefined)
(split searchproperty ',')
searchProperties
this._searchProperties
)
change=(action (mut searchproperty) value="target.selectedItems")
default=searchProperties
default=this._searchProperties
)
)

View File

@ -43,10 +43,10 @@ as |route|>
searchproperty=(hash
value=(if (not-eq searchproperty undefined)
(split searchproperty ',')
searchProperties
this._searchProperties
)
change=(action (mut searchproperty) value="target.selectedItems")
default=searchProperties
default=this._searchProperties
)
)

View File

@ -215,7 +215,7 @@
status: 'status',
searchproperty: {
as: 'searchproperty',
empty: [['Node', 'Address', 'Meta']],
empty: [['Node', 'Address', 'Meta', 'PeerName']],
},
search: {
as: 'filter',