Skip to content

Commit

Permalink
feat: hide activity part if no activities are registered
Browse files Browse the repository at this point in the history
closes #107
  • Loading branch information
danielwiehl committed Mar 14, 2019
1 parent 1e0a78c commit 3c01b6f
Show file tree
Hide file tree
Showing 18 changed files with 633 additions and 57 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Component } from '@angular/core';

@Component({
selector: 'app-activity-1',
template: 'Activity 1 is showing',
})
export class Activity1Component {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Component } from '@angular/core';

@Component({
selector: 'app-activity-2',
template: 'Activity 2 is showing',
})
export class Activity2Component {
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { Activity1Component } from './activity-1/activity-1.component';
import { Activity2Component } from './activity-2/activity-2.component';

const routes: Routes = [];
const routes: Routes = [
{path: 'activity-1', component: Activity1Component},
{path: 'activity-2', component: Activity2Component},
];

@NgModule({
imports: [RouterModule.forRoot(routes, {useHash: true})],
Expand Down
15 changes: 14 additions & 1 deletion projects/app/workbench/workbench-app/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
<wb-workbench></wb-workbench>
<wb-workbench>
<wb-activity title="Activity 1"
itemText="filter_1"
itemCssClass="material-icons"
[visible]="showActivities"
routerLink="activity-1">
</wb-activity>
<wb-activity *ngIf="showActivities"
title="Activity 2"
itemText="filter_2"
itemCssClass="material-icons"
routerLink="activity-2">
</wb-activity>
</wb-workbench>
24 changes: 22 additions & 2 deletions projects/app/workbench/workbench-app/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,29 @@
import { Component } from '@angular/core';
import { Component, OnDestroy } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { coerceBooleanProperty } from '@angular/cdk/coercion';

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
export class AppComponent implements OnDestroy {

private _destroy$ = new Subject<void>();

public showActivities = true;

constructor(route: ActivatedRoute) {
route.queryParamMap
.pipe(takeUntil(this._destroy$))
.subscribe(queryParams => {
this.showActivities = coerceBooleanProperty(queryParams.get('show-activities') || true);
});
}

public ngOnDestroy(): void {
this._destroy$.next();
}
}
6 changes: 5 additions & 1 deletion projects/app/workbench/workbench-app/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { WorkbenchModule } from '@scion/workbench';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { Activity1Component } from './activity-1/activity-1.component';
import { Activity2Component } from './activity-2/activity-2.component';

@NgModule({
declarations: [
AppComponent
AppComponent,
Activity1Component,
Activity2Component,
],
imports: [
BrowserModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export class HostAppPO {
}

/**
* Finds the notification which has given CSS class set.
* Finds the message box which has given CSS class set.
* If not found, the promise resolves to `null`.
*/
public async findMessageBox(cssClass: string): Promise<MessageBoxPO | null> {
Expand Down
35 changes: 35 additions & 0 deletions projects/e2e/workbench/src/activity.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright (c) 2018 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 { HostAppPO } from './page-object/host-app.po';
import { browser } from 'protractor';

describe('Activity', () => {

const hostAppPO = new HostAppPO();

beforeEach(async () => {
await browser.get('/');
});

describe('Activity bar', () => {

it('should not show if no activities are registered', async () => {
await browser.get('/');
await expect(hostAppPO.isActivityBarShowing()).toBeTruthy();

await browser.get('/#/?show-activities=true');
await expect(hostAppPO.isActivityBarShowing()).toBeTruthy();

await browser.get('/#/?show-activities=false');
await expect(hostAppPO.isActivityBarShowing()).toBeFalsy();
});
});
});
23 changes: 0 additions & 23 deletions projects/e2e/workbench/src/app.e2e-spec.ts

This file was deleted.

11 changes: 0 additions & 11 deletions projects/e2e/workbench/src/app.po.ts

This file was deleted.

Loading

0 comments on commit 3c01b6f

Please sign in to comment.