Skip to content

Commit

Permalink
updated app index and main
Browse files Browse the repository at this point in the history
  • Loading branch information
jdpigeon committed Aug 9, 2020
1 parent 5ab998c commit 2eb02a7
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 56 deletions.
8 changes: 5 additions & 3 deletions app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ const store = configureStore();

const AppContainer = process.env.PLAIN_HMR ? Fragment : ReactHotAppContainer;

document.addEventListener('DOMContentLoaded', () =>
document.addEventListener('DOMContentLoaded', () => {
// eslint-disable-next-line global-require
const Root = require('./containers/Root').default;
render(
<AppContainer>
<Root store={store} history={history} />
</AppContainer>,
document.getElementById('root')
)
);
);
});
21 changes: 15 additions & 6 deletions app/main.dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* When running `yarn build` or `yarn build-main`, this file is compiled to
* `./app/main.prod.js` using webpack. This gives us some performance wins.
*/
import 'core-js/stable';
import 'regenerator-runtime/runtime';
import { app, BrowserWindow, ipcMain } from 'electron';
import path from 'path';
import { autoUpdater } from 'electron-updater';
Expand Down Expand Up @@ -52,7 +54,7 @@ const installExtensions = async () => {
const extensions = ['REACT_DEVELOPER_TOOLS', 'REDUX_DEVTOOLS'];

return Promise.all(
extensions.map(name => installer.default(installer[name], forceDownload))
extensions.map((name) => installer.default(installer[name], forceDownload))
).catch(console.log);
};

Expand All @@ -69,13 +71,15 @@ const createWindow = async () => {
width: 1280,
height: 800,
webPreferences:
process.env.NODE_ENV === 'development' || process.env.E2E_BUILD === 'true'
(process.env.NODE_ENV === 'development' ||
process.env.E2E_BUILD === 'true') &&
process.env.ERB_SECURE !== 'true'
? {
nodeIntegration: true
nodeIntegration: true,
}
: {
preload: path.join(__dirname, 'dist/renderer.prod.js')
}
preload: path.join(__dirname, 'dist/renderer.prod.js'),
},
});

mainWindow.setMinimumSize(1075, 708);
Expand Down Expand Up @@ -127,7 +131,12 @@ app.on('window-all-closed', () => {
}
});

app.on('ready', createWindow);
if (process.env.E2E_BUILD === 'true') {
// eslint-disable-next-line promise/catch-or-return
app.whenReady().then(createWindow);
} else {
app.on('ready', createWindow);
}

app.on('activate', () => {
// On macOS it's common to re-create a window in the app when the
Expand Down
94 changes: 47 additions & 47 deletions app/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
Menu,
shell,
BrowserWindow,
MenuItemConstructorOptions
MenuItemConstructorOptions,
} from 'electron';

interface DarwinMenuItemConstructorOptions extends MenuItemConstructorOptions {
Expand Down Expand Up @@ -47,8 +47,8 @@ export default class MenuBuilder {
label: 'Inspect element',
click: () => {
this.mainWindow.webContents.inspectElement(x, y);
}
}
},
},
]).popup({ window: this.mainWindow });
});
}
Expand All @@ -59,20 +59,20 @@ export default class MenuBuilder {
submenu: [
{
label: 'About BrainWaves',
selector: 'orderFrontStandardAboutPanel:'
selector: 'orderFrontStandardAboutPanel:',
},
{ type: 'separator' },
{ label: 'Services', submenu: [] },
{ type: 'separator' },
{
label: 'Hide ElectronReact',
accelerator: 'Command+H',
selector: 'hide:'
selector: 'hide:',
},
{
label: 'Hide Others',
accelerator: 'Command+Shift+H',
selector: 'hideOtherApplications:'
selector: 'hideOtherApplications:',
},
{ label: 'Show All', selector: 'unhideAllApplications:' },
{ type: 'separator' },
Expand All @@ -81,9 +81,9 @@ export default class MenuBuilder {
accelerator: 'Command+Q',
click: () => {
app.quit();
}
}
]
},
},
],
};
const subMenuEdit: DarwinMenuItemConstructorOptions = {
label: 'Edit',
Expand All @@ -97,9 +97,9 @@ export default class MenuBuilder {
{
label: 'Select All',
accelerator: 'Command+A',
selector: 'selectAll:'
}
]
selector: 'selectAll:',
},
],
};
const subMenuViewDev: MenuItemConstructorOptions = {
label: 'View',
Expand All @@ -109,23 +109,23 @@ export default class MenuBuilder {
accelerator: 'Command+R',
click: () => {
this.mainWindow.webContents.reload();
}
},
},
{
label: 'Toggle Full Screen',
accelerator: 'Ctrl+Command+F',
click: () => {
this.mainWindow.setFullScreen(!this.mainWindow.isFullScreen());
}
},
},
{
label: 'Toggle Developer Tools',
accelerator: 'Alt+Command+I',
click: () => {
this.mainWindow.webContents.toggleDevTools();
}
}
]
},
},
],
};
const subMenuViewProd: MenuItemConstructorOptions = {
label: 'View',
Expand All @@ -135,22 +135,22 @@ export default class MenuBuilder {
accelerator: 'Ctrl+Command+F',
click: () => {
this.mainWindow.setFullScreen(!this.mainWindow.isFullScreen());
}
}
]
},
},
],
};
const subMenuWindow: DarwinMenuItemConstructorOptions = {
label: 'Window',
submenu: [
{
label: 'Minimize',
accelerator: 'Command+M',
selector: 'performMiniaturize:'
selector: 'performMiniaturize:',
},
{ label: 'Close', accelerator: 'Command+W', selector: 'performClose:' },
{ type: 'separator' },
{ label: 'Bring All to Front', selector: 'arrangeInFront:' }
]
{ label: 'Bring All to Front', selector: 'arrangeInFront:' },
],
};
const subMenuHelp: MenuItemConstructorOptions = {
label: 'Help',
Expand All @@ -159,29 +159,29 @@ export default class MenuBuilder {
label: 'Learn More',
click() {
shell.openExternal('https://electronjs.org');
}
},
},
{
label: 'Documentation',
click() {
shell.openExternal(
'https://github.com/electron/electron/tree/master/docs#readme'
);
}
},
},
{
label: 'Community Discussions',
click() {
shell.openExternal('https://www.electronjs.org/community');
}
},
},
{
label: 'Search Issues',
click() {
shell.openExternal('https://github.com/electron/electron/issues');
}
}
]
},
},
],
};

const subMenuView =
Expand All @@ -200,16 +200,16 @@ export default class MenuBuilder {
submenu: [
{
label: '&Open',
accelerator: 'Ctrl+O'
accelerator: 'Ctrl+O',
},
{
label: '&Close',
accelerator: 'Ctrl+W',
click: () => {
this.mainWindow.close();
}
}
]
},
},
],
},
{
label: '&View',
Expand All @@ -222,7 +222,7 @@ export default class MenuBuilder {
accelerator: 'Ctrl+R',
click: () => {
this.mainWindow.webContents.reload();
}
},
},
{
label: 'Toggle &Full Screen',
Expand All @@ -231,15 +231,15 @@ export default class MenuBuilder {
this.mainWindow.setFullScreen(
!this.mainWindow.isFullScreen()
);
}
},
},
{
label: 'Toggle &Developer Tools',
accelerator: 'Alt+Ctrl+I',
click: () => {
this.mainWindow.webContents.toggleDevTools();
}
}
},
},
]
: [
{
Expand All @@ -249,9 +249,9 @@ export default class MenuBuilder {
this.mainWindow.setFullScreen(
!this.mainWindow.isFullScreen()
);
}
}
]
},
},
],
},
{
label: 'Help',
Expand All @@ -260,30 +260,30 @@ export default class MenuBuilder {
label: 'Learn More',
click() {
shell.openExternal('https://electronjs.org');
}
},
},
{
label: 'Documentation',
click() {
shell.openExternal(
'https://github.com/electron/electron/tree/master/docs#readme'
);
}
},
},
{
label: 'Community Discussions',
click() {
shell.openExternal('https://www.electronjs.org/community');
}
},
},
{
label: 'Search Issues',
click() {
shell.openExternal('https://github.com/electron/electron/issues');
}
}
]
}
},
},
],
},
];

return templateDefault;
Expand Down

0 comments on commit 2eb02a7

Please sign in to comment.