special ifExperimental directive to toggle features (#445)

This commit is contained in:
Denys Vuika
2018-06-21 16:54:56 +01:00
committed by GitHub
parent 4bcdab8116
commit 759fa23ed4
3 changed files with 56 additions and 1 deletions

View File

@@ -8,6 +8,7 @@
"copyright":
"© 2017 - 2018 Alfresco Software, Inc. All rights reserved."
},
"experimental": {},
"headerColor": "#2196F3",
"languagePicker": false,
"pagination": {

View File

@@ -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 },

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
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<any>,
private viewContainerRef: ViewContainerRef,
private config: AppConfigService
) {}
@Input() set ifExperimental(featureKey: string) {
if (!environment.production) {
const value = this.config.get<boolean>(`experimental.${featureKey}`);
if (value) {
this.viewContainerRef.createEmbeddedView(this.templateRef);
return;
}
}
this.viewContainerRef.clear();
}
}