Merge pull request #6802 from opf/feature/work-package-titles

[28885] Improve html title consistency when navigating to queries

[ci skip]
pull/6803/head
Oliver Günther 6 years ago committed by GitHub
commit c60b7560d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      frontend/src/app/components/routing/wp-list/wp-list.component.ts
  2. 34
      spec/features/work_packages/navigation_spec.rb
  3. 52
      spec/support/components/html_title.rb

@ -53,6 +53,7 @@ import {LoadingIndicatorService} from "core-app/modules/common/loading-indicator
import {I18nService} from "core-app/modules/common/i18n/i18n.service";
import {WorkPackageStaticQueriesService} from 'core-components/wp-query-select/wp-static-queries.service';
import {WorkPackageTableHighlightingService} from "core-components/wp-fast-table/state/wp-table-highlighting.service";
import {OpTitleService} from "core-components/html/op-title.service";
@Component({
selector: 'wp-list',
@ -70,7 +71,6 @@ export class WorkPackagesListComponent implements OnInit, OnDestroy {
tableInformationLoaded = false;
selectedTitle?:string;
staticTitle?:string;
titleEditingEnabled:boolean;
currentQuery:QueryResource;
@ -96,6 +96,7 @@ export class WorkPackagesListComponent implements OnInit, OnDestroy {
readonly $transitions:TransitionService,
readonly $state:StateService,
readonly I18n:I18nService,
readonly titleService:OpTitleService,
readonly wpStaticQueries:WorkPackageStaticQueriesService) {
}
@ -115,6 +116,13 @@ export class WorkPackagesListComponent implements OnInit, OnDestroy {
// Listen for refresh changes
this.setupRefreshObserver();
// Update title on entering this state
this.$transitions.onSuccess({ to: 'work-packages.list' }, () => {
if (this.selectedTitle) {
this.titleService.setFirstPart(this.selectedTitle);
}
});
// Listen for param changes
this.removeTransitionSubscription = this.$transitions.onSuccess({}, (transition):any => {
let options = transition.options();
@ -256,5 +264,10 @@ export class WorkPackagesListComponent implements OnInit, OnDestroy {
this.selectedTitle = this.wpStaticQueries.getStaticName(query);
this.titleEditingEnabled = false;
}
// Update the title if we're in the list state alone
if (this.$state.current.name === 'work-packages.list') {
this.titleService.setFirstPart(this.selectedTitle);
}
}
}

@ -30,8 +30,22 @@ require 'spec_helper'
RSpec.feature 'Work package navigation', js: true, selenium: true do
let(:user) { FactoryBot.create(:admin) }
let(:project) { FactoryBot.create(:project) }
let(:project) { FactoryBot.create(:project, name: 'Some project') }
let(:work_package) { FactoryBot.build(:work_package, project: project) }
let(:global_html_title) { ::Components::HtmlTitle.new }
let(:project_html_title) { ::Components::HtmlTitle.new project }
let(:wp_title_segment) do
"#{work_package.type.name}: #{work_package.subject} (##{work_package.id})"
end
let!(:query) do
query = FactoryBot.build(:query, user: user, project: project)
query.column_names = %w(id subject)
query.name = "My fancy query"
query.save!
query
end
before do
login_as(user)
@ -45,6 +59,7 @@ RSpec.feature 'Work package navigation', js: true, selenium: true do
global_work_packages.visit!
global_work_packages.expect_work_package_listed(work_package)
global_html_title.expect_first_segment 'All open'
# open details pane for work package
@ -52,12 +67,14 @@ RSpec.feature 'Work package navigation', js: true, selenium: true do
split_work_package.expect_subject
split_work_package.expect_current_path
global_html_title.expect_first_segment wp_title_segment
# Go to full screen by double click
full_work_package = global_work_packages.open_full_screen_by_doubleclick(work_package)
full_work_package.expect_subject
full_work_package.expect_current_path
global_html_title.expect_first_segment wp_title_segment
# deep link work package details pane
@ -77,6 +94,18 @@ RSpec.feature 'Work package navigation', js: true, selenium: true do
project_work_packages.visit!
project_work_packages.expect_work_package_listed(work_package)
project_html_title.expect_first_segment 'All open'
# Visit query with project wp
project_work_packages.visit_query query
project_work_packages.expect_work_package_listed(work_package)
project_html_title.expect_first_segment 'My fancy query'
# Go back to work packages without query
page.execute_script('window.history.back()')
project_work_packages.expect_work_package_listed(work_package)
project_html_title.expect_first_segment 'All open'
# open project work package details pane
@ -84,17 +113,20 @@ RSpec.feature 'Work package navigation', js: true, selenium: true do
split_project_work_package.expect_subject
split_project_work_package.expect_current_path
project_html_title.expect_first_segment wp_title_segment
# open work package full screen by button
full_work_package = split_project_work_package.switch_to_fullscreen
full_work_package.expect_subject
expect(current_path).to eq project_work_package_path(project, work_package, 'activity')
project_html_title.expect_first_segment wp_title_segment
# Back to table using the button
find('.work-packages-list-view-button').click
global_work_packages.expect_work_package_listed(work_package)
expect(current_path).to eq project_work_packages_path(project)
project_html_title.expect_first_segment 'All open'
# Link to full screen from index
global_work_packages.open_full_screen_by_link(work_package)

@ -0,0 +1,52 @@
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
#
# 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-2017 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 docs/COPYRIGHT.rdoc for more details.
#++
module Components
class HtmlTitle
include Capybara::DSL
include RSpec::Matchers
attr_reader :project
def initialize(project = nil)
@project = project
end
def expect_first_segment(title_part)
expect(page).to have_title full_title(title_part)
end
def full_title(first_segment)
if project
"#{first_segment} | #{project.name} | #{Setting.app_title}"
else
"#{first_segment} | #{Setting.app_title}"
end
end
end
end
Loading…
Cancel
Save