Prettier support
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
import { createAction } from '@reduxjs/toolkit';
|
||||
|
||||
import * as Constants from '../../constants';
|
||||
import {createAction} from '@reduxjs/toolkit';
|
||||
import {getIPCRenderer} from '../../utils';
|
||||
import { getIPCRenderer } from '../../utils.jsx';
|
||||
|
||||
const ipcRenderer = getIPCRenderer();
|
||||
let yesNoResolvers = [];
|
||||
|
||||
export const confirmYesNo = title => {
|
||||
return dispatch => {
|
||||
return new Promise(resolve => {
|
||||
export const confirmYesNo = (title) => {
|
||||
return (dispatch) => {
|
||||
return new Promise((resolve) => {
|
||||
dispatch(handleConfirmYesNo(true, title, resolve));
|
||||
});
|
||||
};
|
||||
@@ -17,15 +18,12 @@ export const DISPLAY_CONFIRM_YES_NO = 'common/displayConfirmYesNo';
|
||||
const displayConfirmYesNo = (show, title) => {
|
||||
return {
|
||||
type: DISPLAY_CONFIRM_YES_NO,
|
||||
payload: {
|
||||
show,
|
||||
title
|
||||
},
|
||||
payload: { show, title },
|
||||
};
|
||||
};
|
||||
|
||||
export const displaySelectAppPlatform = display => {
|
||||
return dispatch => {
|
||||
export const displaySelectAppPlatform = (display) => {
|
||||
return (dispatch) => {
|
||||
if (display) {
|
||||
dispatch(showWindow());
|
||||
}
|
||||
@@ -34,14 +32,14 @@ export const displaySelectAppPlatform = display => {
|
||||
};
|
||||
};
|
||||
|
||||
export const hideConfirmYesNo = confirmed => {
|
||||
return dispatch => {
|
||||
export const hideConfirmYesNo = (confirmed) => {
|
||||
return (dispatch) => {
|
||||
dispatch(handleConfirmYesNo(false, confirmed));
|
||||
};
|
||||
};
|
||||
|
||||
const handleConfirmYesNo = (show, titleOrConfirmed, resolve) => {
|
||||
return dispatch => {
|
||||
return (dispatch) => {
|
||||
if (show) {
|
||||
yesNoResolvers.push(resolve);
|
||||
dispatch(displayConfirmYesNo(show, titleOrConfirmed));
|
||||
@@ -57,26 +55,23 @@ export const NOTIFY_APPLICATION_BUSY = 'common/notifyApplicationBusy';
|
||||
export const notifyApplicationBusy = (busy, transparent) => {
|
||||
return {
|
||||
type: NOTIFY_APPLICATION_BUSY,
|
||||
payload: {
|
||||
busy,
|
||||
transparent
|
||||
},
|
||||
payload: { busy, transparent },
|
||||
};
|
||||
};
|
||||
|
||||
export const notifyRebootRequired = createAction('common/notifyRebootRequired');
|
||||
|
||||
export const rebootSystem = () => {
|
||||
return dispatch => {
|
||||
return (dispatch) => {
|
||||
dispatch(setApplicationReady(false));
|
||||
if (ipcRenderer) {
|
||||
ipcRenderer.send(Constants.IPC_Reboot_System);
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const saveState = () => {
|
||||
return (dispatch, getState) => {
|
||||
return (_, getState) => {
|
||||
const state = getState();
|
||||
if (state.common.AppReady) {
|
||||
let currentState = {
|
||||
@@ -94,9 +89,7 @@ export const saveState = () => {
|
||||
}
|
||||
|
||||
if (ipcRenderer) {
|
||||
ipcRenderer.send(Constants.IPC_Save_State, {
|
||||
State: currentState
|
||||
});
|
||||
ipcRenderer.send(Constants.IPC_Save_State, { State: currentState });
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -106,7 +99,7 @@ export const setAllowMount = createAction('common/setAllowMount');
|
||||
export const setApplicationReady = createAction('common/setApplicationReady');
|
||||
|
||||
export const SET_DISPLAY_SELECT_APPPLATFORM = 'common/displaySelectAppPlatform';
|
||||
export const setDisplaySelectAppPlatform = display => {
|
||||
export const setDisplaySelectAppPlatform = (display) => {
|
||||
return {
|
||||
type: SET_DISPLAY_SELECT_APPPLATFORM,
|
||||
payload: display,
|
||||
@@ -116,14 +109,14 @@ export const setDisplaySelectAppPlatform = display => {
|
||||
export const setLinuxAppPlatform = createAction('common/setLinuxAppPlatform');
|
||||
|
||||
export const setRebootRequired = () => {
|
||||
return dispatch => {
|
||||
return (dispatch) => {
|
||||
dispatch(showWindow());
|
||||
dispatch(notifyRebootRequired(true));
|
||||
};
|
||||
};
|
||||
|
||||
export const showWindow = () => {
|
||||
return dispatch => {
|
||||
return (_) => {
|
||||
if (ipcRenderer) {
|
||||
ipcRenderer.send(Constants.IPC_Show_Window);
|
||||
}
|
||||
@@ -131,7 +124,7 @@ export const showWindow = () => {
|
||||
};
|
||||
|
||||
export const shutdownApplication = () => {
|
||||
return dispatch => {
|
||||
return (dispatch) => {
|
||||
dispatch(setApplicationReady(false));
|
||||
if (ipcRenderer) {
|
||||
ipcRenderer.send(Constants.IPC_Shutdown);
|
||||
|
||||
@@ -1,58 +1,76 @@
|
||||
import { createAction } from '@reduxjs/toolkit';
|
||||
|
||||
import * as Constants from '../../constants';
|
||||
import {createAction} from '@reduxjs/toolkit';
|
||||
import {getIPCRenderer} from '../../utils';
|
||||
import {notifyError} from './error_actions';
|
||||
import { getIPCRenderer } from '../../utils.jsx';
|
||||
|
||||
import { notifyError } from './error_actions';
|
||||
import {
|
||||
installAndTestRelease,
|
||||
installDependency,
|
||||
installRelease,
|
||||
installUpgrade
|
||||
installUpgrade,
|
||||
} from './install_actions';
|
||||
|
||||
export const setAllowDownload = createAction('download/setAllowDownload');
|
||||
|
||||
export const SET_DOWNLOAD_BEGIN = 'download/setDownloadBegin';
|
||||
export const setDownloadBegin = (name, type, url) => {
|
||||
return {
|
||||
type: SET_DOWNLOAD_BEGIN,
|
||||
payload: {
|
||||
name,
|
||||
type,
|
||||
url
|
||||
}
|
||||
};
|
||||
return { type: SET_DOWNLOAD_BEGIN, payload: { name, type, url } };
|
||||
};
|
||||
|
||||
export const setDownloadEnd = createAction('download/setDownloadEnd');
|
||||
export const setDownloadProgress = createAction('download/setDownloadProgress');
|
||||
|
||||
export const downloadItem = (name, type, urls, isWinFSP, testVersion, appPlatform) => {
|
||||
export const downloadItem = (
|
||||
name,
|
||||
type,
|
||||
urls,
|
||||
isWinFSP,
|
||||
testVersion,
|
||||
appPlatform
|
||||
) => {
|
||||
return (dispatch, getState) => {
|
||||
if (!Array.isArray(urls)) {
|
||||
urls = [urls];
|
||||
}
|
||||
|
||||
const downloadComplete = result => {
|
||||
const downloadComplete = (result) => {
|
||||
if (result.Success) {
|
||||
switch (type) {
|
||||
case Constants.INSTALL_TYPES.Dependency:
|
||||
dispatch(installDependency(result.Destination, result.URL, isWinFSP));
|
||||
break;
|
||||
case Constants.INSTALL_TYPES.Release:
|
||||
dispatch(installRelease(result.Destination));
|
||||
break;
|
||||
case Constants.INSTALL_TYPES.TestRelease:
|
||||
dispatch(installAndTestRelease(result.Destination, testVersion, appPlatform));
|
||||
break;
|
||||
case Constants.INSTALL_TYPES.Upgrade:
|
||||
//const info = this.props.LocationsLookup[this.props.AppPlatform][this.props.VersionLookup[this.props.AppPlatform][0]];
|
||||
const sha256 = null;//info.sha256;
|
||||
const signature = null;//info.sig;
|
||||
dispatch(installUpgrade(result.Destination, sha256, signature, !!result.SkipVerification));
|
||||
break;
|
||||
default:
|
||||
dispatch(notifyError('Unknown download type: ' + type));
|
||||
break;
|
||||
case Constants.INSTALL_TYPES.Dependency:
|
||||
dispatch(
|
||||
installDependency(result.Destination, result.URL, isWinFSP)
|
||||
);
|
||||
break;
|
||||
case Constants.INSTALL_TYPES.Release:
|
||||
dispatch(installRelease(result.Destination));
|
||||
break;
|
||||
case Constants.INSTALL_TYPES.TestRelease:
|
||||
dispatch(
|
||||
installAndTestRelease(
|
||||
result.Destination,
|
||||
testVersion,
|
||||
appPlatform
|
||||
)
|
||||
);
|
||||
break;
|
||||
case Constants.INSTALL_TYPES.Upgrade:
|
||||
// const info =
|
||||
// this.props.LocationsLookup[this.props.AppPlatform][this.props.VersionLookup[this.props.AppPlatform][0]];
|
||||
const sha256 = null; // info.sha256;
|
||||
const signature = null; // info.sig;
|
||||
dispatch(
|
||||
installUpgrade(
|
||||
result.Destination,
|
||||
sha256,
|
||||
signature,
|
||||
!!result.SkipVerification
|
||||
)
|
||||
);
|
||||
break;
|
||||
default:
|
||||
dispatch(notifyError('Unknown download type: ' + type));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (type === Constants.INSTALL_TYPES.TestRelease) {
|
||||
@@ -62,10 +80,13 @@ export const downloadItem = (name, type, urls, isWinFSP, testVersion, appPlatfor
|
||||
}
|
||||
};
|
||||
|
||||
const downloadAtIndex = index => {
|
||||
const downloadAtIndex = (index) => {
|
||||
const url = urls[index];
|
||||
const state = getState();
|
||||
if ((index > 0) || (!state.download.DownloadActive && state.download.AllowDownload)) {
|
||||
if (
|
||||
index > 0 ||
|
||||
(!state.download.DownloadActive && state.download.AllowDownload)
|
||||
) {
|
||||
const ipcRenderer = getIPCRenderer();
|
||||
if (ipcRenderer) {
|
||||
dispatch(setDownloadBegin(name, type, url));
|
||||
@@ -75,8 +96,11 @@ export const downloadItem = (name, type, urls, isWinFSP, testVersion, appPlatfor
|
||||
};
|
||||
|
||||
const downloadFileComplete = (_, arg) => {
|
||||
ipcRenderer.removeListener(Constants.IPC_Download_File_Progress, downloadFileProgress);
|
||||
if (!arg.data.Success && (++index < urls.length)) {
|
||||
ipcRenderer.removeListener(
|
||||
Constants.IPC_Download_File_Progress,
|
||||
downloadFileProgress
|
||||
);
|
||||
if (!arg.data.Success && ++index < urls.length) {
|
||||
downloadAtIndex(index);
|
||||
} else {
|
||||
downloadComplete(arg.data);
|
||||
@@ -84,8 +108,14 @@ export const downloadItem = (name, type, urls, isWinFSP, testVersion, appPlatfor
|
||||
}
|
||||
};
|
||||
|
||||
ipcRenderer.on(Constants.IPC_Download_File_Progress, downloadFileProgress);
|
||||
ipcRenderer.once(Constants.IPC_Download_File_Complete, downloadFileComplete);
|
||||
ipcRenderer.on(
|
||||
Constants.IPC_Download_File_Progress,
|
||||
downloadFileProgress
|
||||
);
|
||||
ipcRenderer.once(
|
||||
Constants.IPC_Download_File_Complete,
|
||||
downloadFileComplete
|
||||
);
|
||||
|
||||
ipcRenderer.send(Constants.IPC_Download_File, {
|
||||
Filename: name,
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
import {
|
||||
showWindow,
|
||||
shutdownApplication
|
||||
} from './common_actions';
|
||||
import { showWindow, shutdownApplication } from './common_actions';
|
||||
|
||||
let ErrorActions = [];
|
||||
|
||||
@@ -36,13 +33,13 @@ export const dismissError = () => {
|
||||
};
|
||||
|
||||
export const dismissInfo = () => {
|
||||
return dispatch => {
|
||||
return (dispatch) => {
|
||||
dispatch(clearInfo());
|
||||
};
|
||||
};
|
||||
|
||||
export const notifyError = (msg, critical, callback) => {
|
||||
return dispatch => {
|
||||
return (dispatch) => {
|
||||
ErrorActions = [callback, ...ErrorActions];
|
||||
msg = msg ? msg.toString() : 'Unknown Error';
|
||||
dispatch(setErrorInfo(msg, critical));
|
||||
@@ -51,7 +48,7 @@ export const notifyError = (msg, critical, callback) => {
|
||||
};
|
||||
|
||||
export const notifyInfo = (title, msg) => {
|
||||
return dispatch => {
|
||||
return (dispatch) => {
|
||||
title = title ? title.toString() : 'Information';
|
||||
msg = msg ? msg.toString() : '';
|
||||
dispatch(setInfo(title, msg));
|
||||
@@ -60,23 +57,10 @@ export const notifyInfo = (title, msg) => {
|
||||
|
||||
export const SET_ERROR_INFO = 'error/setErrorInfo';
|
||||
export const setErrorInfo = (msg, critical) => {
|
||||
return {
|
||||
type: SET_ERROR_INFO,
|
||||
payload: {
|
||||
msg,
|
||||
critical
|
||||
}
|
||||
}
|
||||
return { type: SET_ERROR_INFO, payload: { msg, critical } };
|
||||
};
|
||||
|
||||
|
||||
export const SET_INFO = 'error/setInfo';
|
||||
export const setInfo = (title, msg) => {
|
||||
return {
|
||||
type: SET_INFO,
|
||||
payload: {
|
||||
title,
|
||||
msg
|
||||
}
|
||||
}
|
||||
};
|
||||
return { type: SET_INFO, payload: { title, msg } };
|
||||
};
|
||||
|
||||
@@ -1,18 +1,8 @@
|
||||
import { createAction } from '@reduxjs/toolkit';
|
||||
|
||||
import * as Constants from '../../constants';
|
||||
import {createAction} from '@reduxjs/toolkit';
|
||||
import {
|
||||
getIPCRenderer,
|
||||
getSelectedVersionFromState
|
||||
} from '../../utils';
|
||||
import {notifyError} from './error_actions';
|
||||
import {downloadItem, setAllowDownload} from './download_actions';
|
||||
import {
|
||||
loadReleases,
|
||||
setActiveRelease,
|
||||
setInstalledVersion,
|
||||
setReleaseUpgradeAvailable,
|
||||
setNewReleasesAvailable2,
|
||||
} from './release_version_actions';
|
||||
import { getIPCRenderer, getSelectedVersionFromState } from '../../utils.jsx';
|
||||
|
||||
import {
|
||||
confirmYesNo,
|
||||
displaySelectAppPlatform,
|
||||
@@ -21,18 +11,28 @@ import {
|
||||
setLinuxAppPlatform,
|
||||
setRebootRequired,
|
||||
showWindow,
|
||||
shutdownApplication
|
||||
shutdownApplication,
|
||||
} from './common_actions';
|
||||
import {unmountAll} from './mount_actions';
|
||||
import { downloadItem, setAllowDownload } from './download_actions';
|
||||
import { notifyError } from './error_actions';
|
||||
import { unmountAll } from './mount_actions';
|
||||
import {
|
||||
loadReleases,
|
||||
setActiveRelease,
|
||||
setInstalledVersion,
|
||||
setNewReleasesAvailable2,
|
||||
setReleaseUpgradeAvailable,
|
||||
} from './release_version_actions';
|
||||
|
||||
const ipcRenderer = getIPCRenderer();
|
||||
|
||||
export const checkInstalled = (dependencies, version) => {
|
||||
return (dispatch, getState) => {
|
||||
const checkInstalledComplete = (event, arg) => {
|
||||
const checkInstalledComplete = (_, arg) => {
|
||||
const result = arg.data;
|
||||
const updateState = () => {
|
||||
const installedVersion = result.Success && result.Exists ? result.Version : 'none';
|
||||
const installedVersion =
|
||||
result.Success && result.Exists ? result.Version : 'none';
|
||||
const state = getState();
|
||||
|
||||
const release = state.relver.Release;
|
||||
@@ -40,7 +40,9 @@ export const checkInstalled = (dependencies, version) => {
|
||||
|
||||
let upgradeAvailable = false;
|
||||
if (installedVersion !== 'none') {
|
||||
const latestVersion = state.relver.VersionLookup[Constants.RELEASE_TYPES[release]].length - 1;
|
||||
const latestVersion =
|
||||
state.relver.VersionLookup[Constants.RELEASE_TYPES[release]]
|
||||
.length - 1;
|
||||
if (version === -1) {
|
||||
version = latestVersion;
|
||||
dispatch(setActiveRelease(release, version));
|
||||
@@ -57,14 +59,18 @@ export const checkInstalled = (dependencies, version) => {
|
||||
const autoInstallRelease = getState().install.AutoInstallRelease;
|
||||
dispatch(setAutoInstallRelease(false));
|
||||
|
||||
if (result.Dependencies && (result.Dependencies.length > 0)) {
|
||||
if (result.Dependencies && result.Dependencies.length > 0) {
|
||||
dispatch(showWindow());
|
||||
} else if ((installedVersion === 'none') && autoInstallRelease) {
|
||||
} else if (installedVersion === 'none' && autoInstallRelease) {
|
||||
dispatch(setAllowMount(false));
|
||||
const versionString = getState().relver.VersionLookup[Constants.RELEASE_TYPES[release]][version];
|
||||
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));
|
||||
dispatch(
|
||||
downloadItem(fileName, Constants.INSTALL_TYPES.Release, urls)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -75,7 +81,10 @@ export const checkInstalled = (dependencies, version) => {
|
||||
}
|
||||
};
|
||||
|
||||
ipcRenderer.once(Constants.IPC_Check_Installed_Reply, checkInstalledComplete);
|
||||
ipcRenderer.once(
|
||||
Constants.IPC_Check_Installed_Reply,
|
||||
checkInstalledComplete
|
||||
);
|
||||
ipcRenderer.send(Constants.IPC_Check_Installed, {
|
||||
Dependencies: dependencies,
|
||||
Version: version,
|
||||
@@ -89,10 +98,14 @@ export const checkVersionInstalled = () => {
|
||||
|
||||
dispatch(setAllowDownload(false));
|
||||
const selectedVersion = getSelectedVersionFromState(state);
|
||||
if (selectedVersion && (selectedVersion !== 'unavailable')) {
|
||||
if (selectedVersion && selectedVersion !== 'unavailable') {
|
||||
let dependencies = [];
|
||||
if (state.relver.LocationsLookup[selectedVersion] && state.relver.LocationsLookup[selectedVersion].dependencies) {
|
||||
dependencies = state.relver.LocationsLookup[selectedVersion].dependencies;
|
||||
if (
|
||||
state.relver.LocationsLookup[selectedVersion] &&
|
||||
state.relver.LocationsLookup[selectedVersion].dependencies
|
||||
) {
|
||||
dependencies =
|
||||
state.relver.LocationsLookup[selectedVersion].dependencies;
|
||||
}
|
||||
dispatch(checkInstalled(dependencies, selectedVersion));
|
||||
} else {
|
||||
@@ -107,9 +120,9 @@ export const installDependency = (source, url, isWinFSP) => {
|
||||
if (ipcRenderer && !getState().install.InstallActive) {
|
||||
dispatch(setInstallActive(Constants.INSTALL_TYPES.Dependency));
|
||||
|
||||
const installDependencyComplete = (event, arg) => {
|
||||
const installDependencyComplete = (_, arg) => {
|
||||
const result = arg.data;
|
||||
const handleCompleted = ()=> {
|
||||
const handleCompleted = () => {
|
||||
if (result.RebootRequired) {
|
||||
dispatch(setRebootRequired());
|
||||
} else {
|
||||
@@ -122,13 +135,16 @@ export const installDependency = (source, url, isWinFSP) => {
|
||||
};
|
||||
|
||||
if (result.Success && source.toLowerCase().endsWith('.dmg')) {
|
||||
const dep = getState().install.MissingDependencies.find(d => {
|
||||
const dep = getState().install.MissingDependencies.find((d) => {
|
||||
return d.download === url;
|
||||
});
|
||||
const i = setInterval(()=> {
|
||||
const ret = ipcRenderer.sendSync(Constants.IPC_Check_Dependency_Installed + '_sync', {
|
||||
File: dep.file,
|
||||
});
|
||||
const i = setInterval(() => {
|
||||
const ret = ipcRenderer.sendSync(
|
||||
Constants.IPC_Check_Dependency_Installed + '_sync',
|
||||
{
|
||||
File: dep.file,
|
||||
}
|
||||
);
|
||||
|
||||
if (ret.data.Exists) {
|
||||
clearInterval(i);
|
||||
@@ -142,7 +158,10 @@ export const installDependency = (source, url, isWinFSP) => {
|
||||
}
|
||||
};
|
||||
|
||||
ipcRenderer.once(Constants.IPC_Install_Dependency_Reply, installDependencyComplete);
|
||||
ipcRenderer.once(
|
||||
Constants.IPC_Install_Dependency_Reply,
|
||||
installDependencyComplete
|
||||
);
|
||||
ipcRenderer.send(Constants.IPC_Install_Dependency, {
|
||||
Source: source,
|
||||
URL: url,
|
||||
@@ -160,7 +179,7 @@ export const installAndTestRelease = (source, version, appPlatform) => {
|
||||
FilePath: source,
|
||||
});
|
||||
|
||||
ipcRenderer.once(Constants.IPC_Test_Release_Reply, (event, arg) => {
|
||||
ipcRenderer.once(Constants.IPC_Test_Release_Reply, (_, arg) => {
|
||||
if (arg.data.Success) {
|
||||
ipcRenderer.sendSync(Constants.IPC_Set_Linux_AppPlatform, {
|
||||
AppPlatform: appPlatform,
|
||||
@@ -177,10 +196,13 @@ export const installAndTestRelease = (source, version, appPlatform) => {
|
||||
});
|
||||
ipcRenderer.send(Constants.IPC_Test_Release, {
|
||||
Version: version,
|
||||
})
|
||||
});
|
||||
};
|
||||
|
||||
ipcRenderer.once(Constants.IPC_Extract_Release_Complete, extractReleaseComplete);
|
||||
ipcRenderer.once(
|
||||
Constants.IPC_Extract_Release_Complete,
|
||||
extractReleaseComplete
|
||||
);
|
||||
ipcRenderer.send(Constants.IPC_Extract_Release, {
|
||||
Source: source,
|
||||
Version: version,
|
||||
@@ -192,7 +214,10 @@ export const installAndTestRelease = (source, version, appPlatform) => {
|
||||
export const installReleaseByVersion = (release, version) => {
|
||||
return (dispatch, getState) => {
|
||||
const install = () => {
|
||||
if (getState().download.AllowDownload && !getState().download.DownloadActive) {
|
||||
if (
|
||||
getState().download.AllowDownload &&
|
||||
!getState().download.DownloadActive
|
||||
) {
|
||||
dispatch(setAutoInstallRelease(true));
|
||||
dispatch(setActiveRelease(release, version));
|
||||
} else {
|
||||
@@ -202,31 +227,34 @@ export const installReleaseByVersion = (release, version) => {
|
||||
|
||||
if (getState().mounts.MountsBusy) {
|
||||
dispatch(confirmYesNo('Unmount all drives?'))
|
||||
.then(confirmed => {
|
||||
.then((confirmed) => {
|
||||
if (confirmed) {
|
||||
dispatch(unmountAll(install));
|
||||
}
|
||||
})
|
||||
.catch(error => notifyError(error));
|
||||
.catch((error) => notifyError(error));
|
||||
} else {
|
||||
install();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const installRelease = source => {
|
||||
export const installRelease = (source) => {
|
||||
return (dispatch, getState) => {
|
||||
if (ipcRenderer && !getState().install.InstallActive) {
|
||||
dispatch(setInstallActive(Constants.INSTALL_TYPES.Release));
|
||||
|
||||
const version = getSelectedVersionFromState(getState());
|
||||
const extractReleaseComplete = (event, arg) => {
|
||||
const extractReleaseComplete = (_, arg) => {
|
||||
ipcRenderer.send(Constants.IPC_Delete_File, {
|
||||
FilePath: source,
|
||||
});
|
||||
|
||||
if (arg.data.Success) {
|
||||
localStorage.setItem('previous_releases', localStorage.getItem('releases'));
|
||||
localStorage.setItem(
|
||||
'previous_releases',
|
||||
localStorage.getItem('releases')
|
||||
);
|
||||
dispatch(setNewReleasesAvailable2([]));
|
||||
}
|
||||
|
||||
@@ -234,7 +262,10 @@ export const installRelease = source => {
|
||||
dispatch(checkVersionInstalled());
|
||||
};
|
||||
|
||||
ipcRenderer.once(Constants.IPC_Extract_Release_Complete, extractReleaseComplete);
|
||||
ipcRenderer.once(
|
||||
Constants.IPC_Extract_Release_Complete,
|
||||
extractReleaseComplete
|
||||
);
|
||||
ipcRenderer.send(Constants.IPC_Extract_Release, {
|
||||
Source: source,
|
||||
Version: version,
|
||||
@@ -249,23 +280,33 @@ export const installUpgrade = (source, sha256, signature, skipVerification) => {
|
||||
dispatch(setInstallActive(Constants.INSTALL_TYPES.Upgrade));
|
||||
dispatch(setApplicationReady(false));
|
||||
|
||||
const installUpgradeComplete = (event, arg) => {
|
||||
const installUpgradeComplete = (_, arg) => {
|
||||
const result = arg.data;
|
||||
if (result.Success) {
|
||||
dispatch(shutdownApplication());
|
||||
} else {
|
||||
dispatch(setApplicationReady(true));
|
||||
dispatch(setInstallComplete(result));
|
||||
dispatch(notifyError(result.Error, false, () => {
|
||||
// TODO Prompt to verify
|
||||
if (result.AllowSkipVerification) {
|
||||
dispatch(installUpgrade(source, sha256, signature, true));
|
||||
}
|
||||
}, false));
|
||||
dispatch(
|
||||
notifyError(
|
||||
result.Error,
|
||||
false,
|
||||
() => {
|
||||
// TODO Prompt to verify
|
||||
if (result.AllowSkipVerification) {
|
||||
dispatch(installUpgrade(source, sha256, signature, true));
|
||||
}
|
||||
},
|
||||
false
|
||||
)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
ipcRenderer.once(Constants.IPC_Install_Upgrade_Reply, installUpgradeComplete);
|
||||
ipcRenderer.once(
|
||||
Constants.IPC_Install_Upgrade_Reply,
|
||||
installUpgradeComplete
|
||||
);
|
||||
ipcRenderer.send(Constants.IPC_Install_Upgrade, {
|
||||
Sha256: sha256,
|
||||
Signature: signature,
|
||||
@@ -276,9 +317,17 @@ export const installUpgrade = (source, sha256, signature, skipVerification) => {
|
||||
};
|
||||
};
|
||||
|
||||
export const setAutoInstallRelease = createAction('install/setAutoInstallRelease');
|
||||
export const setDismissDependencies = createAction('install/setDismissDependencies');
|
||||
export const setAutoInstallRelease = createAction(
|
||||
'install/setAutoInstallRelease'
|
||||
);
|
||||
export const setDismissDependencies = createAction(
|
||||
'install/setDismissDependencies'
|
||||
);
|
||||
export const setInstallActive = createAction('install/setInstallActive');
|
||||
export const setInstallTestActive = createAction('install/setInstallTestActive');
|
||||
export const setInstallTestActive = createAction(
|
||||
'install/setInstallTestActive'
|
||||
);
|
||||
export const setInstallComplete = createAction('install/setInstallComplete');
|
||||
export const setMissingDependencies = createAction('install/setMissingDependencies');
|
||||
export const setMissingDependencies = createAction(
|
||||
'install/setMissingDependencies'
|
||||
);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {createAction} from '@reduxjs/toolkit';
|
||||
|
||||
import * as Constants from '../../constants';
|
||||
import {getIPCRenderer} from '../../utils';
|
||||
import {getIPCRenderer} from '../../utils.jsx';
|
||||
|
||||
import {confirmYesNo, saveState} from './common_actions';
|
||||
import {notifyError} from './error_actions';
|
||||
@@ -23,8 +23,10 @@ export const addRemoteMount = (hostNameOrIp, port, token) => {
|
||||
Version: getState().relver.InstalledVersion,
|
||||
});
|
||||
} else {
|
||||
dispatch(
|
||||
notifyError('Failed to set \'RemoteToken\': ' + arg.data.Error));
|
||||
dispatch(noti
|
||||
'Failed to set \'RemoteToken\': '
|
||||
oken
|
||||
': " + arg.data.Error));
|
||||
dispatch(setBusy(false));
|
||||
}
|
||||
});
|
||||
@@ -43,7 +45,14 @@ export const addRemoteMount = (hostNameOrIp, port, token) => {
|
||||
};
|
||||
};
|
||||
|
||||
export const addS3Mount = (name, accessKey, secretKey, region, bucketName, url) => {
|
||||
export const addS3Mount = (
|
||||
name,
|
||||
accessKey,
|
||||
secretKey,
|
||||
region,
|
||||
bucketName,
|
||||
url
|
||||
) => {
|
||||
return (dispatch, getState) => {
|
||||
const ipcRenderer = getIPCRenderer();
|
||||
const provider = 'S3' + name;
|
||||
@@ -60,7 +69,8 @@ export const addS3Mount = (name, accessKey, secretKey, region, bucketName, url)
|
||||
});
|
||||
} else {
|
||||
dispatch(
|
||||
notifyError('Failed to create S3 instance: ' + arg.data.Error));
|
||||
notifyError('Failed to create S3 instance: ' + arg.data.Error)
|
||||
);
|
||||
dispatch(setBusy(false));
|
||||
}
|
||||
});
|
||||
@@ -95,11 +105,12 @@ export const displayConfiguration = (provider, remote, s3) => {
|
||||
};
|
||||
};
|
||||
|
||||
export const removeMount = provider => {
|
||||
return dispatch => {
|
||||
export const removeMount = (provider) => {
|
||||
return (dispatch) => {
|
||||
const isRemote = provider.startsWith('Remote');
|
||||
dispatch(confirmYesNo('Delete [' + provider.substr(isRemote ? 6 : 2) + ']?'))
|
||||
.then(confirmed => {
|
||||
dispatch(
|
||||
confirmYesNo('Delete [' + provider.substr(isRemote ? 6 : 2) + ']?')
|
||||
).then((confirmed) => {
|
||||
if (confirmed) {
|
||||
dispatch(removeMount2(provider));
|
||||
}
|
||||
@@ -107,8 +118,8 @@ export const removeMount = provider => {
|
||||
};
|
||||
};
|
||||
|
||||
const removeMount2 = provider => {
|
||||
return dispatch => {
|
||||
const removeMount2 = (provider) => {
|
||||
return (dispatch) => {
|
||||
const ipcRenderer = getIPCRenderer();
|
||||
ipcRenderer.once(Constants.IPC_Remove_Mount_Reply, (_, arg) => {
|
||||
if (arg.data.Success) {
|
||||
@@ -119,7 +130,7 @@ const removeMount2 = provider => {
|
||||
const isRemote = provider.startsWith('Remote');
|
||||
ipcRenderer.send(Constants.IPC_Remove_Mount, {
|
||||
Remote: isRemote,
|
||||
Name: provider.substr(isRemote ? 6 : 2)
|
||||
Name: provider.substr(isRemote ? 6 : 2),
|
||||
});
|
||||
};
|
||||
};
|
||||
@@ -128,15 +139,13 @@ export const removeMount3 = createAction('mounts/removeMount3');
|
||||
|
||||
export const RESET_MOUNTS_STATE = 'mounts/resetMountsState';
|
||||
export const resetMountsState = () => {
|
||||
return {type: RESET_MOUNTS_STATE, payload: null,}
|
||||
return {type: RESET_MOUNTS_STATE, payload: null};
|
||||
};
|
||||
|
||||
export const SET_ALLOW_MOUNT = 'mounts/setAllowMount';
|
||||
export const setAllowMount =
|
||||
(provider,
|
||||
allow) => {
|
||||
return {type: SET_ALLOW_MOUNT, payload: {provider, allow}};
|
||||
};
|
||||
export const setAllowMount = (provider, allow) => {
|
||||
return {type: SET_ALLOW_MOUNT, payload: {provider, allow}};
|
||||
};
|
||||
|
||||
export const SET_AUTO_MOUNT_PROCESSED = 'mounts/setAutoMountProcessed';
|
||||
export const setAutoMountProcessed = (provider, processed) => {
|
||||
@@ -146,26 +155,22 @@ export const setAutoMountProcessed = (provider, processed) => {
|
||||
export const setBusy = createAction('mounts/setBusy');
|
||||
|
||||
export const SET_MOUNT_STATE = 'mounts/setMountState';
|
||||
export const setMountState =
|
||||
(provider,
|
||||
state) => {
|
||||
return {type: SET_MOUNT_STATE, payload: {provider, state}};
|
||||
};
|
||||
export const setMountState = (provider, state) => {
|
||||
return {type: SET_MOUNT_STATE, payload: {provider, state}};
|
||||
};
|
||||
|
||||
export const SET_MOUNTED = 'mounts/setMounted';
|
||||
export const setMounted =
|
||||
(provider,
|
||||
mounted) => {
|
||||
return {type: SET_MOUNTED, payload: {provider, mounted}};
|
||||
};
|
||||
export const setMounted = (provider, mounted) => {
|
||||
return {type: SET_MOUNTED, payload: {provider, mounted}};
|
||||
};
|
||||
|
||||
export const SET_PROVIDER_STATE = 'mounts/setProviderState';
|
||||
export const setProviderState = (provider, state) => {
|
||||
return {type: SET_PROVIDER_STATE, payload: {provider, state}}
|
||||
return {type: SET_PROVIDER_STATE, payload: {provider, state}};
|
||||
};
|
||||
|
||||
export const unmountAll = completedCallback => {
|
||||
return dispatch => {
|
||||
export const unmountAll = (completedCallback) => {
|
||||
return (dispatch) => {
|
||||
const ipcRenderer = getIPCRenderer();
|
||||
const unmountedCallback = () => {
|
||||
dispatch(resetMountsState());
|
||||
@@ -173,5 +178,5 @@ export const unmountAll = completedCallback => {
|
||||
};
|
||||
ipcRenderer.once(Constants.IPC_Unmount_All_Drives_Reply, unmountedCallback);
|
||||
ipcRenderer.send(Constants.IPC_Unmount_All_Drives);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import {createAction} from '@reduxjs/toolkit';
|
||||
import { createAction } from '@reduxjs/toolkit';
|
||||
|
||||
export const displayPinnedManager = createAction('pinned/displayPinnedManager');
|
||||
|
||||
|
||||
@@ -1,23 +1,26 @@
|
||||
import { createAction } from '@reduxjs/toolkit';
|
||||
import axios from 'axios';
|
||||
|
||||
import * as Constants from '../../constants';
|
||||
import {createAction} from '@reduxjs/toolkit';
|
||||
import {notifyError} from './error_actions';
|
||||
import {
|
||||
checkNewReleases,
|
||||
getIPCRenderer,
|
||||
getNewReleases,
|
||||
getSelectedVersionFromState,
|
||||
} from '../../utils.jsx';
|
||||
|
||||
import {
|
||||
saveState,
|
||||
setAllowMount,
|
||||
setApplicationReady,
|
||||
showWindow
|
||||
showWindow,
|
||||
} from './common_actions';
|
||||
import { notifyError } from './error_actions';
|
||||
import {
|
||||
checkVersionInstalled,
|
||||
setDismissDependencies
|
||||
setDismissDependencies,
|
||||
} from './install_actions';
|
||||
import {unmountAll} from './mount_actions';
|
||||
import {
|
||||
checkNewReleases,
|
||||
getIPCRenderer,
|
||||
getNewReleases, getSelectedVersionFromState
|
||||
} from '../../utils';
|
||||
import { unmountAll } from './mount_actions';
|
||||
|
||||
export const CLEAR_UI_UPGRADE = 'relver/clearUIUpgrade';
|
||||
export const clearUIUpgrade = () => {
|
||||
@@ -27,12 +30,12 @@ export const clearUIUpgrade = () => {
|
||||
};
|
||||
};
|
||||
|
||||
const cleanupOldReleases = versionList => {
|
||||
return dispatch => {
|
||||
const cleanupOldReleases = (versionList) => {
|
||||
return (_) => {
|
||||
const ipcRenderer = getIPCRenderer();
|
||||
if (ipcRenderer) {
|
||||
ipcRenderer.sendSync(Constants.IPC_Cleanup_Releases + '_sync', {
|
||||
version_list: versionList
|
||||
version_list: versionList,
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -42,55 +45,74 @@ export const detectUIUpgrade = () => {
|
||||
return (dispatch, getState) => {
|
||||
axios
|
||||
.get(Constants.UI_RELEASES_URL)
|
||||
.then(response => {
|
||||
.then((response) => {
|
||||
const state = getState();
|
||||
const appPlatform = state.common.AppPlatform;
|
||||
const version = state.common.Version;
|
||||
const data = response.data;
|
||||
|
||||
if (data.Versions &&
|
||||
if (
|
||||
data.Versions &&
|
||||
data.Versions[appPlatform] &&
|
||||
(data.Versions[appPlatform].length > 0) &&
|
||||
(data.Versions[appPlatform][0] !== version)) {
|
||||
dispatch(setUIUpgradeData(data.Locations[appPlatform][data.Versions[appPlatform][0]], data.Versions[appPlatform][0]));
|
||||
data.Versions[appPlatform].length > 0 &&
|
||||
data.Versions[appPlatform][0] !== version
|
||||
) {
|
||||
dispatch(
|
||||
setUIUpgradeData(
|
||||
data.Locations[appPlatform][data.Versions[appPlatform][0]],
|
||||
data.Versions[appPlatform][0]
|
||||
)
|
||||
);
|
||||
if (!state.relver.UpgradeDismissed) {
|
||||
dispatch(showWindow());
|
||||
}
|
||||
} else {
|
||||
dispatch(clearUIUpgrade());
|
||||
}
|
||||
}).catch(() => {
|
||||
})
|
||||
.catch(() => {
|
||||
dispatch(clearUIUpgrade());
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
export const loadReleases = () => {
|
||||
return (dispatch, getState) => {
|
||||
const dispatchActions = (locationsLookup, versionLookup)=> {
|
||||
const dispatchActions = (locationsLookup, versionLookup) => {
|
||||
const state = getState().relver;
|
||||
let release = state.Release;
|
||||
if (release >= Constants.RELEASE_TYPES.length) {
|
||||
release = Constants.DEFAULT_RELEASE;
|
||||
}
|
||||
|
||||
let latestVersion = versionLookup[Constants.RELEASE_TYPES[release]].length - 1;
|
||||
let latestVersion =
|
||||
versionLookup[Constants.RELEASE_TYPES[release]].length - 1;
|
||||
let version = state.Version;
|
||||
if (versionLookup[Constants.RELEASE_TYPES[release]][0] === 'unavailable') {
|
||||
if (
|
||||
versionLookup[Constants.RELEASE_TYPES[release]][0] === 'unavailable'
|
||||
) {
|
||||
release = Constants.DEFAULT_RELEASE;
|
||||
version = latestVersion = versionLookup[Constants.RELEASE_TYPES[release]].length - 1
|
||||
} else if ((version === -1) || !versionLookup[Constants.RELEASE_TYPES[release]][version]) {
|
||||
version = latestVersion =
|
||||
versionLookup[Constants.RELEASE_TYPES[release]].length - 1;
|
||||
} else if (
|
||||
version === -1 ||
|
||||
!versionLookup[Constants.RELEASE_TYPES[release]][version]
|
||||
) {
|
||||
version = latestVersion;
|
||||
}
|
||||
|
||||
dispatch(setReleaseData(locationsLookup, versionLookup));
|
||||
|
||||
const dispatchActions = (processAllowDismiss = true) => {
|
||||
dispatch(setReleaseUpgradeAvailable((version !== latestVersion)));
|
||||
dispatch(setReleaseUpgradeAvailable(version !== latestVersion));
|
||||
dispatch(setApplicationReady(true));
|
||||
dispatch(detectUIUpgrade());
|
||||
if (processAllowDismiss) {
|
||||
dispatch(setAllowDismissDependencies(versionLookup[Constants.RELEASE_TYPES[release]].length > 1));
|
||||
dispatch(
|
||||
setAllowDismissDependencies(
|
||||
versionLookup[Constants.RELEASE_TYPES[release]].length > 1
|
||||
)
|
||||
);
|
||||
}
|
||||
dispatch(checkVersionInstalled());
|
||||
|
||||
@@ -98,16 +120,18 @@ export const loadReleases = () => {
|
||||
for (const key of Object.keys(locationsLookup)) {
|
||||
versionList.push(key);
|
||||
}
|
||||
dispatch(cleanupOldReleases(versionList))
|
||||
dispatch(cleanupOldReleases(versionList));
|
||||
};
|
||||
|
||||
if ((version !== state.Version) || (release !== state.Release)) {
|
||||
dispatch(unmountAll(() => {
|
||||
dispatch(setActiveRelease(release, version));
|
||||
dispatchActions(false);
|
||||
dispatch(showWindow());
|
||||
dispatch(saveState());
|
||||
}));
|
||||
if (version !== state.Version || release !== state.Release) {
|
||||
dispatch(
|
||||
unmountAll(() => {
|
||||
dispatch(setActiveRelease(release, version));
|
||||
dispatchActions(false);
|
||||
dispatch(showWindow());
|
||||
dispatch(saveState());
|
||||
})
|
||||
);
|
||||
} else {
|
||||
dispatchActions();
|
||||
}
|
||||
@@ -115,7 +139,7 @@ export const loadReleases = () => {
|
||||
|
||||
axios
|
||||
.get(Constants.RELEASES_URL)
|
||||
.then(response => {
|
||||
.then((response) => {
|
||||
const appPlatform = getState().common.AppPlatform;
|
||||
const versionLookup = {
|
||||
Release: response.data.Versions.Release[appPlatform],
|
||||
@@ -129,14 +153,21 @@ export const loadReleases = () => {
|
||||
|
||||
const storedReleases = localStorage.getItem('releases');
|
||||
let newReleases = [];
|
||||
if (storedReleases && (storedReleases.length > 0)) {
|
||||
newReleases = getNewReleases(JSON.parse(storedReleases).VersionLookup, versionLookup, getSelectedVersionFromState(getState()));
|
||||
if (storedReleases && storedReleases.length > 0) {
|
||||
newReleases = getNewReleases(
|
||||
JSON.parse(storedReleases).VersionLookup,
|
||||
versionLookup,
|
||||
getSelectedVersionFromState(getState())
|
||||
);
|
||||
}
|
||||
|
||||
localStorage.setItem('releases', JSON.stringify({
|
||||
LocationsLookup: locationsLookup,
|
||||
VersionLookup: versionLookup
|
||||
}));
|
||||
localStorage.setItem(
|
||||
'releases',
|
||||
JSON.stringify({
|
||||
LocationsLookup: locationsLookup,
|
||||
VersionLookup: versionLookup,
|
||||
})
|
||||
);
|
||||
dispatchActions(locationsLookup, versionLookup);
|
||||
|
||||
dispatch(setNewReleasesAvailable(newReleases));
|
||||
@@ -144,12 +175,17 @@ export const loadReleases = () => {
|
||||
dispatch(setNewReleasesAvailable2(newReleases));
|
||||
localStorage.setItem('previous_releases', storedReleases);
|
||||
dispatch(showWindow());
|
||||
} else if ((newReleases = checkNewReleases(getSelectedVersionFromState(getState()))).length > 0) {
|
||||
} else if (
|
||||
(newReleases = checkNewReleases(
|
||||
getSelectedVersionFromState(getState())
|
||||
)).length > 0
|
||||
) {
|
||||
dispatch(setNewReleasesAvailable2(newReleases));
|
||||
}
|
||||
}).catch(error => {
|
||||
})
|
||||
.catch((error) => {
|
||||
const releases = localStorage.getItem('releases');
|
||||
if (releases && (releases.length > 0)) {
|
||||
if (releases && releases.length > 0) {
|
||||
const obj = JSON.parse(releases);
|
||||
const locationsLookup = obj.LocationsLookup;
|
||||
const versionLookup = obj.VersionLookup;
|
||||
@@ -166,10 +202,7 @@ export const NOTIFY_ACTIVE_RELEASE = 'relver/notifyActiveRelease';
|
||||
export const notifyActiveRelease = (release, version) => {
|
||||
return {
|
||||
type: NOTIFY_ACTIVE_RELEASE,
|
||||
payload: {
|
||||
release: release,
|
||||
version: version
|
||||
},
|
||||
payload: { release: release, version: version },
|
||||
};
|
||||
};
|
||||
|
||||
@@ -183,7 +216,7 @@ export const setActiveRelease = (release, version) => {
|
||||
version = -1;
|
||||
}
|
||||
const versions = relver.VersionLookup[Constants.RELEASE_TYPES[release]];
|
||||
dispatch(setAllowDismissDependencies(versions && (versions.length > 1)));
|
||||
dispatch(setAllowDismissDependencies(versions && versions.length > 1));
|
||||
dispatch(setDismissDependencies(false));
|
||||
dispatch(notifyActiveRelease(release, version));
|
||||
if (common.AppReady) {
|
||||
@@ -192,25 +225,35 @@ export const setActiveRelease = (release, version) => {
|
||||
};
|
||||
};
|
||||
|
||||
export const setAllowDismissDependencies = createAction('relver/setAllowDismissDependencies');
|
||||
export const setDismissNewReleasesAvailable = createAction('relver/setDismissNewReleasesAvailable');
|
||||
export const setAllowDismissDependencies = createAction(
|
||||
'relver/setAllowDismissDependencies'
|
||||
);
|
||||
export const setDismissNewReleasesAvailable = createAction(
|
||||
'relver/setDismissNewReleasesAvailable'
|
||||
);
|
||||
export const setDismissUIUpgrade = createAction('relver/setDismissUIUpgrade');
|
||||
export const setInstalledVersion = createAction('relver/setInstalledVersion');
|
||||
export const setNewReleasesAvailable = createAction('relver/setNewReleasesAvailable');
|
||||
export const setNewReleasesAvailable2 = createAction('relver/setNewReleasesAvailable2');
|
||||
export const setNewReleasesAvailable = createAction(
|
||||
'relver/setNewReleasesAvailable'
|
||||
);
|
||||
export const setNewReleasesAvailable2 = createAction(
|
||||
'relver/setNewReleasesAvailable2'
|
||||
);
|
||||
|
||||
export const SET_RELEASE_DATA = 'relver/setReleaseData';
|
||||
export const setReleaseData = (locationsLookup, versionLookup)=> {
|
||||
export const setReleaseData = (locationsLookup, versionLookup) => {
|
||||
return {
|
||||
type: SET_RELEASE_DATA,
|
||||
payload: {
|
||||
locations: locationsLookup,
|
||||
versions: versionLookup,
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export const setReleaseUpgradeAvailable = createAction('relver/setReleaseUpgradeAvailable');
|
||||
export const setReleaseUpgradeAvailable = createAction(
|
||||
'relver/setReleaseUpgradeAvailable'
|
||||
);
|
||||
|
||||
export const SET_UI_UPGRADE_DATA = 'relver/setUIUpgradeData';
|
||||
export const setUIUpgradeData = (upgradeData, version) => {
|
||||
@@ -219,6 +262,6 @@ export const setUIUpgradeData = (upgradeData, version) => {
|
||||
payload: {
|
||||
upgrade_data: upgradeData,
|
||||
version: version,
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {createAction} from '@reduxjs/toolkit';
|
||||
import { createAction } from '@reduxjs/toolkit';
|
||||
|
||||
export const displaySkynetExport = createAction('skynet/displaySkynetExport');
|
||||
export const displaySkynetImport = createAction('skynet/displaySkynetImport');
|
||||
|
||||
@@ -1,71 +1,66 @@
|
||||
import {createReducer} from '@reduxjs/toolkit';
|
||||
import { createReducer } from '@reduxjs/toolkit';
|
||||
|
||||
import {
|
||||
DISPLAY_CONFIRM_YES_NO,
|
||||
NOTIFY_APPLICATION_BUSY,
|
||||
notifyRebootRequired,
|
||||
SET_DISPLAY_SELECT_APPPLATFORM,
|
||||
setAllowMount,
|
||||
setApplicationReady,
|
||||
setLinuxAppPlatform,
|
||||
SET_DISPLAY_SELECT_APPPLATFORM
|
||||
} from '../actions/common_actions';
|
||||
|
||||
export const createCommonReducer = (platformInfo, version) => {
|
||||
return createReducer({
|
||||
AllowMount: false,
|
||||
AppBusy: false,
|
||||
AppBusyTransparent: false,
|
||||
AppPlatform: platformInfo.AppPlatform,
|
||||
AppReady: false,
|
||||
DisplayConfirmYesNo: false,
|
||||
ConfirmTitle: null,
|
||||
DisplaySelectAppPlatform: false,
|
||||
Platform: platformInfo.Platform,
|
||||
RebootRequired: false,
|
||||
Version: version,
|
||||
}, {
|
||||
[DISPLAY_CONFIRM_YES_NO]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
DisplayConfirmYesNo: action.payload.show,
|
||||
ConfirmTitle: action.payload.show ? action.payload.title : null,
|
||||
}
|
||||
return createReducer(
|
||||
{
|
||||
AllowMount: false,
|
||||
AppBusy: false,
|
||||
AppBusyTransparent: false,
|
||||
AppPlatform: platformInfo.AppPlatform,
|
||||
AppReady: false,
|
||||
DisplayConfirmYesNo: false,
|
||||
ConfirmTitle: null,
|
||||
DisplaySelectAppPlatform: false,
|
||||
Platform: platformInfo.Platform,
|
||||
RebootRequired: false,
|
||||
Version: version,
|
||||
},
|
||||
[SET_DISPLAY_SELECT_APPPLATFORM]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
DisplaySelectAppPlatform: action.payload,
|
||||
}
|
||||
},
|
||||
[setAllowMount]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
AllowMount: action.payload,
|
||||
}
|
||||
},
|
||||
[setApplicationReady]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
AppReady: action.payload,
|
||||
};
|
||||
},
|
||||
[setLinuxAppPlatform]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
AppPlatform: action.payload,
|
||||
}
|
||||
},
|
||||
[NOTIFY_APPLICATION_BUSY]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
AppBusy: action.payload.busy,
|
||||
AppBusyTransparent: action.payload.busy && action.payload.transparent,
|
||||
};
|
||||
},
|
||||
[notifyRebootRequired]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
RebootRequired: action.payload,
|
||||
};
|
||||
},
|
||||
});
|
||||
{
|
||||
[DISPLAY_CONFIRM_YES_NO]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
DisplayConfirmYesNo: action.payload.show,
|
||||
ConfirmTitle: action.payload.show ? action.payload.title : null,
|
||||
};
|
||||
},
|
||||
[SET_DISPLAY_SELECT_APPPLATFORM]: (state, action) => {
|
||||
return { ...state, DisplaySelectAppPlatform: action.payload };
|
||||
},
|
||||
[setAllowMount]: (state, action) => {
|
||||
return { ...state, AllowMount: action.payload };
|
||||
},
|
||||
[setApplicationReady]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
AppReady: action.payload,
|
||||
};
|
||||
},
|
||||
[setLinuxAppPlatform]: (state, action) => {
|
||||
return { ...state, AppPlatform: action.payload };
|
||||
},
|
||||
[NOTIFY_APPLICATION_BUSY]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
AppBusy: action.payload.busy,
|
||||
AppBusyTransparent: action.payload.busy && action.payload.transparent,
|
||||
};
|
||||
},
|
||||
[notifyRebootRequired]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
RebootRequired: action.payload,
|
||||
};
|
||||
},
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import {createReducer} from '@reduxjs/toolkit';
|
||||
import { createReducer } from '@reduxjs/toolkit';
|
||||
|
||||
import {
|
||||
setAllowDownload,
|
||||
SET_DOWNLOAD_BEGIN,
|
||||
setAllowDownload,
|
||||
setDownloadEnd,
|
||||
setDownloadProgress
|
||||
setDownloadProgress,
|
||||
} from '../actions/download_actions';
|
||||
|
||||
const defaultDownloadState = {
|
||||
@@ -17,37 +18,37 @@ const defaultDownloadState = {
|
||||
DownloadType: null,
|
||||
};
|
||||
|
||||
export const downloadReducer = createReducer({
|
||||
...defaultDownloadState,
|
||||
AllowDownload: false,
|
||||
}, {
|
||||
[setAllowDownload]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
AllowDownload: action.payload,
|
||||
};
|
||||
export const downloadReducer = createReducer(
|
||||
{
|
||||
...defaultDownloadState,
|
||||
AllowDownload: false,
|
||||
},
|
||||
[SET_DOWNLOAD_BEGIN]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
...defaultDownloadState,
|
||||
DownloadActive: true,
|
||||
DownloadName: action.payload.name,
|
||||
DownloadType: action.payload.type,
|
||||
DownloadURL: action.payload.url,
|
||||
}
|
||||
},
|
||||
[setDownloadEnd]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
...defaultDownloadState,
|
||||
DownloadResult: action.payload,
|
||||
};
|
||||
},
|
||||
[setDownloadProgress]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
DownloadProgress: action.payload,
|
||||
}
|
||||
{
|
||||
[setAllowDownload]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
AllowDownload: action.payload,
|
||||
};
|
||||
},
|
||||
[SET_DOWNLOAD_BEGIN]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
...defaultDownloadState,
|
||||
DownloadActive: true,
|
||||
DownloadName: action.payload.name,
|
||||
DownloadType: action.payload.type,
|
||||
DownloadURL: action.payload.url,
|
||||
};
|
||||
},
|
||||
[setDownloadEnd]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
...defaultDownloadState,
|
||||
DownloadResult: action.payload,
|
||||
};
|
||||
},
|
||||
[setDownloadProgress]: (state, action) => {
|
||||
return { ...state, DownloadProgress: action.payload };
|
||||
},
|
||||
}
|
||||
});
|
||||
);
|
||||
|
||||
@@ -1,52 +1,53 @@
|
||||
import {createReducer} from '@reduxjs/toolkit';
|
||||
import { createReducer } from '@reduxjs/toolkit';
|
||||
import {
|
||||
CLEAR_ERROR,
|
||||
CLEAR_INFO,
|
||||
SET_ERROR_INFO,
|
||||
SET_INFO
|
||||
SET_INFO,
|
||||
} from '../actions/error_actions';
|
||||
|
||||
export const errorReducer = createReducer({
|
||||
DisplayError: false,
|
||||
DisplayInfo: false,
|
||||
ErrorCritical: false,
|
||||
ErrorStack: [],
|
||||
InfoStack: [],
|
||||
}, {
|
||||
[CLEAR_ERROR]: state => {
|
||||
const errorStack = (state.ErrorStack.length > 0) ? state.ErrorStack.slice(1) : [];
|
||||
return {
|
||||
...state,
|
||||
DisplayError: (errorStack.length > 0),
|
||||
ErrorStack: errorStack,
|
||||
}
|
||||
export const errorReducer = createReducer(
|
||||
{
|
||||
DisplayError: false,
|
||||
DisplayInfo: false,
|
||||
ErrorCritical: false,
|
||||
ErrorStack: [],
|
||||
InfoStack: [],
|
||||
},
|
||||
[CLEAR_INFO]: state => {
|
||||
const infoStack = (state.InfoStack.length > 0) ? state.InfoStack.slice(1) : [];
|
||||
return {
|
||||
...state,
|
||||
DisplayInfo: (infoStack.length > 0),
|
||||
InfoStack: infoStack,
|
||||
}
|
||||
},
|
||||
[SET_ERROR_INFO]: (state, action) => {
|
||||
const errorStack = [action.payload.msg, ...state.ErrorStack];
|
||||
return {
|
||||
...state,
|
||||
DisplayError: true,
|
||||
ErrorCritical: state.ErrorCritical || action.payload.critical,
|
||||
ErrorStack: errorStack,
|
||||
}
|
||||
},
|
||||
[SET_INFO]: (state, action) => {
|
||||
const infoStack = [{
|
||||
title: action.payload.title,
|
||||
message: action.payload.msg
|
||||
}, ...state.InfoStack];
|
||||
return {
|
||||
...state,
|
||||
DisplayInfo: true,
|
||||
InfoStack: infoStack,
|
||||
}
|
||||
{
|
||||
[CLEAR_ERROR]: (state) => {
|
||||
const errorStack =
|
||||
state.ErrorStack.length > 0 ? state.ErrorStack.slice(1) : [];
|
||||
return {
|
||||
...state,
|
||||
DisplayError: errorStack.length > 0,
|
||||
ErrorStack: errorStack,
|
||||
};
|
||||
},
|
||||
[CLEAR_INFO]: (state) => {
|
||||
const infoStack =
|
||||
state.InfoStack.length > 0 ? state.InfoStack.slice(1) : [];
|
||||
return {
|
||||
...state,
|
||||
DisplayInfo: infoStack.length > 0,
|
||||
InfoStack: infoStack,
|
||||
};
|
||||
},
|
||||
[SET_ERROR_INFO]: (state, action) => {
|
||||
const errorStack = [action.payload.msg, ...state.ErrorStack];
|
||||
return {
|
||||
...state,
|
||||
DisplayError: true,
|
||||
ErrorCritical: state.ErrorCritical || action.payload.critical,
|
||||
ErrorStack: errorStack,
|
||||
};
|
||||
},
|
||||
[SET_INFO]: (state, action) => {
|
||||
const infoStack = [
|
||||
{ title: action.payload.title, message: action.payload.msg },
|
||||
...state.InfoStack,
|
||||
];
|
||||
return { ...state, DisplayInfo: true, InfoStack: infoStack };
|
||||
},
|
||||
}
|
||||
});
|
||||
);
|
||||
|
||||
@@ -1,60 +1,51 @@
|
||||
import {createReducer} from '@reduxjs/toolkit';
|
||||
import { createReducer } from '@reduxjs/toolkit';
|
||||
import {
|
||||
setAutoInstallRelease,
|
||||
setDismissDependencies,
|
||||
setInstallActive,
|
||||
setInstallComplete,
|
||||
setInstallTestActive,
|
||||
setMissingDependencies
|
||||
setMissingDependencies,
|
||||
} from '../actions/install_actions';
|
||||
|
||||
export const installReducer = createReducer({
|
||||
AutoInstallRelease: false,
|
||||
DismissDependencies: false,
|
||||
InstallActive: false,
|
||||
InstallResult: null,
|
||||
InstallTestActive: false,
|
||||
InstallType: null,
|
||||
MissingDependencies: [],
|
||||
}, {
|
||||
[setAutoInstallRelease]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
AutoInstallRelease: action.payload,
|
||||
}
|
||||
export const installReducer = createReducer(
|
||||
{
|
||||
AutoInstallRelease: false,
|
||||
DismissDependencies: false,
|
||||
InstallActive: false,
|
||||
InstallResult: null,
|
||||
InstallTestActive: false,
|
||||
InstallType: null,
|
||||
MissingDependencies: [],
|
||||
},
|
||||
[setDismissDependencies]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
DismissDependencies: action.payload,
|
||||
}
|
||||
},
|
||||
[setInstallActive]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
InstallActive: true,
|
||||
InstallResult: null,
|
||||
InstallType: action.payload,
|
||||
};
|
||||
},
|
||||
[setInstallComplete]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
InstallActive: false,
|
||||
InstallResult: action.payload,
|
||||
InstallType: null,
|
||||
}
|
||||
},
|
||||
[setInstallTestActive]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
InstallTestActive: action.payload,
|
||||
}
|
||||
},
|
||||
[setMissingDependencies]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
MissingDependencies: action.payload,
|
||||
}
|
||||
{
|
||||
[setAutoInstallRelease]: (state, action) => {
|
||||
return { ...state, AutoInstallRelease: action.payload };
|
||||
},
|
||||
[setDismissDependencies]: (state, action) => {
|
||||
return { ...state, DismissDependencies: action.payload };
|
||||
},
|
||||
[setInstallActive]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
InstallActive: true,
|
||||
InstallResult: null,
|
||||
InstallType: action.payload,
|
||||
};
|
||||
},
|
||||
[setInstallComplete]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
InstallActive: false,
|
||||
InstallResult: action.payload,
|
||||
InstallType: null,
|
||||
};
|
||||
},
|
||||
[setInstallTestActive]: (state, action) => {
|
||||
return { ...state, InstallTestActive: action.payload };
|
||||
},
|
||||
[setMissingDependencies]: (state, action) => {
|
||||
return { ...state, MissingDependencies: action.payload };
|
||||
},
|
||||
}
|
||||
});
|
||||
);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {createReducer} from '@reduxjs/toolkit';
|
||||
import { createReducer } from '@reduxjs/toolkit';
|
||||
|
||||
import * as Constants from '../../constants';
|
||||
import {
|
||||
@@ -12,49 +12,49 @@ import {
|
||||
SET_MOUNT_STATE,
|
||||
SET_MOUNTED,
|
||||
SET_PROVIDER_STATE,
|
||||
setBusy
|
||||
setBusy,
|
||||
} from '../actions/mount_actions';
|
||||
|
||||
export const createMountReducer = state => {
|
||||
export const createMountReducer = (state) => {
|
||||
let providerList = [
|
||||
...Constants.PROVIDER_LIST,
|
||||
...(state.RemoteMounts || []),
|
||||
...(state.S3Mounts || []),
|
||||
];
|
||||
const providerState = providerList
|
||||
.map(provider => {
|
||||
return {
|
||||
[provider]: {
|
||||
AutoMount: false,
|
||||
AutoRestart: false,
|
||||
MountLocation: '',
|
||||
}
|
||||
}
|
||||
})
|
||||
.reduce((map, obj) => {
|
||||
return {...map, ...obj}
|
||||
});
|
||||
|
||||
const mountState = providerList
|
||||
.map(provider => {
|
||||
return {
|
||||
[provider]: {
|
||||
AllowMount: false,
|
||||
DriveLetters: [],
|
||||
Mounted: false,
|
||||
}
|
||||
}
|
||||
})
|
||||
.reduce((map, obj) => {
|
||||
return {...map, ...obj}
|
||||
});
|
||||
|
||||
const autoMountProcessed =
|
||||
providerList.map(provider => {
|
||||
return {[provider]: false,}
|
||||
.map((provider) => {
|
||||
return {
|
||||
[provider]: {
|
||||
AutoMount: false,
|
||||
AutoRestart: false,
|
||||
MountLocation: '',
|
||||
},
|
||||
};
|
||||
})
|
||||
.reduce((map, obj) => {
|
||||
return {...map, ...obj}
|
||||
return { ...map, ...obj };
|
||||
});
|
||||
|
||||
const mountState = providerList
|
||||
.map((provider) => {
|
||||
return {
|
||||
[provider]: {
|
||||
AllowMount: false,
|
||||
DriveLetters: [],
|
||||
Mounted: false,
|
||||
},
|
||||
};
|
||||
})
|
||||
.reduce((map, obj) => {
|
||||
return { ...map, ...obj };
|
||||
});
|
||||
|
||||
const autoMountProcessed = providerList
|
||||
.map((provider) => {
|
||||
return { [provider]: false };
|
||||
})
|
||||
.reduce((map, obj) => {
|
||||
return { ...map, ...obj };
|
||||
});
|
||||
|
||||
return createReducer(
|
||||
@@ -71,52 +71,56 @@ export const createMountReducer = state => {
|
||||
},
|
||||
{
|
||||
[addRemoteMount2]: (state, action) => {
|
||||
let mountState = {...state.MountState};
|
||||
let mountState = { ...state.MountState };
|
||||
mountState[action.payload] = {
|
||||
AllowMount: false,
|
||||
DriveLetters: [],
|
||||
Mounted: false,
|
||||
};
|
||||
|
||||
let providerState = {...state.ProviderState};
|
||||
let providerState = { ...state.ProviderState };
|
||||
providerState[action.payload] = {
|
||||
AutoMount: false,
|
||||
AutoRestart: false,
|
||||
MountLocation: '',
|
||||
};
|
||||
|
||||
let autoMountProcessed = {...state.AutoMountProcessed};
|
||||
let autoMountProcessed = { ...state.AutoMountProcessed };
|
||||
autoMountProcessed[action.payload] = true;
|
||||
|
||||
return {
|
||||
...state, AutoMountProcessed: autoMountProcessed,
|
||||
MountState: mountState, ProviderState: providerState,
|
||||
...state,
|
||||
AutoMountProcessed: autoMountProcessed,
|
||||
MountState: mountState,
|
||||
ProviderState: providerState,
|
||||
RemoteMounts: [...state.RemoteMounts, action.payload],
|
||||
}
|
||||
};
|
||||
},
|
||||
[addS3Mount2]: (state, action) => {
|
||||
let mountState = {...state.MountState};
|
||||
let mountState = { ...state.MountState };
|
||||
mountState[action.payload] = {
|
||||
AllowMount: false,
|
||||
DriveLetters: [],
|
||||
Mounted: false,
|
||||
};
|
||||
|
||||
let providerState = {...state.ProviderState};
|
||||
let providerState = { ...state.ProviderState };
|
||||
providerState[action.payload] = {
|
||||
AutoMount: false,
|
||||
AutoRestart: false,
|
||||
MountLocation: '',
|
||||
};
|
||||
|
||||
let autoMountProcessed = {...state.AutoMountProcessed};
|
||||
let autoMountProcessed = { ...state.AutoMountProcessed };
|
||||
autoMountProcessed[action.payload] = true;
|
||||
|
||||
return {
|
||||
...state, AutoMountProcessed: autoMountProcessed,
|
||||
MountState: mountState, ProviderState: providerState,
|
||||
...state,
|
||||
AutoMountProcessed: autoMountProcessed,
|
||||
MountState: mountState,
|
||||
ProviderState: providerState,
|
||||
S3Mounts: [...state.S3Mounts, action.payload],
|
||||
}
|
||||
};
|
||||
},
|
||||
[DISPLAY_CONFIGURATION]: (state, action) => {
|
||||
return {
|
||||
@@ -127,19 +131,19 @@ export const createMountReducer = state => {
|
||||
};
|
||||
},
|
||||
[removeMount3]: (state, action) => {
|
||||
let mountState = {...state.MountState};
|
||||
let mountState = { ...state.MountState };
|
||||
delete mountState[action.payload];
|
||||
|
||||
let providerState = {...state.ProviderState};
|
||||
let providerState = { ...state.ProviderState };
|
||||
delete providerState[action.payload];
|
||||
|
||||
let autoMountProcessed = {...state.AutoMountProcessed};
|
||||
let autoMountProcessed = { ...state.AutoMountProcessed };
|
||||
delete autoMountProcessed[action.payload];
|
||||
|
||||
const remoteMounts =
|
||||
state.RemoteMounts.filter(i => i !== action.payload);
|
||||
const s3Mounts =
|
||||
state.S3Mounts.filter(i => i !== action.payload);
|
||||
const remoteMounts = state.RemoteMounts.filter(
|
||||
(i) => i !== action.payload
|
||||
);
|
||||
const s3Mounts = state.S3Mounts.filter((i) => i !== action.payload);
|
||||
return {
|
||||
...state,
|
||||
AutoMountProcessed: autoMountProcessed,
|
||||
@@ -150,7 +154,7 @@ export const createMountReducer = state => {
|
||||
};
|
||||
},
|
||||
[RESET_MOUNTS_STATE]: (state, action) => {
|
||||
return {...state, MountsBusy: false, MountState: mountState,}
|
||||
return { ...state, MountsBusy: false, MountState: mountState };
|
||||
},
|
||||
[SET_AUTO_MOUNT_PROCESSED]: (state, action) => {
|
||||
return {
|
||||
@@ -158,7 +162,7 @@ export const createMountReducer = state => {
|
||||
AutoMountProcessed: {
|
||||
...state.AutoMountProcessed,
|
||||
[action.payload.provider]: action.payload.processed,
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
[SET_ALLOW_MOUNT]: (state, action) => {
|
||||
@@ -169,15 +173,13 @@ export const createMountReducer = state => {
|
||||
[action.payload.provider]: {
|
||||
...state.MountState[action.payload.provider],
|
||||
AllowMount: action.payload.allow,
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
},
|
||||
[setBusy]:
|
||||
(state,
|
||||
action) => {
|
||||
return {...state, MountsBusy: action.payload};
|
||||
},
|
||||
[setBusy]: (state, action) => {
|
||||
return { ...state, MountsBusy: action.payload };
|
||||
},
|
||||
[SET_MOUNT_STATE]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
@@ -185,9 +187,9 @@ export const createMountReducer = state => {
|
||||
...state.MountState,
|
||||
[action.payload.provider]: {
|
||||
...state.MountState[action.payload.provider],
|
||||
...action.payload.state
|
||||
...action.payload.state,
|
||||
},
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
[SET_MOUNTED]: (state, action) => {
|
||||
@@ -198,8 +200,8 @@ export const createMountReducer = state => {
|
||||
[action.payload.provider]: {
|
||||
...state.MountState[action.payload.provider],
|
||||
Mounted: action.payload.mounted,
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
},
|
||||
[SET_PROVIDER_STATE]: (state, action) => {
|
||||
@@ -209,10 +211,11 @@ export const createMountReducer = state => {
|
||||
...state.ProviderState,
|
||||
[action.payload.provider]: {
|
||||
...state.ProviderState[action.payload.provider],
|
||||
...action.payload.state
|
||||
...action.payload.state,
|
||||
},
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
});
|
||||
},
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
import {createReducer} from '@reduxjs/toolkit';
|
||||
import {displayPinnedManager} from '../actions/pinned_manager_actions';
|
||||
import { createReducer } from '@reduxjs/toolkit';
|
||||
import { displayPinnedManager } from '../actions/pinned_manager_actions';
|
||||
|
||||
export const pinnedManagerReducer = createReducer({
|
||||
DisplayPinnedManager: false,
|
||||
}, {
|
||||
[displayPinnedManager]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
DisplayPinnedManager: action.payload,
|
||||
};
|
||||
export const pinnedManagerReducer = createReducer(
|
||||
{
|
||||
DisplayPinnedManager: false,
|
||||
},
|
||||
});
|
||||
{
|
||||
[displayPinnedManager]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
DisplayPinnedManager: action.payload,
|
||||
};
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import {createReducer} from '@reduxjs/toolkit';
|
||||
import * as Actions from '../actions/release_version_actions';
|
||||
import * as Constants from '../../constants';
|
||||
import { createReducer } from '@reduxjs/toolkit';
|
||||
|
||||
const versionLookup = Constants.RELEASE_TYPES.map(k=> {
|
||||
return {
|
||||
[k]: ['unavailable']
|
||||
};
|
||||
import * as Constants from '../../constants';
|
||||
import * as Actions from '../actions/release_version_actions';
|
||||
|
||||
const versionLookup = Constants.RELEASE_TYPES.map((k) => {
|
||||
return { [k]: ['unavailable'] };
|
||||
}).reduce((map, obj) => {
|
||||
return {
|
||||
...map,
|
||||
@@ -13,95 +12,95 @@ const versionLookup = Constants.RELEASE_TYPES.map(k=> {
|
||||
};
|
||||
});
|
||||
|
||||
export const releaseVersionReducer = createReducer({
|
||||
AllowDismissDependencies: false,
|
||||
DismissNewReleasesAvailable: true,
|
||||
InstalledVersion: 'none',
|
||||
LocationsLookup: {},
|
||||
NewReleasesAvailable: [],
|
||||
NewReleasesAvailable2: [],
|
||||
Release: Constants.DEFAULT_RELEASE,
|
||||
ReleaseUpgradeAvailable: false,
|
||||
UpgradeAvailable: false,
|
||||
UpgradeData: null,
|
||||
UpgradeVersion: null,
|
||||
UpgradeDismissed: false,
|
||||
Version: -1,
|
||||
VersionLookup: versionLookup,
|
||||
}, {
|
||||
[Actions.CLEAR_UI_UPGRADE]: state => {
|
||||
return {
|
||||
...state,
|
||||
UpgradeAvailable: false,
|
||||
UpgradeDismissed: false,
|
||||
UpgradeData: null,
|
||||
UpgradeVersion: null,
|
||||
};
|
||||
export const releaseVersionReducer = createReducer(
|
||||
{
|
||||
AllowDismissDependencies: false,
|
||||
DismissNewReleasesAvailable: true,
|
||||
InstalledVersion: 'none',
|
||||
LocationsLookup: {},
|
||||
NewReleasesAvailable: [],
|
||||
NewReleasesAvailable2: [],
|
||||
Release: Constants.DEFAULT_RELEASE,
|
||||
ReleaseUpgradeAvailable: false,
|
||||
UpgradeAvailable: false,
|
||||
UpgradeData: null,
|
||||
UpgradeVersion: null,
|
||||
UpgradeDismissed: false,
|
||||
Version: -1,
|
||||
VersionLookup: versionLookup,
|
||||
},
|
||||
[Actions.NOTIFY_ACTIVE_RELEASE]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
Release: action.payload.release,
|
||||
Version: action.payload.version
|
||||
};
|
||||
},
|
||||
[Actions.setAllowDismissDependencies]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
AllowDismissDependencies: action.payload,
|
||||
};
|
||||
},
|
||||
[Actions.setDismissNewReleasesAvailable]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
DismissNewReleasesAvailable: action.payload,
|
||||
};
|
||||
},
|
||||
[Actions.setDismissUIUpgrade]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
UpgradeDismissed: action.payload,
|
||||
};
|
||||
},
|
||||
[Actions.setInstalledVersion]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
InstalledVersion: action.payload,
|
||||
}
|
||||
},
|
||||
[Actions.setNewReleasesAvailable]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
DismissNewReleasesAvailable: false,
|
||||
NewReleasesAvailable: action.payload,
|
||||
};
|
||||
},
|
||||
[Actions.setNewReleasesAvailable2]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
NewReleasesAvailable2: action.payload,
|
||||
};
|
||||
},
|
||||
[Actions.SET_RELEASE_DATA]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
LocationsLookup: action.payload.locations,
|
||||
VersionLookup: action.payload.versions,
|
||||
};
|
||||
},
|
||||
[Actions.setReleaseUpgradeAvailable]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
ReleaseUpgradeAvailable: action.payload,
|
||||
};
|
||||
},
|
||||
[Actions.SET_UI_UPGRADE_DATA]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
UpgradeAvailable: true,
|
||||
UpgradeData: action.payload.upgrade_data,
|
||||
UpgradeVersion: action.payload.version,
|
||||
UpgradeDismissed: false,
|
||||
};
|
||||
{
|
||||
[Actions.CLEAR_UI_UPGRADE]: (state) => {
|
||||
return {
|
||||
...state,
|
||||
UpgradeAvailable: false,
|
||||
UpgradeDismissed: false,
|
||||
UpgradeData: null,
|
||||
UpgradeVersion: null,
|
||||
};
|
||||
},
|
||||
[Actions.NOTIFY_ACTIVE_RELEASE]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
Release: action.payload.release,
|
||||
Version: action.payload.version,
|
||||
};
|
||||
},
|
||||
[Actions.setAllowDismissDependencies]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
AllowDismissDependencies: action.payload,
|
||||
};
|
||||
},
|
||||
[Actions.setDismissNewReleasesAvailable]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
DismissNewReleasesAvailable: action.payload,
|
||||
};
|
||||
},
|
||||
[Actions.setDismissUIUpgrade]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
UpgradeDismissed: action.payload,
|
||||
};
|
||||
},
|
||||
[Actions.setInstalledVersion]: (state, action) => {
|
||||
return { ...state, InstalledVersion: action.payload };
|
||||
},
|
||||
[Actions.setNewReleasesAvailable]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
DismissNewReleasesAvailable: false,
|
||||
NewReleasesAvailable: action.payload,
|
||||
};
|
||||
},
|
||||
[Actions.setNewReleasesAvailable2]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
NewReleasesAvailable2: action.payload,
|
||||
};
|
||||
},
|
||||
[Actions.SET_RELEASE_DATA]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
LocationsLookup: action.payload.locations,
|
||||
VersionLookup: action.payload.versions,
|
||||
};
|
||||
},
|
||||
[Actions.setReleaseUpgradeAvailable]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
ReleaseUpgradeAvailable: action.payload,
|
||||
};
|
||||
},
|
||||
[Actions.SET_UI_UPGRADE_DATA]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
UpgradeAvailable: true,
|
||||
UpgradeData: action.payload.upgrade_data,
|
||||
UpgradeVersion: action.payload.version,
|
||||
UpgradeDismissed: false,
|
||||
};
|
||||
},
|
||||
}
|
||||
});
|
||||
);
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
import {createReducer} from '@reduxjs/toolkit';
|
||||
import { createReducer } from '@reduxjs/toolkit';
|
||||
import * as Actions from '../actions/skynet_actions';
|
||||
|
||||
export const skynetReducer = createReducer({
|
||||
DisplayExport: false,
|
||||
DisplayImport: false,
|
||||
}, {
|
||||
[Actions.displaySkynetExport]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
DisplayExport: action.payload,
|
||||
}
|
||||
export const skynetReducer = createReducer(
|
||||
{
|
||||
DisplayExport: false,
|
||||
DisplayImport: false,
|
||||
},
|
||||
[Actions.displaySkynetImport]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
DisplayImport: action.payload,
|
||||
}
|
||||
},
|
||||
});
|
||||
{
|
||||
[Actions.displaySkynetExport]: (state, action) => {
|
||||
return { ...state, DisplayExport: action.payload };
|
||||
},
|
||||
[Actions.displaySkynetImport]: (state, action) => {
|
||||
return { ...state, DisplayImport: action.payload };
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import {configureStore, getDefaultMiddleware} from '@reduxjs/toolkit';
|
||||
import {createCommonReducer} from '../reducers/common_reducer';
|
||||
import {downloadReducer} from '../reducers/download_reducer';
|
||||
import {errorReducer} from '../reducers/error_reducer';
|
||||
import {installReducer} from '../reducers/install_reducer';
|
||||
import {createMountReducer} from '../reducers/mount_reducer';
|
||||
import {releaseVersionReducer} from '../reducers/release_version_reducer';
|
||||
import {skynetReducer} from '../reducers/skynet_reducer';
|
||||
import {pinnedManagerReducer} from '../reducers/pinned_manager_reducer'
|
||||
import { configureStore, getDefaultMiddleware } from '@reduxjs/toolkit';
|
||||
|
||||
import { createCommonReducer } from '../reducers/common_reducer';
|
||||
import { downloadReducer } from '../reducers/download_reducer';
|
||||
import { errorReducer } from '../reducers/error_reducer';
|
||||
import { installReducer } from '../reducers/install_reducer';
|
||||
import { createMountReducer } from '../reducers/mount_reducer';
|
||||
import { pinnedManagerReducer } from '../reducers/pinned_manager_reducer';
|
||||
import { releaseVersionReducer } from '../reducers/release_version_reducer';
|
||||
import { skynetReducer } from '../reducers/skynet_reducer';
|
||||
|
||||
export default function createAppStore(platformInfo, version, state) {
|
||||
const reducer = {
|
||||
@@ -25,6 +26,6 @@ export default function createAppStore(platformInfo, version, state) {
|
||||
return configureStore({
|
||||
reducer,
|
||||
middleware,
|
||||
devTools: process.env.NODE_ENV !== 'production'
|
||||
devTools: process.env.NODE_ENV !== 'production',
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user