Skip to content

Commit

Permalink
[Gitar] Cleaning up stale flag: integrationEvents with value true (#7940
Browse files Browse the repository at this point in the history
)
  • Loading branch information
gitar-bot[bot] authored Aug 21, 2024
1 parent 48423fa commit 3a15fa7
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -116,7 +115,6 @@ export const IntegrationForm: VFC<IntegrationFormProps> = ({
});
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${
Expand Down Expand Up @@ -318,7 +316,7 @@ export const IntegrationForm: VFC<IntegrationFormProps> = ({
integration
</StyledHeaderTitle>
<ConditionallyRender
condition={editMode && isAdmin && integrationEventsEnabled}
condition={editMode && isAdmin}
show={
<Link onClick={() => setEventsModalOpen(true)}>
View events
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -55,7 +53,6 @@ export const IntegrationCardMenu: VFC<IIntegrationCardMenuProps> = ({
const { refetchAddons } = useAddons();
const { setToastData, setToastApiError } = useToast();
const [eventsModalOpen, setEventsModalOpen] = useState(false);
const integrationEventsEnabled = useUiFlag('integrationEvents');

const closeMenu = () => {
setIsMenuOpen(false);
Expand Down Expand Up @@ -131,24 +128,19 @@ export const IntegrationCardMenu: VFC<IIntegrationCardMenuProps> = ({
}}
onClose={handleMenuClick}
>
<ConditionallyRender
condition={integrationEventsEnabled}
show={
<PermissionHOC permission={ADMIN}>
{({ hasAccess }) => (
<MenuItem
onClick={() => setEventsModalOpen(true)}
disabled={!hasAccess}
>
<ListItemIcon>
<Visibility />
</ListItemIcon>
<ListItemText>View events</ListItemText>
</MenuItem>
)}
</PermissionHOC>
}
/>
<PermissionHOC permission={ADMIN}>
{({ hasAccess }) => (
<MenuItem
onClick={() => setEventsModalOpen(true)}
disabled={!hasAccess}
>
<ListItemIcon>
<Visibility />
</ListItemIcon>
<ListItemText>View events</ListItemText>
</MenuItem>
)}
</PermissionHOC>
<MenuItem
onClick={() => {
setIsToggleOpen(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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)
Expand Down
1 change: 0 additions & 1 deletion frontend/src/interfaces/uiConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ export type UiFlags = {
navigationSidebar?: boolean;
flagCreator?: boolean;
resourceLimits?: boolean;
integrationEvents?: boolean;
newEventSearch?: boolean;
archiveProjects?: boolean;
projectListImprovements?: boolean;
Expand Down
1 change: 0 additions & 1 deletion src/lib/__snapshots__/create-config.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ exports[`should create default config 1`] = `
},
"filterInvalidClientMetrics": false,
"googleAuthEnabled": false,
"integrationEvents": false,
"killInsightsUI": false,
"killScheduledChangeRequestCache": false,
"maintenanceMode": false,
Expand Down
4 changes: 1 addition & 3 deletions src/lib/addons/addon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@ export default abstract class Addon {
async registerEvent(
integrationEvent: IntegrationEventWriteModel,
): Promise<void> {
if (this.flagResolver.isEnabled('integrationEvents')) {
await this.integrationEventsService.registerEvent(integrationEvent);
}
await this.integrationEventsService.registerEvent(integrationEvent);
}

destroy?(): void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ export class IntegrationEventsService {
}

async cleanUpEvents(): Promise<void> {
if (!this.flagResolver.isEnabled('integrationEvents')) return;

await this.integrationEventsStore.cleanUpEvents();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ beforeAll(async () => {
db.stores,
{
experimental: {
flags: {
integrationEvents: true,
},
flags: {},
},
},
db.rawDatabase,
Expand Down
6 changes: 1 addition & 5 deletions src/lib/routes/admin-api/addon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<
Expand Down Expand Up @@ -276,10 +276,6 @@ Note: passing \`null\` as a value for the description property will set it to an
>,
res: Response<IntegrationEventsSchema>,
): Promise<void> {
if (!this.flagResolver.isEnabled('integrationEvents')) {
throw new NotFoundError('This feature is not enabled');
}

const { id } = req.params;

if (Number.isNaN(Number(id))) {
Expand Down
5 changes: 0 additions & 5 deletions src/lib/types/experimental.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export type IFlagKey =
| 'resourceLimits'
| 'extendedMetrics'
| 'removeUnsafeInlineStyleSrc'
| 'integrationEvents'
| 'originMiddleware'
| 'newEventSearch'
| 'archiveProjects'
Expand Down Expand Up @@ -292,10 +291,6 @@ const flags: IFlags = {
process.env.UNLEASH_EXPERIMENTAL_REMOVE_UNSAFE_INLINE_STYLE_SRC,
false,
),
integrationEvents: parseEnvVarBoolean(
process.env.UNLEASH_EXPERIMENTAL_INTEGRATION_EVENTS,
false,
),
originMiddleware: parseEnvVarBoolean(
process.env.UNLEASH_EXPERIMENTAL_ORIGIN_MIDDLEWARE,
false,
Expand Down
1 change: 0 additions & 1 deletion src/server-dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ process.nextTick(async () => {
enableLegacyVariants: false,
resourceLimits: true,
extendedMetrics: true,
integrationEvents: true,
originMiddleware: true,
newEventSearch: true,
projectListImprovements: true,
Expand Down

0 comments on commit 3a15fa7

Please sign in to comment.