blob: 50840d194cd327ed5e37335b239b3dad880fa388 [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',
Eylon Malinf46e53e2019-09-18 08:00:10 +030010 FLAG_1911_INSTANTIATION_ORDER_IN_ASYNC_ALACARTE = 'FLAG_1911_INSTANTIATION_ORDER_IN_ASYNC_ALACARTE',
Ittay Stern6f900cc2018-08-29 17:01:32 +030011 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',
Alexey Sandler43483ad2019-11-19 16:12:18 +020014 FLAG_FLASH_MORE_ACTIONS_BUTTON_IN_OLD_VIEW_EDIT ='FLAG_FLASH_MORE_ACTIONS_BUTTON_IN_OLD_VIEW_EDIT',
Sara Weisseed69432019-11-20 14:50:33 +020015 FLAG_2002_VFM_UPGRADE_ADDITIONAL_OPTIONS ='FLAG_2002_VFM_UPGRADE_ADDITIONAL_OPTIONS',
Eylon Malind00cf802019-12-03 12:12:38 +020016 FLAG_2004_INSTANTIATION_STATUS_FILTER ='FLAG_2004_INSTANTIATION_STATUS_FILTER',
Eylon Malin640a01e2019-12-08 15:56:46 +020017 FLAG_2004_CREATE_ANOTHER_INSTANCE_FROM_TEMPLATE = 'FLAG_2004_CREATE_ANOTHER_INSTANCE_FROM_TEMPLATE',
Yoav Schneiderman3f216a52020-01-22 11:07:00 +020018 FLAG_2006_VFM_SDNC_PRELOAD_FILES = 'FLAG_2006_VFM_SDNC_PRELOAD_FILES',
Ittay Stern59eaa5a2020-01-16 13:30:34 +020019 FLAG_MORE_AUDIT_INFO_LINK_ON_AUDIT_INFO = 'FLAG_MORE_AUDIT_INFO_LINK_ON_AUDIT_INFO',
Alexey Sandler328869a2020-01-26 14:41:24 +020020 FLAG_2004_INSTANTIATION_TEMPLATES_POPUP = 'FLAG_2004_INSTANTIATION_TEMPLATES_POPUP',
Alexey Sandler41768c12020-02-05 13:32:27 +020021 FLAG_2006_USER_PERMISSIONS_BY_OWNING_ENTITY= 'FLAG_2006_USER_PERMISSIONS_BY_OWNING_ENTITY',
22 FLAG_2006_VFMODULE_TAKES_TENANT_AND_REGION_FROM_VNF = 'FLAG_2006_VFMODULE_TAKES_TENANT_AND_REGION_FROM_VNF',
Einat Vinouzefae75692020-03-26 17:22:01 +020023 FLAG_2006_VNF_LOB_MULTI_SELECT= 'FLAG_2006_VNF_LOB_MULTI_SELECT',
Alexey Sandlera3b9e3e2020-04-19 20:32:42 +030024 FLAG_2006_NEW_VIEW_EDIT_BUTTON_IN_INSTANTIATION_STATUS= 'FLAG_2006_NEW_VIEW_EDIT_BUTTON_IN_INSTANTIATION_STATUS',
Alexey Sandlerc8a3cff2020-05-06 18:58:14 +030025 FLAG_2006_PAUSE_VFMODULE_INSTANTIATION_CREATION = 'FLAG_2006_PAUSE_VFMODULE_INSTANTIATION_CREATION',
Ittay Stern6f900cc2018-08-29 17:01:32 +030026}
27
28@Injectable()
29export class FeatureFlagsService {
30
31 constructor(private store: NgRedux<AppState>){}
32
33 public getFlagState(flag: Features):boolean {
34 return FeatureFlagsService.getFlagState(flag, this.store);
35 }
36
Yoav Schneiderman1f2a2942019-12-09 16:42:21 +020037 public getAllFlags(): { [key: string]: boolean}{
38 return this.store.getState().global.flags;
39 }
40
41 public static getAllFlags(store: NgRedux<AppState>): { [key: string]: boolean}{
42 return store.getState().global.flags;
43 }
44
Ittay Stern6f900cc2018-08-29 17:01:32 +030045 /*static method for easy refactoring of code, so no injection of FeatureFlagsService is needed*/
46 public static getFlagState(flag: Features, store: NgRedux<AppState>):boolean {
Einat Vinouzee1f79742019-08-27 16:01:01 +030047 let storeStateGlobalFields = store.getState().global;
48 if(storeStateGlobalFields && storeStateGlobalFields.flags && storeStateGlobalFields.flags[flag] !== undefined){
49 return storeStateGlobalFields.flags[flag];
50 }
51 return false;
Ittay Stern6f900cc2018-08-29 17:01:32 +030052 }
53
54
55}