Skip to content

Conversation

@humitos
Copy link
Member

@humitos humitos commented Jul 2, 2025

This is just a demo of what we can do and/or how to use the last_login_method template variable. This needs more discussion and work, but opening as a draft to have something to talk over.

Email

Screenshot_2025-07-02_17-33-48

GitHub App

Screenshot_2025-07-02_17-34-33

Requires: readthedocs/readthedocs.org#12286
Closes #421

humitos added 2 commits July 2, 2025 17:32
This is just a demo of what we can do and/or how to use the `last_login_method`
template variable.

Closes #421
@agjohnson
Copy link
Contributor

agjohnson commented Jul 9, 2025

One concern I have about using a label and putting the label inside the menu item is that this menu already has space constraints, especially business accessing private versions:

image

With an added label it's going to be very tight and might wrap the menu or menu items.

I was going to use a tooltip for the menu and buttons:

image

<button class="ui  button" type="submit" title="GitLab" data-tooltip="Last used" data-variation="teal visible" data-position="right center">

I think even the menu labeled options could be rethought here though. We should probably just default to the correct tab, no? Do we need a label on this menu?

This is something you'd do at the template level, no JS should be required. We talked in #421 about passing some value to the templates so the templates could render the elements.

@humitos
Copy link
Member Author

humitos commented Jul 10, 2025

I was going to use a tooltip for the menu and buttons:

Tooltips work for me 👍🏼

I think even the menu labeled options could be rethought here though. We should probably just default to the correct tab, no? Do we need a label on this menu?

I'm already doing this in https://github.com/readthedocs/ext-theme/pull/622/files#r2194496182. Do you refer to something different here?

@agjohnson
Copy link
Contributor

Do you refer to something different here?

Yes, specifically "do we need to put a label on the menu"? If we're defaulting is it necessary?

@humitos
Copy link
Member Author

humitos commented Jul 14, 2025

OK, this is moving in a good direction 👍🏼 . I only need to attach the buttons to a specific callback to set the cookie, but all the other login to handle the variables in the template are in place:

VCS - GitHub App

Peek.2025-07-14.14-48.webm

VCS - GitLab

Screenshot_2025-07-14_14-51-38

Email

Screenshot_2025-07-14_14-52-50

SSO

Screenshot_2025-07-14_14-54-05

@humitos
Copy link
Member Author

humitos commented Jul 14, 2025

Yes, specifically "do we need to put a label on the menu"? If we're defaulting is it necessary?

Only for email, since there is no other indicator otherwise.

@humitos humitos marked this pull request as ready for review July 14, 2025 15:21
@humitos humitos requested a review from a team as a code owner July 14, 2025 15:21
@humitos humitos requested a review from agjohnson July 14, 2025 15:21
@humitos
Copy link
Member Author

humitos commented Jul 14, 2025

I had to run the development server at localhost for the cookieStore to work. I used this diff:

diff --git a/dockerfiles/nginx/default.conf.template b/dockerfiles/nginx/default.conf.template
new file mode 100644
index 00000000..e69de29b
diff --git a/dockerfiles/nginx/web.conf.template b/dockerfiles/nginx/web.conf.template
index 9badfd39..69659d14 100644
--- a/dockerfiles/nginx/web.conf.template
+++ b/dockerfiles/nginx/web.conf.template
@@ -1,6 +1,6 @@
 server {
-    listen 80;
-    server_name $NGINX_WEB_SERVER_NAME;
+    listen 80 default_server;
+    server_name $NGINX_WEB_SERVER_NAME localhost;
 
     location /static/ {
         proxy_pass http://storage:9000/static/;
@@ -9,10 +9,10 @@ server {
 
     location / {
         proxy_pass http://web:8000/;
-        proxy_set_header Host $http_host;
+        proxy_set_header Host devthedocs.com;
+        proxy_set_header X-Forwarded-Host devthedocs.com;
         proxy_set_header X-Real-IP $remote_addr;
         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
-        proxy_set_header X-Forwarded-Host $host;
 
         add_header X-Served Django always;
     }
@@ -30,6 +30,4 @@ server {
 
         add_header X-Served Nginx-Proxito-Sendfile always;
     }
-
-
 }
diff --git a/dockerfiles/nginx/wrangler.conf.template b/dockerfiles/nginx/wrangler.conf.template
index b99d1fae..82a6fa12 100644
--- a/dockerfiles/nginx/wrangler.conf.template
+++ b/dockerfiles/nginx/wrangler.conf.template
@@ -1,6 +1,6 @@
 # Proxito
 server {
-    listen 80 default_server;
+    listen 80;
     server_name $NGINX_PROXITO_SERVER_NAME;
 
     # Docker Compose's "logging.driver: none" is not working anymore.

@humitos
Copy link
Member Author

humitos commented Jul 29, 2025

@agjohnson can you take a look at this and do a final review here?

@humitos
Copy link
Member Author

humitos commented Oct 6, 2025

@agjohnson this is ready for review -- can you take a look?

<div class="right menu">
<button class="ui primary button" type="submit">{% trans "Log in" %}</button>
<button class="ui primary button"
data-bind="click: $root.save_login_method"
Copy link
Contributor

Choose a reason for hiding this comment

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

You shouldn't use $root here, this method should be in a dedicated view class. $root is currently only used for some utility methods that are shared across many views.

<a href="{% url "saml_resolve_login" %}{% if redirect_field_value %}?{{ redirect_field_name }}={{ redirect_field_value }}{% endif %}">

<button class="ui button"
data-bind="click: $root.save_login_method"
Copy link
Contributor

Choose a reason for hiding this comment

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

Another mention of $root, should be a method in a view class.

action="{% provider_login_url provider.id process=process scope=scope auth_params=auth_params %}">
{% csrf_token %}

{# djlint: off #}
Copy link
Contributor

Choose a reason for hiding this comment

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

You should use something less generic than off. If there is a rule you're trying to avoid, limit it to that rule.


{# djlint: off #}
<button class="ui {{ button_classes }} button"
data-bind="click: $root.save_login_method"
Copy link
Contributor

Choose a reason for hiding this comment

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

Another $root

variation.pop("visible");
button.dataset.variation = variation.join(" ");
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

You should always use KO view code to manipulate the DOM. Using JS queries or jQuery to manipulate the DOM in addition is mixing patterns and should be always avoided.

I'm a bit confused what this is trying to do though. What is the intention here? It also seems like this would affect all modals, which we don't want.

cookieStore.set("last-login-method", elem.dataset.provider);
}
return true;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be implemented on a dedicated view class, not on the main application view. The main application view is strictly a router to these dedicated views and a couple utility methods.

You should look at any of the other templates that use a model view and work from those templates, they all follow the same pattern with a dedicated view class for each view.

* .. code:: html
*
* <form method="post" action="...">
* <button data-bind="click: $root.save_login_method">
Copy link
Contributor

Choose a reason for hiding this comment

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

Also $root here.

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.

Login: show "Last used" small icon when showing all the options to login

2 participants