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

Fixed "Are you sure" modal shown after toggling private mode- #9472 #964

Merged
merged 7 commits into from Mar 9, 2018

Conversation

@hey24sheep
Copy link
Contributor

commented Mar 5, 2018

Fixed "Are you sure" modal shown after toggling private mode

Closes #9472

  • sets default value of password
  • when private mode is toggled back to initial state
hey24sheep added 3 commits Mar 4, 2018
Closes #9476
- added midgrey to uploader.css upload fail
Closes #9472
- sets default value of password
- when private mode is toggled back to initial state
hey24sheep added 2 commits Mar 5, 2018
Closes #9472
- sets default value of password
- when private mode is toggled back to initial state
@hey24sheep

This comment has been minimized.

Copy link
Contributor Author

commented Mar 7, 2018

@kevinansfield @kirrg001 Kindly have a look and let me know if there is anything for me to do. Thank You.

@@ -109,6 +111,8 @@ export default Controller.extend({
// set a new random password when isPrivate is enabled
if (isPrivate && this.get('settings.hasDirtyAttributes')) {
this.get('settings').set('password', randomPassword());
} else {
this.get('settings').set('password', this._initialPasswordVal);

This comment has been minimized.

Copy link
@kevinansfield

kevinansfield Mar 9, 2018

Collaborator

Rather than storing the initial value on the controller and requiring a change on the route (which shouldn't really be involved in this) we can instead use Ember Data's change tracking to reset the value and keep all the logic in one place:

services/settings.js

    changedAttributes() {
        return this.get('content').changedAttributes();
    },

controllers/settings/general.js

        toggleIsPrivate(isPrivate) {
            let settings = this.get('settings');

            settings.set('isPrivate', isPrivate);
            settings.get('errors').remove('password');

            let changedAttrs = settings.changedAttributes();

            // set a new random password when isPrivate is enabled
            if (isPrivate && changedAttrs.isPrivate) {
                settings.set('password', randomPassword());

            // reset the password when isPrivate is disabled
            } else if (changedAttrs.password) {
                settings.set('password', changedAttrs.password[0]);
            }
        },
@coveralls

This comment has been minimized.

Copy link

commented Mar 9, 2018

Coverage Status

Coverage decreased (-0.01%) to 71.895% when pulling 8b7171a on hey24sheep:master into a947c03 on TryGhost:master.

Closes #9472
- changes according to pr #964 comment
- using Ember Data's change tracking to reset the value
@hey24sheep

This comment has been minimized.

Copy link
Contributor Author

commented Mar 9, 2018

Hi @kevinansfield,
I have pushed the requested changes, have a look. Let me know if there is anything else. Thanks.

@kevinansfield kevinansfield merged commit 09fe424 into TryGhost:master Mar 9, 2018
1 of 2 checks passed
1 of 2 checks passed
coverage/coveralls Coverage decreased (-0.01%) to 71.895%
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.