diff --git a/src/containers/HostList/Host/Host.js b/src/containers/HostList/Host/Host.js index 6fb755b..485e642 100644 --- a/src/containers/HostList/Host/Host.js +++ b/src/containers/HostList/Host/Host.js @@ -21,6 +21,16 @@ const Host = ({ allowDelete, editHost, host_list, host_data, onChange, onDelete }); }; + const getHostDisplay = () => { + return ( + host_data.HostNameOrIp + + ((host_data.Protocol === 'http' && host_data.ApiPort === 80) || + (host_data.Protocol === 'https' && host_data.ApiPort === 443) + ? '' + : ':' + host_data.ApiPort) + ); + }; + const premium = host_data.AuthURL && host_data.AuthUser; return (
@@ -46,23 +56,10 @@ const Host = ({ allowDelete, editHost, host_list, host_data, onChange, onDelete ) : null} {premium ? (

- - {'(premium) ' + - host_data.HostNameOrIp + - ((host_data.Protocol === 'http' && host_data.ApiPort === 80) || - (host_data.Protocol === 'https' && host_data.ApiPort === 443) - ? '' - : ':' + host_data.ApiPort)} - + {'(premium) ' + getHostDisplay()}

) : ( -

- {host_data.HostNameOrIp + - ((host_data.Protocol === 'http' && host_data.ApiPort === 80) || - (host_data.Protocol === 'https' && host_data.ApiPort === 443) - ? '' - : ':' + host_data.ApiPort)} -

+

{getHostDisplay()}

)}
); @@ -78,4 +75,3 @@ Host.propTypes = { }; export default connect(null, mapDispatchToProps)(Host); -// export default Host; diff --git a/src/containers/MountItems/MountItems.js b/src/containers/MountItems/MountItems.js index d6c675c..0f78738 100644 --- a/src/containers/MountItems/MountItems.js +++ b/src/containers/MountItems/MountItems.js @@ -67,11 +67,9 @@ class MountItems extends IPCContainer { } componentWillUnmount() { - for (const provider in this.state.RetryItems) { - if (Object.prototype.hasOwnProperty.call(this.state.RetryItems, provider)) { - this.cancelRetryMount(provider); - } - } + Object.keys(this.state.RetryItems).forEach((provider) => { + this.cancelRetryMount(provider); + }); this.props.resetMountsState(); this.activeDetections = []; @@ -91,8 +89,7 @@ class MountItems extends IPCContainer { detectMounts = () => { if (!this.state.DisplayRetry) { - const providerList = this.getProviderList(); - providerList.forEach((provider) => { + this.getProviderList().forEach((provider) => { this.detectMount(provider); }); } @@ -121,7 +118,7 @@ class MountItems extends IPCContainer { () => { this.sendRequest(Constants.IPC_Show_Window); this.retryIntervals[provider] = setInterval(() => { - let retryItems = { + const retryItems = { ...this.state.RetryItems, }; const retrySeconds = retryItems[provider].RetrySeconds - 1; @@ -174,6 +171,9 @@ class MountItems extends IPCContainer { S3: s3, Version: this.props.InstalledVersion, }).data; + const displayRetry = (msg) => { + this.displayRetryMount(provider, remote, s3, location, msg); + }; if (result.Success) { if (result.Valid) { if (this.props.Platform !== 'win32') { @@ -191,32 +191,16 @@ class MountItems extends IPCContainer { result.Code === new Uint32Array([-1])[0] || result.Code === new Uint8Array([-1])[0] ) { - this.displayRetryMount( - provider, - remote, - s3, - location, - 'Failed to connect to ' + provider + ' daemon' - ); + displayRetry('Failed to connect to ' + provider + ' daemon'); } else if ( result.Code === new Uint32Array([-3])[0] || result.Code === new Uint8Array([-3])[0] ) { - this.displayRetryMount( - provider, - remote, - s3, - location, + displayRetry( 'Incompatible ' + provider + ' daemon. Please upgrade ' + provider + '.' ); } else { - this.displayRetryMount( - provider, - remote, - s3, - location, - 'Version check failed: ' + result.Error - ); + displayRetry('Version check failed: ' + result.Error); } } } else { @@ -226,13 +210,7 @@ class MountItems extends IPCContainer { 'Failed to launch repertory. Please install Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019.' ); } else { - this.displayRetryMount( - provider, - remote, - s3, - location, - 'Version check failed: ' + result.Error - ); + displayRetry('Version check failed: ' + result.Error); } } } @@ -241,23 +219,13 @@ class MountItems extends IPCContainer { this.addMountsBusy(provider); this.props.setAllowMount(provider, false); - if (mount) { - this.sendRequest(Constants.IPC_Mount_Drive, { - Location: location, - Provider: provider, - Remote: remote, - S3: s3, - Version: this.props.InstalledVersion, - }); - } else { - this.sendRequest(Constants.IPC_Unmount_Drive, { - Location: location, - Provider: provider, - Remote: remote, - S3: s3, - Version: this.props.InstalledVersion, - }); - } + this.sendRequest(mount ? Constants.IPC_Mount_Drive : Constants.IPC_Unmount_Drive, { + Location: location, + Provider: provider, + Remote: remote, + S3: s3, + Version: this.props.InstalledVersion, + }); } } }; @@ -285,11 +253,9 @@ class MountItems extends IPCContainer { }; hasActiveMount = () => { - for (const provider of Object.keys(this.props.MountState)) { - if (this.props.MountState[provider].Mounted) return true; - } - - return false; + return !!Object.keys(this.props.MountState).find((provider) => { + return this.props.MountState[provider].Mounted; + }); }; onDetectMountReply = (_, arg) => { @@ -384,32 +350,27 @@ class MountItems extends IPCContainer { render() { let retryDisplay; if (this.state.DisplayRetry) { - let retryList = []; + const retryList = []; let retryCount = 0; - for (const provider in this.state.RetryItems) { - if (Object.prototype.hasOwnProperty.call(this.state.RetryItems, provider)) { - if (this.state.RetryItems[provider].RetryMessage) { - retryList.push( -

{this.state.RetryItems[provider].RetryMessage}

- ); - } + Object.keys(this.state.RetryItems).forEach((provider) => { + if (this.state.RetryItems[provider].RetryMessage) { retryList.push( - +

{this.state.RetryItems[provider].RetryMessage}

); - if (++retryCount < Object.keys(this.state.RetryItems).length) { - retryList.push( -
- ); - } } - } + retryList.push( + + ); + if (++retryCount < Object.keys(this.state.RetryItems).length) { + retryList.push( +
+ ); + } + }); retryDisplay = ( @@ -428,7 +389,7 @@ class MountItems extends IPCContainer { ); } - let footerItems = []; + const footerItems = []; if (this.props.remoteSupported || this.props.s3Supported) { footerItems.push( ); } - let mountItems = []; + const mountItems = []; const addMountItem = (provider, remote, s3) => { if (mountItems.length > 0) { mountItems.push( @@ -466,20 +427,14 @@ class MountItems extends IPCContainer { ); }; - for (const provider of this.getProviderList(true)) { - addMountItem(provider); - } + this.getProviderList(true).forEach((provider) => addMountItem(provider)); if (this.props.remoteSupported) { - for (const provider of this.props.RemoteMounts) { - addMountItem(provider, true); - } + this.props.RemoteMounts.forEach((provider) => addMountItem(provider, true)); } if (this.props.s3Supported) { - for (const provider of this.props.S3Mounts) { - addMountItem(provider, false, true); - } + this.props.S3Mounts.forEach((provider) => addMountItem(provider, false, true)); } return (