Merge pull request #7486 from opf/fix/30595/board-links

[30595] Fix board links when router not initialized

[ci skip]
pull/7496/head
Oliver Günther 5 years ago committed by GitHub
commit e2924f8f03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      frontend/src/app/modules/boards/boards-sidebar/boards-menu.component.html
  2. 4
      frontend/src/app/modules/boards/boards-sidebar/boards-menu.component.ts
  3. 15
      frontend/src/app/modules/router/openproject.routes.ts
  4. 19
      modules/boards/spec/features/board_navigation_spec.rb

@ -4,7 +4,7 @@
<a [textContent]="board.name"
uiSref="boards.show"
[uiOptions]="{ reload: true }"
[uiParams]="{ board_id: board.id, query_props: '' }"
[uiParams]="{ board_id: board.id, query_props: '', projects: 'projects', projectPath: currentProjectIdentifier }"
class="main-menu--children-sub-item ellipsis">
</a>
</li>

@ -7,6 +7,7 @@ import {DynamicBootstrapper} from "core-app/globals/dynamic-bootstrapper";
import {AngularTrackingHelpers} from "core-components/angular/tracking-functions";
import {MainMenuNavigationService} from "core-components/main-menu/main-menu-navigation.service";
import {map} from "rxjs/operators";
import {CurrentProjectService} from "core-components/projects/current-project.service";
@Component({
selector: 'boards-menu',
@ -16,6 +17,8 @@ import {map} from "rxjs/operators";
export class BoardsMenuComponent {
trackById = AngularTrackingHelpers.compareByAttribute('id');
currentProjectIdentifier = this.currentProject.identifier;
public boards$:Observable<Board[]> = this.boardCache.observeAll().pipe(
map((boards:Board[]) => {
return boards.sort(function(a, b){
@ -28,6 +31,7 @@ export class BoardsMenuComponent {
constructor(private readonly boardService:BoardService,
private readonly boardCache:BoardCacheService,
private readonly currentProject:CurrentProjectService,
private readonly mainMenuService:MainMenuNavigationService) {
// When activating the work packages submenu,

@ -168,6 +168,13 @@ export function initializeUiRouterListeners(injector:Injector) {
const profiler:any = (window as any).MiniProfiler;
profiler && profiler.pageTransition();
const projectIdentifier = toParams.projectPath || currentProject.identifier;
if (!toParams.projects && projectIdentifier) {
const newParams = _.clone(toParams);
_.assign(newParams, {projectPath: projectIdentifier, projects: 'projects'});
return $state.target(toState, newParams, {location: 'replace'});
}
// Abort the transition and move to the url instead
if (wpBase === null) {
@ -205,14 +212,6 @@ export function initializeUiRouterListeners(injector:Injector) {
notificationsService.add(toParams.flash_message as INotification);
}
const projectIdentifier = toParams.projectPath || currentProject.identifier;
if (!toParams.projects && projectIdentifier) {
const newParams = _.clone(toParams);
_.assign(newParams, {projectPath: projectIdentifier, projects: 'projects'});
return $state.target(toState, newParams, {location: 'replace'});
}
return true;
});
};

@ -45,7 +45,7 @@ describe 'Work Package boards spec', type: :feature, js: true do
let!(:status) { FactoryBot.create :default_status }
let(:board_index) { Pages::BoardIndex.new(project) }
let(:board_view) { FactoryBot.create :board_grid_with_query, project: project }
let!(:board_view) { FactoryBot.create :board_grid_with_query, name: 'My board', project: project }
let(:project_html_title) { ::Components::HtmlTitle.new project }
before do
@ -55,7 +55,6 @@ describe 'Work Package boards spec', type: :feature, js: true do
end
it 'navigates from boards to the WP full view and back' do
board_view
board_index.visit!
# Add a new WP on the board
@ -75,4 +74,20 @@ describe 'Work Package boards spec', type: :feature, js: true do
find('.work-packages-back-button').click
expect(current_path).to eq project_work_package_boards_path(project, board_view.id)
end
it 'navigates correctly the path from overview page to the boards page' do
visit "/projects/#{project.identifier}"
item = page.find('#menu-sidebar li[data-name="board_view"]', wait: 10)
item.find('.toggler').click
subitem = page.find('.main-menu--children-sub-item', text: 'My board', wait: 10)
expect(subitem[:href]).to end_with "/projects/#{project.identifier}/boards/#{board_view.id}"
subitem.click
board_page = ::Pages::Board.new board_view
board_page.expect_query 'List 1', editable: true
board_page.add_card 'List 1', 'Task 1'
end
end

Loading…
Cancel
Save