From 89a8ad380f3267ee2d6346c81c56e0b58ce4ac6f Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Mon, 26 Oct 2020 09:51:38 -0700 Subject: [PATCH] Added disable watcher on startup. RPS-8 --- electron/electron-store.js | 1 + electron/file-watcher/file-watcher-ipc.js | 5 ++- .../notifications-toggle.atom.jsx | 4 +- .../part-type-converter.atom.jsx | 4 +- .../watcher-startup/watcher-startup.atom.jsx | 41 +++++++++++++++++++ .../jobs-detail-description.molecule.jsx | 2 +- .../jobs-lines-table.molecule.jsx | 7 +++- .../jobs-targets-stats.molecule.jsx | 8 ++-- src/components/pages/jobs/jobs.page.jsx | 1 - src/components/pages/routes/routes.page.jsx | 2 +- .../pages/settings/settings.page.jsx | 2 + src/redux/store.js | 4 +- src/redux/user/user.sagas.js | 4 +- 13 files changed, 70 insertions(+), 15 deletions(-) create mode 100644 src/components/atoms/watcher-startup/watcher-startup.atom.jsx diff --git a/electron/electron-store.js b/electron/electron-store.js index e8bd180..b444ac8 100644 --- a/electron/electron-store.js +++ b/electron/electron-store.js @@ -5,6 +5,7 @@ const store = new Store({ enableNotifications: true, filePaths: [], accepted_ins_co: [], + runWatcherOnStartup: true, polling: { enabled: false, pollingInterval: 1000, diff --git a/electron/file-watcher/file-watcher-ipc.js b/electron/file-watcher/file-watcher-ipc.js index c536d48..378f58e 100644 --- a/electron/file-watcher/file-watcher-ipc.js +++ b/electron/file-watcher/file-watcher-ipc.js @@ -17,7 +17,10 @@ ipcMain.on( ); ipcMain.on(ipcTypes.default.fileWatcher.toMain.start, async (event, arg) => { - StartWatcher(); + if ((arg && arg.startup && store.get("runWatcherOnStartup")) || !arg) { + StartWatcher(); + } + // event.sender.send(ipcTypes.default.fileWatcher.toRenderer.startSuccess); event.sender.send( ipcTypes.default.fileWatcher.toRenderer.filepathsList, diff --git a/src/components/atoms/notifications-toggle/notifications-toggle.atom.jsx b/src/components/atoms/notifications-toggle/notifications-toggle.atom.jsx index 0fea356..64776ef 100644 --- a/src/components/atoms/notifications-toggle/notifications-toggle.atom.jsx +++ b/src/components/atoms/notifications-toggle/notifications-toggle.atom.jsx @@ -15,7 +15,7 @@ const mapDispatchToProps = (dispatch) => ({ //setUserLanguage: language => dispatch(setUserLanguage(language)) }); -export function WatcherPollingMolecule({ appSettings }) { +export function NotificationsToggleAtom({ appSettings }) { const handleChange = (val) => { ipcRenderer.send(ipcTypes.default.app.toMain.track, { event: "TOGGLE_NOTIFICATION", @@ -41,4 +41,4 @@ export function WatcherPollingMolecule({ appSettings }) { export default connect( mapStateToProps, mapDispatchToProps -)(WatcherPollingMolecule); +)(NotificationsToggleAtom); diff --git a/src/components/atoms/part-type-converter/part-type-converter.atom.jsx b/src/components/atoms/part-type-converter/part-type-converter.atom.jsx index 90a1570..a76f99d 100644 --- a/src/components/atoms/part-type-converter/part-type-converter.atom.jsx +++ b/src/components/atoms/part-type-converter/part-type-converter.atom.jsx @@ -1,4 +1,4 @@ -export default (part_type) => { +const converter = (part_type) => { switch (part_type) { case "PAA": return "A/M"; @@ -19,3 +19,5 @@ export default (part_type) => { return part_type; } }; + +export default converter; diff --git a/src/components/atoms/watcher-startup/watcher-startup.atom.jsx b/src/components/atoms/watcher-startup/watcher-startup.atom.jsx new file mode 100644 index 0000000..9bb02f0 --- /dev/null +++ b/src/components/atoms/watcher-startup/watcher-startup.atom.jsx @@ -0,0 +1,41 @@ +import { Switch } from "antd"; +import React from "react"; +import { connect } from "react-redux"; +import { createStructuredSelector } from "reselect"; +import ipcTypes from "../../../ipc.types"; +import { selectSettings } from "../../../redux/application/application.selectors"; +import DataLabel from "../../atoms/data-label/data-label.atom"; +const { ipcRenderer } = window; + +const mapStateToProps = createStructuredSelector({ + //currentUser: selectCurrentUser + appSettings: selectSettings, +}); +const mapDispatchToProps = (dispatch) => ({ + //setUserLanguage: language => dispatch(setUserLanguage(language)) +}); + +export function WatcherStartupAtom({ appSettings }) { + const handleChange = (val) => { + ipcRenderer.send(ipcTypes.default.app.toMain.track, { + event: "TOGGLE_WATCHER_ON_STARTUP", + enabled: val, + }); + + ipcRenderer.send(ipcTypes.default.store.set, { + runWatcherOnStartup: val, + }); + }; + + return ( +
+ + + +
+ ); +} +export default connect(mapStateToProps, mapDispatchToProps)(WatcherStartupAtom); diff --git a/src/components/molecules/jobs-detail-description/jobs-detail-description.molecule.jsx b/src/components/molecules/jobs-detail-description/jobs-detail-description.molecule.jsx index d03346a..b8a25ed 100644 --- a/src/components/molecules/jobs-detail-description/jobs-detail-description.molecule.jsx +++ b/src/components/molecules/jobs-detail-description/jobs-detail-description.molecule.jsx @@ -18,7 +18,7 @@ export default function JobsDetailDescriptionMolecule({ loading, job }) { ghost={false} title={job.clm_no} subTitle={job.ins_co_nm} - extra={[]} + extra={[]} > {`${job.ownr_fn} ${job.ownr_ln}`} diff --git a/src/components/molecules/jobs-lines-table/jobs-lines-table.molecule.jsx b/src/components/molecules/jobs-lines-table/jobs-lines-table.molecule.jsx index 7a23809..1bfc583 100644 --- a/src/components/molecules/jobs-lines-table/jobs-lines-table.molecule.jsx +++ b/src/components/molecules/jobs-lines-table/jobs-lines-table.molecule.jsx @@ -154,10 +154,13 @@ export default function JobLinesTableMolecule({ loading, job }) { x: true, y: "20rem", }} - summary={() => ( + footer={() => ( Summary - + + This is a summary content + + This is a summary content diff --git a/src/components/molecules/jobs-targets-stats/jobs-targets-stats.molecule.jsx b/src/components/molecules/jobs-targets-stats/jobs-targets-stats.molecule.jsx index 5ea09dc..1db0ff3 100644 --- a/src/components/molecules/jobs-targets-stats/jobs-targets-stats.molecule.jsx +++ b/src/components/molecules/jobs-targets-stats/jobs-targets-stats.molecule.jsx @@ -5,7 +5,7 @@ import { createStructuredSelector } from "reselect"; import { selectSelectedJobTargetPc } from "../../../redux/application/application.selectors"; import { CalculateJobRpsDollars, - CalculateJobRpsPc, + CalculateJobRpsPc } from "../../../util/CalculateJobRps"; import ErrorResultAtom from "../../atoms/error-result/error-result.atom"; @@ -25,14 +25,16 @@ export function JobsTargetsStatsMolecule({ job, selectedJobTargetPc, }) { + // eslint-disable-next-line react-hooks/exhaustive-deps const { actPriceSum, jobRpsDollars } = useCallback( CalculateJobRpsDollars(job, true), - [job] + [job, CalculateJobRpsDollars] ); + // eslint-disable-next-line react-hooks/exhaustive-deps const { dbPriceSum, jobRpsPc } = useCallback( CalculateJobRpsPc(job, jobRpsDollars, true), - [job, jobRpsDollars] + [job, jobRpsDollars, CalculateJobRpsPc] ); if (loading) return ; diff --git a/src/components/pages/jobs/jobs.page.jsx b/src/components/pages/jobs/jobs.page.jsx index e6eef89..a406508 100644 --- a/src/components/pages/jobs/jobs.page.jsx +++ b/src/components/pages/jobs/jobs.page.jsx @@ -5,7 +5,6 @@ import JobsListOrganism from "../../organisms/jobs-list-latest/jobs-list-latest. import JobsListSearchOrganism from "../../organisms/jobs-list-search/jobs-list-search.organism"; export default function JobsPage() { - console.log("Jobs Page Rerender"); const selectedBreakpoint = Object.entries(Grid.useBreakpoint()) .filter((screen) => !!screen[1]) .slice(-1)[0]; diff --git a/src/components/pages/routes/routes.page.jsx b/src/components/pages/routes/routes.page.jsx index 166c716..1e0b001 100644 --- a/src/components/pages/routes/routes.page.jsx +++ b/src/components/pages/routes/routes.page.jsx @@ -22,7 +22,7 @@ export function RoutesPage({ bodyshop }) { errorMessage="You do not currently have access to any shop. Please reach out to technical support." /> ); - console.log("routes render"); + return ( + diff --git a/src/redux/store.js b/src/redux/store.js index ecc02f4..5e3b96a 100644 --- a/src/redux/store.js +++ b/src/redux/store.js @@ -30,5 +30,5 @@ sagaMiddleWare.run(rootSaga); export const persistor = persistStore(store); -export default { store, persistStore }; - +const epxortObj = { store, persistStore }; +export default epxortObj; diff --git a/src/redux/user/user.sagas.js b/src/redux/user/user.sagas.js index 007e6b5..57fdcfa 100644 --- a/src/redux/user/user.sagas.js +++ b/src/redux/user/user.sagas.js @@ -140,7 +140,9 @@ export function* signInSuccessSaga({ payload }) { ipcTypes.default.app.toMain.setAcceptableInsCoNm, shop.data.bodyshops[0].accepted_ins_co ); - ipcRenderer.send(ipcTypes.default.fileWatcher.toMain.start); + ipcRenderer.send(ipcTypes.default.fileWatcher.toMain.start, { + startup: true, + }); } else { console.log("No bodyshop has been associated."); yield put(setBodyshop(false));