Browse Source

ui: add peers to node search (#13875)

* Make nodes searchable by peer

* fix only surface peer filter on service search when feature is on
pull/13888/head
Michael Klein 2 years ago committed by GitHub
parent
commit
f7f26220ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      ui/packages/consul-ui/app/controllers/_peered-resource.js
  2. 3
      ui/packages/consul-ui/app/controllers/dc/nodes/index.js
  3. 3
      ui/packages/consul-ui/app/controllers/dc/services/index.js
  4. 1
      ui/packages/consul-ui/app/search/predicates/node.js
  5. 4
      ui/packages/consul-ui/app/templates/dc/nodes/index.hbs
  6. 4
      ui/packages/consul-ui/app/templates/dc/services/index.hbs
  7. 2
      ui/packages/consul-ui/vendor/consul-ui/routes.js

16
ui/packages/consul-ui/app/controllers/_peered-resource.js

@ -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;
}
}
}

3
ui/packages/consul-ui/app/controllers/dc/nodes/index.js

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

3
ui/packages/consul-ui/app/controllers/dc/services/index.js

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

1
ui/packages/consul-ui/app/search/predicates/node.js

@ -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), []),
};

4
ui/packages/consul-ui/app/templates/dc/nodes/index.hbs

@ -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
)
)

4
ui/packages/consul-ui/app/templates/dc/services/index.hbs

@ -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
)
)

2
ui/packages/consul-ui/vendor/consul-ui/routes.js vendored

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

Loading…
Cancel
Save