Merge branch 'release' of github.com:appsmithorg/appsmith into release

This commit is contained in:
Shrikant Sharat Kandula 2020-07-25 15:45:06 +05:30
commit bc0b3e9902
7 changed files with 81 additions and 34 deletions

View File

@ -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 (
<AutoToolTipComponent title={data.toString()} isHidden={isHidden}>
<AutoToolTipComponent title={data} isHidden={isHidden}>
{data}
</AutoToolTipComponent>
);

View File

@ -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<QueryHomeScreenProps> {
return (
<QueryHomePage>
<p style={{ fontSize: "14px" }}>Create Query</p>
<p className="sectionHeader">Create Query</p>
<CardsWrapper>
<DatasourceCardsContainer>
<Card

View File

@ -64,6 +64,7 @@ export const entityDefinitions = {
pageNo: "number",
pageSize: "number",
isVisible: isVisible,
searchText: "string",
}),
DROP_DOWN_WIDGET: {
"!doc":

View File

@ -33,7 +33,7 @@ class TableWidget extends BaseWidget<TableWidgetProps, WidgetState> {
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<TableWidgetProps, WidgetState> {
pageNo: 1,
pageSize: undefined,
selectedRowIndex: -1,
searchKeyword: "",
searchText: "",
};
}
@ -202,8 +202,8 @@ class TableWidget extends BaseWidget<TableWidgetProps, WidgetState> {
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<TableWidgetProps, WidgetState> {
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<TableWidgetProps, WidgetState> {
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;

View File

@ -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;

View File

@ -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<Object> 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

View File

@ -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<Page> 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<ActionExecutionResult> actionExecutionResultMono = executeAction(executeActionDTO, actionConfiguration, mockResult);