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

View File

@@ -20,7 +20,8 @@ const mapDispatchToProps = dispatch => {
export default connect(mapStateToProps, mapDispatchToProps)(props => {
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)}
release={i} />;
});

View File

@@ -5,7 +5,7 @@ import {
getSelectedVersionFromState
} from '../../utils';
import {notifyError} from './error_actions';
import {setAllowDownload} from './download_actions';
import {downloadItem, setAllowDownload} from './download_actions';
import {
loadReleases,
setActiveRelease,
@@ -32,13 +32,15 @@ export const checkInstalled = (dependencies, version) => {
const installedVersion = result.Success && result.Exists ? result.Version : 'none';
const state = getState();
const release = state.relver.Release;
let version = state.relver.Version;
let upgradeAvailable = false;
if (installedVersion !== 'none') {
const latestVersion = state.relver.VersionLookup[Constants.RELEASE_TYPES[state.relver.Release]].length - 1;
let version = state.relver.Version;
const latestVersion = state.relver.VersionLookup[Constants.RELEASE_TYPES[release]].length - 1;
if (version === -1) {
version = latestVersion;
dispatch(setActiveRelease(state.relver.Release, version));
dispatch(setActiveRelease(release, version));
} else {
upgradeAvailable = version !== latestVersion;
}
@@ -48,8 +50,18 @@ export const checkInstalled = (dependencies, version) => {
dispatch(setMissingDependencies(result.Dependencies));
dispatch(setAllowDownload(true));
dispatch(setAllowMount(true));
const autoInstallRelease = getState().install.AutoInstallRelease;
dispatch(setAutoInstallRelease(false));
if (result.Dependencies && (result.Dependencies.length > 0)) {
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 => {
return (dispatch, getState) => {
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 setInstallActive = createAction('install/setInstallActive');
export const setInstallTestActive = createAction('install/setInstallTestActive');

View File

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

View File

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