Skip to content

Commit

Permalink
Merge pull request #5 from 51ngul4r1ty/issue/000127/get-edit-view-but…
Browse files Browse the repository at this point in the history
…ton-working

get edit/view button working in electron
  • Loading branch information
51ngul4r1ty authored Jul 31, 2020
2 parents 2c705d3 + 56be4a2 commit a56d07f
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 20 deletions.
86 changes: 82 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "atollelectron",
"productName": "atollelectron",
"version": "0.13.2",
"version": "0.15.0",
"author": {
"name": "Kevin Berry",
"email": "[email protected]"
Expand Down Expand Up @@ -36,7 +36,7 @@
"forge": "./forge.config.js"
},
"dependencies": {
"@atoll/shared": "0.13.2",
"@atoll/shared": "0.15.0",
"@flopflip/memory-adapter": "1.6.0",
"@flopflip/react-broadcast": "10.1.11",
"axios": "0.19.2",
Expand Down Expand Up @@ -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",
Expand Down
11 changes: 5 additions & 6 deletions src/common/routeBuilder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) => (
Expand All @@ -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 : <div>LOADING...</div>;
}}
</ConfigureFlopFlip>
Expand Down
9 changes: 8 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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", () => {
Expand Down
15 changes: 8 additions & 7 deletions src/renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ 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";

// shared code
import { buildRoutesForElectron } from "common/routeBuilder";
import { AppState } from "@atoll/shared";
import { layouts } from "@atoll/shared";

const history = createElectronClientHistory();
storeHistoryInstance(history);
Expand All @@ -35,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 */ };
Expand All @@ -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);

Expand Down

0 comments on commit a56d07f

Please sign in to comment.