Skip to content

Commit ea0491a

Browse files
authored
fix: Open doc location is KO when doc opened from favorite - EXO-81992 (#1799)
Prior to this, when opening a doc from the favorite drawer, the link to go back from OO opens the home page instead of the documents. This change resolves the issue by modifying the link.
1 parent 289889a commit ea0491a

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed

documents-webapp/src/main/webapp/js/DocumentsUtils.js

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -70,34 +70,35 @@ export function getDownloadUrl(id, lastUpdated) {
7070
}
7171

7272
export function getParentFolderUrl(file) {
73-
if (file && file.id) {
74-
let folderPath = window.location.pathname;
75-
const pathParts = file.path.split('/');
76-
const spaceIndex = pathParts.indexOf('spaces');
77-
if (spaceIndex !== -1) {
78-
if (pathParts[spaceIndex + 2] === 'Documents') {
79-
pathParts[spaceIndex + 2] = 'documents';
80-
}
81-
folderPath = pathParts.slice(spaceIndex + 1, pathParts.length - 1).join('/');
82-
folderPath = `${eXo.env.portal.context}/g/:spaces:${folderPath}`;
83-
} else if (pathParts.indexOf('Users') !== -1) {
84-
const parentIndex = pathParts.indexOf('Private');
85-
if (parentIndex !== -1) {
86-
folderPath = pathParts.slice(parentIndex, pathParts.length - 1).join('/');
87-
folderPath = `${window.location.pathname}/${folderPath}`;
88-
}
89-
}
90-
return folderPath;
73+
if (file && file.id) {
74+
let folderPath = window.location.pathname;
75+
const pathParts = file.path.split('/');
76+
const spaceIndex = pathParts.indexOf('spaces');
77+
if (spaceIndex !== -1) {
78+
if (pathParts[spaceIndex + 2] === 'Documents') {
79+
pathParts[spaceIndex + 2] = 'documents';
80+
}
81+
folderPath = pathParts.slice(spaceIndex + 1, pathParts.length - 1).join('/');
82+
folderPath = `${eXo.env.portal.context}/g/:spaces:${folderPath}`;
83+
} else if (pathParts.indexOf('Users') !== -1) {
84+
const parentIndex = pathParts.indexOf('Private');
85+
if (parentIndex !== -1) {
86+
folderPath = pathParts.slice(parentIndex, pathParts.length - 1).join('/');
87+
folderPath = `${eXo.env.portal.context}/drives/${folderPath}`;
88+
}
9189
}
90+
return folderPath;
91+
}
9292
}
9393

9494
export function getEditorUrl(file, mode) {
95-
const fileId = file.sourceID? file.sourceID: file.id;
96-
let url = `${eXo.env.portal.context}/${eXo.env.portal.portalName}/oeditor?docId=${fileId}&backTo=${getParentFolderUrl(file)}`;
97-
if (mode) {
98-
url += `&mode=${mode}`;
99-
}
100-
return url;
95+
const fileId = file.sourceID? file.sourceID: file.id;
96+
let url = `${eXo.env.portal.context}/${eXo.env.portal.portalName}/oeditor?docId=${fileId}`;
97+
if (mode) {
98+
url += `&mode=${mode}`;
99+
}
100+
url += `&backTo=${getParentFolderUrl(file)}`;
101+
return url;
101102
}
102103

103104
export function getViewType(appId) {

0 commit comments

Comments
 (0)