mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 21:28:11 +09:00 
			
		
		
		
	Improve "generate new access token" form (#33730)
Fix: https://github.com/go-gitea/gitea/issues/33519 As discussed in [PR #33614](https://github.com/go-gitea/gitea/pull/33614), the ScopedAccessTokenSelector Vue component is not particularly useful. This PR removes the component and reverts to using HTML templates. It also introduces some (hopefully) useful refactoring. The Vue component was causing the UX bug reported in the linked issue. Required form fields are now properly working, as expected (see screenshot).  --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
		| @@ -4,10 +4,8 @@ | ||||
| package forms | ||||
|  | ||||
| import ( | ||||
| 	"strconv" | ||||
| 	"testing" | ||||
|  | ||||
| 	auth_model "code.gitea.io/gitea/models/auth" | ||||
| 	"code.gitea.io/gitea/modules/setting" | ||||
|  | ||||
| 	"github.com/gobwas/glob" | ||||
| @@ -104,28 +102,3 @@ func TestRegisterForm_IsDomainAllowed_BlockedEmail(t *testing.T) { | ||||
| 		assert.Equal(t, v.valid, form.IsEmailDomainAllowed()) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestNewAccessTokenForm_GetScope(t *testing.T) { | ||||
| 	tests := []struct { | ||||
| 		form        NewAccessTokenForm | ||||
| 		scope       auth_model.AccessTokenScope | ||||
| 		expectedErr error | ||||
| 	}{ | ||||
| 		{ | ||||
| 			form:  NewAccessTokenForm{Name: "test", Scope: []string{"read:repository"}}, | ||||
| 			scope: "read:repository", | ||||
| 		}, | ||||
| 		{ | ||||
| 			form:  NewAccessTokenForm{Name: "test", Scope: []string{"read:repository", "write:user"}}, | ||||
| 			scope: "read:repository,write:user", | ||||
| 		}, | ||||
| 	} | ||||
|  | ||||
| 	for i, test := range tests { | ||||
| 		t.Run(strconv.Itoa(i), func(t *testing.T) { | ||||
| 			scope, err := test.form.GetScope() | ||||
| 			assert.Equal(t, test.expectedErr, err) | ||||
| 			assert.Equal(t, test.scope, scope) | ||||
| 		}) | ||||
| 	} | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user