SCION Workbench | Projects Overview | Changelog | Contributing | Sponsoring |
---|
SCION Workbench > How To Guides > Layout
This chapter requires a perspective to be registered. See Providing a Perspective to learn how to provide a perspective.
Query perspectives using the WorkbenchService.perspectives
signal.
Switch perspectives using the WorkbenchService.switchPerspective
method.
Reset the active perspective to its initial layout using the WorkbenchService.resetPerspective
method.
Check if a perspective is active using the WorkbenchPerspective.active
signal, or read the active perspective from the WorkbenchService.activePerspective
signal.
// Read the active perspective.
const activePerspective = inject(WorkbenchService).activePerspective();
// Check if a perspective is active.
const perspective = inject(WorkbenchService).getPerspective('perspective');
const isActive = perspective.active()
Set the initial perspective in the workbench configuration by defining the initialPerspective
property. Provide either a perspective id or a function to select from available perspectives.
Setting the developer
perspective as the initial perspective.
import {provideWorkbench} from '@scion/workbench';
provideWorkbench({
layout: {
initialPerspective: 'developer',
},
});
Selecting the developer
perspective based on the user's roles and available perspectives.
import {provideWorkbench, WorkbenchPerspective} from '@scion/workbench';
import {inject} from '@angular/core';
provideWorkbench({
layout: {
initialPerspective: async (perspectives: WorkbenchPerspective[]) => {
if (await inject(AuthService).hasRole('developer') && perspectives.some(perspective => perspective.id === 'developer')) {
return 'developer';
}
return undefined;
},
},
});
The
AuthService
is illustrative and not part of the Workbench API.