From 0671a3980926687514657d90fb77ef311ee6ecc9 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Wed, 28 Aug 2019 13:34:11 -0500 Subject: [PATCH] #36: Add ability to select Linux distribution type if OS is unsupported - partial --- CHANGELOG.md | 1 + public/electron.js | 30 +++++++++++-------- src/App.js | 23 ++++++++++---- .../SelectAppPlatform/SelectAppPlatform.css | 11 +++++++ .../SelectAppPlatform/SelectAppPlatform.js | 27 +++++++++++++++++ src/constants.js | 6 ++++ src/redux/actions/common_actions.js | 1 + src/redux/reducers/common_reducer.js | 8 +++++ 8 files changed, 90 insertions(+), 17 deletions(-) create mode 100644 src/components/SelectAppPlatform/SelectAppPlatform.css create mode 100644 src/components/SelectAppPlatform/SelectAppPlatform.js diff --git a/CHANGELOG.md b/CHANGELOG.md index fb75554..e89cfac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog ## 1.0.8 +* \#36: Add ability to select Linux distribution type if OS is unsupported * Added additional WinFsp uninstall strings ## 1.0.7 diff --git a/public/electron.js b/public/electron.js index 6772291..769822f 100644 --- a/public/electron.js +++ b/public/electron.js @@ -28,6 +28,7 @@ let expectedUnmount = {}; let launchHidden = false; let firstMountCheck = true; let manualMountDetection = {}; +let platformOverride; let isShutdown = false; let isQuiting = false; @@ -244,6 +245,7 @@ const loadUiSettings = () => { if (fs.statSync(settingFile).isFile()) { const settings = JSON.parse(fs.readFileSync(settingFile, 'utf8')); launchHidden = settings.launch_hidden; + platformOverride = settings.platform_override; } } catch (e) { } @@ -659,13 +661,16 @@ ipcMain.on(Constants.IPC_Get_Platform, (event) => { const platform = os.platform(); if (platform === 'linux') { - const scriptFile = path.join(os.tmpdir(), 'repertory_detect_linux.sh'); - fs.writeFileSync(scriptFile, detectScript); + if (platformOverride && (platformOverride.trim().length > 0)) { + sendResponse(platformOverride, 'linux'); + } else { + const scriptFile = path.join(os.tmpdir(), 'repertory_detect_linux.sh'); + fs.writeFileSync(scriptFile, detectScript); - helpers + helpers .executeScript(scriptFile) .then(data => { - let appPlatform = data.replace(/(\r\n|\n|\r)/gm,""); + let appPlatform = data.replace(/(\r\n|\n|\r)/gm, ""); if (appPlatform === 'unknown') { helpers .downloadFile(Constants.LINUX_DETECT_SCRIPT_URL, scriptFile, null, err => { @@ -673,14 +678,14 @@ ipcMain.on(Constants.IPC_Get_Platform, (event) => { sendResponse(appPlatform, platform); } else { helpers - .executeScript(scriptFile) - .then(data => { - appPlatform = data.replace(/(\r\n|\n|\r)/gm, ""); - sendResponse(appPlatform, platform); - }) - .catch(() => { - sendResponse(appPlatform, platform); - }); + .executeScript(scriptFile) + .then(data => { + appPlatform = data.replace(/(\r\n|\n|\r)/gm, ""); + sendResponse(appPlatform, platform); + }) + .catch(() => { + sendResponse(appPlatform, platform); + }); } }); } else { @@ -690,6 +695,7 @@ ipcMain.on(Constants.IPC_Get_Platform, (event) => { .catch(() => { sendResponse(platform, platform); }); + } } else { sendResponse(platform, platform); } diff --git a/src/App.js b/src/App.js index b0ae7f8..c36adc6 100644 --- a/src/App.js +++ b/src/App.js @@ -14,7 +14,11 @@ import MountItems from './containers/MountItems/MountItems'; import {notifyError} from './redux/actions/error_actions'; import Reboot from './components/Reboot/Reboot'; import ReleaseVersionDisplay from './components/ReleaseVersionDisplay/ReleaseVersionDisplay'; -import {saveState} from './redux/actions/common_actions'; +import { + displaySelectAppPlatform, + saveState +} from './redux/actions/common_actions'; +import SelectAppPlatform from './components/SelectAppPlatform/SelectAppPlatform'; import Text from './components/UI/Text/Text'; import UpgradeIcon from './components/UpgradeIcon/UpgradeIcon'; import UpgradeUI from './components/UpgradeUI/UpgradeUI'; @@ -30,7 +34,11 @@ class App extends IPCContainer { componentDidMount() { const detectUpgrades = () => { if (this.props.AppPlatform === 'unknown') { - this.props.notifyError('Operating system is not supported.', true); + if (this.props.Platform === 'linux') { + this.props.displaySelectAppPlatform(true); + } else { + this.props.notifyError('Operating system is not supported.', true); + } } else { this.props.loadReleases(); } @@ -119,9 +127,12 @@ class App extends IPCContainer { const downloadDisplay = this.createModalConditionally(this.props.DownloadActive, ); const errorDisplay = this.createModalConditionally(this.props.DisplayError, , true); const upgradeDisplay = this.createModalConditionally(showUpgrade, ); + const selectAppPlatformDisplay = this.createModalConditionally(this.props.DisplaySelectAppPlatform, ); let mainContent = []; - if (this.props.AppReady) { + if (this.props.DisplaySelectAppPlatform || !this.props.AppReady) { + mainContent = + } else { let key = 0; mainContent.push((
)); } - } else { - mainContent = } return (
+ {selectAppPlatformDisplay} {errorDisplay} {dependencyDisplay} {upgradeDisplay} @@ -193,12 +203,14 @@ const mapStateToProps = state => { DismissDependencies: state.install.DismissDependencies, DisplayConfiguration: state.mounts.DisplayConfiguration, DisplayError: state.error.DisplayError, + DisplaySelectAppPlatform: state.common.DisplaySelectAppPlatform, DownloadActive: state.download.DownloadActive, InstallActive: state.install.InstallActive, InstalledVersion: state.relver.InstalledVersion, LocationsLookup: state.relver.LocationsLookup, MissingDependencies: state.install.MissingDependencies, MountsBusy: state.mounts.MountsBusy, + Platform: state.common.Platform, ProviderState: state.mounts.ProviderState, RebootRequired: state.common.RebootRequired, Release: state.relver.Release, @@ -212,6 +224,7 @@ const mapStateToProps = state => { const mapDispatchToProps = dispatch => { return { + displaySelectAppPlatform: ()=> dispatch(displaySelectAppPlatform()), loadReleases: ()=> dispatch(loadReleases()), notifyError: (msg, critical, callback) => dispatch(notifyError(msg, critical, callback)), saveState: () => dispatch(saveState()), diff --git a/src/components/SelectAppPlatform/SelectAppPlatform.css b/src/components/SelectAppPlatform/SelectAppPlatform.css new file mode 100644 index 0000000..6f13ee9 --- /dev/null +++ b/src/components/SelectAppPlatform/SelectAppPlatform.css @@ -0,0 +1,11 @@ +.SAPHeading { + color: var(--text_color_error); + text-align: center; + margin-bottom: 4px; +} + +.SAPContent { + max-height: 60vh; + overflow-y: auto; + margin-bottom: 8px; +} \ No newline at end of file diff --git a/src/components/SelectAppPlatform/SelectAppPlatform.js b/src/components/SelectAppPlatform/SelectAppPlatform.js new file mode 100644 index 0000000..6da459d --- /dev/null +++ b/src/components/SelectAppPlatform/SelectAppPlatform.js @@ -0,0 +1,27 @@ +import React from 'react'; +import './SelectAppPlatform.css'; +import * as Constants from '../../constants'; +import {connect} from 'react-redux'; +import Box from '../UI/Box/Box'; +import Button from '../UI/Button/Button'; +import DropDown from '../UI/DropDown/DropDown'; +import {rebootSystem} from '../../redux/actions/common_actions'; + +const mapDispatchToProps = dispatch => { + return { + rebootSystem: () => dispatch(rebootSystem()), + }; +}; + +export default connect(null, mapDispatchToProps)(props => { + return ( + +

Select Linux Platform

+
+

Repertory was unable to detect your Linux distribution. Please select one of the following and click 'Test' to continue:

+
+ + +
+ ); +}); \ No newline at end of file diff --git a/src/constants.js b/src/constants.js index 913a7ae..e8909cb 100644 --- a/src/constants.js +++ b/src/constants.js @@ -36,6 +36,12 @@ exports.UI_RELEASES_URL = 'https://bitbucket.org/blockstorage/repertory-ui/raw/' exports.LINUX_DETECT_SCRIPT_URL = 'https://bitbucket.org/blockstorage/repertory/raw/' + REPERTORY_BRANCH + '/detect_linux.sh'; +exports.LINUX_SELECTABLE_PLATFORMS = [ + 'ubuntu18.04', + 'ubuntu18.10', + 'ubuntu19.04' +]; + exports.DATA_LOCATIONS = { linux: '~/.local/repertory/ui', darwin: '~/Library/Application Support/repertory/ui', diff --git a/src/redux/actions/common_actions.js b/src/redux/actions/common_actions.js index 72854fb..18a3bce 100644 --- a/src/redux/actions/common_actions.js +++ b/src/redux/actions/common_actions.js @@ -4,6 +4,7 @@ import {getIPCRenderer} from '../../utils'; const ipcRenderer = getIPCRenderer(); +export const displaySelectAppPlatform = createAction('common/displaySelectAppPlatform'); export const notifyRebootRequired = createAction('common/notifyRebootRequired'); export const setAllowMount = createAction('common/setAllowMount'); diff --git a/src/redux/reducers/common_reducer.js b/src/redux/reducers/common_reducer.js index a2599bc..d1b2799 100644 --- a/src/redux/reducers/common_reducer.js +++ b/src/redux/reducers/common_reducer.js @@ -1,5 +1,6 @@ import {createReducer} from 'redux-starter-kit'; import { + displaySelectAppPlatform, notifyRebootRequired, setAllowMount, setApplicationReady, @@ -10,10 +11,17 @@ export const createCommonReducer = (platform, appPlatform, version) => { AllowMount: false, AppPlatform: appPlatform, AppReady: false, + DisplaySelectAppPlatform: false, Platform: platform, RebootRequired: false, Version: version, }, { + [displaySelectAppPlatform]: (state, action) => { + return { + ...state, + DisplaySelectAppPlatform: action.payload, + } + }, [setAllowMount]: (state, action) => { return { ...state,