Send platform parameter when creating labels (#1179)

* Catches errors when polling for data on Manage Hosts Page

* Sends platform parameter to server on label create

* Remove unnecessary condition to format platform param

* Clean up scheduled query formData
This commit is contained in:
Mike Stone
2017-02-07 13:37:41 -05:00
committed by GitHub
parent e60a732c48
commit 3120acf8f3
6 changed files with 12 additions and 12 deletions
@@ -11,7 +11,7 @@ import validate from 'components/forms/ConfigurePackQueryForm/validate';
const baseClass = 'configure-pack-query-form';
const fieldNames = ['query_id', 'interval', 'logging_type', 'platform', 'shard', 'version'];
const platformOptions = [
{ label: 'All', value: 'all' },
{ label: 'All', value: '' },
{ label: 'Windows', value: 'windows' },
{ label: 'Linux', value: 'linux' },
{ label: 'macOS', value: 'darwin' },
@@ -46,7 +46,7 @@ describe('ConfigurePackQueryForm - component', () => {
expect(spy).toHaveBeenCalledWith({
interval: 123,
logging_type: 'differential',
platform: 'all',
platform: '',
query_id: 1,
version: '',
shard: 12,
+2 -2
View File
@@ -69,10 +69,10 @@ class Kolide extends Base {
}
labels = {
create: ({ description, name, query }) => {
create: ({ description, name, platform, query }) => {
const { LABELS } = endpoints;
return this.authenticatedPost(this.endpoint(LABELS), JSON.stringify({ description, name, query }))
return this.authenticatedPost(this.endpoint(LABELS), JSON.stringify({ description, name, platform, query }))
.then((response) => {
const { label } = response;
+2 -1
View File
@@ -83,8 +83,9 @@ describe('Kolide - API client', () => {
it('calls the appropriate endpoint with the correct parameters', (done) => {
const description = 'label description';
const name = 'label name';
const platform = 'windows';
const query = 'SELECT * FROM users';
const labelParams = { description, name, query };
const labelParams = { description, name, platform, query };
const request = validCreateLabelRequest(bearerToken, labelParams);
Kolide.setBearerToken(bearerToken);
@@ -83,9 +83,12 @@ export class ManageHostsPage extends Component {
componentDidMount () {
const { dispatch } = this.props;
const getEntities = () => {
dispatch(hostActions.silentLoadAll());
dispatch(labelActions.silentLoadAll());
dispatch(silentGetStatusLabelCounts);
dispatch(hostActions.silentLoadAll())
.catch(() => false);
dispatch(labelActions.silentLoadAll())
.catch(() => false);
dispatch(silentGetStatusLabelCounts)
.catch(() => false);
};
this.interval = global.window.setInterval(getEntities, 5000);
@@ -160,10 +160,6 @@ export class EditPackPage extends Component {
}
handleConfigurePackQuerySubmit = (formData) => {
if (formData.platform.indexOf('all') !== -1) {
formData.platform = '';
}
const { create } = scheduledQueryActions;
const { dispatch, packID } = this.props;
const scheduledQueryData = {