import * as React from 'react'; import { Link, Route, Navigate, Routes, useParams, useSearchParams, useMatch, useNavigate, } from 'react-router-dom'; import { useTheme } from '@mui/material/styles'; import useMediaQuery from '@mui/material/useMediaQuery'; import Box from '@mui/material/Box'; import Grid from '@mui/material/Grid'; import Tabs from '@mui/material/Tabs'; import Tab from '@mui/material/Tab'; import AddIcon from '@mui/icons-material/Add'; import useFormatMessage from 'hooks/useFormatMessage'; import useAppConfig from 'hooks/useAppConfig.ee'; import useCurrentUserAbility from 'hooks/useCurrentUserAbility'; import * as URLS from 'config/urls'; import SplitButton from 'components/SplitButton'; import ConditionalIconButton from 'components/ConditionalIconButton'; import AppConnections from 'components/AppConnections'; import AppFlows from 'components/AppFlows'; import AddAppConnection from 'components/AddAppConnection'; import AppIcon from 'components/AppIcon'; import Container from 'components/Container'; import PageTitle from 'components/PageTitle'; import useApp from 'hooks/useApp'; const ReconnectConnection = (props) => { const { application, onClose } = props; const { connectionId } = useParams(); return ( ); }; export default function Application() { const theme = useTheme(); const matchSmallScreens = useMediaQuery(theme.breakpoints.down('md')); const formatMessage = useFormatMessage(); const connectionsPathMatch = useMatch({ path: URLS.APP_CONNECTIONS_PATTERN, end: false, }); const flowsPathMatch = useMatch({ path: URLS.APP_FLOWS_PATTERN, end: false }); const [searchParams] = useSearchParams(); const { appKey } = useParams(); const navigate = useNavigate(); const { data, loading } = useApp(appKey); const app = data?.data || {}; const { data: appConfig } = useAppConfig(appKey); const connectionId = searchParams.get('connectionId') || undefined; const currentUserAbility = useCurrentUserAbility(); const goToApplicationPage = () => navigate('connections'); const connectionOptions = React.useMemo(() => { const shouldHaveCustomConnection = appConfig?.data?.canConnect && appConfig?.data?.canCustomConnect; const options = [ { label: formatMessage('app.addConnection'), key: 'addConnection', 'data-test': 'add-connection-button', to: URLS.APP_ADD_CONNECTION(appKey, appConfig?.data?.canConnect), disabled: !currentUserAbility.can('create', 'Connection'), }, ]; if (shouldHaveCustomConnection) { options.push({ label: formatMessage('app.addCustomConnection'), key: 'addCustomConnection', 'data-test': 'add-custom-connection-button', to: URLS.APP_ADD_CONNECTION(appKey), disabled: !currentUserAbility.can('create', 'Connection'), }); } return options; }, [appKey, appConfig?.data, currentUserAbility]); if (loading) return null; return ( <> {app.name} } disabled={!currentUserAbility.can('create', 'Flow')} > {formatMessage('app.createFlow')} } /> disabled) } options={connectionOptions} /> } /> } /> } /> } /> } /> } /> ); }