diff options
author | KN4CK3R <admin@oldschoolhack.me> | 2022-10-19 14:40:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-19 14:40:28 +0200 |
commit | c3b2e44392e7f6c9a77a46664788c0bb9a6f33cb (patch) | |
tree | 6fe65807cd30770951ede4396a149ce03fb56b96 /web_src/js/features/comp | |
parent | 7d1aed83f4d0cdf096ec8758ff8a85ddccf1328d (diff) | |
download | gitea-c3b2e44392e7f6c9a77a46664788c0bb9a6f33cb.tar.gz gitea-c3b2e44392e7f6c9a77a46664788c0bb9a6f33cb.zip |
Add team member invite by email (#20307)
Allows to add (not registered) team members by email.
related #5353
Invite by mail:

Pending invitations:

Email:

Join form:

Co-authored-by: Jack Hay <jjphay@gmail.com>
Diffstat (limited to 'web_src/js/features/comp')
-rw-r--r-- | web_src/js/features/comp/SearchUserBox.js | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/web_src/js/features/comp/SearchUserBox.js b/web_src/js/features/comp/SearchUserBox.js index 08f97595af..46ecb8ebf4 100644 --- a/web_src/js/features/comp/SearchUserBox.js +++ b/web_src/js/features/comp/SearchUserBox.js @@ -3,15 +3,20 @@ import {htmlEscape} from 'escape-goat'; const {appSubUrl} = window.config; +const looksLikeEmailAddressCheck = /^\S+@\S+$/; + export function initCompSearchUserBox() { const $searchUserBox = $('#search-user-box'); + const allowEmailInput = $searchUserBox.attr('data-allow-email') === 'true'; + const allowEmailDescription = $searchUserBox.attr('data-allow-email-description'); $searchUserBox.search({ minCharacters: 2, apiSettings: { url: `${appSubUrl}/user/search?q={query}`, onResponse(response) { const items = []; - const searchQueryUppercase = $searchUserBox.find('input').val().toUpperCase(); + const searchQuery = $searchUserBox.find('input').val(); + const searchQueryUppercase = searchQuery.toUpperCase(); $.each(response.data, (_i, item) => { let title = item.login; if (item.full_name && item.full_name.length > 0) { @@ -28,6 +33,14 @@ export function initCompSearchUserBox() { } }); + if (allowEmailInput && items.length === 0 && looksLikeEmailAddressCheck.test(searchQuery)) { + const resultItem = { + title: searchQuery, + description: allowEmailDescription + }; + items.push(resultItem); + } + return {results: items}; } }, |