#38: Enhance new repertory release available notification

This commit is contained in:
2020-02-21 15:35:16 -06:00
parent a70359d36b
commit 39409495c4
5 changed files with 57 additions and 11 deletions

View File

@@ -7,16 +7,22 @@ import {
notifyError, notifyError,
notifyInfo notifyInfo
} from '../../../redux/actions/error_actions'; } from '../../../redux/actions/error_actions';
import {installReleaseByVersion} from '../../../redux/actions/install_actions';
const mapDispatchToProps = dispatch => { const mapDispatchToProps = dispatch => {
return { return {
installReleaseByVersion: (release, version) => dispatch(installReleaseByVersion(release, version)),
notifyError: msg => dispatch(notifyError(msg)), notifyError: msg => dispatch(notifyError(msg)),
notifyInfo: (title, msg) => dispatch(notifyInfo(title, msg)), notifyInfo: (title, msg) => dispatch(notifyInfo(title, msg)),
}; };
}; };
export default connect(null, mapDispatchToProps)(({release, lastItem, notifyError, notifyInfo}) => { export default connect(null, mapDispatchToProps)(({dismiss, release, lastItem, notifyError, notifyInfo, installReleaseByVersion}) => {
const title = '[' + Constants.RELEASE_TYPES[release.Release] + '] ' + release.Display; const title = '[' + Constants.RELEASE_TYPES[release.Release] + '] ' + release.Display;
const installReleaseVersion = () => {
dismiss();
installReleaseByVersion(release.Release, release.Version);
};
const displayChanges = async () => { const displayChanges = async () => {
try { try {
const lines = await getChangesForRepertoryVersion(release.VersionString); const lines = await getChangesForRepertoryVersion(release.VersionString);
@@ -40,7 +46,7 @@ export default connect(null, mapDispatchToProps)(({release, lastItem, notifyErro
<div style={{width: 'var(--default_spacing)'}}/> <div style={{width: 'var(--default_spacing)'}}/>
</td> </td>
<td width="50%"> <td width="50%">
<Button buttonStyles={{width: '100%'}}>Install</Button> <Button buttonStyles={{width: '100%'}} clicked={installReleaseVersion}>Install</Button>
</td> </td>
</tr> </tr>
{lastItem ? null : <tr style={{height: 'var(--default_spacing)'}}/>} {lastItem ? null : <tr style={{height: 'var(--default_spacing)'}}/>}

View File

@@ -20,7 +20,8 @@ const mapDispatchToProps = dispatch => {
export default connect(mapStateToProps, mapDispatchToProps)(props => { export default connect(mapStateToProps, mapDispatchToProps)(props => {
const newReleases = props.NewReleasesAvailable.map((i, idx) => { const newReleases = props.NewReleasesAvailable.map((i, idx) => {
return <NewRelease key={'new_release_' + i.Release + '_' + i.Version} return <NewRelease dismiss={props.dismissNewReleasesAvailable}
key={'new_release_' + i.Release + '_' + i.Version}
lastItem={idx === (props.NewReleasesAvailable.length - 1)} lastItem={idx === (props.NewReleasesAvailable.length - 1)}
release={i} />; release={i} />;
}); });

View File

@@ -5,7 +5,7 @@ import {
getSelectedVersionFromState getSelectedVersionFromState
} from '../../utils'; } from '../../utils';
import {notifyError} from './error_actions'; import {notifyError} from './error_actions';
import {setAllowDownload} from './download_actions'; import {downloadItem, setAllowDownload} from './download_actions';
import { import {
loadReleases, loadReleases,
setActiveRelease, setActiveRelease,
@@ -32,13 +32,15 @@ export const checkInstalled = (dependencies, version) => {
const installedVersion = result.Success && result.Exists ? result.Version : 'none'; const installedVersion = result.Success && result.Exists ? result.Version : 'none';
const state = getState(); const state = getState();
const release = state.relver.Release;
let version = state.relver.Version;
let upgradeAvailable = false; let upgradeAvailable = false;
if (installedVersion !== 'none') { if (installedVersion !== 'none') {
const latestVersion = state.relver.VersionLookup[Constants.RELEASE_TYPES[state.relver.Release]].length - 1; const latestVersion = state.relver.VersionLookup[Constants.RELEASE_TYPES[release]].length - 1;
let version = state.relver.Version;
if (version === -1) { if (version === -1) {
version = latestVersion; version = latestVersion;
dispatch(setActiveRelease(state.relver.Release, version)); dispatch(setActiveRelease(release, version));
} else { } else {
upgradeAvailable = version !== latestVersion; upgradeAvailable = version !== latestVersion;
} }
@@ -48,8 +50,18 @@ export const checkInstalled = (dependencies, version) => {
dispatch(setMissingDependencies(result.Dependencies)); dispatch(setMissingDependencies(result.Dependencies));
dispatch(setAllowDownload(true)); dispatch(setAllowDownload(true));
dispatch(setAllowMount(true)); dispatch(setAllowMount(true));
const autoInstallRelease = getState().install.AutoInstallRelease;
dispatch(setAutoInstallRelease(false));
if (result.Dependencies && (result.Dependencies.length > 0)) { if (result.Dependencies && (result.Dependencies.length > 0)) {
dispatch(showWindow()); dispatch(showWindow());
} else if ((installedVersion === 'none') && autoInstallRelease) {
dispatch(setAllowMount(false));
const versionString = getState().relver.VersionLookup[Constants.RELEASE_TYPES[release]][version];
const urls = getState().relver.LocationsLookup[versionString].urls;
const fileName = versionString + '.zip';
dispatch(downloadItem(fileName, Constants.INSTALL_TYPES.Release, urls));
} }
}; };
@@ -174,6 +186,24 @@ export const installAndTestRelease = (source, version, appPlatform) => {
}; };
}; };
export const installReleaseByVersion = (release, version) => {
return (dispatch, getState) => {
let allowInstall = !getState().mounts.MountsBusy;
if (!allowInstall) {
// TODO: prompt to unmount
}
if (allowInstall) {
if (getState().download.AllowDownload && !getState().download.DownloadActive) {
dispatch(setAutoInstallRelease(true));
dispatch(setActiveRelease(release, version));
} else {
notifyError('Download is active. Unable to install release.');
}
}
};
};
export const installRelease = source => { export const installRelease = source => {
return (dispatch, getState) => { return (dispatch, getState) => {
if (ipcRenderer && !getState().install.InstallActive) { if (ipcRenderer && !getState().install.InstallActive) {
@@ -231,6 +261,7 @@ export const installUpgrade = (source, sha256, signature, skipVerification) => {
}; };
}; };
export const setAutoInstallRelease = createAction('install/setAutoInstallRelease');
export const setDismissDependencies = createAction('install/setDismissDependencies'); export const setDismissDependencies = createAction('install/setDismissDependencies');
export const setInstallActive = createAction('install/setInstallActive'); export const setInstallActive = createAction('install/setInstallActive');
export const setInstallTestActive = createAction('install/setInstallTestActive'); export const setInstallTestActive = createAction('install/setInstallTestActive');

View File

@@ -1,5 +1,6 @@
import {createReducer} from '@reduxjs/toolkit'; import {createReducer} from '@reduxjs/toolkit';
import { import {
setAutoInstallRelease,
setDismissDependencies, setDismissDependencies,
setInstallActive, setInstallActive,
setInstallComplete, setInstallComplete,
@@ -8,6 +9,7 @@ import {
} from '../actions/install_actions'; } from '../actions/install_actions';
export const installReducer = createReducer({ export const installReducer = createReducer({
AutoInstallRelease: false,
DismissDependencies: false, DismissDependencies: false,
InstallActive: false, InstallActive: false,
InstallResult: null, InstallResult: null,
@@ -15,6 +17,12 @@ export const installReducer = createReducer({
InstallType: null, InstallType: null,
MissingDependencies: [], MissingDependencies: [],
}, { }, {
[setAutoInstallRelease]: (state, action) => {
return {
...state,
AutoInstallRelease: action.payload,
}
},
[setDismissDependencies]: (state, action) => { [setDismissDependencies]: (state, action) => {
return { return {
...state, ...state,

View File

@@ -85,12 +85,12 @@ export const getNewReleases = (existingReleases, newReleases) => {
}); });
} }
ret.push({ /*ret.push({
Display: '1.2.2-release', Display: '1.2.2-release',
Release: 1, Release: 0,
Version: 2, Version: 3,
VersionString: '1.2.2-release', VersionString: '1.2.2-release',
}); });*/
return ret; return ret;
}; };