From 43ce6a6102894b7e63e1c9a77ce9ca0839668586 Mon Sep 17 00:00:00 2001 From: AnnaHariprasad5123 Date: Tue, 9 Jul 2024 15:59:38 +0530 Subject: [PATCH 1/3] fix: Update datasource deletion message for clarity --- .../cypress/e2e/Regression/ServerSide/QueryPane/MySQL_Spec.ts | 2 +- .../server/datasources/base/DatasourceServiceCEImpl.java | 4 +++- .../java/com/appsmith/server/exceptions/AppsmithError.java | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/client/cypress/e2e/Regression/ServerSide/QueryPane/MySQL_Spec.ts b/app/client/cypress/e2e/Regression/ServerSide/QueryPane/MySQL_Spec.ts index 873c89ff79d1..bf1b9606359e 100644 --- a/app/client/cypress/e2e/Regression/ServerSide/QueryPane/MySQL_Spec.ts +++ b/app/client/cypress/e2e/Regression/ServerSide/QueryPane/MySQL_Spec.ts @@ -91,7 +91,7 @@ describe( after("Verify Deletion of the datasource", () => { dataSources.DeleteDatasourceFromWithinDS(dsName, 409); agHelper.ValidateToastMessage( - "Cannot delete datasource since it has 1 action(s) using it.", + "Cannot delete datasource since it has 1 query using it.", ); //table is 1 action }); diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/datasources/base/DatasourceServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/datasources/base/DatasourceServiceCEImpl.java index 91cc1e08a634..a8666d863d9c 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/datasources/base/DatasourceServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/datasources/base/DatasourceServiceCEImpl.java @@ -806,7 +806,9 @@ public Mono archiveById(String id) { .flatMap(objects -> { final Long actionsCount = objects.getT2(); if (actionsCount > 0) { - return Mono.error(new AppsmithException(AppsmithError.DATASOURCE_HAS_ACTIONS, actionsCount)); + String queryWord = actionsCount == 1 ? "query" : "queries"; + return Mono.error( + new AppsmithException(AppsmithError.DATASOURCE_HAS_ACTIONS, actionsCount, queryWord)); } return Mono.just(objects.getT1()); }) diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/exceptions/AppsmithError.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/exceptions/AppsmithError.java index 6e386d10f3b4..eb10c512d236 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/exceptions/AppsmithError.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/exceptions/AppsmithError.java @@ -502,7 +502,7 @@ public enum AppsmithError { DATASOURCE_HAS_ACTIONS( 409, AppsmithErrorCode.DATASOURCE_HAS_ACTIONS.getCode(), - "Cannot delete datasource since it has {0} action(s) using it.", + "Cannot delete datasource since it has {0} {1} using it.", AppsmithErrorAction.DEFAULT, "Datasource cannot be deleted", ErrorType.BAD_REQUEST, From e0d3d539dccadc239a6ae7b7d844ee879cd32338 Mon Sep 17 00:00:00 2001 From: AnnaHariprasad5123 Date: Thu, 11 Jul 2024 14:19:40 +0530 Subject: [PATCH 2/3] fix: DataSourceServiceTest --- .../com/appsmith/server/services/DatasourceServiceTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/DatasourceServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/DatasourceServiceTest.java index 5744932c5d0f..4da79899dfac 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/DatasourceServiceTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/DatasourceServiceTest.java @@ -947,7 +947,8 @@ public void deleteDatasourceWithActions() { }) .flatMap(datasource -> datasourceService.archiveById(datasource.getId())); - StepVerifier.create(datasourceMono).verifyErrorMessage(AppsmithError.DATASOURCE_HAS_ACTIONS.getMessage("1")); + StepVerifier.create(datasourceMono) + .verifyErrorMessage(AppsmithError.DATASOURCE_HAS_ACTIONS.getMessage("1", "query")); } @Test From 766dec4518d9243886557433a7d61a866b959817 Mon Sep 17 00:00:00 2001 From: AnnaHariprasad5123 Date: Thu, 11 Jul 2024 14:19:40 +0530 Subject: [PATCH 3/3] fix: DataSourceServiceTest --- app/client/cypress/support/Pages/DataSources.ts | 2 +- .../com/appsmith/server/services/DatasourceServiceTest.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/client/cypress/support/Pages/DataSources.ts b/app/client/cypress/support/Pages/DataSources.ts index 6c90656a49d4..380c23183d8d 100644 --- a/app/client/cypress/support/Pages/DataSources.ts +++ b/app/client/cypress/support/Pages/DataSources.ts @@ -897,7 +897,7 @@ export class DataSources { this.agHelper.AssertContains( responseStatus === 200 ? "datasource deleted successfully" - : "action(s) using it", + : "Cannot delete datasource", ); }); } diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/DatasourceServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/DatasourceServiceTest.java index 5744932c5d0f..4da79899dfac 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/DatasourceServiceTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/DatasourceServiceTest.java @@ -947,7 +947,8 @@ public void deleteDatasourceWithActions() { }) .flatMap(datasource -> datasourceService.archiveById(datasource.getId())); - StepVerifier.create(datasourceMono).verifyErrorMessage(AppsmithError.DATASOURCE_HAS_ACTIONS.getMessage("1")); + StepVerifier.create(datasourceMono) + .verifyErrorMessage(AppsmithError.DATASOURCE_HAS_ACTIONS.getMessage("1", "query")); } @Test