#36: Add ability to select Linux distribution type if OS is unsupported - partial
This commit is contained in:
18
src/containers/SelectAppPlatform/SelectAppPlatform.css
Normal file
18
src/containers/SelectAppPlatform/SelectAppPlatform.css
Normal file
@@ -0,0 +1,18 @@
|
||||
.SAPHeading {
|
||||
color: var(--text_color_error);
|
||||
text-align: center;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.SAPContent {
|
||||
max-height: 60vh;
|
||||
width: 255px;
|
||||
overflow-y: auto;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.SAPActions {
|
||||
margin-top: 4px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
83
src/containers/SelectAppPlatform/SelectAppPlatform.js
Normal file
83
src/containers/SelectAppPlatform/SelectAppPlatform.js
Normal 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);
|
||||
Reference in New Issue
Block a user