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>
This commit is contained in:
@ -17,7 +17,6 @@ import {
|
||||
} from 'src/engine/metadata-modules/remote-server/utils/validate-remote-server-input';
|
||||
import { ForeignDataWrapperQueryFactory } from 'src/engine/api/graphql/workspace-query-builder/factories/foreign-data-wrapper-query.factory';
|
||||
import { RemoteTableService } from 'src/engine/metadata-modules/remote-server/remote-table/remote-table.service';
|
||||
import { RemoteTableStatus } from 'src/engine/metadata-modules/remote-server/remote-table/dtos/remote-table.dto';
|
||||
|
||||
@Injectable()
|
||||
export class RemoteServerService<T extends RemoteServerType> {
|
||||
@ -117,21 +116,18 @@ export class RemoteServerService<T extends RemoteServerType> {
|
||||
throw new NotFoundException('Object does not exist');
|
||||
}
|
||||
|
||||
const remoteTablesToRemove = (
|
||||
await this.remoteTableService.findAvailableRemoteTablesByServerId(
|
||||
id,
|
||||
const foreignTablesToRemove =
|
||||
await this.remoteTableService.fetchForeignTableNamesWithinWorkspace(
|
||||
workspaceId,
|
||||
)
|
||||
).filter((remoteTable) => remoteTable.status === RemoteTableStatus.SYNCED);
|
||||
remoteServer.foreignDataWrapperId,
|
||||
);
|
||||
|
||||
if (remoteTablesToRemove.length) {
|
||||
for (const remoteTable of remoteTablesToRemove) {
|
||||
await this.remoteTableService.unsyncRemoteTable(
|
||||
{
|
||||
remoteServerId: id,
|
||||
name: remoteTable.name,
|
||||
},
|
||||
if (foreignTablesToRemove.length) {
|
||||
for (const foreignTableName of foreignTablesToRemove) {
|
||||
await this.remoteTableService.removeForeignTableAndMetadata(
|
||||
foreignTableName,
|
||||
workspaceId,
|
||||
remoteServer,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user