From 77fbac01e4d9c6a0701421a923295f291aa85eee Mon Sep 17 00:00:00 2001 From: Jaanus Sellin Date: Mon, 11 Sep 2023 13:28:43 +0300 Subject: [PATCH] feat: remove newApplicationsList feature flag (#4653) --- .../ApplicationList/OldApplicationList.tsx | 99 ------------------- .../TemporaryApplicationListWrapper.tsx | 16 --- frontend/src/component/menu/routes.ts | 7 +- frontend/src/interfaces/uiConfig.ts | 1 - .../__snapshots__/create-config.test.ts.snap | 2 - src/lib/db/client-applications-store.ts | 59 ++++------- src/lib/db/index.ts | 4 +- src/lib/types/experimental.ts | 5 - src/server-dev.ts | 1 - src/test/e2e/api/admin/metrics.e2e.test.ts | 12 +-- 10 files changed, 25 insertions(+), 181 deletions(-) delete mode 100644 frontend/src/component/application/ApplicationList/OldApplicationList.tsx delete mode 100644 frontend/src/component/application/ApplicationList/TemporaryApplicationListWrapper.tsx diff --git a/frontend/src/component/application/ApplicationList/OldApplicationList.tsx b/frontend/src/component/application/ApplicationList/OldApplicationList.tsx deleted file mode 100644 index 0e94082383..0000000000 --- a/frontend/src/component/application/ApplicationList/OldApplicationList.tsx +++ /dev/null @@ -1,99 +0,0 @@ -import { useEffect, useMemo, useState } from 'react'; -import { CircularProgress, Link } from '@mui/material'; -import { Warning } from '@mui/icons-material'; -import { AppsLinkList, styles as themeStyles } from 'component/common'; -import { PageContent } from 'component/common/PageContent/PageContent'; -import { PageHeader } from 'component/common/PageHeader/PageHeader'; -import useApplications from 'hooks/api/getters/useApplications/useApplications'; -import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; -import { useSearchParams } from 'react-router-dom'; -import { Search } from 'component/common/Search/Search'; -import { safeRegExp } from '@server/util/escape-regex'; - -type PageQueryType = Partial>; - -export const OldApplicationList = () => { - const { applications, loading } = useApplications(); - const [searchParams, setSearchParams] = useSearchParams(); - const [searchValue, setSearchValue] = useState( - searchParams.get('search') || '' - ); - - useEffect(() => { - const tableState: PageQueryType = {}; - if (searchValue) { - tableState.search = searchValue; - } - - setSearchParams(tableState, { - replace: true, - }); - }, [searchValue, setSearchParams]); - - const filteredApplications = useMemo(() => { - const regExp = safeRegExp(searchValue, 'i'); - return searchValue - ? applications?.filter(a => regExp.test(a.appName)) - : applications; - }, [applications, searchValue]); - - const renderNoApplications = () => ( - <> -
-
-
- Oh snap, it does not seem like you have connected any - applications. To connect your application to Unleash you will - require a Client SDK. -
-
- You can read more about how to use Unleash in your application - in the{' '} - - documentation. - -
- - ); - - if (!filteredApplications) { - return ; - } - - let applicationCount = - filteredApplications.length < applications.length - ? `${filteredApplications.length} of ${applications.length}` - : applications.length; - - return ( - <> - - } - /> - } - > -
- 0} - show={} - elseShow={ - ...loading
} - elseShow={renderNoApplications()} - /> - } - /> - -
- - ); -}; diff --git a/frontend/src/component/application/ApplicationList/TemporaryApplicationListWrapper.tsx b/frontend/src/component/application/ApplicationList/TemporaryApplicationListWrapper.tsx deleted file mode 100644 index 0c86a6f2ea..0000000000 --- a/frontend/src/component/application/ApplicationList/TemporaryApplicationListWrapper.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; -import useUiConfig from '../../../hooks/api/getters/useUiConfig/useUiConfig'; -import { ApplicationList } from './ApplicationList'; -import { OldApplicationList } from './OldApplicationList'; - -export const TemporaryApplicationListWrapper = () => { - const { uiConfig } = useUiConfig(); - - return ( - } - elseShow={} - /> - ); -}; diff --git a/frontend/src/component/menu/routes.ts b/frontend/src/component/menu/routes.ts index 60ba3b2838..c0003f479a 100644 --- a/frontend/src/component/menu/routes.ts +++ b/frontend/src/component/menu/routes.ts @@ -44,8 +44,8 @@ import { LazyProject } from 'component/project/Project/LazyProject'; import { LoginHistory } from 'component/loginHistory/LoginHistory'; import { FeatureTypesList } from 'component/featureTypes/FeatureTypesList'; import { AddonsList } from 'component/integrations/IntegrationList/AddonsList'; -import { TemporaryApplicationListWrapper } from 'component/application/ApplicationList/TemporaryApplicationListWrapper'; import { ViewIntegration } from 'component/integrations/ViewIntegration/ViewIntegration'; +import { ApplicationList } from '../application/ApplicationList/ApplicationList'; export const routes: IRoute[] = [ // Splash @@ -181,7 +181,7 @@ export const routes: IRoute[] = [ { path: '/applications', title: 'Applications', - component: TemporaryApplicationListWrapper, + component: ApplicationList, type: 'protected', menu: { mobile: true, advanced: true }, }, @@ -502,14 +502,13 @@ const computeRoutes = () => { export const getCondensedRoutes = (routes: IRoute[]): INavigationMenuItem[] => { return routes.map(route => { - const condensedRoute = { + return { path: route.path, flag: route.flag, title: route.title, menu: route.menu, configFlag: route.configFlag, }; - return condensedRoute; }); }; diff --git a/frontend/src/interfaces/uiConfig.ts b/frontend/src/interfaces/uiConfig.ts index be189c7201..91772b67f4 100644 --- a/frontend/src/interfaces/uiConfig.ts +++ b/frontend/src/interfaces/uiConfig.ts @@ -60,7 +60,6 @@ export type UiFlags = { customRootRolesKillSwitch?: boolean; strategyVariant?: boolean; lastSeenByEnvironment?: boolean; - newApplicationList?: boolean; integrationsRework?: boolean; multipleRoles?: boolean; featureNamingPattern?: boolean; diff --git a/src/lib/__snapshots__/create-config.test.ts.snap b/src/lib/__snapshots__/create-config.test.ts.snap index fb4390013d..152ce1a640 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`] = ` }, "migrationLock": true, "multipleRoles": false, - "newApplicationList": false, "personalAccessTokensKillSwitch": false, "proPlanAutoCharge": false, "responseTimeWithAppNameKillSwitch": false, @@ -130,7 +129,6 @@ exports[`should create default config 1`] = ` }, "migrationLock": true, "multipleRoles": false, - "newApplicationList": false, "personalAccessTokensKillSwitch": false, "proPlanAutoCharge": false, "responseTimeWithAppNameKillSwitch": false, diff --git a/src/lib/db/client-applications-store.ts b/src/lib/db/client-applications-store.ts index 48b0571d02..1ca45fdd23 100644 --- a/src/lib/db/client-applications-store.ts +++ b/src/lib/db/client-applications-store.ts @@ -7,7 +7,6 @@ import { import { Logger, LogProvider } from '../logger'; import { IApplicationQuery } from '../types/query'; import { Db } from './db'; -import { IFlagResolver } from '../types'; const COLUMNS = [ 'app_name', @@ -110,18 +109,10 @@ export default class ClientApplicationsStore { private db: Db; - private flagResolver: IFlagResolver; - private logger: Logger; - constructor( - db: Db, - eventBus: EventEmitter, - getLogger: LogProvider, - flagResolver: IFlagResolver, - ) { + constructor(db: Db, eventBus: EventEmitter, getLogger: LogProvider) { this.db = db; - this.flagResolver = flagResolver; this.logger = getLogger('client-applications-store.ts'); } @@ -193,38 +184,26 @@ export default class ClientApplicationsStore async getAppsForStrategy( query: IApplicationQuery, ): Promise { - if (this.flagResolver.isEnabled('newApplicationList')) { - const rows = await this.db - .select([ - ...COLUMNS.map((column) => `${TABLE}.${column}`), - 'project', - 'environment', - ]) - .from(TABLE) - .leftJoin( - TABLE_USAGE, - `${TABLE_USAGE}.app_name`, - `${TABLE}.app_name`, - ); - const apps = reduceRows(rows); + const rows = await this.db + .select([ + ...COLUMNS.map((column) => `${TABLE}.${column}`), + 'project', + 'environment', + ]) + .from(TABLE) + .leftJoin( + TABLE_USAGE, + `${TABLE_USAGE}.app_name`, + `${TABLE}.app_name`, + ); + const apps = reduceRows(rows); - if (query.strategyName) { - return apps.filter((app) => - app.strategies.includes(query.strategyName), - ); - } - return apps; - } else { - const rows = await this.db.select(COLUMNS).from(TABLE); - const apps = rows.map(mapRow); - - if (query.strategyName) { - return apps.filter((app) => - app.strategies.includes(query.strategyName), - ); - } - return apps; + if (query.strategyName) { + return apps.filter((app) => + app.strategies.includes(query.strategyName), + ); } + return apps; } async getUnannounced(): Promise { diff --git a/src/lib/db/index.ts b/src/lib/db/index.ts index fddc5a5e3e..e6329e3b04 100644 --- a/src/lib/db/index.ts +++ b/src/lib/db/index.ts @@ -1,5 +1,4 @@ -import { IUnleashConfig } from '../types/option'; -import { IUnleashStores } from '../types/stores'; +import { IUnleashConfig, IUnleashStores } from '../types'; import EventStore from './event-store'; import FeatureToggleStore from './feature-toggle-store'; @@ -54,7 +53,6 @@ export const createStores = ( db, eventBus, getLogger, - config.flagResolver, ), clientInstanceStore: new ClientInstanceStore(db, eventBus, getLogger), clientMetricsStoreV2: new ClientMetricsStoreV2( diff --git a/src/lib/types/experimental.ts b/src/lib/types/experimental.ts index 736f3cda30..76c1f63d05 100644 --- a/src/lib/types/experimental.ts +++ b/src/lib/types/experimental.ts @@ -24,7 +24,6 @@ export type IFlagKey = | 'filterInvalidClientMetrics' | 'lastSeenByEnvironment' | 'customRootRolesKillSwitch' - | 'newApplicationList' | 'integrationsRework' | 'multipleRoles' | 'featureNamingPattern' @@ -120,10 +119,6 @@ const flags: IFlags = { process.env.UNLEASH_EXPERIMENTAL_MULTIPLE_ROLES, false, ), - newApplicationList: parseEnvVarBoolean( - process.env.UNLEASH_EXPERIMENTAL_NEW_APPLICATION_LIST, - false, - ), featureNamingPattern: parseEnvVarBoolean( process.env.UNLEASH_EXPERIMENTAL_FEATURE_NAMING_PATTERN, false, diff --git a/src/server-dev.ts b/src/server-dev.ts index ad2cac1670..0ebe247baa 100644 --- a/src/server-dev.ts +++ b/src/server-dev.ts @@ -40,7 +40,6 @@ process.nextTick(async () => { slackAppAddon: true, lastSeenByEnvironment: true, integrationsRework: true, - newApplicationList: true, featureNamingPattern: true, doraMetrics: true, }, diff --git a/src/test/e2e/api/admin/metrics.e2e.test.ts b/src/test/e2e/api/admin/metrics.e2e.test.ts index 5051e4c234..29346ba4ef 100644 --- a/src/test/e2e/api/admin/metrics.e2e.test.ts +++ b/src/test/e2e/api/admin/metrics.e2e.test.ts @@ -9,16 +9,8 @@ let app: IUnleashTest; let db: ITestDb; beforeAll(async () => { - db = await dbInit('metrics_serial', getLogger, { - experimental: { flags: { newApplicationList: true } }, - }); - app = await setupAppWithCustomConfig(db.stores, { - experimental: { - flags: { - newApplicationList: true, - }, - }, - }); + db = await dbInit('metrics_serial', getLogger, {}); + app = await setupAppWithCustomConfig(db.stores, {}); }); beforeEach(async () => {