mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-31 17:38:28 +00:00
special ifExperimental directive to toggle features (#445)
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
"copyright":
|
||||
"© 2017 - 2018 Alfresco Software, Inc. All rights reserved."
|
||||
},
|
||||
"experimental": {},
|
||||
"headerColor": "#2196F3",
|
||||
"languagePicker": false,
|
||||
"pagination": {
|
||||
|
@@ -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 },
|
||||
|
52
src/app/directives/experimental.directive.ts
Normal file
52
src/app/directives/experimental.directive.ts
Normal 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();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user