mirror of https://github.com/go-gitea/gitea.git
Merge branch 'main' into lunny/remove_num_watches
This commit is contained in:
commit
9b1e52445e
|
@ -642,7 +642,7 @@ rules:
|
||||||
no-this-before-super: [2]
|
no-this-before-super: [2]
|
||||||
no-throw-literal: [2]
|
no-throw-literal: [2]
|
||||||
no-undef-init: [2]
|
no-undef-init: [2]
|
||||||
no-undef: [2, {typeof: true}]
|
no-undef: [2, {typeof: true}] # TODO: disable this rule after tsc passes
|
||||||
no-undefined: [0]
|
no-undefined: [0]
|
||||||
no-underscore-dangle: [0]
|
no-underscore-dangle: [0]
|
||||||
no-unexpected-multiline: [2]
|
no-unexpected-multiline: [2]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
-
|
-
|
||||||
id: 1
|
id: 1
|
||||||
setting_key: 'picture.disable_gravatar'
|
setting_key: 'picture.disable_gravatar'
|
||||||
setting_value: 'false'
|
setting_value: 'true'
|
||||||
version: 1
|
version: 1
|
||||||
created: 1653533198
|
created: 1653533198
|
||||||
updated: 1653533198
|
updated: 1653533198
|
||||||
|
|
|
@ -23,9 +23,9 @@
|
||||||
allow_import_local: false
|
allow_import_local: false
|
||||||
allow_create_organization: true
|
allow_create_organization: true
|
||||||
prohibit_login: false
|
prohibit_login: false
|
||||||
avatar: avatar1
|
avatar: ""
|
||||||
avatar_email: user1@example.com
|
avatar_email: user1@example.com
|
||||||
use_custom_avatar: false
|
use_custom_avatar: true
|
||||||
num_followers: 0
|
num_followers: 0
|
||||||
num_following: 0
|
num_following: 0
|
||||||
num_stars: 0
|
num_stars: 0
|
||||||
|
@ -60,8 +60,9 @@
|
||||||
allow_import_local: false
|
allow_import_local: false
|
||||||
allow_create_organization: true
|
allow_create_organization: true
|
||||||
prohibit_login: false
|
prohibit_login: false
|
||||||
avatar: avatar2
|
avatar: ""
|
||||||
avatar_email: user2@example.com
|
avatar_email: user2@example.com
|
||||||
|
# cause a random avatar to be generated when referenced for test purposes
|
||||||
use_custom_avatar: false
|
use_custom_avatar: false
|
||||||
num_followers: 2
|
num_followers: 2
|
||||||
num_following: 1
|
num_following: 1
|
||||||
|
@ -97,9 +98,9 @@
|
||||||
allow_import_local: false
|
allow_import_local: false
|
||||||
allow_create_organization: true
|
allow_create_organization: true
|
||||||
prohibit_login: false
|
prohibit_login: false
|
||||||
avatar: avatar3
|
avatar: ""
|
||||||
avatar_email: org3@example.com
|
avatar_email: org3@example.com
|
||||||
use_custom_avatar: false
|
use_custom_avatar: true
|
||||||
num_followers: 0
|
num_followers: 0
|
||||||
num_following: 0
|
num_following: 0
|
||||||
num_stars: 0
|
num_stars: 0
|
||||||
|
@ -134,9 +135,9 @@
|
||||||
allow_import_local: false
|
allow_import_local: false
|
||||||
allow_create_organization: true
|
allow_create_organization: true
|
||||||
prohibit_login: false
|
prohibit_login: false
|
||||||
avatar: avatar4
|
avatar: ""
|
||||||
avatar_email: user4@example.com
|
avatar_email: user4@example.com
|
||||||
use_custom_avatar: false
|
use_custom_avatar: true
|
||||||
num_followers: 0
|
num_followers: 0
|
||||||
num_following: 1
|
num_following: 1
|
||||||
num_stars: 0
|
num_stars: 0
|
||||||
|
@ -171,9 +172,9 @@
|
||||||
allow_import_local: false
|
allow_import_local: false
|
||||||
allow_create_organization: false
|
allow_create_organization: false
|
||||||
prohibit_login: false
|
prohibit_login: false
|
||||||
avatar: avatar5
|
avatar: ""
|
||||||
avatar_email: user5@example.com
|
avatar_email: user5@example.com
|
||||||
use_custom_avatar: false
|
use_custom_avatar: true
|
||||||
num_followers: 0
|
num_followers: 0
|
||||||
num_following: 0
|
num_following: 0
|
||||||
num_stars: 0
|
num_stars: 0
|
||||||
|
@ -208,9 +209,9 @@
|
||||||
allow_import_local: false
|
allow_import_local: false
|
||||||
allow_create_organization: true
|
allow_create_organization: true
|
||||||
prohibit_login: false
|
prohibit_login: false
|
||||||
avatar: avatar6
|
avatar: ""
|
||||||
avatar_email: org6@example.com
|
avatar_email: org6@example.com
|
||||||
use_custom_avatar: false
|
use_custom_avatar: true
|
||||||
num_followers: 0
|
num_followers: 0
|
||||||
num_following: 0
|
num_following: 0
|
||||||
num_stars: 0
|
num_stars: 0
|
||||||
|
@ -245,9 +246,9 @@
|
||||||
allow_import_local: false
|
allow_import_local: false
|
||||||
allow_create_organization: true
|
allow_create_organization: true
|
||||||
prohibit_login: false
|
prohibit_login: false
|
||||||
avatar: avatar7
|
avatar: ""
|
||||||
avatar_email: org7@example.com
|
avatar_email: org7@example.com
|
||||||
use_custom_avatar: false
|
use_custom_avatar: true
|
||||||
num_followers: 0
|
num_followers: 0
|
||||||
num_following: 0
|
num_following: 0
|
||||||
num_stars: 0
|
num_stars: 0
|
||||||
|
@ -282,9 +283,9 @@
|
||||||
allow_import_local: false
|
allow_import_local: false
|
||||||
allow_create_organization: true
|
allow_create_organization: true
|
||||||
prohibit_login: false
|
prohibit_login: false
|
||||||
avatar: avatar8
|
avatar: ""
|
||||||
avatar_email: user8@example.com
|
avatar_email: user8@example.com
|
||||||
use_custom_avatar: false
|
use_custom_avatar: true
|
||||||
num_followers: 1
|
num_followers: 1
|
||||||
num_following: 1
|
num_following: 1
|
||||||
num_stars: 0
|
num_stars: 0
|
||||||
|
@ -319,9 +320,9 @@
|
||||||
allow_import_local: false
|
allow_import_local: false
|
||||||
allow_create_organization: true
|
allow_create_organization: true
|
||||||
prohibit_login: false
|
prohibit_login: false
|
||||||
avatar: avatar9
|
avatar: ""
|
||||||
avatar_email: user9@example.com
|
avatar_email: user9@example.com
|
||||||
use_custom_avatar: false
|
use_custom_avatar: true
|
||||||
num_followers: 0
|
num_followers: 0
|
||||||
num_following: 0
|
num_following: 0
|
||||||
num_stars: 0
|
num_stars: 0
|
||||||
|
@ -332,6 +333,7 @@
|
||||||
repo_admin_change_team_access: false
|
repo_admin_change_team_access: false
|
||||||
theme: ""
|
theme: ""
|
||||||
keep_activity_private: false
|
keep_activity_private: false
|
||||||
|
created_unix: 1730468968
|
||||||
|
|
||||||
-
|
-
|
||||||
id: 10
|
id: 10
|
||||||
|
@ -356,9 +358,9 @@
|
||||||
allow_import_local: false
|
allow_import_local: false
|
||||||
allow_create_organization: true
|
allow_create_organization: true
|
||||||
prohibit_login: false
|
prohibit_login: false
|
||||||
avatar: avatar10
|
avatar: ""
|
||||||
avatar_email: user10@example.com
|
avatar_email: user10@example.com
|
||||||
use_custom_avatar: false
|
use_custom_avatar: true
|
||||||
num_followers: 0
|
num_followers: 0
|
||||||
num_following: 0
|
num_following: 0
|
||||||
num_stars: 2
|
num_stars: 2
|
||||||
|
@ -393,9 +395,9 @@
|
||||||
allow_import_local: false
|
allow_import_local: false
|
||||||
allow_create_organization: true
|
allow_create_organization: true
|
||||||
prohibit_login: false
|
prohibit_login: false
|
||||||
avatar: avatar11
|
avatar: ""
|
||||||
avatar_email: user11@example.com
|
avatar_email: user11@example.com
|
||||||
use_custom_avatar: false
|
use_custom_avatar: true
|
||||||
num_followers: 0
|
num_followers: 0
|
||||||
num_following: 0
|
num_following: 0
|
||||||
num_stars: 0
|
num_stars: 0
|
||||||
|
@ -430,9 +432,9 @@
|
||||||
allow_import_local: false
|
allow_import_local: false
|
||||||
allow_create_organization: true
|
allow_create_organization: true
|
||||||
prohibit_login: false
|
prohibit_login: false
|
||||||
avatar: avatar12
|
avatar: ""
|
||||||
avatar_email: user12@example.com
|
avatar_email: user12@example.com
|
||||||
use_custom_avatar: false
|
use_custom_avatar: true
|
||||||
num_followers: 0
|
num_followers: 0
|
||||||
num_following: 0
|
num_following: 0
|
||||||
num_stars: 0
|
num_stars: 0
|
||||||
|
@ -467,9 +469,9 @@
|
||||||
allow_import_local: false
|
allow_import_local: false
|
||||||
allow_create_organization: true
|
allow_create_organization: true
|
||||||
prohibit_login: false
|
prohibit_login: false
|
||||||
avatar: avatar13
|
avatar: ""
|
||||||
avatar_email: user13@example.com
|
avatar_email: user13@example.com
|
||||||
use_custom_avatar: false
|
use_custom_avatar: true
|
||||||
num_followers: 0
|
num_followers: 0
|
||||||
num_following: 0
|
num_following: 0
|
||||||
num_stars: 0
|
num_stars: 0
|
||||||
|
@ -504,9 +506,9 @@
|
||||||
allow_import_local: false
|
allow_import_local: false
|
||||||
allow_create_organization: true
|
allow_create_organization: true
|
||||||
prohibit_login: false
|
prohibit_login: false
|
||||||
avatar: avatar14
|
avatar: ""
|
||||||
avatar_email: user13@example.com
|
avatar_email: user13@example.com
|
||||||
use_custom_avatar: false
|
use_custom_avatar: true
|
||||||
num_followers: 0
|
num_followers: 0
|
||||||
num_following: 0
|
num_following: 0
|
||||||
num_stars: 0
|
num_stars: 0
|
||||||
|
@ -541,9 +543,9 @@
|
||||||
allow_import_local: false
|
allow_import_local: false
|
||||||
allow_create_organization: true
|
allow_create_organization: true
|
||||||
prohibit_login: false
|
prohibit_login: false
|
||||||
avatar: avatar15
|
avatar: ""
|
||||||
avatar_email: user15@example.com
|
avatar_email: user15@example.com
|
||||||
use_custom_avatar: false
|
use_custom_avatar: true
|
||||||
num_followers: 0
|
num_followers: 0
|
||||||
num_following: 0
|
num_following: 0
|
||||||
num_stars: 0
|
num_stars: 0
|
||||||
|
@ -578,9 +580,9 @@
|
||||||
allow_import_local: false
|
allow_import_local: false
|
||||||
allow_create_organization: true
|
allow_create_organization: true
|
||||||
prohibit_login: false
|
prohibit_login: false
|
||||||
avatar: avatar16
|
avatar: ""
|
||||||
avatar_email: user16@example.com
|
avatar_email: user16@example.com
|
||||||
use_custom_avatar: false
|
use_custom_avatar: true
|
||||||
num_followers: 0
|
num_followers: 0
|
||||||
num_following: 0
|
num_following: 0
|
||||||
num_stars: 0
|
num_stars: 0
|
||||||
|
@ -615,9 +617,9 @@
|
||||||
allow_import_local: false
|
allow_import_local: false
|
||||||
allow_create_organization: true
|
allow_create_organization: true
|
||||||
prohibit_login: false
|
prohibit_login: false
|
||||||
avatar: avatar17
|
avatar: ""
|
||||||
avatar_email: org17@example.com
|
avatar_email: org17@example.com
|
||||||
use_custom_avatar: false
|
use_custom_avatar: true
|
||||||
num_followers: 0
|
num_followers: 0
|
||||||
num_following: 0
|
num_following: 0
|
||||||
num_stars: 0
|
num_stars: 0
|
||||||
|
@ -652,9 +654,9 @@
|
||||||
allow_import_local: false
|
allow_import_local: false
|
||||||
allow_create_organization: true
|
allow_create_organization: true
|
||||||
prohibit_login: false
|
prohibit_login: false
|
||||||
avatar: avatar18
|
avatar: ""
|
||||||
avatar_email: user18@example.com
|
avatar_email: user18@example.com
|
||||||
use_custom_avatar: false
|
use_custom_avatar: true
|
||||||
num_followers: 0
|
num_followers: 0
|
||||||
num_following: 0
|
num_following: 0
|
||||||
num_stars: 0
|
num_stars: 0
|
||||||
|
@ -689,9 +691,9 @@
|
||||||
allow_import_local: false
|
allow_import_local: false
|
||||||
allow_create_organization: true
|
allow_create_organization: true
|
||||||
prohibit_login: false
|
prohibit_login: false
|
||||||
avatar: avatar19
|
avatar: ""
|
||||||
avatar_email: org19@example.com
|
avatar_email: org19@example.com
|
||||||
use_custom_avatar: false
|
use_custom_avatar: true
|
||||||
num_followers: 0
|
num_followers: 0
|
||||||
num_following: 0
|
num_following: 0
|
||||||
num_stars: 0
|
num_stars: 0
|
||||||
|
@ -726,9 +728,9 @@
|
||||||
allow_import_local: false
|
allow_import_local: false
|
||||||
allow_create_organization: true
|
allow_create_organization: true
|
||||||
prohibit_login: false
|
prohibit_login: false
|
||||||
avatar: avatar20
|
avatar: ""
|
||||||
avatar_email: user20@example.com
|
avatar_email: user20@example.com
|
||||||
use_custom_avatar: false
|
use_custom_avatar: true
|
||||||
num_followers: 0
|
num_followers: 0
|
||||||
num_following: 0
|
num_following: 0
|
||||||
num_stars: 0
|
num_stars: 0
|
||||||
|
@ -763,9 +765,9 @@
|
||||||
allow_import_local: false
|
allow_import_local: false
|
||||||
allow_create_organization: true
|
allow_create_organization: true
|
||||||
prohibit_login: false
|
prohibit_login: false
|
||||||
avatar: avatar21
|
avatar: ""
|
||||||
avatar_email: user21@example.com
|
avatar_email: user21@example.com
|
||||||
use_custom_avatar: false
|
use_custom_avatar: true
|
||||||
num_followers: 0
|
num_followers: 0
|
||||||
num_following: 0
|
num_following: 0
|
||||||
num_stars: 0
|
num_stars: 0
|
||||||
|
@ -800,9 +802,9 @@
|
||||||
allow_import_local: false
|
allow_import_local: false
|
||||||
allow_create_organization: true
|
allow_create_organization: true
|
||||||
prohibit_login: false
|
prohibit_login: false
|
||||||
avatar: avatar22
|
avatar: ""
|
||||||
avatar_email: limited_org@example.com
|
avatar_email: limited_org@example.com
|
||||||
use_custom_avatar: false
|
use_custom_avatar: true
|
||||||
num_followers: 0
|
num_followers: 0
|
||||||
num_following: 0
|
num_following: 0
|
||||||
num_stars: 0
|
num_stars: 0
|
||||||
|
@ -837,9 +839,9 @@
|
||||||
allow_import_local: false
|
allow_import_local: false
|
||||||
allow_create_organization: true
|
allow_create_organization: true
|
||||||
prohibit_login: false
|
prohibit_login: false
|
||||||
avatar: avatar23
|
avatar: ""
|
||||||
avatar_email: privated_org@example.com
|
avatar_email: privated_org@example.com
|
||||||
use_custom_avatar: false
|
use_custom_avatar: true
|
||||||
num_followers: 0
|
num_followers: 0
|
||||||
num_following: 0
|
num_following: 0
|
||||||
num_stars: 0
|
num_stars: 0
|
||||||
|
@ -874,9 +876,9 @@
|
||||||
allow_import_local: false
|
allow_import_local: false
|
||||||
allow_create_organization: true
|
allow_create_organization: true
|
||||||
prohibit_login: false
|
prohibit_login: false
|
||||||
avatar: avatar24
|
avatar: ""
|
||||||
avatar_email: user24@example.com
|
avatar_email: user24@example.com
|
||||||
use_custom_avatar: false
|
use_custom_avatar: true
|
||||||
num_followers: 0
|
num_followers: 0
|
||||||
num_following: 0
|
num_following: 0
|
||||||
num_stars: 0
|
num_stars: 0
|
||||||
|
@ -911,9 +913,9 @@
|
||||||
allow_import_local: false
|
allow_import_local: false
|
||||||
allow_create_organization: true
|
allow_create_organization: true
|
||||||
prohibit_login: false
|
prohibit_login: false
|
||||||
avatar: avatar25
|
avatar: ""
|
||||||
avatar_email: org25@example.com
|
avatar_email: org25@example.com
|
||||||
use_custom_avatar: false
|
use_custom_avatar: true
|
||||||
num_followers: 0
|
num_followers: 0
|
||||||
num_following: 0
|
num_following: 0
|
||||||
num_stars: 0
|
num_stars: 0
|
||||||
|
@ -948,9 +950,9 @@
|
||||||
allow_import_local: false
|
allow_import_local: false
|
||||||
allow_create_organization: true
|
allow_create_organization: true
|
||||||
prohibit_login: false
|
prohibit_login: false
|
||||||
avatar: avatar26
|
avatar: ""
|
||||||
avatar_email: org26@example.com
|
avatar_email: org26@example.com
|
||||||
use_custom_avatar: false
|
use_custom_avatar: true
|
||||||
num_followers: 0
|
num_followers: 0
|
||||||
num_following: 0
|
num_following: 0
|
||||||
num_stars: 0
|
num_stars: 0
|
||||||
|
@ -985,9 +987,9 @@
|
||||||
allow_import_local: false
|
allow_import_local: false
|
||||||
allow_create_organization: true
|
allow_create_organization: true
|
||||||
prohibit_login: false
|
prohibit_login: false
|
||||||
avatar: avatar27
|
avatar: ""
|
||||||
avatar_email: user27@example.com
|
avatar_email: user27@example.com
|
||||||
use_custom_avatar: false
|
use_custom_avatar: true
|
||||||
num_followers: 0
|
num_followers: 0
|
||||||
num_following: 0
|
num_following: 0
|
||||||
num_stars: 0
|
num_stars: 0
|
||||||
|
@ -1022,9 +1024,9 @@
|
||||||
allow_import_local: false
|
allow_import_local: false
|
||||||
allow_create_organization: true
|
allow_create_organization: true
|
||||||
prohibit_login: false
|
prohibit_login: false
|
||||||
avatar: avatar28
|
avatar: ""
|
||||||
avatar_email: user28@example.com
|
avatar_email: user28@example.com
|
||||||
use_custom_avatar: false
|
use_custom_avatar: true
|
||||||
num_followers: 0
|
num_followers: 0
|
||||||
num_following: 0
|
num_following: 0
|
||||||
num_stars: 0
|
num_stars: 0
|
||||||
|
@ -1059,9 +1061,9 @@
|
||||||
allow_import_local: false
|
allow_import_local: false
|
||||||
allow_create_organization: true
|
allow_create_organization: true
|
||||||
prohibit_login: false
|
prohibit_login: false
|
||||||
avatar: avatar29
|
avatar: ""
|
||||||
avatar_email: user29@example.com
|
avatar_email: user29@example.com
|
||||||
use_custom_avatar: false
|
use_custom_avatar: true
|
||||||
num_followers: 0
|
num_followers: 0
|
||||||
num_following: 0
|
num_following: 0
|
||||||
num_stars: 0
|
num_stars: 0
|
||||||
|
@ -1096,9 +1098,9 @@
|
||||||
allow_import_local: false
|
allow_import_local: false
|
||||||
allow_create_organization: true
|
allow_create_organization: true
|
||||||
prohibit_login: false
|
prohibit_login: false
|
||||||
avatar: avatar29
|
avatar: ""
|
||||||
avatar_email: user30@example.com
|
avatar_email: user30@example.com
|
||||||
use_custom_avatar: false
|
use_custom_avatar: true
|
||||||
num_followers: 0
|
num_followers: 0
|
||||||
num_following: 0
|
num_following: 0
|
||||||
num_stars: 0
|
num_stars: 0
|
||||||
|
@ -1133,9 +1135,9 @@
|
||||||
allow_import_local: false
|
allow_import_local: false
|
||||||
allow_create_organization: true
|
allow_create_organization: true
|
||||||
prohibit_login: false
|
prohibit_login: false
|
||||||
avatar: avatar31
|
avatar: ""
|
||||||
avatar_email: user31@example.com
|
avatar_email: user31@example.com
|
||||||
use_custom_avatar: false
|
use_custom_avatar: true
|
||||||
num_followers: 0
|
num_followers: 0
|
||||||
num_following: 1
|
num_following: 1
|
||||||
num_stars: 0
|
num_stars: 0
|
||||||
|
@ -1170,9 +1172,9 @@
|
||||||
allow_import_local: false
|
allow_import_local: false
|
||||||
allow_create_organization: true
|
allow_create_organization: true
|
||||||
prohibit_login: false
|
prohibit_login: false
|
||||||
avatar: avatar32
|
avatar: ""
|
||||||
avatar_email: user30@example.com
|
avatar_email: user30@example.com
|
||||||
use_custom_avatar: false
|
use_custom_avatar: true
|
||||||
num_followers: 0
|
num_followers: 0
|
||||||
num_following: 0
|
num_following: 0
|
||||||
num_stars: 0
|
num_stars: 0
|
||||||
|
@ -1207,9 +1209,9 @@
|
||||||
allow_import_local: false
|
allow_import_local: false
|
||||||
allow_create_organization: true
|
allow_create_organization: true
|
||||||
prohibit_login: false
|
prohibit_login: false
|
||||||
avatar: avatar33
|
avatar: ""
|
||||||
avatar_email: user33@example.com
|
avatar_email: user33@example.com
|
||||||
use_custom_avatar: false
|
use_custom_avatar: true
|
||||||
num_followers: 1
|
num_followers: 1
|
||||||
num_following: 0
|
num_following: 0
|
||||||
num_stars: 0
|
num_stars: 0
|
||||||
|
@ -1245,7 +1247,7 @@
|
||||||
allow_import_local: false
|
allow_import_local: false
|
||||||
allow_create_organization: false
|
allow_create_organization: false
|
||||||
prohibit_login: false
|
prohibit_login: false
|
||||||
avatar: avatar34
|
avatar: ""
|
||||||
avatar_email: user34@example.com
|
avatar_email: user34@example.com
|
||||||
use_custom_avatar: true
|
use_custom_avatar: true
|
||||||
num_followers: 0
|
num_followers: 0
|
||||||
|
@ -1282,9 +1284,9 @@
|
||||||
allow_import_local: false
|
allow_import_local: false
|
||||||
allow_create_organization: true
|
allow_create_organization: true
|
||||||
prohibit_login: false
|
prohibit_login: false
|
||||||
avatar: avatar35
|
avatar: ""
|
||||||
avatar_email: private_org35@example.com
|
avatar_email: private_org35@example.com
|
||||||
use_custom_avatar: false
|
use_custom_avatar: true
|
||||||
num_followers: 0
|
num_followers: 0
|
||||||
num_following: 0
|
num_following: 0
|
||||||
num_stars: 0
|
num_stars: 0
|
||||||
|
@ -1319,9 +1321,9 @@
|
||||||
allow_import_local: false
|
allow_import_local: false
|
||||||
allow_create_organization: true
|
allow_create_organization: true
|
||||||
prohibit_login: false
|
prohibit_login: false
|
||||||
avatar: avatar22
|
avatar: ""
|
||||||
avatar_email: abcde@gitea.com
|
avatar_email: abcde@gitea.com
|
||||||
use_custom_avatar: false
|
use_custom_avatar: true
|
||||||
num_followers: 0
|
num_followers: 0
|
||||||
num_following: 0
|
num_following: 0
|
||||||
num_stars: 0
|
num_stars: 0
|
||||||
|
@ -1356,9 +1358,9 @@
|
||||||
allow_import_local: false
|
allow_import_local: false
|
||||||
allow_create_organization: true
|
allow_create_organization: true
|
||||||
prohibit_login: true
|
prohibit_login: true
|
||||||
avatar: avatar29
|
avatar: ""
|
||||||
avatar_email: user37@example.com
|
avatar_email: user37@example.com
|
||||||
use_custom_avatar: false
|
use_custom_avatar: true
|
||||||
num_followers: 0
|
num_followers: 0
|
||||||
num_following: 0
|
num_following: 0
|
||||||
num_stars: 0
|
num_stars: 0
|
||||||
|
@ -1393,9 +1395,9 @@
|
||||||
allow_import_local: false
|
allow_import_local: false
|
||||||
allow_create_organization: true
|
allow_create_organization: true
|
||||||
prohibit_login: false
|
prohibit_login: false
|
||||||
avatar: avatar38
|
avatar: ""
|
||||||
avatar_email: user38@example.com
|
avatar_email: user38@example.com
|
||||||
use_custom_avatar: false
|
use_custom_avatar: true
|
||||||
num_followers: 0
|
num_followers: 0
|
||||||
num_following: 0
|
num_following: 0
|
||||||
num_stars: 0
|
num_stars: 0
|
||||||
|
@ -1430,9 +1432,9 @@
|
||||||
allow_import_local: false
|
allow_import_local: false
|
||||||
allow_create_organization: true
|
allow_create_organization: true
|
||||||
prohibit_login: false
|
prohibit_login: false
|
||||||
avatar: avatar39
|
avatar: ""
|
||||||
avatar_email: user39@example.com
|
avatar_email: user39@example.com
|
||||||
use_custom_avatar: false
|
use_custom_avatar: true
|
||||||
num_followers: 0
|
num_followers: 0
|
||||||
num_following: 0
|
num_following: 0
|
||||||
num_stars: 0
|
num_stars: 0
|
||||||
|
@ -1467,9 +1469,9 @@
|
||||||
allow_import_local: false
|
allow_import_local: false
|
||||||
allow_create_organization: true
|
allow_create_organization: true
|
||||||
prohibit_login: false
|
prohibit_login: false
|
||||||
avatar: avatar40
|
avatar: ""
|
||||||
avatar_email: user40@example.com
|
avatar_email: user40@example.com
|
||||||
use_custom_avatar: false
|
use_custom_avatar: true
|
||||||
num_followers: 0
|
num_followers: 0
|
||||||
num_following: 0
|
num_following: 0
|
||||||
num_stars: 0
|
num_stars: 0
|
||||||
|
@ -1504,9 +1506,9 @@
|
||||||
allow_import_local: false
|
allow_import_local: false
|
||||||
allow_create_organization: true
|
allow_create_organization: true
|
||||||
prohibit_login: false
|
prohibit_login: false
|
||||||
avatar: avatar41
|
avatar: ""
|
||||||
avatar_email: org41@example.com
|
avatar_email: org41@example.com
|
||||||
use_custom_avatar: false
|
use_custom_avatar: true
|
||||||
num_followers: 0
|
num_followers: 0
|
||||||
num_following: 0
|
num_following: 0
|
||||||
num_stars: 0
|
num_stars: 0
|
||||||
|
@ -1541,9 +1543,9 @@
|
||||||
allow_import_local: false
|
allow_import_local: false
|
||||||
allow_create_organization: true
|
allow_create_organization: true
|
||||||
prohibit_login: false
|
prohibit_login: false
|
||||||
avatar: avatar42
|
avatar: ""
|
||||||
avatar_email: org42@example.com
|
avatar_email: org42@example.com
|
||||||
use_custom_avatar: false
|
use_custom_avatar: true
|
||||||
num_followers: 0
|
num_followers: 0
|
||||||
num_following: 0
|
num_following: 0
|
||||||
num_stars: 0
|
num_stars: 0
|
||||||
|
|
|
@ -48,19 +48,19 @@ const (
|
||||||
UserTypeIndividual UserType = iota // Historic reason to make it starts at 0.
|
UserTypeIndividual UserType = iota // Historic reason to make it starts at 0.
|
||||||
|
|
||||||
// UserTypeOrganization defines an organization
|
// UserTypeOrganization defines an organization
|
||||||
UserTypeOrganization
|
UserTypeOrganization // 1
|
||||||
|
|
||||||
// UserTypeUserReserved reserves a (non-existing) user, i.e. to prevent a spam user from re-registering after being deleted, or to reserve the name until the user is actually created later on
|
// UserTypeUserReserved reserves a (non-existing) user, i.e. to prevent a spam user from re-registering after being deleted, or to reserve the name until the user is actually created later on
|
||||||
UserTypeUserReserved
|
UserTypeUserReserved // 2
|
||||||
|
|
||||||
// UserTypeOrganizationReserved reserves a (non-existing) organization, to be used in combination with UserTypeUserReserved
|
// UserTypeOrganizationReserved reserves a (non-existing) organization, to be used in combination with UserTypeUserReserved
|
||||||
UserTypeOrganizationReserved
|
UserTypeOrganizationReserved // 3
|
||||||
|
|
||||||
// UserTypeBot defines a bot user
|
// UserTypeBot defines a bot user
|
||||||
UserTypeBot
|
UserTypeBot // 4
|
||||||
|
|
||||||
// UserTypeRemoteUser defines a remote user for federated users
|
// UserTypeRemoteUser defines a remote user for federated users
|
||||||
UserTypeRemoteUser
|
UserTypeRemoteUser // 5
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -884,7 +884,13 @@ func UpdateUserCols(ctx context.Context, u *User, cols ...string) error {
|
||||||
|
|
||||||
// GetInactiveUsers gets all inactive users
|
// GetInactiveUsers gets all inactive users
|
||||||
func GetInactiveUsers(ctx context.Context, olderThan time.Duration) ([]*User, error) {
|
func GetInactiveUsers(ctx context.Context, olderThan time.Duration) ([]*User, error) {
|
||||||
var cond builder.Cond = builder.Eq{"is_active": false}
|
cond := builder.And(
|
||||||
|
builder.Eq{"is_active": false},
|
||||||
|
builder.Or( // only plain user
|
||||||
|
builder.Eq{"`type`": UserTypeIndividual},
|
||||||
|
builder.Eq{"`type`": UserTypeUserReserved},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
if olderThan > 0 {
|
if olderThan > 0 {
|
||||||
cond = cond.And(builder.Lt{"created_unix": time.Now().Add(-olderThan).Unix()})
|
cond = cond.And(builder.Lt{"created_unix": time.Now().Add(-olderThan).Unix()})
|
||||||
|
|
|
@ -588,3 +588,17 @@ func TestDisabledUserFeatures(t *testing.T) {
|
||||||
assert.True(t, user_model.IsFeatureDisabledWithLoginType(user, f))
|
assert.True(t, user_model.IsFeatureDisabledWithLoginType(user, f))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestGetInactiveUsers(t *testing.T) {
|
||||||
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||||
|
|
||||||
|
// all inactive users
|
||||||
|
// user1's createdunix is 1730468968
|
||||||
|
users, err := user_model.GetInactiveUsers(db.DefaultContext, 0)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Len(t, users, 1)
|
||||||
|
interval := time.Now().Unix() - 1730468968 + 3600*24
|
||||||
|
users, err = user_model.GetInactiveUsers(db.DefaultContext, time.Duration(interval*int64(time.Second)))
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Len(t, users, 0)
|
||||||
|
}
|
||||||
|
|
|
@ -4,8 +4,6 @@
|
||||||
package repository
|
package repository
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/md5"
|
|
||||||
"fmt"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
@ -125,15 +123,12 @@ func TestPushCommits_AvatarLink(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
setting.GravatarSource = "https://secure.gravatar.com/avatar"
|
|
||||||
setting.OfflineMode = true
|
|
||||||
|
|
||||||
assert.Equal(t,
|
assert.Equal(t,
|
||||||
"/avatars/avatar2?size="+strconv.Itoa(28*setting.Avatar.RenderedSizeFactor),
|
"/avatars/ab53a2911ddf9b4817ac01ddcd3d975f?size="+strconv.Itoa(28*setting.Avatar.RenderedSizeFactor),
|
||||||
pushCommits.AvatarLink(db.DefaultContext, "user2@example.com"))
|
pushCommits.AvatarLink(db.DefaultContext, "user2@example.com"))
|
||||||
|
|
||||||
assert.Equal(t,
|
assert.Equal(t,
|
||||||
fmt.Sprintf("https://secure.gravatar.com/avatar/%x?d=identicon&s=%d", md5.Sum([]byte("nonexistent@example.com")), 28*setting.Avatar.RenderedSizeFactor),
|
"/assets/img/avatar_default.png",
|
||||||
pushCommits.AvatarLink(db.DefaultContext, "nonexistent@example.com"))
|
pushCommits.AvatarLink(db.DefaultContext, "nonexistent@example.com"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -104,6 +104,7 @@ copy_url = Copy URL
|
||||||
copy_hash = Copy hash
|
copy_hash = Copy hash
|
||||||
copy_content = Copy content
|
copy_content = Copy content
|
||||||
copy_branch = Copy branch name
|
copy_branch = Copy branch name
|
||||||
|
copy_path = Copy path
|
||||||
copy_success = Copied!
|
copy_success = Copied!
|
||||||
copy_error = Copy failed
|
copy_error = Copy failed
|
||||||
copy_type_unsupported = This file type cannot be copied
|
copy_type_unsupported = This file type cannot be copied
|
||||||
|
@ -352,7 +353,7 @@ enable_update_checker = Enable Update Checker
|
||||||
enable_update_checker_helper = Checks for new version releases periodically by connecting to gitea.io.
|
enable_update_checker_helper = Checks for new version releases periodically by connecting to gitea.io.
|
||||||
env_config_keys = Environment Configuration
|
env_config_keys = Environment Configuration
|
||||||
env_config_keys_prompt = The following environment variables will also be applied to your configuration file:
|
env_config_keys_prompt = The following environment variables will also be applied to your configuration file:
|
||||||
config_write_file_prompt = These configuration options will be written into:
|
config_write_file_prompt = These configuration options will be written into: %s
|
||||||
|
|
||||||
[home]
|
[home]
|
||||||
nav_menu = Navigation Menu
|
nav_menu = Navigation Menu
|
||||||
|
|
|
@ -348,6 +348,7 @@ func PrepareViewPullInfo(ctx *context.Context, issue *issues_model.Issue) *git.C
|
||||||
}
|
}
|
||||||
|
|
||||||
if !baseGitRepo.IsBranchExist(pull.BaseBranch) {
|
if !baseGitRepo.IsBranchExist(pull.BaseBranch) {
|
||||||
|
ctx.Data["BaseBranchNotExist"] = true
|
||||||
ctx.Data["IsPullRequestBroken"] = true
|
ctx.Data["IsPullRequestBroken"] = true
|
||||||
ctx.Data["BaseTarget"] = pull.BaseBranch
|
ctx.Data["BaseTarget"] = pull.BaseBranch
|
||||||
ctx.Data["HeadTarget"] = pull.HeadBranch
|
ctx.Data["HeadTarget"] = pull.HeadBranch
|
||||||
|
|
|
@ -18,6 +18,7 @@ import (
|
||||||
|
|
||||||
func TestRepository_ContributorsGraph(t *testing.T) {
|
func TestRepository_ContributorsGraph(t *testing.T) {
|
||||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||||
|
|
||||||
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 2})
|
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 2})
|
||||||
assert.NoError(t, repo.LoadOwner(db.DefaultContext))
|
assert.NoError(t, repo.LoadOwner(db.DefaultContext))
|
||||||
mockCache, err := cache.NewStringCache(setting.Cache{})
|
mockCache, err := cache.NewStringCache(setting.Cache{})
|
||||||
|
@ -46,7 +47,7 @@ func TestRepository_ContributorsGraph(t *testing.T) {
|
||||||
|
|
||||||
assert.EqualValues(t, &ContributorData{
|
assert.EqualValues(t, &ContributorData{
|
||||||
Name: "Ethan Koenig",
|
Name: "Ethan Koenig",
|
||||||
AvatarLink: "https://secure.gravatar.com/avatar/b42fb195faa8c61b8d88abfefe30e9e3?d=identicon",
|
AvatarLink: "/assets/img/avatar_default.png",
|
||||||
TotalCommits: 1,
|
TotalCommits: 1,
|
||||||
Weeks: map[int64]*WeekData{
|
Weeks: map[int64]*WeekData{
|
||||||
1511654400000: {
|
1511654400000: {
|
||||||
|
|
|
@ -338,7 +338,9 @@
|
||||||
|
|
||||||
<div class="inline field">
|
<div class="inline field">
|
||||||
<div class="right-content">
|
<div class="right-content">
|
||||||
{{ctx.Locale.Tr "install.config_write_file_prompt"}} <span class="ui label">{{.CustomConfFile}}</span> <button class="btn interact-fg" data-clipboard-text="{{.CustomConfFile}}">{{svg "octicon-copy" 14}}</button>
|
{{$copyBtn := svg "octicon-copy" 14}}
|
||||||
|
{{$filePath := HTMLFormat `<span class="ui label">%s</span> <button class="btn interact-fg" data-clipboard-text="%s">%s</button>` .CustomConfFile .CustomConfFile $copyBtn}}
|
||||||
|
{{ctx.Locale.Tr "install.config_write_file_prompt" $filePath}}
|
||||||
</div>
|
</div>
|
||||||
<div class="tw-mt-4 tw-mb-2 tw-text-center">
|
<div class="tw-mt-4 tw-mb-2 tw-text-center">
|
||||||
<button class="ui primary button">{{ctx.Locale.Tr "install.install_btn_confirm"}}</button>
|
<button class="ui primary button">{{ctx.Locale.Tr "install.install_btn_confirm"}}</button>
|
||||||
|
|
|
@ -130,7 +130,7 @@
|
||||||
</div>
|
</div>
|
||||||
<span class="file tw-flex tw-items-center tw-font-mono tw-flex-1"><a class="muted file-link" title="{{if $file.IsRenamed}}{{$file.OldName}} → {{end}}{{$file.Name}}" href="#diff-{{$file.NameHash}}">{{if $file.IsRenamed}}{{$file.OldName}} → {{end}}{{$file.Name}}</a>
|
<span class="file tw-flex tw-items-center tw-font-mono tw-flex-1"><a class="muted file-link" title="{{if $file.IsRenamed}}{{$file.OldName}} → {{end}}{{$file.Name}}" href="#diff-{{$file.NameHash}}">{{if $file.IsRenamed}}{{$file.OldName}} → {{end}}{{$file.Name}}</a>
|
||||||
{{if .IsLFSFile}} ({{ctx.Locale.Tr "repo.stored_lfs"}}){{end}}
|
{{if .IsLFSFile}} ({{ctx.Locale.Tr "repo.stored_lfs"}}){{end}}
|
||||||
<button class="btn interact-fg tw-p-2" data-clipboard-text="{{$file.Name}}">{{svg "octicon-copy" 14}}</button>
|
<button class="btn interact-fg tw-p-2" data-clipboard-text="{{$file.Name}}" data-tooltip-content="{{ctx.Locale.Tr "copy_path"}}">{{svg "octicon-copy" 14}}</button>
|
||||||
{{if $file.IsGenerated}}
|
{{if $file.IsGenerated}}
|
||||||
<span class="ui label">{{ctx.Locale.Tr "repo.diff.generated"}}</span>
|
<span class="ui label">{{ctx.Locale.Tr "repo.diff.generated"}}</span>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
|
@ -106,6 +106,7 @@
|
||||||
<span class="breadcrumb-divider">/</span>
|
<span class="breadcrumb-divider">/</span>
|
||||||
{{- if eq $i $l -}}
|
{{- if eq $i $l -}}
|
||||||
<span class="active section" title="{{$v}}">{{$v}}</span>
|
<span class="active section" title="{{$v}}">{{$v}}</span>
|
||||||
|
<button class="btn interact-fg tw-mx-1" data-clipboard-text="{{$.TreePath}}" data-tooltip-content="{{ctx.Locale.Tr "copy_path"}}">{{svg "octicon-copy" 14}}</button>
|
||||||
{{- else -}}
|
{{- else -}}
|
||||||
{{$p := index $.Paths $i}}<span class="section"><a href="{{$.BranchLink}}/{{PathEscapeSegments $p}}" title="{{$v}}">{{$v}}</a></span>
|
{{$p := index $.Paths $i}}<span class="section"><a href="{{$.BranchLink}}/{{PathEscapeSegments $p}}" title="{{$v}}">{{$v}}</a></span>
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
|
@ -16,12 +16,14 @@
|
||||||
<input type="text" placeholder="{{ctx.Locale.Tr "repo.issues.filter_assignees"}}">
|
<input type="text" placeholder="{{ctx.Locale.Tr "repo.issues.filter_assignees"}}">
|
||||||
</div>
|
</div>
|
||||||
<div class="item clear-selection">{{ctx.Locale.Tr "repo.issues.new.clear_assignees"}}</div>
|
<div class="item clear-selection">{{ctx.Locale.Tr "repo.issues.new.clear_assignees"}}</div>
|
||||||
{{range $data.CandidateAssignees}}
|
<div class="scrolling menu">
|
||||||
<a class="item muted" href="#" data-value="{{.ID}}">
|
{{range $data.CandidateAssignees}}
|
||||||
<span class="item-check-mark">{{svg "octicon-check"}}</span>
|
<a class="item muted" href="#" data-value="{{.ID}}">
|
||||||
{{ctx.AvatarUtils.Avatar . 20}} {{template "repo/search_name" .}}
|
<span class="item-check-mark">{{svg "octicon-check"}}</span>
|
||||||
</a>
|
{{ctx.AvatarUtils.Avatar . 20}} {{template "repo/search_name" .}}
|
||||||
{{end}}
|
</a>
|
||||||
|
{{end}}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="ui list tw-flex tw-flex-row tw-gap-2">
|
<div class="ui list tw-flex tw-flex-row tw-gap-2">
|
||||||
|
|
|
@ -17,25 +17,27 @@
|
||||||
<input type="text" placeholder="{{ctx.Locale.Tr "repo.issues.filter_labels"}}">
|
<input type="text" placeholder="{{ctx.Locale.Tr "repo.issues.filter_labels"}}">
|
||||||
</div>
|
</div>
|
||||||
<a class="item clear-selection" href="#">{{ctx.Locale.Tr "repo.issues.new.clear_labels"}}</a>
|
<a class="item clear-selection" href="#">{{ctx.Locale.Tr "repo.issues.new.clear_labels"}}</a>
|
||||||
{{$previousExclusiveScope := "_no_scope"}}
|
<div class="scrolling menu">
|
||||||
{{range $data.RepoLabels}}
|
{{$previousExclusiveScope := "_no_scope"}}
|
||||||
{{$exclusiveScope := .ExclusiveScope}}
|
{{range $data.RepoLabels}}
|
||||||
{{if and (ne $previousExclusiveScope "_no_scope") (ne $previousExclusiveScope $exclusiveScope)}}
|
{{$exclusiveScope := .ExclusiveScope}}
|
||||||
<div class="divider"></div>
|
{{if and (ne $previousExclusiveScope "_no_scope") (ne $previousExclusiveScope $exclusiveScope)}}
|
||||||
|
<div class="divider"></div>
|
||||||
|
{{end}}
|
||||||
|
{{$previousExclusiveScope = $exclusiveScope}}
|
||||||
|
{{template "repo/issue/sidebar/label_list_item" dict "Label" .}}
|
||||||
{{end}}
|
{{end}}
|
||||||
{{$previousExclusiveScope = $exclusiveScope}}
|
{{if and $data.RepoLabels $data.OrgLabels}}<div class="divider"></div>{{end}}
|
||||||
{{template "repo/issue/sidebar/label_list_item" dict "Label" .}}
|
{{$previousExclusiveScope = "_no_scope"}}
|
||||||
{{end}}
|
{{range $data.OrgLabels}}
|
||||||
<div class="divider"></div>
|
{{$exclusiveScope := .ExclusiveScope}}
|
||||||
{{$previousExclusiveScope = "_no_scope"}}
|
{{if and (ne $previousExclusiveScope "_no_scope") (ne $previousExclusiveScope $exclusiveScope)}}
|
||||||
{{range $data.OrgLabels}}
|
<div class="divider"></div>
|
||||||
{{$exclusiveScope := .ExclusiveScope}}
|
{{end}}
|
||||||
{{if and (ne $previousExclusiveScope "_no_scope") (ne $previousExclusiveScope $exclusiveScope)}}
|
{{$previousExclusiveScope = $exclusiveScope}}
|
||||||
<div class="divider"></div>
|
{{template "repo/issue/sidebar/label_list_item" dict "Label" .}}
|
||||||
{{end}}
|
{{end}}
|
||||||
{{$previousExclusiveScope = $exclusiveScope}}
|
</div>
|
||||||
{{template "repo/issue/sidebar/label_list_item" dict "Label" .}}
|
|
||||||
{{end}}
|
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -20,25 +20,26 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="divider"></div>
|
<div class="divider"></div>
|
||||||
<div class="item clear-selection">{{ctx.Locale.Tr "repo.issues.new.clear_milestone"}}</div>
|
<div class="item clear-selection">{{ctx.Locale.Tr "repo.issues.new.clear_milestone"}}</div>
|
||||||
{{if $data.OpenMilestones}}
|
<div class="scrolling menu">
|
||||||
<div class="divider"></div>
|
{{if $data.OpenMilestones}}
|
||||||
<div class="header">{{ctx.Locale.Tr "repo.issues.new.open_milestone"}}</div>
|
<div class="header">{{ctx.Locale.Tr "repo.issues.new.open_milestone"}}</div>
|
||||||
{{range $data.OpenMilestones}}
|
{{range $data.OpenMilestones}}
|
||||||
<a class="item muted" data-value="{{.ID}}" href="{{$pageMeta.RepoLink}}/issues?milestone={{.ID}}">
|
<a class="item muted" data-value="{{.ID}}" href="{{$pageMeta.RepoLink}}/issues?milestone={{.ID}}">
|
||||||
{{svg "octicon-milestone" 18}} {{.Name}}
|
{{svg "octicon-milestone" 18}} {{.Name}}
|
||||||
</a>
|
</a>
|
||||||
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{if and $data.OpenMilestones $data.ClosedMilestones}}<div class="divider"></div>{{end}}
|
||||||
{{if $data.ClosedMilestones}}
|
{{if $data.ClosedMilestones}}
|
||||||
<div class="divider"></div>
|
<div class="header">{{ctx.Locale.Tr "repo.issues.new.closed_milestone"}}</div>
|
||||||
<div class="header">{{ctx.Locale.Tr "repo.issues.new.closed_milestone"}}</div>
|
{{range $data.ClosedMilestones}}
|
||||||
{{range $data.ClosedMilestones}}
|
<a class="item muted" data-value="{{.ID}}" href="{{$pageMeta.RepoLink}}/issues?milestone={{.ID}}">
|
||||||
<a class="item muted" data-value="{{.ID}}" href="{{$pageMeta.RepoLink}}/issues?milestone={{.ID}}">
|
{{svg "octicon-milestone" 18}} {{.Name}}
|
||||||
{{svg "octicon-milestone" 18}} {{.Name}}
|
</a>
|
||||||
</a>
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -18,24 +18,25 @@
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
<div class="item clear-selection">{{ctx.Locale.Tr "repo.issues.new.clear_projects"}}</div>
|
<div class="item clear-selection">{{ctx.Locale.Tr "repo.issues.new.clear_projects"}}</div>
|
||||||
{{if $data.OpenProjects}}
|
<div class="scrolling menu">
|
||||||
<div class="divider"></div>
|
{{if $data.OpenProjects}}
|
||||||
<div class="header">{{ctx.Locale.Tr "repo.issues.new.open_projects"}}</div>
|
<div class="header">{{ctx.Locale.Tr "repo.issues.new.open_projects"}}</div>
|
||||||
{{range $data.OpenProjects}}
|
{{range $data.OpenProjects}}
|
||||||
<a class="item muted" data-value="{{.ID}}" href="{{.Link ctx}}">
|
<a class="item muted" data-value="{{.ID}}" href="{{.Link ctx}}">
|
||||||
{{svg .IconName 18}} {{.Title}}
|
{{svg .IconName 18}} {{.Title}}
|
||||||
</a>
|
</a>
|
||||||
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{if and $data.OpenProjects $data.ClosedProjects}}<div class="divider"></div>{{end}}
|
||||||
{{if $data.ClosedProjects}}
|
{{if $data.ClosedProjects}}
|
||||||
<div class="divider"></div>
|
<div class="header">{{ctx.Locale.Tr "repo.issues.new.closed_projects"}}</div>
|
||||||
<div class="header">{{ctx.Locale.Tr "repo.issues.new.closed_projects"}}</div>
|
{{range $data.ClosedProjects}}
|
||||||
{{range $data.ClosedProjects}}
|
<a class="item muted" data-value="{{.ID}}" href="{{.Link ctx}}">
|
||||||
<a class="item muted" data-value="{{.ID}}" href="{{.Link ctx}}">
|
{{svg .IconName 18}} {{.Title}}
|
||||||
{{svg .IconName 18}} {{.Title}}
|
</a>
|
||||||
</a>
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="ui list">
|
<div class="ui list">
|
||||||
|
|
|
@ -17,27 +17,29 @@
|
||||||
<input type="text" placeholder="{{ctx.Locale.Tr "repo.issues.filter_reviewers"}}">
|
<input type="text" placeholder="{{ctx.Locale.Tr "repo.issues.filter_reviewers"}}">
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{range $data.Reviewers}}
|
<div class="scrolling menu flex-items-menu">
|
||||||
{{if .User}}
|
{{range $data.Reviewers}}
|
||||||
<a class="item muted {{if .Requested}}checked{{end}}" href="{{.User.HomeLink}}" data-value="{{.ItemID}}" data-can-change="{{.CanChange}}"
|
{{if .User}}
|
||||||
{{if not .CanChange}}data-tooltip-content="{{ctx.Locale.Tr "repo.issues.remove_request_review_block"}}"{{end}}>
|
<a class="item muted {{if .Requested}}checked{{end}}" href="{{.User.HomeLink}}" data-value="{{.ItemID}}" data-can-change="{{.CanChange}}"
|
||||||
<span class="item-check-mark">{{svg "octicon-check"}}</span>
|
{{if not .CanChange}}data-tooltip-content="{{ctx.Locale.Tr "repo.issues.remove_request_review_block"}}"{{end}}>
|
||||||
{{ctx.AvatarUtils.Avatar .User 20}} {{template "repo/search_name" .User}}
|
|
||||||
</a>
|
|
||||||
{{end}}
|
|
||||||
{{end}}
|
|
||||||
{{if $data.TeamReviewers}}
|
|
||||||
{{if $data.Reviewers}}<div class="divider"></div>{{end}}
|
|
||||||
{{range $data.TeamReviewers}}
|
|
||||||
{{if .Team}}
|
|
||||||
<a class="item muted {{if .Requested}}checked{{end}}" href="#" data-value="{{.ItemID}}" data-can-change="{{.CanChange}}"
|
|
||||||
{{if not .CanChange}} data-tooltip-content="{{ctx.Locale.Tr "repo.issues.remove_request_review_block"}}"{{end}}>
|
|
||||||
<span class="item-check-mark">{{svg "octicon-check"}}</span>
|
<span class="item-check-mark">{{svg "octicon-check"}}</span>
|
||||||
{{svg "octicon-people" 20}} {{$repoOwnerName}}/{{.Team.Name}}
|
{{ctx.AvatarUtils.Avatar .User 20}} {{template "repo/search_name" .User}}
|
||||||
</a>
|
</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{if $data.TeamReviewers}}
|
||||||
|
{{if $data.Reviewers}}<div class="divider"></div>{{end}}
|
||||||
|
{{range $data.TeamReviewers}}
|
||||||
|
{{if .Team}}
|
||||||
|
<a class="item muted {{if .Requested}}checked{{end}}" href="#" data-value="{{.ItemID}}" data-can-change="{{.CanChange}}"
|
||||||
|
{{if not .CanChange}} data-tooltip-content="{{ctx.Locale.Tr "repo.issues.remove_request_review_block"}}"{{end}}>
|
||||||
|
<span class="item-check-mark">{{svg "octicon-check"}}</span>
|
||||||
|
{{svg "octicon-people" 20}} {{$repoOwnerName}}/{{.Team.Name}}
|
||||||
|
</a>
|
||||||
|
{{end}}
|
||||||
|
{{end}}
|
||||||
|
{{end}}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -231,7 +231,8 @@
|
||||||
{{template "shared/user/avatarlink" dict "user" .Poster}}
|
{{template "shared/user/avatarlink" dict "user" .Poster}}
|
||||||
<span class="text grey muted-links">
|
<span class="text grey muted-links">
|
||||||
{{template "shared/user/authorlink" .Poster}}
|
{{template "shared/user/authorlink" .Poster}}
|
||||||
{{ctx.Locale.Tr "repo.issues.delete_branch_at" .OldRef $createdStr}}
|
{{$oldRef := HTMLFormat `<span class="tw-line-through">%s</span>` .OldRef}}
|
||||||
|
{{ctx.Locale.Tr "repo.issues.delete_branch_at" $oldRef $createdStr}}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
{{else if eq .Type 12}}
|
{{else if eq .Type 12}}
|
||||||
|
|
|
@ -61,12 +61,16 @@
|
||||||
{{if .Issue.PullRequest.IsAgitFlow}}
|
{{if .Issue.PullRequest.IsAgitFlow}}
|
||||||
{{$headHref = HTMLFormat `%s <a href="%s" target="_blank"><span class="ui label basic tiny" data-tooltip-content="%s">AGit</span></a>` $headHref "https://docs.gitea.com/usage/agit" (ctx.Locale.Tr "repo.pull.agit_documentation")}}
|
{{$headHref = HTMLFormat `%s <a href="%s" target="_blank"><span class="ui label basic tiny" data-tooltip-content="%s">AGit</span></a>` $headHref "https://docs.gitea.com/usage/agit" (ctx.Locale.Tr "repo.pull.agit_documentation")}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{$headHref = HTMLFormat `<span data-tooltip-content="%s">%s</span>` (ctx.Locale.Tr "form.target_branch_not_exist") $headHref}}
|
{{$headHref = HTMLFormat `<span class="tw-line-through" data-tooltip-content="%s">%s</span>` (ctx.Locale.Tr "form.target_branch_not_exist") $headHref}}
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
{{$baseHref := .BaseTarget}}
|
{{$baseHref := .BaseTarget}}
|
||||||
{{if .BaseBranchLink}}
|
{{if .BaseBranchLink}}
|
||||||
{{$baseHref = HTMLFormat `<a href="%s">%s</a>` .BaseBranchLink $baseHref}}
|
{{if .BaseBranchNotExist}}
|
||||||
|
{{$baseHref = HTMLFormat `<span class="tw-line-through" data-tooltip-content="%s">%s</span>` (ctx.Locale.Tr "form.target_branch_not_exist") $baseHref}}
|
||||||
|
{{else}}
|
||||||
|
{{$baseHref = HTMLFormat `<a href="%s">%s</a>` .BaseBranchLink $baseHref}}
|
||||||
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if .Issue.PullRequest.HasMerged}}
|
{{if .Issue.PullRequest.HasMerged}}
|
||||||
{{$mergedStr:= DateUtils.TimeSince .Issue.PullRequest.MergedUnix}}
|
{{$mergedStr:= DateUtils.TimeSince .Issue.PullRequest.MergedUnix}}
|
||||||
|
|
|
@ -107,7 +107,7 @@ func TestE2e(t *testing.T) {
|
||||||
cmd.Stdout = &stdout
|
cmd.Stdout = &stdout
|
||||||
cmd.Stderr = &stderr
|
cmd.Stderr = &stderr
|
||||||
|
|
||||||
err := cmd.Run()
|
err = cmd.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Currently colored output is conflicting. Using Printf until that is resolved.
|
// Currently colored output is conflicting. Using Printf until that is resolved.
|
||||||
fmt.Printf("%v", stdout.String())
|
fmt.Printf("%v", stdout.String())
|
||||||
|
|
|
@ -589,7 +589,8 @@ func TestPullDontRetargetChildOnWrongRepo(t *testing.T) {
|
||||||
resp := session.MakeRequest(t, req, http.StatusOK)
|
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||||
|
|
||||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||||
targetBranch := htmlDoc.doc.Find("#branch_target>a").Text()
|
// the branch has been deleted, so there is no a html tag instead of span
|
||||||
|
targetBranch := htmlDoc.doc.Find("#branch_target>span").Text()
|
||||||
prStatus := strings.TrimSpace(htmlDoc.doc.Find(".issue-title-meta>.issue-state-label").Text())
|
prStatus := strings.TrimSpace(htmlDoc.doc.Find(".issue-title-meta>.issue-state-label").Text())
|
||||||
|
|
||||||
assert.EqualValues(t, "base-pr", targetBranch)
|
assert.EqualValues(t, "base-pr", targetBranch)
|
||||||
|
|
|
@ -1397,6 +1397,10 @@ table th[data-sortt-desc] .svg {
|
||||||
gap: .5rem;
|
gap: .5rem;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
.ui.dropdown .menu.flex-items-menu > .item img,
|
||||||
|
.ui.dropdown .menu.flex-items-menu > .item svg {
|
||||||
|
margin: 0; /* use gap, but not margin */
|
||||||
|
}
|
||||||
|
|
||||||
.ui.dropdown.ellipsis-items-nowrap > .text {
|
.ui.dropdown.ellipsis-items-nowrap > .text {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
|
@ -53,11 +53,6 @@
|
||||||
.issue-sidebar-combo .ui.dropdown .item:not(.checked) .item-check-mark {
|
.issue-sidebar-combo .ui.dropdown .item:not(.checked) .item-check-mark {
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
}
|
}
|
||||||
/* ideally, we should move these styles to ".ui.dropdown .menu.flex-items-menu > .item ...", could be done later */
|
|
||||||
.issue-sidebar-combo .ui.dropdown .menu > .item > img,
|
|
||||||
.issue-sidebar-combo .ui.dropdown .menu > .item > svg {
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.issue-content-right .dropdown > .menu {
|
.issue-content-right .dropdown > .menu {
|
||||||
max-width: 270px;
|
max-width: 270px;
|
||||||
|
@ -66,6 +61,12 @@
|
||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.issue-content-right .dropdown > .menu .item-secondary-info small {
|
||||||
|
display: block;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 767.98px) {
|
@media (max-width: 767.98px) {
|
||||||
.issue-content-left,
|
.issue-content-left,
|
||||||
.issue-content-right {
|
.issue-content-right {
|
||||||
|
@ -73,11 +74,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.repository .issue-content-right .filter.menu {
|
|
||||||
max-height: 500px;
|
|
||||||
overflow-x: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.repository .filter.menu.labels .label-filter .menu .info {
|
.repository .filter.menu.labels .label-filter .menu .info {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
padding: 0.5rem 0;
|
padding: 0.5rem 0;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
export function initAutoFocusEnd() {
|
export function initAutoFocusEnd() {
|
||||||
for (const el of document.querySelectorAll('.js-autofocus-end')) {
|
for (const el of document.querySelectorAll<HTMLInputElement>('.js-autofocus-end')) {
|
||||||
el.focus(); // expects only one such element on one page. If there are many, then the last one gets the focus.
|
el.focus(); // expects only one such element on one page. If there are many, then the last one gets the focus.
|
||||||
el.setSelectionRange(el.value.length, el.value.length);
|
el.setSelectionRange(el.value.length, el.value.length);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,9 +35,11 @@ export async function initCaptcha() {
|
||||||
}
|
}
|
||||||
case 'm-captcha': {
|
case 'm-captcha': {
|
||||||
const {default: mCaptcha} = await import(/* webpackChunkName: "mcaptcha-vanilla-glue" */'@mcaptcha/vanilla-glue');
|
const {default: mCaptcha} = await import(/* webpackChunkName: "mcaptcha-vanilla-glue" */'@mcaptcha/vanilla-glue');
|
||||||
|
// @ts-expect-error
|
||||||
mCaptcha.INPUT_NAME = 'm-captcha-response';
|
mCaptcha.INPUT_NAME = 'm-captcha-response';
|
||||||
const instanceURL = captchaEl.getAttribute('data-instance-url');
|
const instanceURL = captchaEl.getAttribute('data-instance-url');
|
||||||
|
|
||||||
|
// @ts-expect-error
|
||||||
mCaptcha.default({
|
mCaptcha.default({
|
||||||
siteKey: {
|
siteKey: {
|
||||||
instanceUrl: new URL(instanceURL),
|
instanceUrl: new URL(instanceURL),
|
||||||
|
|
|
@ -3,7 +3,7 @@ import {fomanticQuery} from '../modules/fomantic/base.ts';
|
||||||
|
|
||||||
const {pageData} = window.config;
|
const {pageData} = window.config;
|
||||||
|
|
||||||
async function initInputCitationValue(citationCopyApa, citationCopyBibtex) {
|
async function initInputCitationValue(citationCopyApa: HTMLButtonElement, citationCopyBibtex: HTMLButtonElement) {
|
||||||
const [{Cite, plugins}] = await Promise.all([
|
const [{Cite, plugins}] = await Promise.all([
|
||||||
import(/* webpackChunkName: "citation-js-core" */'@citation-js/core'),
|
import(/* webpackChunkName: "citation-js-core" */'@citation-js/core'),
|
||||||
import(/* webpackChunkName: "citation-js-formats" */'@citation-js/plugin-software-formats'),
|
import(/* webpackChunkName: "citation-js-formats" */'@citation-js/plugin-software-formats'),
|
||||||
|
@ -27,9 +27,9 @@ export async function initCitationFileCopyContent() {
|
||||||
|
|
||||||
if (!pageData.citationFileContent) return;
|
if (!pageData.citationFileContent) return;
|
||||||
|
|
||||||
const citationCopyApa = document.querySelector('#citation-copy-apa');
|
const citationCopyApa = document.querySelector<HTMLButtonElement>('#citation-copy-apa');
|
||||||
const citationCopyBibtex = document.querySelector('#citation-copy-bibtex');
|
const citationCopyBibtex = document.querySelector<HTMLButtonElement>('#citation-copy-bibtex');
|
||||||
const inputContent = document.querySelector('#citation-copy-content');
|
const inputContent = document.querySelector<HTMLInputElement>('#citation-copy-content');
|
||||||
|
|
||||||
if ((!citationCopyApa && !citationCopyBibtex) || !inputContent) return;
|
if ((!citationCopyApa && !citationCopyBibtex) || !inputContent) return;
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ export async function initCitationFileCopyContent() {
|
||||||
citationCopyApa.classList.toggle('primary', !isBibtex);
|
citationCopyApa.classList.toggle('primary', !isBibtex);
|
||||||
};
|
};
|
||||||
|
|
||||||
document.querySelector('#cite-repo-button')?.addEventListener('click', async (e) => {
|
document.querySelector('#cite-repo-button')?.addEventListener('click', async (e: MouseEvent & {target: HTMLAnchorElement}) => {
|
||||||
const dropdownBtn = e.target.closest('.ui.dropdown.button');
|
const dropdownBtn = e.target.closest('.ui.dropdown.button');
|
||||||
dropdownBtn.classList.add('is-loading');
|
dropdownBtn.classList.add('is-loading');
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ const {copy_success, copy_error} = window.config.i18n;
|
||||||
// - data-clipboard-target: Holds a selector for a <input> or <textarea> whose content is copied
|
// - data-clipboard-target: Holds a selector for a <input> or <textarea> whose content is copied
|
||||||
// - data-clipboard-text-type: When set to 'url' will convert relative to absolute urls
|
// - data-clipboard-text-type: When set to 'url' will convert relative to absolute urls
|
||||||
export function initGlobalCopyToClipboardListener() {
|
export function initGlobalCopyToClipboardListener() {
|
||||||
document.addEventListener('click', async (e) => {
|
document.addEventListener('click', async (e: MouseEvent & {target: HTMLElement}) => {
|
||||||
const target = e.target.closest('[data-clipboard-text], [data-clipboard-target]');
|
const target = e.target.closest('[data-clipboard-text], [data-clipboard-target]');
|
||||||
if (!target) return;
|
if (!target) return;
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ export function initGlobalCopyToClipboardListener() {
|
||||||
|
|
||||||
let text = target.getAttribute('data-clipboard-text');
|
let text = target.getAttribute('data-clipboard-text');
|
||||||
if (!text) {
|
if (!text) {
|
||||||
text = document.querySelector(target.getAttribute('data-clipboard-target'))?.value;
|
text = document.querySelector<HTMLInputElement>(target.getAttribute('data-clipboard-target'))?.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (text && target.getAttribute('data-clipboard-text-type') === 'url') {
|
if (text && target.getAttribute('data-clipboard-text-type') === 'url') {
|
||||||
|
|
|
@ -21,7 +21,7 @@ const baseOptions = {
|
||||||
automaticLayout: true,
|
automaticLayout: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
function getEditorconfig(input) {
|
function getEditorconfig(input: HTMLInputElement) {
|
||||||
try {
|
try {
|
||||||
return JSON.parse(input.getAttribute('data-editorconfig'));
|
return JSON.parse(input.getAttribute('data-editorconfig'));
|
||||||
} catch {
|
} catch {
|
||||||
|
@ -58,7 +58,7 @@ function exportEditor(editor) {
|
||||||
if (!window.codeEditors.includes(editor)) window.codeEditors.push(editor);
|
if (!window.codeEditors.includes(editor)) window.codeEditors.push(editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function createMonaco(textarea, filename, editorOpts) {
|
export async function createMonaco(textarea: HTMLTextAreaElement, filename: string, editorOpts: Record<string, any>) {
|
||||||
const monaco = await import(/* webpackChunkName: "monaco" */'monaco-editor');
|
const monaco = await import(/* webpackChunkName: "monaco" */'monaco-editor');
|
||||||
|
|
||||||
initLanguages(monaco);
|
initLanguages(monaco);
|
||||||
|
@ -72,7 +72,7 @@ export async function createMonaco(textarea, filename, editorOpts) {
|
||||||
// https://github.com/microsoft/monaco-editor/issues/2427
|
// https://github.com/microsoft/monaco-editor/issues/2427
|
||||||
// also, monaco can only parse 6-digit hex colors, so we convert the colors to that format
|
// also, monaco can only parse 6-digit hex colors, so we convert the colors to that format
|
||||||
const styles = window.getComputedStyle(document.documentElement);
|
const styles = window.getComputedStyle(document.documentElement);
|
||||||
const getColor = (name) => tinycolor(styles.getPropertyValue(name).trim()).toString('hex6');
|
const getColor = (name: string) => tinycolor(styles.getPropertyValue(name).trim()).toString('hex6');
|
||||||
|
|
||||||
monaco.editor.defineTheme('gitea', {
|
monaco.editor.defineTheme('gitea', {
|
||||||
base: isDarkTheme() ? 'vs-dark' : 'vs',
|
base: isDarkTheme() ? 'vs-dark' : 'vs',
|
||||||
|
@ -127,13 +127,13 @@ export async function createMonaco(textarea, filename, editorOpts) {
|
||||||
return {monaco, editor};
|
return {monaco, editor};
|
||||||
}
|
}
|
||||||
|
|
||||||
function getFileBasedOptions(filename, lineWrapExts) {
|
function getFileBasedOptions(filename: string, lineWrapExts: string[]) {
|
||||||
return {
|
return {
|
||||||
wordWrap: (lineWrapExts || []).includes(extname(filename)) ? 'on' : 'off',
|
wordWrap: (lineWrapExts || []).includes(extname(filename)) ? 'on' : 'off',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function togglePreviewDisplay(previewable) {
|
function togglePreviewDisplay(previewable: boolean) {
|
||||||
const previewTab = document.querySelector('a[data-tab="preview"]');
|
const previewTab = document.querySelector('a[data-tab="preview"]');
|
||||||
if (!previewTab) return;
|
if (!previewTab) return;
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ function togglePreviewDisplay(previewable) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function createCodeEditor(textarea, filenameInput) {
|
export async function createCodeEditor(textarea: HTMLTextAreaElement, filenameInput: HTMLInputElement) {
|
||||||
const filename = basename(filenameInput.value);
|
const filename = basename(filenameInput.value);
|
||||||
const previewableExts = new Set((textarea.getAttribute('data-previewable-extensions') || '').split(','));
|
const previewableExts = new Set((textarea.getAttribute('data-previewable-extensions') || '').split(','));
|
||||||
const lineWrapExts = (textarea.getAttribute('data-line-wrap-extensions') || '').split(',');
|
const lineWrapExts = (textarea.getAttribute('data-line-wrap-extensions') || '').split(',');
|
||||||
|
@ -177,10 +177,10 @@ export async function createCodeEditor(textarea, filenameInput) {
|
||||||
return editor;
|
return editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getEditorConfigOptions(ec) {
|
function getEditorConfigOptions(ec: Record<string, any>): Record<string, any> {
|
||||||
if (!isObject(ec)) return {};
|
if (!isObject(ec)) return {};
|
||||||
|
|
||||||
const opts = {};
|
const opts: Record<string, any> = {};
|
||||||
opts.detectIndentation = !('indent_style' in ec) || !('indent_size' in ec);
|
opts.detectIndentation = !('indent_style' in ec) || !('indent_size' in ec);
|
||||||
if ('indent_size' in ec) opts.indentSize = Number(ec.indent_size);
|
if ('indent_size' in ec) opts.indentSize = Number(ec.indent_size);
|
||||||
if ('tab_width' in ec) opts.tabSize = Number(ec.tab_width) || opts.indentSize;
|
if ('tab_width' in ec) opts.tabSize = Number(ec.tab_width) || opts.indentSize;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import {createTippy} from '../modules/tippy.ts';
|
import {createTippy} from '../modules/tippy.ts';
|
||||||
|
|
||||||
export async function initColorPickers() {
|
export async function initColorPickers() {
|
||||||
const els = document.querySelectorAll('.js-color-picker-input');
|
const els = document.querySelectorAll<HTMLElement>('.js-color-picker-input');
|
||||||
if (!els.length) return;
|
if (!els.length) return;
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
|
@ -14,15 +14,15 @@ export async function initColorPickers() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateSquare(el, newValue) {
|
function updateSquare(el: HTMLElement, newValue: string): void {
|
||||||
el.style.color = /#[0-9a-f]{6}/i.test(newValue) ? newValue : 'transparent';
|
el.style.color = /#[0-9a-f]{6}/i.test(newValue) ? newValue : 'transparent';
|
||||||
}
|
}
|
||||||
|
|
||||||
function updatePicker(el, newValue) {
|
function updatePicker(el: HTMLElement, newValue: string): void {
|
||||||
el.setAttribute('color', newValue);
|
el.setAttribute('color', newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
function initPicker(el) {
|
function initPicker(el: HTMLElement): void {
|
||||||
const input = el.querySelector('input');
|
const input = el.querySelector('input');
|
||||||
|
|
||||||
const square = document.createElement('div');
|
const square = document.createElement('div');
|
||||||
|
@ -37,7 +37,7 @@ function initPicker(el) {
|
||||||
updateSquare(square, e.detail.value);
|
updateSquare(square, e.detail.value);
|
||||||
});
|
});
|
||||||
|
|
||||||
input.addEventListener('input', (e) => {
|
input.addEventListener('input', (e: Event & {target: HTMLInputElement}) => {
|
||||||
updateSquare(square, e.target.value);
|
updateSquare(square, e.target.value);
|
||||||
updatePicker(picker, e.target.value);
|
updatePicker(picker, e.target.value);
|
||||||
});
|
});
|
||||||
|
@ -56,7 +56,7 @@ function initPicker(el) {
|
||||||
|
|
||||||
// init precolors
|
// init precolors
|
||||||
for (const colorEl of el.querySelectorAll('.precolors .color')) {
|
for (const colorEl of el.querySelectorAll('.precolors .color')) {
|
||||||
colorEl.addEventListener('click', (e) => {
|
colorEl.addEventListener('click', (e: MouseEvent & {target: HTMLAnchorElement}) => {
|
||||||
const newValue = e.target.getAttribute('data-color-hex');
|
const newValue = e.target.getAttribute('data-color-hex');
|
||||||
input.value = newValue;
|
input.value = newValue;
|
||||||
input.dispatchEvent(new Event('input', {bubbles: true}));
|
input.dispatchEvent(new Event('input', {bubbles: true}));
|
||||||
|
|
|
@ -3,7 +3,7 @@ import {POST} from '../modules/fetch.ts';
|
||||||
import {hideElem, showElem, toggleElem} from '../utils/dom.ts';
|
import {hideElem, showElem, toggleElem} from '../utils/dom.ts';
|
||||||
import {showErrorToast} from '../modules/toast.ts';
|
import {showErrorToast} from '../modules/toast.ts';
|
||||||
|
|
||||||
export function initGlobalButtonClickOnEnter() {
|
export function initGlobalButtonClickOnEnter(): void {
|
||||||
$(document).on('keypress', 'div.ui.button,span.ui.button', (e) => {
|
$(document).on('keypress', 'div.ui.button,span.ui.button', (e) => {
|
||||||
if (e.code === ' ' || e.code === 'Enter') {
|
if (e.code === ' ' || e.code === 'Enter') {
|
||||||
$(e.target).trigger('click');
|
$(e.target).trigger('click');
|
||||||
|
@ -12,13 +12,13 @@ export function initGlobalButtonClickOnEnter() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function initGlobalDeleteButton() {
|
export function initGlobalDeleteButton(): void {
|
||||||
// ".delete-button" shows a confirmation modal defined by `data-modal-id` attribute.
|
// ".delete-button" shows a confirmation modal defined by `data-modal-id` attribute.
|
||||||
// Some model/form elements will be filled by `data-id` / `data-name` / `data-data-xxx` attributes.
|
// Some model/form elements will be filled by `data-id` / `data-name` / `data-data-xxx` attributes.
|
||||||
// If there is a form defined by `data-form`, then the form will be submitted as-is (without any modification).
|
// If there is a form defined by `data-form`, then the form will be submitted as-is (without any modification).
|
||||||
// If there is no form, then the data will be posted to `data-url`.
|
// If there is no form, then the data will be posted to `data-url`.
|
||||||
// TODO: it's not encouraged to use this method. `show-modal` does far better than this.
|
// TODO: it's not encouraged to use this method. `show-modal` does far better than this.
|
||||||
for (const btn of document.querySelectorAll('.delete-button')) {
|
for (const btn of document.querySelectorAll<HTMLElement>('.delete-button')) {
|
||||||
btn.addEventListener('click', (e) => {
|
btn.addEventListener('click', (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ export function initGlobalDeleteButton() {
|
||||||
// if `data-type="form"` exists, then submit the form by the selector provided by `data-form="..."`
|
// if `data-type="form"` exists, then submit the form by the selector provided by `data-form="..."`
|
||||||
if (btn.getAttribute('data-type') === 'form') {
|
if (btn.getAttribute('data-type') === 'form') {
|
||||||
const formSelector = btn.getAttribute('data-form');
|
const formSelector = btn.getAttribute('data-form');
|
||||||
const form = document.querySelector(formSelector);
|
const form = document.querySelector<HTMLFormElement>(formSelector);
|
||||||
if (!form) throw new Error(`no form named ${formSelector} found`);
|
if (!form) throw new Error(`no form named ${formSelector} found`);
|
||||||
form.submit();
|
form.submit();
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ export function initGlobalDeleteButton() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function initGlobalButtons() {
|
export function initGlobalButtons(): void {
|
||||||
// There are many "cancel button" elements in modal dialogs, Fomantic UI expects they are button-like elements but never submit a form.
|
// There are many "cancel button" elements in modal dialogs, Fomantic UI expects they are button-like elements but never submit a form.
|
||||||
// However, Gitea misuses the modal dialog and put the cancel buttons inside forms, so we must prevent the form submission.
|
// However, Gitea misuses the modal dialog and put the cancel buttons inside forms, so we must prevent the form submission.
|
||||||
// There are a few cancel buttons in non-modal forms, and there are some dynamically created forms (eg: the "Edit Issue Content")
|
// There are a few cancel buttons in non-modal forms, and there are some dynamically created forms (eg: the "Edit Issue Content")
|
||||||
|
|
|
@ -7,30 +7,20 @@ import {validateTextareaNonEmpty} from './comp/ComboMarkdownEditor.ts';
|
||||||
import {initViewedCheckboxListenerFor, countAndUpdateViewedFiles, initExpandAndCollapseFilesButton} from './pull-view-file.ts';
|
import {initViewedCheckboxListenerFor, countAndUpdateViewedFiles, initExpandAndCollapseFilesButton} from './pull-view-file.ts';
|
||||||
import {initImageDiff} from './imagediff.ts';
|
import {initImageDiff} from './imagediff.ts';
|
||||||
import {showErrorToast} from '../modules/toast.ts';
|
import {showErrorToast} from '../modules/toast.ts';
|
||||||
import {submitEventSubmitter, queryElemSiblings, hideElem, showElem, animateOnce} from '../utils/dom.ts';
|
import {
|
||||||
|
submitEventSubmitter,
|
||||||
|
queryElemSiblings,
|
||||||
|
hideElem,
|
||||||
|
showElem,
|
||||||
|
animateOnce,
|
||||||
|
addDelegatedEventListener,
|
||||||
|
createElementFromHTML,
|
||||||
|
} from '../utils/dom.ts';
|
||||||
import {POST, GET} from '../modules/fetch.ts';
|
import {POST, GET} from '../modules/fetch.ts';
|
||||||
|
import {fomanticQuery} from '../modules/fomantic/base.ts';
|
||||||
|
|
||||||
const {pageData, i18n} = window.config;
|
const {pageData, i18n} = window.config;
|
||||||
|
|
||||||
function initRepoDiffReviewButton() {
|
|
||||||
const reviewBox = document.querySelector('#review-box');
|
|
||||||
if (!reviewBox) return;
|
|
||||||
|
|
||||||
const counter = reviewBox.querySelector('.review-comments-counter');
|
|
||||||
if (!counter) return;
|
|
||||||
|
|
||||||
$(document).on('click', 'button[name="pending_review"]', (e) => {
|
|
||||||
const $form = $(e.target).closest('form');
|
|
||||||
// Watch for the form's submit event.
|
|
||||||
$form.on('submit', () => {
|
|
||||||
const num = parseInt(counter.getAttribute('data-pending-comment-number')) + 1 || 1;
|
|
||||||
counter.setAttribute('data-pending-comment-number', num);
|
|
||||||
counter.textContent = num;
|
|
||||||
animateOnce(reviewBox, 'pulse-1p5-200');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function initRepoDiffFileViewToggle() {
|
function initRepoDiffFileViewToggle() {
|
||||||
$('.file-view-toggle').on('click', function () {
|
$('.file-view-toggle').on('click', function () {
|
||||||
for (const el of queryElemSiblings(this)) {
|
for (const el of queryElemSiblings(this)) {
|
||||||
|
@ -47,19 +37,15 @@ function initRepoDiffFileViewToggle() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function initRepoDiffConversationForm() {
|
function initRepoDiffConversationForm() {
|
||||||
$(document).on('submit', '.conversation-holder form', async (e) => {
|
addDelegatedEventListener<HTMLFormElement>(document, 'submit', '.conversation-holder form', async (form, e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
const textArea = form.querySelector<HTMLTextAreaElement>('textarea');
|
||||||
|
if (!validateTextareaNonEmpty(textArea)) return;
|
||||||
|
if (form.classList.contains('is-loading')) return;
|
||||||
|
|
||||||
const $form = $(e.target);
|
|
||||||
const textArea = e.target.querySelector('textarea');
|
|
||||||
if (!validateTextareaNonEmpty(textArea)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (e.target.classList.contains('is-loading')) return;
|
|
||||||
try {
|
try {
|
||||||
e.target.classList.add('is-loading');
|
form.classList.add('is-loading');
|
||||||
const formData = new FormData($form[0]);
|
const formData = new FormData(form);
|
||||||
|
|
||||||
// if the form is submitted by a button, append the button's name and value to the form data
|
// if the form is submitted by a button, append the button's name and value to the form data
|
||||||
const submitter = submitEventSubmitter(e);
|
const submitter = submitEventSubmitter(e);
|
||||||
|
@ -68,26 +54,42 @@ function initRepoDiffConversationForm() {
|
||||||
formData.append(submitter.name, submitter.value);
|
formData.append(submitter.name, submitter.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await POST(e.target.getAttribute('action'), {data: formData});
|
const trLineType = form.closest('tr').getAttribute('data-line-type');
|
||||||
const $newConversationHolder = $(await response.text());
|
const response = await POST(form.getAttribute('action'), {data: formData});
|
||||||
const {path, side, idx} = $newConversationHolder.data();
|
const newConversationHolder = createElementFromHTML(await response.text());
|
||||||
|
const path = newConversationHolder.getAttribute('data-path');
|
||||||
|
const side = newConversationHolder.getAttribute('data-side');
|
||||||
|
const idx = newConversationHolder.getAttribute('data-idx');
|
||||||
|
|
||||||
|
form.closest('.conversation-holder').replaceWith(newConversationHolder);
|
||||||
|
form = null; // prevent further usage of the form because it should have been replaced
|
||||||
|
|
||||||
$form.closest('.conversation-holder').replaceWith($newConversationHolder);
|
|
||||||
let selector;
|
let selector;
|
||||||
if ($form.closest('tr').data('line-type') === 'same') {
|
if (trLineType === 'same') {
|
||||||
selector = `[data-path="${path}"] .add-code-comment[data-idx="${idx}"]`;
|
selector = `[data-path="${path}"] .add-code-comment[data-idx="${idx}"]`;
|
||||||
} else {
|
} else {
|
||||||
selector = `[data-path="${path}"] .add-code-comment[data-side="${side}"][data-idx="${idx}"]`;
|
selector = `[data-path="${path}"] .add-code-comment[data-side="${side}"][data-idx="${idx}"]`;
|
||||||
}
|
}
|
||||||
for (const el of document.querySelectorAll(selector)) {
|
for (const el of document.querySelectorAll(selector)) {
|
||||||
el.classList.add('tw-invisible');
|
el.classList.add('tw-invisible'); // TODO need to figure out why
|
||||||
|
}
|
||||||
|
fomanticQuery(newConversationHolder.querySelectorAll('.ui.dropdown')).dropdown();
|
||||||
|
|
||||||
|
// the default behavior is to add a pending review, so if no submitter, it also means "pending_review"
|
||||||
|
if (!submitter || submitter?.matches('button[name="pending_review"]')) {
|
||||||
|
const reviewBox = document.querySelector('#review-box');
|
||||||
|
const counter = reviewBox?.querySelector('.review-comments-counter');
|
||||||
|
if (!counter) return;
|
||||||
|
const num = parseInt(counter.getAttribute('data-pending-comment-number')) + 1 || 1;
|
||||||
|
counter.setAttribute('data-pending-comment-number', String(num));
|
||||||
|
counter.textContent = String(num);
|
||||||
|
animateOnce(reviewBox, 'pulse-1p5-200');
|
||||||
}
|
}
|
||||||
$newConversationHolder.find('.dropdown').dropdown();
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error:', error);
|
console.error('Error:', error);
|
||||||
showErrorToast(i18n.network_error);
|
showErrorToast(i18n.network_error);
|
||||||
} finally {
|
} finally {
|
||||||
e.target.classList.remove('is-loading');
|
form?.classList.remove('is-loading');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -219,7 +221,6 @@ export function initRepoDiffView() {
|
||||||
initDiffFileList();
|
initDiffFileList();
|
||||||
initDiffCommitSelect();
|
initDiffCommitSelect();
|
||||||
initRepoDiffShowMore();
|
initRepoDiffShowMore();
|
||||||
initRepoDiffReviewButton();
|
|
||||||
initRepoDiffFileViewToggle();
|
initRepoDiffFileViewToggle();
|
||||||
initViewedCheckboxListenerFor();
|
initViewedCheckboxListenerFor();
|
||||||
initExpandAndCollapseFilesButton();
|
initExpandAndCollapseFilesButton();
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import $ from 'jquery';
|
import $ from 'jquery';
|
||||||
import {htmlEscape} from 'escape-goat';
|
import {htmlEscape} from 'escape-goat';
|
||||||
import {createTippy, showTemporaryTooltip} from '../modules/tippy.ts';
|
import {createTippy, showTemporaryTooltip} from '../modules/tippy.ts';
|
||||||
import {hideElem, showElem, toggleElem} from '../utils/dom.ts';
|
import {addDelegatedEventListener, createElementFromHTML, hideElem, showElem, toggleElem} from '../utils/dom.ts';
|
||||||
import {setFileFolding} from './file-fold.ts';
|
import {setFileFolding} from './file-fold.ts';
|
||||||
import {ComboMarkdownEditor, getComboMarkdownEditor, initComboMarkdownEditor} from './comp/ComboMarkdownEditor.ts';
|
import {ComboMarkdownEditor, getComboMarkdownEditor, initComboMarkdownEditor} from './comp/ComboMarkdownEditor.ts';
|
||||||
import {parseIssuePageInfo, toAbsoluteUrl} from '../utils.ts';
|
import {parseIssuePageInfo, toAbsoluteUrl} from '../utils.ts';
|
||||||
|
@ -443,21 +443,19 @@ export function initRepoPullRequestReview() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).on('click', '.add-code-comment', async function (e) {
|
addDelegatedEventListener(document, 'click', '.add-code-comment', async (el, e) => {
|
||||||
if (e.target.classList.contains('btn-add-single')) return; // https://github.com/go-gitea/gitea/issues/4745
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
const isSplit = this.closest('.code-diff')?.classList.contains('code-diff-split');
|
const isSplit = el.closest('.code-diff')?.classList.contains('code-diff-split');
|
||||||
const side = this.getAttribute('data-side');
|
const side = el.getAttribute('data-side');
|
||||||
const idx = this.getAttribute('data-idx');
|
const idx = el.getAttribute('data-idx');
|
||||||
const path = this.closest('[data-path]')?.getAttribute('data-path');
|
const path = el.closest('[data-path]')?.getAttribute('data-path');
|
||||||
const tr = this.closest('tr');
|
const tr = el.closest('tr');
|
||||||
const lineType = tr.getAttribute('data-line-type');
|
const lineType = tr.getAttribute('data-line-type');
|
||||||
|
|
||||||
const ntr = tr.nextElementSibling;
|
let ntr = tr.nextElementSibling;
|
||||||
let $ntr = $(ntr);
|
|
||||||
if (!ntr?.classList.contains('add-comment')) {
|
if (!ntr?.classList.contains('add-comment')) {
|
||||||
$ntr = $(`
|
ntr = createElementFromHTML(`
|
||||||
<tr class="add-comment" data-line-type="${lineType}">
|
<tr class="add-comment" data-line-type="${lineType}">
|
||||||
${isSplit ? `
|
${isSplit ? `
|
||||||
<td class="add-comment-left" colspan="4"></td>
|
<td class="add-comment-left" colspan="4"></td>
|
||||||
|
@ -466,24 +464,18 @@ export function initRepoPullRequestReview() {
|
||||||
<td class="add-comment-left add-comment-right" colspan="5"></td>
|
<td class="add-comment-left add-comment-right" colspan="5"></td>
|
||||||
`}
|
`}
|
||||||
</tr>`);
|
</tr>`);
|
||||||
$(tr).after($ntr);
|
tr.after(ntr);
|
||||||
}
|
}
|
||||||
|
const td = ntr.querySelector(`.add-comment-${side}`);
|
||||||
const $td = $ntr.find(`.add-comment-${side}`);
|
const commentCloud = td.querySelector('.comment-code-cloud');
|
||||||
const $commentCloud = $td.find('.comment-code-cloud');
|
if (!commentCloud && !ntr.querySelector('button[name="pending_review"]')) {
|
||||||
if (!$commentCloud.length && !$ntr.find('button[name="pending_review"]').length) {
|
const response = await GET(el.closest('[data-new-comment-url]')?.getAttribute('data-new-comment-url'));
|
||||||
try {
|
td.innerHTML = await response.text();
|
||||||
const response = await GET(this.closest('[data-new-comment-url]')?.getAttribute('data-new-comment-url'));
|
td.querySelector<HTMLInputElement>("input[name='line']").value = idx;
|
||||||
const html = await response.text();
|
td.querySelector<HTMLInputElement>("input[name='side']").value = (side === 'left' ? 'previous' : 'proposed');
|
||||||
$td.html(html);
|
td.querySelector<HTMLInputElement>("input[name='path']").value = path;
|
||||||
$td.find("input[name='line']").val(idx);
|
const editor = await initComboMarkdownEditor(td.querySelector<HTMLElement>('.combo-markdown-editor'));
|
||||||
$td.find("input[name='side']").val(side === 'left' ? 'previous' : 'proposed');
|
editor.focus();
|
||||||
$td.find("input[name='path']").val(path);
|
|
||||||
const editor = await initComboMarkdownEditor($td[0].querySelector('.combo-markdown-editor'));
|
|
||||||
editor.focus();
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,4 +58,8 @@ interface Window {
|
||||||
push: (e: ErrorEvent & PromiseRejectionEvent) => void | number,
|
push: (e: ErrorEvent & PromiseRejectionEvent) => void | number,
|
||||||
},
|
},
|
||||||
__webpack_public_path__: string;
|
__webpack_public_path__: string;
|
||||||
|
grecaptcha: any,
|
||||||
|
turnstile: any,
|
||||||
|
hcaptcha: any,
|
||||||
|
codeEditors: any[],
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ function targetElement(el: Element) {
|
||||||
return el.classList.contains('is-loading') ? el : el.closest('pre');
|
return el.classList.contains('is-loading') ? el : el.closest('pre');
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function renderMath(): void {
|
export async function renderMath(): Promise<void> {
|
||||||
const els = document.querySelectorAll('.markup code.language-math');
|
const els = document.querySelectorAll('.markup code.language-math');
|
||||||
if (!els.length) return;
|
if (!els.length) return;
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ function attachDirAuto(el: DirElement) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function initDirAuto() {
|
export function initDirAuto(): void {
|
||||||
const observer = new MutationObserver((mutationList) => {
|
const observer = new MutationObserver((mutationList) => {
|
||||||
const len = mutationList.length;
|
const len = mutationList.length;
|
||||||
for (let i = 0; i < len; i++) {
|
for (let i = 0; i < len; i++) {
|
||||||
|
|
|
@ -9,7 +9,7 @@ const safeMethods = new Set(['GET', 'HEAD', 'OPTIONS', 'TRACE']);
|
||||||
// fetch wrapper, use below method name functions and the `data` option to pass in data
|
// fetch wrapper, use below method name functions and the `data` option to pass in data
|
||||||
// which will automatically set an appropriate headers. For json content, only object
|
// which will automatically set an appropriate headers. For json content, only object
|
||||||
// and array types are currently supported.
|
// and array types are currently supported.
|
||||||
export function request(url: string, {method = 'GET', data, headers = {}, ...other}: RequestOpts = {}) {
|
export function request(url: string, {method = 'GET', data, headers = {}, ...other}: RequestOpts = {}): Promise<Response> {
|
||||||
let body: RequestData;
|
let body: RequestData;
|
||||||
let contentType: string;
|
let contentType: string;
|
||||||
if (data instanceof FormData || data instanceof URLSearchParams) {
|
if (data instanceof FormData || data instanceof URLSearchParams) {
|
||||||
|
|
|
@ -19,7 +19,7 @@ export function initGiteaFomantic() {
|
||||||
// Do not use "cursor: pointer" for dropdown labels
|
// Do not use "cursor: pointer" for dropdown labels
|
||||||
$.fn.dropdown.settings.className.label += ' tw-cursor-default';
|
$.fn.dropdown.settings.className.label += ' tw-cursor-default';
|
||||||
// Always use Gitea's SVG icons
|
// Always use Gitea's SVG icons
|
||||||
$.fn.dropdown.settings.templates.label = function(_value, text, preserveHTML, className) {
|
$.fn.dropdown.settings.templates.label = function(_value: any, text: any, preserveHTML: any, className: Record<string, string>) {
|
||||||
const escape = $.fn.dropdown.settings.templates.escape;
|
const escape = $.fn.dropdown.settings.templates.escape;
|
||||||
return escape(text, preserveHTML) + svg('octicon-x', 16, `${className.delete} icon`);
|
return escape(text, preserveHTML) + svg('octicon-x', 16, `${className.delete} icon`);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import $ from 'jquery';
|
import $ from 'jquery';
|
||||||
|
import type {FomanticInitFunction} from '../../types.ts';
|
||||||
|
|
||||||
export function initFomanticApiPatch() {
|
export function initFomanticApiPatch() {
|
||||||
//
|
//
|
||||||
|
@ -15,7 +16,7 @@ export function initFomanticApiPatch() {
|
||||||
//
|
//
|
||||||
const patchKey = '_giteaFomanticApiPatch';
|
const patchKey = '_giteaFomanticApiPatch';
|
||||||
const oldApi = $.api;
|
const oldApi = $.api;
|
||||||
$.api = $.fn.api = function(...args) {
|
$.api = $.fn.api = function(...args: Parameters<FomanticInitFunction>) {
|
||||||
const apiCall = oldApi.bind(this);
|
const apiCall = oldApi.bind(this);
|
||||||
const ret = oldApi.apply(this, args);
|
const ret = oldApi.apply(this, args);
|
||||||
|
|
||||||
|
@ -23,7 +24,7 @@ export function initFomanticApiPatch() {
|
||||||
const internalGet = apiCall('internal', 'get');
|
const internalGet = apiCall('internal', 'get');
|
||||||
if (!internalGet.urlEncodedValue[patchKey]) {
|
if (!internalGet.urlEncodedValue[patchKey]) {
|
||||||
const oldUrlEncodedValue = internalGet.urlEncodedValue;
|
const oldUrlEncodedValue = internalGet.urlEncodedValue;
|
||||||
internalGet.urlEncodedValue = function (value) {
|
internalGet.urlEncodedValue = function (value: any) {
|
||||||
try {
|
try {
|
||||||
return oldUrlEncodedValue(value);
|
return oldUrlEncodedValue(value);
|
||||||
} catch {
|
} catch {
|
||||||
|
|
|
@ -5,7 +5,7 @@ export function generateAriaId() {
|
||||||
return `_aria_auto_id_${ariaIdCounter++}`;
|
return `_aria_auto_id_${ariaIdCounter++}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function linkLabelAndInput(label, input) {
|
export function linkLabelAndInput(label: Element, input: Element) {
|
||||||
const labelFor = label.getAttribute('for');
|
const labelFor = label.getAttribute('for');
|
||||||
const inputId = input.getAttribute('id');
|
const inputId = input.getAttribute('id');
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ import {queryElemChildren} from '../../utils/dom.ts';
|
||||||
|
|
||||||
export function initFomanticDimmer() {
|
export function initFomanticDimmer() {
|
||||||
// stand-in for removed dimmer module
|
// stand-in for removed dimmer module
|
||||||
$.fn.dimmer = function (arg0, arg1) {
|
$.fn.dimmer = function (arg0: string, arg1: any) {
|
||||||
if (arg0 === 'add content') {
|
if (arg0 === 'add content') {
|
||||||
const $el = arg1;
|
const $el = arg1;
|
||||||
const existingDimmer = document.querySelector('body > .ui.dimmer');
|
const existingDimmer = document.querySelector('body > .ui.dimmer');
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import $ from 'jquery';
|
import $ from 'jquery';
|
||||||
import {generateAriaId} from './base.ts';
|
import {generateAriaId} from './base.ts';
|
||||||
|
import type {FomanticInitFunction} from '../../types.ts';
|
||||||
|
|
||||||
const ariaPatchKey = '_giteaAriaPatchDropdown';
|
const ariaPatchKey = '_giteaAriaPatchDropdown';
|
||||||
const fomanticDropdownFn = $.fn.dropdown;
|
const fomanticDropdownFn = $.fn.dropdown;
|
||||||
|
@ -8,13 +9,13 @@ const fomanticDropdownFn = $.fn.dropdown;
|
||||||
export function initAriaDropdownPatch() {
|
export function initAriaDropdownPatch() {
|
||||||
if ($.fn.dropdown === ariaDropdownFn) throw new Error('initAriaDropdownPatch could only be called once');
|
if ($.fn.dropdown === ariaDropdownFn) throw new Error('initAriaDropdownPatch could only be called once');
|
||||||
$.fn.dropdown = ariaDropdownFn;
|
$.fn.dropdown = ariaDropdownFn;
|
||||||
ariaDropdownFn.settings = fomanticDropdownFn.settings;
|
(ariaDropdownFn as FomanticInitFunction).settings = fomanticDropdownFn.settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
// the patched `$.fn.dropdown` function, it passes the arguments to Fomantic's `$.fn.dropdown` function, and:
|
// the patched `$.fn.dropdown` function, it passes the arguments to Fomantic's `$.fn.dropdown` function, and:
|
||||||
// * it does the one-time attaching on the first call
|
// * it does the one-time attaching on the first call
|
||||||
// * it delegates the `onLabelCreate` to the patched `onLabelCreate` to add necessary aria attributes
|
// * it delegates the `onLabelCreate` to the patched `onLabelCreate` to add necessary aria attributes
|
||||||
function ariaDropdownFn(...args) {
|
function ariaDropdownFn(...args: Parameters<FomanticInitFunction>) {
|
||||||
const ret = fomanticDropdownFn.apply(this, args);
|
const ret = fomanticDropdownFn.apply(this, args);
|
||||||
|
|
||||||
// if the `$().dropdown()` call is without arguments, or it has non-string (object) argument,
|
// if the `$().dropdown()` call is without arguments, or it has non-string (object) argument,
|
||||||
|
@ -33,7 +34,7 @@ function ariaDropdownFn(...args) {
|
||||||
|
|
||||||
// make the item has role=option/menuitem, add an id if there wasn't one yet, make items as non-focusable
|
// make the item has role=option/menuitem, add an id if there wasn't one yet, make items as non-focusable
|
||||||
// the elements inside the dropdown menu item should not be focusable, the focus should always be on the dropdown primary element.
|
// the elements inside the dropdown menu item should not be focusable, the focus should always be on the dropdown primary element.
|
||||||
function updateMenuItem(dropdown, item) {
|
function updateMenuItem(dropdown: HTMLElement, item: HTMLElement) {
|
||||||
if (!item.id) item.id = generateAriaId();
|
if (!item.id) item.id = generateAriaId();
|
||||||
item.setAttribute('role', dropdown[ariaPatchKey].listItemRole);
|
item.setAttribute('role', dropdown[ariaPatchKey].listItemRole);
|
||||||
item.setAttribute('tabindex', '-1');
|
item.setAttribute('tabindex', '-1');
|
||||||
|
@ -43,7 +44,7 @@ function updateMenuItem(dropdown, item) {
|
||||||
* make the label item and its "delete icon" have correct aria attributes
|
* make the label item and its "delete icon" have correct aria attributes
|
||||||
* @param {HTMLElement} label
|
* @param {HTMLElement} label
|
||||||
*/
|
*/
|
||||||
function updateSelectionLabel(label) {
|
function updateSelectionLabel(label: HTMLElement) {
|
||||||
// the "label" is like this: "<a|div class="ui label" data-value="1">the-label-name <i|svg class="delete icon"/></a>"
|
// the "label" is like this: "<a|div class="ui label" data-value="1">the-label-name <i|svg class="delete icon"/></a>"
|
||||||
if (!label.id) {
|
if (!label.id) {
|
||||||
label.id = generateAriaId();
|
label.id = generateAriaId();
|
||||||
|
@ -59,7 +60,7 @@ function updateSelectionLabel(label) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// delegate the dropdown's template functions and callback functions to add aria attributes.
|
// delegate the dropdown's template functions and callback functions to add aria attributes.
|
||||||
function delegateOne($dropdown) {
|
function delegateOne($dropdown: any) {
|
||||||
const dropdownCall = fomanticDropdownFn.bind($dropdown);
|
const dropdownCall = fomanticDropdownFn.bind($dropdown);
|
||||||
|
|
||||||
// If there is a "search input" in the "menu", Fomantic will only "focus the input" but not "toggle the menu" when the "dropdown icon" is clicked.
|
// If there is a "search input" in the "menu", Fomantic will only "focus the input" but not "toggle the menu" when the "dropdown icon" is clicked.
|
||||||
|
@ -74,7 +75,7 @@ function delegateOne($dropdown) {
|
||||||
// the "template" functions are used for dynamic creation (eg: AJAX)
|
// the "template" functions are used for dynamic creation (eg: AJAX)
|
||||||
const dropdownTemplates = {...dropdownCall('setting', 'templates'), t: performance.now()};
|
const dropdownTemplates = {...dropdownCall('setting', 'templates'), t: performance.now()};
|
||||||
const dropdownTemplatesMenuOld = dropdownTemplates.menu;
|
const dropdownTemplatesMenuOld = dropdownTemplates.menu;
|
||||||
dropdownTemplates.menu = function(response, fields, preserveHTML, className) {
|
dropdownTemplates.menu = function(response: any, fields: any, preserveHTML: any, className: Record<string, string>) {
|
||||||
// when the dropdown menu items are loaded from AJAX requests, the items are created dynamically
|
// when the dropdown menu items are loaded from AJAX requests, the items are created dynamically
|
||||||
const menuItems = dropdownTemplatesMenuOld(response, fields, preserveHTML, className);
|
const menuItems = dropdownTemplatesMenuOld(response, fields, preserveHTML, className);
|
||||||
const div = document.createElement('div');
|
const div = document.createElement('div');
|
||||||
|
@ -89,7 +90,7 @@ function delegateOne($dropdown) {
|
||||||
|
|
||||||
// the `onLabelCreate` is used to add necessary aria attributes for dynamically created selection labels
|
// the `onLabelCreate` is used to add necessary aria attributes for dynamically created selection labels
|
||||||
const dropdownOnLabelCreateOld = dropdownCall('setting', 'onLabelCreate');
|
const dropdownOnLabelCreateOld = dropdownCall('setting', 'onLabelCreate');
|
||||||
dropdownCall('setting', 'onLabelCreate', function(value, text) {
|
dropdownCall('setting', 'onLabelCreate', function(value: any, text: string) {
|
||||||
const $label = dropdownOnLabelCreateOld.call(this, value, text);
|
const $label = dropdownOnLabelCreateOld.call(this, value, text);
|
||||||
updateSelectionLabel($label[0]);
|
updateSelectionLabel($label[0]);
|
||||||
return $label;
|
return $label;
|
||||||
|
@ -97,7 +98,7 @@ function delegateOne($dropdown) {
|
||||||
|
|
||||||
const oldSet = dropdownCall('internal', 'set');
|
const oldSet = dropdownCall('internal', 'set');
|
||||||
const oldSetDirection = oldSet.direction;
|
const oldSetDirection = oldSet.direction;
|
||||||
oldSet.direction = function($menu) {
|
oldSet.direction = function($menu: any) {
|
||||||
oldSetDirection.call(this, $menu);
|
oldSetDirection.call(this, $menu);
|
||||||
const classNames = dropdownCall('setting', 'className');
|
const classNames = dropdownCall('setting', 'className');
|
||||||
$menu = $menu || $dropdown.find('> .menu');
|
$menu = $menu || $dropdown.find('> .menu');
|
||||||
|
@ -113,7 +114,7 @@ function delegateOne($dropdown) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// for static dropdown elements (generated by server-side template), prepare them with necessary aria attributes
|
// for static dropdown elements (generated by server-side template), prepare them with necessary aria attributes
|
||||||
function attachStaticElements(dropdown, focusable, menu) {
|
function attachStaticElements(dropdown: HTMLElement, focusable: HTMLElement, menu: HTMLElement) {
|
||||||
// prepare static dropdown menu list popup
|
// prepare static dropdown menu list popup
|
||||||
if (!menu.id) {
|
if (!menu.id) {
|
||||||
menu.id = generateAriaId();
|
menu.id = generateAriaId();
|
||||||
|
@ -125,7 +126,7 @@ function attachStaticElements(dropdown, focusable, menu) {
|
||||||
menu.setAttribute('role', dropdown[ariaPatchKey].listPopupRole);
|
menu.setAttribute('role', dropdown[ariaPatchKey].listPopupRole);
|
||||||
|
|
||||||
// prepare selection label items
|
// prepare selection label items
|
||||||
for (const label of dropdown.querySelectorAll('.ui.label')) {
|
for (const label of dropdown.querySelectorAll<HTMLElement>('.ui.label')) {
|
||||||
updateSelectionLabel(label);
|
updateSelectionLabel(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +143,7 @@ function attachStaticElements(dropdown, focusable, menu) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function attachInit(dropdown) {
|
function attachInit(dropdown: HTMLElement) {
|
||||||
dropdown[ariaPatchKey] = {};
|
dropdown[ariaPatchKey] = {};
|
||||||
if (dropdown.classList.contains('custom')) return;
|
if (dropdown.classList.contains('custom')) return;
|
||||||
|
|
||||||
|
@ -161,7 +162,7 @@ function attachInit(dropdown) {
|
||||||
|
|
||||||
// TODO: multiple selection is only partially supported. Check and test them one by one in the future.
|
// TODO: multiple selection is only partially supported. Check and test them one by one in the future.
|
||||||
|
|
||||||
const textSearch = dropdown.querySelector('input.search');
|
const textSearch = dropdown.querySelector<HTMLElement>('input.search');
|
||||||
const focusable = textSearch || dropdown; // the primary element for focus, see comment above
|
const focusable = textSearch || dropdown; // the primary element for focus, see comment above
|
||||||
if (!focusable) return;
|
if (!focusable) return;
|
||||||
|
|
||||||
|
@ -191,7 +192,7 @@ function attachInit(dropdown) {
|
||||||
attachStaticElements(dropdown, focusable, menu);
|
attachStaticElements(dropdown, focusable, menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
function attachDomEvents(dropdown, focusable, menu) {
|
function attachDomEvents(dropdown: HTMLElement, focusable: HTMLElement, menu: HTMLElement) {
|
||||||
// when showing, it has class: ".animating.in"
|
// when showing, it has class: ".animating.in"
|
||||||
// when hiding, it has class: ".visible.animating.out"
|
// when hiding, it has class: ".visible.animating.out"
|
||||||
const isMenuVisible = () => (menu.classList.contains('visible') && !menu.classList.contains('out')) || menu.classList.contains('in');
|
const isMenuVisible = () => (menu.classList.contains('visible') && !menu.classList.contains('out')) || menu.classList.contains('in');
|
||||||
|
@ -215,7 +216,7 @@ function attachDomEvents(dropdown, focusable, menu) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
dropdown.addEventListener('keydown', (e) => {
|
dropdown.addEventListener('keydown', (e: KeyboardEvent) => {
|
||||||
// here it must use keydown event before dropdown's keyup handler, otherwise there is no Enter event in our keyup handler
|
// here it must use keydown event before dropdown's keyup handler, otherwise there is no Enter event in our keyup handler
|
||||||
if (e.key === 'Enter') {
|
if (e.key === 'Enter') {
|
||||||
const dropdownCall = fomanticDropdownFn.bind($(dropdown));
|
const dropdownCall = fomanticDropdownFn.bind($(dropdown));
|
||||||
|
@ -260,7 +261,7 @@ function attachDomEvents(dropdown, focusable, menu) {
|
||||||
deferredRefreshAriaActiveItem(100);
|
deferredRefreshAriaActiveItem(100);
|
||||||
}, 0);
|
}, 0);
|
||||||
}, true);
|
}, true);
|
||||||
dropdown.addEventListener('click', (e) => {
|
dropdown.addEventListener('click', (e: MouseEvent) => {
|
||||||
if (isMenuVisible() &&
|
if (isMenuVisible() &&
|
||||||
ignoreClickPreVisible !== 2 && // dropdown is switch from invisible to visible
|
ignoreClickPreVisible !== 2 && // dropdown is switch from invisible to visible
|
||||||
ignoreClickPreEvents === 2 // the click event is related to mousedown+focus
|
ignoreClickPreEvents === 2 // the click event is related to mousedown+focus
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import $ from 'jquery';
|
import $ from 'jquery';
|
||||||
|
import type {FomanticInitFunction} from '../../types.ts';
|
||||||
|
|
||||||
const fomanticModalFn = $.fn.modal;
|
const fomanticModalFn = $.fn.modal;
|
||||||
|
|
||||||
|
@ -6,12 +7,12 @@ const fomanticModalFn = $.fn.modal;
|
||||||
export function initAriaModalPatch() {
|
export function initAriaModalPatch() {
|
||||||
if ($.fn.modal === ariaModalFn) throw new Error('initAriaModalPatch could only be called once');
|
if ($.fn.modal === ariaModalFn) throw new Error('initAriaModalPatch could only be called once');
|
||||||
$.fn.modal = ariaModalFn;
|
$.fn.modal = ariaModalFn;
|
||||||
ariaModalFn.settings = fomanticModalFn.settings;
|
(ariaModalFn as FomanticInitFunction).settings = fomanticModalFn.settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
// the patched `$.fn.modal` modal function
|
// the patched `$.fn.modal` modal function
|
||||||
// * it does the one-time attaching on the first call
|
// * it does the one-time attaching on the first call
|
||||||
function ariaModalFn(...args) {
|
function ariaModalFn(...args: Parameters<FomanticInitFunction>) {
|
||||||
const ret = fomanticModalFn.apply(this, args);
|
const ret = fomanticModalFn.apply(this, args);
|
||||||
if (args[0] === 'show' || args[0]?.autoShow) {
|
if (args[0] === 'show' || args[0]?.autoShow) {
|
||||||
for (const el of this) {
|
for (const el of this) {
|
||||||
|
|
|
@ -8,13 +8,13 @@ export function initFomanticTransition() {
|
||||||
'set duration', 'save conditions', 'restore conditions',
|
'set duration', 'save conditions', 'restore conditions',
|
||||||
]);
|
]);
|
||||||
// stand-in for removed transition module
|
// stand-in for removed transition module
|
||||||
$.fn.transition = function (arg0, arg1, arg2) {
|
$.fn.transition = function (arg0: any, arg1: any, arg2: any) {
|
||||||
if (arg0 === 'is supported') return true;
|
if (arg0 === 'is supported') return true;
|
||||||
if (arg0 === 'is animating') return false;
|
if (arg0 === 'is animating') return false;
|
||||||
if (arg0 === 'is inward') return false;
|
if (arg0 === 'is inward') return false;
|
||||||
if (arg0 === 'is outward') return false;
|
if (arg0 === 'is outward') return false;
|
||||||
|
|
||||||
let argObj;
|
let argObj: Record<string, any>;
|
||||||
if (typeof arg0 === 'string') {
|
if (typeof arg0 === 'string') {
|
||||||
// many behaviors are no-op now. https://fomantic-ui.com/modules/transition.html#/usage
|
// many behaviors are no-op now. https://fomantic-ui.com/modules/transition.html#/usage
|
||||||
if (transitionNopBehaviors.has(arg0)) return this;
|
if (transitionNopBehaviors.has(arg0)) return this;
|
||||||
|
|
|
@ -1,17 +1,18 @@
|
||||||
import type {SortableOptions} from 'sortablejs';
|
import type {SortableOptions, SortableEvent} from 'sortablejs';
|
||||||
|
|
||||||
export async function createSortable(el, opts: {handle?: string} & SortableOptions = {}) {
|
export async function createSortable(el: HTMLElement, opts: {handle?: string} & SortableOptions = {}) {
|
||||||
|
// @ts-expect-error: wrong type derived by typescript
|
||||||
const {Sortable} = await import(/* webpackChunkName: "sortablejs" */'sortablejs');
|
const {Sortable} = await import(/* webpackChunkName: "sortablejs" */'sortablejs');
|
||||||
|
|
||||||
return new Sortable(el, {
|
return new Sortable(el, {
|
||||||
animation: 150,
|
animation: 150,
|
||||||
ghostClass: 'card-ghost',
|
ghostClass: 'card-ghost',
|
||||||
onChoose: (e) => {
|
onChoose: (e: SortableEvent) => {
|
||||||
const handle = opts.handle ? e.item.querySelector(opts.handle) : e.item;
|
const handle = opts.handle ? e.item.querySelector(opts.handle) : e.item;
|
||||||
handle.classList.add('tw-cursor-grabbing');
|
handle.classList.add('tw-cursor-grabbing');
|
||||||
opts.onChoose?.(e);
|
opts.onChoose?.(e);
|
||||||
},
|
},
|
||||||
onUnchoose: (e) => {
|
onUnchoose: (e: SortableEvent) => {
|
||||||
const handle = opts.handle ? e.item.querySelector(opts.handle) : e.item;
|
const handle = opts.handle ? e.item.querySelector(opts.handle) : e.item;
|
||||||
handle.classList.remove('tw-cursor-grabbing');
|
handle.classList.remove('tw-cursor-grabbing');
|
||||||
opts.onUnchoose?.(e);
|
opts.onUnchoose?.(e);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import tippy, {followCursor} from 'tippy.js';
|
import tippy, {followCursor} from 'tippy.js';
|
||||||
import {isDocumentFragmentOrElementNode} from '../utils/dom.ts';
|
import {isDocumentFragmentOrElementNode} from '../utils/dom.ts';
|
||||||
import {formatDatetime} from '../utils/time.ts';
|
import {formatDatetime} from '../utils/time.ts';
|
||||||
import type {Content, Instance, Props} from 'tippy.js';
|
import type {Content, Instance, Placement, Props} from 'tippy.js';
|
||||||
|
|
||||||
type TippyOpts = {
|
type TippyOpts = {
|
||||||
role?: string,
|
role?: string,
|
||||||
|
@ -16,6 +16,7 @@ export function createTippy(target: Element, opts: TippyOpts = {}): Instance {
|
||||||
// because we should use our own wrapper functions to handle them, do not let the user override them
|
// because we should use our own wrapper functions to handle them, do not let the user override them
|
||||||
const {onHide, onShow, onDestroy, role, theme, arrow, ...other} = opts;
|
const {onHide, onShow, onDestroy, role, theme, arrow, ...other} = opts;
|
||||||
|
|
||||||
|
// @ts-expect-error: wrong type derived by typescript
|
||||||
const instance: Instance = tippy(target, {
|
const instance: Instance = tippy(target, {
|
||||||
appendTo: document.body,
|
appendTo: document.body,
|
||||||
animation: false,
|
animation: false,
|
||||||
|
@ -65,7 +66,7 @@ export function createTippy(target: Element, opts: TippyOpts = {}): Instance {
|
||||||
*
|
*
|
||||||
* Note: "tooltip" doesn't equal to "tippy". "tooltip" means a auto-popup content, it just uses tippy as the implementation.
|
* Note: "tooltip" doesn't equal to "tippy". "tooltip" means a auto-popup content, it just uses tippy as the implementation.
|
||||||
*/
|
*/
|
||||||
function attachTooltip(target: Element, content: Content = null) {
|
function attachTooltip(target: Element, content: Content = null): Instance {
|
||||||
switchTitleToTooltip(target);
|
switchTitleToTooltip(target);
|
||||||
|
|
||||||
content = content ?? target.getAttribute('data-tooltip-content');
|
content = content ?? target.getAttribute('data-tooltip-content');
|
||||||
|
@ -77,16 +78,16 @@ function attachTooltip(target: Element, content: Content = null) {
|
||||||
const hasClipboardTarget = target.hasAttribute('data-clipboard-target');
|
const hasClipboardTarget = target.hasAttribute('data-clipboard-target');
|
||||||
const hideOnClick = !hasClipboardTarget;
|
const hideOnClick = !hasClipboardTarget;
|
||||||
|
|
||||||
const props = {
|
const props: TippyOpts = {
|
||||||
content,
|
content,
|
||||||
delay: 100,
|
delay: 100,
|
||||||
role: 'tooltip',
|
role: 'tooltip',
|
||||||
theme: 'tooltip',
|
theme: 'tooltip',
|
||||||
hideOnClick,
|
hideOnClick,
|
||||||
placement: target.getAttribute('data-tooltip-placement') || 'top-start',
|
placement: target.getAttribute('data-tooltip-placement') as Placement || 'top-start',
|
||||||
followCursor: target.getAttribute('data-tooltip-follow-cursor') || false,
|
followCursor: target.getAttribute('data-tooltip-follow-cursor') as Props['followCursor'] || false,
|
||||||
...(target.getAttribute('data-tooltip-interactive') === 'true' ? {interactive: true, aria: {content: 'describedby', expanded: false}} : {}),
|
...(target.getAttribute('data-tooltip-interactive') === 'true' ? {interactive: true, aria: {content: 'describedby', expanded: false}} : {}),
|
||||||
} as TippyOpts;
|
};
|
||||||
|
|
||||||
if (!target._tippy) {
|
if (!target._tippy) {
|
||||||
createTippy(target, props);
|
createTippy(target, props);
|
||||||
|
@ -96,7 +97,7 @@ function attachTooltip(target: Element, content: Content = null) {
|
||||||
return target._tippy;
|
return target._tippy;
|
||||||
}
|
}
|
||||||
|
|
||||||
function switchTitleToTooltip(target: Element) {
|
function switchTitleToTooltip(target: Element): void {
|
||||||
let title = target.getAttribute('title');
|
let title = target.getAttribute('title');
|
||||||
if (title) {
|
if (title) {
|
||||||
// apply custom formatting to relative-time's tooltips
|
// apply custom formatting to relative-time's tooltips
|
||||||
|
@ -121,14 +122,14 @@ function switchTitleToTooltip(target: Element) {
|
||||||
* Some browsers like PaleMoon don't support "addEventListener('mouseenter', capture)"
|
* Some browsers like PaleMoon don't support "addEventListener('mouseenter', capture)"
|
||||||
* The tippy by default uses "mouseenter" event to show, so we use "mouseover" event to switch to tippy
|
* The tippy by default uses "mouseenter" event to show, so we use "mouseover" event to switch to tippy
|
||||||
*/
|
*/
|
||||||
function lazyTooltipOnMouseHover(e: MouseEvent) {
|
function lazyTooltipOnMouseHover(e: MouseEvent): void {
|
||||||
e.target.removeEventListener('mouseover', lazyTooltipOnMouseHover, true);
|
e.target.removeEventListener('mouseover', lazyTooltipOnMouseHover, true);
|
||||||
attachTooltip(this);
|
attachTooltip(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Activate the tooltip for current element.
|
// Activate the tooltip for current element.
|
||||||
// If the element has no aria-label, use the tooltip content as aria-label.
|
// If the element has no aria-label, use the tooltip content as aria-label.
|
||||||
function attachLazyTooltip(el: Element) {
|
function attachLazyTooltip(el: Element): void {
|
||||||
el.addEventListener('mouseover', lazyTooltipOnMouseHover, {capture: true});
|
el.addEventListener('mouseover', lazyTooltipOnMouseHover, {capture: true});
|
||||||
|
|
||||||
// meanwhile, if the element has no aria-label, use the tooltip content as aria-label
|
// meanwhile, if the element has no aria-label, use the tooltip content as aria-label
|
||||||
|
@ -141,13 +142,13 @@ function attachLazyTooltip(el: Element) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Activate the tooltip for all children elements.
|
// Activate the tooltip for all children elements.
|
||||||
function attachChildrenLazyTooltip(target: Element) {
|
function attachChildrenLazyTooltip(target: Element): void {
|
||||||
for (const el of target.querySelectorAll<Element>('[data-tooltip-content]')) {
|
for (const el of target.querySelectorAll<Element>('[data-tooltip-content]')) {
|
||||||
attachLazyTooltip(el);
|
attachLazyTooltip(el);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function initGlobalTooltips() {
|
export function initGlobalTooltips(): void {
|
||||||
// use MutationObserver to detect new "data-tooltip-content" elements added to the DOM, or attributes changed
|
// use MutationObserver to detect new "data-tooltip-content" elements added to the DOM, or attributes changed
|
||||||
const observerConnect = (observer: MutationObserver) => observer.observe(document, {
|
const observerConnect = (observer: MutationObserver) => observer.observe(document, {
|
||||||
subtree: true,
|
subtree: true,
|
||||||
|
@ -178,7 +179,7 @@ export function initGlobalTooltips() {
|
||||||
attachChildrenLazyTooltip(document.documentElement);
|
attachChildrenLazyTooltip(document.documentElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function showTemporaryTooltip(target: Element, content: Content) {
|
export function showTemporaryTooltip(target: Element, content: Content): void {
|
||||||
// if the target is inside a dropdown, the menu will be hidden soon
|
// if the target is inside a dropdown, the menu will be hidden soon
|
||||||
// so display the tooltip on the dropdown instead
|
// so display the tooltip on the dropdown instead
|
||||||
target = target.closest('.ui.dropdown') || target;
|
target = target.closest('.ui.dropdown') || target;
|
||||||
|
|
|
@ -2,7 +2,7 @@ import {sleep} from '../utils.ts';
|
||||||
|
|
||||||
const {appSubUrl} = window.config;
|
const {appSubUrl} = window.config;
|
||||||
|
|
||||||
export async function logoutFromWorker() {
|
export async function logoutFromWorker(): Promise<void> {
|
||||||
// wait for a while because other requests (eg: logout) may be in the flight
|
// wait for a while because other requests (eg: logout) may be in the flight
|
||||||
await sleep(5000);
|
await sleep(5000);
|
||||||
window.location.href = `${appSubUrl}/`;
|
window.location.href = `${appSubUrl}/`;
|
||||||
|
|
|
@ -54,3 +54,8 @@ export type Issue = {
|
||||||
merged: boolean;
|
merged: boolean;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type FomanticInitFunction = {
|
||||||
|
settings?: Record<string, any>,
|
||||||
|
(...args: any[]): any,
|
||||||
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ import {createElementFromAttrs, createElementFromHTML, querySingleVisibleElem} f
|
||||||
|
|
||||||
test('createElementFromHTML', () => {
|
test('createElementFromHTML', () => {
|
||||||
expect(createElementFromHTML('<a>foo<span>bar</span></a>').outerHTML).toEqual('<a>foo<span>bar</span></a>');
|
expect(createElementFromHTML('<a>foo<span>bar</span></a>').outerHTML).toEqual('<a>foo<span>bar</span></a>');
|
||||||
|
expect(createElementFromHTML('<tr data-x="1"><td>foo</td></tr>').outerHTML).toEqual('<tr data-x="1"><td>foo</td></tr>');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('createElementFromAttrs', () => {
|
test('createElementFromAttrs', () => {
|
||||||
|
|
|
@ -301,10 +301,17 @@ export function replaceTextareaSelection(textarea: HTMLTextAreaElement, text: st
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warning: Do not enter any unsanitized variables here
|
// Warning: Do not enter any unsanitized variables here
|
||||||
export function createElementFromHTML(htmlString: string): HTMLElement {
|
export function createElementFromHTML<T extends HTMLElement>(htmlString: string): T {
|
||||||
|
htmlString = htmlString.trim();
|
||||||
|
// some tags like "tr" are special, it must use a correct parent container to create
|
||||||
|
if (htmlString.startsWith('<tr')) {
|
||||||
|
const container = document.createElement('table');
|
||||||
|
container.innerHTML = htmlString;
|
||||||
|
return container.querySelector<T>('tr');
|
||||||
|
}
|
||||||
const div = document.createElement('div');
|
const div = document.createElement('div');
|
||||||
div.innerHTML = htmlString.trim();
|
div.innerHTML = htmlString;
|
||||||
return div.firstChild as HTMLElement;
|
return div.firstChild as T;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createElementFromAttrs(tagName: string, attrs: Record<string, any>, ...children: (Node|string)[]): HTMLElement {
|
export function createElementFromAttrs(tagName: string, attrs: Record<string, any>, ...children: (Node|string)[]): HTMLElement {
|
||||||
|
@ -340,3 +347,11 @@ export function querySingleVisibleElem<T extends HTMLElement>(parent: Element, s
|
||||||
if (candidates.length > 1) throw new Error(`Expected exactly one visible element matching selector "${selector}", but found ${candidates.length}`);
|
if (candidates.length > 1) throw new Error(`Expected exactly one visible element matching selector "${selector}", but found ${candidates.length}`);
|
||||||
return candidates.length ? candidates[0] as T : null;
|
return candidates.length ? candidates[0] as T : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function addDelegatedEventListener<T extends HTMLElement>(parent: Node, type: string, selector: string, listener: (elem: T, e: Event) => void | Promise<any>, options?: boolean | AddEventListenerOptions) {
|
||||||
|
parent.addEventListener(type, (e: Event) => {
|
||||||
|
const elem = (e.target as HTMLElement).closest(selector);
|
||||||
|
if (!elem) return;
|
||||||
|
listener(elem as T, e);
|
||||||
|
}, options);
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import emojis from '../../../assets/emoji.json';
|
import emojis from '../../../assets/emoji.json';
|
||||||
import {GET} from '../modules/fetch.ts';
|
import {GET} from '../modules/fetch.ts';
|
||||||
import type {Issue} from '../features/issue.ts';
|
import type {Issue} from '../types.ts';
|
||||||
|
|
||||||
const maxMatches = 6;
|
const maxMatches = 6;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue