diff --git a/public/electron.js b/public/electron.js index 769822f..7f17196 100644 --- a/public/electron.js +++ b/public/electron.js @@ -284,6 +284,7 @@ const saveUiSettings = () => { try { fs.writeFileSync(settingFile, JSON.stringify({ launch_hidden: launchHidden, + platform_override: platformOverride, }), 'utf-8'); } catch (e) { } @@ -662,7 +663,7 @@ ipcMain.on(Constants.IPC_Get_Platform, (event) => { const platform = os.platform(); if (platform === 'linux') { if (platformOverride && (platformOverride.trim().length > 0)) { - sendResponse(platformOverride, 'linux'); + sendResponse(platformOverride.trim(), 'linux'); } else { const scriptFile = path.join(os.tmpdir(), 'repertory_detect_linux.sh'); fs.writeFileSync(scriptFile, detectScript); @@ -948,6 +949,12 @@ ipcMain.on(Constants.IPC_Set_Config_Values, (event, data) => { setConfigValue(0); }); +ipcMain.on(Constants.IPC_Set_Linux_AppPlatform, (event, data) => { + platformOverride = data.AppPlatform; + saveUiSettings(); + event.returnValue = true; +}); + ipcMain.on(Constants.IPC_Shutdown, () => { closeApplication(); }); diff --git a/src/App.js b/src/App.js index c36adc6..6f15cbe 100644 --- a/src/App.js +++ b/src/App.js @@ -18,7 +18,7 @@ import { displaySelectAppPlatform, saveState } from './redux/actions/common_actions'; -import SelectAppPlatform from './components/SelectAppPlatform/SelectAppPlatform'; +import SelectAppPlatform from './containers/SelectAppPlatform/SelectAppPlatform'; import Text from './components/UI/Text/Text'; import UpgradeIcon from './components/UpgradeIcon/UpgradeIcon'; import UpgradeUI from './components/UpgradeUI/UpgradeUI'; @@ -43,8 +43,8 @@ class App extends IPCContainer { this.props.loadReleases(); } }; - this.scheduledUpdateJob = Scheduler.scheduleJob('23 11 * * *', detectUpgrades); detectUpgrades(); + this.scheduledUpdateJob = Scheduler.scheduleJob('23 11 * * *', detectUpgrades); } componentDidUpdate(prevProps) { @@ -224,7 +224,7 @@ const mapStateToProps = state => { const mapDispatchToProps = dispatch => { return { - displaySelectAppPlatform: ()=> dispatch(displaySelectAppPlatform()), + displaySelectAppPlatform: display => dispatch(displaySelectAppPlatform(display)), loadReleases: ()=> dispatch(loadReleases()), notifyError: (msg, critical, callback) => dispatch(notifyError(msg, critical, callback)), saveState: () => dispatch(saveState()), diff --git a/src/components/SelectAppPlatform/SelectAppPlatform.js b/src/components/SelectAppPlatform/SelectAppPlatform.js deleted file mode 100644 index 6da459d..0000000 --- a/src/components/SelectAppPlatform/SelectAppPlatform.js +++ /dev/null @@ -1,27 +0,0 @@ -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 e8909cb..ddb1916 100644 --- a/src/constants.js +++ b/src/constants.js @@ -28,7 +28,8 @@ exports.DEV_PUBLIC_KEY = '-----BEGIN PUBLIC KEY-----\n' + '-----END PUBLIC KEY-----'; -const REPERTORY_BRANCH = '1.1.0-release_branch'; +//const REPERTORY_BRANCH = '1.1.0-release_branch'; +const REPERTORY_BRANCH = 'master'; const REPERTORY_UI_BRANCH = '1.0.8_branch'; exports.RELEASES_URL = 'https://bitbucket.org/blockstorage/repertory/raw/' + REPERTORY_BRANCH + '/releases.json'; @@ -68,6 +69,7 @@ exports.RELEASE_TYPES = [ exports.INSTALL_TYPES = { Dependency: 'dependency', Release: 'release', + TestRelease: 'test_release', Upgrade: 'upgrade', }; @@ -126,8 +128,13 @@ 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_Test_Release = 'test_release'; +exports.IPC_Test_Release_Reply = 'test_release_reply'; + exports.IPC_Unmount_All_Drives = 'unmount_all'; exports.IPC_Unmount_All_Drives_Reply = 'unmount_all_reply'; diff --git a/src/components/SelectAppPlatform/SelectAppPlatform.css b/src/containers/SelectAppPlatform/SelectAppPlatform.css similarity index 64% rename from src/components/SelectAppPlatform/SelectAppPlatform.css rename to src/containers/SelectAppPlatform/SelectAppPlatform.css index 6f13ee9..723c7f6 100644 --- a/src/components/SelectAppPlatform/SelectAppPlatform.css +++ b/src/containers/SelectAppPlatform/SelectAppPlatform.css @@ -6,6 +6,13 @@ .SAPContent { max-height: 60vh; + width: 255px; overflow-y: auto; margin-bottom: 8px; -} \ No newline at end of file +} + +.SAPActions { + margin-top: 4px; + display: flex; + flex-direction: row; +} diff --git a/src/containers/SelectAppPlatform/SelectAppPlatform.js b/src/containers/SelectAppPlatform/SelectAppPlatform.js new file mode 100644 index 0000000..10f4f2e --- /dev/null +++ b/src/containers/SelectAppPlatform/SelectAppPlatform.js @@ -0,0 +1,83 @@ +import React from 'react'; +import IPCContainer from '../IPCContainer/IPCContainer'; +import './SelectAppPlatform.css'; +import * as Constants from '../../constants'; +import {connect} from 'react-redux'; +import Box from '../../components/UI/Box/Box'; +import Button from '../../components/UI/Button/Button'; +import {downloadItem} from '../../redux/actions/download_actions'; +import DropDown from '../../components/UI/DropDown/DropDown'; +import axios from 'axios'; +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); + }; + 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.grabLatestRelease(Constants.LINUX_SELECTABLE_PLATFORMS[this.state.Selected]) + }; + + render() { + return ( + +

Select Linux Platform

+
+

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

+
+
+ this.setState({ + ...this.state, + Selected: e.target.value + })} + disabled={this.props.InstallTestActive} + items={Constants.LINUX_SELECTABLE_PLATFORMS} + selected={this.state.Selected}/> + +
+
+ ); + } +} + +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)), + setInstallTestActive: active => dispatch(setInstallTestActive(active)), + }; +}; + +export default connect(mapStateToProps, mapDispatchToProps)(SelectAppPlatform); \ No newline at end of file diff --git a/src/redux/actions/common_actions.js b/src/redux/actions/common_actions.js index 18a3bce..ca9ce7a 100644 --- a/src/redux/actions/common_actions.js +++ b/src/redux/actions/common_actions.js @@ -4,9 +4,17 @@ import {getIPCRenderer} from '../../utils'; const ipcRenderer = getIPCRenderer(); -export const displaySelectAppPlatform = createAction('common/displaySelectAppPlatform'); +export const displaySelectAppPlatform = display => { + return dispatch => { + if (display) { + dispatch(showWindow()); + } + + dispatch(setDisplaySelectAppPlatform(display)); + }; +}; + export const notifyRebootRequired = createAction('common/notifyRebootRequired'); -export const setAllowMount = createAction('common/setAllowMount'); export const rebootSystem = () => { return dispatch => { @@ -17,7 +25,19 @@ export const rebootSystem = () => { } }; +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 2f8367e..5002fbc 100644 --- a/src/redux/actions/download_actions.js +++ b/src/redux/actions/download_actions.js @@ -3,6 +3,7 @@ import {createAction} from 'redux-starter-kit'; import {getIPCRenderer} from '../../utils'; import {notifyError} from './error_actions'; import { + installAndTestRelease, installDependency, installRelease, installUpgrade @@ -25,7 +26,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) => { +export const downloadItem = (name, type, urls, isWinFSP, testVersion, appPlatform) => { return (dispatch, getState) => { if (!Array.isArray(urls)) { urls = [urls]; @@ -40,6 +41,9 @@ export const downloadItem = (name, type, urls, isWinFSP) => { 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]]; const sha256 = null;//info.sha256; diff --git a/src/redux/actions/install_actions.js b/src/redux/actions/install_actions.js index 4c11816..1550869 100644 --- a/src/redux/actions/install_actions.js +++ b/src/redux/actions/install_actions.js @@ -7,13 +7,16 @@ import { import {notifyError} from './error_actions'; import {setAllowDownload} from './download_actions'; import { + loadReleases, setActiveRelease, setInstalledVersion, setReleaseUpgradeAvailable } from './release_version_actions'; import { + displaySelectAppPlatform, setAllowMount, setApplicationReady, + setLinuxAppPlatform, setRebootRequired, showWindow, shutdownApplication @@ -134,6 +137,42 @@ export const installDependency = (source, url, isWinFSP) => { }; }; +export const installAndTestRelease = (source, version, appPlatform) => { + return (dispatch, getState) => { + if (ipcRenderer && !getState().install.InstallTestActive) { + const extractReleaseComplete = (event, arg) => { + ipcRenderer.send(Constants.IPC_Delete_File, { + FilePath: source, + }); + + ipcRenderer.once(Constants.IPC_Test_Release_Reply, (event, arg) => { + if (arg.data.Success) { + ipcRenderer.sendSync(Constants.IPC_Set_Linux_AppPlatform, { + AppPlatform: appPlatform, + }); + dispatch(setLinuxAppPlatform(appPlatform)); + dispatch(setInstallTestActive(false)); + dispatch(displaySelectAppPlatform(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 installRelease = source => { return (dispatch, getState) => { if (ipcRenderer && !getState().install.InstallActive) { @@ -193,5 +232,6 @@ export const installUpgrade = (source, sha256, signature, skipVerification) => { export const setDismissDependencies = createAction('install/setDismissDependencies'); export const setInstallActive = createAction('install/setInstallActive'); +export const setInstallTestActive = createAction('install/setInstallTestActive'); export const setInstallComplete = createAction('install/setInstallComplete'); export const setMissingDependencies = createAction('install/setMissingDependencies'); diff --git a/src/redux/reducers/common_reducer.js b/src/redux/reducers/common_reducer.js index d1b2799..1502396 100644 --- a/src/redux/reducers/common_reducer.js +++ b/src/redux/reducers/common_reducer.js @@ -1,9 +1,10 @@ import {createReducer} from 'redux-starter-kit'; import { - displaySelectAppPlatform, notifyRebootRequired, setAllowMount, setApplicationReady, + setLinuxAppPlatform, + SET_DISPLAY_SELECT_APPPLATFORM } from '../actions/common_actions'; export const createCommonReducer = (platform, appPlatform, version) => { @@ -16,7 +17,7 @@ export const createCommonReducer = (platform, appPlatform, version) => { RebootRequired: false, Version: version, }, { - [displaySelectAppPlatform]: (state, action) => { + [SET_DISPLAY_SELECT_APPPLATFORM]: (state, action) => { return { ...state, DisplaySelectAppPlatform: action.payload, @@ -34,6 +35,12 @@ export const createCommonReducer = (platform, appPlatform, version) => { AppReady: action.payload, }; }, + [setLinuxAppPlatform]: (state, action) => { + return { + ...state, + AppPlatform: action.payload, + } + }, [notifyRebootRequired]: (state, action) => { return { ...state, diff --git a/src/redux/reducers/install_reducer.js b/src/redux/reducers/install_reducer.js index 9237040..78c7b95 100644 --- a/src/redux/reducers/install_reducer.js +++ b/src/redux/reducers/install_reducer.js @@ -3,6 +3,7 @@ import { setDismissDependencies, setInstallActive, setInstallComplete, + setInstallTestActive, setMissingDependencies } from '../actions/install_actions'; @@ -10,6 +11,7 @@ export const installReducer = createReducer({ DismissDependencies: false, InstallActive: false, InstallResult: null, + InstallTestActive: false, InstallType: null, MissingDependencies: [], }, { @@ -35,6 +37,12 @@ export const installReducer = createReducer({ InstallType: null, } }, + [setInstallTestActive]: (state, action) => { + return { + ...state, + InstallTestActive: action.payload, + } + }, [setMissingDependencies]: (state, action) => { return { ...state,