@@ -18,10 +26,10 @@ export default props => {
+ clicked={() => props.setDismissUIUpgrade(true)}>Cancel
|
);
-};
\ No newline at end of file
+});
\ No newline at end of file
diff --git a/src/constants.js b/src/constants.js
index de7603d..dabe650 100644
--- a/src/constants.js
+++ b/src/constants.js
@@ -58,6 +58,13 @@ exports.PROVIDER_ARG = {
siaprime: '-sp'
};
+exports.RELEASE_TYPES = [
+ 'Release',
+ 'RC',
+ 'Beta',
+ 'Alpha',
+];
+
exports.IPC_Browse_Directory = 'browse_directory';
exports.IPC_Check_Daemon_Version = 'check_daemon_version';
@@ -98,9 +105,6 @@ exports.IPC_Get_State_Reply = 'get_state_reply';
exports.IPC_Grab_Releases = 'grab_releases';
exports.IPC_Grab_Releases_Reply = 'grab_releases_reply';
-exports.IPC_Grab_UI_Releases = 'grab_ui_releases';
-exports.IPC_Grab_UI_Releases_Reply = 'grab_ui_releases_reply';
-
exports.IPC_Install_Dependency = 'install_dependency';
exports.IPC_Install_Dependency_Reply = 'install_dependency_reply';
diff --git a/src/index.js b/src/index.js
index 24b4d61..b0a33b7 100644
--- a/src/index.js
+++ b/src/index.js
@@ -18,10 +18,10 @@ if (!process.versions.hasOwnProperty('electron')) {
root.style.setProperty('--default_font_size', '15px');
}
- const store = createAppStore(arg.Platform, arg.AppPlatform);
+ const store = createAppStore(arg.Platform, arg.AppPlatform, packageJson.version);
ReactDOM.render((
-
+
), document.getElementById('root'));
serviceWorker.unregister();
diff --git a/src/redux/actions/release_version_actions.js b/src/redux/actions/release_version_actions.js
new file mode 100644
index 0000000..cac2990
--- /dev/null
+++ b/src/redux/actions/release_version_actions.js
@@ -0,0 +1,50 @@
+import axios from 'axios';
+import * as Constants from '../../constants';
+import {createAction} from 'redux-starter-kit';
+
+export const CLEAR_UI_UPGRADE = 'relver/clearUIUpgrade';
+export const clearUIUpgrade = () => {
+ return {
+ type: CLEAR_UI_UPGRADE,
+ payload: null,
+ };
+};
+
+export const detectUIUpgrade = () => {
+ return (dispatch, getState) => {
+ axios
+ .get(Constants.UI_RELEASES_URL)
+ .then(response => {
+ const state = getState();
+ const appPlatform = state.common.AppPlatform;
+ const version = state.common.Version;
+ const data = response.data;
+
+ 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]]));
+ } else {
+ dispatch(clearUIUpgrade());
+ }
+ }).catch(() => {
+ dispatch(clearUIUpgrade());
+ //TODO Display error
+ });
+ };
+};
+
+export const SET_ACTIVE_RELEASE = 'relver/setActiveRelease';
+export const setActiveRelease = (release, version) => {
+ return {
+ type: SET_ACTIVE_RELEASE,
+ payload: {
+ release,
+ version
+ }
+ };
+};
+
+export const setDismissUIUpgrade = createAction('relver/setDismissUIUpgrade');
+export const setUIUpgradeData = createAction('relver/setUIUpgradeData');
\ No newline at end of file
diff --git a/src/redux/reducers/release_version_reducer.js b/src/redux/reducers/release_version_reducer.js
new file mode 100644
index 0000000..b6e715c
--- /dev/null
+++ b/src/redux/reducers/release_version_reducer.js
@@ -0,0 +1,53 @@
+import {createReducer} from 'redux-starter-kit';
+import * as Actions from '../actions/release_version_actions';
+import * as Constants from '../../constants';
+
+const versionLookup = Constants.RELEASE_TYPES.map(k=> {
+ return {
+ [k]: ['unavailable']
+ };
+}).reduce((map, obj) => {
+ return {
+ ...map,
+ ...obj,
+ };
+});
+
+export const releaseVersionReducer = createReducer({
+ LocationsLookup: {},
+ Release: 2,
+ UpgradeAvailable: false,
+ UpgradeDismissed: false,
+ Version: -1,
+ VersionLookup: versionLookup,
+}, {
+ [Actions.CLEAR_UI_UPGRADE]: state => {
+ return {
+ ...state,
+ UpgradeAvailable: false,
+ UpgradeDismissed: false,
+ UpgradeData: null,
+ };
+ },
+ [Actions.SET_ACTIVE_RELEASE]: (state, action) => {
+ return {
+ ...state,
+ Release: action.payload.release,
+ Version: action.payload.version
+ };
+ },
+ [Actions.setDismissUIUpgrade]: (state, action) => {
+ return {
+ ...state,
+ UpgradeDismissed: action.payload,
+ };
+ },
+ [Actions.setUIUpgradeData]: (state, action) => {
+ return {
+ ...state,
+ UpgradeAvailable: true,
+ UpgradeData: action.payload,
+ UpgradeDismissed: false,
+ };
+ }
+});
\ No newline at end of file
diff --git a/src/redux/store/createAppStore.js b/src/redux/store/createAppStore.js
index d663cef..6793173 100644
--- a/src/redux/store/createAppStore.js
+++ b/src/redux/store/createAppStore.js
@@ -1,17 +1,20 @@
import {configureStore, createReducer, getDefaultMiddleware} from 'redux-starter-kit';
import {mountReducer} from '../reducers/mount_reducer';
+import {releaseVersionReducer} from '../reducers/release_version_reducer';
-export default function createAppStore(platform, appPlatform) {
+export default function createAppStore(platform, appPlatform, version) {
const createCommonReducer = () => {
return createReducer({
AppPlatform: appPlatform,
Platform: platform,
+ Version: version,
}, {});
};
const reducer = {
- common: createCommonReducer(platform, appPlatform),
+ common: createCommonReducer(platform, appPlatform, version),
mounts: mountReducer,
+ relver: releaseVersionReducer,
};
const middleware = [...getDefaultMiddleware()];