From e1229baa61ccd4fbd4e6dfe4a027e2aa7fb43b38 Mon Sep 17 00:00:00 2001 From: ophirharpazg Date: Wed, 27 May 2020 17:10:36 +0300 Subject: [PATCH] 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;