15 Commits

Author SHA1 Message Date
Juan Cruz Viotti
997133c979 refactor(GUI): get rid of basename Angular filter (#1252)
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-04-01 14:52:06 -04:00
Juan Cruz Viotti
e4a9a03239 refactor: unify error related tasks (#1154)
The current error handling logic is a mess. We have code that tries to
fetch information about errors in different places throughout the
application, and its incredibly hard to ensure certain types of error
get decent human friendly error messages.

This commit groups, improves, and tests all error related functions in
`lib/shared/errors.js`.

Here's a summary of the changes, in more detail:

- Move the `HUMAN_FRIENDLY` object to `shared/errors.js`
- Extend `HUMAN_FRIENDLY` with error descriptions
- Add `ENOMEM` to `shared/errors.js`
- Group CLI and `OSDialogService` mechanisms for getting an error title
  and an error description
- Move error serialisation routines from `robot` to `shared/errors.js`
- Create and use `createError()` and `createUserError()` utility
  functions
- Add user friendly descriptions to many errors
- Don't report user errors to TrackJS

Fixes: https://github.com/resin-io/etcher/issues/1098
Change-Type: minor
Changelog-Entry: Make errors more user friendly throughout the application.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-10 13:11:45 -04:00
Juan Cruz Viotti
df8611df11 chore: add ESLint Lodash plugin (#1148)
This is one step towards enforcing the linter until we barely have to
check for style issues on code reviews.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-08 19:11:15 -04:00
Juan Cruz Viotti
6c8bc117ab chore: revise ESLint built-in configuration (#1149)
There are a lot of new rules since the last time I revised the ESLint
rules documentation.

I've updated the main `.eslintrc.yml` to include some newer additions,
plus I added another ESLint configuration file inside `tests`, so we can
add some stricted rules to the production code while relaxing them for
the test suite (due to the fact that Mocha is not very ES6 friendly and
Angular tests require a bit of dark magic to setup).

This is a summary of the most important changes:

- Disallow "magic numbers"

These should now be extracted to constants, which forces us to think of
a good name for them, and thus make the code more self-documenting (I
had to Google up the meaning of some existing magic numbers, so I guess
this will be great for readability purposes).

- Require consistent `return` statements

Some functions relied on JavaScript relaxed casting mechanism to work,
which now have explicit return values. This flag also helped me detect
some promises that were not being returned, and therefore risked not
being caught by the exception handlers in case of errors.

- Disallow redefining function arguments

Immutability makes functions easier to reason about.

- Enforce JavaScript string templates instead of string concatenation

We were heavily mixing boths across the codebase.

There are some extra rules that I tweaked, however most of codebase
changes in this commit are related to the rules mentioned above.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-07 23:46:44 -04:00
Juan Cruz Viotti
1a00430999 chore: fix JSDoc warnings (#1151)
- The type in `@type` should be surrounded by curly braces
- We should use `@type` in some cases where we used `@property`
- `@module` descriptions should go above such tag
- Namespaces should not declare their access type

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-02 12:13:28 -04:00
Juan Cruz Viotti
aea4403a16 refactor: move all byte-size conversion logic to lib/shared/units.js (#1021)
This commit extracts the byte-related conversions from the `byte-size`
AngularJS module and the `FlashStateModel` to a re-usable generic
CommonJS module at `lib/shared/units.js`, than can also be used by the
CLI.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-01-13 16:11:28 -04:00
Juan Cruz Viotti
5ac486d941 style: refer to Resin.io as resin.io, according to the style manual (#823)
> For all, lower-case capitalization unless beginning a sentence (Ex. I
> like resin.io. Resin.io is great.)

See: https://github.com/resin-io/docs#style-manual
See: https://github.com/resin-io/etcher/issues/797
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2016-11-03 10:57:29 -04:00
Juan Cruz Viotti
c291a9067d fix: emit progress even when not in the main screen (#523)
We have logic that displays useful log messages about the state of the
flashing, as well as update the window progress in each oeprating system
(dock in OS X, task bar in Windows, etc), however since this logic lives
in the controller, the progress reports are completely frozen if the
user navigates away from the main screen (to the settings page for
example).

As a solution, we move the code that subscribes to the state change
events to a global `.run()` so it can persist page changes.

Since making sure the listeners are unregistered is not relevant anymore
(since the code is not running in a controller anymore), we get rid of
`NotifierService`, a module we built for this purpose, and directly
subscribe to the Redux store instead.

Signed-off-by: Juan Cruz Viotti <jviottidc@gmail.com>
2016-06-23 18:39:15 -04:00
Juan Cruz Viotti
c44594b45e refactor: use ES6 fat arrows in application code (#522)
ES6 fat arrows provide reasonable `this` behaviour, which protects us
from some subtle accidental bugs, and erradicates `const self = this`
from the codebase.

Far arrows were not applied in Mocha code and AngularJS
controllers/services constructors since these frameworks rely on
`.bind()` on those functions.

Signed-off-by: Juan Cruz Viotti <jviottidc@gmail.com>
2016-06-23 17:41:41 -04:00
Juan Cruz Viotti
b923008f7c refactor: make use of angular-if-state (#506)
We'll use this external module rather than our local `if-state`
implementation.

Signed-off-by: Juan Cruz Viotti <jviottidc@gmail.com>
2016-06-22 10:41:02 -04:00
Juan Cruz Viotti
7d0ea21567 Run linter as part of npm test (#436)
* Fix lint warnings

Signed-off-by: Juan Cruz Viotti <jviottidc@gmail.com>

* Run linter as part of `npm test`

Signed-off-by: Juan Cruz Viotti <jviottidc@gmail.com>
2016-05-24 15:35:51 -04:00
Juan Cruz Viotti
c1074de198 Upgrade electron to v1.1.1 (#427)
Signed-off-by: Juan Cruz Viotti <jviottidc@gmail.com>
2016-05-24 10:37:31 -04:00
Juan Cruz Viotti
a4e2639c00 Implement update notifier modal (#406)
Auto-update functionality is not ready for usage. As a workaround to
prevent users staying with older versions, we now check for updates at
startup, and if the user is not running the latest version, we present a
modal informing the user of the availiblity of a new version, and
provide a call to action to open the Etcher website in his web browser.

Extra features:

- The user can skip the update, and tell the program to delay the
notification for 7 days.

Misc changes:

- Center modal with flexbox, to allow more flexibility on the modal height.
interacting with the S3 server.
- Implement `ManifestBindService`, which now serves as a backend for the
`manifest-bind` directive to allow the directive's functionality to be
re-used by other services.
- Namespace checkbox styles that are specific to the settings page.

Fixes: https://github.com/resin-io/etcher/issues/396
Signed-off-by: Juan Cruz Viotti <jviottidc@gmail.com>
2016-05-12 13:11:30 -04:00
Juan Cruz Viotti
d5b3e0a83f Upgrade drivelist to v3.0.0 (#354)
This new version reports the size as a number of bytes instead of a
human readable string, so we have to take care of converting back to a
readable GB format ourselves.

Signed-off-by: Juan Cruz Viotti <jviottidc@gmail.com>
2016-04-25 12:46:59 -04:00
Juan Cruz Viotti
afeba11424 Move GUI code into lib/gui (#358)
This refactoring will be useful on future changes, where there will be
a single application entry point that will execute the CLI or the GUI
version depending on the environment.

Signed-off-by: Juan Cruz Viotti <jviottidc@gmail.com>
2016-04-25 12:08:19 -04:00