fix(require): Move more requires to new electron format

This commit is contained in:
Ben Gotow 2016-04-13 15:35:01 -07:00
parent 8e2be2d076
commit fe171a0c8c
17 changed files with 24 additions and 25 deletions

View file

@ -135,11 +135,11 @@ class TemplateStore extends NylasStore {
}
_displayError(message) {
const dialog = require('remote').require('dialog');
const dialog = require('electron').remote.dialog;
dialog.showErrorBox('Template Creation Error', message);
}
_displayDialog(title, message, buttons) {
const dialog = require('remote').require('dialog');
const dialog = require('electron').remote.dialog;
return (dialog.showMessageBox({
title: title,
message: title,

View file

@ -49,7 +49,7 @@ class TranslateButton extends React.Component {
_onError(error) {
Actions.closePopover()
const dialog = require('remote').require('dialog');
const dialog = require('electron').remote.dialog;
dialog.showErrorBox('Language Conversion Failed', error.toString());
}

View file

@ -161,7 +161,7 @@ export default class ParticipantsTextField extends React.Component {
const menu = new MenuClass();
menu.append(new MenuItem({
label: `Copy ${participant.email}`,
click: () => require('clipboard').writeText(participant.email),
click: () => require('electron').clipboard.writeText(participant.email),
}))
menu.append(new MenuItem({
type: 'separator',

View file

@ -64,5 +64,5 @@ module.exports =
ipcRenderer.send 'command', 'application:install-update'
true
if action.id is 'release-bar:view-changelog'
require('shell').openExternal('https://github.com/nylas/N1/blob/master/CHANGELOG.md')
require('electron').shell.openExternal('https://github.com/nylas/N1/blob/master/CHANGELOG.md')
false

View file

@ -20,7 +20,7 @@ class DeveloperBarCurlItem extends React.Component
return @props.item isnt nextProps.item
_onCopyCommand: =>
clipboard = require('clipboard')
clipboard = require('electron').clipboard
clipboard.writeText(@props.item.command)
_isError: ->

View file

@ -22,7 +22,7 @@ describe('Clean app boot', ()=> {
it("has the autoupdater pointing to the correct url when there's no config loaded", () => {
this.app.client.execute(()=>{
const app = require('remote').getGlobal('application');
const app = require('electron').remote.getGlobal('application');
return {
platform: process.platform,
arch: process.arch,

View file

@ -19,7 +19,7 @@ describe('Logged in app boot', () => {
it("has the autoupdater pointing to the correct url", () => {
this.app.client.execute(()=>{
app = require('remote').getGlobal('application')
app = require('electron').remote.getGlobal('application')
return {
platform: process.platform,
arch: process.arch,

View file

@ -182,11 +182,11 @@ class EventedIFrame extends React.Component
event.preventDefault()
{remote} = require('electron')
clipboard = require('clipboard')
clipboard = require('electron').clipboard
Menu = remote.require('menu')
MenuItem = remote.require('menu-item')
NativeImage = require('native-image')
shell = require('shell')
shell = require('electron').shell
path = require('path')
fs = require('fs')
menu = new Menu()

View file

@ -63,7 +63,7 @@ module.exports = ErrorLogger = (function() {
}
ErrorLogger.prototype.openLogs = function() {
var shell = require('shell');
var shell = require('electron').shell;
shell.openItem(this._logPath());
};

View file

@ -226,7 +226,7 @@ class DatabaseStore extends NylasStore
catch err
console.log("Could not write mail rules to file: #{err}")
app = require('remote').getGlobal('application')
app = require('electron').remote.getGlobal('application')
app.rebuildDatabase()
_prettyConsoleLog: (q) =>

View file

@ -627,8 +627,7 @@ class NylasEnvConstructor extends Model
width > 0 and height > 0 and x + width > 0 and y + height > 0
getDefaultWindowDimensions: ->
screen = remote.require('screen')
{width, height} = screen.getPrimaryDisplay().workAreaSize
{width, height} = remote.screen.getPrimaryDisplay().workAreaSize
x = 0
y = 0

View file

@ -48,7 +48,7 @@ class NylasSpellchecker
# Separate method for testing
_setWebframeSpellchecker: (lang, spellCheck) ->
require('web-frame').setSpellCheckProvider(lang, false, {spellCheck})
require('electron').webFrame.setSpellCheckProvider(lang, false, {spellCheck})
# node-spellchecker's method for resolving the builtin hunspell
# dictionaries for Linux (From

View file

@ -11,7 +11,7 @@ restoreSelection = exp.restoreSelection;
getSelectionData = exp.getSelectionData;
var receiveEvent = function (json) {
var remote = require('remote');
var remote = require('electron').remote;
if (json.selectionData) {
document.removeEventListener("selectionchange", selectionChange);
@ -108,7 +108,7 @@ events.forEach(function(type) {
representation.targetChecked = event.target.checked;
}
var remote = require('remote');
var remote = require('electron').remote;
ipc.send("from-react-remote-window", {windowId: remote.getCurrentWindow().id, event: representation});
if ((event.type != 'keydown') && (event.type != 'keypress') && (event.type != 'keyup')) {
event.preventDefault();
@ -121,7 +121,7 @@ selectionChange = function() {
selectionData = getSelectionData()
if (_.isEqual(selectionData, lastSelectionData)) { return; }
lastSelectionData = _.clone(selectionData)
var remote = require('remote');
var remote = require('electron').remote;
remote.getCurrentWindow().id
ipc.send("from-react-remote-window-selection", selectionData);
}

View file

@ -223,7 +223,7 @@ var openWindowForComponent = function(Component, options) {
}
}
var remote = require('remote');
var remote = require('electron').remote;
var url = require('url');
var BrowserWindow = remote.require('browser-window');

View file

@ -30,7 +30,7 @@ function handleSetupError (error) {
function copyEnvFromMainProcess() {
var _ = require('underscore');
var remote = require('remote');
var remote = require('electron').remote;
var newEnv = _.extend({}, process.env, remote.process.env);
process.env = newEnv;
}
@ -60,7 +60,7 @@ function setupWindow (loadSettings) {
// productName: 'N1',
// companyName: 'Nylas',
// // By explicitly passing the app version here, we could save the call
// // of "require('remote').require('app').getVersion()".
// // of "require('electron').remote.require('app').getVersion()".
// extra: {_version: loadSettings.appVersion}
// })

View file

@ -33,7 +33,7 @@ export default class MyComposerButton extends React.Component {
}
_getDialog() {
return require('remote').require('dialog');
return require('electron').remote.dialog;
}
render() {

View file

@ -3,9 +3,9 @@
<div class="sheet-toolbar">
<div style="position:absolute; width:100%; height:100%; z-index: 1;" class="sheet-toolbar-container">
<div name="ToolbarWindowControls" class="toolbar-window-controls">
<button class="close" onClick="require('remote').getCurrentWindow().close()"></button>
<button class="minimize" onClick="require('remote').getCurrentWindow().minimize()"></button>
<button class="maximize" onClick="require('remote').getCurrentWindow().maximize()"></button>
<button class="close" onClick="require('electron').remote.getCurrentWindow().close()"></button>
<button class="minimize" onClick="require('electron').remote.getCurrentWindow().minimize()"></button>
<button class="maximize" onClick="require('electron').remote.getCurrentWindow().maximize()"></button>
</div>
<div class="window-title"></div>
</div>