blob: 7df15fcdaff0b048e39e84d1368428cbc2b44463 [file] [log] [blame]
Ittay Stern6f900cc2018-08-29 17:01:32 +03001import {NgRedux} from "@angular-redux/store";
2import {AppState} from "../../store/reducers";
3import {Injectable} from "@angular/core";
4
5export enum Features {
6 FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST='FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST',
7 FLAG_1902_NEW_VIEW_EDIT='FLAG_1902_NEW_VIEW_EDIT',
8 FLAG_1902_VNF_GROUPING='FLAG_1902_VNF_GROUPING',
9 FLAG_VF_MODULE_RESUME_STATUS_CREATE = 'FLAG_VF_MODULE_RESUME_STATUS_CREATE',
10 DRAG_AND_DROP_OPERATION = 'DRAG_AND_DROP_OPERATION',
11 FLAG_1906_COMPONENT_INFO = 'FLAG_1906_COMPONENT_INFO',
Einat Vinouzee1f79742019-08-27 16:01:01 +030012 FLAG_1908_RESUME_MACRO_SERVICE = 'FLAG_1908_RESUME_MACRO_SERVICE',
13 FLAG_FLASH_REPLACE_VF_MODULE ='FLAG_FLASH_REPLACE_VF_MODULE',
Ittay Stern9284a732019-09-10 10:28:36 +030014 FLAG_FLASH_MORE_ACTIONS_BUTTON_IN_OLD_VIEW_EDIT ='FLAG_FLASH_MORE_ACTIONS_BUTTON_IN_OLD_VIEW_EDIT'
Ittay Stern6f900cc2018-08-29 17:01:32 +030015}
16
17@Injectable()
18export class FeatureFlagsService {
19
20 constructor(private store: NgRedux<AppState>){}
21
22 public getFlagState(flag: Features):boolean {
23 return FeatureFlagsService.getFlagState(flag, this.store);
24 }
25
26 /*static method for easy refactoring of code, so no injection of FeatureFlagsService is needed*/
27 public static getFlagState(flag: Features, store: NgRedux<AppState>):boolean {
Einat Vinouzee1f79742019-08-27 16:01:01 +030028 let storeStateGlobalFields = store.getState().global;
29 if(storeStateGlobalFields && storeStateGlobalFields.flags && storeStateGlobalFields.flags[flag] !== undefined){
30 return storeStateGlobalFields.flags[flag];
31 }
32 return false;
Ittay Stern6f900cc2018-08-29 17:01:32 +030033 }
34
35
36}