Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 1 | import {NgRedux} from "@angular-redux/store"; |
| 2 | import {AppState} from "../../store/reducers"; |
| 3 | import {Injectable} from "@angular/core"; |
| 4 | |
| 5 | export 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 Malin | f46e53e | 2019-09-18 08:00:10 +0300 | [diff] [blame] | 10 | FLAG_1911_INSTANTIATION_ORDER_IN_ASYNC_ALACARTE = 'FLAG_1911_INSTANTIATION_ORDER_IN_ASYNC_ALACARTE', |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 11 | FLAG_1906_COMPONENT_INFO = 'FLAG_1906_COMPONENT_INFO', |
Einat Vinouze | e1f7974 | 2019-08-27 16:01:01 +0300 | [diff] [blame] | 12 | FLAG_1908_RESUME_MACRO_SERVICE = 'FLAG_1908_RESUME_MACRO_SERVICE', |
| 13 | FLAG_FLASH_REPLACE_VF_MODULE ='FLAG_FLASH_REPLACE_VF_MODULE', |
Alexey Sandler | 43483ad | 2019-11-19 16:12:18 +0200 | [diff] [blame] | 14 | FLAG_FLASH_MORE_ACTIONS_BUTTON_IN_OLD_VIEW_EDIT ='FLAG_FLASH_MORE_ACTIONS_BUTTON_IN_OLD_VIEW_EDIT', |
Sara Weiss | eed6943 | 2019-11-20 14:50:33 +0200 | [diff] [blame] | 15 | FLAG_2002_VFM_UPGRADE_ADDITIONAL_OPTIONS ='FLAG_2002_VFM_UPGRADE_ADDITIONAL_OPTIONS', |
Eylon Malin | d00cf80 | 2019-12-03 12:12:38 +0200 | [diff] [blame] | 16 | FLAG_2004_INSTANTIATION_STATUS_FILTER ='FLAG_2004_INSTANTIATION_STATUS_FILTER', |
Eylon Malin | 640a01e | 2019-12-08 15:56:46 +0200 | [diff] [blame] | 17 | FLAG_2004_CREATE_ANOTHER_INSTANCE_FROM_TEMPLATE = 'FLAG_2004_CREATE_ANOTHER_INSTANCE_FROM_TEMPLATE', |
Yoav Schneiderman | 3f216a5 | 2020-01-22 11:07:00 +0200 | [diff] [blame] | 18 | FLAG_2006_VFM_SDNC_PRELOAD_FILES = 'FLAG_2006_VFM_SDNC_PRELOAD_FILES', |
Ittay Stern | 59eaa5a | 2020-01-16 13:30:34 +0200 | [diff] [blame] | 19 | FLAG_MORE_AUDIT_INFO_LINK_ON_AUDIT_INFO = 'FLAG_MORE_AUDIT_INFO_LINK_ON_AUDIT_INFO', |
Alexey Sandler | 328869a | 2020-01-26 14:41:24 +0200 | [diff] [blame] | 20 | FLAG_2004_INSTANTIATION_TEMPLATES_POPUP = 'FLAG_2004_INSTANTIATION_TEMPLATES_POPUP', |
Alexey Sandler | 41768c1 | 2020-02-05 13:32:27 +0200 | [diff] [blame] | 21 | 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 Vinouze | fae7569 | 2020-03-26 17:22:01 +0200 | [diff] [blame] | 23 | FLAG_2006_VNF_LOB_MULTI_SELECT= 'FLAG_2006_VNF_LOB_MULTI_SELECT', |
Alexey Sandler | a3b9e3e | 2020-04-19 20:32:42 +0300 | [diff] [blame] | 24 | FLAG_2006_NEW_VIEW_EDIT_BUTTON_IN_INSTANTIATION_STATUS= 'FLAG_2006_NEW_VIEW_EDIT_BUTTON_IN_INSTANTIATION_STATUS', |
Alexey Sandler | c8a3cff | 2020-05-06 18:58:14 +0300 | [diff] [blame] | 25 | FLAG_2006_PAUSE_VFMODULE_INSTANTIATION_CREATION = 'FLAG_2006_PAUSE_VFMODULE_INSTANTIATION_CREATION', |
ikram | 6cb5548 | 2020-07-15 17:45:37 -0400 | [diff] [blame] | 26 | FLAG_2008_PAUSE_INSTANTIATION_ON_VFMODULE_POPUP = 'FLAG_2008_PAUSE_INSTANTIATION_ON_VFMODULE_POPUP', |
ikram | 09a6562 | 2020-07-22 10:28:15 -0400 | [diff] [blame^] | 27 | FLAG_2008_REMOVE_PAUSE_INSTANTIATION = 'FLAG_2008_REMOVE_PAUSE_INSTANTIATION', |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 28 | } |
| 29 | |
| 30 | @Injectable() |
| 31 | export class FeatureFlagsService { |
| 32 | |
| 33 | constructor(private store: NgRedux<AppState>){} |
| 34 | |
| 35 | public getFlagState(flag: Features):boolean { |
| 36 | return FeatureFlagsService.getFlagState(flag, this.store); |
| 37 | } |
| 38 | |
Yoav Schneiderman | 1f2a294 | 2019-12-09 16:42:21 +0200 | [diff] [blame] | 39 | public getAllFlags(): { [key: string]: boolean}{ |
| 40 | return this.store.getState().global.flags; |
| 41 | } |
| 42 | |
| 43 | public static getAllFlags(store: NgRedux<AppState>): { [key: string]: boolean}{ |
| 44 | return store.getState().global.flags; |
| 45 | } |
| 46 | |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 47 | /*static method for easy refactoring of code, so no injection of FeatureFlagsService is needed*/ |
| 48 | public static getFlagState(flag: Features, store: NgRedux<AppState>):boolean { |
Einat Vinouze | e1f7974 | 2019-08-27 16:01:01 +0300 | [diff] [blame] | 49 | let storeStateGlobalFields = store.getState().global; |
| 50 | if(storeStateGlobalFields && storeStateGlobalFields.flags && storeStateGlobalFields.flags[flag] !== undefined){ |
| 51 | return storeStateGlobalFields.flags[flag]; |
| 52 | } |
| 53 | return false; |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | |
| 57 | } |