mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	feat: Open-Source Strategy Constraints (#2112)
This commits lift the flags and makes Strategy Constraints available to all users of Unleash. Read more in the docs: https://docs.getunleash.io/advanced/strategy_constraints Enjoy! @ivarconr Author and maintainer
This commit is contained in:
		
							parent
							
								
									9ba441b9cf
								
							
						
					
					
						commit
						ef965d66de
					
				@ -141,23 +141,13 @@ export const FeatureStrategyForm = ({
 | 
				
			|||||||
                    />
 | 
					                    />
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            />
 | 
					            />
 | 
				
			||||||
            <ConditionallyRender
 | 
					 | 
				
			||||||
                condition={Boolean(uiConfig.flags.C || uiConfig.flags.CO)}
 | 
					 | 
				
			||||||
                show={
 | 
					 | 
				
			||||||
            <FeatureStrategyConstraints
 | 
					            <FeatureStrategyConstraints
 | 
				
			||||||
                projectId={feature.project}
 | 
					                projectId={feature.project}
 | 
				
			||||||
                environmentId={environmentId}
 | 
					                environmentId={environmentId}
 | 
				
			||||||
                strategy={strategy}
 | 
					                strategy={strategy}
 | 
				
			||||||
                setStrategy={setStrategy}
 | 
					                setStrategy={setStrategy}
 | 
				
			||||||
            />
 | 
					            />
 | 
				
			||||||
                }
 | 
					            <hr className={styles.hr} />
 | 
				
			||||||
            />
 | 
					 | 
				
			||||||
            <ConditionallyRender
 | 
					 | 
				
			||||||
                condition={Boolean(
 | 
					 | 
				
			||||||
                    uiConfig.flags.SE || uiConfig.flags.C || uiConfig.flags.CO
 | 
					 | 
				
			||||||
                )}
 | 
					 | 
				
			||||||
                show={<hr className={styles.hr} />}
 | 
					 | 
				
			||||||
            />
 | 
					 | 
				
			||||||
            <FeatureStrategyType
 | 
					            <FeatureStrategyType
 | 
				
			||||||
                strategy={strategy}
 | 
					                strategy={strategy}
 | 
				
			||||||
                strategyDefinition={strategyDefinition}
 | 
					                strategyDefinition={strategyDefinition}
 | 
				
			||||||
 | 
				
			|||||||
@ -147,7 +147,6 @@ exports[`returns all baseRoutes 1`] = `
 | 
				
			|||||||
  },
 | 
					  },
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    "component": [Function],
 | 
					    "component": [Function],
 | 
				
			||||||
    "flag": "C",
 | 
					 | 
				
			||||||
    "menu": {},
 | 
					    "menu": {},
 | 
				
			||||||
    "parent": "/context",
 | 
					    "parent": "/context",
 | 
				
			||||||
    "path": "/context/create",
 | 
					    "path": "/context/create",
 | 
				
			||||||
@ -156,7 +155,6 @@ exports[`returns all baseRoutes 1`] = `
 | 
				
			|||||||
  },
 | 
					  },
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    "component": [Function],
 | 
					    "component": [Function],
 | 
				
			||||||
    "flag": "C",
 | 
					 | 
				
			||||||
    "menu": {},
 | 
					    "menu": {},
 | 
				
			||||||
    "parent": "/context",
 | 
					    "parent": "/context",
 | 
				
			||||||
    "path": "/context/edit/:name",
 | 
					    "path": "/context/edit/:name",
 | 
				
			||||||
@ -165,7 +163,6 @@ exports[`returns all baseRoutes 1`] = `
 | 
				
			|||||||
  },
 | 
					  },
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    "component": [Function],
 | 
					    "component": [Function],
 | 
				
			||||||
    "flag": "C",
 | 
					 | 
				
			||||||
    "menu": {
 | 
					    "menu": {
 | 
				
			||||||
      "advanced": true,
 | 
					      "advanced": true,
 | 
				
			||||||
      "mobile": true,
 | 
					      "mobile": true,
 | 
				
			||||||
 | 
				
			|||||||
@ -9,7 +9,7 @@ import AdminUsers from 'component/admin/users/UsersAdmin';
 | 
				
			|||||||
import { GroupsAdmin } from 'component/admin/groups/GroupsAdmin';
 | 
					import { GroupsAdmin } from 'component/admin/groups/GroupsAdmin';
 | 
				
			||||||
import { AuthSettings } from 'component/admin/auth/AuthSettings';
 | 
					import { AuthSettings } from 'component/admin/auth/AuthSettings';
 | 
				
			||||||
import Login from 'component/user/Login/Login';
 | 
					import Login from 'component/user/Login/Login';
 | 
				
			||||||
import { C, EEA, P, RE, SE, UG } from 'component/common/flags';
 | 
					import { EEA, P, RE, SE, UG } from 'component/common/flags';
 | 
				
			||||||
import { NewUser } from 'component/user/NewUser/NewUser';
 | 
					import { NewUser } from 'component/user/NewUser/NewUser';
 | 
				
			||||||
import ResetPassword from 'component/user/ResetPassword/ResetPassword';
 | 
					import ResetPassword from 'component/user/ResetPassword/ResetPassword';
 | 
				
			||||||
import ForgottenPassword from 'component/user/ForgottenPassword/ForgottenPassword';
 | 
					import ForgottenPassword from 'component/user/ForgottenPassword/ForgottenPassword';
 | 
				
			||||||
@ -203,7 +203,6 @@ export const routes: IRoute[] = [
 | 
				
			|||||||
        title: 'Create',
 | 
					        title: 'Create',
 | 
				
			||||||
        component: CreateUnleashContextPage,
 | 
					        component: CreateUnleashContextPage,
 | 
				
			||||||
        type: 'protected',
 | 
					        type: 'protected',
 | 
				
			||||||
        flag: C,
 | 
					 | 
				
			||||||
        menu: {},
 | 
					        menu: {},
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
@ -212,7 +211,6 @@ export const routes: IRoute[] = [
 | 
				
			|||||||
        title: ':name',
 | 
					        title: ':name',
 | 
				
			||||||
        component: EditContext,
 | 
					        component: EditContext,
 | 
				
			||||||
        type: 'protected',
 | 
					        type: 'protected',
 | 
				
			||||||
        flag: C,
 | 
					 | 
				
			||||||
        menu: {},
 | 
					        menu: {},
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
@ -220,7 +218,6 @@ export const routes: IRoute[] = [
 | 
				
			|||||||
        title: 'Context fields',
 | 
					        title: 'Context fields',
 | 
				
			||||||
        component: ContextList,
 | 
					        component: ContextList,
 | 
				
			||||||
        type: 'protected',
 | 
					        type: 'protected',
 | 
				
			||||||
        flag: C,
 | 
					 | 
				
			||||||
        menu: { mobile: true, advanced: true },
 | 
					        menu: { mobile: true, advanced: true },
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -2,7 +2,6 @@ import { useAuthSplash } from 'hooks/api/getters/useAuth/useAuthSplash';
 | 
				
			|||||||
import { useLocation, Navigate } from 'react-router-dom';
 | 
					import { useLocation, Navigate } from 'react-router-dom';
 | 
				
			||||||
import { matchPath } from 'react-router';
 | 
					import { matchPath } from 'react-router';
 | 
				
			||||||
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
 | 
					import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
 | 
				
			||||||
import { IFlags } from 'interfaces/uiConfig';
 | 
					 | 
				
			||||||
import { IAuthSplash } from 'hooks/api/getters/useAuth/useAuthEndpoint';
 | 
					import { IAuthSplash } from 'hooks/api/getters/useAuth/useAuthEndpoint';
 | 
				
			||||||
import { activeSplashIds, SplashId } from 'component/splash/splash';
 | 
					import { activeSplashIds, SplashId } from 'component/splash/splash';
 | 
				
			||||||
import { useAuthUser } from 'hooks/api/getters/useAuth/useAuthUser';
 | 
					import { useAuthUser } from 'hooks/api/getters/useAuth/useAuthUser';
 | 
				
			||||||
@ -31,10 +30,7 @@ export const SplashPageRedirect = () => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    // Find the splash page to show (if any).
 | 
					    // Find the splash page to show (if any).
 | 
				
			||||||
    const showSplashId = activeSplashIds.find(splashId => {
 | 
					    const showSplashId = activeSplashIds.find(splashId => {
 | 
				
			||||||
        return (
 | 
					        return !hasSeenSplashId(splashId, splash);
 | 
				
			||||||
            isSplashRelevant(splashId, uiConfig.flags) &&
 | 
					 | 
				
			||||||
            !hasSeenSplashId(splashId, splash)
 | 
					 | 
				
			||||||
        );
 | 
					 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!showSplashId) {
 | 
					    if (!showSplashId) {
 | 
				
			||||||
@ -47,11 +43,3 @@ export const SplashPageRedirect = () => {
 | 
				
			|||||||
const hasSeenSplashId = (splashId: SplashId, splash: IAuthSplash): boolean => {
 | 
					const hasSeenSplashId = (splashId: SplashId, splash: IAuthSplash): boolean => {
 | 
				
			||||||
    return Boolean(splash[splashId]);
 | 
					    return Boolean(splash[splashId]);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					 | 
				
			||||||
const isSplashRelevant = (splashId: SplashId, flags: IFlags): boolean => {
 | 
					 | 
				
			||||||
    if (splashId === 'operators') {
 | 
					 | 
				
			||||||
        return Boolean(flags.C || flags.CO);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    return true;
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
				
			|||||||
@ -3070,15 +3070,10 @@ camelcase@^6.2.0:
 | 
				
			|||||||
  resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a"
 | 
					  resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a"
 | 
				
			||||||
  integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==
 | 
					  integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==
 | 
				
			||||||
 | 
					
 | 
				
			||||||
caniuse-lite@^1.0.30001317:
 | 
					caniuse-lite@^1.0.30001317, caniuse-lite@^1.0.30001332:
 | 
				
			||||||
  version "1.0.30001325"
 | 
					  version "1.0.30001414"
 | 
				
			||||||
  resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001325.tgz#2b4ad19b77aa36f61f2eaf72e636d7481d55e606"
 | 
					  resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001414.tgz"
 | 
				
			||||||
  integrity sha512-sB1bZHjseSjDtijV1Hb7PB2Zd58Kyx+n/9EotvZ4Qcz2K3d0lWB8dB4nb8wN/TsOGFq3UuAm0zQZNQ4SoR7TrQ==
 | 
					  integrity sha512-t55jfSaWjCdocnFdKQoO+d2ct9C59UZg4dY3OnUlSZ447r8pUtIKdp0hpAzrGFultmTC+Us+KpKi4GZl/LXlFg==
 | 
				
			||||||
 | 
					 | 
				
			||||||
caniuse-lite@^1.0.30001332:
 | 
					 | 
				
			||||||
  version "1.0.30001339"
 | 
					 | 
				
			||||||
  resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001339.tgz#f9aece4ea8156071613b27791547ba0b33f176cf"
 | 
					 | 
				
			||||||
  integrity sha512-Es8PiVqCe+uXdms0Gu5xP5PF2bxLR7OBp3wUzUnuO7OHzhOfCyg3hdiGWVPVxhiuniOzng+hTc1u3fEQ0TlkSQ==
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
caseless@~0.12.0:
 | 
					caseless@~0.12.0:
 | 
				
			||||||
  version "0.12.0"
 | 
					  version "0.12.0"
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user