[ADF-4909] Hide about-plugins and about-product-versions sections whe… (#5095)

* [ADF-4909] Hide about-plugins and about-product-versions sections when they are empty

* [ADF-4909] Add missing unsubsciption
This commit is contained in:
arditdomi 2019-09-24 16:48:09 +01:00 committed by Eugenio Romano
parent a9b7c91a00
commit 4b1ed97943
3 changed files with 20 additions and 9 deletions

View File

@ -3,9 +3,9 @@
<small>{{ 'ABOUT.PACKAGES.DESCRIPTION' | translate }}</small> <small>{{ 'ABOUT.PACKAGES.DESCRIPTION' | translate }}</small>
<adf-datatable [data]="dependencyEntries"></adf-datatable> <adf-datatable [data]="dependencyEntries"></adf-datatable>
<div class="adf-extension-details-container" *ngIf="showExtensions && extensions$"> <div class="adf-extension-details-container" *ngIf="showExtensions && extensions.length">
<h3>{{ 'ABOUT.EXTENSIONS.TITLE' | translate }}</h3> <h3>{{ 'ABOUT.EXTENSIONS.TITLE' | translate }}</h3>
<mat-table [dataSource]="extensions$ | async"> <mat-table [dataSource]="extensions">
<!-- $id Column --> <!-- $id Column -->
<ng-container matColumnDef="$id"> <ng-container matColumnDef="$id">
<mat-header-cell <mat-header-cell

View File

@ -15,22 +15,23 @@
* limitations under the License. * limitations under the License.
*/ */
import { Component, Input, OnInit, ViewEncapsulation } from '@angular/core'; import { Component, Input, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
import { ObjectDataTableAdapter } from '../../datatable/data/object-datatable-adapter'; import { ObjectDataTableAdapter } from '../../datatable/data/object-datatable-adapter';
import { Observable } from 'rxjs';
import { AppExtensionService, ExtensionRef } from '@alfresco/adf-extensions'; import { AppExtensionService, ExtensionRef } from '@alfresco/adf-extensions';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
@Component({ @Component({
selector: 'adf-about-application-modules', selector: 'adf-about-application-modules',
templateUrl: './about-application-modules.component.html', templateUrl: './about-application-modules.component.html',
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None
}) })
export class AboutApplicationModulesComponent implements OnInit { export class AboutApplicationModulesComponent implements OnInit, OnDestroy {
extensionColumns: string[] = ['$id', '$name', '$version', '$vendor', '$license', '$runtime', '$description']; extensionColumns: string[] = ['$id', '$name', '$version', '$vendor', '$license', '$runtime', '$description'];
dependencyEntries: ObjectDataTableAdapter; dependencyEntries: ObjectDataTableAdapter;
extensions$: Observable<ExtensionRef[]>; extensions: ExtensionRef[];
/** Toggles showing/hiding of extensions block. */ /** Toggles showing/hiding of extensions block. */
@Input() @Input()
@ -42,8 +43,9 @@ export class AboutApplicationModulesComponent implements OnInit {
/** Current version of the app running */ /** Current version of the app running */
@Input() dependencies: any; @Input() dependencies: any;
constructor(appExtensions: AppExtensionService) { private onDestroy$ = new Subject<boolean>();
this.extensions$ = appExtensions.references$;
constructor(private appExtensions: AppExtensionService) {
} }
ngOnInit() { ngOnInit() {
@ -63,5 +65,14 @@ export class AboutApplicationModulesComponent implements OnInit {
{ type: 'text', key: 'name', title: 'Name', sortable: true }, { type: 'text', key: 'name', title: 'Name', sortable: true },
{ type: 'text', key: 'version', title: 'Version', sortable: true } { type: 'text', key: 'version', title: 'Version', sortable: true }
]); ]);
this.appExtensions.references$
.pipe(takeUntil(this.onDestroy$))
.subscribe((extensions) => this.extensions = extensions);
}
ngOnDestroy() {
this.onDestroy$.next(true);
this.onDestroy$.complete();
} }
} }

View File

@ -1,4 +1,4 @@
<div class="adf-about-container"> <div class="adf-about-container" *ngIf="bpmVersion || ecmVersion">
<h3>{{ 'ABOUT.VERSIONS.TITLE' | translate }}</h3> <h3>{{ 'ABOUT.VERSIONS.TITLE' | translate }}</h3>
<div *ngIf="bpmVersion"> <div *ngIf="bpmVersion">
<mat-card> <mat-card>