From c3b2e44392e7f6c9a77a46664788c0bb9a6f33cb Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Wed, 19 Oct 2022 14:40:28 +0200 Subject: Add team member invite by email (#20307) Allows to add (not registered) team members by email. related #5353 Invite by mail: ![grafik](https://user-images.githubusercontent.com/1666336/178154779-adcc547f-c0b7-4a2a-a131-4e41a3d9d3ad.png) Pending invitations: ![grafik](https://user-images.githubusercontent.com/1666336/178154882-9d739bb8-2b04-46c1-a025-c1f4be26af98.png) Email: ![grafik](https://user-images.githubusercontent.com/1666336/178164716-f2f90893-7ba6-4a5e-a3db-42538a660258.png) Join form: ![grafik](https://user-images.githubusercontent.com/1666336/178154840-aaab983a-d922-4414-b01a-9b1a19c5cef7.png) Co-authored-by: Jack Hay --- web_src/js/features/comp/SearchUserBox.js | 15 ++++++++++++++- web_src/less/_organization.less | 5 +++++ 2 files changed, 19 insertions(+), 1 deletion(-) (limited to 'web_src') 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}; } }, diff --git a/web_src/less/_organization.less b/web_src/less/_organization.less index b80739671f..c52753e29b 100644 --- a/web_src/less/_organization.less +++ b/web_src/less/_organization.less @@ -119,6 +119,11 @@ margin-top: -3px; } } + + .ui.avatar { + width: 100%; + height: 100%; + } } &.members { -- cgit v1.2.3