Skip to content
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
71b162a
[Beats Management] Move to Ingest UI arch and initial TS effort (#20039)
mattapperson Jun 26, 2018
ebffb62
add details page, re-configure routes
mattapperson Aug 8, 2018
85c1e59
move tag crud to new route stuff
mattapperson Aug 8, 2018
e782314
update tag create/edit component api
mattapperson Aug 8, 2018
2151ae3
tags creation now working
mattapperson Aug 8, 2018
7ab3a96
bunch of stuff I should have split up better…
mattapperson Aug 10, 2018
c2d3a4a
fixed perf bug, selected items that are removed are no longer phantom…
mattapperson Aug 13, 2018
8317937
fix rendering of assignments
mattapperson Aug 13, 2018
c1ebd16
remove assign to beats, the UX was too poor
mattapperson Aug 13, 2018
58f4aac
[Beats Management] Move to Ingest UI arch and initial TS effort (#20039)
mattapperson Jun 26, 2018
ce60486
Beats/update (#21702)
mattapperson Aug 8, 2018
b071284
progress on config forms
mattapperson Aug 14, 2018
6298c2f
config view inital input types working
mattapperson Aug 14, 2018
b8c0605
ts fixes
mattapperson Aug 14, 2018
d628018
fix more ts
mattapperson Aug 14, 2018
9373a2c
code now errors on invalid yaml
mattapperson Aug 15, 2018
b533c30
remove un-needed include
mattapperson Aug 15, 2018
40e49e4
fix bad rebase
mattapperson Aug 15, 2018
acbc416
saving config blocks as yaml to db is now working
mattapperson Aug 16, 2018
5219006
propperly formatted YAML
mattapperson Aug 16, 2018
9a11a85
loading tags back on edit screen in-progress
mattapperson Aug 16, 2018
0fd670b
fix types
mattapperson Aug 17, 2018
aac2b30
vis name validation for tag
mattapperson Aug 17, 2018
22c358d
update EUI style
mattapperson Aug 17, 2018
4cd93aa
tweak design
mattapperson Aug 17, 2018
9888cf5
fixed tag assignments (still has a ui glitch)
mattapperson Aug 20, 2018
4e25282
fix form validation on select
mattapperson Aug 20, 2018
00e826a
fix deps
mattapperson Aug 21, 2018
48f3497
update deps
mattapperson Aug 21, 2018
d44f2f4
attached beats now works in the edit tag screen, edit now disables ch…
mattapperson Aug 24, 2018
29a5f07
better un-parsing of yaml, some elements now rendering to edit config…
mattapperson Aug 24, 2018
4679e91
delete config block now works
mattapperson Aug 24, 2018
6a88c35
fix ability to edit config
mattapperson Aug 27, 2018
0103aea
fix deps
mattapperson Aug 27, 2018
d0502fe
fix another rebase issue
mattapperson Aug 27, 2018
57fdb5b
tweaks and fixes
mattapperson Aug 28, 2018
dfa443f
fix several bugs
mattapperson Aug 28, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@
"@types/minimatch": "^2.0.29",
"@types/node": "^8.10.20",
"@types/prop-types": "^15.5.3",
"@types/react": "^16.3.14",
"@types/react": "^16.3.0",
"@types/react-dom": "^16.0.5",
"@types/react-redux": "^5.0.6",
"@types/redux": "^3.6.31",
Expand Down
2 changes: 1 addition & 1 deletion x-pack/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ module.exports = function (kibana) {
indexManagement(kibana),
consoleExtensions(kibana),
notifications(kibana),
kueryAutocomplete(kibana)
kueryAutocomplete(kibana),
];
};
8 changes: 2 additions & 6 deletions x-pack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,13 @@
"@kbn/plugin-helpers": "link:../packages/kbn-plugin-helpers",
"@kbn/test": "link:../packages/kbn-test",
"@types/boom": "^4.3.8",
"@types/chance": "^1.0.1",
"@types/history": "^4.6.2",
"@types/hapi": "15.0.1",
"@types/jest": "^22.2.3",
"@types/joi": "^10.4.0",
"@types/jsonwebtoken": "^7.2.8",
"@types/lodash": "^3.10.0",
"@types/pngjs": "^3.3.0",
"@types/react-router": "^4.0.30",
"@types/react-router-dom": "^4.2.7",
"@types/sinon": "^5.0.1",
"abab": "^1.0.4",
"ansicolors": "0.3.2",
"aws-sdk": "2.2.33",
Expand Down Expand Up @@ -97,8 +94,6 @@
"@kbn/ui-framework": "link:../packages/kbn-ui-framework",
"@samverschueren/stream-to-observable": "^0.3.0",
"@slack/client": "^4.2.2",
"@types/elasticsearch": "^5.0.24",
"@types/jsonwebtoken": "^7.2.7",
"@types/uuid": "^3.4.3",
"angular-paging": "2.2.1",
"angular-resource": "1.4.9",
Expand All @@ -120,6 +115,7 @@
"elasticsearch": "^14.1.0",
"extract-zip": "1.5.0",
"font-awesome": "4.4.0",
"formsy-react": "^1.1.4",
"get-port": "2.1.0",
"getos": "^3.1.0",
"glob": "6.0.4",
Expand Down
4 changes: 3 additions & 1 deletion x-pack/plugins/beats_management/common/domain_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { ClientSideBeatTag } from '../public/lib/lib';
import { ConfigurationBlockTypes } from './constants';

export interface ConfigurationBlock {
type: ConfigurationBlockTypes;
description: string;
block_yml: string;
}

Expand All @@ -30,7 +32,7 @@ export interface CMBeat {
}

export interface CMPopulatedBeat extends CMBeat {
full_tags: BeatTag[];
full_tags: ClientSideBeatTag[];
}

export interface BeatTag {
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/beats_management/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export function beats(kibana: any) {
},
config: () => config,
configPrefix,

init(server: any) {
initServerWithKibana(server);
},
Expand Down
61 changes: 61 additions & 0 deletions x-pack/plugins/beats_management/public/components/config_list.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* 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.
*/

// @ts-ignore
import { EuiBasicTable, EuiLink } from '@elastic/eui';
import React from 'react';
import { supportedConfigs } from '../config_schemas';
import { ClientSideConfigurationBlock } from '../lib/lib';

interface ComponentProps {
configs: ClientSideConfigurationBlock[];
onConfigClick: (action: 'edit' | 'delete', config: ClientSideConfigurationBlock) => any;
}

export const ConfigList: React.SFC<ComponentProps> = props => (
<EuiBasicTable
items={props.configs}
columns={[
{
field: 'type',
name: 'Type',
truncateText: false,
render: (value: string, config: ClientSideConfigurationBlock) => {
const type = supportedConfigs.find((sc: any) => sc.value === config.type);

return (
<EuiLink onClick={() => props.onConfigClick('edit', config)}>
{type ? type.text : config.type}
</EuiLink>
);
},
},
{
field: 'block_obj.module',
name: 'Module',
truncateText: false,
render: (item: ClientSideConfigurationBlock) =>
(item && (item.block_obj as any).module) || 'N/A',
},
{
field: 'description',
name: 'Description',
},
{
name: 'Actions',
actions: [
{
name: 'Remove',
description: 'Remove this config from tag',
type: 'icon',
icon: 'trash',
onClick: (item: ClientSideConfigurationBlock) => props.onConfigClick('delete', item),
},
],
},
]}
/>
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/*
* 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.
*/
// @ts-ignore
import { CommonProps, EuiCodeEditor, EuiCodeEditorProps, EuiFormRow } from '@elastic/eui';
// @ts-ignore
import { FormsyInputProps, withFormsy } from 'formsy-react';
import React, { Component, InputHTMLAttributes } from 'react';

interface ComponentProps extends FormsyInputProps, CommonProps, EuiCodeEditorProps {
instantValidation: boolean;
label: string;
isReadOnly: boolean;
mode: 'javascript' | 'yaml';
errorText: string;
fullWidth: boolean;
helpText: React.ReactElement<any>;
compressed: boolean;
onChange(value: string): void;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make these optional - sorry, should have commented here before as well

onBlur(): void;
}

interface ComponentState {
allowError: boolean;
}

class CodeEditor extends Component<
InputHTMLAttributes<HTMLTextAreaElement> & ComponentProps,
ComponentState
> {
public static defaultProps = {
passRequiredToField: true,
};

public state = { allowError: false };

public componentDidMount() {
const { defaultValue, setValue } = this.props;
if (defaultValue) {
setValue(defaultValue);
}
}

public componentWillReceiveProps(nextProps: ComponentProps) {
if (nextProps.isFormSubmitted()) {
this.showError();
}
}

public handleChange = (value: string) => {
this.props.setValue(value);
if (this.props.onChange) {
this.props.onChange(value);
}
if (this.props.instantValidation) {
this.showError();
}
};

public handleBlur = () => {
this.showError();
if (this.props.onBlur) {
this.props.onBlur();
}
};

public showError = () => this.setState({ allowError: true });

public render() {
const {
id,
label,
isReadOnly,
isValid,
getValue,
isPristine,
getErrorMessage,
mode,
fullWidth,
className,
helpText,
} = this.props;

const { allowError } = this.state;
const error = !isPristine() && !isValid() && allowError;

return (
<EuiFormRow
id={id}
label={label}
helpText={helpText}
isInvalid={error}
error={error ? getErrorMessage() : []}
>
<EuiCodeEditor
id={id}
name={name}
mode={mode}
theme="github"
value={getValue()}
isReadOnly={isReadOnly || false}
isInvalid={error}
onChange={this.handleChange}
onBlur={this.handleBlur}
width={fullWidth ? '100%' : undefined}
className={className}
/>
</EuiFormRow>
);
}
}

export const FormsyEuiCodeEditor = withFormsy(CodeEditor);
111 changes: 111 additions & 0 deletions x-pack/plugins/beats_management/public/components/inputs/input.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*
* 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 { CommonProps, EuiFieldText, EuiFieldTextProps, EuiFormRow } from '@elastic/eui';
import { FormsyInputProps, withFormsy } from 'formsy-react';
import React, { Component, InputHTMLAttributes } from 'react';

interface ComponentProps extends FormsyInputProps, CommonProps, EuiFieldTextProps {
instantValidation?: boolean;
label: string;
errorText: string;
fullWidth: boolean;
helpText: React.ReactElement<any>;
compressed: boolean;
onChange?(e: React.ChangeEvent<HTMLInputElement>, value: any): void;
onBlur?(e: React.ChangeEvent<HTMLInputElement>, value: any): void;
}

interface ComponentState {
allowError: boolean;
}

class FieldText extends Component<
InputHTMLAttributes<HTMLInputElement> & ComponentProps,
ComponentState
> {
public static defaultProps = {
passRequiredToField: true,
};

public state = { allowError: false };

public componentDidMount() {
const { defaultValue, setValue } = this.props;
if (defaultValue) {
setValue(defaultValue);
}
}

public componentWillReceiveProps(nextProps: ComponentProps) {
if (nextProps.isFormSubmitted()) {
this.showError();
}
}

public handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const { value } = e.currentTarget;
this.props.setValue(value);
if (this.props.onChange) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're requiring the parent to provide a function for this prop - is it a best practice in TS to check if a variable is falsey even if it's required?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bad types on my part, they should be optional

this.props.onChange(e, e.currentTarget.value);
}
if (this.props.instantValidation) {
this.showError();
}
};

public handleBlur = (e: React.ChangeEvent<HTMLInputElement>) => {
this.showError();
if (this.props.onBlur) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question as in handleChange.

this.props.onBlur(e, e.currentTarget.value);
}
};

public showError = () => this.setState({ allowError: true });

public render() {
const {
id,
required,
label,
getValue,
isValid,
isPristine,
getErrorMessage,
fullWidth,
className,
disabled,
helpText,
} = this.props;

const { allowError } = this.state;
const error = !isPristine() && !isValid() && allowError;

return (
<EuiFormRow
id={id}
label={label}
helpText={helpText}
isInvalid={!disabled && error}
error={!disabled && error ? getErrorMessage() : []}
>
<EuiFieldText
id={id}
name={name}
value={getValue()}
isInvalid={!disabled && error}
onChange={this.handleChange}
onBlur={this.handleBlur}
fullWidth={fullWidth}
disabled={disabled}
required={required}
className={className}
/>
</EuiFormRow>
);
}
}

export const FormsyEuiFieldText = withFormsy(FieldText);
Loading