Fix Sonar vulnerabilities

Fix the vulnerabilities reported by Sonar.

Issue-ID: CLAMP-530
Change-Id: I9f6a7fe9ce042045085c371ef3777188b11ffb36
Signed-off-by: xuegao <xg353y@intl.att.com>
diff --git a/ui-react/src/components/dialogs/DeployLoop.js b/ui-react/src/components/dialogs/DeployLoop.js
index 805f0f2..d71af92 100644
--- a/ui-react/src/components/dialogs/DeployLoop.js
+++ b/ui-react/src/components/dialogs/DeployLoop.js
@@ -64,14 +64,13 @@
 		LoopService.updateGlobalProperties(loopName, this.state.temporaryPropertiesJson).then(resp => {
 			this.setState({ show: false });
 
-			console.log("Perform action: deploy");
 			LoopActionService.performAction(loopName, "deploy").then(pars => {
-				alert("Action deploy successfully performed");
+				this.props.showAlert("Action deploy successfully performed");
 				// refresh status and update loop logs
 				this.refreshStatus(loopName);
 			})
 			.catch(error => {
-				alert("Action deploy failed");
+				this.props.showAlert("Action deploy failed");
 				// refresh status and update loop logs
 				this.refreshStatus(loopName);
 			});
@@ -84,7 +83,7 @@
 			this.props.history.push('/');
 		})
 		.catch(error => {
-			alert("Refresh status failed");
+			this.props.showAlert("Refresh status failed");
 			this.props.history.push('/');
 		});
 	}
diff --git a/ui-react/src/components/dialogs/DeployLoop.test.js b/ui-react/src/components/dialogs/DeployLoop.test.js
index 2959ed6..44bc783 100644
--- a/ui-react/src/components/dialogs/DeployLoop.test.js
+++ b/ui-react/src/components/dialogs/DeployLoop.test.js
@@ -61,6 +61,7 @@
 		const flushPromises = () => new Promise(setImmediate);
 		const historyMock = { push: jest.fn() };
 		const updateLoopFunction = jest.fn();
+		const showAlert = jest.fn();
 		const handleSave = jest.spyOn(DeployLoop.prototype,'handleSave');
 		LoopService.updateGlobalProperties = jest.fn().mockImplementation(() => {
 			return Promise.resolve({
@@ -83,10 +84,9 @@
 				json: () => {}
 			});
 		});
-		const jsdomAlert = window.alert;
-		window.alert = () => {};
+
 		const component = shallow(<DeployLoop history={historyMock} 
-						loopCache={loopCache} updateLoopFunction={updateLoopFunction} />)
+						loopCache={loopCache} updateLoopFunction={updateLoopFunction} showAlert={showAlert} />)
 
 		component.find('[variant="primary"]').prop('onClick')();
 		await flushPromises();
@@ -95,7 +95,6 @@
 		expect(handleSave).toHaveBeenCalledTimes(1);
 		expect(component.state('show')).toEqual(false);
 		expect(historyMock.push.mock.calls[0]).toEqual([ '/']);
-		window.alert = jsdomAlert;
 		handleSave.mockClear();
 	});
 
diff --git a/ui-react/src/components/dialogs/OperationalPolicy/OperationalPolicyModal.js b/ui-react/src/components/dialogs/OperationalPolicy/OperationalPolicyModal.js
index 4dc1f90..5c5f024 100644
--- a/ui-react/src/components/dialogs/OperationalPolicy/OperationalPolicyModal.js
+++ b/ui-react/src/components/dialogs/OperationalPolicy/OperationalPolicyModal.js
@@ -54,7 +54,7 @@
 
 		if (errors.length !== 0) {
 			console.error("Errors detected during config policy data validation ", errors);
-			alert(errors);
+			this.props.showAlert(errors);
 		}
 		else {
 			console.info("NO validation errors found in config policy data");
diff --git a/ui-react/src/components/dialogs/PerformActions.js b/ui-react/src/components/dialogs/PerformActions.js
index 9c34e14..66b1928 100644
--- a/ui-react/src/components/dialogs/PerformActions.js
+++ b/ui-react/src/components/dialogs/PerformActions.js
@@ -50,14 +50,14 @@
 	componentDidMount() {
 		const action = this.state.loopAction;
 		const loopName = this.state.loopName;
-		console.log("Perform action:" + action);
+
 		LoopActionService.performAction(loopName, action).then(pars => {
-			alert("Action " + action + " successfully performed");
+			this.props.showAlert("Action " + action + " successfully performed");
 			// refresh status and update loop logs
 			this.refreshStatus(loopName);
 		})
 		.catch(error => {
-			alert("Action " + action + " failed");
+			this.props.showAlert("Action " + action + " failed");
 			// refresh status and update loop logs
 			this.refreshStatus(loopName);
 		});
diff --git a/ui-react/src/components/dialogs/PerformActions.test.js b/ui-react/src/components/dialogs/PerformActions.test.js
index 56fdcf3..0b07862 100644
--- a/ui-react/src/components/dialogs/PerformActions.test.js
+++ b/ui-react/src/components/dialogs/PerformActions.test.js
@@ -36,6 +36,7 @@
 		const flushPromises = () => new Promise(setImmediate);
 		const historyMock = { push: jest.fn() };
 		const updateLoopFunction = jest.fn();
+		const showAlert = jest.fn();
 		
 		LoopActionService.refreshStatus = jest.fn().mockImplementation(() => {
 			return Promise.resolve({
@@ -44,21 +45,19 @@
 				json: () => {}
 			});
 		});
-		const jsdomAlert = window.alert;
-		window.alert = () => {};
 		const component = shallow(<PerformActions loopCache={loopCache} 
-					loopAction="submit" history={historyMock} updateLoopFunction={updateLoopFunction} />)
+					loopAction="submit" history={historyMock} updateLoopFunction={updateLoopFunction} showAlert={showAlert} />)
 		await flushPromises();
 		component.update();
 
 		expect(historyMock.push.mock.calls[0]).toEqual([ '/']);
-		window.alert = jsdomAlert;
 	});
 
 	it('Test the render method action successful', async () => {
 		const flushPromises = () => new Promise(setImmediate);
 		const historyMock = { push: jest.fn() };
 		const updateLoopFunction = jest.fn();
+		const showAlert = jest.fn();
 
 		LoopActionService.performAction = jest.fn().mockImplementation(() => {
 			return Promise.resolve({
@@ -74,15 +73,12 @@
 				json: () => {}
 			});
 		});
-		const jsdomAlert = window.alert;
-		window.alert = () => {};
 		const component = shallow(<PerformActions loopCache={loopCache} 
-						loopAction="submit" history={historyMock} updateLoopFunction={updateLoopFunction} />)
+						loopAction="submit" history={historyMock} updateLoopFunction={updateLoopFunction} showAlert={showAlert} />)
 		await flushPromises();
 		component.update();
 
 		expect(historyMock.push.mock.calls[0]).toEqual([ '/']);
-		window.alert = jsdomAlert;
 	});
 
 });
diff --git a/ui-react/src/components/dialogs/RefreshStatus.js b/ui-react/src/components/dialogs/RefreshStatus.js
index cf08655..64b35d9 100644
--- a/ui-react/src/components/dialogs/RefreshStatus.js
+++ b/ui-react/src/components/dialogs/RefreshStatus.js
@@ -22,7 +22,7 @@
  */
 import React from 'react';
 import LoopActionService from '../../api/LoopActionService';
-import Spinner from 'react-bootstrap/Spinner'
+import Spinner from 'react-bootstrap/Spinner';
 import styled from 'styled-components';
 
 const StyledSpinnerDiv = styled.div`
@@ -42,15 +42,14 @@
 	}
 
 	componentDidMount() {
-		console.log("Refresh status for: " + this.state.loopName);
 		// refresh status and update loop logs
 		LoopActionService.refreshStatus(this.state.loopName).then(data => {
-			alert("Status successfully refreshed")
+			this.props.showAlert("Status successfully refreshed");
 			this.props.updateLoopFunction(data);
 			this.props.history.push('/');
 		})
 		.catch(error => {
-			alert("Status refreshing failed");
+			this.props.showAlert("Status refreshing failed");
 			this.props.history.push('/');
 		});
 	}
diff --git a/ui-react/src/components/dialogs/RefreshStatus.test.js b/ui-react/src/components/dialogs/RefreshStatus.test.js
index cb782ad..3038eb3 100644
--- a/ui-react/src/components/dialogs/RefreshStatus.test.js
+++ b/ui-react/src/components/dialogs/RefreshStatus.test.js
@@ -35,21 +35,20 @@
 	it('Test refresh status failed', async () => {
 		const flushPromises = () => new Promise(setImmediate);
 		const historyMock = { push: jest.fn() };
+		const showAlert = jest.fn();
 
-		const jsdomAlert = window.alert;
-		window.alert = () => {};
-		const component = shallow(<RefreshStatus loopCache={loopCache} history={historyMock} />)
+		const component = shallow(<RefreshStatus loopCache={loopCache} history={historyMock} showAlert={showAlert} />)
 		await flushPromises();
 		component.update();
 
 		expect(historyMock.push.mock.calls[0]).toEqual([ '/']);
-		window.alert = jsdomAlert;
 	});
 
 	it('Test refresh status successful', async () => {
 		const flushPromises = () => new Promise(setImmediate);
 		const historyMock = { push: jest.fn() };
 		const updateLoopFunction = jest.fn();
+		const showAlert = jest.fn();
 
 		LoopActionService.refreshStatus = jest.fn().mockImplementation(() => {
 			return Promise.resolve({
@@ -58,15 +57,13 @@
 				json: () => {}
 			});
 		});
-		const jsdomAlert = window.alert;
-		window.alert = () => {};
+
 		const component = shallow(<RefreshStatus loopCache={loopCache} 
-						loopAction="submit" history={historyMock} updateLoopFunction={updateLoopFunction} />)
+						loopAction="submit" history={historyMock} updateLoopFunction={updateLoopFunction} showAlert={showAlert} />)
 		await flushPromises();
 		component.update();
 
 		expect(historyMock.push.mock.calls[0]).toEqual([ '/']);
-		window.alert = jsdomAlert;
 	});
 
 });