Skip to content

Commit

Permalink
chore: strategy variant flag removed (#4603)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwasniew committed Sep 4, 2023
1 parent 8aace7f commit 45e089f
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 57 deletions.
Expand Up @@ -258,7 +258,6 @@ export const FeatureStrategyForm = ({
<StyledHr />
<ConditionallyRender
condition={
Boolean(uiConfig?.flags?.strategyVariant) &&
strategy.parameters != null &&
'stickiness' in strategy.parameters
}
Expand Down
Expand Up @@ -29,15 +29,13 @@ import PermissionIconButton from 'component/common/PermissionIconButton/Permissi
import { Edit } from '@mui/icons-material';
import { VariantInfoAlert } from 'component/common/VariantInfoAlert/VariantInfoAlert';
import { StrategyVariantsPreferredAlert } from 'component/common/StrategyVariantsUpgradeAlert/StrategyVariantsUpgradeAlert';
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';

const StyledButtonContainer = styled('div')(({ theme }) => ({
display: 'flex',
gap: theme.spacing(1.5),
}));

export const FeatureEnvironmentVariants = () => {
const { uiConfig } = useUiConfig();
const { setToastData, setToastApiError } = useToast();
const theme = useTheme();
const isSmallScreen = useMediaQuery(theme.breakpoints.down('md'));
Expand Down Expand Up @@ -267,11 +265,7 @@ export const FeatureEnvironmentVariants = () => {
}
>
<VariantInfoAlert mode="feature" />
<ConditionallyRender
condition={Boolean(uiConfig?.flags?.strategyVariant)}
show={<StrategyVariantsPreferredAlert />}
/>

<StrategyVariantsPreferredAlert />
{environments.map(environment => {
const otherEnvsWithVariants = environments.filter(
({ name, variants }) =>
Expand Down
Expand Up @@ -182,7 +182,6 @@ export const ProjectDefaultStrategyForm = ({
/>
<ConditionallyRender
condition={
Boolean(uiConfig?.flags?.strategyVariant) &&
strategy.parameters != null &&
'stickiness' in strategy.parameters
}
Expand Down
2 changes: 0 additions & 2 deletions src/lib/__snapshots__/create-config.test.ts.snap
Expand Up @@ -97,7 +97,6 @@ exports[`should create default config 1`] = `
"proPlanAutoCharge": false,
"responseTimeWithAppNameKillSwitch": false,
"slackAppAddon": false,
"strategyVariant": false,
"strictSchemaValidation": false,
},
},
Expand Down Expand Up @@ -132,7 +131,6 @@ exports[`should create default config 1`] = `
"proPlanAutoCharge": false,
"responseTimeWithAppNameKillSwitch": false,
"slackAppAddon": false,
"strategyVariant": false,
"strictSchemaValidation": false,
},
"externalResolver": {
Expand Down
4 changes: 1 addition & 3 deletions src/lib/db/feature-toggle-client-store.ts
Expand Up @@ -253,9 +253,7 @@ export default class FeatureToggleClientStore
parameters: mapValues(row.parameters || {}, ensureStringValue),
sortOrder: row.sort_order,
};
if (this.flagResolver.isEnabled('strategyVariant')) {
strategy.variants = row.strategy_variants || [];
}
strategy.variants = row.strategy_variants || [];
return strategy;
}

Expand Down
4 changes: 1 addition & 3 deletions src/lib/features/playground/advanced-playground.test.ts
Expand Up @@ -10,9 +10,7 @@ let app: IUnleashTest;
let db: ITestDb;

beforeAll(async () => {
db = await dbInit('advanced_playground', getLogger, {
experimental: { flags: { strategyVariant: true } },
});
db = await dbInit('advanced_playground', getLogger);
app = await setupAppWithCustomConfig(
db.stores,
{
Expand Down
64 changes: 30 additions & 34 deletions src/lib/services/feature-toggle-service.ts
Expand Up @@ -398,12 +398,10 @@ class FeatureToggleService {
disabled: featureStrategy.disabled,
constraints: featureStrategy.constraints || [],
parameters: featureStrategy.parameters,
sortOrder: featureStrategy.sortOrder,
segments: segments.map((segment) => segment.id) ?? [],
};

if (this.flagResolver.isEnabled('strategyVariant')) {
result.sortOrder = featureStrategy.sortOrder;
}
return result;
}

Expand Down Expand Up @@ -460,39 +458,37 @@ class FeatureToggleService {
);
}),
);
if (this.flagResolver.isEnabled('strategyVariant')) {
const newOrder = (
await this.getStrategiesForEnvironment(
project,
featureName,
environment,
)
const newOrder = (
await this.getStrategiesForEnvironment(
project,
featureName,
environment,
)
.sort((strategy1, strategy2) => {
if (
typeof strategy1.sortOrder === 'number' &&
typeof strategy2.sortOrder === 'number'
) {
return strategy1.sortOrder - strategy2.sortOrder;
}
return 0;
})
.map((strategy) => strategy.id);
)
.sort((strategy1, strategy2) => {
if (
typeof strategy1.sortOrder === 'number' &&
typeof strategy2.sortOrder === 'number'
) {
return strategy1.sortOrder - strategy2.sortOrder;
}
return 0;
})
.map((strategy) => strategy.id);

const eventData: StrategyIds = { strategyIds: newOrder };
const eventData: StrategyIds = { strategyIds: newOrder };

const tags = await this.tagStore.getAllTagsForFeature(featureName);
const event = new StrategiesOrderChangedEvent({
featureName,
environment,
project,
createdBy,
preData: eventPreData,
data: eventData,
tags: tags,
});
await this.eventStore.store(event);
}
const tags = await this.tagStore.getAllTagsForFeature(featureName);
const event = new StrategiesOrderChangedEvent({
featureName,
environment,
project,
createdBy,
preData: eventPreData,
data: eventData,
tags: tags,
});
await this.eventStore.store(event);
}

async createStrategy(
Expand Down Expand Up @@ -1226,7 +1222,7 @@ class FeatureToggleService {
segments: [],
title: strategy.title,
disabled: strategy.disabled,
// FIXME: Should we return sortOrder here, or adjust OpenAPI?
sortOrder: strategy.sortOrder,
};

if (segments && segments.length > 0) {
Expand Down
5 changes: 0 additions & 5 deletions src/lib/types/experimental.ts
Expand Up @@ -20,7 +20,6 @@ export type IFlagKey =
| 'disableBulkToggle'
| 'disableNotifications'
| 'advancedPlayground'
| 'strategyVariant'
| 'slackAppAddon'
| 'filterInvalidClientMetrics'
| 'lastSeenByEnvironment'
Expand Down Expand Up @@ -96,10 +95,6 @@ const flags: IFlags = {
process.env.DISABLE_NOTIFICATIONS,
false,
),
strategyVariant: parseEnvVarBoolean(
process.env.UNLEASH_STRATEGY_VARIANT,
false,
),
slackAppAddon: parseEnvVarBoolean(
process.env.UNLEASH_SLACK_APP_ADDON,
false,
Expand Down
1 change: 0 additions & 1 deletion src/server-dev.ts
Expand Up @@ -37,7 +37,6 @@ process.nextTick(async () => {
embedProxyFrontend: true,
anonymiseEventLog: false,
responseTimeWithAppNameKillSwitch: false,
strategyVariant: true,
slackAppAddon: true,
lastSeenByEnvironment: true,
newApplicationList: true,
Expand Down

0 comments on commit 45e089f

Please sign in to comment.