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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Replace search title component with primer header
Oliver Günther1b2157bec5d1
diff --git a/app/views/search/index.html.erb b/app/views/search/index.html.erbindex 404dd236a4b..4932da1a133 100644--- a/app/views/search/index.html.erb+++ b/app/views/search/index.html.erb@@ -29,10 +29,34 @@ See COPYRIGHT and LICENSE files for more details.<% content_for :header_tags do %><%= call_hook :search_index_head %>-<% end %>-<opce-global-search-title></opce-global-search-title>+<%=+ render(Primer::OpenProject::PageHeader.new) do |header|+ title =+ case @search_params[:scope]+ when "all"+ t("global_search.title.all_projects", search_term: @question)+ when "current_project"+ t("global_search.title.current_project", search_term: @question, project_name: @project.name)+ else+ if @project+ t("global_search.title.project_and_subprojects", search_term: @question, project_name: @project.name)+ else+ t("global_search.title.all_projects", search_term: @question)+ end+ end++ header.with_title { title }++ header.with_breadcrumbs(+ [+ ({ href: project_overview_path(@project.id), text: @project.name } if @project),+ title+ ].compact+ )+ end+%><opce-global-search-tabs></opce-global-search-tabs>diff --git a/config/locales/en.yml b/config/locales/en.ymlindex d7fa2e7f07b..c3ee8304999 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -393,6 +393,10 @@ en:blueprint: "Pattern blueprint"global_search:+ title:+ all_projects: 'Search for "%{search_term}" in all projects'+ current_project: 'Search for "%{search_term}" in %{project_name}'+ project_and_subprojects: 'Search for "%{search_term}" in %{project_name} and all subprojects'placeholder: "Search in %{app_title}"overwritten_tabs:all: "All"diff --git a/frontend/src/app/core/global_search/openproject-global-search.module.ts b/frontend/src/app/core/global_search/openproject-global-search.module.tsindex 5b14b2b0cf4..c1fba2d5d0e 100644--- a/frontend/src/app/core/global_search/openproject-global-search.module.ts+++ b/frontend/src/app/core/global_search/openproject-global-search.module.ts@@ -31,7 +31,6 @@ import { OpenprojectWorkPackagesModule } from 'core-app/features/work-packages/oimport { GlobalSearchInputComponent } from 'core-app/core/global_search/input/global-search-input.component';import { GlobalSearchWorkPackagesComponent } from 'core-app/core/global_search/global-search-work-packages.component';import { GlobalSearchTabsComponent } from 'core-app/core/global_search/tabs/global-search-tabs.component';-import { GlobalSearchTitleComponent } from 'core-app/core/global_search/title/global-search-title.component';import { GlobalSearchService } from 'core-app/core/global_search/services/global-search.service';import {OpenprojectAutocompleterModule,@@ -53,7 +52,6 @@ import { RecentItemsService } from 'core-app/core/recent-items.service';GlobalSearchInputComponent,GlobalSearchWorkPackagesComponent,GlobalSearchTabsComponent,- GlobalSearchTitleComponent,],})export class OpenprojectGlobalSearchModule {diff --git a/frontend/src/app/core/global_search/title/global-search-title.component.html b/frontend/src/app/core/global_search/title/global-search-title.component.htmldeleted file mode 100644index f14e3bdbe61..00000000000--- a/frontend/src/app/core/global_search/title/global-search-title.component.html+++ /dev/null@@ -1,16 +0,0 @@-<op-breadcrumbs- [items]="breadcrumbItems()"-></op-breadcrumbs>-<div class="toolbar-container">- <div class="toolbar">- <div class="title-container">- <h2 [attr.title]="searchTitle">- {{ text.search_for }}- <i>"{{ searchTerm }}"</i>- {{ project === '' ? '' : text.in }}- <i>{{ project }}</i>- </h2>- <ul class="toolbar-items"></ul>- </div>- </div>-</div>diff --git a/frontend/src/app/core/global_search/title/global-search-title.component.ts b/frontend/src/app/core/global_search/title/global-search-title.component.tsdeleted file mode 100644index c7ad560d3a9..00000000000--- a/frontend/src/app/core/global_search/title/global-search-title.component.ts+++ /dev/null@@ -1,134 +0,0 @@-//-- copyright-// OpenProject is an open source project management software.-// Copyright (C) the OpenProject GmbH-//-// This program is free software; you can redistribute it and/or-// modify it under the terms of the GNU General Public License version 3.-//-// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-// Copyright (C) 2006-2013 Jean-Philippe Lang-// Copyright (C) 2010-2013 the ChiliProject Team-//-// This program is free software; you can redistribute it and/or-// modify it under the terms of the GNU General Public License-// as published by the Free Software Foundation; either version 2-// of the License, or (at your option) any later version.-//-// This program is distributed in the hope that it will be useful,-// but WITHOUT ANY WARRANTY; without even the implied warranty of-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-// GNU General Public License for more details.-//-// You should have received a copy of the GNU General Public License-// along with this program; if not, write to the Free Software-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-//-// See COPYRIGHT and LICENSE files for more details.-//++-import {- ChangeDetectionStrategy,- ChangeDetectorRef,- Component,- ElementRef,- Injector,- Input,- OnInit,-} from '@angular/core';-import { distinctUntilChanged } from 'rxjs/operators';-import { combineLatest } from 'rxjs';-import { I18nService } from 'core-app/core/i18n/i18n.service';-import { GlobalSearchService } from 'core-app/core/global_search/services/global-search.service';-import { CurrentProjectService } from 'core-app/core/current-project/current-project.service';-import { InjectField } from 'core-app/shared/helpers/angular/inject-field.decorator';-import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';-import { PathHelperService } from 'core-app/core/path-helper/path-helper.service';-import { OpTitleService } from 'core-app/core/html/op-title.service';--@Component({- selector: 'opce-global-search-title',- templateUrl: './global-search-title.component.html',- changeDetection: ChangeDetectionStrategy.OnPush,- standalone: false,-})-export class GlobalSearchTitleComponent extends UntilDestroyedMixin implements OnInit {- @Input() public searchTerm:string;-- @Input() public project:string;-- @Input() public projectScope:string;-- @Input() public searchTitle:string;-- @InjectField() private currentProjectService:CurrentProjectService;-- public text:{ [key:string]:string } = {- all_projects: this.I18n.t('js.global_search.title.all_projects'),- project_and_subprojects: this.I18n.t('js.global_search.title.project_and_subprojects'),- search_for: this.I18n.t('js.global_search.title.search_for'),- in: this.I18n.t('js.label_in'),- };-- constructor(- readonly elementRef:ElementRef,- readonly cdRef:ChangeDetectorRef,- readonly globalSearchService:GlobalSearchService,- readonly I18n:I18nService,- readonly injector:Injector,- protected readonly pathHelper:PathHelperService,- protected readonly titleService:OpTitleService,- ) {- super();- }-- ngOnInit() {- // Listen on changes of search input value and project scope- combineLatest([- this.globalSearchService.searchTerm$,- this.globalSearchService.projectScope$,- ])- .pipe(- distinctUntilChanged(),- this.untilDestroyed(),- )- .subscribe(([newSearchTerm, newProjectScope]) => {- this.searchTerm = newSearchTerm;- /* eslint-disable-next-line @typescript-eslint/no-unsafe-argument */- this.project = this.projectText(newProjectScope);- this.searchTitle = `${this.text.search_for} ${this.searchTerm} ${this.project === '' ? '' : this.text.in} ${this.project}`;-- this.cdRef.detectChanges();- });- }-- breadcrumbItems() {- const items = [];- items.push({- href: this.pathHelper.homePath(),- text: this.titleService.appTitle,- });- if (this.currentProjectService?.identifier) {- items.push({- href: this.pathHelper.projectPath(this.currentProjectService.identifier),- text: this.currentProjectService.name,- });- }- items.push(this.searchTitle);-- return items;- }-- private projectText(scope:string):string {- const currentProjectName = this.currentProjectService.name ? this.currentProjectService.name : '';-- switch (scope) {- case 'all':- return this.text.all_projects;- case 'current_project':- return currentProjectName;- case '':- return `${currentProjectName} ${this.text.project_and_subprojects}`;- default:- return '';- }- }-}