Skip to content

Commit

Permalink
enableShowLoginIDWhenSearchUser
Browse files Browse the repository at this point in the history
  • Loading branch information
SkywalkerSpace committed Jun 18, 2024
1 parent bd6a21f commit 74ef597
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 9 deletions.
7 changes: 4 additions & 3 deletions frontend/src/components/user-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import AsyncSelect from 'react-select/async';
import { seafileAPI } from '../utils/seafile-api';
import { gettext, enableShowContactEmailWhenSearchUser } from '../utils/constants';
import { gettext, enableShowContactEmailWhenSearchUser, enableShowLoginIDWhenSearchUser } from '../utils/constants';
import { Utils } from '../utils/utils';
import toaster from './toast';
import { UserSelectStyle } from './common/select';
Expand Down Expand Up @@ -49,12 +49,13 @@ class UserSelect extends React.Component {
let obj = {};
obj.value = item.name;
obj.email = item.email;
obj.label = enableShowContactEmailWhenSearchUser ? (
obj.label = (enableShowContactEmailWhenSearchUser || enableShowLoginIDWhenSearchUser) ? (
<div className="d-flex">
<img src={item.avatar_url} className="avatar" width="24" alt="" />
<div className="ml-2">
<span className="user-option-name">{item.name}</span><br />
<span className="user-option-email">{item.contact_email}</span>
{enableShowContactEmailWhenSearchUser && <span className="user-option-email">{item.contact_email}</span>}
{enableShowLoginIDWhenSearchUser && <span className="user-option-email">{item.login_id}</span>}
</div>
</div>
) : (
Expand Down
1 change: 1 addition & 0 deletions frontend/src/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export const canInvitePeople = window.app.pageOptions.canInvitePeople;
export const canLockUnlockFile = window.app.pageOptions.canLockUnlockFile;
export const customNavItems = window.app.pageOptions.customNavItems;
export const enableShowContactEmailWhenSearchUser = window.app.pageOptions.enableShowContactEmailWhenSearchUser;
export const enableShowLoginIDWhenSearchUser = window.app.pageOptions.enableShowLoginIDWhenSearchUser;
export const maxUploadFileSize = window.app.pageOptions.maxUploadFileSize;
export const maxNumberOfFilesForFileupload = window.app.pageOptions.maxNumberOfFilesForFileupload;
export const enableOCM = window.app.pageOptions.enableOCM;
Expand Down
12 changes: 9 additions & 3 deletions seahub/api2/endpoints/search_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from seahub.avatar.templatetags.avatar_tags import api_avatar_url

from seahub.settings import ENABLE_GLOBAL_ADDRESSBOOK, \
ENABLE_SEARCH_FROM_LDAP_DIRECTLY
ENABLE_SEARCH_FROM_LDAP_DIRECTLY, ENABLE_SHOW_LOGIN_ID_WHEN_SEARCH_USER

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -175,15 +175,21 @@ def get(self, request, format=None):

def format_searched_user_result(request, users, size):
results = []
if ENABLE_SHOW_LOGIN_ID_WHEN_SEARCH_USER:
profile_queryset = Profile.objects.filter(user__in=users)
profile_dict = { p.user: p.login_id for p in profile_queryset if p.login_id }

for email in users:
url, is_default, date_uploaded = api_avatar_url(email, size)
results.append({
user_info = {
"email": email,
"avatar_url": url,
"name": email2nickname(email),
"contact_email": email2contact_email(email),
})
}
if ENABLE_SHOW_LOGIN_ID_WHEN_SEARCH_USER:
user_info['login_id'] = profile_dict.get(email, '')
results.append(user_info)

return results

Expand Down
4 changes: 1 addition & 3 deletions seahub/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@
ENABLE_WATERMARK = False

ENABLE_SHOW_CONTACT_EMAIL_WHEN_SEARCH_USER = False
ENABLE_SHOW_ID_IN_ORG_WHEN_SEARCH_USER = False
ENABLE_SHOW_LOGIN_ID_WHEN_SEARCH_USER = False

# enable work weixin
ENABLE_WORK_WEIXIN = False
Expand Down Expand Up @@ -758,8 +758,6 @@ def genpassword():
ENABLE_USER_SET_CONTACT_EMAIL = False
ENABLE_USER_SET_NAME = True

ENABLE_SHOW_ID_IN_ORG_WHEN_SEARCH_USER = False

# SSO to thirdparty website
ENABLE_SSO_TO_THIRDPART_WEBSITE = False
THIRDPART_WEBSITE_SECRET_KEY = ''
Expand Down
1 change: 1 addition & 0 deletions seahub/templates/base_for_react.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
canInvitePeople: {% if enable_guest_invitation and user.permissions.can_invite_guest %} true {% else %} false {% endif %},
customNavItems: {% if custom_nav_items %} JSON.parse('{{ custom_nav_items | escapejs }}') {% else %} {{'[]'}} {% endif %},
enableShowContactEmailWhenSearchUser: {% if enable_show_contact_email_when_search_user %} true {% else %} false {% endif %},
enableShowLoginIDWhenSearchUser: {% if enable_show_login_id_when_search_user %} true {% else %} false {% endif %},
{% if max_upload_file_size > 0 %}
maxUploadFileSize: {{ max_upload_file_size }},
{% endif %}
Expand Down
1 change: 1 addition & 0 deletions seahub/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,7 @@ def react_fake_view(request, **kwargs):
'file_audit_enabled': FILE_AUDIT_ENABLED,
'custom_nav_items': json.dumps(CUSTOM_NAV_ITEMS),
'enable_show_contact_email_when_search_user': settings.ENABLE_SHOW_CONTACT_EMAIL_WHEN_SEARCH_USER,
'enable_show_login_id_when_search_user': settings.ENABLE_SHOW_LOGIN_ID_WHEN_SEARCH_USER,
'additional_share_dialog_note': ADDITIONAL_SHARE_DIALOG_NOTE,
'additional_app_bottom_links': ADDITIONAL_APP_BOTTOM_LINKS,
'additional_about_dialog_links': ADDITIONAL_ABOUT_DIALOG_LINKS,
Expand Down

0 comments on commit 74ef597

Please sign in to comment.