diff options
author | Raul <r.ferreira.fuentes@gmail.com> | 2022-10-17 11:24:19 +0300 |
---|---|---|
committer | Raul <r.ferreira.fuentes@gmail.com> | 2022-10-17 11:41:53 +0300 |
commit | 8dcf37593f713156a36a3837913c05f6ced7a4c9 (patch) | |
tree | 2237555a07db3d6a0f57ab25a6a52148accb6432 | |
parent | bfadc2a9c64b1fdb83892144cc0f09df9535433b (diff) |
For PDFs rename context menu option to "Open with"
Signed-off-by: Raul <r.ferreira.fuentes@gmail.com>
-rw-r--r-- | src/files.js | 46 | ||||
-rw-r--r-- | src/viewer.js | 5 |
2 files changed, 3 insertions, 48 deletions
diff --git a/src/files.js b/src/files.js index aca96a34..4cd6d270 100644 --- a/src/files.js +++ b/src/files.js @@ -49,52 +49,6 @@ const odfViewer = { excludeMimeFromDefaultOpen: OC.getCapabilities().richdocuments.mimetypesNoDefaultOpen, hideDownloadMimes: ['image/jpeg', 'image/svg+xml', 'image/cgm', 'image/vnd.dxf', 'image/x-emf', 'image/x-wmf', 'image/x-wpg', 'image/x-freehand', 'image/bmp', 'image/png', 'image/gif', 'image/tiff', 'image/jpg', 'image/jpeg', 'text/plain', 'application/pdf'], - registerFileActions() { - const EDIT_ACTION_NAME = 'Edit with ' + OC.getCapabilities().richdocuments.productName - for (const mime of odfViewer.supportedMimes) { - OCA.Files.fileActions.register( - mime, - EDIT_ACTION_NAME, - OC.PERMISSION_READ, - imagePath('core', 'actions/rename'), - (fileName, context) => { - // Workaround since the new template frontend doesn't pass - // the full context yet nor the filelist contains the element - // at the point when the action is triggered. - // This will be fixed by https://github.com/nextcloud/server/pull/25797 - // but this should be kept for backward compatibility for now - if (!context?.$file) { - if (context?.fileList) { - context.fileList.setViewerMode(true) - } - const filePath = (context.dir === '/' ? '/' : context.dir + '/') + fileName - OCA.Files.App.fileList.filesClient.getFileInfo(filePath).then((status, fileInfo) => { - const fileModel = context.fileList.findFile(fileName) - const shareOwnerId = fileModel?.shareOwnerId || fileInfo?.shareOwnerId - context.fileId = fileInfo.id - return this.onEdit(fileName, { - ...context, - shareOwnerId, - }) - }) - return - } - - const fileModel = context.fileList.findFile(fileName) - const shareOwnerId = fileModel?.shareOwnerId - return this.onEdit(fileName, { - ...context, - shareOwnerId, - }) - }, - t('richdocuments', 'Edit with {productName}', { productName: OC.getCapabilities().richdocuments.productName }, undefined, { escape: false }) - ) - if (odfViewer.excludeMimeFromDefaultOpen.indexOf(mime) === -1 || isDownloadHidden) { - OCA.Files.fileActions.setDefault(mime, EDIT_ACTION_NAME) - } - } - }, - onEdit(fileName, context) { let fileDir let fileId diff --git a/src/viewer.js b/src/viewer.js index e2100c1e..4ab712a2 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -43,7 +43,8 @@ if (OCA.Viewer) { if (OCA.Viewer.openWith) { const supportedMimes = getCapabilities().richdocuments.mimetypesNoDefaultOpen const actionName = 'Edit with ' + getCapabilities().richdocuments.productName - const actionDisplayName = t('richdocuments', 'Edit with {productName}', { productName: getCapabilities().richdocuments.productName }, undefined, { escape: false }) + const actionDisplayNameEdit = t('richdocuments', 'Edit with {productName}', { productName: getCapabilities().richdocuments.productName }, undefined, { escape: false }) + const actionDisplayNameOpen = t('richdocuments', 'Open with {productName}', { productName: getCapabilities().richdocuments.productName }, undefined, { escape: false }) for (const mime of supportedMimes) { const action = { @@ -51,7 +52,7 @@ if (OCA.Viewer.openWith) { mime, permissions: OC.PERMISSION_READ, iconClass: 'icon-richdocuments', - displayName: actionDisplayName, + displayName: mime === 'application/pdf' ? actionDisplayNameOpen : actionDisplayNameEdit, actionHandler: (fileName, context) => { OCA.Viewer.openWith('richdocuments', { path: context.fileInfoModel.getFullPath(), |