import { VFC, useState } from 'react'; import useAddons from 'hooks/api/getters/useAddons/useAddons'; import { AvailableIntegrations } from './AvailableIntegrations/AvailableIntegrations'; import { ConfiguredIntegrations } from './ConfiguredIntegrations/ConfiguredIntegrations'; import { Tab, Tabs, styled, useTheme } from '@mui/material'; import { Add } from '@mui/icons-material'; import { Route, Routes, useLocation, useNavigate } from 'react-router-dom'; import { useUiFlag } from 'hooks/useUiFlag'; import { useIncomingWebhooks } from 'hooks/api/getters/useIncomingWebhooks/useIncomingWebhooks'; import { PageContent } from 'component/common/PageContent/PageContent'; import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; import { PageHeader } from 'component/common/PageHeader/PageHeader'; import { TabLink } from 'component/common/TabNav/TabLink'; import ResponsiveButton from 'component/common/ResponsiveButton/ResponsiveButton'; import { ADMIN } from 'component/providers/AccessProvider/permissions'; import { IIncomingWebhook } from 'interfaces/incomingWebhook'; import { IncomingWebhooks } from 'component/incomingWebhooks/IncomingWebhooks'; const StyledHeader = styled('div')(() => ({ display: 'flex', justifyContent: 'space-between', alignItems: 'center', })); const StyledTabsContainer = styled('div')({ flex: 1, }); const StyledActions = styled('div')({ display: 'flex', alignItems: 'center', }); export const IntegrationList: VFC = () => { const { pathname } = useLocation(); const navigate = useNavigate(); const theme = useTheme(); const incomingWebhooksEnabled = useUiFlag('incomingWebhooks'); const { providers, addons, loading } = useAddons(); const { incomingWebhooks } = useIncomingWebhooks(); const [selectedIncomingWebhook, setSelectedIncomingWebhook] = useState(); const [incomingWebhookModalOpen, setIncomingWebhookModalOpen] = useState(false); const onNewIncomingWebhook = () => { navigate('/integrations/incoming-webhooks'); setSelectedIncomingWebhook(undefined); setIncomingWebhookModalOpen(true); }; const tabs = [ { label: 'Integrations', path: '/integrations', }, { label: `Incoming webhooks (${incomingWebhooks.length})`, path: '/integrations/incoming-webhooks', }, ]; return ( {tabs.map(({ label, path }) => ( {label} } sx={{ padding: 0, }} /> ))} New incoming webhook } /> } elseShow={} /> } isLoading={loading} withTabs={incomingWebhooksEnabled} > } /> 0} show={ } /> } /> ); };