Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#58144] Show email on the UI for users with permission #16919

Draft
wants to merge 26 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e453fcc
[#58144] Show email on the UI for users with permission
dombesz Oct 8, 2024
85cfefe
Add migration spec
dombesz Oct 8, 2024
5cfe28a
Fix specs
dombesz Oct 8, 2024
4f759ea
Remove hideMail flag from the frontend and documentation
dombesz Oct 8, 2024
3a81b7c
Fix specs
dombesz Oct 8, 2024
cf810d2
Do not allow searching for email without view email permission
dombesz Oct 8, 2024
ad0b57c
Fix specs
dombesz Oct 9, 2024
f208254
Enable email signaling and display emails in user autocompleters.
dombesz Oct 10, 2024
8e2263d
Do not truncate the whole user option completely but rather the part …
HDinger Oct 10, 2024
fcde3cd
Simplify the autocompleter layout, plus fix truncation issue on small…
dombesz Oct 10, 2024
e86ae7b
Apply autocompleter emails to the invite user modal.
dombesz Oct 10, 2024
f1c63d5
Add email to user related autocomplete filters
dombesz Oct 10, 2024
849b575
Make the autocompleter aligned on the team planner and the assignee b…
dombesz Oct 10, 2024
e0472a1
Fix specs
dombesz Oct 11, 2024
f4d1be0
Add user invitation, work package share, user signal rendering specs
dombesz Oct 16, 2024
cb1330c
Changes from dev
EinLama Oct 22, 2024
c17298b
fix typo, add mini spec
EinLama Oct 22, 2024
55edced
fix specs
EinLama Oct 22, 2024
9799391
first assignee spec
EinLama Oct 23, 2024
1bd1ae2
set accountable spec
EinLama Oct 23, 2024
bc2f0d0
use existing helpers when available
EinLama Oct 23, 2024
960e039
minor refactors
EinLama Oct 24, 2024
d79c822
watcher specs
EinLama Oct 24, 2024
fd87de5
refactor work package specs to also use global roles
EinLama Oct 24, 2024
d4c7871
Move autocomplete helper to the proper place
EinLama Oct 24, 2024
5d1cfc3
filter search spec
EinLama Oct 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions app/components/members/row_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ def name
end

def mail
return unless user?
return if principal.pref.hide_mail
return unless user? && user_is_allowed_to_see_email

link = mail_to(principal.mail)

Expand Down Expand Up @@ -288,5 +287,9 @@ def principal_show_path
def user?
principal.is_a?(User)
end

def user_is_allowed_to_see_email
(principal == User.current) || User.current.allowed_globally?(:view_user_email)
end
end
end
2 changes: 1 addition & 1 deletion app/components/users/profile/attributes_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

component_wrapper do
flex_layout do |details_container|
if @user.pref.can_expose_mail?
if user_is_allowed_to_see_email
details_container.with_row(font_weight: :bold) do
User.human_attribute_name(:mail)
end
Expand Down
6 changes: 5 additions & 1 deletion app/components/users/profile/attributes_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def initialize(user:)
end

def render?
@user.pref.can_expose_mail? || @user.visible_custom_field_values.any? { _1.value.present? }
user_is_allowed_to_see_email || @user.visible_custom_field_values.any? { _1.value.present? }
end

def visible_custom_fields
Expand All @@ -51,6 +51,10 @@ def visible_custom_fields
.keys
.sort_by(&:name)
end

def user_is_allowed_to_see_email
User.current == @user || User.current.allowed_globally?(:view_user_email)
end
end
end
end
2 changes: 1 addition & 1 deletion app/models/permitted_params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def wiki_page
end

def pref
params.fetch(:pref, {}).permit(:hide_mail, :time_zone, :theme,
params.fetch(:pref, {}).permit(:time_zone, :theme,
:comments_sorting, :warn_on_leaving_unsaved,
:auto_hide_popups)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def available_operators
end

def email_field_allowed?
true
User.current.allowed_globally?(:view_user_email)
end

private
Expand Down
4 changes: 0 additions & 4 deletions app/models/queries/principals/filters/typeahead_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ def type
:search
end

def email_field_allowed?
User.current.allowed_globally?(:view_user_email)
end

def human_name
I18n.t("label_search")
end
Expand Down
8 changes: 0 additions & 8 deletions app/models/user_preference.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,6 @@ def diff_type
settings.fetch(:diff_type, "inline")
end

def hide_mail
settings.fetch(:hide_mail, true)
end

def can_expose_mail?
!hide_mail
end

def auto_hide_popups=(value)
settings[:auto_hide_popups] = to_boolean(value)
end
Expand Down
2 changes: 0 additions & 2 deletions app/services/user_preferences/set_attributes_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
module UserPreferences
class SetAttributesService < ::BaseServices::SetAttributes
def set_attributes(params)
set_boolean_value(:hide_mail, params.delete(:hide_mail)) if params.key?(:hide_mail)

params.each do |k, v|
model[k] = v if model.supported_settings_method?(k)
end
Expand Down
4 changes: 3 additions & 1 deletion app/views/common/feed.atom.builder
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do
if author
xml.author do
xml.name(author)
xml.email(author.mail) if author.is_a?(User) && author.mail.present? && author.pref.can_expose_mail?
if author.is_a?(User) && author.mail.present? && User.current.allowed_globally?(:view_user_email)
xml.email(author.mail)
end
end
end
xml.content "type" => "html" do
Expand Down
4 changes: 3 additions & 1 deletion app/views/journals/index.atom.builder
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do
xml.updated change.created_at.xmlschema
xml.author do
xml.name change.user.name
xml.email(change.user.mail) if change.user.is_a?(User) && change.user.mail.present? && change.user.pref.can_expose_mail?
if change.user.is_a?(User) && change.user.mail.present? && User.current.allowed_globally?(:view_user_email)
xml.email(change.user.mail)
end
end
xml.content "type" => "html" do
xml.text! "<ul>"
Expand Down
4 changes: 0 additions & 4 deletions app/views/my/account.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@ See COPYRIGHT and LICENSE files for more details.
<% end %>
</div>

<%= fields_for :pref, @user.pref, builder: TabularFormBuilder, lang: current_language do |pref_fields| %>
<div class="form--field"><%= pref_fields.check_box :hide_mail %></div>
<% end %>

<%= call_hook(:view_my_account, user: @user, form: f) %>

<%= render partial: "customizable/form",
Expand Down
1 change: 0 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,6 @@ en:
consented_at: "Consented at"
user_preference:
comments_sorting: "Display comments"
hide_mail: "Hide my email address"
impaired: "Accessibility mode"
time_zone: "Time zone"
auto_hide_popups: "Auto-hide success notifications"
Expand Down
3 changes: 0 additions & 3 deletions config/schemas/user_preferences.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
"type": "object",
"additionalProperties": false,
"properties": {
"hide_mail": {
"type": "boolean"
},
"time_zone": {
"type": ["string", "null"]
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class RemoveHideMailFromUserPreferences < ActiveRecord::Migration[7.1]
def up
execute <<~SQL.squish
UPDATE user_preferences
SET settings = settings - 'hide_mail'
SQL
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ example:
method: "patch"
_type: UserPreferences
commentSortDescending: true
hideMail: false
timeZone: "Europe/Berlin"
warnOnLeavingUnsaved: true
notifications:
Expand Down
2 changes: 0 additions & 2 deletions docs/api/apiv3/paths/my_preferences.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ get:
method: "patch"
_type: "UserPreferences"
commentSortDescending: true
hideMail: false
timeZone: "Europe/Berlin"
warnOnLeavingUnsaved: true
notifications:
Expand Down Expand Up @@ -83,7 +82,6 @@ patch:
method: "patch"
_type: UserPreferences
commentSortDescending: true
hideMail: false
timeZone: Europe/Berlin
warnOnLeavingUnsaved: true
notifications:
Expand Down
1 change: 0 additions & 1 deletion docs/api/apiv3/tags/userpreferences.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ description: |-
| Property | Description | Type | Constraints | Supported operations |
|:----------------------:| ----------------------------------------------------------- | ---------- | ----------- | -------------------- |
| autoHidePopups | Whether to hide popups (e.g. success messages) after 5 seconds | Boolean | | READ / WRITE |
| hideMail | Hide mail address from other users | Boolean | | READ / WRITE |
| notifications | The settings for the notifications to be received by the user | NotificationSetting | | READ / WRITE |
| timeZone | Current selected time zone | String | | READ / WRITE |
| commentSortDescending | Sort comments in descending order | Boolean | | READ / WRITE |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@
class="ng-option-label"
>
<!--Selectable option-->
<div [ngOptionHighlight]="search">{{ item.principal.name }}</div>
<span [ngOptionHighlight]="search">{{ item.principal.name }}</span>
<span
class="op-autocompleter__option-principal-email"
*ngIf="item.principal.email"
[ngOptionHighlight]="search">{{ item.principal.email }}</span>

<!-- Already a member of the project -->
<div
*ngIf="item.disabled"
class="ellipsis"
>{{ text.alreadyAMember() }}</div>
class="ellipsis">{{ text.alreadyAMember() }}</div>
</div>
</ng-template>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@import '../../global_styles/openproject/variables'

.op-autocompleter
&__option-principal-email
color: var(--fgColor-muted)
font-size: var(--font-size-small)
margin-left: var(--stack-gap-condensed)

@media screen and (max-width: $breakpoint-sm)
&__option-principal-email
display: block
margin-left: 0
margin-top: var(--control-xsmall-gap)
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
ChangeDetectionStrategy,
Component,
Input,
EventEmitter,
Expand Down Expand Up @@ -39,7 +40,9 @@ interface NgSelectPrincipalOption {

@Component({
selector: 'op-ium-principal-search',
styleUrls: ['./principal-search.component.sass'],
templateUrl: './principal-search.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class PrincipalSearchComponent extends UntilDestroyedMixin implements OnInit {
@Input() spotFormBinding:UntypedFormControl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export interface ImmediateRemindersSettings {
export interface IUserPreference {
autoHidePopups:boolean;
commentSortDescending:boolean;
hideMail:boolean;
timeZone:string|null;
warnOnLeavingUnsaved:boolean;
workdays:number[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ function createInitialState():IUserPreference {
return {
autoHidePopups: true,
commentSortDescending: false,
hideMail: true,
timeZone: null,
warnOnLeavingUnsaved: true,
notifications: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,21 +180,27 @@
</ng-container>

<ng-container *ngSwitchCase="resource ==='users' || resource ==='assignee' || resource === 'principals'">
<div class="op-autocompleter--option-principal-wrapper">
<op-principal
*ngIf="item && item.href"
[principal]="item"
[hideName]="true"
class="op-autocompleter--option-principal-avatar"
size="mini"
></op-principal>
<span [ngOptionHighlight]="search" class="ellipsis">{{ item.name }}</span>
</div>
<op-principal
*ngIf="item && item.href"
[principal]="item"
[hideName]="true"
class="op-autocompleter--option-principal-avatar"
size="mini"
></op-principal>
<span [ngOptionHighlight]="search">{{ item.name }}</span>
<span
class="op-autocompleter__option-principal-email"
*ngIf="item.email"
[ngOptionHighlight]="search">{{ item.email }}</span>
</ng-container>

<ng-container
*ngSwitchCase="resource ==='subproject' || resource ==='version' || resource ==='status' || resource ==='default' || !resource">
<span [ngOptionHighlight]="search">{{ item.name }}</span>
<span
class="op-autocompleter__option-principal-email"
*ngIf="item.email"
[ngOptionHighlight]="search">{{ item.email }}</span>
</ng-container>
</ng-template>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import '../../global_styles/openproject/variables'

.op-autocompleter
&--option-wrapper
padding: 5px 5px
Expand Down Expand Up @@ -47,7 +49,15 @@
white-space: nowrap
text-overflow: ellipsis

&--option-principal
&-wrapper
display: flex
overflow: hidden
&__option-principal-email
color: var(--fgColor-muted)
font-size: var(--font-size-small)
margin-left: var(--stack-gap-condensed)

@media screen and (max-width: $breakpoint-sm)
&__option-principal-email
display: block
margin-left: 0
margin-top: var(--control-xsmall-gap)
&--option-principal-avatar + span + &__option-principal-email
margin-left: var(--control-small-size)
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
class="op-user-autocompleter--name">
{{ item.name }}
</span>
<span
class="op-autocompleter__option-principal-email"
*ngIf="item.email"
[opSearchHighlight]="search"
>{{ item.email }}</span>
</ng-template>
<ng-template #footerTemplate *ngIf="inviteUserToProject">
<op-invite-user-button
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@import '../../global_styles/openproject/variables'

.op-autocompleter
&__option-principal-email
color: var(--fgColor-muted)
font-size: var(--font-size-small)
margin-left: var(--stack-gap-condensed)

@media screen and (max-width: $breakpoint-sm)
&__option-principal-email
display: block
margin-left: var(--control-small-size)
margin-top: var(--control-xsmall-gap)
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { IAutocompleterTemplateComponent } from 'core-app/shared/components/auto

@Component({
templateUrl: './user-autocompleter-template.component.html',
styleUrls: ['./user-autocompleter-template.component.sass'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class UserAutocompleterTemplateComponent implements IAutocompleterTemplateComponent {
Expand Down
Loading
Loading