-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Endpoint] task/management-details #58308
Changes from all commits
d6a3512
5c3a6e8
099c76f
c81ab1c
1828522
6aca41e
339ff58
2f4fdf2
6b56dc2
72efb8b
a395a8e
14d2086
b0133af
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { EndpointResultList } from '../../../../../common/types'; | ||
|
||
export const mockHostResultList: (options?: { | ||
total?: number; | ||
request_page_size?: number; | ||
request_page_index?: number; | ||
}) => EndpointResultList = (options = {}) => { | ||
const { | ||
total = 1, | ||
request_page_size: requestPageSize = 10, | ||
request_page_index: requestPageIndex = 0, | ||
} = options; | ||
|
||
// Skip any that are before the page we're on | ||
const numberToSkip = requestPageSize * requestPageIndex; | ||
|
||
// total - numberToSkip is the count of non-skipped ones, but return no more than a pageSize, and no less than 0 | ||
const actualCountToReturn = Math.max(Math.min(total - numberToSkip, requestPageSize), 0); | ||
|
||
const endpoints = []; | ||
for (let index = 0; index < actualCountToReturn; index++) { | ||
endpoints.push({ | ||
'@timestamp': new Date(1582231151055).toString(), | ||
event: { | ||
created: new Date('2020-02-20T20:39:11.055Z'), | ||
}, | ||
endpoint: { | ||
policy: { | ||
id: '00000000-0000-0000-0000-000000000000', | ||
}, | ||
}, | ||
agent: { | ||
version: '6.9.2', | ||
id: '9a87fdac-e6c0-4f27-a25c-e349e7093cb1', | ||
}, | ||
host: { | ||
id: '3ca26fe5-1c7d-42b8-8763-98256d161c9f', | ||
hostname: 'bea-0.example.com', | ||
ip: ['10.154.150.114', '10.43.37.62', '10.217.73.149'], | ||
mac: ['ea-5a-a8-c0-5-95', '7e-d8-fe-7f-b6-4e', '23-31-5d-af-e6-2b'], | ||
os: { | ||
name: 'windows 6.2', | ||
full: 'Windows Server 2012', | ||
version: '6.2', | ||
variant: 'Windows Server Release 2', | ||
}, | ||
}, | ||
}); | ||
} | ||
const mock: EndpointResultList = { | ||
endpoints, | ||
total, | ||
request_page_size: requestPageSize, | ||
request_page_index: requestPageIndex, | ||
}; | ||
return mock; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,9 @@ const initialState = (): ManagementListState => { | |
pageIndex: 0, | ||
total: 0, | ||
loading: false, | ||
detailsError: undefined, | ||
details: undefined, | ||
location: undefined, | ||
}; | ||
}; | ||
|
||
|
@@ -37,18 +40,30 @@ export const managementListReducer: Reducer<ManagementListState, AppAction> = ( | |
pageIndex, | ||
loading: false, | ||
}; | ||
} | ||
|
||
if (action.type === 'userExitedManagementList') { | ||
} else if (action.type === 'serverReturnedManagementDetails') { | ||
return { | ||
...state, | ||
details: action.payload, | ||
}; | ||
} else if (action.type === 'serverFailedToReturnManagementDetails') { | ||
return { | ||
...state, | ||
detailsError: action.payload, | ||
}; | ||
} else if (action.type === 'userExitedManagementList') { | ||
return initialState(); | ||
} | ||
|
||
if (action.type === 'userPaginatedManagementList') { | ||
} else if (action.type === 'userPaginatedManagementList') { | ||
return { | ||
...state, | ||
...action.payload, | ||
loading: true, | ||
}; | ||
} else if (action.type === 'userChangedUrl') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @oatkiller @paul-tavares Are we ok with copying and pasting this in all of our reducers? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @peluja1012 I don't like it either. Example:
Just a example of how it could be done - probably not in the Any other ideas/suggestions? Lets agree on an implementation design approach and then we can move forward on getting it through |
||
return { | ||
...state, | ||
location: action.payload, | ||
detailsError: undefined, | ||
}; | ||
} | ||
|
||
return state; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the API endpoint called
/endpoint/metadata
? Doesn't it return a list of hosts? @kevinlogThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@peluja1012 we talked about a couple different options here besides
/endpoint/endpoints
. One was/endpoint/hosts
. We settled on/endpoint/metadata
since the information will eventually be more than just host data and will include more data specific toendpoints