From 126e0a7d043ac48c5a01a87d00fd5f26c32bf6ad Mon Sep 17 00:00:00 2001 From: akash-codemonk <67054171+akash-codemonk@users.noreply.github.com> Date: Fri, 24 Jul 2020 18:35:37 +0530 Subject: [PATCH 1/3] Update Create query style (#157) --- .../src/pages/Editor/QueryEditor/QueryHomeScreen.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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

Date: Fri, 24 Jul 2020 19:28:28 +0530 Subject: [PATCH 2/3] Fix-Search component in Table widget updated with support for clearing search data (#96) * Added Button component in Table widget for actions * Action button state loading added for Table widget * Action button font-weight made as normal * Created header for common functionalities in Table Widget * Client side searching added in Table Widget. Action created for server side searching also. * Columns visibility feature initial commit * Column visibility list added in Table Widget * Changed pagination designs in accordance with new layout. This enable user to jump page as well. * Using colors values from constants * Table widget pagination, numeric input page number clamped between 1 and total pages * Adding tool tip to truncated values in table widget. Added AutoToolTipComponent that adds tooltip when text is truncated. * Table data download changes. Added downlaod icon and button to table widget. * Table data download changes * Table button loading state fixed. Table code refactored, rendering from props instead of state in ReactTableComponent * Table widget action button alignment fixed * Handled actions column changes * added proper keys to useMemo for react table widget * Download table data as CSV implemented * table data download, unused code removed * Code refactors and added dependency map with meta props and table data for computing columns * Table UI breakages on scroll and empty cells fixed * Handled empty rows in table widget * Fixed last row cut issue * Code review changes * Code review changes * Added table widget component heights as enum * code review changes * Search component in Table widget updated with support for clearing data, renamed properties * Opening image in new tab on clicking in table widget * Fixed table craching due to empty data filtering * Empty extra space on loading removed in table widget * Removed stopping of event propagation on table widget action button click * Fixing for test cases * Table header UI overflow fixed * Clearing selected row on searching data in table widget * fix for cypress test * Table crash issue fix * searchKeyword renamed to searchText. searchText added to entity definitions Co-authored-by: Arpit Mohan --- .../designSystems/appsmith/TableUtilities.tsx | 6 ++++-- .../src/utils/autocomplete/EntityDefinitions.ts | 1 + app/client/src/widgets/TableWidget.tsx | 14 +++++++------- 3 files changed, 12 insertions(+), 9 deletions(-) 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/utils/autocomplete/EntityDefinitions.ts b/app/client/src/utils/autocomplete/EntityDefinitions.ts index a7d7ced678..abc8a9c7e4 100644 --- a/app/client/src/utils/autocomplete/EntityDefinitions.ts +++ b/app/client/src/utils/autocomplete/EntityDefinitions.ts @@ -64,6 +64,7 @@ export const entityDefinitions = { pageNo: "number", pageSize: "number", isVisible: isVisible, + searchText: "string", }), DROP_DOWN_WIDGET: { "!doc": diff --git a/app/client/src/widgets/TableWidget.tsx b/app/client/src/widgets/TableWidget.tsx index 546c1c89dd..868b654e29 100644 --- a/app/client/src/widgets/TableWidget.tsx +++ b/app/client/src/widgets/TableWidget.tsx @@ -33,7 +33,7 @@ class TableWidget extends BaseWidget { 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; From 5ee1c242248425a7ca3f72ff5bcc3dad3f9f67ba Mon Sep 17 00:00:00 2001 From: Shrikant Sharat Kandula Date: Sat, 25 Jul 2020 15:43:22 +0530 Subject: [PATCH 3/3] Fix layouts not be updated when an action is updated (#160) * Fix layouts not be updated when an action is updated * Add test for updating onLoadActions when action updated --- .../appsmith/server/dtos/DslActionDTO.java | 2 + .../services/LayoutActionServiceImpl.java | 35 +++++-------- .../server/services/ActionServiceTest.java | 50 ++++++++++++++++++- 3 files changed, 63 insertions(+), 24 deletions(-) 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);