Handle release unavailable

This commit is contained in:
Scott E. Graves
2019-07-24 14:09:11 -05:00
parent 763bf4491d
commit 37607bf152
5 changed files with 56 additions and 9 deletions

View File

@@ -3,9 +3,11 @@ import * as Constants from '../../constants';
import {createAction} from 'redux-starter-kit';
import {notifyError} from './error_actions';
import {
saveState,
setApplicationReady,
showWindow
} from './common_actions';
import {unmountAll} from './mount_actions';
export const CLEAR_UI_UPGRADE = 'relver/clearUIUpgrade';
export const clearUIUpgrade = () => {
@@ -47,19 +49,34 @@ export const loadReleases = () => {
return (dispatch, getState) => {
const dispatchActions = (locationsLookup, versionLookup)=> {
const state = getState().relver;
const latestVersion = versionLookup[Constants.RELEASE_TYPES[state.Release]].length - 1;
let latestVersion = versionLookup[Constants.RELEASE_TYPES[state.Release]].length - 1;
let release = state.Release;
let version = state.Version;
if ((version === -1) || !versionLookup[Constants.RELEASE_TYPES[state.Release]][version]) {
if (versionLookup[Constants.RELEASE_TYPES[release]][0] === 'unavailable') {
release = state.ReleaseDefault;
latestVersion = version = 0;
} else if ((version === -1) || !versionLookup[Constants.RELEASE_TYPES[state.Release]][version]) {
version = latestVersion;
}
dispatch(setReleaseData(locationsLookup, versionLookup));
if (version !== state.Version) {
dispatch(setActiveRelease(state.Release, version));
const dispatchActions = () => {
dispatch(setReleaseUpgradeAvailable((version !== latestVersion)));
dispatch(setApplicationReady(true));
dispatch(detectUIUpgrade());
};
if ((version !== state.Version) || (release !== state.Release)) {
dispatch(unmountAll(() => {
dispatch(setActiveRelease(release, version));
dispatchActions();
dispatch(showWindow());
dispatch(saveState());
}));
} else {
dispatchActions();
}
dispatch(setReleaseUpgradeAvailable((version !== latestVersion)));
dispatch(setApplicationReady(true));
dispatch(detectUIUpgrade());
};
axios