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

Fix title being set without base title

Oliver Günther22f8d4085843
diff --git a/app/views/layouts/_common_head.html.erb b/app/views/layouts/_common_head.html.erb
index ff5c3345103..1e895933c5f 100644
--- a/app/views/layouts/_common_head.html.erb
+++ b/app/views/layouts/_common_head.html.erb
@@ -4,6 +4,7 @@
<%= appsignal_frontend_tag %>
<% relative_url_root = OpenProject::Configuration['rails_relative_url_root'] || '' %>
+<meta name="app_title" content="<%= page_title(*html_title_parts) %>"/>
<meta name="app_base_path" content="<%= relative_url_root %>"/>
<base href="<%= relative_url_root %>/" />
<% if @project %>
diff --git a/frontend/src/app/core/html/op-title.service.ts b/frontend/src/app/core/html/op-title.service.ts
index c4b1f0bfb82..e244597f396 100644
--- a/frontend/src/app/core/html/op-title.service.ts
+++ b/frontend/src/app/core/html/op-title.service.ts
@@ -6,28 +6,15 @@ const titlePartsSeparator = ' | ';
@Injectable({ providedIn: 'root' })
export class OpTitleService {
constructor(private titleService:Title) {
-
- }
-
- public get current():string {
- return this.titleService.getTitle();
}
- public get titleParts():string[] {
- return this.current.split(titlePartsSeparator);
+ public get base():string {
+ const appTitle = document.querySelector('meta[name=app_title]') as HTMLMetaElement;
+ return appTitle.content;
}
public setFirstPart(value:string) {
- const parts = this.titleParts;
- parts[0] = value;
-
- this.titleService.setTitle(parts.join(titlePartsSeparator));
- }
-
- public prependFirstPart(value:string):void {
- const parts = this.titleParts;
- parts.unshift(value);
-
- this.titleService.setTitle(parts.join(titlePartsSeparator));
+ const newTitle = [value, this.base].join(titlePartsSeparator);
+ this.titleService.setTitle(newTitle);
}
}
diff --git a/frontend/src/app/shared/components/grids/grid/page/grid-page.component.ts b/frontend/src/app/shared/components/grids/grid/page/grid-page.component.ts
index 0267279a917..fe6a42d70ab 100644
--- a/frontend/src/app/shared/components/grids/grid/page/grid-page.component.ts
+++ b/frontend/src/app/shared/components/grids/grid/page/grid-page.component.ts
@@ -1,6 +1,5 @@
import { ChangeDetectorRef, Directive, OnDestroy, OnInit, Renderer2 } from '@angular/core';
import { I18nService } from 'core-app/core/i18n/i18n.service';
-import { Title } from '@angular/platform-browser';
import { GridInitializationService } from 'core-app/shared/components/grids/grid/initialization.service';
import { PathHelperService } from 'core-app/core/path-helper/path-helper.service';
import { GridResource } from 'core-app/features/hal/resources/grid-resource';
@@ -8,6 +7,7 @@ import { GridAddWidgetService } from 'core-app/shared/components/grids/grid/add-
import { GridAreaService } from 'core-app/shared/components/grids/grid/area.service';
import { CurrentProjectService } from 'core-app/core/current-project/current-project.service';
import { ConfigurationService } from 'core-app/core/config/configuration.service';
+import { OpTitleService } from 'core-app/core/html/op-title.service';
@Directive()
export abstract class GridPageComponent implements OnInit, OnDestroy {
@@ -25,7 +25,7 @@ export abstract class GridPageComponent implements OnInit, OnDestroy {
readonly currentProject:CurrentProjectService,
readonly i18n:I18nService,
readonly cdRef:ChangeDetectorRef,
- readonly title:Title,
+ readonly title:OpTitleService,
readonly addWidget:GridAddWidgetService,
readonly renderer:Renderer2,
readonly areas:GridAreaService,
@@ -57,7 +57,7 @@ export abstract class GridPageComponent implements OnInit, OnDestroy {
}
private setHtmlTitle() {
- this.title.setTitle(this.text.html_title);
+ this.title.setFirstPart(this.text.html_title);
}
protected abstract i18nNamespace():string;