Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[#55581] hover cards only in project share, not wp share

Tobias Dillmann5d186422589f
diff --git a/app/components/shares/invite_user_form_component.html.erb b/app/components/shares/invite_user_form_component.html.erb
index dea952c59aa..f1bc280c58b 100644
--- a/app/components/shares/invite_user_form_component.html.erb
+++ b/app/components/shares/invite_user_form_component.html.erb
@@ -10,7 +10,7 @@
) do |form|
grid_layout('invite-user-form', tag: :div) do |invite_form|
invite_form.with_area('invitee') do
- render(Shares::Invitee.new(form))
+ render(Shares::Invitee.new(form, allow_hover_cards:))
end
invite_form.with_area('permission') do
diff --git a/app/components/shares/invite_user_form_component.rb b/app/components/shares/invite_user_form_component.rb
index f8d40024bae..07f5559506f 100644
--- a/app/components/shares/invite_user_form_component.rb
+++ b/app/components/shares/invite_user_form_component.rb
@@ -32,14 +32,15 @@ module Shares
include OpTurbo::Streamable
include OpPrimer::ComponentHelpers
- attr_reader :entity, :strategy, :errors
+ attr_reader :entity, :strategy, :errors, :allow_hover_cards
- def initialize(strategy:, errors: nil)
+ def initialize(strategy:, errors: nil, allow_hover_cards: false)
super
@strategy = strategy
@entity = strategy.entity
@errors = errors
+ @allow_hover_cards = allow_hover_cards
end
def new_share
diff --git a/app/components/shares/manage_shares_component.html.erb b/app/components/shares/manage_shares_component.html.erb
index a584ee90d85..af18bb5f422 100644
--- a/app/components/shares/manage_shares_component.html.erb
+++ b/app/components/shares/manage_shares_component.html.erb
@@ -1,7 +1,7 @@
<%=
if strategy.manageable?
modal_content.with_row do
- render(Shares::InviteUserFormComponent.new(strategy:, errors: errors))
+ render(Shares::InviteUserFormComponent.new(strategy:, errors:, allow_hover_cards:))
end
end
@@ -100,13 +100,15 @@
end
else
strategy.shares.each do |share|
- render(Shares::ShareRowComponent.new(share:, strategy:, container: border_box))
+ render(Shares::ShareRowComponent.new(share:, strategy:, container: border_box, allow_hover_cards:))
end
end
end
end
- modal_content.with_row do
- helpers.angular_component_tag 'opce-custom-modal-overlay', class: 'op-user-share-modal-overlay'
+ if allow_hover_cards
+ modal_content.with_row do
+ helpers.angular_component_tag 'opce-custom-modal-overlay', class: 'op-user-share-modal-overlay'
+ end
end
%>
diff --git a/app/components/shares/manage_shares_component.rb b/app/components/shares/manage_shares_component.rb
index fa61c6afdd5..22246aed01a 100644
--- a/app/components/shares/manage_shares_component.rb
+++ b/app/components/shares/manage_shares_component.rb
@@ -36,6 +36,7 @@ module Shares
attr_reader :strategy,
:entity,
:errors,
+ :allow_hover_cards,
:modal_content
def initialize(strategy:, modal_content:, errors: nil)
@@ -45,6 +46,7 @@ module Shares
@entity = strategy.entity
@errors = errors
@modal_content = modal_content
+ @allow_hover_cards = strategy.allow_hover_cards?
end
def self.wrapper_key
diff --git a/app/components/shares/share_row_component.html.erb b/app/components/shares/share_row_component.html.erb
index 29ba414445d..47c931db3e7 100644
--- a/app/components/shares/share_row_component.html.erb
+++ b/app/components/shares/share_row_component.html.erb
@@ -14,7 +14,7 @@
user_row_grid.with_area(:avatar, tag: :div) do
render(Users::AvatarComponent.new(user: principal, show_name: false, size: :medium,
- hover_card: { active: true, target: :custom }))
+ hover_card: { active: allow_hover_cards, target: :custom }))
end
user_row_grid.with_area(:user_details, tag: :div, classes: 'ellipsis') do
diff --git a/app/components/shares/share_row_component.rb b/app/components/shares/share_row_component.rb
index 45df3ab20e0..ae3b9845768 100644
--- a/app/components/shares/share_row_component.rb
+++ b/app/components/shares/share_row_component.rb
@@ -36,7 +36,7 @@ module Shares
include OpTurbo::Streamable
include OpPrimer::ComponentHelpers
- def initialize(share:, strategy:, container: nil)
+ def initialize(share:, strategy:, container: nil, allow_hover_cards: false)
super
@share = share
@@ -45,6 +45,7 @@ module Shares
@principal = share.principal
@available_roles = strategy.available_roles
@container = container
+ @allow_hover_cards = allow_hover_cards
end
def wrapper_uniq_by
@@ -53,7 +54,7 @@ module Shares
private
- attr_reader :share, :entity, :principal, :container, :available_roles, :strategy
+ attr_reader :share, :entity, :principal, :container, :available_roles, :strategy, :allow_hover_cards
def share_editable?
@share_editable ||= User.current != share.principal && sharing_manageable?
diff --git a/app/forms/shares/invitee.rb b/app/forms/shares/invitee.rb
index 7b373f0c2dc..c60ed79d1c3 100644
--- a/app/forms/shares/invitee.rb
+++ b/app/forms/shares/invitee.rb
@@ -52,14 +52,16 @@ module Shares
focusDirectly: true,
appendToComponent: true,
disabled: @disabled,
- isOpenedInModal: true
+ isOpenedInModal: true,
+ hoverCards: @allow_hover_cards
}
)
end
- def initialize(disabled: false)
+ def initialize(disabled: false, allow_hover_cards: false)
super()
@disabled = disabled
+ @allow_hover_cards = allow_hover_cards
end
end
end
diff --git a/app/models/sharing_strategies/base_strategy.rb b/app/models/sharing_strategies/base_strategy.rb
index bff01d94d89..25c00ff2e85 100644
--- a/app/models/sharing_strategies/base_strategy.rb
+++ b/app/models/sharing_strategies/base_strategy.rb
@@ -50,6 +50,10 @@ module SharingStrategies
raise NotImplementedError, "Override in a subclass and return true if the current user can manage sharing"
end
+ def allow_hover_cards?
+ raise NotImplementedError, "Override in a subclass and return true if hover cards should appear hovering users"
+ end
+
def create_contract_class
raise NotImplementedError, "Override in a subclass and return the contract class for creating a share"
end
diff --git a/app/models/sharing_strategies/project_query_strategy.rb b/app/models/sharing_strategies/project_query_strategy.rb
index eb05b1970d7..7a898438bb6 100644
--- a/app/models/sharing_strategies/project_query_strategy.rb
+++ b/app/models/sharing_strategies/project_query_strategy.rb
@@ -54,6 +54,10 @@ module SharingStrategies
@entity.visible?
end
+ def allow_hover_cards?
+ true
+ end
+
def create_contract_class
Shares::ProjectQueries::CreateContract
end
diff --git a/app/models/sharing_strategies/work_package_strategy.rb b/app/models/sharing_strategies/work_package_strategy.rb
index 556767dc08a..018c6b0f5c7 100644
--- a/app/models/sharing_strategies/work_package_strategy.rb
+++ b/app/models/sharing_strategies/work_package_strategy.rb
@@ -53,6 +53,13 @@ module SharingStrategies
user.allowed_in_project?(:view_shared_work_packages, @entity.project)
end
+ # Since the work package share dialog is embedded into an angular page, hover cards would compete for the
+ # portal outlet when rendering, causing bugs. Until the work package share dialog is refactored to be an
+ # async-dialog, we must disable hover cards for it.
+ def allow_hover_cards?
+ false
+ end
+
def share_description(share) # rubocop:disable Metrics/PerceivedComplexity,Metrics/AbcSize
scope = %i[sharing user_details]
diff --git a/frontend/src/app/shared/components/autocompleter/user-autocompleter/user-autocompleter-template.component.html b/frontend/src/app/shared/components/autocompleter/user-autocompleter/user-autocompleter-template.component.html
index 93c0ca81458..e7753cd2dfa 100644
--- a/frontend/src/app/shared/components/autocompleter/user-autocompleter/user-autocompleter-template.component.html
+++ b/frontend/src/app/shared/components/autocompleter/user-autocompleter/user-autocompleter-template.component.html
@@ -7,6 +7,7 @@
*ngIf="item && item.href"
[principal]="item"
[hideName]="true"
+ [hoverCard]="hoverCards"
[hoverCardModalTarget]="isOpenedInModal ? 'custom' : 'default'"
size="mini"
></op-principal>
diff --git a/frontend/src/app/shared/components/autocompleter/user-autocompleter/user-autocompleter-template.component.ts b/frontend/src/app/shared/components/autocompleter/user-autocompleter/user-autocompleter-template.component.ts
index 66518a14878..8861ebdca3c 100644
--- a/frontend/src/app/shared/components/autocompleter/user-autocompleter/user-autocompleter-template.component.ts
+++ b/frontend/src/app/shared/components/autocompleter/user-autocompleter/user-autocompleter-template.component.ts
@@ -43,6 +43,7 @@ import { IAutocompleterTemplateComponent } from 'core-app/shared/components/auto
export class UserAutocompleterTemplateComponent implements IAutocompleterTemplateComponent {
@Input() public inviteUserToProject:string|undefined;
@Input() public isOpenedInModal:boolean = false;
+ @Input() public hoverCards:boolean = true;
@ViewChild('optionTemplate') optionTemplate:TemplateRef<Element>;
@ViewChild('footerTemplate') footerTemplate?:TemplateRef<Element>;
diff --git a/frontend/src/app/shared/components/autocompleter/user-autocompleter/user-autocompleter.component.ts b/frontend/src/app/shared/components/autocompleter/user-autocompleter/user-autocompleter.component.ts
index 3de589bdec4..c7188cb09cf 100644
--- a/frontend/src/app/shared/components/autocompleter/user-autocompleter/user-autocompleter.component.ts
+++ b/frontend/src/app/shared/components/autocompleter/user-autocompleter/user-autocompleter.component.ts
@@ -88,6 +88,7 @@ export class UserAutocompleterComponent extends OpAutocompleterComponent<IUserAu
@Input() public inviteUserToProject:string|undefined;
@Input() public isOpenedInModal:boolean = false;
+ @Input() public hoverCards:boolean = true;
@Input() public url:string = this.apiV3Service.users.path;
@@ -103,6 +104,7 @@ export class UserAutocompleterComponent extends OpAutocompleterComponent<IUserAu
this.applyTemplates(UserAutocompleterTemplateComponent, {
inviteUserToProject: this.inviteUserToProject,
isOpenedInModal: this.isOpenedInModal,
+ hoverCards: this.hoverCards,
});
this