From 8f603ca4a7dee5f949b2968dc18ce2e468f72c25 Mon Sep 17 00:00:00 2001 From: Kevin Date: Thu, 30 Jul 2020 23:16:38 -0400 Subject: [PATCH 1/4] get edit/view button working in electron --- package-lock.json | 78 +++++++++++++++++++++++++++++++++++++ package.json | 5 ++- src/common/routeBuilder.tsx | 11 +++--- src/main.ts | 9 ++++- src/renderer.tsx | 5 ++- 5 files changed, 97 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index eb4cffd..eeaaabc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10824,6 +10824,34 @@ } } }, + "electron-devtools-installer": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/electron-devtools-installer/-/electron-devtools-installer-3.1.1.tgz", + "integrity": "sha512-g2D4J6APbpsiIcnLkFMyKZ6bOpEJ0Ltcc2m66F7oKUymyGAt628OWeU9nRZoh1cNmUs/a6Cls2UfOmsZtE496Q==", + "dev": true, + "requires": { + "rimraf": "^3.0.2", + "semver": "^7.2.1", + "unzip-crx-3": "^0.2.0" + }, + "dependencies": { + "rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + }, + "semver": { + "version": "7.3.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", + "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==", + "dev": true + } + } + }, "electron-installer-common": { "version": "0.10.2", "resolved": "https://registry.npmjs.org/electron-installer-common/-/electron-installer-common-0.10.2.tgz", @@ -14589,6 +14617,12 @@ "minimatch": "^3.0.4" } }, + "immediate": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/immediate/-/immediate-3.0.6.tgz", + "integrity": "sha1-nbHb0Pr43m++D13V5Wu2BigN5ps=", + "dev": true + }, "immer": { "version": "5.3.6", "resolved": "https://registry.npmjs.org/immer/-/immer-5.3.6.tgz", @@ -17470,6 +17504,18 @@ "object.assign": "^4.1.0" } }, + "jszip": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/jszip/-/jszip-3.5.0.tgz", + "integrity": "sha512-WRtu7TPCmYePR1nazfrtuF216cIVon/3GWOvHS9QR5bIwSbnxtdpma6un3jyGGNhHsKCSzn5Ypk+EkDRvTGiFA==", + "dev": true, + "requires": { + "lie": "~3.3.0", + "pako": "~1.0.2", + "readable-stream": "~2.3.6", + "set-immediate-shim": "~1.0.1" + } + }, "junk": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/junk/-/junk-3.1.0.tgz", @@ -17570,6 +17616,15 @@ "type-check": "~0.3.2" } }, + "lie": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/lie/-/lie-3.3.0.tgz", + "integrity": "sha512-UaiMJzeWRlEujzAuw5LokY1L5ecNQYZKfmyZ9L7wDHb/p5etKaxXhohBcrw0EYby+G/NA52vRSN4N39dxHAIwQ==", + "dev": true, + "requires": { + "immediate": "~3.0.5" + } + }, "lines-and-columns": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.1.6.tgz", @@ -22643,6 +22698,12 @@ "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", "dev": true }, + "set-immediate-shim": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz", + "integrity": "sha1-SysbJ+uAip+NzEgaWOXlb1mfP2E=", + "dev": true + }, "set-value": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz", @@ -25336,6 +25397,17 @@ } } }, + "unzip-crx-3": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/unzip-crx-3/-/unzip-crx-3-0.2.0.tgz", + "integrity": "sha512-0+JiUq/z7faJ6oifVB5nSwt589v1KCduqIJupNVDoWSXZtWDmjDGO3RAEOvwJ07w90aoXoP4enKsR7ecMrJtWQ==", + "dev": true, + "requires": { + "jszip": "^3.1.0", + "mkdirp": "^0.5.1", + "yaku": "^0.16.6" + } + }, "unzip-response": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/unzip-response/-/unzip-response-2.0.1.tgz", @@ -26919,6 +26991,12 @@ "resolved": "https://registry.npmjs.org/yaeti/-/yaeti-0.0.6.tgz", "integrity": "sha1-8m9ITXJoTPQr7ft2lwqhYI+/lXc=" }, + "yaku": { + "version": "0.16.7", + "resolved": "https://registry.npmjs.org/yaku/-/yaku-0.16.7.tgz", + "integrity": "sha1-HRlceKqbW/hHnIlblQT9TwhHmE4=", + "dev": true + }, "yalc": { "version": "1.0.0-pre.35", "resolved": "https://registry.npmjs.org/yalc/-/yalc-1.0.0-pre.35.tgz", diff --git a/package.json b/package.json index b489299..0095eac 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "atollelectron", "productName": "atollelectron", - "version": "0.13.2", + "version": "0.15.0", "author": { "name": "Kevin Berry", "email": "41717340+51ngul4r1ty@users.noreply.github.com" @@ -36,7 +36,7 @@ "forge": "./forge.config.js" }, "dependencies": { - "@atoll/shared": "0.13.2", + "@atoll/shared": "file:.yalc/@atoll/shared", "@flopflip/memory-adapter": "1.6.0", "@flopflip/react-broadcast": "10.1.11", "axios": "0.19.2", @@ -106,6 +106,7 @@ "css-loader": "3.4.2", "dependency-cruiser": "9.7.0", "electron": "9.0.5", + "electron-devtools-installer": "3.1.1", "eslint": "6.8.0", "eslint-config-wiremore": "3.0.5", "file-loader": "5.1.0", diff --git a/src/common/routeBuilder.tsx b/src/common/routeBuilder.tsx index a41e6f7..c9f89ae 100644 --- a/src/common/routeBuilder.tsx +++ b/src/common/routeBuilder.tsx @@ -4,6 +4,9 @@ import { Switch, Route } from "react-router-dom"; import { ConfigureFlopFlip } from "@flopflip/react-broadcast"; import adapter from "@flopflip/memory-adapter"; +// libraries +import { buildFeatureTogglesList, FEATURE_TOGGLE_LIST } from "@atoll/shared"; + // components import { IntlProvider, @@ -33,7 +36,8 @@ const getDefaultFlags = (windowObj: any, forSsr: boolean) => { if (forSsr) { return { showEditButton: false }; } - return (windowObj as any).__TOGGLES__; + const toggles = (windowObj as any).__TOGGLES__ || buildFeatureTogglesList(FEATURE_TOGGLE_LIST); + return toggles; }; export const buildRoutes = (windowObj: any, forSsr: boolean) => ( @@ -44,11 +48,6 @@ export const buildRoutes = (windowObj: any, forSsr: boolean) => ( defaultFlags={getDefaultFlags(windowObj, forSsr)} > {({ isAdapterReady }) => { - if (isAdapterReady) { - console.log("isAdapterReady = true"); - } else { - console.log("isAdapterReady = false"); - } return isAdapterReady ? appRoutes :
LOADING...
; }} diff --git a/src/main.ts b/src/main.ts index 7215ad1..52e986a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,5 +1,7 @@ const { app, BrowserWindow } = require("electron"); +import installExtension, { REDUX_DEVTOOLS } from "electron-devtools-installer"; + // Handle creating/removing shortcuts on Windows when installing/uninstalling. if (require("electron-squirrel-startup")) { // eslint-disable-line global-require @@ -45,7 +47,12 @@ const createWindow = () => { // This method will be called when Electron has finished // initialization and is ready to create browser windows. // Some APIs can only be used after this event occurs. -app.on("ready", createWindow); +app.on("ready", () => { + createWindow(); + installExtension(REDUX_DEVTOOLS) + .then((name) => console.log(`Added Extension: ${name}`)) + .catch((err) => console.log("An error occurred: ", err)); +}); // Quit when all windows are closed. app.on("window-all-closed", () => { diff --git a/src/renderer.tsx b/src/renderer.tsx index eee58ad..03da75e 100644 --- a/src/renderer.tsx +++ b/src/renderer.tsx @@ -19,7 +19,6 @@ import { // shared code import { buildRoutesForElectron } from "common/routeBuilder"; import { AppState } from "@atoll/shared"; -import { layouts } from "@atoll/shared"; const history = createElectronClientHistory(); storeHistoryInstance(history); @@ -34,6 +33,7 @@ const syncHistoryWithStore = (appStore, appHistory) => { // TODO: Allow this to be configured - for now it is hard-coded to local development initConfig({ getDocumentLocHref: () => "http://localhost:8500/" }); +// BUSY HERE --------------- Why doesn't this get used by FlopFlip? It seems to be using the other state that's from "window"??? const featureToggles: FeatureTogglesState = { toggles: FEATURE_TOGGLE_LIST }; @@ -44,7 +44,8 @@ const newState: StateTree = { ...oldState, app: newApp, featureToggles }; const store = configureStore({ initialState: newState, // { app: { executingOnClient: true } }, history, - middleware: [] + middleware: [], + windowRef: window }); syncHistoryWithStore(store, history); From e7b6bee2cd41e6b6b39062a04067fb1a94570db7 Mon Sep 17 00:00:00 2001 From: Kevin Date: Thu, 30 Jul 2020 23:23:04 -0400 Subject: [PATCH 2/4] bump ver --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index eeaaabc..d792a7f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,13 +1,13 @@ { "name": "atollelectron", - "version": "0.13.2", + "version": "0.15.0", "lockfileVersion": 1, "requires": true, "dependencies": { "@atoll/shared": { - "version": "0.13.2", - "resolved": "https://registry.npmjs.org/@atoll/shared/-/shared-0.13.2.tgz", - "integrity": "sha512-vNmeDEHDPOH3rX9ZNcpATqen1sZuVBePlDTpEdDVSxVEarr36faTbTnFDndYDKN+EVgcLLmkMQ2fppDNqaY6iA==", + "version": "0.15.0", + "resolved": "https://registry.npmjs.org/@atoll/shared/-/shared-0.15.0.tgz", + "integrity": "sha512-j/IH4NEsezOImOFGgqY+CmN2YZPx8gnNqhC5eWglwoZdx4GAfyUK5PVhSRUg0Mfgxwyf2Rh4qiVN5Hhaojw6qA==", "requires": { "@csstools/normalize.css": "10.1.0", "@flopflip/react-broadcast": "10.1.11", diff --git a/package.json b/package.json index 0095eac..06ecb12 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "forge": "./forge.config.js" }, "dependencies": { - "@atoll/shared": "file:.yalc/@atoll/shared", + "@atoll/shared": "0.15.0", "@flopflip/memory-adapter": "1.6.0", "@flopflip/react-broadcast": "10.1.11", "axios": "0.19.2", From 659ff5191c8a3b2dc365a710ca74bda25b12d084 Mon Sep 17 00:00:00 2001 From: Kevin Date: Thu, 30 Jul 2020 23:24:36 -0400 Subject: [PATCH 3/4] remove commented line --- src/renderer.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/renderer.tsx b/src/renderer.tsx index 03da75e..41cdfba 100644 --- a/src/renderer.tsx +++ b/src/renderer.tsx @@ -33,7 +33,6 @@ const syncHistoryWithStore = (appStore, appHistory) => { // TODO: Allow this to be configured - for now it is hard-coded to local development initConfig({ getDocumentLocHref: () => "http://localhost:8500/" }); -// BUSY HERE --------------- Why doesn't this get used by FlopFlip? It seems to be using the other state that's from "window"??? const featureToggles: FeatureTogglesState = { toggles: FEATURE_TOGGLE_LIST }; From 56be4a23f174e7bde746ae65520c2ffde588843e Mon Sep 17 00:00:00 2001 From: Kevin Date: Thu, 30 Jul 2020 23:26:33 -0400 Subject: [PATCH 4/4] format toggles correctly in state tree --- src/renderer.tsx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/renderer.tsx b/src/renderer.tsx index 41cdfba..4a6dd47 100644 --- a/src/renderer.tsx +++ b/src/renderer.tsx @@ -5,14 +5,15 @@ import { remote } from "electron"; import { Provider } from "react-redux"; import { ConnectedRouter } from "connected-react-router"; -// redux related +// libraries import { - configureStore, - createElectronClientHistory, storeHistoryInstance, initConfig, - FeatureTogglesState, + createElectronClientHistory, + configureStore, + buildFeatureTogglesList, StateTree, + FeatureTogglesState, FEATURE_TOGGLE_LIST } from "@atoll/shared"; @@ -34,7 +35,7 @@ const syncHistoryWithStore = (appStore, appHistory) => { initConfig({ getDocumentLocHref: () => "http://localhost:8500/" }); const featureToggles: FeatureTogglesState = { - toggles: FEATURE_TOGGLE_LIST + toggles: buildFeatureTogglesList(FEATURE_TOGGLE_LIST) }; const oldState: StateTree = { app: { executingOnClient: true } as AppState } as StateTree; const newApp = { ...oldState.app /*, locale */ };