@gooddata/js-utils
Advanced tools
Comparing version 3.10.14 to 3.10.15-alpha-ptquang86-qp-sd-1338-naming-2021-01-15T10-15-44-167Z
@@ -14,3 +14,4 @@ import { IBootstrapData } from './userUtils'; | ||
export declare function isFreemiumEdition(platformEdition: string): boolean; | ||
export declare function shouldEnableNewNavigation(featureFlags: IFeatureFlags): boolean; | ||
export declare function updatePrivateFFForPPInBootstrap(bootstrapData: IBootstrapData, featureFlags: INormalizedFeatureFlags): IBootstrapData; | ||
export {}; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// (C) 2020 GoodData Corporation | ||
// (C) 2020-2021 GoodData Corporation | ||
var set_1 = __importDefault(require("lodash/set")); | ||
@@ -13,2 +13,3 @@ var cloneDeep = require("lodash/cloneDeep"); | ||
var PLATFORM_EDITION = 'platformEdition'; | ||
var ENABLE_NEW_NAVIGATION = 'enableNewNavigationForResponsiveUi'; | ||
var ENABLE_PP_EXPERIENCE = 'enablePixelPerfectExperience'; | ||
@@ -29,2 +30,16 @@ var PORTAL_LOGO_PAGE = 'portalLogoPage'; | ||
exports.isFreemiumEdition = isFreemiumEdition; | ||
function shouldEnableNewNavigation(featureFlags) { | ||
var enableNewNavigationForResponsiveUi = featureFlags.enableNewNavigationForResponsiveUi; | ||
if (enableNewNavigationForResponsiveUi) { | ||
var platformEdition = featureFlags.platformEdition; | ||
// Free: always true | ||
if (platformEdition === FREE) { | ||
return true; | ||
} | ||
// Growth/Enterprise: with PP: false, without PP: On demand | ||
return shouldHidePPExperience(featureFlags); | ||
} | ||
return false; | ||
} | ||
exports.shouldEnableNewNavigation = shouldEnableNewNavigation; | ||
// calling from AD/KD/Load/Users Management Page | ||
@@ -35,2 +50,3 @@ function updatePrivateFFForPPInBootstrap(bootstrapData, featureFlags) { | ||
PLATFORM_EDITION, | ||
ENABLE_NEW_NAVIGATION, | ||
ENABLE_PP_EXPERIENCE, | ||
@@ -37,0 +53,0 @@ PORTAL_LOGO_PAGE |
{ | ||
"name": "@gooddata/js-utils", | ||
"version": "3.10.14", | ||
"version": "3.10.15-alpha-ptquang86-qp-sd-1338-naming-2021-01-15T10-15-44-167Z", | ||
"description": "Various utils shared on GoodData frontend", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -1,2 +0,2 @@ | ||
// (C) 2020 GoodData Corporation | ||
// (C) 2020-2021 GoodData Corporation | ||
import set from 'lodash/set'; | ||
@@ -9,2 +9,3 @@ import cloneDeep = require('lodash/cloneDeep'); | ||
const PLATFORM_EDITION = 'platformEdition'; | ||
const ENABLE_NEW_NAVIGATION = 'enableNewNavigationForResponsiveUi'; | ||
const ENABLE_PP_EXPERIENCE = 'enablePixelPerfectExperience'; | ||
@@ -40,2 +41,21 @@ const PORTAL_LOGO_PAGE = 'portalLogoPage'; | ||
export function shouldEnableNewNavigation( | ||
featureFlags: IFeatureFlags | ||
): boolean { | ||
const enableNewNavigationForResponsiveUi = featureFlags.enableNewNavigationForResponsiveUi as boolean; | ||
if (enableNewNavigationForResponsiveUi) { | ||
const platformEdition = featureFlags.platformEdition as string; | ||
// Free: always true | ||
if (platformEdition === FREE) { | ||
return true; | ||
} | ||
// Growth/Enterprise: with PP: false, without PP: On demand | ||
return shouldHidePPExperience(featureFlags); | ||
} | ||
return false; | ||
} | ||
// calling from AD/KD/Load/Users Management Page | ||
@@ -49,2 +69,3 @@ export function updatePrivateFFForPPInBootstrap( | ||
PLATFORM_EDITION, | ||
ENABLE_NEW_NAVIGATION, | ||
ENABLE_PP_EXPERIENCE, | ||
@@ -57,3 +78,7 @@ PORTAL_LOGO_PAGE | ||
if (featureFlagValue) { | ||
set(clonedBootstrapData, `${CURRENT_FEATURE_FLAGS_PATH}.${name}`, featureFlagValue); | ||
set( | ||
clonedBootstrapData, | ||
`${CURRENT_FEATURE_FLAGS_PATH}.${name}`, | ||
featureFlagValue | ||
); | ||
} | ||
@@ -60,0 +85,0 @@ }); |
@@ -1,3 +0,8 @@ | ||
// (C) 2020 GoodData Corporation | ||
import { shouldHidePPExperience, isFreemiumEdition, updatePrivateFFForPPInBootstrap } from '../featureFlags' | ||
// (C) 2020-2021 GoodData Corporation | ||
import { | ||
shouldEnableNewNavigation, | ||
shouldHidePPExperience, | ||
isFreemiumEdition, | ||
updatePrivateFFForPPInBootstrap, | ||
} from '../featureFlags'; | ||
@@ -46,2 +51,82 @@ describe('featureFlags utils', () => { | ||
describe('shouldEnableNewNavigation', () => { | ||
describe('Free user', () => { | ||
it('should return false', () => { | ||
const enableNewNavigation = shouldEnableNewNavigation({ | ||
enableNewNavigationForResponsiveUi: false, | ||
platformEdition: 'free', | ||
}); | ||
expect(enableNewNavigation).toBe(false); | ||
}); | ||
it('should return true', () => { | ||
const enableNewNavigation = shouldEnableNewNavigation({ | ||
enableNewNavigationForResponsiveUi: true, | ||
platformEdition: 'free', | ||
}); | ||
expect(enableNewNavigation).toBe(true); | ||
}); | ||
}); | ||
describe('Growth user', () => { | ||
it('should return false', () => { | ||
const enableNewNavigation = shouldEnableNewNavigation({ | ||
enableNewNavigationForResponsiveUi: false, | ||
platformEdition: 'growth', | ||
}); | ||
expect(enableNewNavigation).toBe(false); | ||
}); | ||
it('should return true when enablePixelPerfectExperience is false', () => { | ||
const enableNewNavigation = shouldEnableNewNavigation({ | ||
hidePixelPerfectExperience: false, | ||
enablePixelPerfectExperience: false, | ||
enableNewNavigationForResponsiveUi: true, | ||
platformEdition: 'growth', | ||
}); | ||
expect(enableNewNavigation).toBe(true); | ||
}); | ||
it('should return false when enablePixelPerfectExperience is true', () => { | ||
const enableNewNavigation = shouldEnableNewNavigation({ | ||
hidePixelPerfectExperience: false, | ||
enablePixelPerfectExperience: true, | ||
enableNewNavigationForResponsiveUi: true, | ||
platformEdition: 'growth', | ||
}); | ||
expect(enableNewNavigation).toBe(false); | ||
}); | ||
}); | ||
describe('Enterprise user', () => { | ||
it('should return false', () => { | ||
const enableNewNavigation = shouldEnableNewNavigation({ | ||
enableNewNavigationForResponsiveUi: false, | ||
platformEdition: 'enterprise', | ||
}); | ||
expect(enableNewNavigation).toBe(false); | ||
}); | ||
it('should return true when hidePixelPerfectExperience is true', () => { | ||
const enableNewNavigation = shouldEnableNewNavigation({ | ||
hidePixelPerfectExperience: true, | ||
enablePixelPerfectExperience: false, | ||
enableNewNavigationForResponsiveUi: true, | ||
platformEdition: 'enterprise', | ||
}); | ||
expect(enableNewNavigation).toBe(true); | ||
}); | ||
it('should return false when hidePixelPerfectExperience is false', () => { | ||
const enableNewNavigation = shouldEnableNewNavigation({ | ||
hidePixelPerfectExperience: false, | ||
enablePixelPerfectExperience: false, | ||
enableNewNavigationForResponsiveUi: true, | ||
platformEdition: 'enterprise', | ||
}); | ||
expect(enableNewNavigation).toBe(false); | ||
}); | ||
}); | ||
}); | ||
describe('updatePrivateFFForPPInBootstrap', () => { | ||
@@ -54,2 +139,3 @@ it('should update private feature flags for pixel perfect', () => { | ||
platformEdition: 'free', | ||
enableNewNavigationForResponsiveUi: false, | ||
enablePixelPerfectExperience: false, | ||
@@ -72,2 +158,6 @@ portalLogoPage: '/logo', | ||
}, | ||
enableNewNavigationForResponsiveUi: { | ||
value: true, | ||
source: 'user' | ||
}, | ||
enablePixelPerfectExperience: { | ||
@@ -87,2 +177,3 @@ value: true, | ||
platformEdition: 'growth', | ||
enableNewNavigationForResponsiveUi: true, | ||
enablePixelPerfectExperience: true, | ||
@@ -89,0 +180,0 @@ portalLogoPage: '/logo1', |
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
109260
2206
2