mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-10 17:53:36 +02:00
add featureSwitchRefactor flag
This commit is contained in:
parent
581fb40554
commit
7e6ef0539f
@ -4,8 +4,7 @@ import { useRequiredPathParam } from 'hooks/useRequiredPathParam';
|
|||||||
import { styled } from '@mui/material';
|
import { styled } from '@mui/material';
|
||||||
import StringTruncator from 'component/common/StringTruncator/StringTruncator';
|
import StringTruncator from 'component/common/StringTruncator/StringTruncator';
|
||||||
import { FeatureOverviewSidePanelEnvironmentHider } from './FeatureOverviewSidePanelEnvironmentHider';
|
import { FeatureOverviewSidePanelEnvironmentHider } from './FeatureOverviewSidePanelEnvironmentHider';
|
||||||
import { FeatureToggleSwitch } from 'component/project/Project/ProjectFeatureToggles/FeatureToggleSwitch/FeatureToggleSwitch';
|
import { FeatureToggleSwitch } from 'component/project/Project/ProjectFeatureToggles/FeatureToggleSwitch/LegacyFeatureToggleSwitch';
|
||||||
import { useMemo } from 'react';
|
|
||||||
|
|
||||||
const StyledContainer = styled('div')(({ theme }) => ({
|
const StyledContainer = styled('div')(({ theme }) => ({
|
||||||
marginLeft: theme.spacing(-1.5),
|
marginLeft: theme.spacing(-1.5),
|
||||||
@ -59,20 +58,6 @@ export const FeatureOverviewSidePanelEnvironmentSwitch = ({
|
|||||||
if (callback) callback();
|
if (callback) callback();
|
||||||
};
|
};
|
||||||
|
|
||||||
const featureEnvironment = feature?.environments?.find(
|
|
||||||
(env) => env.name === environment.name,
|
|
||||||
);
|
|
||||||
|
|
||||||
const hasStrategies =
|
|
||||||
featureEnvironment?.strategies &&
|
|
||||||
featureEnvironment?.strategies?.length > 0;
|
|
||||||
|
|
||||||
const hasEnabledStrategies =
|
|
||||||
hasStrategies &&
|
|
||||||
featureEnvironment?.strategies?.some(
|
|
||||||
(strategy) => strategy.disabled !== true,
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledContainer>
|
<StyledContainer>
|
||||||
<StyledLabel>
|
<StyledLabel>
|
||||||
@ -80,12 +65,9 @@ export const FeatureOverviewSidePanelEnvironmentSwitch = ({
|
|||||||
featureId={feature.name}
|
featureId={feature.name}
|
||||||
projectId={projectId}
|
projectId={projectId}
|
||||||
environmentName={environment.name}
|
environmentName={environment.name}
|
||||||
type={featureEnvironment?.type || ''}
|
|
||||||
onToggle={handleToggle}
|
onToggle={handleToggle}
|
||||||
onError={showInfoBox}
|
onError={showInfoBox}
|
||||||
value={enabled}
|
value={enabled}
|
||||||
hasStrategies={hasStrategies}
|
|
||||||
hasEnabledStrategies={hasEnabledStrategies}
|
|
||||||
/>
|
/>
|
||||||
{children ?? defaultContent}
|
{children ?? defaultContent}
|
||||||
</StyledLabel>
|
</StyledLabel>
|
||||||
|
@ -39,7 +39,7 @@ interface IFeatureToggleSwitchProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated
|
* @deprecated remove when flag `featureSwitchRefactor` is removed
|
||||||
*/
|
*/
|
||||||
export const FeatureToggleSwitch: VFC<IFeatureToggleSwitchProps> = ({
|
export const FeatureToggleSwitch: VFC<IFeatureToggleSwitchProps> = ({
|
||||||
projectId,
|
projectId,
|
||||||
|
@ -112,7 +112,7 @@ const defaultSort: SortingRule<string> & {
|
|||||||
} = { id: 'createdAt' };
|
} = { id: 'createdAt' };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated
|
* @deprecated remove when flag `featureSwitchRefactor` is removed
|
||||||
*/
|
*/
|
||||||
export const ProjectFeatureToggles = ({
|
export const ProjectFeatureToggles = ({
|
||||||
features,
|
features,
|
||||||
|
@ -4,11 +4,13 @@ import useProject, {
|
|||||||
} from 'hooks/api/getters/useProject/useProject';
|
} from 'hooks/api/getters/useProject/useProject';
|
||||||
import { Box, styled } from '@mui/material';
|
import { Box, styled } from '@mui/material';
|
||||||
import { ProjectFeatureToggles as LegacyProjectFeatureToggles } from './ProjectFeatureToggles/LegacyProjectFeatureToggles';
|
import { ProjectFeatureToggles as LegacyProjectFeatureToggles } from './ProjectFeatureToggles/LegacyProjectFeatureToggles';
|
||||||
|
import { ProjectFeatureToggles } from './ProjectFeatureToggles/ProjectFeatureToggles';
|
||||||
import ProjectInfo from './ProjectInfo/ProjectInfo';
|
import ProjectInfo from './ProjectInfo/ProjectInfo';
|
||||||
import { usePageTitle } from 'hooks/usePageTitle';
|
import { usePageTitle } from 'hooks/usePageTitle';
|
||||||
import { useRequiredPathParam } from 'hooks/useRequiredPathParam';
|
import { useRequiredPathParam } from 'hooks/useRequiredPathParam';
|
||||||
import { useLastViewedProject } from 'hooks/useLastViewedProject';
|
import { useLastViewedProject } from 'hooks/useLastViewedProject';
|
||||||
import { ProjectStats } from './ProjectStats/ProjectStats';
|
import { ProjectStats } from './ProjectStats/ProjectStats';
|
||||||
|
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
||||||
|
|
||||||
const refreshInterval = 15 * 1000;
|
const refreshInterval = 15 * 1000;
|
||||||
|
|
||||||
@ -59,11 +61,24 @@ const ProjectOverview = () => {
|
|||||||
<StyledContentContainer>
|
<StyledContentContainer>
|
||||||
<ProjectStats stats={project.stats} />
|
<ProjectStats stats={project.stats} />
|
||||||
<StyledProjectToggles>
|
<StyledProjectToggles>
|
||||||
<LegacyProjectFeatureToggles
|
<ConditionallyRender
|
||||||
key={loading ? 'loading' : 'ready'}
|
condition={true}
|
||||||
features={features}
|
show={() => (
|
||||||
environments={environments}
|
<ProjectFeatureToggles
|
||||||
loading={loading}
|
key={loading ? 'loading' : 'ready'}
|
||||||
|
features={features}
|
||||||
|
environments={environments}
|
||||||
|
loading={loading}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
elseShow={() => (
|
||||||
|
<LegacyProjectFeatureToggles
|
||||||
|
key={loading ? 'loading' : 'ready'}
|
||||||
|
features={features}
|
||||||
|
environments={environments}
|
||||||
|
loading={loading}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
/>
|
/>
|
||||||
</StyledProjectToggles>
|
</StyledProjectToggles>
|
||||||
</StyledContentContainer>
|
</StyledContentContainer>
|
||||||
|
@ -72,6 +72,7 @@ export type UiFlags = {
|
|||||||
internalMessageBanners?: boolean;
|
internalMessageBanners?: boolean;
|
||||||
disableEnvsOnRevive?: boolean;
|
disableEnvsOnRevive?: boolean;
|
||||||
playgroundImprovements?: boolean;
|
playgroundImprovements?: boolean;
|
||||||
|
featureSwitchRefactor?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface IVersionInfo {
|
export interface IVersionInfo {
|
||||||
|
@ -601,15 +601,17 @@ class FeatureStrategiesStore implements IFeatureStrategiesStore {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
selectColumns = [
|
if (this.flagResolver.isEnabled('featureSwitchRefactor')) {
|
||||||
...selectColumns,
|
selectColumns = [
|
||||||
this.db.raw(
|
...selectColumns,
|
||||||
'EXISTS (SELECT 1 FROM feature_strategies WHERE feature_strategies.feature_name = features.name AND feature_strategies.environment = feature_environments.environment) as has_strategies',
|
this.db.raw(
|
||||||
),
|
'EXISTS (SELECT 1 FROM feature_strategies WHERE feature_strategies.feature_name = features.name AND feature_strategies.environment = feature_environments.environment) as has_strategies',
|
||||||
this.db.raw(
|
),
|
||||||
'EXISTS (SELECT 1 FROM feature_strategies WHERE feature_strategies.feature_name = features.name AND feature_strategies.environment = feature_environments.environment AND (feature_strategies.disabled IS NULL OR feature_strategies.disabled = false)) as has_enabled_strategies',
|
this.db.raw(
|
||||||
),
|
'EXISTS (SELECT 1 FROM feature_strategies WHERE feature_strategies.feature_name = features.name AND feature_strategies.environment = feature_environments.environment AND (feature_strategies.disabled IS NULL OR feature_strategies.disabled = false)) as has_enabled_strategies',
|
||||||
];
|
),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
query = query.select(selectColumns);
|
query = query.select(selectColumns);
|
||||||
const rows = await query;
|
const rows = await query;
|
||||||
|
@ -38,7 +38,8 @@ export type IFlagKey =
|
|||||||
| 'internalMessageBanner'
|
| 'internalMessageBanner'
|
||||||
| 'separateAdminClientApi'
|
| 'separateAdminClientApi'
|
||||||
| 'disableEnvsOnRevive'
|
| 'disableEnvsOnRevive'
|
||||||
| 'playgroundImprovements';
|
| 'playgroundImprovements'
|
||||||
|
| 'featureSwitchRefactor';
|
||||||
|
|
||||||
export type IFlags = Partial<{ [key in IFlagKey]: boolean | Variant }>;
|
export type IFlags = Partial<{ [key in IFlagKey]: boolean | Variant }>;
|
||||||
|
|
||||||
@ -178,6 +179,10 @@ const flags: IFlags = {
|
|||||||
process.env.UNLEASH_EXPERIMENTAL_PLAYGROUND_IMPROVEMENTS,
|
process.env.UNLEASH_EXPERIMENTAL_PLAYGROUND_IMPROVEMENTS,
|
||||||
false,
|
false,
|
||||||
),
|
),
|
||||||
|
featureSwitchRefactor: parseEnvVarBoolean(
|
||||||
|
process.env.UNLEASH_EXPERIMENTAL_FEATURE_SWITCH_REFACTOR,
|
||||||
|
false,
|
||||||
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
export const defaultExperimentalOptions: IExperimentalOptions = {
|
export const defaultExperimentalOptions: IExperimentalOptions = {
|
||||||
|
@ -194,8 +194,8 @@ export interface IEnvironmentBase {
|
|||||||
|
|
||||||
export interface IEnvironmentOverview extends IEnvironmentBase {
|
export interface IEnvironmentOverview extends IEnvironmentBase {
|
||||||
variantCount: number;
|
variantCount: number;
|
||||||
hasStrategies: boolean;
|
hasStrategies?: boolean;
|
||||||
hasEnabledStrategies: boolean;
|
hasEnabledStrategies?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IFeatureOverview {
|
export interface IFeatureOverview {
|
||||||
|
@ -49,6 +49,7 @@ process.nextTick(async () => {
|
|||||||
useLastSeenRefactor: true,
|
useLastSeenRefactor: true,
|
||||||
separateAdminClientApi: true,
|
separateAdminClientApi: true,
|
||||||
playgroundImprovements: true,
|
playgroundImprovements: true,
|
||||||
|
featureSwitchRefactor: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
authentication: {
|
authentication: {
|
||||||
|
Loading…
Reference in New Issue
Block a user