forked from p15670423/monkey
Island, UI: Handle the case when version couldn't be fetched
This commit is contained in:
parent
c61737abc0
commit
737070f956
|
@ -28,6 +28,11 @@ class VersionComponent extends AuthComponent {
|
||||||
|
|
||||||
newerVersionAvailable() {
|
newerVersionAvailable() {
|
||||||
const semverGt = require('semver/functions/gt');
|
const semverGt = require('semver/functions/gt');
|
||||||
|
if(this.state.latestVersion === null) {
|
||||||
|
// Couldn't fetch the latest version.
|
||||||
|
// Consider showing this state to the user
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if(this.state.latestVersion !== undefined && this.state.versionNumber !== undefined) {
|
if(this.state.latestVersion !== undefined && this.state.versionNumber !== undefined) {
|
||||||
return semverGt(this.state.latestVersion, this.state.versionNumber);
|
return semverGt(this.state.latestVersion, this.state.versionNumber);
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ class Version:
|
||||||
response = requests.get(url, timeout=LATEST_VERSION_TIMEOUT).json()
|
response = requests.get(url, timeout=LATEST_VERSION_TIMEOUT).json()
|
||||||
except requests.exceptions.RequestException as err:
|
except requests.exceptions.RequestException as err:
|
||||||
logger.warning(f"Failed to connect to {url}, Error: {err}")
|
logger.warning(f"Failed to connect to {url}, Error: {err}")
|
||||||
return self._version_number, None
|
return None, None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
download_link = response["download_link"]
|
download_link = response["download_link"]
|
||||||
|
@ -73,6 +73,6 @@ class Version:
|
||||||
f"Failed to fetch version information from {url}, response: {response}."
|
f"Failed to fetch version information from {url}, response: {response}."
|
||||||
f"Most likely deployment {self._deployment.value} is not recognized."
|
f"Most likely deployment {self._deployment.value} is not recognized."
|
||||||
)
|
)
|
||||||
return self._version_number, None
|
return None, None
|
||||||
|
|
||||||
return latest_version, download_link
|
return latest_version, download_link
|
||||||
|
|
Loading…
Reference in New Issue