chore: Back merge v1.8.15 (#19288)
Should only contain what is already in master branch. Signed-off-by: Shrikant Sharat Kandula <shrikant@appsmith.com> Co-authored-by: Arpit Mohan <mohanarpit@users.noreply.github.com> Co-authored-by: Trisha Anand <trisha@appsmith.com> Co-authored-by: Aman Agarwal <aman@appsmith.com> Co-authored-by: Anand Srinivasan <66776129+eco-monk@users.noreply.github.com> Co-authored-by: Aishwarya-U-R <91450662+Aishwarya-U-R@users.noreply.github.com> Co-authored-by: Goutham Pratapa <pratapagoutham@gmail.com> Co-authored-by: Rohit Agarwal <rohit_agarwal@live.in> Co-authored-by: Arsalan Yaldram <arsalanyaldram0211@outlook.com> Co-authored-by: Ashit Rath <ashit@appsmith.com> Co-authored-by: balajisoundar <balaji@appsmith.com> Co-authored-by: Anagh Hegde <anagh@appsmith.com> Co-authored-by: Shrikant Sharat Kandula <shrikant@appsmith.com> Co-authored-by: Rishabh Rathod <rishabh.rathod@appsmith.com> Co-authored-by: Manish Kumar <107841575+sondermanish@users.noreply.github.com> Co-authored-by: Arpit Mohan <arpit@appsmith.com> Co-authored-by: keyurparalkar <keyur@appsmith.com> Co-authored-by: Ayush Pahwa <ayush@appsmith.com> Co-authored-by: Parthvi <80334441+Parthvi12@users.noreply.github.com> Co-authored-by: Parthvi Goswami <parthvigoswami@Parthvis-MacBook-Pro.local> Co-authored-by: Jacob Gillespie <jacobwgillespie@gmail.com> Co-authored-by: yatinappsmith <84702014+yatinappsmith@users.noreply.github.com> Co-authored-by: Vishnu Gp <vishnu@appsmith.com> Co-authored-by: f0c1s <anubhav@appsmith.com> Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com> Co-authored-by: Pawan Kumar <pawan.stardust@gmail.com> Co-authored-by: Dhruvik Neharia <dhruvik@appsmith.com> Co-authored-by: subratadeypappu <subrata@appsmith.com> Co-authored-by: ChandanBalajiBP <chandan@appsmith.com> Co-authored-by: Tanvi Bhakta <tanvibhakta@gmail.com> Co-authored-by: Anand Srinivasan <anand.a.srinivasan@outlook.com> Co-authored-by: Albin <albin@appsmith.com> Co-authored-by: arunvjn <32433245+arunvjn@users.noreply.github.com> Co-authored-by: Tolulope Adetula <31691737+Tooluloope@users.noreply.github.com> Co-authored-by: akash-codemonk <67054171+akash-codemonk@users.noreply.github.com> Co-authored-by: “sneha122” <“sneha@appsmith.com”> Co-authored-by: Ankita Kinger <ankita@appsmith.com> Co-authored-by: sidhantgoel <sidhant@appsmith.com> Co-authored-by: Rimil Dey <rimildeyjsr@gmail.com>
This commit is contained in:
parent
d2c586d309
commit
23652a185b
|
|
@ -1049,6 +1049,7 @@ export const MANDATORY_FIELDS_ERROR = () => "Mandatory fields cannot be empty";
|
|||
|
||||
// Audit logs begin
|
||||
export const AUDIT_LOGS = () => "Audit Logs";
|
||||
export const TRY_AGAIN_WITH_YOUR_FILTER = () => "Try again with your filter";
|
||||
|
||||
// Audit logs Upgrade page begin
|
||||
export const INTRODUCING = (featureName: string) =>
|
||||
|
|
|
|||
|
|
@ -43,8 +43,8 @@ public class PageControllerCE {
|
|||
|
||||
@Autowired
|
||||
public PageControllerCE(ApplicationPageService applicationPageService,
|
||||
NewPageService newPageService,
|
||||
CreateDBTablePageSolution createDBTablePageSolution
|
||||
NewPageService newPageService,
|
||||
CreateDBTablePageSolution createDBTablePageSolution
|
||||
) {
|
||||
this.applicationPageService = applicationPageService;
|
||||
this.newPageService = newPageService;
|
||||
|
|
@ -122,9 +122,10 @@ public class PageControllerCE {
|
|||
* In case the page has never been published, the page gets deleted.
|
||||
* In case the page has been published, this page would eventually get deleted whenever the application is published
|
||||
* next.
|
||||
*
|
||||
* @param defaultPageId defaultPageId which will be needed to find the actual page that needs to be deleted
|
||||
* @param branchName git branch to find the exact page which needs to be deleted
|
||||
* @return deleted page DTO
|
||||
* @return deleted page DTO
|
||||
*/
|
||||
@DeleteMapping("/{defaultPageId}")
|
||||
public Mono<ResponseDTO<PageDTO>> deletePage(@PathVariable String defaultPageId,
|
||||
|
|
@ -155,10 +156,11 @@ public class PageControllerCE {
|
|||
* If Application ID is present, it'll fetch all pages of that application in the provided mode.
|
||||
* if Page ID is present, it'll fetch all pages of the corresponding Application.
|
||||
* If both IDs are present, it'll use the Application ID only and ignore the Page ID
|
||||
*
|
||||
* @param applicationId Id of the application
|
||||
* @param pageId id of a page
|
||||
* @param mode In which mode it's in
|
||||
* @param branchName name of the current branch
|
||||
* @param pageId id of a page
|
||||
* @param mode In which mode it's in
|
||||
* @param branchName name of the current branch
|
||||
* @return List of ApplicationPagesDTO along with other meta data
|
||||
*/
|
||||
@GetMapping
|
||||
|
|
@ -166,6 +168,7 @@ public class PageControllerCE {
|
|||
@RequestParam(required = false) String pageId,
|
||||
@RequestParam(required = true, defaultValue = "EDIT") ApplicationMode mode,
|
||||
@RequestHeader(name = FieldName.BRANCH_NAME, required = false) String branchName) {
|
||||
log.debug("Going to fetch applicationPageDTO for applicationId: {}, pageId: {}, branchName: {}, mode: {}", applicationId, pageId, branchName, mode);
|
||||
return newPageService.findApplicationPages(applicationId, pageId, branchName, mode)
|
||||
.map(resources -> new ResponseDTO<>(HttpStatus.OK.value(), resources, null));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,11 +24,13 @@ public interface CustomNewPageRepositoryCE extends AppsmithRepository<NewPage> {
|
|||
|
||||
Mono<NewPage> findByNameAndApplicationIdAndViewMode(String name, String applicationId, AclPermission aclPermission, Boolean viewMode);
|
||||
|
||||
Flux<NewPage> findAllByIds(List<String> ids, AclPermission aclPermission);
|
||||
Flux<NewPage> findAllPageDTOsByIds(List<String> ids, AclPermission aclPermission);
|
||||
|
||||
Mono<String> getNameByPageId(String pageId, boolean isPublishedName);
|
||||
|
||||
Mono<NewPage> findPageByBranchNameAndDefaultPageId(String branchName, String defaultPageId, AclPermission permission);
|
||||
|
||||
Flux<NewPage> findSlugsByApplicationIds(List<String> applicationIds, AclPermission aclPermission);
|
||||
|
||||
Mono<NewPage> findRootApplicationIdById(String defaultPageId, AclPermission readPermission);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,10 @@ import com.appsmith.server.constants.FieldName;
|
|||
import com.appsmith.server.domains.NewPage;
|
||||
import com.appsmith.server.domains.QLayout;
|
||||
import com.appsmith.server.domains.QNewPage;
|
||||
import com.appsmith.server.domains.User;
|
||||
import com.appsmith.server.dtos.PageDTO;
|
||||
import com.appsmith.server.exceptions.AppsmithError;
|
||||
import com.appsmith.server.exceptions.AppsmithException;
|
||||
import com.appsmith.server.repositories.BaseAppsmithRepositoryImpl;
|
||||
import com.appsmith.server.repositories.CacheableRepositoryHelper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
@ -13,6 +16,7 @@ import org.springframework.data.mongodb.core.ReactiveMongoOperations;
|
|||
import org.springframework.data.mongodb.core.convert.MongoConverter;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
import org.springframework.security.core.context.ReactiveSecurityContextHolder;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
|
|
@ -50,6 +54,27 @@ public class CustomNewPageRepositoryCEImpl extends BaseAppsmithRepositoryImpl<Ne
|
|||
return queryAll(List.of(applicationIdCriteria, activeEditModeCriteria), aclPermission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<NewPage> findRootApplicationIdById(String id, AclPermission permission) {
|
||||
if (id == null) {
|
||||
return Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, FieldName.ID));
|
||||
}
|
||||
return ReactiveSecurityContextHolder.getContext()
|
||||
.map(ctx -> ctx.getAuthentication())
|
||||
.map(auth -> auth.getPrincipal())
|
||||
.flatMap(principal -> getAllPermissionGroupsForUser((User) principal))
|
||||
.flatMap(permissionGroups -> {
|
||||
Query query = new Query(getIdCriteria(id));
|
||||
query.fields().include(FieldName.APPLICATION_ID, FieldName.DEFAULT_RESOURCES);
|
||||
query.addCriteria(new Criteria().andOperator(notDeleted(), userAcl(permissionGroups, permission)));
|
||||
|
||||
return mongoOperations.query(this.genericDomain)
|
||||
.matching(query)
|
||||
.one()
|
||||
.flatMap(obj -> setUserPermissionsInObject(obj, permissionGroups));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<NewPage> findByIdAndLayoutsIdAndViewMode(String id, String layoutId, AclPermission aclPermission, Boolean viewMode) {
|
||||
String layoutsIdKey;
|
||||
|
|
@ -65,7 +90,7 @@ public class CustomNewPageRepositoryCEImpl extends BaseAppsmithRepositoryImpl<Ne
|
|||
layoutsKey = fieldName(QNewPage.newPage.unpublishedPage) + "." + fieldName(QNewPage.newPage.unpublishedPage.layouts);
|
||||
|
||||
// In case a page has been deleted in edit mode, but still exists in deployed mode, NewPage object would exist. To handle this, only fetch non-deleted pages
|
||||
Criteria deletedCriterion = where (fieldName(QNewPage.newPage.unpublishedPage) + "." + fieldName(QNewPage.newPage.unpublishedPage.deletedAt)).is(null);
|
||||
Criteria deletedCriterion = where(fieldName(QNewPage.newPage.unpublishedPage) + "." + fieldName(QNewPage.newPage.unpublishedPage.deletedAt)).is(null);
|
||||
criteria.add(deletedCriterion);
|
||||
}
|
||||
layoutsIdKey = layoutsKey + "." + fieldName(QLayout.layout.id);
|
||||
|
|
@ -86,7 +111,7 @@ public class CustomNewPageRepositoryCEImpl extends BaseAppsmithRepositoryImpl<Ne
|
|||
|
||||
if (Boolean.FALSE.equals(viewMode)) {
|
||||
// In case a page has been deleted in edit mode, but still exists in deployed mode, NewPage object would exist. To handle this, only fetch non-deleted pages
|
||||
Criteria deletedCriterion = where (fieldName(QNewPage.newPage.unpublishedPage) + "." + fieldName(QNewPage.newPage.unpublishedPage.deletedAt)).is(null);
|
||||
Criteria deletedCriterion = where(fieldName(QNewPage.newPage.unpublishedPage) + "." + fieldName(QNewPage.newPage.unpublishedPage.deletedAt)).is(null);
|
||||
criteria.add(deletedCriterion);
|
||||
}
|
||||
|
||||
|
|
@ -106,7 +131,7 @@ public class CustomNewPageRepositoryCEImpl extends BaseAppsmithRepositoryImpl<Ne
|
|||
|
||||
if (Boolean.FALSE.equals(viewMode)) {
|
||||
// In case a page has been deleted in edit mode, but still exists in deployed mode, NewPage object would exist. To handle this, only fetch non-deleted pages
|
||||
Criteria deletedCriteria = where (fieldName(QNewPage.newPage.unpublishedPage) + "." + fieldName(QNewPage.newPage.unpublishedPage.deletedAt)).is(null);
|
||||
Criteria deletedCriteria = where(fieldName(QNewPage.newPage.unpublishedPage) + "." + fieldName(QNewPage.newPage.unpublishedPage.deletedAt)).is(null);
|
||||
criteria.add(deletedCriteria);
|
||||
}
|
||||
|
||||
|
|
@ -114,11 +139,27 @@ public class CustomNewPageRepositoryCEImpl extends BaseAppsmithRepositoryImpl<Ne
|
|||
}
|
||||
|
||||
@Override
|
||||
public Flux<NewPage> findAllByIds(List<String> ids, AclPermission aclPermission) {
|
||||
Criteria idsCriterion = where("id")
|
||||
.in(ids);
|
||||
public Flux<NewPage> findAllPageDTOsByIds(List<String> ids, AclPermission aclPermission) {
|
||||
ArrayList<String> includedFields = new ArrayList<>(List.of(
|
||||
FieldName.APPLICATION_ID,
|
||||
FieldName.DEFAULT_RESOURCES,
|
||||
"unpublishedPage.name",
|
||||
"unpublishedPage.isHidden",
|
||||
"unpublishedPage.slug",
|
||||
"unpublishedPage.customSlug",
|
||||
"publishedPage.name",
|
||||
"publishedPage.isHidden",
|
||||
"publishedPage.slug",
|
||||
"publishedPage.customSlug"
|
||||
));
|
||||
|
||||
return queryAll(List.of(idsCriterion), aclPermission);
|
||||
Criteria idsCriterion = where("id").in(ids);
|
||||
|
||||
return this.queryAll(
|
||||
new ArrayList<>(List.of(idsCriterion)),
|
||||
includedFields,
|
||||
aclPermission,
|
||||
null);
|
||||
}
|
||||
|
||||
private Criteria getNameCriterion(String name, Boolean viewMode) {
|
||||
|
|
|
|||
|
|
@ -244,6 +244,7 @@ public class NewPageServiceCEImpl extends BaseService<NewPageRepository, NewPage
|
|||
return Mono.just(application);
|
||||
})
|
||||
.flatMap(application -> {
|
||||
log.debug("Fetched application data for id: {}", applicationId);
|
||||
if (markApplicationAsRecentlyAccessed) {
|
||||
// add this application and workspace id to the recently used list in UserData
|
||||
return userDataService.updateLastUsedAppAndWorkspaceList(application)
|
||||
|
|
@ -282,13 +283,15 @@ public class NewPageServiceCEImpl extends BaseService<NewPageRepository, NewPage
|
|||
}
|
||||
return pages.stream().map(page -> page.getId()).collect(Collectors.toList());
|
||||
})
|
||||
.flatMapMany(pageIds -> repository.findAllByIds(pageIds, pagePermission.getReadPermission()))
|
||||
.flatMapMany(pageIds -> repository.findAllPageDTOsByIds(pageIds, pagePermission.getReadPermission()))
|
||||
.collectList()
|
||||
.flatMap(pagesFromDb -> Mono.zip(
|
||||
Mono.just(pagesFromDb),
|
||||
defaultPageIdMono,
|
||||
applicationMono
|
||||
)).flatMap(tuple -> {
|
||||
))
|
||||
.flatMap(tuple -> {
|
||||
log.debug("Retrieved Page DTOs from DB ...");
|
||||
List<NewPage> pagesFromDb = tuple.getT1();
|
||||
String defaultPageId = tuple.getT2();
|
||||
|
||||
|
|
@ -353,6 +356,7 @@ public class NewPageServiceCEImpl extends BaseService<NewPageRepository, NewPage
|
|||
|
||||
return Mono.zip(applicationMono, pagesListMono)
|
||||
.map(tuple -> {
|
||||
log.debug("Populating applicationPagesDTO ...");
|
||||
Application application = tuple.getT1();
|
||||
application.setPages(null);
|
||||
application.setPublishedPages(null);
|
||||
|
|
@ -591,7 +595,7 @@ public class NewPageServiceCEImpl extends BaseService<NewPageRepository, NewPage
|
|||
if (!StringUtils.hasLength(defaultPageId)) {
|
||||
return Mono.error(new AppsmithException(INVALID_PARAMETER, FieldName.PAGE_ID, defaultPageId));
|
||||
}
|
||||
getPageMono = repository.findById(defaultPageId, pagePermission.getReadPermission());
|
||||
getPageMono = repository.findRootApplicationIdById(defaultPageId, pagePermission.getReadPermission());
|
||||
} else {
|
||||
getPageMono = repository.findPageByBranchNameAndDefaultPageId(branchName, defaultPageId, pagePermission.getReadPermission());
|
||||
}
|
||||
|
|
@ -600,6 +604,7 @@ public class NewPageServiceCEImpl extends BaseService<NewPageRepository, NewPage
|
|||
new AppsmithException(AppsmithError.NO_RESOURCE_FOUND, FieldName.PAGE_ID, defaultPageId + ", " + branchName))
|
||||
)
|
||||
.map(newPage -> {
|
||||
log.debug("Retrieved possible application ids for page, picking the appropriate one now");
|
||||
if (newPage.getDefaultResources() != null) {
|
||||
return newPage.getDefaultResources().getApplicationId();
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user