mirror of
https://github.com/fleetdm/fleet
synced 2026-05-23 08:58:41 +00:00
Special case host_name on the backend to enable frontend consistency (#318)
See #317 for followup to this.
This commit is contained in:
parent
8107128320
commit
b83fbf0ec9
4 changed files with 8 additions and 3 deletions
|
|
@ -17,7 +17,7 @@ export default (client) => {
|
|||
},
|
||||
loadAll: (page = 1, perPage = 100, selected = '') => {
|
||||
const { HOSTS, LABEL_HOSTS } = endpoints;
|
||||
const pagination = `page=${page - 1}&per_page=${perPage}&order_key=host_name`;
|
||||
const pagination = `page=${page - 1}&per_page=${perPage}&order_key=hostname`;
|
||||
|
||||
let endpoint = '';
|
||||
const labelPrefix = 'labels/';
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ describe('Kolide - API client (hosts)', () => {
|
|||
it('calls the label endpoint when used with label filter', () => {
|
||||
const request = createRequestMock({
|
||||
bearerToken,
|
||||
endpoint: '/api/v1/fleet/labels/6/hosts?page=1&per_page=50&order_key=host_name',
|
||||
endpoint: '/api/v1/fleet/labels/6/hosts?page=1&per_page=50&order_key=hostname',
|
||||
method: 'get',
|
||||
response: { hosts: [] },
|
||||
});
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ export default {
|
|||
valid: (bearerToken) => {
|
||||
return createRequestMock({
|
||||
bearerToken,
|
||||
endpoint: '/api/v1/fleet/hosts?page=0&per_page=100&order_key=host_name',
|
||||
endpoint: '/api/v1/fleet/hosts?page=0&per_page=100&order_key=hostname',
|
||||
method: 'get',
|
||||
response: { hosts: [] },
|
||||
});
|
||||
|
|
|
|||
|
|
@ -121,6 +121,11 @@ func (r listHostsResponse) error() error { return r.Err }
|
|||
func makeListHostsEndpoint(svc kolide.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
req := request.(listHostsRequest)
|
||||
// Special case this key so that the frontend can migrate to using only "hostname"
|
||||
// TODO #317 remove special cases for host_name by standardizing on hostname
|
||||
if req.ListOptions.OrderKey == "hostname" {
|
||||
req.ListOptions.OrderKey = "host_name"
|
||||
}
|
||||
hosts, err := svc.ListHosts(ctx, req.ListOptions)
|
||||
if err != nil {
|
||||
return listHostsResponse{Err: err}, nil
|
||||
|
|
|
|||
Loading…
Reference in a new issue