forked from sentinl/sentinl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor wizard condition components using EUI react components.
Update agg field on type change. Fix 'month' unit. Fix typo, pass correctly the 1st numAggField. Delete unused lib imports. Create a UiCodeEditor component and apply it to several places. To-do: substitude all ace editors by this component. It is done to stop this error in the browser dev console ajaxorg/ace#1460 Put directive arguments inside double quotes. Remove unused lib imports. Upgrade elastic/eui version. Improve UiCodeEditor code style. Lift state up for the wizard condition panel expression component. Improve code style.
- Loading branch information
1 parent
b7e01ca
commit 1ba4819
Showing
31 changed files
with
725 additions
and
717 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import React from 'react'; | ||
import { render, unmountComponentAtNode } from 'react-dom'; | ||
import { uiModules } from 'ui/modules'; | ||
import UiCodeEditor from './ui_code_editor'; | ||
|
||
const module = uiModules.get('apps/sentinl'); | ||
module.directive('uiCodeEditor', function () { | ||
return { | ||
restrict: 'E', | ||
scope: { | ||
value: '=', | ||
mode: '@', | ||
maxLines: '=', | ||
minLines: '=', | ||
isReadOnly: '=', | ||
debounce: '=', | ||
onValueChange: '&' | ||
}, | ||
controller: function ($scope, $element, $timeout) { | ||
function renderComponent() { | ||
render( | ||
<UiCodeEditor | ||
value={$scope.value} | ||
mode={$scope.mode} | ||
maxLines={$scope.maxLines} | ||
minLines={$scope.minLines} | ||
isReadOnly={$scope.isReadOnly} | ||
debounce={$scope.debounce} | ||
onValueChange={(value) => { | ||
$scope.onValueChange({ value }); | ||
}} | ||
></UiCodeEditor>, | ||
$element[0] | ||
); | ||
}; | ||
|
||
renderComponent(); | ||
|
||
$scope.$watch('value', () => { | ||
renderComponent(); | ||
}); | ||
|
||
$scope.$on('$destroy', () => unmountComponentAtNode($element[0])); | ||
} | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import React, { | ||
PureComponent, | ||
} from 'react'; | ||
|
||
import { render } from 'react-dom'; | ||
|
||
import 'brace/theme/github'; | ||
import 'brace/mode/javascript'; | ||
import 'brace/mode/json'; | ||
import 'brace/snippets/javascript'; | ||
import 'brace/snippets/json'; | ||
import 'brace/ext/language_tools'; | ||
|
||
import { | ||
EuiCodeEditor, | ||
} from '@elastic/eui'; | ||
|
||
export default class UiCodeEditor extends PureComponent { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.editor = { | ||
debounce: this.props.debounce || 1, // ms | ||
}; | ||
|
||
this.state = { | ||
value: this.props.value, | ||
}; | ||
} | ||
|
||
componentWillReceiveProps(nextProps) { | ||
if (nextProps.value !== this.props.value) { | ||
this.setState({ value: nextProps.value }); | ||
} | ||
} | ||
|
||
onChange = (value) => { | ||
this.setState({ value }); | ||
setTimeout(() => { | ||
this.props.onValueChange(value); | ||
}, this.editor.debounce); | ||
}; | ||
|
||
render() { | ||
return ( | ||
<EuiCodeEditor | ||
mode={this.props.mode} | ||
theme="github" | ||
width="100%" | ||
value={this.state.value} | ||
onChange={this.onChange} | ||
isReadOnly={this.props.isReadOnly} | ||
setOptions = {{ | ||
rendererOptions: { | ||
maxLines: this.props.maxLines, | ||
minLines: this.props.minLines, | ||
}, | ||
fontSize: '14px', | ||
enableBasicAutocompletion: true, | ||
enableSnippets: true, | ||
enableLiveAutocompletion: true, | ||
}} | ||
/> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 0 additions & 35 deletions
35
.../condition_panel_watcher_wizard/components/dd_watcher_agg_field/dd_watcher_agg_field.html
This file was deleted.
Oops, something went wrong.
77 changes: 0 additions & 77 deletions
77
...ts/condition_panel_watcher_wizard/components/dd_watcher_agg_field/dd_watcher_agg_field.js
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
...wizard/components/condition_panel_watcher_wizard/components/dd_watcher_agg_field/index.js
This file was deleted.
Oops, something went wrong.
32 changes: 0 additions & 32 deletions
32
...tion_panel_watcher_wizard/components/dd_watcher_agg_interval/dd_watcher_agg_interval.html
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.