From 34e101750dfb12f8d1556be57a50a1e7425c8eb5 Mon Sep 17 00:00:00 2001 From: Gitar Date: Tue, 20 Aug 2024 13:35:39 +0000 Subject: [PATCH 1/5] [Gitar] Updating TSX files --- .../IntegrationForm/IntegrationForm.tsx | 4 +-- .../IntegrationCardMenu.tsx | 34 +++++++------------ 2 files changed, 14 insertions(+), 24 deletions(-) diff --git a/frontend/src/component/integrations/IntegrationForm/IntegrationForm.tsx b/frontend/src/component/integrations/IntegrationForm/IntegrationForm.tsx index 65ec5f123959..979db6bf3253 100644 --- a/frontend/src/component/integrations/IntegrationForm/IntegrationForm.tsx +++ b/frontend/src/component/integrations/IntegrationForm/IntegrationForm.tsx @@ -52,7 +52,6 @@ import { IntegrationDelete } from './IntegrationDelete/IntegrationDelete'; import { IntegrationStateSwitch } from './IntegrationStateSwitch/IntegrationStateSwitch'; import { capitalizeFirst } from 'utils/capitalizeFirst'; import { IntegrationHowToSection } from '../IntegrationHowToSection/IntegrationHowToSection'; -import { useUiFlag } from 'hooks/useUiFlag'; import { IntegrationEventsModal } from '../IntegrationEvents/IntegrationEventsModal'; import AccessContext from 'contexts/AccessContext'; @@ -116,7 +115,6 @@ export const IntegrationForm: VFC = ({ }); const [eventsModalOpen, setEventsModalOpen] = useState(false); const { isAdmin } = useContext(AccessContext); - const integrationEventsEnabled = useUiFlag('integrationEvents'); const submitText = editMode ? 'Update' : 'Create'; const url = `${uiConfig.unleashUrl}/api/admin/addons${ @@ -318,7 +316,7 @@ export const IntegrationForm: VFC = ({ integration setEventsModalOpen(true)}> View events diff --git a/frontend/src/component/integrations/IntegrationList/IntegrationCard/IntegrationCardMenu/IntegrationCardMenu.tsx b/frontend/src/component/integrations/IntegrationList/IntegrationCard/IntegrationCardMenu/IntegrationCardMenu.tsx index 6cdcecc1a028..715fd38f7b0b 100644 --- a/frontend/src/component/integrations/IntegrationList/IntegrationCard/IntegrationCardMenu/IntegrationCardMenu.tsx +++ b/frontend/src/component/integrations/IntegrationList/IntegrationCard/IntegrationCardMenu/IntegrationCardMenu.tsx @@ -25,8 +25,6 @@ import useAddons from 'hooks/api/getters/useAddons/useAddons'; import useToast from 'hooks/useToast'; import { formatUnknownError } from 'utils/formatUnknownError'; import { Dialogue } from 'component/common/Dialogue/Dialogue'; -import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; -import { useUiFlag } from 'hooks/useUiFlag'; import Visibility from '@mui/icons-material/Visibility'; import { PermissionHOC } from 'component/common/PermissionHOC/PermissionHOC'; import { IntegrationEventsModal } from 'component/integrations/IntegrationEvents/IntegrationEventsModal'; @@ -55,7 +53,6 @@ export const IntegrationCardMenu: VFC = ({ const { refetchAddons } = useAddons(); const { setToastData, setToastApiError } = useToast(); const [eventsModalOpen, setEventsModalOpen] = useState(false); - const integrationEventsEnabled = useUiFlag('integrationEvents'); const closeMenu = () => { setIsMenuOpen(false); @@ -131,24 +128,19 @@ export const IntegrationCardMenu: VFC = ({ }} onClose={handleMenuClick} > - - {({ hasAccess }) => ( - setEventsModalOpen(true)} - disabled={!hasAccess} - > - - - - View events - - )} - - } - /> + + {({ hasAccess }) => ( + setEventsModalOpen(true)} + disabled={!hasAccess} + > + + + + View events + + )} + { setIsToggleOpen(true); From ce21de902c21b3136b1729cae1234272619eedbf Mon Sep 17 00:00:00 2001 From: Gitar Date: Tue, 20 Aug 2024 13:35:39 +0000 Subject: [PATCH 2/5] [Gitar] Updating TypeScript files --- .../useIntegrationEvents.ts | 5 +---- frontend/src/interfaces/uiConfig.ts | 1 - .../__snapshots__/create-config.test.ts.snap | 1 - src/lib/addons/addon.ts | 4 +--- .../integration-events-service.ts | 2 -- .../integration-events.e2e.test.ts | 4 +--- .../openapi/spec/integration-events-schema.ts | 10 +-------- src/lib/routes/admin-api/addon.ts | 21 ++----------------- src/lib/types/experimental.ts | 5 ----- src/server-dev.ts | 1 - 10 files changed, 6 insertions(+), 48 deletions(-) diff --git a/frontend/src/hooks/api/getters/useIntegrationEvents/useIntegrationEvents.ts b/frontend/src/hooks/api/getters/useIntegrationEvents/useIntegrationEvents.ts index 95176e4ce25b..f10b58833618 100644 --- a/frontend/src/hooks/api/getters/useIntegrationEvents/useIntegrationEvents.ts +++ b/frontend/src/hooks/api/getters/useIntegrationEvents/useIntegrationEvents.ts @@ -5,7 +5,6 @@ import useSWRInfinite, { } from 'swr/infinite'; import { formatApiPath } from 'utils/formatPath'; import type { IntegrationEvents } from 'interfaces/integrationEvent'; -import { useUiFlag } from 'hooks/useUiFlag'; import AccessContext from 'contexts/AccessContext'; import handleErrorResponses from '../httpErrorResponseHandler'; @@ -21,15 +20,13 @@ export const useIntegrationEvents = ( options: SWRInfiniteConfiguration = {}, ) => { const { isAdmin } = useContext(AccessContext); - const integrationEventsEnabled = useUiFlag('integrationEvents'); const getKey: SWRInfiniteKeyLoader = ( pageIndex: number, previousPageData: IntegrationEvents, ) => { // Does not meet conditions - if (!integrationId || !isAdmin || !integrationEventsEnabled) - return null; + if (!integrationId || !isAdmin) return null; // Reached the end if (previousPageData && !previousPageData.integrationEvents.length) diff --git a/frontend/src/interfaces/uiConfig.ts b/frontend/src/interfaces/uiConfig.ts index c00a70a7cab6..00a3097c4e86 100644 --- a/frontend/src/interfaces/uiConfig.ts +++ b/frontend/src/interfaces/uiConfig.ts @@ -90,7 +90,6 @@ export type UiFlags = { flagCreator?: boolean; resourceLimits?: boolean; insightsV2?: boolean; - integrationEvents?: boolean; newEventSearch?: boolean; archiveProjects?: boolean; projectListImprovements?: boolean; diff --git a/src/lib/__snapshots__/create-config.test.ts.snap b/src/lib/__snapshots__/create-config.test.ts.snap index d5f1617b9b68..5435adcf91f7 100644 --- a/src/lib/__snapshots__/create-config.test.ts.snap +++ b/src/lib/__snapshots__/create-config.test.ts.snap @@ -121,7 +121,6 @@ exports[`should create default config 1`] = ` "filterInvalidClientMetrics": false, "googleAuthEnabled": false, "insightsV2": false, - "integrationEvents": false, "killInsightsUI": false, "killScheduledChangeRequestCache": false, "maintenanceMode": false, diff --git a/src/lib/addons/addon.ts b/src/lib/addons/addon.ts index 6ba3dc7405d9..9cec97f189a4 100644 --- a/src/lib/addons/addon.ts +++ b/src/lib/addons/addon.ts @@ -92,9 +92,7 @@ export default abstract class Addon { async registerEvent( integrationEvent: IntegrationEventWriteModel, ): Promise { - if (this.flagResolver.isEnabled('integrationEvents')) { - await this.integrationEventsService.registerEvent(integrationEvent); - } + await this.integrationEventsService.registerEvent(integrationEvent); } destroy?(): void; diff --git a/src/lib/features/integration-events/integration-events-service.ts b/src/lib/features/integration-events/integration-events-service.ts index d41630ffb7ee..bbfaf6b2605b 100644 --- a/src/lib/features/integration-events/integration-events-service.ts +++ b/src/lib/features/integration-events/integration-events-service.ts @@ -44,8 +44,6 @@ export class IntegrationEventsService { } async cleanUpEvents(): Promise { - if (!this.flagResolver.isEnabled('integrationEvents')) return; - await this.integrationEventsStore.cleanUpEvents(); } } diff --git a/src/lib/features/integration-events/integration-events.e2e.test.ts b/src/lib/features/integration-events/integration-events.e2e.test.ts index cd1b26f218dc..0c2476d946b9 100644 --- a/src/lib/features/integration-events/integration-events.e2e.test.ts +++ b/src/lib/features/integration-events/integration-events.e2e.test.ts @@ -51,9 +51,7 @@ beforeAll(async () => { db.stores, { experimental: { - flags: { - integrationEvents: true, - }, + flags: {}, }, }, db.rawDatabase, diff --git a/src/lib/openapi/spec/integration-events-schema.ts b/src/lib/openapi/spec/integration-events-schema.ts index ad04834e31c0..ce32cd1f3c07 100644 --- a/src/lib/openapi/spec/integration-events-schema.ts +++ b/src/lib/openapi/spec/integration-events-schema.ts @@ -10,15 +10,7 @@ export const integrationEventsSchema = { type: 'object', additionalProperties: false, required: ['integrationEvents'], - properties: { - integrationEvents: { - type: 'array', - description: 'A list of integration events.', - items: { - $ref: integrationEventSchema.$id, - }, - }, - }, + properties: {}, components: { schemas: { integrationEventSchema, diff --git a/src/lib/routes/admin-api/addon.ts b/src/lib/routes/admin-api/addon.ts index ae10aaf0e61d..64f0ff7eb72c 100644 --- a/src/lib/routes/admin-api/addon.ts +++ b/src/lib/routes/admin-api/addon.ts @@ -38,7 +38,7 @@ import { type IntegrationEventsSchema, integrationEventsSchema, } from '../../openapi/spec/integration-events-schema'; -import { BadDataError, NotFoundError } from '../../error'; +import { BadDataError } from '../../error'; import type { IntegrationEventsService } from '../../services'; type AddonServices = Pick< @@ -276,10 +276,6 @@ Note: passing \`null\` as a value for the description property will set it to an >, res: Response, ): Promise { - if (!this.flagResolver.isEnabled('integrationEvents')) { - throw new NotFoundError('This feature is not enabled'); - } - const { id } = req.params; if (Number.isNaN(Number(id))) { @@ -288,24 +284,11 @@ Note: passing \`null\` as a value for the description property will set it to an const { limit = '50', offset = '0' } = req.query; - const normalizedLimit = - Number(limit) > 0 && Number(limit) <= 100 ? Number(limit) : 50; - const normalizedOffset = Number(offset) > 0 ? Number(offset) : 0; - - const integrationEvents = - await this.integrationEventsService.getPaginatedEvents( - id, - normalizedLimit, - normalizedOffset, - ); - this.openApiService.respondWithValidation( 200, res, integrationEventsSchema.$id, - { - integrationEvents: serializeDates(integrationEvents), - }, + {}, ); } } diff --git a/src/lib/types/experimental.ts b/src/lib/types/experimental.ts index e6df34fecd5a..92cb8fbe8900 100644 --- a/src/lib/types/experimental.ts +++ b/src/lib/types/experimental.ts @@ -60,7 +60,6 @@ export type IFlagKey = | 'extendedMetrics' | 'removeUnsafeInlineStyleSrc' | 'insightsV2' - | 'integrationEvents' | 'originMiddleware' | 'newEventSearch' | 'archiveProjects' @@ -296,10 +295,6 @@ const flags: IFlags = { process.env.UNLEASH_EXPERIMENTAL_INSIGHTS_V2, false, ), - integrationEvents: parseEnvVarBoolean( - process.env.UNLEASH_EXPERIMENTAL_INTEGRATION_EVENTS, - false, - ), originMiddleware: parseEnvVarBoolean( process.env.UNLEASH_EXPERIMENTAL_ORIGIN_MIDDLEWARE, false, diff --git a/src/server-dev.ts b/src/server-dev.ts index 33037fd15747..b418feb2d128 100644 --- a/src/server-dev.ts +++ b/src/server-dev.ts @@ -53,7 +53,6 @@ process.nextTick(async () => { resourceLimits: true, extendedMetrics: true, insightsV2: true, - integrationEvents: true, originMiddleware: true, newEventSearch: true, projectListImprovements: true, From acc5f97eca0e27dde51a4060008db143ddc932b7 Mon Sep 17 00:00:00 2001 From: David Leek Date: Wed, 21 Aug 2024 09:39:46 +0200 Subject: [PATCH 3/5] chore: add back integration events api code and openapi spec parts that were deleted in error --- src/lib/openapi/spec/integration-events-schema.ts | 10 +++++++++- src/lib/routes/admin-api/addon.ts | 15 ++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/lib/openapi/spec/integration-events-schema.ts b/src/lib/openapi/spec/integration-events-schema.ts index ce32cd1f3c07..ad04834e31c0 100644 --- a/src/lib/openapi/spec/integration-events-schema.ts +++ b/src/lib/openapi/spec/integration-events-schema.ts @@ -10,7 +10,15 @@ export const integrationEventsSchema = { type: 'object', additionalProperties: false, required: ['integrationEvents'], - properties: {}, + properties: { + integrationEvents: { + type: 'array', + description: 'A list of integration events.', + items: { + $ref: integrationEventSchema.$id, + }, + }, + }, components: { schemas: { integrationEventSchema, diff --git a/src/lib/routes/admin-api/addon.ts b/src/lib/routes/admin-api/addon.ts index 64f0ff7eb72c..c65112f7c9c5 100644 --- a/src/lib/routes/admin-api/addon.ts +++ b/src/lib/routes/admin-api/addon.ts @@ -284,11 +284,24 @@ Note: passing \`null\` as a value for the description property will set it to an const { limit = '50', offset = '0' } = req.query; + const normalizedLimit = + Number(limit) > 0 && Number(limit) <= 100 ? Number(limit) : 50; + const normalizedOffset = Number(offset) > 0 ? Number(offset) : 0; + + const integrationEvents = + await this.integrationEventsService.getPaginatedEvents( + id, + normalizedLimit, + normalizedOffset, + ); + this.openApiService.respondWithValidation( 200, res, integrationEventsSchema.$id, - {}, + { + integrationEvents: serializeDates(integrationEvents), + }, ); } } From 412e15b4bd2f38458cb8eb741e424eaa39e4f20a Mon Sep 17 00:00:00 2001 From: David Leek Date: Wed, 21 Aug 2024 14:13:36 +0200 Subject: [PATCH 4/5] fix: remove readded feature flag from bad merge --- frontend/src/interfaces/uiConfig.ts | 1 - src/lib/__snapshots__/create-config.test.ts.snap | 1 - src/lib/types/experimental.ts | 4 ---- src/server-dev.ts | 1 - 4 files changed, 7 deletions(-) diff --git a/frontend/src/interfaces/uiConfig.ts b/frontend/src/interfaces/uiConfig.ts index 21ae1f363507..85a6e0994cd4 100644 --- a/frontend/src/interfaces/uiConfig.ts +++ b/frontend/src/interfaces/uiConfig.ts @@ -89,7 +89,6 @@ export type UiFlags = { navigationSidebar?: boolean; flagCreator?: boolean; resourceLimits?: boolean; - insightsV2?: boolean; newEventSearch?: boolean; archiveProjects?: boolean; projectListImprovements?: boolean; diff --git a/src/lib/__snapshots__/create-config.test.ts.snap b/src/lib/__snapshots__/create-config.test.ts.snap index d3d2ad21054b..11585572f29d 100644 --- a/src/lib/__snapshots__/create-config.test.ts.snap +++ b/src/lib/__snapshots__/create-config.test.ts.snap @@ -120,7 +120,6 @@ exports[`should create default config 1`] = ` }, "filterInvalidClientMetrics": false, "googleAuthEnabled": false, - "insightsV2": false, "killInsightsUI": false, "killScheduledChangeRequestCache": false, "maintenanceMode": false, diff --git a/src/lib/types/experimental.ts b/src/lib/types/experimental.ts index cf5a64c108f7..72c6b63ca08b 100644 --- a/src/lib/types/experimental.ts +++ b/src/lib/types/experimental.ts @@ -292,10 +292,6 @@ const flags: IFlags = { process.env.UNLEASH_EXPERIMENTAL_REMOVE_UNSAFE_INLINE_STYLE_SRC, false, ), - insightsV2: parseEnvVarBoolean( - process.env.UNLEASH_EXPERIMENTAL_INSIGHTS_V2, - false, - ), originMiddleware: parseEnvVarBoolean( process.env.UNLEASH_EXPERIMENTAL_ORIGIN_MIDDLEWARE, false, diff --git a/src/server-dev.ts b/src/server-dev.ts index 1fbab8384e1f..0d9807b148a5 100644 --- a/src/server-dev.ts +++ b/src/server-dev.ts @@ -52,7 +52,6 @@ process.nextTick(async () => { enableLegacyVariants: false, resourceLimits: true, extendedMetrics: true, - insightsV2: true, originMiddleware: true, newEventSearch: true, projectListImprovements: true, From ecb76383ae08e2dca9e5188273a77b0bdad06050 Mon Sep 17 00:00:00 2001 From: David Leek Date: Wed, 21 Aug 2024 14:14:38 +0200 Subject: [PATCH 5/5] fix: remove insightsv2 remnants from bad merge --- src/lib/types/experimental.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib/types/experimental.ts b/src/lib/types/experimental.ts index 72c6b63ca08b..b2a515e5f28b 100644 --- a/src/lib/types/experimental.ts +++ b/src/lib/types/experimental.ts @@ -59,7 +59,6 @@ export type IFlagKey = | 'resourceLimits' | 'extendedMetrics' | 'removeUnsafeInlineStyleSrc' - | 'insightsV2' | 'originMiddleware' | 'newEventSearch' | 'archiveProjects'