From 1e1f3ce3a12ea6167dc5e0e903eff40a876e752e Mon Sep 17 00:00:00 2001 From: Khaliq Date: Thu, 15 Feb 2024 08:56:17 +0200 Subject: [PATCH] [nan-377] restore connection details (#1677) --- .../webapp/src/pages/ConnectionDetails.tsx | 135 ++++++++---------- 1 file changed, 57 insertions(+), 78 deletions(-) diff --git a/packages/webapp/src/pages/ConnectionDetails.tsx b/packages/webapp/src/pages/ConnectionDetails.tsx index e1f5155246..7dbf15f739 100644 --- a/packages/webapp/src/pages/ConnectionDetails.tsx +++ b/packages/webapp/src/pages/ConnectionDetails.tsx @@ -38,7 +38,6 @@ interface Connection { export default function ConnectionDetails() { const [loaded, setLoaded] = useState(false); const [syncLoaded, setSyncLoaded] = useState(false); - const [lastCommand, setLastCommand] = useState(); const [fetchingRefreshToken, setFetchingRefreshToken] = useState(false); const [syncs, setSyncs] = useState([]); const [serverErrorMessage, setServerErrorMessage] = useState(''); @@ -127,7 +126,6 @@ We could not retrieve and/or refresh your access token due to the following erro try { const data = await res.json(); setSyncs(data); - setLastCommand(null); } catch (e) { console.log(e); } @@ -145,12 +143,10 @@ We could not retrieve and/or refresh your access token due to the following erro const res = await runCommandSyncAPI(command, scheduleId, nango_connection_id, syncId, syncName, connection?.provider); if (res?.status === 200) { - if (command === 'RUN' || command === 'UNPAUSE') { - setLastCommand('RUN'); - } else if (command === 'CANCEL') { - setLastCommand('CANCEL'); - } else { + try { setSyncLoaded(false); + } catch (e) { + console.log(e); } } }; @@ -484,71 +480,62 @@ We could not retrieve and/or refresh your access token due to the following erro
  • - {lastCommand !== 'RUN' && ( - <> - {sync.schedule_status === 'PAUSED' && sync.latest_sync?.status !== 'RUNNING' && ( -
    - -

    stopped

    -
    - )} - - {sync?.schedule_status === 'RUNNING' && sync?.latest_sync === null && ( -
    - -
    - )} - {sync?.latest_sync?.status === 'STOPPED' && - sync.schedule_status !== 'PAUSED' && - (sync.latest_sync.activity_log_id && sync.latest_sync.activity_log_id !== null ? ( - - - - ) : ( -
    - -
    - ))} - {sync.latest_sync?.status === 'SUCCESS' && - sync.schedule_status !== 'PAUSED' && - (sync.latest_sync?.activity_log_id !== null ? ( - - - - - - ) : ( - -
    - -
    -
    - ))} - + {sync.schedule_status === 'PAUSED' && sync.latest_sync?.status !== 'RUNNING' && ( +
    + +

    stopped

    +
    )} - {lastCommand !== 'CANCEL' && ( - <> - {(sync.latest_sync?.status === 'RUNNING' || lastCommand === 'RUN') && - (sync.latest_sync.activity_log_id && sync.latest_sync?.activity_log_id !== null ? ( - - - - ) : ( -
    - -
    - ))} - + {sync?.schedule_status === 'RUNNING' && sync?.latest_sync === null && ( +
    + +
    )} + {sync?.latest_sync?.status === 'STOPPED' && + sync.schedule_status !== 'PAUSED' && + (sync.latest_sync.activity_log_id && sync.latest_sync.activity_log_id !== null ? ( + + + + ) : ( +
    + +
    + ))} + {sync.latest_sync?.status === 'RUNNING' && + (sync.latest_sync.activity_log_id && sync.latest_sync?.activity_log_id !== null ? ( + + + + ) : ( +
    + +
    + ))} + {sync.latest_sync?.status === 'SUCCESS' && + sync.schedule_status !== 'PAUSED' && + (sync.latest_sync?.activity_log_id !== null ? ( + + + + + + ) : ( + +
    + +
    +
    + ))}
  • {sync.latest_sync?.result && Object.keys(sync.latest_sync?.result).length > 0 ? ( {parseLatestSyncResult(sync.latest_sync.result, sync.latest_sync.models)}} type="dark"> @@ -626,14 +613,6 @@ We could not retrieve and/or refresh your access token due to the following erro >

    Trigger

    - {(sync.latest_sync?.status === 'RUNNING' || lastCommand === 'RUN') && ( - - )} {/*