85 Commits

Author SHA1 Message Date
Juan Cruz Viotti
4122e0bf1d refactor: move most models to lib/shared/ (#1596)
Now that the Redux store is no longer front-end dependent, we can move
most of the models to lib/shared. Currently, lib/shared is a mess, and
contains all sorts of functionality, however moving things out of the
GUI is the first step. Once we have everything decoupled, we can
organise all the code we have there.

Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
2017-07-18 12:34:10 -03:00
Juan Cruz Viotti
a5b1a92920 chore: add eslint-jsdoc-plugin to eslint (#1585)
This plugin helps us detect some things the built-in jsdoc rules can't,
like whether there is an example or not.

As expected, the addition of this plugin helped detect some minor JSDoc
issues.

Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
2017-07-12 10:19:08 -04:00
Benedict Aas
b18fa1f13f feat(GUI): add webview api version parameter (#1558)
We add the API version sent to the banner via a GET search parameter,
allowing for more intricate control over what data needs or can be sent.
2017-07-04 13:11:44 -04:00
Benedict Aas
a7d713c323 feat(GUI): rewrite svg-icon directive in react (#1464)
We change from using an Angular directive to using React through
react2angular in the SVGIcon module.
2017-06-12 08:42:52 -04:00
Benedict Aas
ef739fb222 refactor(GUI): remove angular dependency from selection-state (#1509)
We remove the dependency on Angular from SelectionStateModel and rename
it to selectionState.
2017-06-12 08:40:52 -04:00
Benedict Aas
31a2389d04 fix(GUI): reset webview after navigating away (#1422)
We reload and reset the webview to its original URL when the user
navigates away from the success screen.

Changelog-Entry: Reset webview after navigating away from the success screen.
2017-06-08 11:42:55 -04:00
Benedict Aas
14b04413b5 refactor(GUI): remove angular from DrivesModel (#1265)
We remove usage of Angular from DrivesModel.

Depends: https://github.com/resin-io/etcher/pull/1261
Depends: https://github.com/resin-io/etcher/pull/1264

* remove angular injection from tests

* move file

* add empty array test
2017-06-05 10:30:58 -04:00
Benedict Aas
dcb152aa00 fix(GUI): don't break up size number in drive selector (#1467)
We make the size number in the drive selector stay whole through
the `word-break: keep-all` CSS property, ensuring that it doesn't
partially overflow to the next line.

See: https://github.com/resin-io/etcher/issues/1437
Changelog-Entry: Don't break up size numbers in the drive selector.
2017-05-26 07:36:32 -04:00
Juan Cruz Viotti
1e169315fd refactor(GUI): turn the update notifier modal into a native dialog (#1359)
Electron v1.6.1 introduced checkbox support to the native message
dialog, giving us everything that was needed to implement the update
notifier modal using a native dialog.

This change allows us to get rid of a lot code.

See: https://github.com/electron/electron/pull/8590
Change-Type: patch
Changelog-Entry: Turn the update notifier modal into a native dialog.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-05-23 19:06:35 -04:00
Benedict Aas
2c26b4c6ac feat(GUI): dynamic finish page (#1368)
* feat(GUI): dynamic finish page

We implement an externally loaded dynamic finish page in React with
`react2angular`. If the Internet connection is unreliable or unavailable, or a
non-200 HTTP response is returned we display a fallback default finish banner.

Change-Type: minor
Changelog-Entry: Implement a dynamic finish page.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-05-12 01:07:24 -04:00
Benedict Aas
69a982bf8d refactor(GUI): remove analytics angular dependency (#1387)
We rename `AnalyticsService` to `analytics` and remove its dependency on
Angular.
2017-05-10 20:27:54 -04:00
Benedict Aas
b6aa5ada30 refactor(GUI): central error/warning messages function (#1193)
* Centralise drive error/warning messages with a function
  `.getDriveImageCompatibilityStatuses` in `lib/shared/drive-constraints.js`
  -- tests included
* Fix an error where several labels show at once
* Clarify the source drive label to 'Drive Contains Image'
* Remove label icons and make text bold to match Zeplin's design

Closes: https://github.com/resin-io/etcher/issues/1143
Closes: https://github.com/resin-io/etcher/issues/1144
2017-05-10 13:52:20 -04:00
Juan Cruz Viotti
d3b35742a6 refactor(GUI): integrate etcher-latest-version into the main repo (#1183)
`etcher-latest-version` was kept in a separate repository in order to
re-use it with the Etcher website, however the Etcher website is not
using it at all, and we're moving towards having the website in the main
repository.

Therefore, this commit brings back the logic from
`etcher-latest-version`, but introduces it as
`lib/shared/s3-packages.js`, in order to not tie ourselves to the
AngularJS framework, and as a step towards the Etcher SDK.

As a nice little bonus, this commit adds support for an
`ETCHER_FAKE_S3_LATEST_VERSION` environment variable that can be used to
trick Etcher that there is an available update, and therefore show the
update notifier modal.

Also, this commit adds support for snapshot builds update-checks, by
checking the `resin-nightly-downloads` S3 bucket if the current version
contains a git commit hash build number.

If the version is not a production release, then the update notifier
modal doesn't present the checkbox to disable update notifications for X
days.

We also add a property called `updates.semverRange` to `package.json`,
which can be used to fine control which versions are considered as
candidates for an update notification.

This commit adds a setting called `includeUnstableChannel`, which can be
used to tweak whether unstable (beta) releases are considered or not
when checking for the latest available version.

See: https://github.com/resin-io-modules/etcher-latest-version
Fixes: https://github.com/resin-io/etcher/issues/953
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-04-26 23:52:04 -04:00
Benedict Aas
b28c345ba0 refactor(GUI): remove Angular from FlashStateModel and rename (#1264)
We remove the usage of Angular from 'FlashStateModel' and its usage
throughout the project comes under the new 'flashState' moniker.


Depends: https://github.com/resin-io/etcher/pull/1261
2017-04-10 14:30:21 -04:00
Benedict Aas
19dd2834fb fix(GUI): replace Math object usage in progressButton directive (#1263)
We were using `Math.min` in a progressButton's template expression,
however such object is not exposed to the Angular expression context.
2017-04-10 09:59:13 -04:00
Benedict Aas
ff495a45a8 refactor(GUI): remove angular from SettingsModel and rename (#1261)
We remove the usage of Angular in SettingsModel in our efforts to make
Etcher as agnostic as possible as we make our move to React.
2017-04-07 10:45:43 -04:00
Benedict Aas
63901ccf77 fix(GUI): limit button progress and width to 100 (#1256)
We limit the progress button width by limiting the progress to a maximum
value of 100.

Change-Type: patch
Changelog-Entry: Prevent progress button percentage to exceed 100%.
2017-04-05 12:00:59 -04:00
Juan Cruz Viotti
e16234e3e8 refactor(GUI): get rid of drive-constraints Angular factory wrapper (#1250)
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-04-04 13:44:03 -04:00
Andrew Scheller
ee2bbef9da chore: codespell improvements (#1174)
* fix the command so it actually works - see https://github.com/lucasdemarchi/codespell/issues/101
 * check the spelling of more files
 * ignore known-binary filetypes
 * fix a couple of spelling mistakes it caught

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-11 18:10:54 -04:00
Ștefan Daniel Mihăilă
34c85eb150 feat(GUI): improve analytics events (#1111)
* feat(GUI): improve analytics events

This commit adds more events to our current analytics.
Will further improve in a future commit.

Change-Type: patch
See: https://github.com/resin-io/etcher/issues/1100

* refactor(gui): use single function to set normal and dangerous settings

Change-Type: patch
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-10 15:18:49 -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
Benedict Aas
33a4ed8c95 feat(GUI): allow opening drive selector modal when no drives (#1146)
We change the drive selector button text to be a static 'select drive'
and allow the user to open the dialog even if there are no drives,
displaying the 'no drives' warning inside the modal.

Closes: https://github.com/resin-io/etcher/issues/884
Changelog-Entry: Allow opening the drive selector modal when there are no
drives.
2017-03-01 10:27:26 -04:00
Ștefan Daniel Mihăilă
5b9104e8aa feat(GUI): warn when atempting to burn Windows images (#1043)
Change-Type: minor
Changelog-Entry: Show warning when user tries to flash a Windows image
Closes: https://github.com/resin-io/etcher/issues/1035
2017-02-24 15:12:03 -04:00
Juan Cruz Viotti
f4c92676a9 fix(GUI): update notifier transformRequest error at startup (#1122)
Etcher checks what is the latest version by making an HTTP request to S3
in order to see if it should present the update notifier modal at
startup.

If the user is not connected to the internet, or is on an unstable
connection, the request might fail completely or timeout, leading to a
weird error message being presented to the user:

```json
{
  "data": null,
  "status": -1,
  "config": {
    "method": "GET",
    "transformRequest": [null],
    "transformResponse": [null],
    "url": "https://resin-production-downloads.s3.amazonaws.com",
    "headers": {
      "Accept": "application/json, text/plain, */*"
    }
  },
  "statusText": ""
}
```

To solve the error, we tweak `UpdateNotifierService.getLatestVersion()`
to resolve the current version if there was a problem making the request
(e.g: the response didn't come through at all), which after some
experimentation, we can check by comparing the `status` property with
`-1`.

This error happens in all operating systems, and currently is trending
on TrackJS.

Change-Type: patch
Changelog-Entry: Fix `transformRequest` error at startup when not connected to the internet, or when on an unstable connection.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-02-23 11:20:10 -04:00
Juan Cruz Viotti
cf4dc5ff37 refactor(GUI): remove component-drive-selector-body outdated class (#1072)
The rules inside this class should be moved to
`.modal-drive-selector-modal`.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-02-13 14:59:29 -04:00
Juan Cruz Viotti
6bdba5ffd4 style(GUI): move update notifier checkbox inside modal body (#1071)
This is a small step towards unifying all the modal skeletons that we
use through the application.

By moving the checkbox to the modal body we can declare the footer and
the header once in a single place.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-02-09 11:30:19 -04:00
Juan Cruz Viotti
05fdd5cc29 refactor(GUI): unify modal body styles (#1073)
- Remove unnecessary `.modal-text` wrapper
- Move drive selector specific styles to `_drive-selector.scss`

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-02-07 16:14:15 -04:00
Shou
048aac5ac2 feat(gui): update main page design
We match the main page design to its updated style.

* Remove help icon text.
* 'Change' image/drive buttons are now violet blue.
* Remove step number icons and accompanying descriptions.
* Flash progress button now turns into a striking orange, from blue.

Changelog-Entry: Update main page design to its new style.
2017-02-07 12:21:45 -04:00
Juan Cruz Viotti
8e5840ce69 chore: integrate codespell and fix existing spelling issues
This tool scans the comments of every source file and reports back
spelling errors.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-02-06 14:53:20 -04:00
Juan Cruz Viotti
95d4f2f608 fix(GUI): prevent flashing the drive where the source image is located
Currently Etcher will allow you to flash an image to the same drive that
contains the image. As a way to protect against that case we introduce
the concept of a "source drive", which means a drive that contains the
source image.

This commit adds the following logic around this new concept:

- Don't auto-select a source drive
- De-select an already selected drive if an image inside it is selected
- Disable the drive in the drive selector modal
- Add a "Source Drive" badge to the drive in the drive selector modal

Fixes: https://github.com/resin-io/etcher/issues/830
Change-Type: minor
Changelog-Entry: Prevent flashing the drive where the source image is located.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-02-06 14:53:08 -04:00
Juan Cruz Viotti
4f621f6ae3 style(GUI): capitalize every text for consitency purposes (#1056)
Fixes: https://github.com/resin-io/etcher/issues/881
Change-Type: patch
Changelog-Entry: Capitalize every text throughout the application.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-01-27 11:08:49 -04:00
Juan Cruz Viotti
9dd9065305 refactor(GUI): reuse WarningModalService in FlashErrorModal (#1051)
This is the first commit in a series of changes to normalise the use of
modals throughout the application.

`FlashStateModel` is basically a `WarningModalService` that cleans the
flash state, therefore making it re-use `WarningModalService` directly
removes unnecessary duplication.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-01-25 17:06:49 -04:00
Juan Cruz Viotti
4649bace00 style(GUI): change WarningModal title to "Attention" (#1052)
See: https://github.com/resin-io/etcher/pull/1043
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-01-25 17:06:16 -04:00
Juan Cruz Viotti
7165c60f0d fix(GUI): normalize button text casing (#1046)
Some button texts are all uppercase, while the remaining of them are
capitalised. This commit capitalises all button texts for consistency
purposes.

Fixes: https://github.com/resin-io/etcher/issues/881
Change-Type: patch
Changelog-Entry: Normalize button text casing.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-01-25 10:57:47 -04:00
Juan Cruz Viotti
e5a52c9377 fix(GUI): improve validation error message (#1047)
The current validation message is obscure and tends to lead users to
believe there is a problem with Etcher.

Fixes: https://github.com/resin-io/etcher/issues/735
Change-Type: patch
Changelog-Entry: Improve validation error message.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-01-25 10:32:07 -04:00
Juan Cruz Viotti
543cfea1b4 fix(GUI): expand button in modal menu if its the only one (#1023)
The `.modal-menu` class holds buttons that are shown at the bottom of
the modal. If there are two buttons, the class will show them side by
side with equal sizes, however if there is only one button, it will be
incorrectly resized to 50% of the available space.

Change-Type: patch
Changelog-Entry: Fix alignment of single call to action buttons inside modals.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-01-13 17:37:35 -04:00
Juan Cruz Viotti
c552494480 refactor: extract application messages to lib/shared/messages.js (#1022)
There are certain application messages that should be re-used between
the CLI and the GUI. In order to allow such re-usability, we extract out
the application messages used in JavaScript into
`lib/shared/messages.js` as a collection of Lodash `_.template`
templates.

Notice this file doesn't include application messages included in
Angular templates directly since it'd be hard to refactor all of them.
We plan to move to React soon, which will allow moving the remaining
messages very easily.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-01-13 11:03:46 -04:00
Ștefan Daniel Mihăilă
050d187e6f refactor: extract SelectionStateModel stateless functions (#982)
`SelectionStateModel`'s methods `isSystemDrive` and `isDriveLocked`
don't depend on application state. They have been extracted in a different
AngularJS service: `DriveConstraintsModel`. The new service's actual
implementation is in `lib/src`, in order to be reused by the CLI.

Miscellaneous changes:

- Rename `lib/src` to `lib/shared`
- Refactor `drive-constraints` to throw when image is undefined

The default behaviour was to pretend that we're all good if the if
the image is not specified. We're not using this "feature", and
it can be dangerous if we forget to pass in the image.

- Make `isSystemDrive` return `false` if `system` property is undefined
- Use `drive-constraints` in `store.js`

Change-Type: patch
2017-01-06 12:42:11 -04:00
Benedict Aas
de6ad80038 feat(gui): add referers to etcher.io links (#990)
We add referers to the two etcher.io links in the interface—one for the
update link, and one for the footer logo link.

Closes: https://github.com/resin-io/etcher/issues/987
2016-12-30 00:43:31 -04:00
Benedict Aas
d7e1fe09fc feat(gui): label system drives in drive-list widget (#978)
System drives in the drive-list widget now have a red warning label
beneath. Also new is the `isSystemDrive()` method under
`SelectionStateModel` and its unit-tests.

See: https://github.com/resin-io/etcher/issues/888
Changelog-Entry: Label system drives in the drive-list widget
2016-12-16 10:41:04 -04:00
Benedict Aas
cce9ce25d7 feat(gui): show available version in update notifier modal (#928)
We show the Etcher version string in the update notifier modal, by giving
the version string to the template through options similar to the warning
modal.

- We memoize the version Promise and assume the update version won't change
  during runtime.

Changelog-Entry: Show available Etcher version in the update notifier.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2016-12-06 11:33:52 -04:00
Benedict Aas
e24c2b6466 feat(GUI): confirm before quitting etcher while writing (#868)
When Etcher is writing to a drive and the user closes the window,
currently there is no confirmation. This commit changes that and
the user has to confirm the exit.

Other changes include the warning modal taking a `rejectionLabel` option
that shows a reject button when provided.

Closes: https://github.com/resin-io/etcher/issues/744
Change-Type: minor
Changelog-Entry: Confirm before user quits while writing.
2016-12-05 10:56:38 -04:00
Benedict Aas
ae6b707bb4 feat(gui): add changelog link to update notifier (#920)
We add a blue clickable link to the Github changelog in the update dialog
modal.

Closes: https://github.com/resin-io/etcher/issues/905
Change-Type: patch
Changelog-Entry: Add a changelog link to the update notifier modal.
2016-12-05 10:55:33 -04:00
Benedict Aas
cfeb35b531 feat(GUI): allow double-click to quick-select drives (#889)
The user can now double-click to swiftly select a drive in the
drive widget instead of having to toggle a drive and then clicking the
continue button to close the modal and finalize the drive selection.

Closes: https://github.com/resin-io/etcher/issues/880
Change-Type: patch
Changelog-Entry: Implement double-click to quick-select drives in the
drive widget.
2016-11-30 11:11:11 -04:00
Benedict Aas
ccd2076a20 fix(GUI): show not-allowed cursor over unselectable drives (#886)
The cursor is incorrectly a pointer on hover over a disabled and
unselectable drive in the drive selector widget. This patch changes the
cursor to `not-allowed`, providing the user with visual feedback that it is
not selectable.

Fixes: https://github.com/resin-io/etcher/issues/865
Change-Type: patch
Changelog-Entry: Use not-allowed cursor over disabled drives in the
drive selector widget.
2016-11-30 11:06:41 -04:00
Benedict Aas
18799d4274 fix(GUI): wrap long words in drivelist (#882)
Drives with long names or descriptions expand outside the drivelist,
this commit fixes that using CSS `word-break: break-all`.

Change-Type: patch
Changelog-Entry: Wrap drive names and descriptions in the drive selector widget.
2016-11-18 17:28:10 +00:00
Juan Cruz Viotti
ca4d05ced0 refactor(GUI): resolve undefined on modal keyboard bindings (#879)
Currently we resolve `false`, which might not mean very much to some
modal use cases. `undefined` is a much more generic falsy value.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2016-11-18 15:23:10 +00:00
Benedict Aas
e85906d50d fix(GUI): pressing escape cancels modal dialogue (#878)
Pressing the ESC key in any modal dialogue currently just emits a
message. This change actually cancels the modal, closing it.

Closes: https://github.com/resin-io/etcher/issues/874
Change-Type: patch
Changelog-Entry: Allow the user to press ESC to cancel a modal dialog.
2016-11-18 12:55:30 +00:00
Juan Cruz Viotti
5a48395d6d style(GUI): unify "close" top right corner X in all modals (#841)
Every modal in the application should contain the same "close" X at the
top right corner, for consistency purposes. The only modal lacking this
button was the update notifier modal.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2016-11-07 17:56:03 +02:00