Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Button to reset configuration #141

Closed
wants to merge 10 commits into from
Closed

Button to reset configuration #141

wants to merge 10 commits into from

Conversation

ericcornelissen
Copy link

@ericcornelissen ericcornelissen commented Jul 24, 2018

Adds a new button to the main menu that can be used to reset the configuration of SVGO. As requested in #101 (and simple-icons/#771).

Design considerations

  • There is currently no "Are you sure" popup when clicking the reset configuration button, might be an idea to add it (added with dfb7392)
  • The button is currently in the mainMenuUI, could also be placed in the settingsUI. I'm fine either way 😄

Clarification of the code

  • main-controller.js:277 was added because the reset button calls _compressSvg, but may be called when no SVG has been selected yet.
  • I'm emitting an event in main-menu.js:97 mainly because I couldn't think of a better approach

Tested on Desktop

  • Chrome
  • Firefox
  • Safari
  • IE/Edge

Tested on Mobile

  • Chrome
  • Firefox

By simply removing 'settings' key from the indexedDB 'keyval' 
ObjectStore.

As requested in #101
Moved the `storage.delete` statement to the main-controller so the 
settingsUI can be updated easily. The main-controller is informed about 
a reset by the `'reset-config'` event from the mainMenuUI component.
This allows for backwards compatability (and other wierd cases where the 
default configuration is missing). People who used the app before this 
change will not have a `default-config` entry in their indexedDB, 
courtesy of main-controller.js:224-233
When no default configuration was found, create a new toast using the 
toastUI rather then using the standard `alert()`. The toast also allows 
for easy implementation of a reload option in the notification.
@jakearchibald
Copy link
Owner

Ohh thanks! Will take a look.

@jakearchibald
Copy link
Owner

There is currently no "Are you sure" popup when clicking the reset configuration button, might be an idea to add it

I think the best way to do this is via a toast (https://github.com/jakearchibald/svgomg/blob/master/src/js/page/main-controller.js#L158) which says "Options reset" but has "Undo" & "Dismiss" buttons. I'll take a look at that.

@ericcornelissen
Copy link
Author

I think the best way to do this is via a toast (https://github.com/jakearchibald/svgomg/blob/master/src/js/page/main-controller.js#L158) which says "Options reset" but has "Undo" & "Dismiss" buttons. I'll take a look at that.

I've already used a toast, so I'm comfortable adding it for you 😄

Adds an "Undo" option to the existing toast if no default configuration 
was found, and a new toast with an "Undo" and "Dismiss" button if an 
existin default configuration *was* found.
Naive implementation to restore the config before resetting the 
configuration
By reusing _saveSettings in the _resetConfig method, slightly altering 
it to work as expected, as _resetConfig sets/saves the configuration on 
three seperate occasions.

_saveSetting now also sets the config in the settings UI and compresses 
the SVG.
@jakearchibald
Copy link
Owner

I'm going to have a hack around with this. I think the setting is currently in the wrong place – it should sit with the settings it resets. There might be a better way to encapsulate the behaviour too. I'll have a play and get you to review if that's ok?

@ericcornelissen
Copy link
Author

ericcornelissen commented Aug 7, 2018

Of course it is, have a go at it 😄

@jakearchibald
Copy link
Owner

#142 - how's this?

@ericcornelissen
Copy link
Author

#142 - how's this?

Looks good 👍

@jakearchibald
Copy link
Owner

Done in #142. Thanks @ericcornelissen for helping with the design!

@ericcornelissen
Copy link
Author

Np, glad it is added now 🎉

@ericcornelissen ericcornelissen deleted the reset-configuration branch August 7, 2018 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants