### Description Create ESLint rule to discourage usage of navigate() and prefer Link ### Refs #5468 ### Demo   Fixes #5468 --------- Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com> Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Matheus <matheus_benini@hotmail.com> Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
73 lines
2.5 KiB
TypeScript
73 lines
2.5 KiB
TypeScript
import { useNavigate } from 'react-router-dom';
|
|
import { Section } from '@react-email/components';
|
|
import { H2Title } from 'twenty-ui';
|
|
|
|
import { useDeleteOneDatabaseConnection } from '@/databases/hooks/useDeleteOneDatabaseConnection';
|
|
import { SettingsIntegrationDatabaseConnectionSummaryCard } from '@/settings/integrations/database-connection/components/SettingsIntegrationDatabaseConnectionSummaryCard';
|
|
import { SettingsIntegrationDatabaseTablesListCard } from '@/settings/integrations/database-connection/components/SettingsIntegrationDatabaseTablesListCard';
|
|
import { useDatabaseConnection } from '@/settings/integrations/database-connection/hooks/useDatabaseConnection';
|
|
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
|
import { SettingsPath } from '@/types/SettingsPath';
|
|
import { Breadcrumb } from '@/ui/navigation/bread-crumb/components/Breadcrumb';
|
|
|
|
export const SettingsIntegrationDatabaseConnectionShowContainer = () => {
|
|
const navigate = useNavigate();
|
|
const { connection, integration, databaseKey, tables } =
|
|
useDatabaseConnection({ fetchPolicy: 'network-only' });
|
|
|
|
const { deleteOneDatabaseConnection } = useDeleteOneDatabaseConnection();
|
|
|
|
if (!connection || !integration) {
|
|
return null;
|
|
}
|
|
|
|
const deleteConnection = async () => {
|
|
await deleteOneDatabaseConnection({ id: connection.id });
|
|
|
|
navigate(`${settingsIntegrationsPagePath}/${databaseKey}`);
|
|
};
|
|
|
|
const settingsIntegrationsPagePath = getSettingsPagePath(
|
|
SettingsPath.Integrations,
|
|
);
|
|
|
|
return (
|
|
<>
|
|
<Breadcrumb
|
|
links={[
|
|
{
|
|
children: 'Integrations',
|
|
href: settingsIntegrationsPagePath,
|
|
},
|
|
{
|
|
children: integration.text,
|
|
href: `${settingsIntegrationsPagePath}/${databaseKey}`,
|
|
},
|
|
{ children: connection.label },
|
|
]}
|
|
/>
|
|
<Section>
|
|
<H2Title title="About" description="About this remote object" />
|
|
<SettingsIntegrationDatabaseConnectionSummaryCard
|
|
databaseLogoUrl={integration.from.image}
|
|
connectionId={connection.id}
|
|
connectionLabel={connection.label}
|
|
onRemove={deleteConnection}
|
|
/>
|
|
</Section>
|
|
<Section>
|
|
<H2Title
|
|
title="Tables"
|
|
description="Select the tables that should be tracked"
|
|
/>
|
|
{!!tables?.length && (
|
|
<SettingsIntegrationDatabaseTablesListCard
|
|
connectionId={connection.id}
|
|
tables={tables}
|
|
/>
|
|
)}
|
|
</Section>
|
|
</>
|
|
);
|
|
};
|