Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
code cleanup
Thiago Araujo da Silvab281e4559610
diff --git a/backend/src/services/alarm/alarm-channel-dal.ts b/backend/src/services/alarm/alarm-channel-dal.tsindex 9669d0a279..6b3dc2d24f 100644--- a/backend/src/services/alarm/alarm-channel-dal.ts+++ b/backend/src/services/alarm/alarm-channel-dal.ts@@ -43,21 +43,6 @@ export const alarmChannelDALFactory = (db: TDbClient) => {}};- const findByIdInScope = async (- id: string,- { orgId, projectId }: { orgId: string; projectId?: string | null },- tx?: Knex- ): Promise<TAlarmChannels | undefined> => {- try {- const query = (tx || db.replicaNode())(TableName.AlarmChannel).where(`${TableName.AlarmChannel}.id`, id);- scopeFilter(query, orgId, projectId);- const channel = await query.select(selectAllTableCols(TableName.AlarmChannel)).first();- return channel as TAlarmChannels | undefined;- } catch (error) {- throw new DatabaseError({ error, name: "FindByIdInScope" });- }- };-const findByIdsInScope = async (ids: string[],{ orgId, projectId }: { orgId: string; projectId?: string | null },@@ -131,7 +116,6 @@ export const alarmChannelDALFactory = (db: TDbClient) => {return {...alarmChannelOrm,findWithUsageByScope,- findByIdInScope,findByIdsInScope,findByNameInScope,findByAlarmId,diff --git a/backend/src/services/alarm/alarm-types.ts b/backend/src/services/alarm/alarm-types.tsindex c644df2b71..589aec9291 100644--- a/backend/src/services/alarm/alarm-types.ts+++ b/backend/src/services/alarm/alarm-types.ts@@ -1,4 +1,3 @@-import { Knex } from "knex";import { z } from "zod";import { TGenericPermission } from "@app/lib/types";@@ -53,7 +52,6 @@ export type TFindDueTargetsInput = {eventType: string;condition: unknown;filters: unknown;- tx?: Knex;};export interface IResourceAlarmProvider<TTarget = unknown> {diff --git a/frontend/src/views/AlarmsPage/components/AlarmRow.tsx b/frontend/src/views/AlarmsPage/components/AlarmRow.tsxindex acee5f27e6..e220d6f89e 100644--- a/frontend/src/views/AlarmsPage/components/AlarmRow.tsx+++ b/frontend/src/views/AlarmsPage/components/AlarmRow.tsx@@ -1,14 +1,4 @@-import {- AlertTriangleIcon,- BellIcon,- Ellipsis,- HashIcon,- KeyRoundIcon,- LinkIcon,- MailIcon,- PencilIcon,- Trash2Icon-} from "lucide-react";+import { Ellipsis, KeyRoundIcon, PencilIcon, Trash2Icon } from "lucide-react";import {Badge,@@ -23,26 +13,18 @@ import {import {ALARM_EVENT_TYPE_LABELS,ALARM_RESOURCE_TYPE_LABELS,- AlarmChannelType,AlarmEventType,AlarmResourceType,TAlarm,TAlarmChannelSummary} from "@app/hooks/api/alarms";-type LucideIcon = typeof MailIcon;+import { getChannelIcon, LucideIcon } from "./channelIcons";const RESOURCE_ICONS: Record<string, LucideIcon> = {[AlarmResourceType.IdentityCredential]: KeyRoundIcon};-const CHANNEL_ICONS: Record<AlarmChannelType, LucideIcon> = {- [AlarmChannelType.Email]: MailIcon,- [AlarmChannelType.Slack]: HashIcon,- [AlarmChannelType.Webhook]: LinkIcon,- [AlarmChannelType.PagerDuty]: AlertTriangleIcon-};-type Props = {alarm: TAlarm;onEdit: (alarm: TAlarm) => void;@@ -59,7 +41,7 @@ export const AlarmRow = ({ alarm, onEdit, onDelete }: Props) => {: "On event";const renderChannel = (channel: TAlarmChannelSummary) => {- const Icon = CHANNEL_ICONS[channel.channelType] ?? BellIcon;+ const Icon = getChannelIcon(channel.channelType);return (<Badgekey={channel.id}diff --git a/frontend/src/views/AlarmsPage/components/AttachChannelsField.tsx b/frontend/src/views/AlarmsPage/components/AttachChannelsField.tsxindex 11a5048ad5..5213779856 100644--- a/frontend/src/views/AlarmsPage/components/AttachChannelsField.tsx+++ b/frontend/src/views/AlarmsPage/components/AttachChannelsField.tsx@@ -1,15 +1,5 @@-import { useState } from "react";import { Controller, useFormContext } from "react-hook-form";-import {- AlertTriangleIcon,- BellIcon,- ChevronDownIcon,- HashIcon,- LinkIcon,- MailIcon,- PlusIcon,- XIcon-} from "lucide-react";+import { ChevronDownIcon, PlusIcon, XIcon } from "lucide-react";import {Button,@@ -22,18 +12,9 @@ import {Skeleton} from "@app/components/v3";import { TAlarmChannel, useListAlarmChannels } from "@app/hooks/api/alarmChannels";-import { AlarmChannelType, TAlarmForm } from "@app/hooks/api/alarms";--import { AddChannelModal } from "./channels/AddChannelModal";+import { TAlarmForm } from "@app/hooks/api/alarms";-type LucideIcon = typeof MailIcon;--const CHANNEL_ICONS: Record<AlarmChannelType, LucideIcon> = {- [AlarmChannelType.Email]: MailIcon,- [AlarmChannelType.Slack]: HashIcon,- [AlarmChannelType.Webhook]: LinkIcon,- [AlarmChannelType.PagerDuty]: AlertTriangleIcon-};+import { getChannelIcon } from "./channelIcons";type Props = {projectId?: string;@@ -45,7 +26,6 @@ export const AttachChannelsField = ({ projectId }: Props) => {formState: { errors }} = useFormContext<TAlarmForm>();const { isPending, data: channels = [] } = useListAlarmChannels(projectId ? { projectId } : {});- const [isChannelModalOpen, setIsChannelModalOpen] = useState(false);const byId = new Map(channels.map((c) => [c.id, c]));const rootError = errors.channelIds?.message || errors.channelIds?.root?.message;@@ -59,7 +39,7 @@ export const AttachChannelsField = ({ projectId }: Props) => {const available = channels.filter((c) => !selectedIds.includes(c.id));const renderCard = (channel: TAlarmChannel) => {- const Icon = CHANNEL_ICONS[channel.channelType] ?? BellIcon;+ const Icon = getChannelIcon(channel.channelType);return (<divkey={channel.id}@@ -111,7 +91,7 @@ export const AttachChannelsField = ({ projectId }: Props) => {className="max-h-64 min-w-[var(--radix-dropdown-menu-trigger-width)] overflow-y-auto">{available.map((channel) => {- const Icon = CHANNEL_ICONS[channel.channelType] ?? BellIcon;+ const Icon = getChannelIcon(channel.channelType);return (<DropdownMenuItemkey={channel.id}@@ -144,13 +124,6 @@ export const AttachChannelsField = ({ projectId }: Props) => {)}</div>)}-- <AddChannelModal- isOpen={isChannelModalOpen}- onOpenChange={setIsChannelModalOpen}- projectId={projectId}- onCreated={(channelId) => field.onChange([...selectedIds, channelId])}- /></div>);}}diff --git a/frontend/src/views/AlarmsPage/components/channelIcons.ts b/frontend/src/views/AlarmsPage/components/channelIcons.tsnew file mode 100644index 0000000000..aebd44d78d--- /dev/null+++ b/frontend/src/views/AlarmsPage/components/channelIcons.ts@@ -0,0 +1,15 @@+import { AlertTriangleIcon, BellIcon, HashIcon, LinkIcon, MailIcon } from "lucide-react";++import { AlarmChannelType } from "@app/hooks/api/alarms";++export type LucideIcon = typeof MailIcon;++const CHANNEL_ICONS: Record<AlarmChannelType, LucideIcon> = {+ [AlarmChannelType.Email]: MailIcon,+ [AlarmChannelType.Slack]: HashIcon,+ [AlarmChannelType.Webhook]: LinkIcon,+ [AlarmChannelType.PagerDuty]: AlertTriangleIcon+};++export const getChannelIcon = (channelType: AlarmChannelType): LucideIcon =>+ CHANNEL_ICONS[channelType] ?? BellIcon;diff --git a/frontend/src/views/AlarmsPage/components/channels/ChannelRow.tsx b/frontend/src/views/AlarmsPage/components/channels/ChannelRow.tsxindex ad816ab361..8af0d3d5b2 100644--- a/frontend/src/views/AlarmsPage/components/channels/ChannelRow.tsx+++ b/frontend/src/views/AlarmsPage/components/channels/ChannelRow.tsx@@ -1,13 +1,4 @@-import {- AlertTriangleIcon,- BellIcon,- Ellipsis,- HashIcon,- LinkIcon,- MailIcon,- PencilIcon,- Trash2Icon-} from "lucide-react";+import { Ellipsis, PencilIcon, Trash2Icon } from "lucide-react";import {DropdownMenu,@@ -19,16 +10,9 @@ import {TableRow} from "@app/components/v3";import { TAlarmChannel } from "@app/hooks/api/alarmChannels";-import { ALARM_CHANNEL_TYPE_LABELS, AlarmChannelType } from "@app/hooks/api/alarms";--type LucideIcon = typeof MailIcon;+import { ALARM_CHANNEL_TYPE_LABELS } from "@app/hooks/api/alarms";-const CHANNEL_ICONS: Record<AlarmChannelType, LucideIcon> = {- [AlarmChannelType.Email]: MailIcon,- [AlarmChannelType.Slack]: HashIcon,- [AlarmChannelType.Webhook]: LinkIcon,- [AlarmChannelType.PagerDuty]: AlertTriangleIcon-};+import { getChannelIcon } from "../channelIcons";type Props = {channel: TAlarmChannel;@@ -37,7 +21,7 @@ type Props = {};export const ChannelRow = ({ channel, onEdit, onDelete }: Props) => {- const Icon = CHANNEL_ICONS[channel.channelType] ?? BellIcon;+ const Icon = getChannelIcon(channel.channelType);const typeLabel = ALARM_CHANNEL_TYPE_LABELS[channel.channelType] ?? channel.channelType;return (