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', |
Sara Weiss | ef5e3b2 | 2019-12-05 13:23:13 +0200 | [diff] [blame^] | 17 | FLAG_2004_TEMP_BUTTON_TO_INSTANTIATION_STATUS_FILTER ='FLAG_2004_TEMP_BUTTON_TO_INSTANTIATION_STATUS_FILTER', |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 18 | } |
| 19 | |
| 20 | @Injectable() |
| 21 | export class FeatureFlagsService { |
| 22 | |
| 23 | constructor(private store: NgRedux<AppState>){} |
| 24 | |
| 25 | public getFlagState(flag: Features):boolean { |
| 26 | return FeatureFlagsService.getFlagState(flag, this.store); |
| 27 | } |
| 28 | |
| 29 | /*static method for easy refactoring of code, so no injection of FeatureFlagsService is needed*/ |
| 30 | public static getFlagState(flag: Features, store: NgRedux<AppState>):boolean { |
Einat Vinouze | e1f7974 | 2019-08-27 16:01:01 +0300 | [diff] [blame] | 31 | let storeStateGlobalFields = store.getState().global; |
| 32 | if(storeStateGlobalFields && storeStateGlobalFields.flags && storeStateGlobalFields.flags[flag] !== undefined){ |
| 33 | return storeStateGlobalFields.flags[flag]; |
| 34 | } |
| 35 | return false; |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | |
| 39 | } |