From b14669e986548d9339490d0834170d8eeb87af14 Mon Sep 17 00:00:00 2001 From: sneha122 Date: Wed, 22 Jan 2025 19:51:23 +0530 Subject: [PATCH 1/2] fix: ds structure issue fixed for zendesk integration (#38795) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description This PR fixes the issue where for Saas integrations like zendesk, we do not have a structure to be displayed, in that case we should show appropriate error message. Fixes #38736 _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="@tag.All" ### :mag: Cypress test results > [!TIP] > 🟒 🟒 🟒 All cypress tests have passed! πŸŽ‰ πŸŽ‰ πŸŽ‰ > Workflow run: > Commit: 5a9ef72ef41275bcd6303e311313758f0c24789d > Cypress dashboard. > Tags: `@tag.All` > Spec: >
Wed, 22 Jan 2025 12:24:10 UTC ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No ## Summary by CodeRabbit - **Refactor** - Deprecated the previous method for retrieving datasource context. - Updated the datasource context retrieval process to include plugin information. --------- Co-authored-by: β€œsneha122” <β€œsneha@appsmith.com”> --- .../services/ce/DatasourceContextServiceCEImpl.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/DatasourceContextServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/DatasourceContextServiceCEImpl.java index adc1d2ea82bb..69632105e0d3 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/DatasourceContextServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/DatasourceContextServiceCEImpl.java @@ -384,6 +384,11 @@ public boolean isValidDatasourceContextAvailable( && !isInErrorState; } + /** + * This method is deprecated and should not be used. Use the method {@link #getDatasourceContext(DatasourceStorage, Plugin)} instead. + * such entities as possible candidates for domain mapping. + */ + @Deprecated @Override public Mono> getDatasourceContext(DatasourceStorage datasourceStorage) { final String datasourceId = datasourceStorage.getDatasourceId(); @@ -452,9 +457,12 @@ public Mono> getDatasourceContext(DatasourceStorage datasou @Override public Mono retryOnce(DatasourceStorage datasourceStorage, Function, Mono> task) { - final Mono taskRunnerMono = Mono.justOrEmpty(datasourceStorage) - .flatMap(this::getDatasourceContext) + .flatMap(ds -> { + return pluginService + .findById(datasourceStorage.getPluginId()) + .flatMap(plugin -> getDatasourceContext(datasourceStorage, plugin)); + }) // Now that we have the context (connection details), call the task. .flatMap(task); From 928a00e9b1ac21c05edafc05c1a573f677307f85 Mon Sep 17 00:00:00 2001 From: Manish Kumar <107841575+sondermanish@users.noreply.github.com> Date: Thu, 23 Jan 2025 10:37:37 +0530 Subject: [PATCH 2/2] chore: Removed setting of published theme while application import (#38806) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description > [!TIP] > _Add a TL;DR when the description is longer than 500 words or extremely technical (helps the content, marketing, and DevRel team)._ > > _Please also include relevant motivation and context. List any dependencies that are required for this change. Add links to Notion, Figma or any other documents that might be relevant to the PR._ Fixes #38767 > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="@tag.Git, @tag.ImportExport" ### :mag: Cypress test results > [!TIP] > 🟒 🟒 🟒 All cypress tests have passed! πŸŽ‰ πŸŽ‰ πŸŽ‰ > Workflow run: > Commit: 0e9f7c2b12a4dc384ceedce1492170cd965fa13a > Cypress dashboard. > Tags: `@tag.Git, @tag.ImportExport` > Spec: >
Wed, 22 Jan 2025 18:43:17 UTC ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No ## Summary by CodeRabbit - **Theme Management** - Simplified theme import and publishing logic - Removed handling of published mode themes during import process - Updated theme management to handle scenarios with null theme IDs - **Bug Fixes** - Improved null handling for application and theme-related lists - Ensured proper initialization of page and theme lists to prevent potential exceptions - **Testing** - Updated test assertions to reflect new theme management approach - Adjusted expectations for published mode theme ID during application imports --- .../ApplicationImportServiceCEImpl.java | 19 +++++++++++----- .../themes/base/ThemeServiceCEImpl.java | 18 ++++++++++----- .../ThemeImportableServiceCEImpl.java | 20 +++++------------ .../imports/internal/ImportServiceTests.java | 22 ++++++------------- 4 files changed, 38 insertions(+), 41 deletions(-) diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/imports/ApplicationImportServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/imports/ApplicationImportServiceCEImpl.java index 6d876dd96c38..94c29a24331c 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/imports/ApplicationImportServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/imports/ApplicationImportServiceCEImpl.java @@ -53,6 +53,8 @@ import java.util.Set; import java.util.stream.Collectors; +import static com.appsmith.server.constants.FieldName.PUBLISHED; +import static com.appsmith.server.constants.FieldName.UNPUBLISHED; import static com.appsmith.server.helpers.ImportExportUtils.setPropertiesToExistingApplication; import static com.appsmith.server.helpers.ImportExportUtils.setPublishedApplicationProperties; import static org.springframework.util.StringUtils.hasText; @@ -361,11 +363,18 @@ public Mono updateAndSaveArtifactInContext( application.setWorkspaceId(importingMetaDTO.getWorkspaceId()); application.setIsPublic(null); application.setPolicies(null); - Map> mapOfApplicationPageList = Map.of( - FieldName.PUBLISHED, - application.getPublishedPages(), - FieldName.UNPUBLISHED, - application.getPages()); + + List unPublishedPages = CollectionUtils.isEmpty(application.getPages()) + ? new ArrayList<>() + : application.getPages(); + + List publishedPages = CollectionUtils.isEmpty(application.getPublishedPages()) + ? new ArrayList<>() + : application.getPublishedPages(); + + Map> mapOfApplicationPageList = + Map.of(PUBLISHED, publishedPages, UNPUBLISHED, unPublishedPages); + mappedImportableResourcesDTO .getResourceStoreFromArtifactExchangeJson() .putAll(mapOfApplicationPageList); diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/themes/base/ThemeServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/themes/base/ThemeServiceCEImpl.java index 97b3215c3258..49cd7905a529 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/themes/base/ThemeServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/themes/base/ThemeServiceCEImpl.java @@ -260,12 +260,18 @@ public Mono publishTheme(String applicationId) { editModeTheme.getId(), applicationPermission.getEditPermission())) .thenReturn(editModeTheme); - } else { // a customized theme is set as edit mode theme, copy that theme for published mode - return saveThemeForApplication( - application.getPublishedModeThemeId(), - editModeTheme, - application, - ApplicationMode.PUBLISHED); + } else { + // Unlike other entities themes doesn't have a concept of published and unpublished, + // hence while publishing the themes, contents from unpublished needs to be copied to + // published theme and for that the theme needs to exist. + // In cases of import and new application published theme should be null, + // hence the need of default themeId + Mono publishedThemeIdMono = Mono.justOrEmpty(application.getPublishedModeThemeId()) + .switchIfEmpty(getDefaultThemeId()); + + // a customized theme is set as edit mode theme, copy that theme for published mode + return publishedThemeIdMono.flatMap(publishedThemeId -> saveThemeForApplication( + publishedThemeId, editModeTheme, application, ApplicationMode.PUBLISHED)); } }); }); diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/themes/importable/ThemeImportableServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/themes/importable/ThemeImportableServiceCEImpl.java index 3ca18b567c6c..7ca9c0d2808e 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/themes/importable/ThemeImportableServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/themes/importable/ThemeImportableServiceCEImpl.java @@ -71,31 +71,21 @@ public Mono importEntities( return Mono.empty().then(); } return importableArtifactMono.flatMap(importableArtifact -> { - Mono editModeTheme = updateExistingAppThemeFromJSON( + Mono editModeThemeMono = updateExistingAppThemeFromJSON( importableArtifact, importableArtifact.getUnpublishedThemeId(), artifactExchangeJson.getUnpublishedTheme(), mappedImportableResourcesDTO); - Mono publishedModeTheme = updateExistingAppThemeFromJSON( - importableArtifact, - importableArtifact.getPublishedThemeId(), - artifactExchangeJson.getPublishedTheme(), - mappedImportableResourcesDTO); - - return Mono.zip(editModeTheme, publishedModeTheme) - .flatMap(importedThemesTuple -> { - String editModeThemeId = importedThemesTuple.getT1().getId(); - String publishedModeThemeId = - importedThemesTuple.getT2().getId(); - + return editModeThemeMono + .flatMap(editModeTheme -> { + String editModeThemeId = editModeTheme.getId(); importableArtifact.setUnpublishedThemeId(editModeThemeId); - importableArtifact.setPublishedThemeId(publishedModeThemeId); + // this will update the theme in the application and will be updated to db in the dry ops // execution Application application = new Application(); - application.setPublishedModeThemeId(publishedModeThemeId); application.setUnpublishedThemeId(editModeThemeId); application.setId(importableArtifact.getId()); diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/imports/internal/ImportServiceTests.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/imports/internal/ImportServiceTests.java index 37fd07110d3f..1ac66965af93 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/imports/internal/ImportServiceTests.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/imports/internal/ImportServiceTests.java @@ -1016,7 +1016,7 @@ public void importArtifactFromValidJsonFileTest() { assertThat(application.getModifiedBy()).isEqualTo("api_user"); assertThat(application.getUpdatedAt()).isNotNull(); assertThat(application.getEditModeThemeId()).isNotNull(); - assertThat(application.getPublishedModeThemeId()).isNotNull(); + assertThat(application.getPublishedModeThemeId()).isNull(); assertThat(isPartialImport).isEqualTo(Boolean.TRUE); assertThat(unConfiguredDatasourceList).isNotNull(); @@ -1138,22 +1138,14 @@ public void importApplicationInWorkspace_WhenCustomizedThemes_ThemesCreated() { StepVerifier.create(resultMono.flatMap(applicationImportDTO -> Mono.zip( Mono.just(applicationImportDTO), - themeRepository.findById(applicationImportDTO.getEditModeThemeId()), - themeRepository.findById(applicationImportDTO.getPublishedModeThemeId())))) + themeRepository.findById(applicationImportDTO.getEditModeThemeId())))) .assertNext(tuple -> { - final Application application = tuple.getT1(); Theme editTheme = tuple.getT2(); - Theme publishedTheme = tuple.getT3(); assertThat(editTheme.isSystemTheme()).isFalse(); assertThat(editTheme.getDisplayName()).isEqualTo("Custom edit theme"); assertThat(editTheme.getWorkspaceId()).isNull(); assertThat(editTheme.getApplicationId()).isNull(); - - assertThat(publishedTheme.isSystemTheme()).isFalse(); - assertThat(publishedTheme.getDisplayName()).isEqualTo("Custom published theme"); - assertThat(publishedTheme.getWorkspaceId()).isNullOrEmpty(); - assertThat(publishedTheme.getApplicationId()).isNullOrEmpty(); }) .verifyComplete(); } @@ -1299,7 +1291,7 @@ public void importArtifact_WithoutThemes_LegacyThemesAssigned() { StepVerifier.create(resultMono) .assertNext(applicationImportDTO -> { assertThat(applicationImportDTO.getEditModeThemeId()).isNotEmpty(); - assertThat(applicationImportDTO.getPublishedModeThemeId()).isNotEmpty(); + assertThat(applicationImportDTO.getPublishedModeThemeId()).isNull(); }) .verifyComplete(); } @@ -1532,7 +1524,7 @@ public void importApplication_withUnConfiguredDatasources_Success() { assertThat(application.getModifiedBy()).isEqualTo("api_user"); assertThat(application.getUpdatedAt()).isNotNull(); assertThat(application.getEditModeThemeId()).isNotNull(); - assertThat(application.getPublishedModeThemeId()).isNotNull(); + assertThat(application.getPublishedModeThemeId()).isNull(); assertThat(isPartialImport).isEqualTo(Boolean.TRUE); assertThat(unConfiguredDatasourceList.size()).isNotEqualTo(0); @@ -1860,7 +1852,7 @@ public void discardChange_addNewPageAfterImport_addedPageRemoved() { assertThat(application.getModifiedBy()).isEqualTo("api_user"); assertThat(application.getUpdatedAt()).isNotNull(); assertThat(application.getEditModeThemeId()).isNotNull(); - assertThat(application.getPublishedModeThemeId()).isNotNull(); + assertThat(application.getPublishedModeThemeId()).isNull(); assertThat(pageList).hasSize(3); @@ -4744,7 +4736,7 @@ public void extractFileAndUpdateApplication_addNewPageAfterImport_addedPageRemov assertThat(application.getModifiedBy()).isEqualTo("api_user"); assertThat(application.getUpdatedAt()).isNotNull(); assertThat(application.getEditModeThemeId()).isNotNull(); - assertThat(application.getPublishedModeThemeId()).isNotNull(); + assertThat(application.getPublishedModeThemeId()).isNull(); assertThat(pageList).hasSize(3); @@ -5296,7 +5288,7 @@ public void importApplication_WhenUpdateLayoutFailures_Success() throws URISynta assertThat(application.getModifiedBy()).isEqualTo("api_user"); assertThat(application.getUpdatedAt()).isNotNull(); assertThat(application.getEditModeThemeId()).isNotNull(); - assertThat(application.getPublishedModeThemeId()).isNotNull(); + assertThat(application.getPublishedModeThemeId()).isNull(); assertThat(isPartialImport).isEqualTo(Boolean.TRUE); assertThat(unConfiguredDatasourceList.size()).isNotEqualTo(0);