Electron's `shell.openExternal()` fails on GNU/Linux when Electron is
ran with `sudo`. The issue was reported, and this is a workaround until
its fixed on the Electron side.
`node-open` is smart enough to check the `$SUDO_USER` environment
variable and to prepend `sudo -u <user>` if needed.
We keep `shell.openExternal()` for OSes other than Linux since we intend
to fully rely on it when the issue is fixed, and since its closer
integration with the operating system might lead to more accurate
results than a third party NPM module.
See https://github.com/electron/electron/issues/5039
Signed-off-by: Juan Cruz Viotti <jviottidc@gmail.com>
Its hard to attempt to debug or reproduce an issue if we don't know the
version the user is running.
Signed-off-by: Juan Cruz Viotti <jviottidc@gmail.com>
The following error is thrown if the open file dialog is cancelled
without any selection:
Unhandled rejection TypeError: Cannot read property '0' of undefined
at Number.indexedGetter (/home/parallels/Projects/etcher/node_modules/bluebird/js/release/call_get.js:106:15)
at Number.tryCatcher (/home/parallels/Projects/etcher/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/home/parallels/Projects/etcher/node_modules/bluebird/js/release/promise.js:503:31)
at Promise._settlePromise (/home/parallels/Projects/etcher/node_modules/bluebird/js/release/promise.js:560:18)
at Promise._settlePromise0 (/home/parallels/Projects/etcher/node_modules/bluebird/js/release/promise.js:605:10)
at Promise._settlePromises (/home/parallels/Projects/etcher/node_modules/bluebird/js/release/promise.js:684:18)
at Async._drainQueue (/home/parallels/Projects/etcher/node_modules/bluebird/js/release/async.js:126:16)
at Async._drainQueues (/home/parallels/Projects/etcher/node_modules/bluebird/js/release/async.js:136:10)
at Immediate.Async.drainQueues [as _onImmediate] (/home/parallels/Projects/etcher/node_modules/bluebird/js/release/async.js:16:14)
at processImmediate [as _immediateCallback] (timers.js:383:17)
Signed-off-by: Juan Cruz Viotti <jviottidc@gmail.com>
From the documentation:
> `useContentSize` Boolean - The `width` and `height` would be used as web
> page’s size, which means the actual window’s size will include window
> frame’s size and be slightly larger. Default is `false`.
The original issue is that when you specify a width/height, the actual
size that you get is slighly smaller, since the OS title bar is included
in the size you provide.
By using the `useContentSize` option, we ensure the `WebView` gets the
intended size, no matter the title bar.
This PR invalidates: https://github.com/resin-io/etcher/pull/244
Signed-off-by: Juan Cruz Viotti <jviottidc@gmail.com>
On Electron, the user can click and press over a button,
then move the mouse away from the button and release,
and the button will erroneusly keep the `:focus` state style.
The current workaround consists of:
- Iterate through all the Bootstrap button styles.
- Set the default 'background', `color` and `border-color` to match the
style of the normal state.
Signed-off-by: Juan Cruz Viotti <jviottidc@gmail.com>
This directives will be used in the header navigation instead of
re-using this logic from the `NavigationController`.
A consequence of this change is that `NavigationController` is no longer
needed, and therefore is removed.
This modal provides a more advanced way to select a drive. It prevents
certain issues the dropdown was having, like the contents overflowing
when there were many connected drives.
Fixes: https://github.com/resin-io/etcher/issues/202
Turns out that even by using `process.exit(1)`, the electron main
process doesn't exit instantly, but continues executing code.
This causes electron to throw on `electron.globalShortcut` because this
functionality is not available given that we didn't create a renderer
view.
Fixes: https://github.com/resin-io/etcher/issues/215
This error was reported by TrackJS various times:
```
TypeError: Cannot read property 'length' of undefined
at EventEmitter.<anonymous> (file:///Users/jviotti/Projects/resin/etcher/lib/browser/app.js:104:15)
at emitOne (events.js:77:13)
at EventEmitter.emit (events.js:169:7)
at /Users/jviotti/Projects/resin/etcher/lib/browser/modules/drive-scanner.js:131:17
at processQueue (/Users/jviotti/Projects/resin/etcher/node_modules/angular/angular.js:15616:28)
at /Users/jviotti/Projects/resin/etcher/node_modules/angular/angular.js:15632:27
at Scope.$eval (/Users/jviotti/Projects/resin/etcher/node_modules/angular/angular.js:16884:28)
at Scope.$digest (/Users/jviotti/Projects/resin/etcher/node_modules/angular/angular.js:16700:31)
at /Users/jviotti/Projects/resin/etcher/node_modules/angular/angular.js:16923:26
at completeOutstandingRequest (/Users/jviotti/Projects/resin/etcher/node_modules/angular/angular.js:5825:10),
```
The error refers to the following line in `app.js`:
```js
if (drives.length === 1 && self.selection.hasImage()) {
```
Which indicates that the array of detected drives returned to the main
controller is `undefined` for some reason.
The problem resides in the `.scan()` method of `DriveScannerService`:
```js
this.scan = function() {
return $q.when(drives.listRemovable()).catch(dialog.showError);
};
```
When an error is thrown when scanning the drives, the `.catch()` block
is called. This means that the error is not propagated to the outer code
and the promise resolves with `undefined`.
The solution is to move `.catch()` to the place `.scan()` is called,
instead of making use of it in the low-level parts of the process.