#36: Add ability to select Linux distribution type if OS is unsupported - partial

This commit is contained in:
2019-08-28 18:58:43 -05:00
parent 0671a39809
commit 0105602a44
11 changed files with 194 additions and 38 deletions

View File

@@ -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();
});

View File

@@ -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()),

View File

@@ -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 (
<Box dxDark dxStyle={{padding: '8px'}}>
<h1 className={'SAPHeading'}>Select Linux Platform</h1>
<div className={'SAPContent'}>
<p>Repertory was unable to detect your Linux distribution. Please select one of the following and click <b>'Test'</b> to continue:</p>
</div>
<DropDown items={Constants.LINUX_SELECTABLE_PLATFORMS}/>
<Button clicked={}>Test</Button>
</Box>
);
});

View File

@@ -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';

View File

@@ -6,6 +6,13 @@
.SAPContent {
max-height: 60vh;
width: 255px;
overflow-y: auto;
margin-bottom: 8px;
}
.SAPActions {
margin-top: 4px;
display: flex;
flex-direction: row;
}

View File

@@ -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 (
<Box dxDark dxStyle={{padding: '8px'}}>
<h1 className={'SAPHeading'}>Select Linux Platform</h1>
<div className={'SAPContent'}>
<p>Repertory was unable to detect your Linux distribution. Please select one of the following and click <b>Test</b> to continue:</p>
</div>
<div className={'SAPActions'}>
<DropDown changed={e => this.setState({
...this.state,
Selected: e.target.value
})}
disabled={this.props.InstallTestActive}
items={Constants.LINUX_SELECTABLE_PLATFORMS}
selected={this.state.Selected}/>
<Button clicked={this.handleTestClicked}
disabled={this.props.InstallTestActive}>Test</Button>
</div>
</Box>
);
}
}
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);

View File

@@ -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());

View File

@@ -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;

View File

@@ -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');

View File

@@ -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,

View File

@@ -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,