diff --git a/frontend/src/component/context/ContextFieldUsage/ContextFieldUsage.test.tsx b/frontend/src/component/context/ContextFieldUsage/ContextFieldUsage.test.tsx index ad7b22c9a5..2d093df840 100644 --- a/frontend/src/component/context/ContextFieldUsage/ContextFieldUsage.test.tsx +++ b/frontend/src/component/context/ContextFieldUsage/ContextFieldUsage.test.tsx @@ -24,12 +24,6 @@ const setupRoutes = () => { ], } ); - testServerRoute(server, '/api/admin/ui-config', { - flags: { - segmentContextFieldUsage: true, - }, - }); - testServerRoute(server, '/api/admin/projects', { version: 1, projects: [ diff --git a/frontend/src/component/context/ContextForm/ContextForm.tsx b/frontend/src/component/context/ContextForm/ContextForm.tsx index 106a77c6ed..a4d280bade 100644 --- a/frontend/src/component/context/ContextForm/ContextForm.tsx +++ b/frontend/src/component/context/ContextForm/ContextForm.tsx @@ -267,10 +267,7 @@ export const ContextForm: React.FC = ({ /> {stickiness ? 'On' : 'Off'} - } - /> + {children} diff --git a/frontend/src/component/context/ContextList/ContextList/ContextList.test.tsx b/frontend/src/component/context/ContextList/ContextList/ContextList.test.tsx index 24beb1cf89..4910c04535 100644 --- a/frontend/src/component/context/ContextList/ContextList/ContextList.test.tsx +++ b/frontend/src/component/context/ContextList/ContextList/ContextList.test.tsx @@ -20,12 +20,6 @@ const setupRoutes = () => { createdAt: '2023-05-24T06:23:07.797Z', }, ]); - testServerRoute(server, '/api/admin/ui-config', { - flags: { - SE: true, - segmentContextFieldUsage: true, - }, - }); }; test('should show the count of projects and features used in', async () => { diff --git a/frontend/src/component/context/ContextList/ContextList/ContextList.tsx b/frontend/src/component/context/ContextList/ContextList/ContextList.tsx index 0b525a91da..71cebf0d81 100644 --- a/frontend/src/component/context/ContextList/ContextList/ContextList.tsx +++ b/frontend/src/component/context/ContextList/ContextList/ContextList.tsx @@ -86,17 +86,13 @@ const ContextList: VFC = () => { ), sortType: 'alphanumeric', }, - ...(uiConfig.flags.segmentContextFieldUsage - ? [ - { - Header: 'Used in', - width: '60%', - Cell: ({ row: { original } }: any) => ( - - ), - }, - ] - : []), + { + Header: 'Used in', + width: '60%', + Cell: ({ row: { original } }: any) => ( + + ), + }, { Header: 'Actions', id: 'Actions', @@ -128,7 +124,7 @@ const ContextList: VFC = () => { sortType: 'number', }, ], - [uiConfig.flags.segmentContextFieldUsage] + [] ); const initialState = useMemo( diff --git a/frontend/src/component/segments/SegmentTable/SegmentTable.test.tsx b/frontend/src/component/segments/SegmentTable/SegmentTable.test.tsx index 30dd6fc0fa..fdd3ba0be8 100644 --- a/frontend/src/component/segments/SegmentTable/SegmentTable.test.tsx +++ b/frontend/src/component/segments/SegmentTable/SegmentTable.test.tsx @@ -25,7 +25,6 @@ const setupRoutes = () => { testServerRoute(server, '/api/admin/ui-config', { flags: { SE: true, - segmentContextFieldUsage: true, }, }); }; diff --git a/frontend/src/component/segments/SegmentTable/SegmentTable.tsx b/frontend/src/component/segments/SegmentTable/SegmentTable.tsx index f94b14adec..e026417961 100644 --- a/frontend/src/component/segments/SegmentTable/SegmentTable.tsx +++ b/frontend/src/component/segments/SegmentTable/SegmentTable.tsx @@ -59,10 +59,7 @@ export const SegmentTable = () => { return segments; }, [segments, projectId]); - const columns = useMemo( - () => getColumns(uiConfig.flags.segmentContextFieldUsage), - [uiConfig.flags.segmentContextFieldUsage] - ); + const columns = useMemo(() => getColumns(), []); const { getTableProps, getTableBodyProps, @@ -177,7 +174,7 @@ export const SegmentTable = () => { ); }; -const getColumns = (segmentContextFieldUsage?: boolean) => [ +const getColumns = () => [ { id: 'Icon', width: '1%', @@ -201,18 +198,13 @@ const getColumns = (segmentContextFieldUsage?: boolean) => [ /> ), }, - ...(segmentContextFieldUsage - ? [ - { - Header: 'Used in', - width: '60%', - Cell: ({ row: { original } }: any) => ( - - ), - }, - ] - : []), - + { + Header: 'Used in', + width: '60%', + Cell: ({ row: { original } }: any) => ( + + ), + }, { Header: 'Project', accessor: 'project', diff --git a/frontend/src/interfaces/uiConfig.ts b/frontend/src/interfaces/uiConfig.ts index bf466e0074..33848a4a99 100644 --- a/frontend/src/interfaces/uiConfig.ts +++ b/frontend/src/interfaces/uiConfig.ts @@ -48,7 +48,6 @@ export interface IFlags { demo?: boolean; googleAuthEnabled?: boolean; disableBulkToggle?: boolean; - segmentContextFieldUsage?: boolean; disableNotifications?: boolean; advancedPlayground?: boolean; customRootRoles?: boolean; diff --git a/src/lib/__snapshots__/create-config.test.ts.snap b/src/lib/__snapshots__/create-config.test.ts.snap index 1ef0beac75..4a10893ac4 100644 --- a/src/lib/__snapshots__/create-config.test.ts.snap +++ b/src/lib/__snapshots__/create-config.test.ts.snap @@ -94,7 +94,6 @@ exports[`should create default config 1`] = ` "personalAccessTokensKillSwitch": false, "proPlanAutoCharge": false, "responseTimeWithAppNameKillSwitch": false, - "segmentContextFieldUsage": false, "slackAppAddon": false, "strategySplittedButton": false, "strategyVariant": false, @@ -130,7 +129,6 @@ exports[`should create default config 1`] = ` "personalAccessTokensKillSwitch": false, "proPlanAutoCharge": false, "responseTimeWithAppNameKillSwitch": false, - "segmentContextFieldUsage": false, "slackAppAddon": false, "strategySplittedButton": false, "strategyVariant": false, diff --git a/src/lib/db/context-field-store.ts b/src/lib/db/context-field-store.ts index 698c239f8d..6c85d08e20 100644 --- a/src/lib/db/context-field-store.ts +++ b/src/lib/db/context-field-store.ts @@ -87,42 +87,33 @@ class ContextFieldStore implements IContextFieldStore { } async getAll(): Promise { - if (this.flagResolver.isEnabled('segmentContextFieldUsage')) { - const rows = await this.db - .select( - this.prefixColumns(), - 'used_in_projects', - 'used_in_features', - ) - .countDistinct( - `${T.featureStrategies}.project_name AS used_in_projects`, - ) - .countDistinct( - `${T.featureStrategies}.feature_name AS used_in_features`, - ) - .from(T.contextFields) - .joinRaw( - `LEFT JOIN ${T.featureStrategies} ON EXISTS ( + const rows = await this.db + .select( + this.prefixColumns(), + 'used_in_projects', + 'used_in_features', + ) + .countDistinct( + `${T.featureStrategies}.project_name AS used_in_projects`, + ) + .countDistinct( + `${T.featureStrategies}.feature_name AS used_in_features`, + ) + .from(T.contextFields) + .joinRaw( + `LEFT JOIN ${T.featureStrategies} ON EXISTS ( SELECT 1 FROM jsonb_array_elements(${T.featureStrategies}.constraints) AS elem WHERE elem ->> 'contextName' = ${T.contextFields}.name )`, - ) - .groupBy( - this.prefixColumns( - COLUMNS.filter((column) => column !== 'legal_values'), - ), - ) - .orderBy('name', 'asc'); - return rows.map(mapRow); - } else { - const rows = await this.db - .select(COLUMNS) - .from(T.contextFields) - .orderBy('name', 'asc'); - - return rows.map(mapRow); - } + ) + .groupBy( + this.prefixColumns( + COLUMNS.filter((column) => column !== 'legal_values'), + ), + ) + .orderBy('name', 'asc'); + return rows.map(mapRow); } async get(key: string): Promise { diff --git a/src/lib/db/segment-store.ts b/src/lib/db/segment-store.ts index 2a88d6d6a9..956080edfb 100644 --- a/src/lib/db/segment-store.ts +++ b/src/lib/db/segment-store.ts @@ -107,42 +107,33 @@ export default class SegmentStore implements ISegmentStore { } async getAll(): Promise { - if (this.flagResolver.isEnabled('segmentContextFieldUsage')) { - const rows: ISegmentRow[] = await this.db - .select( - this.prefixColumns(), - 'used_in_projects', - 'used_in_features', - ) - .countDistinct( - `${T.featureStrategies}.project_name AS used_in_projects`, - ) - .countDistinct( - `${T.featureStrategies}.feature_name AS used_in_features`, - ) - .from(T.segments) - .leftJoin( - T.featureStrategySegment, - `${T.segments}.id`, - `${T.featureStrategySegment}.segment_id`, - ) - .leftJoin( - T.featureStrategies, - `${T.featureStrategies}.id`, - `${T.featureStrategySegment}.feature_strategy_id`, - ) - .groupBy(this.prefixColumns()) - .orderBy('name', 'asc'); + const rows: ISegmentRow[] = await this.db + .select( + this.prefixColumns(), + 'used_in_projects', + 'used_in_features', + ) + .countDistinct( + `${T.featureStrategies}.project_name AS used_in_projects`, + ) + .countDistinct( + `${T.featureStrategies}.feature_name AS used_in_features`, + ) + .from(T.segments) + .leftJoin( + T.featureStrategySegment, + `${T.segments}.id`, + `${T.featureStrategySegment}.segment_id`, + ) + .leftJoin( + T.featureStrategies, + `${T.featureStrategies}.id`, + `${T.featureStrategySegment}.feature_strategy_id`, + ) + .groupBy(this.prefixColumns()) + .orderBy('name', 'asc'); - return rows.map(this.mapRow); - } else { - const rows: ISegmentRow[] = await this.db - .select(this.prefixColumns()) - .from(T.segments) - .orderBy('name', 'asc'); - - return rows.map(this.mapRow); - } + return rows.map(this.mapRow); } async getActive(): Promise { diff --git a/src/lib/types/experimental.ts b/src/lib/types/experimental.ts index 302e9891ab..7a80d8b4ba 100644 --- a/src/lib/types/experimental.ts +++ b/src/lib/types/experimental.ts @@ -19,7 +19,6 @@ export type IFlagKey = | 'demo' | 'googleAuthEnabled' | 'disableBulkToggle' - | 'segmentContextFieldUsage' | 'disableNotifications' | 'advancedPlayground' | 'customRootRoles' @@ -96,10 +95,6 @@ const flags: IFlags = { process.env.DISABLE_BULK_TOGGLE, false, ), - segmentContextFieldUsage: parseEnvVarBoolean( - process.env.UNLEASH_SSEGMENT_CONTEXT_FIELD_USAGE, - false, - ), disableNotifications: parseEnvVarBoolean( process.env.DISABLE_NOTIFICATIONS, false, diff --git a/src/server-dev.ts b/src/server-dev.ts index aa3139c656..ebed002237 100644 --- a/src/server-dev.ts +++ b/src/server-dev.ts @@ -37,7 +37,6 @@ process.nextTick(async () => { embedProxyFrontend: true, anonymiseEventLog: false, responseTimeWithAppNameKillSwitch: false, - segmentContextFieldUsage: true, advancedPlayground: true, strategySplittedButton: true, strategyVariant: true,