diff --git a/src/app.config.json b/src/app.config.json index c9e6c692e..01f23c221 100644 --- a/src/app.config.json +++ b/src/app.config.json @@ -8,6 +8,7 @@ "copyright": "© 2017 - 2018 Alfresco Software, Inc. All rights reserved." }, + "experimental": {}, "headerColor": "#2196F3", "languagePicker": false, "pagination": { diff --git a/src/app/app.module.ts b/src/app/app.module.ts index d7fe07e74..a5cbd78fc 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -79,6 +79,7 @@ import { AppStoreModule } from './store/app-store.module'; import { PaginationDirective } from './directives/pagination.directive'; import { DocumentListDirective } from './directives/document-list.directive'; import { MaterialModule } from './material.module'; +import { ExperimentalDirective } from './directives/experimental.directive'; @NgModule({ imports: [ @@ -132,7 +133,8 @@ import { MaterialModule } from './material.module'; CreateFolderDirective, DownloadNodesDirective, PaginationDirective, - DocumentListDirective + DocumentListDirective, + ExperimentalDirective ], providers: [ { provide: PageTitleService, useClass: AcaPageTitleService }, diff --git a/src/app/directives/experimental.directive.ts b/src/app/directives/experimental.directive.ts new file mode 100644 index 000000000..1370a7136 --- /dev/null +++ b/src/app/directives/experimental.directive.ts @@ -0,0 +1,52 @@ +/*! + * @license + * Alfresco Example Content Application + * + * Copyright (C) 2005 - 2018 Alfresco Software Limited + * + * This file is part of the Alfresco Example Content Application. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * The Alfresco Example Content Application is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Alfresco Example Content Application is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ + +import { Directive, TemplateRef, ViewContainerRef, Input } from '@angular/core'; +import { AppConfigService } from '@alfresco/adf-core'; +import { environment } from '../../environments/environment'; + +@Directive({ + // tslint:disable-next-line:directive-selector + selector: '[ifExperimental]' +}) +export class ExperimentalDirective { + constructor( + private templateRef: TemplateRef, + private viewContainerRef: ViewContainerRef, + private config: AppConfigService + ) {} + + @Input() set ifExperimental(featureKey: string) { + if (!environment.production) { + const value = this.config.get(`experimental.${featureKey}`); + if (value) { + this.viewContainerRef.createEmbeddedView(this.templateRef); + return; + } + } + + this.viewContainerRef.clear(); + } +}