Skip to content

Commit

Permalink
[Beats CM] Manage Tags (#21776)
Browse files Browse the repository at this point in the history
* [ML] Fixing issue with historical job audit messages (#21718)

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

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

* Initial scaffolding for Beats plugin

* Removing bits not (yet) necessary in initial scaffolding

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

* Install Beats index template on plugin init

* Adding missing files

* [Beats Management] APIs: Create enrollment tokens (#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 (#19100)

* [Beats Management] APIs: Enroll beat (#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 (#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 (#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 (#19194)

* [Beats Management] APIs: Update beat (#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 (#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 (#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 (#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 (#19342)

* Updating mappings

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

* [Beats Management] Prevent timing attacks when checking auth tokens (#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) (#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) (#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 (#20039)

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

* Initial scaffolding for Beats plugin

* Removing bits not (yet) necessary in initial scaffolding

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

* Install Beats index template on plugin init

* Adding missing files

* [Beats Management] APIs: Create enrollment tokens (#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 (#19100)

* [Beats Management] APIs: Enroll beat (#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 (#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 (#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 (#19194)

* [Beats Management] APIs: Update beat (#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 (#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 (#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 (#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 (#19342)

* Updating mappings

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

* [Beats Management] Prevent timing attacks when checking auth tokens (#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) (#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) (#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 (#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 (#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 (#20603)

* [Beats Management] Move tokens to use JWT, add more complete test suite (#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 #20566

* updated lock file

* fix bad merge

* update TSLinting

* fix bad rebase

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

* Init plugin public resources.

* rename beats to beats_management

* rendering react now

* Beats/initial ui (#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 (#21287)

* Beats/real adapters (#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 (#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 (#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

* Add create tags view.

* fix types

* update deps

* update kibana API for version

* Added component/config interface for editing/creating tags. Added separate pages for create/edit tags.

* Fixup.
  • Loading branch information
justinkambic authored and mattapperson committed Aug 27, 2018
1 parent bb7d0e7 commit 13bf2bc
Show file tree
Hide file tree
Showing 6 changed files with 359 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* 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.
*/

export { TagCreateConfig, TagEditConfig, TagViewConfig } from './tag_configs';
export { TagEdit } from './tag_edit';
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* 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.
*/

export interface TagViewConfig {
showAttachedBeats: boolean;
}

export const TagCreateConfig: TagViewConfig = {
showAttachedBeats: false,
};

export const TagEditConfig: TagViewConfig = {
showAttachedBeats: true,
};
232 changes: 232 additions & 0 deletions x-pack/plugins/beats_management/public/components/tag/tag_edit.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
/*
* 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 {
// @ts-ignore
EuiBadge,
EuiButton,
EuiButtonEmpty,
// @ts-ignore
EuiCodeEditor,
// @ts-ignore
EuiColorPicker,
EuiFieldText,
EuiFlexGroup,
EuiFlexItem,
EuiFlyout,
EuiFlyoutBody,
EuiFlyoutFooter,
EuiFlyoutHeader,
// @ts-ignore
EuiForm,
EuiFormRow,
EuiPanel,
// @ts-ignore
EuiSearchBar,
EuiSpacer,
// @ts-ignore
EuiTabbedContent,
EuiText,
EuiTitle,
} from '@elastic/eui';
import 'brace/mode/yaml';
import 'brace/theme/github';
import React from 'react';
import { ConfigurationBlock } from '../../../common/domain_types';
import { Table } from '../table';
import { BeatsTableType } from '../table';
import { TagViewConfig } from '../tag';

interface TagEditProps {
items: any[];
config: TagViewConfig;
}

interface TagEditState {
color: string | null;
configurationBlocks: ConfigurationBlock[];
showFlyout: boolean;
tableRef: any;
tagName: string | null;
}

export class TagEdit extends React.PureComponent<TagEditProps, TagEditState> {
constructor(props: TagEditProps) {
super(props);

this.state = {
color: '#DD0A73',
configurationBlocks: [],
showFlyout: false,
tableRef: React.createRef(),
tagName: null,
};
}

public render() {
const {
config: { showAttachedBeats },
items,
} = this.props;
const { color, configurationBlocks, tagName } = this.state;
return (
<div>
<EuiTitle size="m">
<h1>Add a new tag</h1>
</EuiTitle>
<EuiSpacer size="m" />
<EuiPanel>
<EuiFlexGroup>
<EuiFlexItem>
<EuiTitle size="xs">
<h3>Define this tag</h3>
</EuiTitle>
<EuiText color="subdued">
<p>
Tags will apply a set configuration to a group of beats.
<br />
The tag type defines the options available.
</p>
</EuiText>
<div>
<EuiBadge color={color ? color : '#FF0'}>{tagName ? tagName : 'Tag name'}</EuiBadge>
</div>
</EuiFlexItem>
<EuiFlexItem>
<EuiForm>
<EuiFormRow label="Name">
<EuiFieldText
name="tagName"
onChange={this.updateBadgeName}
placeholder="Tag name"
/>
</EuiFormRow>
<EuiFormRow label="Color">
<EuiColorPicker color={color} onChange={this.updateBadgeColor} />
</EuiFormRow>
</EuiForm>
</EuiFlexItem>
</EuiFlexGroup>
</EuiPanel>
<EuiSpacer />
<EuiPanel>
<EuiFlexGroup alignItems={configurationBlocks.length ? 'stretch' : 'center'}>
<EuiFlexItem>
<EuiTitle size="xs">
<h3>Configurations</h3>
</EuiTitle>
<EuiText color="subdued">
<p>
You can have multiple configurations applied to an individual tag. These
configurations can repeat or mix types as necessary. For example, you may utilize
three metricbeat configurations alongside one input and filebeat configuration.
</p>
</EuiText>
</EuiFlexItem>
<EuiFlexItem>
<div>
<EuiButton onClick={this.openConfigFlyout}>Add a new configuration</EuiButton>
</div>
</EuiFlexItem>
</EuiFlexGroup>
</EuiPanel>
<EuiSpacer />
{showAttachedBeats && (
<EuiPanel paddingSize="m">
<EuiTitle size="xs">
<h3>Attached Beats</h3>
</EuiTitle>
<Table
actionHandler={(a, b) => {
/* TODO: handle assignment/delete actions */
}}
assignmentOptions={[]}
assignmentTitle={null}
items={items}
ref={this.state.tableRef}
showAssignmentOptions={false}
type={BeatsTableType}
/>
</EuiPanel>
)}
<EuiSpacer size="m" />
<EuiFlexGroup>
<EuiFlexItem grow={false}>
<EuiButton fill isDisabled={true}>
Save
</EuiButton>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButtonEmpty>Cancel</EuiButtonEmpty>
</EuiFlexItem>
</EuiFlexGroup>
{this.state.showFlyout && (
<EuiFlyout onClose={() => this.setState({ showFlyout: false })}>
<EuiFlyoutHeader>
<EuiTitle size="m">
<h2>Add Configuration</h2>
</EuiTitle>
</EuiFlyoutHeader>
<EuiFlyoutBody>
<EuiFormRow label="Configuration type">
<EuiSearchBar
onChange={() => {
// TODO: handle search changes
}}
/>
</EuiFormRow>
<EuiFormRow label="Configuration description">
<EuiFieldText
onChange={() => {
// TODO: update field value
}}
placeholder="Description (optional)"
/>
</EuiFormRow>
<EuiTabbedContent
tabs={[
{
id: 'basic_settings',
name: 'Basic Settings',
content: <div>Add configuration options here</div>,
},
{
id: 'yaml_editor',
name: 'YAML Editor',
content: <EuiCodeEditor mode="yaml" theme="github" />,
},
]}
/>
</EuiFlyoutBody>
<EuiFlyoutFooter>
<EuiFlexGroup justifyContent="spaceBetween">
<EuiFlexItem grow={false}>
<EuiButtonEmpty
iconType="cross"
onClick={() => this.setState({ showFlyout: false })}
>
Close
</EuiButtonEmpty>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButton fill>Save</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlyoutFooter>
</EuiFlyout>
)}
</div>
);
}

private openConfigFlyout = () => {
this.setState({
showFlyout: true,
});
};
private updateBadgeColor = (e: any) => this.setState({ color: e });
private updateBadgeName = (e: any) => this.setState({ tagName: e.target.value });
}
40 changes: 40 additions & 0 deletions x-pack/plugins/beats_management/public/pages/main/create_tag.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* 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 'brace/mode/yaml';
import 'brace/theme/github';
import React from 'react';
import { ConfigurationBlock } from '../../../common/domain_types';
import { TagCreateConfig, TagEdit } from '../../components/tag';
import { FrontendLibs } from '../../lib/lib';

interface CreateTagPageProps {
libs: FrontendLibs;
}

interface CreateTagPageState {
color: string | null;
configurationBlocks: ConfigurationBlock[];
showFlyout: boolean;
tagName: string | null;
}

export class CreateTagPage extends React.PureComponent<CreateTagPageProps, CreateTagPageState> {
constructor(props: CreateTagPageProps) {
super(props);

this.state = {
color: '#DD0A73',
configurationBlocks: [],
showFlyout: false,
tagName: null,
};
}

public render() {
return <TagEdit config={TagCreateConfig} items={[]} />;
}
}
40 changes: 40 additions & 0 deletions x-pack/plugins/beats_management/public/pages/main/edit_tag.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* 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 'brace/mode/yaml';
import 'brace/theme/github';
import React from 'react';
import { ConfigurationBlock } from '../../../common/domain_types';
import { TagEdit, TagEditConfig } from '../../components/tag';
import { FrontendLibs } from '../../lib/lib';

interface EditTagPageProps {
libs: FrontendLibs;
}

interface EditTagPageState {
color: string | null;
configurationBlocks: ConfigurationBlock[];
showFlyout: boolean;
tagName: string | null;
}

export class EditTagPage extends React.PureComponent<EditTagPageProps, EditTagPageState> {
constructor(props: EditTagPageProps) {
super(props);

this.state = {
color: '#DD0A73',
configurationBlocks: [],
showFlyout: false,
tagName: null,
};
}

public render() {
return <TagEdit config={TagEditConfig} items={[]} />;
}
}
22 changes: 22 additions & 0 deletions x-pack/plugins/beats_management/public/pages/main/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import { PrimaryLayout } from '../../components/layouts/primary';
import { FrontendLibs } from '../../lib/lib';
import { ActivityPage } from './activity';
import { BeatsPage } from './beats';
import { CreateTagPage } from './create_tag';
import { EditTagPage } from './edit_tag';
import { TagsPage } from './tags';

interface MainPagesProps {
Expand Down Expand Up @@ -60,6 +62,16 @@ export class MainPages extends React.PureComponent<MainPagesProps, MainPagesStat
name: 'Tags',
disabled: false,
},
{
id: '/createtag',
name: 'Create Tag',
disabled: false,
},
{
id: '/edittag',
name: 'Edit Tag',
disabled: false,
},
];

const renderedTabs = tabs.map((tab, index) => (
Expand Down Expand Up @@ -106,6 +118,16 @@ export class MainPages extends React.PureComponent<MainPagesProps, MainPagesStat
exact={true}
render={(props: any) => <TagsPage libs={this.props.libs} {...props} />}
/>
<Route
path="/createtag"
exact={true}
render={(props: any) => <CreateTagPage libs={this.props.libs} {...props} />}
/>
<Route
path="/edittag"
exact={true}
render={(props: any) => <EditTagPage libs={this.props.libs} {...props} />}
/>
</Switch>
</PrimaryLayout>
);
Expand Down

0 comments on commit 13bf2bc

Please sign in to comment.