Skip to content

Commit

Permalink
remove feature flag: toggle tag filtering (#2668)
Browse files Browse the repository at this point in the history
  • Loading branch information
nunogois committed Dec 12, 2022
1 parent a3fdef1 commit e8d0fdb
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 56 deletions.
Expand Up @@ -43,6 +43,7 @@ import { ColumnsMenu } from './ColumnsMenu/ColumnsMenu';
import { useStyles } from './ProjectFeatureToggles.styles';
import { usePinnedFavorites } from 'hooks/usePinnedFavorites';
import { useFavoriteFeaturesApi } from 'hooks/api/actions/useFavoriteFeaturesApi/useFavoriteFeaturesApi';
import { FeatureTagCell } from 'component/common/Table/cells/FeatureTagCell/FeatureTagCell';

interface IProjectFeatureTogglesProps {
features: IProject['features'];
Expand Down Expand Up @@ -239,20 +240,18 @@ export const ProjectFeatureToggles = ({
sortType: 'alphanumeric',
searchable: true,
},
// FIXME: no tags on project feature toggles from backend
// {
// id: 'tags',
// Header: 'Tags',
// accessor: (row: IFeatureToggleListItem) =>
// row.tags
// ?.map(({ type, value }) => `${type}:${value}`)
// .join('\n') || '',
// Cell: FeatureTagCell,
// width: 80,
// hideInMenu: true,
// searchable: true,
// isVisible: false,
// },
{
id: 'tags',
Header: 'Tags',
accessor: (row: IFeatureToggleListItem) =>
row.tags
?.map(({ type, value }) => `${type}:${value}`)
.join('\n') || '',
Cell: FeatureTagCell,
width: 80,
hideInMenu: true,
searchable: true,
},
{
Header: 'Created',
accessor: 'createdAt',
Expand Down Expand Up @@ -429,16 +428,15 @@ export const ProjectFeatureToggles = ({
useSortBy
);

// TODO: update after tags are added, move to other useEffect
// useEffect(() => {
// if (!features.some(({ tags }) => tags?.length)) {
// setHiddenColumns(hiddenColumns => [...hiddenColumns, 'tags']);
// } else {
// setHiddenColumns(hiddenColumns =>
// hiddenColumns.filter(column => column !== 'tags')
// );
// }
// }, [setHiddenColumns, features]);
useEffect(() => {
if (!features.some(({ tags }) => tags?.length)) {
setHiddenColumns(hiddenColumns => [...hiddenColumns, 'tags']);
} else {
setHiddenColumns(hiddenColumns =>
hiddenColumns.filter(column => column !== 'tags')
);
}
}, [setHiddenColumns, features]);

useEffect(() => {
if (loading) {
Expand Down
2 changes: 0 additions & 2 deletions src/lib/__snapshots__/create-config.test.ts.snap
Expand Up @@ -77,7 +77,6 @@ exports[`should create default config 1`] = `
"networkView": false,
"proxyReturnAllToggles": false,
"responseTimeWithAppName": false,
"toggleTagFiltering": false,
"tokensLastSeen": false,
"variantsPerEnvironment": false,
},
Expand All @@ -94,7 +93,6 @@ exports[`should create default config 1`] = `
"networkView": false,
"proxyReturnAllToggles": false,
"responseTimeWithAppName": false,
"toggleTagFiltering": false,
"tokensLastSeen": false,
"variantsPerEnvironment": false,
},
Expand Down
17 changes: 4 additions & 13 deletions src/lib/db/feature-strategy-store.ts
Expand Up @@ -427,7 +427,8 @@ class FeatureStrategiesStore implements IFeatureStrategiesStore {
'environments',
'feature_environments.environment',
'environments.name',
);
)
.leftJoin('feature_tag as ft', 'ft.feature_name', 'features.name');

let selectColumns = [
'features.name as feature_name',
Expand All @@ -439,20 +440,10 @@ class FeatureStrategiesStore implements IFeatureStrategiesStore {
'feature_environments.environment as environment',
'environments.type as environment_type',
'environments.sort_order as environment_sort_order',
'ft.tag_value as tag_value',
'ft.tag_type as tag_type',
] as (string | Raw<any>)[];

if (this.flagResolver.isEnabled('toggleTagFiltering')) {
query = query.leftJoin(
'feature_tag as ft',
'ft.feature_name',
'features.name',
);
selectColumns = [
...selectColumns,
'ft.tag_value as tag_value',
'ft.tag_type as tag_type',
];
}
if (userId && this.flagResolver.isEnabled('favorites')) {
query = query.leftJoin(`favorite_features`, function () {
this.on('favorite_features.feature', 'features.name').andOnVal(
Expand Down
22 changes: 10 additions & 12 deletions src/lib/db/feature-toggle-client-store.ts
Expand Up @@ -135,18 +135,16 @@ export default class FeatureToggleClientStore
.leftJoin('segments', `segments.id`, `fss.segment_id`);

if (isAdmin) {
if (this.flagResolver.isEnabled('toggleTagFiltering')) {
query = query.leftJoin(
'feature_tag as ft',
'ft.feature_name',
'features.name',
);
selectColumns = [
...selectColumns,
'ft.tag_value as tag_value',
'ft.tag_type as tag_type',
];
}
query = query.leftJoin(
'feature_tag as ft',
'ft.feature_name',
'features.name',
);
selectColumns = [
...selectColumns,
'ft.tag_value as tag_value',
'ft.tag_type as tag_type',
];

if (userId && this.flagResolver.isEnabled('favorites')) {
query = query.leftJoin(`favorite_features`, function () {
Expand Down
4 changes: 0 additions & 4 deletions src/lib/types/experimental.ts
Expand Up @@ -26,10 +26,6 @@ export const defaultExperimentalOptions = {
process.env.UNLEASH_EXPERIMENTAL_RESPONSE_TIME_WITH_APP_NAME,
false,
),
toggleTagFiltering: parseEnvVarBoolean(
process.env.UNLEASH_EXPERIMENTAL_TOGGLE_TAG_FILTERING,
false,
),
proxyReturnAllToggles: parseEnvVarBoolean(
process.env.UNLEASH_EXPERIMENTAL_PROXY_RETURN_ALL_TOGGLES,
false,
Expand Down
1 change: 0 additions & 1 deletion src/server-dev.ts
Expand Up @@ -40,7 +40,6 @@ process.nextTick(async () => {
anonymiseEventLog: false,
responseTimeWithAppName: true,
changeRequests: true,
toggleTagFiltering: true,
favorites: true,
variantsPerEnvironment: true,
networkView: true,
Expand Down

0 comments on commit e8d0fdb

Please sign in to comment.