[Improvement] Update the positioning parameters for bot threads (#6036)
* -updated the position field for comment threads * -use default origin header when origin header not present in comment email
This commit is contained in:
parent
89000efffd
commit
5970d06164
|
|
@ -2,4 +2,6 @@ package com.appsmith.server.constants;
|
|||
|
||||
public class Appsmith {
|
||||
public final static String APPSMITH_REGISTERED = "appsmith_registered";
|
||||
// We default the origin header to the production deployment of the client's URL
|
||||
public static final String DEFAULT_ORIGIN_HEADER = "https://app.appsmith.com";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public class CommentController extends BaseController<CommentService, Comment, S
|
|||
@PostMapping("/threads")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public Mono<ResponseDTO<CommentThread>> createThread(@Valid @RequestBody CommentThread resource,
|
||||
@RequestHeader(name = "Origin") String originHeader) {
|
||||
@RequestHeader(name = "Origin", required = false) String originHeader) {
|
||||
log.debug("Going to create resource {}", resource.getClass().getName());
|
||||
return service.createThread(resource, originHeader)
|
||||
.map(created -> new ResponseDTO<>(HttpStatus.CREATED.value(), created, null));
|
||||
|
|
|
|||
|
|
@ -54,8 +54,8 @@ public class CommentThread extends AbstractCommentDomain {
|
|||
|
||||
@Data
|
||||
public static class Position {
|
||||
Float top;
|
||||
Float left;
|
||||
Integer top;
|
||||
Integer left;
|
||||
Float topPercent;
|
||||
Float leftPercent;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.appsmith.server.helpers;
|
||||
|
||||
import com.appsmith.server.constants.Appsmith;
|
||||
import com.appsmith.server.constants.Security;
|
||||
import com.appsmith.server.domains.ApplicationPage;
|
||||
import com.appsmith.server.services.ApplicationService;
|
||||
|
|
@ -22,7 +23,6 @@ public class RedirectHelper {
|
|||
|
||||
public static final String DEFAULT_REDIRECT_URL = "/applications";
|
||||
public static final String SIGNUP_SUCCESS_URL = "/signup-success";
|
||||
public static final String DEFAULT_REDIRECT_ORIGIN = "https://app.appsmith.com";
|
||||
private static final String REDIRECT_URL_HEADER = "X-Redirect-Url";
|
||||
private static final String REDIRECT_URL_QUERY_PARAM = "redirectUrl";
|
||||
private static final String FORK_APP_ID_QUERY_PARAM = "appId";
|
||||
|
|
@ -135,7 +135,7 @@ public class RedirectHelper {
|
|||
*/
|
||||
public String getRedirectDomain(HttpHeaders httpHeaders) {
|
||||
// This is the failsafe for when nothing could be identified
|
||||
String redirectOrigin = DEFAULT_REDIRECT_ORIGIN;
|
||||
String redirectOrigin = Appsmith.DEFAULT_ORIGIN_HEADER;
|
||||
|
||||
if (!StringUtils.isEmpty(httpHeaders.getOrigin())) {
|
||||
// For PUT/POST requests or CORS?
|
||||
|
|
|
|||
|
|
@ -384,12 +384,13 @@ public class CommentServiceImpl extends BaseService<CommentRepository, Comment,
|
|||
// create a new bot thread
|
||||
CommentThread commentThread = new CommentThread();
|
||||
commentThread.setIsPrivate(true);
|
||||
commentThread.setWidgetType("CANVAS_WIDGET");
|
||||
CommentThread.Position position = new CommentThread.Position();
|
||||
position.setTop(0.558882236480713f);
|
||||
position.setLeft(73.5241470336914f);
|
||||
position.setTop(100);
|
||||
position.setLeft(100);
|
||||
commentThread.setPosition(position);
|
||||
commentThread.setPageId(resolvedThread.getPageId());
|
||||
commentThread.setRefId(resolvedThread.getRefId());
|
||||
commentThread.setRefId("0");
|
||||
commentThread.setMode(resolvedThread.getMode());
|
||||
|
||||
return saveCommentThread(commentThread, application, user)
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import com.appsmith.server.acl.AppsmithRole;
|
|||
import com.appsmith.server.acl.RoleGraph;
|
||||
import com.appsmith.server.configurations.CommonConfig;
|
||||
import com.appsmith.server.configurations.EmailConfig;
|
||||
import com.appsmith.server.constants.Appsmith;
|
||||
import com.appsmith.server.constants.FieldName;
|
||||
import com.appsmith.server.domains.Application;
|
||||
import com.appsmith.server.domains.InviteUser;
|
||||
|
|
@ -85,8 +86,6 @@ public class UserServiceImpl extends BaseService<UserRepository, User, String> i
|
|||
private static final String INVITE_USER_CLIENT_URL_FORMAT = "%s/user/signup?email=%s";
|
||||
private static final String INVITE_USER_EMAIL_TEMPLATE = "email/inviteUserCreatorTemplate.html";
|
||||
private static final String USER_ADDED_TO_ORGANIZATION_EMAIL_TEMPLATE = "email/inviteExistingUserToOrganizationTemplate.html";
|
||||
// We default the origin header to the production deployment of the client's URL
|
||||
private static final String DEFAULT_ORIGIN_HEADER = "https://app.appsmith.com";
|
||||
|
||||
@Autowired
|
||||
public UserServiceImpl(Scheduler scheduler,
|
||||
|
|
@ -421,7 +420,7 @@ public class UserServiceImpl extends BaseService<UserRepository, User, String> i
|
|||
|
||||
if (originHeader == null || originHeader.isBlank()) {
|
||||
// Default to the production link
|
||||
originHeader = DEFAULT_ORIGIN_HEADER;
|
||||
originHeader = Appsmith.DEFAULT_ORIGIN_HEADER;
|
||||
}
|
||||
|
||||
final String finalOriginHeader = originHeader;
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
|
||||
import static com.appsmith.server.acl.AclPermission.MANAGE_APPLICATIONS;
|
||||
import static com.appsmith.server.constants.Appsmith.DEFAULT_ORIGIN_HEADER;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
|
|
@ -115,8 +116,13 @@ public class EmailEventHandler {
|
|||
if (Boolean.FALSE.equals(canManageApplication)) { // user has no permission to manage application
|
||||
urlPostfix = "";
|
||||
}
|
||||
|
||||
String baseUrl = originHeader;
|
||||
if(StringUtils.isEmpty(originHeader)) {
|
||||
baseUrl = DEFAULT_ORIGIN_HEADER;
|
||||
}
|
||||
return String.format("%s/applications/%s/pages/%s%s?commentThreadId=%s&isCommentMode=true",
|
||||
originHeader, application.getId(), pageId, urlPostfix, threadId
|
||||
baseUrl, application.getId(), pageId, urlPostfix, threadId
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user