From e8d0fdba1fc478569b1c982843047df876b52536 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nuno=20G=C3=B3is?= Date: Mon, 12 Dec 2022 13:21:12 +0000 Subject: [PATCH] remove feature flag: toggle tag filtering (#2668) https://linear.app/unleash/issue/2-482/clean-up-feature-flag-after-this-goes-ga Relevant discussion: https://unleash-internal.slack.com/archives/C046LV6HH6W/p1670837328201169 --- .../ProjectFeatureToggles.tsx | 46 +++++++++---------- .../__snapshots__/create-config.test.ts.snap | 2 - src/lib/db/feature-strategy-store.ts | 17 ++----- src/lib/db/feature-toggle-client-store.ts | 22 ++++----- src/lib/types/experimental.ts | 4 -- src/server-dev.ts | 1 - 6 files changed, 36 insertions(+), 56 deletions(-) diff --git a/frontend/src/component/project/Project/ProjectFeatureToggles/ProjectFeatureToggles.tsx b/frontend/src/component/project/Project/ProjectFeatureToggles/ProjectFeatureToggles.tsx index 1f7094a1e3..7ea95be247 100644 --- a/frontend/src/component/project/Project/ProjectFeatureToggles/ProjectFeatureToggles.tsx +++ b/frontend/src/component/project/Project/ProjectFeatureToggles/ProjectFeatureToggles.tsx @@ -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']; @@ -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', @@ -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) { diff --git a/src/lib/__snapshots__/create-config.test.ts.snap b/src/lib/__snapshots__/create-config.test.ts.snap index 11f6788257..5b2f85022f 100644 --- a/src/lib/__snapshots__/create-config.test.ts.snap +++ b/src/lib/__snapshots__/create-config.test.ts.snap @@ -77,7 +77,6 @@ exports[`should create default config 1`] = ` "networkView": false, "proxyReturnAllToggles": false, "responseTimeWithAppName": false, - "toggleTagFiltering": false, "tokensLastSeen": false, "variantsPerEnvironment": false, }, @@ -94,7 +93,6 @@ exports[`should create default config 1`] = ` "networkView": false, "proxyReturnAllToggles": false, "responseTimeWithAppName": false, - "toggleTagFiltering": false, "tokensLastSeen": false, "variantsPerEnvironment": false, }, diff --git a/src/lib/db/feature-strategy-store.ts b/src/lib/db/feature-strategy-store.ts index bb924578ff..4ee0848bdd 100644 --- a/src/lib/db/feature-strategy-store.ts +++ b/src/lib/db/feature-strategy-store.ts @@ -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', @@ -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)[]; - 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( diff --git a/src/lib/db/feature-toggle-client-store.ts b/src/lib/db/feature-toggle-client-store.ts index 81ad4e8ffa..8fec32a84c 100644 --- a/src/lib/db/feature-toggle-client-store.ts +++ b/src/lib/db/feature-toggle-client-store.ts @@ -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 () { diff --git a/src/lib/types/experimental.ts b/src/lib/types/experimental.ts index c1a9483bc6..b8486b6948 100644 --- a/src/lib/types/experimental.ts +++ b/src/lib/types/experimental.ts @@ -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, diff --git a/src/server-dev.ts b/src/server-dev.ts index d3e394c78d..ee4a373e09 100644 --- a/src/server-dev.ts +++ b/src/server-dev.ts @@ -40,7 +40,6 @@ process.nextTick(async () => { anonymiseEventLog: false, responseTimeWithAppName: true, changeRequests: true, - toggleTagFiltering: true, favorites: true, variantsPerEnvironment: true, networkView: true,