From e1229baa61ccd4fbd4e6dfe4a027e2aa7fb43b38 Mon Sep 17 00:00:00 2001 From: ophirharpazg Date: Wed, 27 May 2020 17:10:36 +0300 Subject: [PATCH 1/4] The Missing Binaries modal works but in a non-elegant way --- .../ui/src/components/pages/RunMonkeyPage.js | 26 ++++++++++-- .../ui-components/MissingBinariesModal.js | 41 +++++++++++++++++++ 2 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 monkey/monkey_island/cc/ui/src/components/ui-components/MissingBinariesModal.js diff --git a/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage.js b/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage.js index a741148fb..8ca334e73 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage.js @@ -13,6 +13,8 @@ import {Link} from 'react-router-dom'; import AuthComponent from '../AuthComponent'; import AwsRunTable from '../run-monkey/AwsRunTable'; +import MissingBinariesModal from '../ui-components/MissingBinariesModal'; + import '../../styles/MonkeyRunPage.scss'; const loading_css_override = css` @@ -40,8 +42,11 @@ class RunMonkeyPageComponent extends AuthComponent { awsMachines: [], isLoadingAws: true, isErrorWhileCollectingAwsMachines: false, - awsMachineCollectionErrorMsg: '' + awsMachineCollectionErrorMsg: '', + showModal: false }; + + this.closeModal = this.closeModal.bind(this); } componentDidMount() { @@ -130,6 +135,12 @@ class RunMonkeyPageComponent extends AuthComponent { runningOnIslandState: 'installing' }); } else { + /* If Monkey binaries are missing, change the state accordingly */ + if (res['error_text'].startsWith('Copy file failed')) { + this.setState({ + showModal: true} + ); + } this.setState({ runningOnIslandState: 'not_running' }); @@ -285,6 +296,12 @@ class RunMonkeyPageComponent extends AuthComponent { ) } + closeModal = () => { + this.setState({ + showModal: false + }) + }; + render() { return ( @@ -296,11 +313,14 @@ class RunMonkeyPageComponent extends AuthComponent {

+ { // TODO: implement button functionality /* diff --git a/monkey/monkey_island/cc/ui/src/components/ui-components/MissingBinariesModal.js b/monkey/monkey_island/cc/ui/src/components/ui-components/MissingBinariesModal.js new file mode 100644 index 000000000..afd1ff0de --- /dev/null +++ b/monkey/monkey_island/cc/ui/src/components/ui-components/MissingBinariesModal.js @@ -0,0 +1,41 @@ +import {Modal} from 'react-bootstrap'; +import React from 'react'; +import {GridLoader} from 'react-spinners'; + + +class MissingBinariesModal extends React.PureComponent { + + constructor(props) { + super(props); + + this.state = { + showModal: this.props.showModal + }; + } + + render = () => { + return ( + this.props.onClose()}> + +

+
Uh oh...
+

+

+ Some Monkey binaries are not found where they should be...{"\r\n"} + Try downloading them from here, + at the bottommost section titled "Assets". +

+
+ +
+ + + ) + }; + +} + +export default MissingBinariesModal; From a4d4f629e0146189b569539640521adddc863f7f Mon Sep 17 00:00:00 2001 From: ophirharpazg Date: Wed, 27 May 2020 19:32:09 +0300 Subject: [PATCH 2/4] Raise a modal indicating that Monkey binaries are missing. --- .../ui/src/components/pages/RunMonkeyPage.js | 8 +++-- .../ui-components/MissingBinariesModal.js | 36 +++++++++++++++---- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage.js b/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage.js index 8ca334e73..afb8afafb 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage.js @@ -43,7 +43,8 @@ class RunMonkeyPageComponent extends AuthComponent { isLoadingAws: true, isErrorWhileCollectingAwsMachines: false, awsMachineCollectionErrorMsg: '', - showModal: false + showModal: false, + errorDetails: '' }; this.closeModal = this.closeModal.bind(this); @@ -138,7 +139,8 @@ class RunMonkeyPageComponent extends AuthComponent { /* If Monkey binaries are missing, change the state accordingly */ if (res['error_text'].startsWith('Copy file failed')) { this.setState({ - showModal: true} + showModal: true, + errorDetails: res['error_text']} ); } this.setState({ @@ -320,7 +322,7 @@ class RunMonkeyPageComponent extends AuthComponent { + errorDetails = {this.state.errorDetails}/> { // TODO: implement button functionality /* diff --git a/monkey/monkey_island/cc/ui/src/components/ui-components/MissingBinariesModal.js b/monkey/monkey_island/cc/ui/src/components/ui-components/MissingBinariesModal.js index afd1ff0de..b09774c2e 100644 --- a/monkey/monkey_island/cc/ui/src/components/ui-components/MissingBinariesModal.js +++ b/monkey/monkey_island/cc/ui/src/components/ui-components/MissingBinariesModal.js @@ -9,22 +9,44 @@ class MissingBinariesModal extends React.PureComponent { super(props); this.state = { - showModal: this.props.showModal + showModal: this.props.showModal, + errorDetails: this.props.errorDetails }; } + componentDidUpdate(prevProps) { + if (this.props !== prevProps) { + this.setState({ + showModal: this.props.showModal, + errorDetails: this.props.errorDetails + }) + } + } + render = () => { return ( - this.props.onClose()}> + this.props.onClose()}>

Uh oh...

-

- Some Monkey binaries are not found where they should be...{"\r\n"} - Try downloading them from here, - at the bottommost section titled "Assets". -

+
+

+ + Some Monkey binaries are not found where they should be...
+ Try downloading them from here, + at the bottommost section titled "Assets". +

+
+
+

+ Error Details +

+
+
+              {this.state.errorDetails}
+            
+

From a07ec9251c928e87eb313d866c00e84d48cbe12c Mon Sep 17 00:00:00 2001 From: ophirharpazg Date: Fri, 29 May 2020 00:30:03 +0300 Subject: [PATCH 4/4] formatting of the binaries path --- .../cc/ui/src/components/ui-components/MissingBinariesModal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monkey/monkey_island/cc/ui/src/components/ui-components/MissingBinariesModal.js b/monkey/monkey_island/cc/ui/src/components/ui-components/MissingBinariesModal.js index 19f6c3dbe..c73094fb6 100644 --- a/monkey/monkey_island/cc/ui/src/components/ui-components/MissingBinariesModal.js +++ b/monkey/monkey_island/cc/ui/src/components/ui-components/MissingBinariesModal.js @@ -35,7 +35,7 @@ class MissingBinariesModal extends React.PureComponent { Some Monkey binaries are not found where they should be...
You can download the files from here, - at the bottommost section titled "Assets", and place them under the directory monkey/monkey_island/cc/binaries. + at the bottommost section titled "Assets", and place them under the directory monkey/monkey_island/cc/binaries.