Skip to content

Commit

Permalink
feat(workbench/perspective): activate first view of each part if not …
Browse files Browse the repository at this point in the history
…specified
  • Loading branch information
Marcarrian committed Jun 20, 2024
1 parent 656fb88 commit 161d05d
Show file tree
Hide file tree
Showing 18 changed files with 91 additions and 69 deletions.
2 changes: 1 addition & 1 deletion apps/workbench-getting-started-app/src/app/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const appConfig: ApplicationConfig = {
layout: (factory: WorkbenchLayoutFactory) => factory
.addPart(MAIN_AREA)
.addPart('left', {relativeTo: MAIN_AREA, align: 'left', ratio: .25})
.addView('todos', {partId: 'left', activateView: true})
.addView('todos', {partId: 'left'})
.navigateView('todos', ['todos']),
}),
provideRouter([
Expand Down
9 changes: 2 additions & 7 deletions apps/workbench-testing-app/src/app/workbench.perspectives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,7 @@ function provideDeveloperPerspectiveLayout(factory: WorkbenchLayoutFactory): Wor
.navigateView('search', [], {hint: 'search'})
.navigateView('progress', [], {hint: 'progress'})
.navigateView('outline', [], {hint: 'outline'})
.activateView('package-explorer')
.activateView('git-repositories')
.activateView('console')
.activateView('outline');
.activateView('console');
}

/** @private */
Expand All @@ -144,7 +141,5 @@ function provideDebugPerspectiveLayout(factory: WorkbenchLayoutFactory): Workben
.navigateView('variables', [], {hint: 'variables'})
.navigateView('expressions', [], {hint: 'expressions'})
.navigateView('breakpoints', [], {hint: 'breakpoints'})
.activateView('debug')
.activateView('console')
.activateView('variables');
.activateView('console');
}
4 changes: 2 additions & 2 deletions docs/site/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ In this step, we will create the TODO list and place it to the left of the main
[+] layout: (factory: WorkbenchLayoutFactory) => factory
[+] .addPart(MAIN_AREA)
[+] .addPart('left', {relativeTo: MAIN_AREA, align: 'left', ratio: .25})
[+] .addView('todos', {partId: 'left', activateView: true})
[+] .addView('todos', {partId: 'left'})
[+] .navigateView('todos', ['todos'])
}),
provideRouter([
Expand Down Expand Up @@ -358,7 +358,7 @@ In this step, we will create a component to open a TODO in a view.
layout: (factory: WorkbenchLayoutFactory) => factory
.addPart(MAIN_AREA)
.addPart('left', {relativeTo: MAIN_AREA, align: 'left', ratio: .25})
.addView('todos', {partId: 'left', activateView: true})
.addView('todos', {partId: 'left'})
.navigateView('todos', ['todos'])
}),
provideRouter([
Expand Down
5 changes: 0 additions & 5 deletions docs/site/howto/how-to-define-initial-layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ bootstrapApplication(AppComponent, {
.navigateView('console', [], {hint: 'console'}) // Set hint to differentiate between routes with an empty path.
.navigateView('problems', [], {hint: 'problems'}) // Set hint to differentiate between routes with an empty path.
.navigateView('search', ['path/to/search'])

// Decide which views to activate.
.activateView('navigator')
.activateView('explorer')
.activateView('console')
}),
],
});
Expand Down
12 changes: 2 additions & 10 deletions docs/site/howto/how-to-provide-perspective.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,7 @@ bootstrapApplication(AppComponent, {
.navigateView('outline', [], {hint: 'outline'}) // Set hint to differentiate between routes with an empty path.
.navigateView('console', [], {hint: 'console'}) // Set hint to differentiate between routes with an empty path.
.navigateView('problems', [], {hint: 'problems'}) // Set hint to differentiate between routes with an empty path.
.navigateView('search', ['path/to/search'])

// Decide which views to activate.
.activateView('navigator')
.activateView('outline')
.activateView('console'),
.navigateView('search', ['path/to/search']),
data: {
label: 'Administrator',
},
Expand All @@ -76,10 +71,7 @@ bootstrapApplication(AppComponent, {
.navigateView('navigator', ['path/to/navigator'])
.navigateView('explorer', ['path/to/explorer'])
.navigateView('outline', [], {hint: 'outline'}) // Set hint to differentiate between routes with an empty path.
.navigateView('search', ['path/to/search'])

// Decide which views to activate.
.activateView('explorer'),
.navigateView('search', ['path/to/search']),
data: {
label: 'Manager',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ test.describe('Workbench View CSS Class', () => {
const routerPage = await microfrontendNavigator.openInNewTab(RouterPagePO, 'app1');
await routerPage.navigate({component: 'testee-1'}, {
target: 'view.100',
cssClass: 'testee-navigation-1'
cssClass: 'testee-navigation-1',
});

// Expect CSS classes of the navigation to be set.
Expand All @@ -72,7 +72,7 @@ test.describe('Workbench View CSS Class', () => {
// Navigate to test view 2 passing CSS class 'testee-navigation-2'.
await routerPage.navigate({component: 'testee-2'}, {
target: 'view.100',
cssClass: 'testee-navigation-2'
cssClass: 'testee-navigation-2',
});

// Expect CSS classes of the navigation to be set.
Expand All @@ -99,7 +99,7 @@ test.describe('Workbench View CSS Class', () => {
// Navigate to test view 1 without passing CSS class.
await routerPage.navigate({component: 'testee-1'}, {
target: 'view.100',
cssClass: []
cssClass: [],
});

// Expect CSS classes of the previous navigation not to be set.
Expand Down Expand Up @@ -129,7 +129,7 @@ test.describe('Workbench View CSS Class', () => {
await routerPage.navigate({component: 'view', app: 'app1'}, {
target: 'view.100',
activate: false,
cssClass: 'testee'
cssClass: 'testee',
});

const viewPage = new ViewPagePO(appPO, {viewId: 'view.100'});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ test.describe('Workbench', () => {
await workbenchNavigator.createPerspective(factory => factory
.addPart(MAIN_AREA)
.addPart('left', {relativeTo: MAIN_AREA, align: 'left', ratio: .2})
.addView('view.100', {partId: 'left', activateView: true})
.addView('view.100', {partId: 'left'})
.navigateView('view.100', ['test-view']),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ test.describe('Workbench View', () => {
.addPart('part')
.addView('view.101', {partId: 'part'})
.addView('view.102', {partId: 'part'})
.addView('view.103', {partId: 'part', activateView: true})
.addView('view.103', {partId: 'part'})
.navigateView('view.101', ['test-view']) // path-based view
.navigateView('view.102', ['test-view']) // path-based view
.navigateView('view.103', [], {hint: 'test-view'}), // empty-path view
Expand Down Expand Up @@ -249,7 +249,7 @@ test.describe('Workbench View', () => {
{id: 'view.102'},
{id: 'view.103'},
],
activeViewId: 'view.103',
activeViewId: 'view.102',
}),
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ test.describe('Navigational State', () => {
await workbenchNavigator.createPerspective(factory => factory
.addPart('left')
.addPart('right', {align: 'right'})
.addView('router', {partId: 'left', activateView: true, cssClass: 'router'})
.addView('testee', {partId: 'right', activateView: true, cssClass: 'testee'})
.addView('router', {partId: 'left', cssClass: 'router'})
.addView('testee', {partId: 'right', cssClass: 'testee'})
.navigateView('router', ['test-router'])
.navigateView('testee', ['test-view']),
);
Expand Down Expand Up @@ -220,7 +220,7 @@ test.describe('Navigational State', () => {
await workbenchNavigator.createPerspective(factory => factory
.addPart('left')
.addPart('right', {align: 'right'})
.addView('workbench-router', {partId: 'left', activateView: true, cssClass: 'workbench-router'})
.addView('workbench-router', {partId: 'left', cssClass: 'workbench-router'})
.addView('angular-router', {partId: 'left', cssClass: 'angular-router'})
.navigateView('workbench-router', ['test-router'])
.navigateView('angular-router', ['test-pages/angular-router-test-page']),
Expand Down
10 changes: 5 additions & 5 deletions projects/scion/e2e-testing/src/workbench/router-link.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ test.describe('Workbench RouterLink', () => {
await workbenchNavigator.createPerspective(factory => factory
.addPart(MAIN_AREA)
.addPart('left', {align: 'left'})
.addView('view.101', {partId: 'left', activateView: true}),
.addView('view.101', {partId: 'left'}),
);

// Add state via separate navigation as not supported when adding views to the perspective.
Expand Down Expand Up @@ -420,8 +420,8 @@ test.describe('Workbench RouterLink', () => {
await workbenchNavigator.createPerspective(factory => factory
.addPart('left')
.addPart('right', {align: 'right'})
.addView('view.101', {partId: 'left', activateView: true})
.addView('view.102', {partId: 'right', activateView: true}),
.addView('view.101', {partId: 'left'})
.addView('view.102', {partId: 'right'}),
);
await workbenchNavigator.modifyLayout(layout => layout
.navigateView('view.101', ['test-router'], {state: {navigated: 'false'}})
Expand Down Expand Up @@ -471,7 +471,7 @@ test.describe('Workbench RouterLink', () => {
await workbenchNavigator.createPerspective(factory => factory
.addPart(MAIN_AREA)
.addPart('left', {align: 'left'})
.addView('view.101', {partId: 'left', activateView: true}),
.addView('view.101', {partId: 'left'}),
);

// Add state via separate navigation as not supported when adding views to the perspective.
Expand Down Expand Up @@ -530,7 +530,7 @@ test.describe('Workbench RouterLink', () => {
await workbenchNavigator.createPerspective(factory => factory
.addPart(MAIN_AREA)
.addPart('left', {align: 'left'})
.addView('view.101', {partId: 'left', activateView: true}),
.addView('view.101', {partId: 'left'}),
);

// Add state via separate navigation as not supported when adding views to the perspective.
Expand Down
12 changes: 6 additions & 6 deletions projects/scion/e2e-testing/src/workbench/router.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ test.describe('Workbench Router', () => {
.addPart('left')
.addPart('right', {align: 'right'})
.addView('router', {partId: 'left', cssClass: 'router'})
.addView('view.100', {partId: 'right', activateView: true})
.addView('view.100', {partId: 'right'})
.navigateView('router', ['test-router']),
);

Expand Down Expand Up @@ -1668,7 +1668,7 @@ test.describe('Workbench Router', () => {
await workbenchNavigator.createPerspective(factory => factory
.addPart('left')
.addPart('right', {relativeTo: 'left', align: 'right'})
.addView('router', {partId: 'left', activateView: true, cssClass: 'router'})
.addView('router', {partId: 'left', cssClass: 'router'})
.addView('testee', {partId: 'right', cssClass: 'testee'})
.navigateView('router', ['test-router']),
);
Expand All @@ -1695,9 +1695,9 @@ test.describe('Workbench Router', () => {
await workbenchNavigator.createPerspective(factory => factory
.addPart('left')
.addPart('right', {relativeTo: 'left', align: 'right'})
.addView('test-router', {partId: 'left', activateView: true, cssClass: 'router'})
.addView('test-router', {partId: 'left', cssClass: 'router'})
.addView('testee-1', {partId: 'right', cssClass: 'testee-1'})
.addView('testee-2', {partId: 'right', cssClass: 'testee-2', activateView: true})
.addView('testee-2', {partId: 'right', cssClass: 'testee-2'})
.navigateView('test-router', ['test-router'])
.navigateView('testee-1', ['test-view'])
.navigateView('testee-2', ['test-view']),
Expand Down Expand Up @@ -1729,10 +1729,10 @@ test.describe('Workbench Router', () => {
await workbenchNavigator.createPerspective(factory => factory
.addPart('left')
.addPart('right', {relativeTo: 'left', align: 'right'})
.addView('test-router', {partId: 'left', activateView: true, cssClass: 'router'})
.addView('test-router', {partId: 'left', cssClass: 'router'})
.addView('testee-1', {partId: 'right', cssClass: 'testee-1'})
.addView('testee-1', {partId: 'right', cssClass: 'testee-2'})
.addView('testee-2', {partId: 'right', cssClass: 'testee-3', activateView: true})
.addView('testee-2', {partId: 'right', cssClass: 'testee-3'})
.navigateView('test-router', ['test-router'])
.navigateView('testee-1', ['test-view'])
.navigateView('testee-2', ['test-view']),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ test.describe('View Tabbar', () => {
.addPart('part')
.addView('view.1', {partId: 'part'})
.addView('view.2', {partId: 'part'})
.addView('view.3', {partId: 'part', activateView: true})
.addView('view.3', {partId: 'part'})
.addView('view.4', {partId: 'part'}),
);

Expand Down Expand Up @@ -245,7 +245,7 @@ test.describe('View Tabbar', () => {
.addPart('part')
.addView('view.1', {partId: 'part'})
.addView('view.2', {partId: 'part'})
.addView('view.3', {partId: 'part', activateView: true})
.addView('view.3', {partId: 'part'})
.addView('view.4', {partId: 'part'}),
);

Expand Down Expand Up @@ -273,7 +273,7 @@ test.describe('View Tabbar', () => {
.addPart('part')
.addView('view.1', {partId: 'part'})
.addView('view.2', {partId: 'part'})
.addView('view.3', {partId: 'part', activateView: true})
.addView('view.3', {partId: 'part'})
.addView('view.4', {partId: 'part'}),
);

Expand Down
4 changes: 2 additions & 2 deletions projects/scion/workbench/src/lib/part/workbench-part.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ describe('WorkbenchPart', () => {
layout: factory => factory
.addPart('left-top')
.addPart('left-bottom', {relativeTo: 'left-top', align: 'bottom'})
.addView('view.101', {partId: 'left-top', activateView: true})
.addView('view.102', {partId: 'left-bottom', activateView: true})
.addView('view.101', {partId: 'left-top'})
.addView('view.102', {partId: 'left-bottom'})
.navigateView('view.101', ['test-page'])
.navigateView('view.102', ['test-page'])
.activatePart('left-top'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,7 @@ export interface WorkbenchPerspectiveDefinition {
* .navigateView('explorer', ['path/to/explorer'])
* .navigateView('console', [], {hint: 'console'}) // Set hint to differentiate between routes with an empty path.
* .navigateView('problems', [], {hint: 'problems'}) // Set hint to differentiate between routes with an empty path.
* .navigateView('search', ['path/to/search'])
*
* // Decide which views to activate.
* .activateView('navigator')
* .activateView('explorer')
* .activateView('console');
* .navigateView('search', ['path/to/search']);
* }
* ```
*
Expand Down
Loading

0 comments on commit 161d05d

Please sign in to comment.