#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

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