-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(workbench/perspective): support browser back navigation after swi…
…tching perspective Switching perspectives now creates a session history entry, allowing for back/forward browser navigation. closes #579 BREAKING CHANGE: The active perspective is now set after navigation completes (previously before navigation), so it is unavailable during route resolution/activation. Route guards (like `canMatch`) should use the `canMatchWorkbenchPerspective` function instead of `WorkbenchService` or `WorkbenchPerspective` to determine the perspective’s activation state. **Migration Example:** **Before:** ```ts import {Route} from '@angular/router'; import {inject} from '@angular/core'; import {WorkbenchService} from '@scion/workbench'; const route: Route = { canMatch: [() => inject(WorkbenchService).activePerspective()?.id === 'perspective'], // or canMatch: [() => inject(WorkbenchService).perspectives().find(perspective => perspective.id === 'perspective')?.active()], };``` **After:** ```ts import {Route} from '@angular/router'; import {canMatchWorkbenchPerspective} from '@scion/workbench'; const route: Route = { canMatch: [canMatchWorkbenchPerspective('perspective')], }; ```
- Loading branch information
1 parent
4c8412c
commit 5777728
Showing
24 changed files
with
184 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
@if (workbenchStartup.whenStarted | async) { | ||
@if (workbenchStartup.isStarted()) { | ||
<app-header/> | ||
} | ||
<main> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
projects/scion/e2e-testing/src/workbench/workbench-perspective.e2e-spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright (c) 2018-2024 Swiss Federal Railways | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
|
||
import {expect} from '@playwright/test'; | ||
import {test} from '../fixtures'; | ||
import {MPart} from '../matcher/to-equal-workbench-layout.matcher'; | ||
|
||
test.describe('Workbench Perspective', () => { | ||
|
||
test('should support back/forward browser navigation after switching perspective', async ({appPO, workbenchNavigator}) => { | ||
await appPO.navigateTo({microfrontendSupport: false}); | ||
|
||
// Create perspective. | ||
await workbenchNavigator.createPerspective('testee-1', factory => factory.addPart('part-1').addView('view.101', {partId: 'part-1'})); | ||
await workbenchNavigator.createPerspective('testee-2', factory => factory.addPart('part-2').addView('view.102', {partId: 'part-2'})); | ||
|
||
// Switch to perspective 1. | ||
await appPO.switchPerspective('testee-1'); | ||
|
||
await expect.poll(() => appPO.getActivePerspectiveId()).toEqual('testee-1'); | ||
await expect(appPO.workbench).toEqualWorkbenchLayout({ | ||
workbenchGrid: {root: new MPart({id: 'part-1', views: [{id: 'view.101'}]})}, | ||
}); | ||
|
||
// Switch to perspective 2. | ||
await appPO.switchPerspective('testee-2'); | ||
|
||
await expect.poll(() => appPO.getActivePerspectiveId()).toEqual('testee-2'); | ||
await expect(appPO.workbench).toEqualWorkbenchLayout({ | ||
workbenchGrid: {root: new MPart({id: 'part-2', views: [{id: 'view.102'}]})}, | ||
}); | ||
|
||
// Perform browser history back. | ||
await appPO.navigateBack(); | ||
|
||
// Expect perspective 1 to be active. | ||
await expect.poll(() => appPO.getActivePerspectiveId()).toEqual('testee-1'); | ||
await expect(appPO.workbench).toEqualWorkbenchLayout({ | ||
workbenchGrid: {root: new MPart({id: 'part-1', views: [{id: 'view.101'}]})}, | ||
}); | ||
|
||
// Perform browser history forward. | ||
await appPO.navigateForward(); | ||
|
||
// Expect perspective 2 to be active. | ||
await expect.poll(() => appPO.getActivePerspectiveId()).toEqual('testee-2'); | ||
await expect(appPO.workbench).toEqualWorkbenchLayout({ | ||
workbenchGrid: {root: new MPart({id: 'part-2', views: [{id: 'view.102'}]})}, | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.