diff --git a/app/client/src/components/designSystems/appsmith/TableUtilities.tsx b/app/client/src/components/designSystems/appsmith/TableUtilities.tsx index bb7de29097..e0ec6bb916 100644 --- a/app/client/src/components/designSystems/appsmith/TableUtilities.tsx +++ b/app/client/src/components/designSystems/appsmith/TableUtilities.tsx @@ -368,9 +368,11 @@ export const renderCell = ( } default: const data = - isString(value) || isNumber(value) ? value : JSON.stringify(value); + isString(value) || isNumber(value) + ? value.toString() + : JSON.stringify(value); return ( - + {data} ); diff --git a/app/client/src/pages/Editor/QueryEditor/QueryHomeScreen.tsx b/app/client/src/pages/Editor/QueryEditor/QueryHomeScreen.tsx index 8b67dee76c..44caba0d0e 100644 --- a/app/client/src/pages/Editor/QueryEditor/QueryHomeScreen.tsx +++ b/app/client/src/pages/Editor/QueryEditor/QueryHomeScreen.tsx @@ -28,6 +28,11 @@ const QueryHomePage = styled.div` max-height: 95vh; overflow: auto; + .sectionHeader { + font-weight: ${props => props.theme.fontWeights[2]}; + font-size: ${props => props.theme.fontSizes[4]}px; + } + .addIcon { align-items: center; margin-top: 15px; @@ -186,7 +191,7 @@ class QueryHomeScreen extends React.Component { return ( -

Create Query

+

Create Query

{ prevPageKey: VALIDATION_TYPES.TEXT, label: VALIDATION_TYPES.TEXT, selectedRowIndex: VALIDATION_TYPES.NUMBER, - searchKeyword: VALIDATION_TYPES.TEXT, + searchText: VALIDATION_TYPES.TEXT, // columnActions: VALIDATION_TYPES.ARRAY_ACTION_SELECTOR, // onRowSelected: VALIDATION_TYPES.ACTION_SELECTOR, // onPageChange: VALIDATION_TYPES.ACTION_SELECTOR, @@ -50,7 +50,7 @@ class TableWidget extends BaseWidget { pageNo: 1, pageSize: undefined, selectedRowIndex: -1, - searchKeyword: "", + searchText: "", }; } @@ -202,8 +202,8 @@ class TableWidget extends BaseWidget { return []; } const searchKey = - this.props.searchKeyword !== undefined - ? this.props.searchKeyword.toString().toUpperCase() + this.props.searchText !== undefined + ? this.props.searchText.toString().toUpperCase() : ""; return tableData.filter((item: object) => { return Object.values(item) @@ -249,7 +249,7 @@ class TableWidget extends BaseWidget { isLoading={this.props.isLoading} widgetId={this.props.widgetId} widgetName={this.props.widgetName} - searchKey={this.props.searchKeyword} + searchKey={this.props.searchText} renderMode={this.props.renderMode} hiddenColumns={hiddenColumns} columnActions={this.props.columnActions} @@ -302,7 +302,7 @@ class TableWidget extends BaseWidget { handleSearchTable = (searchKey: any) => { const { onSearchTextChanged } = this.props; this.resetSelectedRowIndex(); - super.updateWidgetMetaProperty("searchKeyword", searchKey); + super.updateWidgetMetaProperty("searchText", searchKey); if (onSearchTextChanged) { super.executeAction({ dynamicString: onSearchTextChanged, @@ -385,7 +385,7 @@ export interface TableWidgetProps extends WidgetProps { nextPageKey?: string; prevPageKey?: string; label: string; - searchKeyword: string; + searchText: string; tableData: object[]; onPageChange?: string; pageSize: number; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/DslActionDTO.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/DslActionDTO.java index 8baa2a9181..79cb1922c6 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/DslActionDTO.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/DslActionDTO.java @@ -1,6 +1,7 @@ package com.appsmith.server.dtos; import com.appsmith.server.domains.PluginType; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; @@ -10,6 +11,7 @@ import static com.appsmith.external.constants.ActionConstants.DEFAULT_ACTION_EXE @Getter @Setter +@EqualsAndHashCode public class DslActionDTO { String id; String name; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/LayoutActionServiceImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/LayoutActionServiceImpl.java index 461271b9ee..029224c850 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/LayoutActionServiceImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/LayoutActionServiceImpl.java @@ -510,30 +510,19 @@ public class LayoutActionServiceImpl implements LayoutActionService { return dbAction; }) .flatMap(actionService::validateAndSaveActionToRepository) - .flatMap(savedAction -> { + .flatMap(savedAction -> // Now that the action has been saved, update the page layout as well - String pageId = savedAction.getPageId(); - Mono updateLayoutsMono = null; - if (pageId != null) { - updateLayoutsMono = pageService.findById(pageId, MANAGE_PAGES) - .map(page -> { - if (page.getLayouts() == null) { - return Mono.empty(); - } - - return Mono.just(page.getLayouts()) - .flatMapMany(Flux::fromIterable) - .map(layout -> this.updateLayout(page.getId(), layout.getId(), layout)) - .collect(toSet()) - .then(Mono.just(savedAction)); - }); - } - if (updateLayoutsMono != null) { - return updateLayoutsMono - .then(Mono.just(savedAction)); - } - return Mono.just(savedAction); - }) + Mono.justOrEmpty(savedAction.getPageId()) + .flatMap(pageId -> pageService.findById(pageId, MANAGE_PAGES)) + .flatMapMany(page -> { + if (page.getLayouts() == null) { + return Mono.empty(); + } + return Flux.fromIterable(page.getLayouts()) + .flatMap(layout -> updateLayout(page.getId(), layout.getId(), layout)); + }) + .then(Mono.just(savedAction)) + ) .map(savedAction -> { Action act = (Action) savedAction; analyticsService diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ActionServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ActionServiceTest.java index b36ef563ba..72d5fc2f36 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ActionServiceTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ActionServiceTest.java @@ -13,6 +13,7 @@ import com.appsmith.server.constants.FieldName; import com.appsmith.server.domains.Action; import com.appsmith.server.domains.Application; import com.appsmith.server.domains.Datasource; +import com.appsmith.server.domains.Layout; import com.appsmith.server.domains.Organization; import com.appsmith.server.domains.Page; import com.appsmith.server.domains.Plugin; @@ -28,6 +29,7 @@ import com.appsmith.server.repositories.OrganizationRepository; import com.appsmith.server.repositories.PluginRepository; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.extern.slf4j.Slf4j; +import net.minidev.json.JSONObject; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -51,6 +53,7 @@ import java.util.UUID; import static com.appsmith.external.constants.ActionConstants.DEFAULT_ACTION_EXECUTION_TIMEOUT_MS; import static com.appsmith.server.acl.AclPermission.MANAGE_ACTIONS; import static com.appsmith.server.acl.AclPermission.READ_ACTIONS; +import static com.appsmith.server.acl.AclPermission.READ_PAGES; import static org.assertj.core.api.Assertions.assertThat; @RunWith(SpringRunner.class) @@ -91,6 +94,9 @@ public class ActionServiceTest { @Autowired LayoutActionService layoutActionService; + @Autowired + LayoutService layoutService; + Application testApp = null; Page testPage = null; @@ -110,7 +116,15 @@ public class ActionServiceTest { Application application = new Application(); application.setName(UUID.randomUUID().toString()); testApp = applicationPageService.createApplication(application, organization.getId()).block(); - testPage = pageService.getById(testApp.getPages().get(0).getId()).block(); + + final String pageId = testApp.getPages().get(0).getId(); + Layout layout = new Layout(); + JSONObject dsl = new JSONObject(Map.of("text", "{{ query1.data }}")); + layout.setDsl(dsl); + layout.setPublishedDsl(dsl); + layoutService.createLayout(pageId, layout).block(); + + testPage = pageService.getById(pageId).block(); } Organization testOrg = organizationRepository.findByName("Another Test Organization", AclPermission.READ_ORGANIZATIONS).block(); @@ -549,6 +563,40 @@ public class ActionServiceTest { .verifyComplete(); } + @Test + @WithUserDetails(value = "api_user") + public void updateActionUpdatesLayout() { + Mockito.when(pluginExecutorHelper.getPluginExecutor(Mockito.any())).thenReturn(Mono.just(new MockPluginExecutor())); + + Action action = new Action(); + action.setName("query1"); + action.setPageId(testPage.getId()); + ActionConfiguration actionConfiguration = new ActionConfiguration(); + actionConfiguration.setHttpMethod(HttpMethod.GET); + action.setActionConfiguration(actionConfiguration); + action.setDatasource(datasource); + + Mono resultMono = actionService + .create(action) + .flatMap(savedAction -> { + Action updates = new Action(); + updates.setExecuteOnLoad(true); + updates.setPolicies(null); + updates.setUserPermissions(null); + return layoutActionService.updateAction(savedAction.getId(), updates); + }) + .flatMap(savedAction -> pageService.findById(testPage.getId(), READ_PAGES)); + + StepVerifier + .create(resultMono) + .assertNext(page -> { + assertThat(page.getLayouts()).hasSize(2); + assertThat(page.getLayouts().get(1).getLayoutOnLoadActions()).hasSize(1); + assertThat(page.getLayouts().get(1).getLayoutOnLoadActions().get(0).iterator().next().getName()).isEqualTo("query1"); + }) + .verifyComplete(); + } + private void executeAndAssertAction(ExecuteActionDTO executeActionDTO, ActionConfiguration actionConfiguration, ActionExecutionResult mockResult) { Mono actionExecutionResultMono = executeAction(executeActionDTO, actionConfiguration, mockResult);