From d84382c7ace4bddbb70fe75a304567ce10749018 Mon Sep 17 00:00:00 2001 From: vakarisz Date: Tue, 12 Jul 2022 15:50:06 +0300 Subject: [PATCH] UI: Fix bugs in ImportConfigModal and ImportConfigModal --- .../configuration-components/ImportConfigModal.tsx | 3 ++- .../cc/ui/src/components/ui-components/IslandResetModal.tsx | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/monkey/monkey_island/cc/ui/src/components/configuration-components/ImportConfigModal.tsx b/monkey/monkey_island/cc/ui/src/components/configuration-components/ImportConfigModal.tsx index cce66a521..0b9623b1f 100644 --- a/monkey/monkey_island/cc/ui/src/components/configuration-components/ImportConfigModal.tsx +++ b/monkey/monkey_island/cc/ui/src/components/configuration-components/ImportConfigModal.tsx @@ -106,7 +106,8 @@ const ConfigImportModal = (props: Props) => { reader.onload = (event) => { let importContents = null; try { - importContents = JSON.parse(event.target.result); + let contents = event.target.result as string; + importContents = JSON.parse(contents); } catch (e){ setErrorMessage('File is not in a valid json format'); return diff --git a/monkey/monkey_island/cc/ui/src/components/ui-components/IslandResetModal.tsx b/monkey/monkey_island/cc/ui/src/components/ui-components/IslandResetModal.tsx index 8936cc077..5b3db45eb 100644 --- a/monkey/monkey_island/cc/ui/src/components/ui-components/IslandResetModal.tsx +++ b/monkey/monkey_island/cc/ui/src/components/ui-components/IslandResetModal.tsx @@ -106,17 +106,17 @@ const IslandResetModal = (props: Props) => { .then(res => { if (res.status === 200) { return auth.authFetch('/api/clear-simulation-data', {method: 'POST'}) - }) + }}) .then(res => { if (res.status === 200) { return auth.authFetch('/api/island-mode', {method: 'POST', body: '{"mode": "unset"}'}) - }) + }}) .then(res => { if (res.status !== 200) { throw 'Error resetting the simulation' } }) -} + } function showModalButtons() { return (