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

[#59925] autocompleters: only show hover card for users

Tobias Dillmann3eb1fa74d453
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 5e7d374a59f..192998cfa64 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
@@ -13,7 +13,7 @@
></op-principal>
<span [opSearchHighlight]="search"
[attr.data-hover-card-target]="getHoverCardTarget()"
- [attr.data-hover-card-url]="getHoverCardUrl(item.id)"
+ [attr.data-hover-card-url]="getHoverCardUrl(item)"
class="op-user-autocompleter--name op-hover-card--preview-trigger">
{{ item.name }}
</span>
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 f1c7052a027..610c16e3795 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
@@ -32,6 +32,8 @@ import {
} from 'core-app/shared/components/autocompleter/op-autocompleter/op-autocompleter.component';
import { PathHelperService } from 'core-app/core/path-helper/path-helper.service';
import { PortalOutletTarget } from 'core-app/shared/components/modal/portal-outlet-target.enum';
+import { PrincipalLike } from 'core-app/shared/components/principal/principal-types';
+import { hrefFromPrincipal, typeFromHref } from 'core-app/shared/components/principal/principal-helper';
@Component({
templateUrl: './user-autocompleter-template.component.html',
@@ -52,7 +54,14 @@ export class UserAutocompleterTemplateComponent implements IAutocompleterTemplat
return this.isOpenedInModal ? PortalOutletTarget.Custom : PortalOutletTarget.Default;
}
- public getHoverCardUrl(id:string) {
- return this.hoverCards ? this.pathHelperService.userHoverCardPath(id) : '';
+ public getHoverCardUrl(principal:PrincipalLike) {
+ if (!this.hoverCards || !principal.id) { return ''; }
+
+ const type = typeFromHref(hrefFromPrincipal(principal));
+ if (!type || type !== 'user') {
+ return '';
+ }
+
+ return this.pathHelperService.userHoverCardPath(principal.id);
}
}