Skip to content

Commit

Permalink
Beats/update (elastic#21702)
Browse files Browse the repository at this point in the history
* [ML] Fixing issue with historical job audit messages (elastic#21718)

* Add proper aria-label for close inspector (elastic#21719)

* [Beats Management] Initial scaffolding for plugin (elastic#18977)

* Initial scaffolding for Beats plugin

* Removing bits not (yet) necessary in initial scaffolding

* [Beats Management] Install Beats index template on plugin init (elastic#19072)

* Install Beats index template on plugin init

* Adding missing files

* [Beats Management] APIs: Create enrollment tokens (elastic#19018)

* WIP checkin

* Register API routes

* Fixing typo in index name

* Adding TODOs

* Removing commented out license checking code that isn't yet implemented

* Remove unnecessary async/await

* Don't return until indices have been refreshed

* Add API integration test

* Converting to Jest test

* Fixing API for default case + adding test for it

* Fixing copy pasta typos

* Adding TODO

* Fixing variable name

* Using a single index

* Adding expiration date field

* Adding test for expiration date field

* Ignore non-existent index

* Fixing logic in test

* Creating constant for default enrollment tokens TTL value

* Updating test

* Fixing name of test file (elastic#19100)

* [Beats Management] APIs: Enroll beat (elastic#19056)

* WIP checkin

* Add API integration test

* Converting to Jest test

* Create API for enrolling a beat

* Handle invalid or expired enrollment tokens

* Use create instead of index to prevent same beat from being enrolled twice

* Adding unit test for duplicate beat enrollment

* Do not persist enrollment token with beat once token has been checked and used

* Fix datatype of host_ip field

* Make Kibana API guess host IP instead of requiring it in payload

* Fixing error introduced in rebase conflict resolution

* [Beats Management] APIs: List beats (elastic#19086)

* WIP checkin

* Add API integration test

* Converting to Jest test

* WIP checkin

* Fixing API for default case + adding test for it

* Fixing copy pasta typos

* Fixing variable name

* Using a single index

* Implementing GET /api/beats/agents API

* Updating mapping

* [Beats Management] APIs: Verify beats (elastic#19103)

* WIP checkin

* WIP checkin

* Add API integration test

* Converting to Jest test

* Fixing API for default case + adding test for it

* Fixing copy pasta typos

* Fixing variable name

* Using a single index

* Implementing GET /api/beats/agents API

* Creating POST /api/beats/agents/verify API

* Refactoring: extracting out helper functions

* Fleshing out remaining tests

* Expanding TODO note so I won't forget :)

* Fixing file name

* Updating mapping

* Moving TODO comment to right file

* Rename determine* helper functions to find*

* Fixing assertions (elastic#19194)

* [Beats Management] APIs: Update beat (elastic#19148)

* WIP checkin

* WIP checkin

* Add API integration test

* Converting to Jest test

* Fixing API for default case + adding test for it

* Fixing copy pasta typos

* Fixing variable name

* Using a single index

* Implementing GET /api/beats/agents API

* Creating POST /api/beats/agents/verify API

* Refactoring: extracting out helper functions

* Expanding TODO note so I won't forget :)

* Fixing file name

* Updating mapping

* Add API tests

* Update template to allow version field for beat

* Implement PUT /api/beats/agent/{beat ID} API

* Make enroll beat code consistent with update beat code

* Fixing minor typo in TODO comment

* Allow version in request payload

* Make sure beat is not updated in ES in error scenarios

* Adding version as required field in Enroll Beat API payload

* Using destructuring

* Fixing rename that was accidentally reversed in conflict fixing

* [Beats Management] APIs: take auth tokens via headers (elastic#19210)

* WIP checkin

* WIP checkin

* Add API integration test

* Converting to Jest test

* Fixing API for default case + adding test for it

* Fixing copy pasta typos

* Fixing variable name

* Using a single index

* Implementing GET /api/beats/agents API

* Creating POST /api/beats/agents/verify API

* Refactoring: extracting out helper functions

* Expanding TODO note so I won't forget :)

* Fixing file name

* Updating mapping

* Fixing minor typo in TODO comment

* Make "Enroll Beat" API take enrollment token via header instead of request body

* Make "Update Beat" API take access token via header instead of request body

* [Beats Management] APIs: Create configuration block (elastic#19270)

* WIP checkin

* WIP checkin

* Add API integration test

* Converting to Jest test

* Fixing API for default case + adding test for it

* Fixing copy pasta typos

* Fixing variable name

* Using a single index

* Implementing GET /api/beats/agents API

* Creating POST /api/beats/agents/verify API

* Refactoring: extracting out helper functions

* Expanding TODO note so I won't forget :)

* Fixing file name

* Updating mapping

* Fixing minor typo in TODO comment

* Implementing POST /api/beats/configuration_blocks API

* Removing unnecessary escaping

* Fleshing out types + adding validation for them

* Making output singular (was outputs)

* Removing metricbeat.inputs

* Revert implementation of `POST /api/beats/configuration_blocks` API (elastic#19340)

This API allowed the user to operate at a level of abstraction that is unnecessarily and dangerously too low. A better API would be at one level higher, where users can create, update, and delete tags (where a tag can contain multiple configuration blocks).

* [Beats Management] APIs: Create or update tag (elastic#19342)

* Updating mappings

* Implementing PUT /api/beats/tag/{tag} API

* [Beats Management] Prevent timing attacks when checking auth tokens (elastic#19363)

* Using crypto.timingSafeEqual() for comparing auth tokens

* Prevent subtler timing attack in token comparison function

* Introduce random delay after we try to find token in ES to mitigate timing attack

* Remove random delay

* [Beats Management] APIs: Assign tag(s) to beat(s) (elastic#19431)

* Using crypto.timingSafeEqual() for comparing auth tokens

* Introduce random delay after we try to find token in ES to mitigate timing attack

* Rename "determine" to "find"

* Remove random delay

* Starting to implement POST /api/beats/beats_tags API

* Changing API

* Updating tests for changes to API

* Updating ES archive

* Renaming

* Use destructuring

* Moving start of script to own line to increase readability

* Using destructuring

* [Beats Management] APIs: Remove tag(s) from beat(s) (elastic#19440)

* Using crypto.timingSafeEqual() for comparing auth tokens

* Introduce random delay after we try to find token in ES to mitigate timing attack

* Remove random delay

* Starting to implement POST /api/beats/beats_tags API

* Changing API

* Updating tests for changes to API

* Renaming

* Use destructuring

* Using crypto.timingSafeEqual() for comparing auth tokens

* Introduce random delay after we try to find token in ES to mitigate timing attack

* Implementing `POST /api/beats/agents_tags/removals` API

* Updating ES archive

* Use destructuring

* Moving start of script to own line to increase readability

* Nothing to remove if there are no existing tags!

* Updating tests to match changes in bulk update painless script

* Use destructuring

* [Beats Management] Move to Ingest UI arch and initial TS effort (elastic#20039)

* [Beats Management] Initial scaffolding for plugin (elastic#18977)

* Initial scaffolding for Beats plugin

* Removing bits not (yet) necessary in initial scaffolding

* [Beats Management] Install Beats index template on plugin init (elastic#19072)

* Install Beats index template on plugin init

* Adding missing files

* [Beats Management] APIs: Create enrollment tokens (elastic#19018)

* WIP checkin

* Register API routes

* Fixing typo in index name

* Adding TODOs

* Removing commented out license checking code that isn't yet implemented

* Remove unnecessary async/await

* Don't return until indices have been refreshed

* Add API integration test

* Converting to Jest test

* Fixing API for default case + adding test for it

* Fixing copy pasta typos

* Adding TODO

* Fixing variable name

* Using a single index

* Adding expiration date field

* Adding test for expiration date field

* Ignore non-existent index

* Fixing logic in test

* Creating constant for default enrollment tokens TTL value

* Updating test

* Fixing name of test file (elastic#19100)

* [Beats Management] APIs: Enroll beat (elastic#19056)

* WIP checkin

* Add API integration test

* Converting to Jest test

* Create API for enrolling a beat

* Handle invalid or expired enrollment tokens

* Use create instead of index to prevent same beat from being enrolled twice

* Adding unit test for duplicate beat enrollment

* Do not persist enrollment token with beat once token has been checked and used

* Fix datatype of host_ip field

* Make Kibana API guess host IP instead of requiring it in payload

* Fixing error introduced in rebase conflict resolution

* [Beats Management] APIs: List beats (elastic#19086)

* WIP checkin

* Add API integration test

* Converting to Jest test

* WIP checkin

* Fixing API for default case + adding test for it

* Fixing copy pasta typos

* Fixing variable name

* Using a single index

* Implementing GET /api/beats/agents API

* Updating mapping

* [Beats Management] APIs: Verify beats (elastic#19103)

* WIP checkin

* WIP checkin

* Add API integration test

* Converting to Jest test

* Fixing API for default case + adding test for it

* Fixing copy pasta typos

* Fixing variable name

* Using a single index

* Implementing GET /api/beats/agents API

* Creating POST /api/beats/agents/verify API

* Refactoring: extracting out helper functions

* Fleshing out remaining tests

* Expanding TODO note so I won't forget :)

* Fixing file name

* Updating mapping

* Moving TODO comment to right file

* Rename determine* helper functions to find*

* Fixing assertions (elastic#19194)

* [Beats Management] APIs: Update beat (elastic#19148)

* WIP checkin

* WIP checkin

* Add API integration test

* Converting to Jest test

* Fixing API for default case + adding test for it

* Fixing copy pasta typos

* Fixing variable name

* Using a single index

* Implementing GET /api/beats/agents API

* Creating POST /api/beats/agents/verify API

* Refactoring: extracting out helper functions

* Expanding TODO note so I won't forget :)

* Fixing file name

* Updating mapping

* Add API tests

* Update template to allow version field for beat

* Implement PUT /api/beats/agent/{beat ID} API

* Make enroll beat code consistent with update beat code

* Fixing minor typo in TODO comment

* Allow version in request payload

* Make sure beat is not updated in ES in error scenarios

* Adding version as required field in Enroll Beat API payload

* Using destructuring

* Fixing rename that was accidentally reversed in conflict fixing

* [Beats Management] APIs: take auth tokens via headers (elastic#19210)

* WIP checkin

* WIP checkin

* Add API integration test

* Converting to Jest test

* Fixing API for default case + adding test for it

* Fixing copy pasta typos

* Fixing variable name

* Using a single index

* Implementing GET /api/beats/agents API

* Creating POST /api/beats/agents/verify API

* Refactoring: extracting out helper functions

* Expanding TODO note so I won't forget :)

* Fixing file name

* Updating mapping

* Fixing minor typo in TODO comment

* Make "Enroll Beat" API take enrollment token via header instead of request body

* Make "Update Beat" API take access token via header instead of request body

* [Beats Management] APIs: Create configuration block (elastic#19270)

* WIP checkin

* WIP checkin

* Add API integration test

* Converting to Jest test

* Fixing API for default case + adding test for it

* Fixing copy pasta typos

* Fixing variable name

* Using a single index

* Implementing GET /api/beats/agents API

* Creating POST /api/beats/agents/verify API

* Refactoring: extracting out helper functions

* Expanding TODO note so I won't forget :)

* Fixing file name

* Updating mapping

* Fixing minor typo in TODO comment

* Implementing POST /api/beats/configuration_blocks API

* Removing unnecessary escaping

* Fleshing out types + adding validation for them

* Making output singular (was outputs)

* Removing metricbeat.inputs

* Revert implementation of `POST /api/beats/configuration_blocks` API (elastic#19340)

This API allowed the user to operate at a level of abstraction that is unnecessarily and dangerously too low. A better API would be at one level higher, where users can create, update, and delete tags (where a tag can contain multiple configuration blocks).

* [Beats Management] APIs: Create or update tag (elastic#19342)

* Updating mappings

* Implementing PUT /api/beats/tag/{tag} API

* [Beats Management] Prevent timing attacks when checking auth tokens (elastic#19363)

* Using crypto.timingSafeEqual() for comparing auth tokens

* Prevent subtler timing attack in token comparison function

* Introduce random delay after we try to find token in ES to mitigate timing attack

* Remove random delay

* [Beats Management] APIs: Assign tag(s) to beat(s) (elastic#19431)

* Using crypto.timingSafeEqual() for comparing auth tokens

* Introduce random delay after we try to find token in ES to mitigate timing attack

* Rename "determine" to "find"

* Remove random delay

* Starting to implement POST /api/beats/beats_tags API

* Changing API

* Updating tests for changes to API

* Updating ES archive

* Renaming

* Use destructuring

* Moving start of script to own line to increase readability

* Using destructuring

* [Beats Management] APIs: Remove tag(s) from beat(s) (elastic#19440)

* Using crypto.timingSafeEqual() for comparing auth tokens

* Introduce random delay after we try to find token in ES to mitigate timing attack

* Remove random delay

* Starting to implement POST /api/beats/beats_tags API

* Changing API

* Updating tests for changes to API

* Renaming

* Use destructuring

* Using crypto.timingSafeEqual() for comparing auth tokens

* Introduce random delay after we try to find token in ES to mitigate timing attack

* Implementing `POST /api/beats/agents_tags/removals` API

* Updating ES archive

* Use destructuring

* Moving start of script to own line to increase readability

* Nothing to remove if there are no existing tags!

* Updating tests to match changes in bulk update painless script

* Use destructuring

* Ported over base types and arch structure

* move management of installIndexTemplate into the framework adapter

* ts-lint fix

* tslint fixes

* more ts tweaks

* fix paths

* added several working endpoints

* add more routes and bug fixes

* fix linting

* fix type remove CRUFT

* remove more cruft

* remove more CRUFT

* added comments, change plurality

* add tsconfig file

* add extends path

* fixed typo

* serveral PR review fixes

* fixed lodash type version

* “fix” types by applying a lot of any

* [Beats Management] Move tokens to use JWT, add more complete test suite (elastic#20317)

* inital effort to move to JWT and added jest based tests on libs

* assign beats tests all passing

* token tests now pass

* add more tests

* all tests now green

* fix broken test, this is beats CM not logstash 😊

* added readme

* move enrollment token back to a hash

* remove un-needed comment

* alias lodash get to avoid confusion

* isolated hash creation

* [Beats Management] add more tests, update types, break out ES into it's own adapter (elastic#20566)

* inital effort to move to JWT and added jest based tests on libs

* assign beats tests all passing

* token tests now pass

* add more tests

* all tests now green

* move enrollment token back to a hash

* remove un-needed comment

* alias lodash get to avoid confusion

* isolated hash creation

* Add initial efforts for backend framework adapter testing

* move ES code to a DatabaseAdapter from BackendAdapter and add a TON of types for ES

* re-typed

* renamed types to match pattern

* aditional renames

* adapter tests should always just use adapterSetup();

* database now uses InternalRequest

* corrected spelling of framework

* fix typings

* remove CRUFT

* RequestOrInternal

* Dont pass around request objects everywhere, just pass the user. Also, removed hapi types as they were not compatible

* fix tests, add test, removed extra comment

* fix auth

* updated lock file

* [Beats Management] add get beat endpoint (elastic#20603)

* [Beats Management] Move tokens to use JWT, add more complete test suite (elastic#20317)

* inital effort to move to JWT and added jest based tests on libs

* assign beats tests all passing

* token tests now pass

* add more tests

* all tests now green

* fix broken test, this is beats CM not logstash 😊

* added readme

* move enrollment token back to a hash

* remove un-needed comment

* alias lodash get to avoid confusion

* isolated hash creation

* inital effort to move to JWT and added jest based tests on libs

* assign beats tests all passing

* token tests now pass

* add more tests

* all tests now green

* move enrollment token back to a hash

* remove un-needed comment

* alias lodash get to avoid confusion

* isolated hash creation

* Add initial efforts for backend framework adapter testing

* move ES code to a DatabaseAdapter from BackendAdapter and add a TON of types for ES

* re-typed

* renamed types to match pattern

* aditional renames

* adapter tests should always just use adapterSetup();

* database now uses InternalRequest

* corrected spelling of framework

* fix typings

* remove CRUFT

* RequestOrInternal

* Dont pass around request objects everywhere, just pass the user. Also, removed hapi types as they were not compatible

* fix tests, add test, removed extra comment

* Moved critical path code from route, to more easeley tested domain

* fix auth

* remove beat verification, added get beat endpoint to return configs

* fix type

* update createGetBeatConfigurationRoute URL

* rename method

* update to match PR elastic#20566

* updated lock file

* fix bad merge

* update TSLinting

* fix bad rebase

* [Beats Management] [WIP] Create public resources for management plugin (elastic#20864)

* Init plugin public resources.

* rename beats to beats_management

* rendering react now

* Beats/initial ui (elastic#20994)

* initial layout and main nav

* modal UI and pattern for UI established

* fix path

* wire up in-memroy adapters

* tweak adapters

* add getAll method to tags adapter (elastic#21287)

* Beats/real adapters (elastic#21481)

* add initial real adapters, and nulled data where we need endpoints

* UI adapters and needed endpoints added (though not tested)

* prep for route tests and some cleanup

* move files

* [Beats Management] Add BeatsTable/Bulk Action Search Component (elastic#21182)

* Add BeatsTable and control bar components.

* Clean yarn.lock.

* Move raw numbers/strings to constants. Remove obsolete state/props.

* Update/add tests.

* Change prop name from "items" to "beats".

* Rename some variables.

* Move search bar filter definitions to table render.

* Update table to support assignment options.

* Update action control position.

* Refactor split render function into custom components.

* Beats/basic use cases (elastic#21660)

* tweak adapter responses / types. re-add enroll ui

* routes enabled, enroll now pings the server

* full enrollment path now working

* improved pinging for beat enrollment

* fix location of history call

* reload beats list on beat enrollment completion

* add update on client side, expand update on server to allow for partial data, and user auth

* remove double beat lookup

* fix tests

* only return active beats

* disenroll now working

* fig getAll query

* re-enrolling a beat will now work

* fix types

* fix types

* update deps

* update kibana API for version
  • Loading branch information
mattapperson committed Aug 15, 2018
1 parent 5cd1013 commit 424ae6a
Show file tree
Hide file tree
Showing 6 changed files with 228 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export class Table extends React.Component<BeatsTableProps, BeatsTableState> {
};

public render() {

const {
actionHandler,
assignmentOptions,
Expand Down
73 changes: 32 additions & 41 deletions x-pack/plugins/beats_management/public/pages/main/beats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from '@elastic/eui';

import React from 'react';
import { BeatTag, CMPopulatedBeat } from '../../../common/domain_types';
import { BeatTag, CMBeat, CMPopulatedBeat } from '../../../common/domain_types';
import { BeatsTagAssignment } from '../../../server/lib/adapters/beats/adapter_types';
import { BeatsTableType, Table } from '../../components/table';
import { FrontendLibs } from '../../lib/lib';
Expand All @@ -23,19 +23,19 @@ interface BeatsPageProps {
}

interface BeatsPageState {
beats: CMPopulatedBeat[];
beats: CMBeat[];
tableRef: any;
tags: any[] | null;
}

export class BeatsPage extends React.PureComponent<BeatsPageProps, BeatsPageState> {
public static ActionArea = BeatsActionArea;
private tableRef = React.createRef<Table>();

constructor(props: BeatsPageProps) {
super(props);

this.state = {
beats: [],
tableRef: React.createRef(),
tags: null,
};

Expand All @@ -51,32 +51,9 @@ export class BeatsPage extends React.PureComponent<BeatsPageProps, BeatsPageStat
<Table
actionHandler={this.handleBeatsActions}
assignmentOptions={this.state.tags}
renderAssignmentOptions={(tag: BeatTag) => {
const selectedBeats = this.getSelectedBeats();
const hasMatches = selectedBeats.some((beat: any) =>
(beat.tags || []).some((t: string) => t === tag.id)
);

return (
<EuiFlexItem key={`${tag.id}-${hasMatches ? 'matched' : 'unmatched'}`}>
<EuiBadge
color={tag.color}
iconType={hasMatches ? 'cross' : undefined}
onClick={
hasMatches
? () => this.removeTagsFromBeats(selectedBeats, tag)
: () => this.assignTagsToBeats(selectedBeats, tag)
}
onClickAriaLabel={tag.id}
>
{tag.id}
</EuiBadge>
</EuiFlexItem>
);
}}
assignmentTitle="Set tags"
items={this.state.beats || []}
ref={this.tableRef}
ref={this.state.tableRef}
showAssignmentOptions={true}
type={BeatsTableType}
/>
Expand Down Expand Up @@ -111,9 +88,6 @@ export class BeatsPage extends React.PureComponent<BeatsPageProps, BeatsPageStat
// the max race condition time is really 10ms but doing 100 to be safe
setTimeout(async () => {
await this.loadBeats();
if (this.tableRef && this.tableRef.current) {
this.tableRef.current.resetSelection();
}
}, 100);
};

Expand All @@ -124,16 +98,39 @@ export class BeatsPage extends React.PureComponent<BeatsPageProps, BeatsPageStat
});
}

// TODO: add reference to ES filter endpoint
// todo: add reference to ES filter endpoint
private handleSearchQuery = (query: any) => {
// await this.props.libs.beats.searach(query);
};

private loadTags = async () => {
const tags = await this.props.libs.tags.getAll();
const selectedBeats = this.getSelectedBeats();

const renderedTags = tags.map((tag: BeatTag) => {
const hasMatches = selectedBeats.some((beat: any) =>
beat.full_tags.some((t: any) => t.id === tag.id)
);

return (
<EuiFlexItem key={tag.id}>
<EuiBadge
color={tag.color}
iconType={hasMatches ? 'cross' : undefined}
onClick={
hasMatches
? () => this.removeTagsFromBeats(selectedBeats, tag)
: () => this.assignTagsToBeats(selectedBeats, tag)
}
onClickAriaLabel={tag.id}
>
{tag.id}
</EuiBadge>
</EuiFlexItem>
);
});
this.setState({
tags,
tags: renderedTags,
});
};

Expand All @@ -149,16 +146,10 @@ export class BeatsPage extends React.PureComponent<BeatsPageProps, BeatsPageStat

private assignTagsToBeats = async (beats: CMPopulatedBeat[], tag: BeatTag) => {
await this.props.libs.beats.assignTagsToBeats(this.createBeatTagAssignments(beats, tag));
await this.loadBeats();
await this.loadTags();
this.loadBeats();
};

private getSelectedBeats = (): CMPopulatedBeat[] => {
if (this.tableRef && this.tableRef.current) {
return this.tableRef.current.state.selection.map(
(beat: CMPopulatedBeat) => this.state.beats.find(b => b.id === beat.id) || beat
);
}
return [];
return this.state.tableRef.current.state.selection;
};
}
53 changes: 10 additions & 43 deletions x-pack/plugins/beats_management/public/pages/main/tags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import {
EuiButton,
EuiButtonEmpty,
EuiFlexGroup,
EuiFlexItem,
EuiIcon,
// @ts-ignore EuiToolTip has no typings in current version
EuiToolTip,
} from '@elastic/eui';

// @ts-ignore EuiToolTip has no typings in current version
import { EuiButtonEmpty, EuiFlexGroup, EuiFlexItem, EuiIcon, EuiToolTip } from '@elastic/eui';
import React from 'react';
import { BeatTag, CMBeat } from '../../../common/domain_types';
import { BeatsTagAssignment } from '../../../server/lib/adapters/beats/adapter_types';
Expand All @@ -25,27 +19,17 @@ interface TagsPageProps {

interface TagsPageState {
beats: any;
tableRef: any;
tags: BeatTag[];
}

export class TagsPage extends React.PureComponent<TagsPageProps, TagsPageState> {
public static ActionArea = ({ history }: any) => (
<EuiButton
size="s"
color="primary"
onClick={async () => {
history.push(`/tag/create`);
}}
>
Create Tag
</EuiButton>
);
public tableRef = React.createRef<Table>();
constructor(props: TagsPageProps) {
super(props);

this.state = {
beats: [],
tableRef: React.createRef(),
tags: [],
};

Expand All @@ -57,34 +41,20 @@ export class TagsPage extends React.PureComponent<TagsPageProps, TagsPageState>
<Table
actionHandler={this.handleTagsAction}
assignmentOptions={this.state.beats}
assignmentTitle={null}
assignmentTitle={'Assign Beats'}
items={this.state.tags}
ref={this.tableRef}
ref={this.state.tableRef}
showAssignmentOptions={true}
type={TagsTableType}
/>
);
}

private handleTagsAction = async (action: string) => {
private handleTagsAction = (action: string, payload: any) => {
switch (action) {
case 'loadAssignmentOptions':
this.loadBeats();
break;
case 'delete':
const tags = this.getSelectedTags().map(tag => tag.id);
const success = await this.props.libs.tags.delete(tags);
if (!success) {
alert(
'Some of these tags might be assigned to beats. Please ensure tags being removed are not activly assigned'
);
} else {
this.loadTags();
if (this.tableRef && this.tableRef.current) {
this.tableRef.current.resetSelection();
}
}
break;
}

this.loadTags();
Expand Down Expand Up @@ -166,10 +136,7 @@ export class TagsPage extends React.PureComponent<TagsPageProps, TagsPageState>
await this.props.libs.beats.assignTagsToBeats(assignments);
};

private getSelectedTags = (): BeatTag[] => {
if (this.tableRef && this.tableRef.current) {
return this.tableRef.current.state.selection;
}
return [];
private getSelectedTags = () => {
return this.state.tableRef.current.state.selection;
};
}
5 changes: 0 additions & 5 deletions x-pack/plugins/beats_management/server/lib/domains/beats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@ export class CMBeatsDomain {
return beat && beat.active ? beat : null;
}

public async getAllWithTags(user: FrameworkUser, tagIds: string[], justActive = true) {
const beats = await this.adapter.getAllWithTags(user, tagIds);
return justActive ? beats.filter((beat: CMBeat) => beat.active === true) : beats;
}

public async update(userOrToken: UserOrToken, beatId: string, beatData: Partial<CMBeat>) {
const beat = await this.adapter.get(this.framework.internalUser, beatId);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
{
"index_patterns": [".management-beats"],
"version": 65000,
"settings": {
"index": {
"number_of_shards": 1,
"auto_expand_replicas": "0-1",
"codec": "best_compression"
}
},
"mappings": {
"_doc": {
"dynamic": "strict",
"properties": {
"type": {
"type": "keyword"
},
"enrollment_token": {
"properties": {
"token": {
"type": "keyword"
},
"expires_on": {
"type": "date"
}
}
},
"tag": {
"properties": {
"id": {
"type": "keyword"
},
"color": {
"type": "keyword"
},
"configuration_blocks": {
"type": "nested",
"properties": {
"type": {
"type": "keyword"
},
"block_yml": {
"type": "text"
}
}
}
}
},
"beat": {
"properties": {
"id": {
"type": "keyword"
},
"active": {
"type": "boolean"
},
"enrollment_token": {
"type": "keyword"
},
"access_token": {
"type": "keyword"
},
"verified_on": {
"type": "date"
},
"type": {
"type": "keyword"
},
"version": {
"type": "keyword"
},
"host_ip": {
"type": "ip"
},
"host_name": {
"type": "keyword"
},
"ephemeral_id": {
"type": "keyword"
},
"local_configuration_yml": {
"type": "text"
},
"tags": {
"type": "keyword"
},
"orig_configuration_yml": {
"type": "text"
},
"metadata": {
"dynamic": "true",
"type": "object"
}
}
}
}
}
}
}
Loading

0 comments on commit 424ae6a

Please sign in to comment.