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

DEV: Convert login modal to component-based API #23093

Merged
merged 18 commits into from Sep 5, 2023
Merged

Conversation

janzenisaac
Copy link
Contributor

@janzenisaac janzenisaac commented Aug 14, 2023

Desktop

Before
Screenshot 2023-08-17 at 1 32 02 PM
After
Screenshot 2023-08-17 at 1 34 13 PM

Mobile

Before
Screenshot 2023-08-17 at 1 28 20 PM
After
Screenshot 2023-08-17 at 1 28 33 PM

Changes Made

  • I took the liberty to hide the password Show / Hide toggle when no password present.
Before
Screenshot 2023-08-15 at 4 46 16 PM Screenshot 2023-08-15 at 4 43 03 PM Screenshot 2023-08-15 at 4 42 58 PM
After
Screenshot 2023-08-15 at 4 45 47 PM Screenshot 2023-08-15 at 4 45 50 PM Screenshot 2023-08-15 at 4 45 39 PM

@flashTypeChanged={{this.flashTypeChanged}}
@securityKeyCredentialChanged={{this.securityKeyCredentialChanged}}
/>
<Modal::Login::Footer
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not ideal to render the <div class="modal-footer"> within the body of the modal, but I am limited in what I can do with the current design of the login modal. I don't think we are necessarily limited by the current structure of the modal (body / footer) we are limited by the structure of the css / html implemented to make it look the way it does.

This would be worth raising with designers once these changes are through

@janzenisaac janzenisaac added the js-modernization Tasks related to our JS modernization project, including the Ember 4.0+ upgrade label Aug 15, 2023
Comment on lines 284 to 288
// I don't think this lives in the right place, this feels like it should live in some kind of auth service / controller
// and then be called in routes/application.js
// we render the login modal but then immediately redirect to the external auth service
// I think we can skip the login modal and just redirect to the external auth service
@action
async externalLogin(loginMethod, { signup = false } = {}) {
if (this.loginDisabled) {
return;
}

try {
this.loggingIn = true;
await loginMethod.doLogin({ signup });
this.args.closeModal();
} catch {
this.loggingIn = false;
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this lives in the right place, this feels like it should live in some kind of auth service / controller and then be called in routes/application.js. We render the login modal but then immediately redirect to the external auth service 🤔 . I think we can skip the login modal and just redirect to the external auth service...

Maybe a refactor for a different PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block of tests is reliant on the legacy login modal, so it has completely fell apart. I know it feels bad to remove an entire test file but in my mind we are left with only two options:

  1. Spend time rewriting these tests to either
  • rely on one of the few remaining legacy modals
  • use some generic legacy modal controller (🤷)

so that we can have a safety net on our new modal API for a bit longer.

  1. Rip off the bandaid and save some time by deleting the tests

By deleting the file, you can see I am obviously in favor of option 2. We are a couple weeks away from deleting them either way, and I feel like we have lived with the new modal API changes long enough we can now safely delete. What do you think @davidtaylorhq

Comment on lines +42 to +50
constructor() {
super(...arguments);
if (this.args.model?.isExternalLogin) {
this.externalLogin(this.args.model.externalLoginMethod, {
signup: this.args.model.signup,
});
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once this PR lands I would love to come back in and refactor this block. We render the Login modal in multiple places to then immediately redirect to an external auth service. I would like to skip the intermediate LoginModal step.

@janzenisaac janzenisaac marked this pull request as ready for review August 17, 2023 17:17
Copy link
Contributor

@pmusaraj pmusaraj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good from a quick look, just a few minor comments.

@discoursebot
Copy link

This pull request has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/oauth2-custom-redirects-plugin/94323/2

@@ -52,27 +54,6 @@ export default Controller.extend(
return (hasAuthOptions || canCreateLocal) && !skipConfirmation;
},

resetForm() {
// We wrap the fields in a structure so we can assign a value
this.setProperties({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come we're making this change in the create-account modal? This one is still a legacy controller, so I would've thought that we still need the manual reset?

@janzenisaac janzenisaac merged commit bb2d1f8 into main Sep 5, 2023
13 checks passed
@janzenisaac janzenisaac deleted the upgrade-login-modal branch September 5, 2023 17:01
janzenisaac added a commit that referenced this pull request Sep 6, 2023
This PR relies upon #23093

- move login modal tests to `..../modal/login/....`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
js-modernization Tasks related to our JS modernization project, including the Ember 4.0+ upgrade
4 participants