Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Remove unused LayoutServiceCE.createLayout #34305

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

public interface LayoutServiceCE {

Mono<Layout> createLayout(String pageId, Layout layout);

Mono<Layout> getLayout(String pageId, String layoutId, Boolean viewMode);

Mono<Layout> getLayout(String defaultPageId, String layoutId, Boolean viewMode, String branchName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,64 +2,26 @@

import com.appsmith.server.constants.FieldName;
import com.appsmith.server.domains.Layout;
import com.appsmith.server.dtos.PageDTO;
import com.appsmith.server.exceptions.AppsmithError;
import com.appsmith.server.exceptions.AppsmithException;
import com.appsmith.server.helpers.ResponseUtils;
import com.appsmith.server.newpages.base.NewPageService;
import com.appsmith.server.solutions.PagePermission;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.bson.types.ObjectId;
import org.springframework.beans.factory.annotation.Autowired;
import reactor.core.publisher.Mono;

import java.util.ArrayList;
import java.util.List;

@Slf4j
@RequiredArgsConstructor
public class LayoutServiceCEImpl implements LayoutServiceCE {

private final NewPageService newPageService;
private final ResponseUtils responseUtils;
private final PagePermission pagePermission;

@Autowired
public LayoutServiceCEImpl(
NewPageService newPageService, ResponseUtils responseUtils, PagePermission pagePermission) {
this.newPageService = newPageService;
this.responseUtils = responseUtils;
this.pagePermission = pagePermission;
}

@Override
public Mono<Layout> createLayout(String pageId, Layout layout) {
if (pageId == null) {
return Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, FieldName.PAGE_ID));
}

// fetch the unpublished page
Mono<PageDTO> pageMono = newPageService
.findPageById(pageId, pagePermission.getEditPermission(), false)
.switchIfEmpty(Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, FieldName.PAGE_ID)));

return pageMono.map(page -> {
List<Layout> layoutList = page.getLayouts();
if (layoutList == null) {
// no layouts exist for this page
layoutList = new ArrayList<Layout>();
}
// Adding an Id to the layout to ensure that a layout can be referred to by its ID as well.
layout.setId(new ObjectId().toString());

layoutList.add(layout);
page.setLayouts(layoutList);
return page;
})
.flatMap(newPageService::saveUnpublishedPage)
.then(Mono.just(layout));
}

@Override
public Mono<Layout> getLayout(String pageId, String layoutId, Boolean viewMode) {
return newPageService
Expand Down
Loading
Loading