Skip to content

Commit 1e1e8b5

Browse files
silverwindGiteaBot
andauthored
Fix OAuth loading state (#24788)
Fix regression from #24740 where the loading state was not showing because the `oauth-login-image` class was removed. Replaced the Fomantic loader with a pure CSS loader and cleaned up the HTML. Diff: https://github.com/go-gitea/gitea/pull/24788/files?diff=unified&w=1 ![](https://github.com/go-gitea/gitea/assets/115237/b5b4137f-9821-464b-9777-858fe85d9e03) Co-authored-by: Giteabot <[email protected]>
1 parent 09ab64d commit 1e1e8b5

File tree

3 files changed

+45
-45
lines changed

3 files changed

+45
-45
lines changed

templates/user/auth/signin_inner.tmpl

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -54,33 +54,30 @@
5454

5555
{{if and .OrderedOAuth2Names .OAuth2Providers}}
5656
<hr class="ui divider"/>
57-
<div class="oauth2 center">
58-
<div id="oauth2-login-loader" class="ui disabled centered loader"></div>
59-
<div>
60-
<div id="oauth2-login-navigator" class="gt-df gt-jc">
61-
<span class="gt-self-center gt-mr-3">{{.locale.Tr "sign_in_with"}}</span>
62-
<div class="gt-df gt-fw gt-gap-4">
63-
{{range $key := .OrderedOAuth2Names}}
64-
{{$provider := index $.OAuth2Providers $key}}
65-
<a class="{{$provider.Name}} silenced oauth-login-link" href="{{AppSubUrl}}/user/oauth2/{{$key}}" data-tooltip-content="{{$provider.DisplayName}}{{if eq $provider.Name "openidConnect"}} ({{$key}}){{end}}">
66-
{{if eq $provider.Name "github"}}
67-
{{svg "octicon-mark-github" 40}}
68-
{{else if eq $provider.Name "gitlab"}}
69-
{{svg "gitea-gitlab" 40}}
70-
{{else if eq $provider.Name "openidConnect"}}
71-
{{svg "gitea-openid" 40}}
72-
{{else}}
73-
<img
74-
class="gt-object-contain"
75-
width="40"
76-
height="40"
77-
alt="{{$provider.DisplayName}}{{if eq $provider.Name "openidConnect"}} ({{$key}}){{end}}"
78-
src="{{AppSubUrl}}{{$provider.Image}}"
79-
>
80-
{{end}}
81-
</a>
82-
{{end}}
83-
</div>
57+
<div id="oauth2-login-navigator">
58+
<div id="oauth2-login-navigator-inner" class="gt-df gt-jc">
59+
<span class="gt-self-center gt-mr-3">{{.locale.Tr "sign_in_with"}}</span>
60+
<div class="gt-df gt-fw gt-gap-4">
61+
{{range $key := .OrderedOAuth2Names}}
62+
{{$provider := index $.OAuth2Providers $key}}
63+
<a class="{{$provider.Name}} silenced oauth-login-link" href="{{AppSubUrl}}/user/oauth2/{{$key}}" data-tooltip-content="{{$provider.DisplayName}}{{if eq $provider.Name "openidConnect"}} ({{$key}}){{end}}">
64+
{{if eq $provider.Name "github"}}
65+
{{svg "octicon-mark-github" 40}}
66+
{{else if eq $provider.Name "gitlab"}}
67+
{{svg "gitea-gitlab" 40}}
68+
{{else if eq $provider.Name "openidConnect"}}
69+
{{svg "gitea-openid" 40}}
70+
{{else}}
71+
<img
72+
class="gt-object-contain"
73+
width="40"
74+
height="40"
75+
alt="{{$provider.DisplayName}}{{if eq $provider.Name "openidConnect"}} ({{$key}}){{end}}"
76+
src="{{AppSubUrl}}{{$provider.Image}}"
77+
>
78+
{{end}}
79+
</a>
80+
{{end}}
8481
</div>
8582
</div>
8683
</div>

web_src/css/modules/animations.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ code.language-math.is-loading::after {
4646
height: 1.25rem;
4747
}
4848

49+
#oauth2-login-navigator.is-loading::after {
50+
width: 40px;
51+
height: 40px;
52+
}
53+
4954
@keyframes fadein {
5055
0% {
5156
opacity: 0;

web_src/js/features/user-auth.js

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
import $ from 'jquery';
2-
import {hideElem, showElem} from '../utils/dom.js';
32

43
export function initUserAuthOauth2() {
5-
const $oauth2LoginNav = $('#oauth2-login-navigator');
6-
if ($oauth2LoginNav.length === 0) return;
7-
8-
$oauth2LoginNav.find('.oauth-login-image').on('click', () => {
9-
const oauthLoader = $('#oauth2-login-loader');
10-
const oauthNav = $('#oauth2-login-navigator');
11-
12-
hideElem(oauthNav);
13-
oauthLoader.removeClass('disabled');
14-
15-
setTimeout(() => {
16-
// recover previous content to let user try again
17-
// usually redirection will be performed before this action
18-
oauthLoader.addClass('disabled');
19-
showElem(oauthNav);
20-
}, 5000);
21-
});
4+
const outer = document.getElementById('oauth2-login-navigator');
5+
if (!outer) return;
6+
const inner = document.getElementById('oauth2-login-navigator-inner');
7+
8+
for (const link of outer.querySelectorAll('.oauth-login-link')) {
9+
link.addEventListener('click', () => {
10+
inner.classList.add('gt-invisible');
11+
outer.classList.add('is-loading');
12+
setTimeout(() => {
13+
// recover previous content to let user try again
14+
// usually redirection will be performed before this action
15+
outer.classList.remove('is-loading');
16+
inner.classList.remove('gt-invisible');
17+
}, 5000);
18+
});
19+
}
2220
}
2321

2422
export function initUserAuthLinkAccountView() {

0 commit comments

Comments
 (0)