From ad4e312d7ac3bf7d9606bdfec44a3f0e9d70b309 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Mon, 24 May 2021 21:28:26 -0500 Subject: [PATCH] Remove Linux platform selection --- src/App.jsx | 22 +--- src/constants.js | 5 +- .../SelectAppPlatform/SelectAppPlatform.css | 18 --- .../SelectAppPlatform/SelectAppPlatform.js | 104 ------------------ src/redux/actions/common_actions.js | 20 ---- src/redux/actions/download_actions.js | 12 +- src/redux/actions/install_actions.js | 40 ------- src/redux/reducers/common_reducer.js | 9 -- src/renderer/ipc/PlatformIPC.js | 82 +++++--------- 9 files changed, 36 insertions(+), 276 deletions(-) delete mode 100644 src/containers/SelectAppPlatform/SelectAppPlatform.css delete mode 100644 src/containers/SelectAppPlatform/SelectAppPlatform.js diff --git a/src/App.jsx b/src/App.jsx index 00e0a30..22bc1c2 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -20,8 +20,7 @@ import { setNewReleasesAvailable, } from './redux/actions/release_version_actions'; import ReleaseVersionDisplay from './components/ReleaseVersionDisplay/ReleaseVersionDisplay'; -import { displaySelectAppPlatform, saveState } from './redux/actions/common_actions'; -import SelectAppPlatform from './containers/SelectAppPlatform/SelectAppPlatform'; +import { saveState } from './redux/actions/common_actions'; import Text from './components/UI/Text/Text'; import UpgradeIcon from './components/UpgradeIcon/UpgradeIcon'; import UpgradeUI from './components/UpgradeUI/UpgradeUI'; @@ -40,11 +39,7 @@ class App extends IPCContainer { componentDidMount() { const detectUpgrades = () => { if (this.props.AppPlatform === 'unknown') { - if (this.props.Platform === 'linux') { - this.props.displaySelectAppPlatform(true); - } else { - this.props.notifyError('Operating system is not supported.', true); - } + this.props.notifyError('Operating system is not supported.', true); } else { this.props.loadReleases(); } @@ -163,7 +158,6 @@ class App extends IPCContainer { !this.props.DisplayInfo && !this.props.InstallActive && !this.props.RebootRequired && - !this.props.DisplaySelectAppPlatform && !showUpgrade && !this.props.DismissNewReleasesAvailable && this.props.NewReleasesAvailable.length > 0; @@ -173,7 +167,6 @@ class App extends IPCContainer { !this.props.DownloadActive && !showNewReleases && !this.props.RebootRequired && - !this.props.DisplaySelectAppPlatform && !showUpgrade && this.props.DisplayAddEditHost; @@ -183,7 +176,6 @@ class App extends IPCContainer { !this.props.DownloadActive && !showNewReleases && !this.props.RebootRequired && - !this.props.DisplaySelectAppPlatform && !showUpgrade && this.props.DisplayImport; @@ -193,7 +185,6 @@ class App extends IPCContainer { !this.props.DownloadActive && !showNewReleases && !this.props.RebootRequired && - !this.props.DisplaySelectAppPlatform && !showUpgrade && this.props.DisplayExport; @@ -227,10 +218,6 @@ class App extends IPCContainer { const infoDisplay = createModalConditionally(this.props.DisplayInfo, , true); const newReleasesDisplay = createModalConditionally(showNewReleases, ); const rebootDisplay = createModalConditionally(this.props.RebootRequired, ); - const selectAppPlatformDisplay = createModalConditionally( - this.props.DisplaySelectAppPlatform, - - ); const upgradeDisplay = createModalConditionally(showUpgrade, ); const importDisplay = createModalConditionally( showSkynetImport, @@ -249,7 +236,7 @@ class App extends IPCContainer { ); let mainContent = []; - if (this.props.DisplaySelectAppPlatform || !this.props.AppReady) { + if (!this.props.AppReady) { mainContent = ( @@ -337,7 +324,6 @@ class App extends IPCContainer { {importDisplay} {exportDisplay} {newReleasesDisplay} - {selectAppPlatformDisplay} {dependencyDisplay} {upgradeDisplay} {pinnedManagerDisplay} @@ -371,7 +357,6 @@ const mapStateToProps = (state) => { DisplayImport: state.skynet.DisplayImport, DisplayInfo: state.error.DisplayInfo, DisplayPinnedManager: state.pinned.DisplayPinnedManager, - DisplaySelectAppPlatform: state.common.DisplaySelectAppPlatform, DismissNewReleasesAvailable: state.relver.DismissNewReleasesAvailable, DownloadActive: state.download.DownloadActive, InstallActive: state.install.InstallActive, @@ -395,7 +380,6 @@ const mapStateToProps = (state) => { const mapDispatchToProps = (dispatch) => { return { - displaySelectAppPlatform: (display) => dispatch(displaySelectAppPlatform(display)), loadReleases: () => dispatch(loadReleases()), notifyError: (msg, critical, callback) => dispatch(notifyError(msg, critical, callback)), saveState: () => dispatch(saveState()), diff --git a/src/constants.js b/src/constants.js index 4e91caf..70120e1 100644 --- a/src/constants.js +++ b/src/constants.js @@ -40,7 +40,7 @@ exports.UI_RELEASES_URL = exports.LINUX_DETECT_SCRIPT_URL = 'https://bitbucket.org/blockstorage/repertory/raw/' + _REPERTORY_BRANCH + '/detect_linux2.sh'; -exports.LINUX_SELECTABLE_PLATFORMS = ['centos7']; +exports.LINUX_SELECTABLE_PLATFORMS = ['linux']; exports.WINFSP_VERSION_NAMES = [ 'WinFsp 2019', @@ -106,7 +106,6 @@ exports.RELEASE_TYPES = ['Release', 'RC', 'Beta', 'Alpha']; exports.INSTALL_TYPES = { Dependency: 'dependency', Release: 'release', - TestRelease: 'test_release', Upgrade: 'upgrade', }; @@ -196,8 +195,6 @@ exports.IPC_Show_Window = 'show_window'; exports.IPC_Set_Config_Values = 'set_config_values'; exports.IPC_Set_Config_Values_Reply = 'set_config_values_reply'; -exports.IPC_Set_Linux_AppPlatform = 'IPC_Set_Linux_AppPlatform'; - exports.IPC_Shutdown = 'shutdown'; exports.IPC_Skynet_Test_Logon = 'skynet_test_logon'; diff --git a/src/containers/SelectAppPlatform/SelectAppPlatform.css b/src/containers/SelectAppPlatform/SelectAppPlatform.css deleted file mode 100644 index b1eacb2..0000000 --- a/src/containers/SelectAppPlatform/SelectAppPlatform.css +++ /dev/null @@ -1,18 +0,0 @@ -.SAPHeading { - color: var(--text_color_error); - text-align: center; - margin-bottom: 4px; -} - -.SAPContent { - max-height: 60vh; - width: 255px; - overflow-y: auto; - margin-bottom: var(--default_spacing); -} - -.SAPActions { - margin-top: 4px; - display: flex; - flex-direction: row; -} diff --git a/src/containers/SelectAppPlatform/SelectAppPlatform.js b/src/containers/SelectAppPlatform/SelectAppPlatform.js deleted file mode 100644 index bac9e8a..0000000 --- a/src/containers/SelectAppPlatform/SelectAppPlatform.js +++ /dev/null @@ -1,104 +0,0 @@ -import React from 'react'; -import './SelectAppPlatform.css'; -import axios from 'axios'; -import { connect } from 'react-redux'; -import * as Constants from '../../constants'; -import Box from '../../components/UI/Box/Box'; -import Button from '../../components/UI/Button/Button'; -import { downloadItem, setAllowDownload } from '../../redux/actions/download_actions'; -import DropDown from '../../components/UI/DropDown/DropDown'; -import IPCContainer from '../IPCContainer/IPCContainer'; -import { notifyError } from '../../redux/actions/error_actions'; -import { setInstallTestActive } from '../../redux/actions/install_actions'; - -class SelectAppPlatform extends IPCContainer { - state = { - Selected: 0, - }; - - grabLatestRelease = (appPlatform) => { - const errorHandler = (error) => { - this.props.notifyError(error); - this.props.setInstallTestActive(false); - this.props.setAllowDownload(false); - }; - axios - .get(Constants.RELEASES_URL) - .then((response) => { - try { - const releases = response.data.Versions.Release[appPlatform]; - const latestVersion = releases[releases.length - 1]; - const release = response.data.Locations[appPlatform][latestVersion]; - this.props.downloadItem( - latestVersion + '.zip', - Constants.INSTALL_TYPES.TestRelease, - release.urls, - false, - latestVersion, - appPlatform - ); - } catch (error) { - errorHandler(error); - } - }) - .catch((error) => { - errorHandler(error); - }); - }; - - handleTestClicked = () => { - this.props.setInstallTestActive(true); - this.props.setAllowDownload(true); - this.grabLatestRelease(Constants.LINUX_SELECTABLE_PLATFORMS[this.state.Selected]); - }; - - handleChanged = (e) => { - this.setState({ - ...this.state, - Selected: Constants.LINUX_SELECTABLE_PLATFORMS.indexOf(e.target.value), - }); - }; - - render() { - return ( - -

Select Linux Platform

-
-

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

-
-
- - -
-
- ); - } -} - -const mapStateToProps = (state) => { - return { - InstallTestActive: state.install.InstallTestActive, - }; -}; - -const mapDispatchToProps = (dispatch) => { - return { - downloadItem: (name, type, urls, isWinFSP, testVersion, appPlatform) => - dispatch(downloadItem(name, type, urls, isWinFSP, testVersion, appPlatform)), - notifyError: (msg) => dispatch(notifyError(msg)), - setAllowDownload: (allow) => dispatch(setAllowDownload(allow)), - setInstallTestActive: (active) => dispatch(setInstallTestActive(active)), - }; -}; - -export default connect(mapStateToProps, mapDispatchToProps)(SelectAppPlatform); diff --git a/src/redux/actions/common_actions.js b/src/redux/actions/common_actions.js index c3557f5..445f3ac 100644 --- a/src/redux/actions/common_actions.js +++ b/src/redux/actions/common_actions.js @@ -8,16 +8,6 @@ import { getIPCRenderer } from '../../utils.jsx'; const ipcRenderer = getIPCRenderer(); -export const displaySelectAppPlatform = (display) => { - return (dispatch) => { - if (display) { - dispatch(showWindow()); - } - - dispatch(setDisplaySelectAppPlatform(display)); - }; -}; - export const NOTIFY_APPLICATION_BUSY = 'common/notifyApplicationBusy'; export const notifyApplicationBusy = (busy, transparent) => { return { @@ -67,16 +57,6 @@ export const saveState = () => { export const setAllowMount = createAction('common/setAllowMount'); export const setApplicationReady = createAction('common/setApplicationReady'); -export const SET_DISPLAY_SELECT_APPPLATFORM = 'common/displaySelectAppPlatform'; -export const setDisplaySelectAppPlatform = (display) => { - return { - type: SET_DISPLAY_SELECT_APPPLATFORM, - payload: display, - }; -}; - -export const setLinuxAppPlatform = createAction('common/setLinuxAppPlatform'); - export const setRebootRequired = () => { return (dispatch) => { dispatch(showWindow()); diff --git a/src/redux/actions/download_actions.js b/src/redux/actions/download_actions.js index 492d6a2..23a9b57 100644 --- a/src/redux/actions/download_actions.js +++ b/src/redux/actions/download_actions.js @@ -4,12 +4,7 @@ import * as Constants from '../../constants'; import { getIPCRenderer } from '../../utils.jsx'; import { notifyError } from './error_actions'; -import { - installAndTestRelease, - installDependency, - installRelease, - installUpgrade, -} from './install_actions'; +import { installDependency, installRelease, installUpgrade } from './install_actions'; export const setAllowDownload = createAction('download/setAllowDownload'); @@ -21,7 +16,7 @@ export const setDownloadBegin = (name, type, url) => { export const setDownloadEnd = createAction('download/setDownloadEnd'); export const setDownloadProgress = createAction('download/setDownloadProgress'); -export const downloadItem = (name, type, urls, isWinFSP, testVersion, appPlatform) => { +export const downloadItem = (name, type, urls, isWinFSP) => { return (dispatch, getState) => { if (!Array.isArray(urls)) { urls = [urls]; @@ -36,9 +31,6 @@ export const downloadItem = (name, type, urls, isWinFSP, testVersion, appPlatfor case Constants.INSTALL_TYPES.Release: dispatch(installRelease(result.Destination)); break; - case Constants.INSTALL_TYPES.TestRelease: - dispatch(installAndTestRelease(result.Destination, testVersion, appPlatform)); - break; case Constants.INSTALL_TYPES.Upgrade: // const info = // this.props.LocationsLookup[this.props.AppPlatform][this.props.VersionLookup[this.props.AppPlatform][0]]; diff --git a/src/redux/actions/install_actions.js b/src/redux/actions/install_actions.js index b605d4d..cdfb08b 100644 --- a/src/redux/actions/install_actions.js +++ b/src/redux/actions/install_actions.js @@ -5,10 +5,8 @@ import { getIPCRenderer, getSelectedVersionFromState } from '../../utils.jsx'; import { confirmYesNoAction, - displaySelectAppPlatform, setAllowMount, setApplicationReady, - setLinuxAppPlatform, setRebootRequired, showWindow, shutdownApplication, @@ -17,7 +15,6 @@ import { downloadItem, setAllowDownload } from './download_actions'; import { notifyError } from './error_actions'; import { unmountAll } from './mount_actions'; import { - loadReleases, setActiveRelease, setInstalledVersion, setNewReleasesAvailable2, @@ -157,43 +154,6 @@ export const installDependency = (source, url, isWinFSP) => { }; }; -export const installAndTestRelease = (source, version, appPlatform) => { - return (dispatch, getState) => { - if (ipcRenderer && getState().install.InstallTestActive) { - const extractReleaseComplete = () => { - ipcRenderer.send(Constants.IPC_Delete_File, { - FilePath: source, - }); - - ipcRenderer.once(Constants.IPC_Test_Release_Reply, (_, arg) => { - if (arg.data.Success) { - ipcRenderer.sendSync(Constants.IPC_Set_Linux_AppPlatform, { - AppPlatform: appPlatform, - }); - dispatch(setLinuxAppPlatform(appPlatform)); - dispatch(setInstallTestActive(false)); - dispatch(displaySelectAppPlatform(false)); - dispatch(setAllowDownload(false)); - dispatch(loadReleases()); - } else { - dispatch(notifyError(arg.data.Error)); - dispatch(setInstallTestActive(false)); - } - }); - ipcRenderer.send(Constants.IPC_Test_Release, { - Version: version, - }); - }; - - ipcRenderer.once(Constants.IPC_Extract_Release_Complete, extractReleaseComplete); - ipcRenderer.send(Constants.IPC_Extract_Release, { - Source: source, - Version: version, - }); - } - }; -}; - export const installReleaseByVersion = (release, version) => { return (dispatch, getState) => { const install = () => { diff --git a/src/redux/reducers/common_reducer.js b/src/redux/reducers/common_reducer.js index 6efc45a..86cb10a 100644 --- a/src/redux/reducers/common_reducer.js +++ b/src/redux/reducers/common_reducer.js @@ -3,10 +3,8 @@ import { confirmYesNoAction, NOTIFY_APPLICATION_BUSY, notifyRebootRequired, - SET_DISPLAY_SELECT_APPPLATFORM, setAllowMount, setApplicationReady, - setLinuxAppPlatform, } from '../actions/common_actions'; export const createCommonReducer = (platformInfo, version) => { @@ -19,7 +17,6 @@ export const createCommonReducer = (platformInfo, version) => { AppReady: false, DisplayConfirmYesNo: false, ConfirmTitle: null, - DisplaySelectAppPlatform: false, Platform: platformInfo.Platform, RebootRequired: false, Version: version, @@ -33,9 +30,6 @@ export const createCommonReducer = (platformInfo, version) => { action.payload.display && action.payload.data ? action.payload.data.title : null, }; }, - [SET_DISPLAY_SELECT_APPPLATFORM]: (state, action) => { - return { ...state, DisplaySelectAppPlatform: action.payload }; - }, [setAllowMount]: (state, action) => { return { ...state, AllowMount: action.payload }; }, @@ -45,9 +39,6 @@ export const createCommonReducer = (platformInfo, version) => { AppReady: action.payload, }; }, - [setLinuxAppPlatform]: (state, action) => { - return { ...state, AppPlatform: action.payload }; - }, [NOTIFY_APPLICATION_BUSY]: (state, action) => { return { ...state, diff --git a/src/renderer/ipc/PlatformIPC.js b/src/renderer/ipc/PlatformIPC.js index 9501d08..7fd096e 100644 --- a/src/renderer/ipc/PlatformIPC.js +++ b/src/renderer/ipc/PlatformIPC.js @@ -4,17 +4,7 @@ const helpers = require('../../helpers'); const os = require('os'); const path = require('path'); -let _platformOverride; - -const getPlatformOverride = () => { - return _platformOverride; -}; - -const setPlatformOverride = (platformOverride) => { - _platformOverride = platformOverride; -}; - -const addListeners = (ipcMain, { detectScript, saveUiSettings }) => { +const addListeners = (ipcMain, { detectScript }) => { ipcMain.on(Constants.IPC_Get_Platform, (event) => { const sendResponse = (appPlatform, platform) => { event.sender.send(Constants.IPC_Get_Platform_Reply, { @@ -25,54 +15,42 @@ const addListeners = (ipcMain, { detectScript, saveUiSettings }) => { const platform = os.platform(); if (platform === 'linux') { - if (_platformOverride && _platformOverride.length > 0) { - sendResponse(_platformOverride, 'linux'); - } else { - const scriptFile = path.join(os.tmpdir(), 'repertory_detect_linux.sh'); - fs.writeFileSync(scriptFile, detectScript); + const scriptFile = path.join(os.tmpdir(), 'repertory_detect_linux.sh'); + fs.writeFileSync(scriptFile, detectScript); - helpers - .executeScript(scriptFile) - .then((data) => { - let appPlatform = data.replace(/(\r\n|\n|\r)/gm, ''); - if (appPlatform === 'unknown') { - helpers.downloadFile(Constants.LINUX_DETECT_SCRIPT_URL, scriptFile, null, (err) => { - if (err) { - sendResponse(appPlatform, platform); - } else { - helpers - .executeScript(scriptFile) - .then((data) => { - appPlatform = data.replace(/(\r\n|\n|\r)/gm, ''); - sendResponse(appPlatform, platform); - }) - .catch(() => { - sendResponse(appPlatform, platform); - }); - } - }); - } else { - sendResponse(appPlatform, platform); - } - }) - .catch(() => { - sendResponse(platform, platform); - }); - } + helpers + .executeScript(scriptFile) + .then((data) => { + let appPlatform = data.replace(/(\r\n|\n|\r)/gm, ''); + if (appPlatform === 'unknown') { + helpers.downloadFile(Constants.LINUX_DETECT_SCRIPT_URL, scriptFile, null, (err) => { + if (err) { + sendResponse(appPlatform, platform); + } else { + helpers + .executeScript(scriptFile) + .then((data) => { + appPlatform = data.replace(/(\r\n|\n|\r)/gm, ''); + sendResponse(appPlatform, platform); + }) + .catch(() => { + sendResponse(appPlatform, platform); + }); + } + }); + } else { + sendResponse(appPlatform, platform); + } + }) + .catch(() => { + sendResponse(platform, platform); + }); } else { sendResponse(platform, platform); } }); - - ipcMain.on(Constants.IPC_Set_Linux_AppPlatform, (event, data) => { - setPlatformOverride(data.AppPlatform); - saveUiSettings(); - event.returnValue = true; - }); }; module.exports = { - getPlatformOverride, - setPlatformOverride, addListeners, };