From 6929da6679b2047711d8e86963757c07d844e305 Mon Sep 17 00:00:00 2001
From: Patrick Fic <>
Date: Thu, 22 Oct 2020 21:12:21 -0700
Subject: [PATCH] Added update status to reducer.
---
electron/main.js | 11 +++++++----
.../update-available/update-available.atom.jsx | 17 +++++++++++++++++
.../molecules/job-group/job-group.molecule.jsx | 2 +-
src/redux/application/application.actions.js | 6 ++++++
src/redux/application/application.reducer.js | 4 +++-
src/redux/application/application.selectors.js | 5 +++++
src/redux/application/application.types.js | 1 +
7 files changed, 40 insertions(+), 6 deletions(-)
create mode 100644 src/components/atoms/update-available/update-available.atom.jsx
diff --git a/electron/main.js b/electron/main.js
index e1b02e7..a174e07 100644
--- a/electron/main.js
+++ b/electron/main.js
@@ -70,7 +70,10 @@ var menu = Menu.buildFromTemplate([
{
label: `Check for Updates (currently ${app.getVersion()})`,
click() {
- autoUpdater.checkForUpdatesAndNotify();
+ autoUpdater.checkForUpdatesAndNotify({
+ title: "ImEX RPS Update Downloaded",
+ body: "Restart ImEX RPS to install.",
+ });
},
},
{
@@ -245,9 +248,9 @@ autoUpdater.on("error", (ev, err) => {
autoUpdater.on("download-progress", (ev, progressObj) => {
console.log("Download progress...");
});
-autoUpdater.on("update-downloaded", (ev, info) => {
- console.log("Update downloaded; will install in 5 seconds");
-});
+// autoUpdater.on("update-downloaded", (ev, info) => {
+// console.log("Update downloaded; will install in 5 seconds");
+// });
autoUpdater.on("update-downloaded", (ev, info) => {
Nucleus.track("UPDATE_DOWNLOADED", info);
if (process.env.NODE_ENV === "production") {
diff --git a/src/components/atoms/update-available/update-available.atom.jsx b/src/components/atoms/update-available/update-available.atom.jsx
new file mode 100644
index 0000000..684b25e
--- /dev/null
+++ b/src/components/atoms/update-available/update-available.atom.jsx
@@ -0,0 +1,17 @@
+import React from "react";
+import { connect } from "react-redux";
+import { createStructuredSelector } from "reselect";
+import { selectUpdateAvailable } from "../../../redux/application/application.selectors";
+const mapStateToProps = createStructuredSelector({
+ //scanLoading: selectScanLoading,
+ updateAvailable: selectUpdateAvailable,
+});
+const mapDispatchToProps = (dispatch) => ({});
+
+export function UpdateAvailableAtom({ available }) {
+ return
Update Available!
;
+}
+export default connect(
+ mapStateToProps,
+ mapDispatchToProps
+)(UpdateAvailableAtom);
diff --git a/src/components/molecules/job-group/job-group.molecule.jsx b/src/components/molecules/job-group/job-group.molecule.jsx
index b970c5c..53965bf 100644
--- a/src/components/molecules/job-group/job-group.molecule.jsx
+++ b/src/components/molecules/job-group/job-group.molecule.jsx
@@ -54,7 +54,7 @@ export function JobGroupMolecule({ bodyshop, jobId, group, job }) {
e.preventDefault()}>
{group}
-
+
{loading && }
diff --git a/src/redux/application/application.actions.js b/src/redux/application/application.actions.js
index ca179ea..060e812 100644
--- a/src/redux/application/application.actions.js
+++ b/src/redux/application/application.actions.js
@@ -38,7 +38,13 @@ export const setSelectedJobTargetPcSuccess = (pct) => ({
type: ApplicationActionTypes.SET_SELECTED_JOB_TARGET_PC_SUCCESS,
payload: pct,
});
+
export const setSettings = (settingsObj) => ({
type: ApplicationActionTypes.SET_SETTINGS,
payload: settingsObj,
});
+
+export const setUpdateAvailable = (available) => ({
+ type: ApplicationActionTypes.SET_UPDATE_AVAILABLE,
+ payload: available,
+});
diff --git a/src/redux/application/application.reducer.js b/src/redux/application/application.reducer.js
index 5cb8ddc..d19df1a 100644
--- a/src/redux/application/application.reducer.js
+++ b/src/redux/application/application.reducer.js
@@ -7,6 +7,7 @@ const INITIAL_STATE = {
selectedJobId: null,
selectedJobTargetPc: 0,
settings: {},
+ updateAvailable: false,
};
const { ipcRenderer } = window;
@@ -60,7 +61,8 @@ const applicationReducer = (state = INITIAL_STATE, action) => {
return { ...state, selectedJobId: action.payload };
case ApplicationActionTypes.SET_SETTINGS:
return { ...state, settings: { ...state.settings, ...action.payload } };
-
+ case ApplicationActionTypes.SET_UPDATE_AVAILABLE:
+ return { ...state, updateAvailable: action.payload };
default:
return state;
}
diff --git a/src/redux/application/application.selectors.js b/src/redux/application/application.selectors.js
index beafc9f..f474fbd 100644
--- a/src/redux/application/application.selectors.js
+++ b/src/redux/application/application.selectors.js
@@ -31,3 +31,8 @@ export const selectSettings = createSelector(
[selectApplication],
(application) => application.settings
);
+
+export const selectUpdateAvailable = createSelector(
+ [selectApplication],
+ (application) => application.updateAvailable
+);
diff --git a/src/redux/application/application.types.js b/src/redux/application/application.types.js
index 3a73825..25f7ddf 100644
--- a/src/redux/application/application.types.js
+++ b/src/redux/application/application.types.js
@@ -8,5 +8,6 @@ const ApplicationActionTypes = {
SET_SELECTED_JOB_TARGET_PC: "SET_SELECTED_JOB_TARGET_PC",
SET_SELECTED_JOB_TARGET_PC_SUCCESS: "SET_SELECTED_JOB_TARGET_PC_SUCCESS",
SET_SETTINGS: "SET_SETTINGS",
+ SET_UPDATE_AVAILABLE: "SET_UPDATE_AVAILABLE",
};
export default ApplicationActionTypes;