Files
twenty_crm/packages/twenty-front/src/modules/settings/integrations/components/SettingsIntegrationDatabaseConnectionSyncStatus.tsx
Thomas Trompette 756de8a31b Add connection failed status (#4939)
1/ When the user inputs wrong connection informations, we do not inform
him. He will only see that no tables are available.
We will display a connection failed status if an error is raised testing
the connection

2/ If the connection fails, it should still be possible to delete the
server. Today, since we try first to delete the tables, the connection
failure throws an error that will prevent server deletion. Using the
foreign tables instead of calling the distant DB.

3/ Redirect to connection show page instead of connection list after
creation

4/ Today, foreign tables are fetched without the server name. This is a
mistake because we need to know which foreign table is linked with which
server. Updating the associated query.

<img width="632" alt="Capture d’écran 2024-04-12 à 10 52 49"
src="https://github.com/twentyhq/twenty/assets/22936103/9e8406b8-75d0-494c-ac1f-5e9fa7100f5c">

---------

Co-authored-by: Thomas Trompette <thomast@twenty.com>
2024-04-15 14:09:01 +02:00

39 lines
1021 B
TypeScript

import { useGetDatabaseConnectionTables } from '@/databases/hooks/useGetDatabaseConnectionTables';
import { Status } from '@/ui/display/status/components/Status';
import { RemoteTableStatus } from '~/generated-metadata/graphql';
import { isDefined } from '~/utils/isDefined';
type SettingsIntegrationDatabaseConnectionSyncStatusProps = {
connectionId: string;
skip?: boolean;
};
export const SettingsIntegrationDatabaseConnectionSyncStatus = ({
connectionId,
skip,
}: SettingsIntegrationDatabaseConnectionSyncStatusProps) => {
const { tables, error } = useGetDatabaseConnectionTables({
connectionId,
skip,
});
if (isDefined(error)) {
return <Status color="red" text="Connection failed" />;
}
const syncedTables = tables.filter(
(table) => table.status === RemoteTableStatus.Synced,
);
return (
<Status
color="green"
text={
syncedTables.length === 1
? `1 tracked table`
: `${syncedTables.length} tracked tables`
}
/>
);
};