diff --git x-pack/plugins/beats_management/public/components/tag/index.ts x-pack/plugins/beats_management/public/components/tag/index.ts new file mode 100644 index 0000000000..8447142e16 --- /dev/null +++ x-pack/plugins/beats_management/public/components/tag/index.ts @@ -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'; diff --git x-pack/plugins/beats_management/public/components/tag/tag_configs.ts x-pack/plugins/beats_management/public/components/tag/tag_configs.ts new file mode 100644 index 0000000000..08ad711e79 --- /dev/null +++ x-pack/plugins/beats_management/public/components/tag/tag_configs.ts @@ -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, +}; diff --git x-pack/plugins/beats_management/public/components/tag/tag_edit.tsx x-pack/plugins/beats_management/public/components/tag/tag_edit.tsx new file mode 100644 index 0000000000..a85f462186 --- /dev/null +++ x-pack/plugins/beats_management/public/components/tag/tag_edit.tsx @@ -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 { + 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 ( +
+ +

Add a new tag

+
+ + + + + +

Define this tag

+
+ +

+ Tags will apply a set configuration to a group of beats. +
+ The tag type defines the options available. +

+
+
+ {tagName ? tagName : 'Tag name'} +
+
+ + + + + + + + + + +
+
+ + + + + +

Configurations

+
+ +

+ 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. +

+
+
+ +
+ Add a new configuration +
+
+
+
+ + {showAttachedBeats && ( + + +

Attached Beats

+
+ { + /* TODO: handle assignment/delete actions */ + }} + assignmentOptions={[]} + assignmentTitle={null} + items={items} + ref={this.state.tableRef} + showAssignmentOptions={false} + type={BeatsTableType} + /> + + )} + + + + + Save + + + + Cancel + + + {this.state.showFlyout && ( + this.setState({ showFlyout: false })}> + + +

Add Configuration

+
+
+ + + { + // TODO: handle search changes + }} + /> + + + { + // TODO: update field value + }} + placeholder="Description (optional)" + /> + + Add configuration options here, + }, + { + id: 'yaml_editor', + name: 'YAML Editor', + content: , + }, + ]} + /> + + + + + this.setState({ showFlyout: false })} + > + Close + + + + Save + + + +
+ )} + + ); + } + + private openConfigFlyout = () => { + this.setState({ + showFlyout: true, + }); + }; + private updateBadgeColor = (e: any) => this.setState({ color: e }); + private updateBadgeName = (e: any) => this.setState({ tagName: e.target.value }); +} diff --git x-pack/plugins/beats_management/public/pages/main/create_tag.tsx x-pack/plugins/beats_management/public/pages/main/create_tag.tsx new file mode 100644 index 0000000000..27ba69e435 --- /dev/null +++ x-pack/plugins/beats_management/public/pages/main/create_tag.tsx @@ -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 { + constructor(props: CreateTagPageProps) { + super(props); + + this.state = { + color: '#DD0A73', + configurationBlocks: [], + showFlyout: false, + tagName: null, + }; + } + + public render() { + return ; + } +} diff --git x-pack/plugins/beats_management/public/pages/main/edit_tag.tsx x-pack/plugins/beats_management/public/pages/main/edit_tag.tsx new file mode 100644 index 0000000000..dab4d82e36 --- /dev/null +++ x-pack/plugins/beats_management/public/pages/main/edit_tag.tsx @@ -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 { + constructor(props: EditTagPageProps) { + super(props); + + this.state = { + color: '#DD0A73', + configurationBlocks: [], + showFlyout: false, + tagName: null, + }; + } + + public render() { + return ; + } +} diff --git x-pack/plugins/beats_management/public/pages/main/index.tsx x-pack/plugins/beats_management/public/pages/main/index.tsx index 49c4f75707..7d201bde44 100644 --- x-pack/plugins/beats_management/public/pages/main/index.tsx +++ x-pack/plugins/beats_management/public/pages/main/index.tsx @@ -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 { @@ -60,6 +62,16 @@ export class MainPages extends React.PureComponent ( @@ -106,6 +118,16 @@ export class MainPages extends React.PureComponent } /> + } + /> + } + /> );