Skip to content

Commit

Permalink
fix: Redirect should be to related to current page after editing atta…
Browse files Browse the repository at this point in the history
…chment - EXO-71706 (#256)

* fix: Redirect should be to related to current page after editing attachment - EXO-71706
  • Loading branch information
mkrout authored Jul 8, 2024
1 parent c0ea02a commit b041347
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
22 changes: 22 additions & 0 deletions services/src/main/java/org/exoplatform/onlyoffice/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,9 @@ public String getPlatformRestUrl() {
/** The close timestamp. */
private Long closedTime;

/** The back to path. */
private String backTo;

/**
* Instantiates a new config for use with {@link Externalizable} methods. User
* by serialization.
Expand Down Expand Up @@ -1524,6 +1527,25 @@ public Boolean getSameModifier() {
return this.sameModifier.get();
}


/**
* Gets the backTo.
*
* @return the backTo
*/
public String getBackTo() {
return backTo;
}

/**
* Sets the backTo.
*
* @param backTo the backTo
*/
public void setBackTo(String backTo) {
this.backTo = backTo;
}

/**
* Create a copy of this editor but for another given user.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ private Config getConfig(RenderRequest request, RenderResponse response, Resourc

RequestContext requestContext = RequestContext.getCurrentInstance();
String docId = requestContext.getRequestParameter("docId");
String backTo = requestContext.getRequestParameter("backTo");

if (docId != null) {
try {
Expand Down Expand Up @@ -183,6 +184,9 @@ private Config getConfig(RenderRequest request, RenderResponse response, Resourc
config.getEditorConfig().setLang(Locale.getDefault().getLanguage());
}
}
if (backTo != null) {
config.setBackTo(backTo);
}
} else {
showError(i18n.getString("OnlyofficeEditorClient.ErrorTitle"),
i18n.getString("OnlyofficeEditor.error.EditorCannotBeCreated"));
Expand Down
14 changes: 13 additions & 1 deletion webapp/src/main/webapp/js/onlyoffice.js
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@
"goback": {
"blank": true,
"text": message("GoToDocument"),
"url": config.explorerUrl
"url": getBackUrl(config)
},
"help": true,
"logo": {
Expand Down Expand Up @@ -569,6 +569,18 @@
}
return process.promise();
};
/**
* Create back button url.
*/
var getBackUrl = function(config) {
if(!config.backTo){
return config.explorerUrl;
}
const url = new URL(`${window.location.origin}${config.backTo}`);
url.searchParams.set('updated', changesSaved);
return url.toString();
};

this.createEditor = createEditor;
this.createViewer = createViewer;

Expand Down

0 comments on commit b041347

Please sign in to comment.