From 611faf53805da294808608bcae93376dc1453af1 Mon Sep 17 00:00:00 2001 From: Andrey Borysenko Date: Tue, 7 May 2024 16:54:14 +0300 Subject: [PATCH] keep v1 handler for single file action Signed-off-by: Andrey Borysenko --- src/filesplugin28.js | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/filesplugin28.js b/src/filesplugin28.js index 9971292b..479c096b 100644 --- a/src/filesplugin28.js +++ b/src/filesplugin28.js @@ -65,15 +65,25 @@ function registerFileAction28(fileAction, inlineSvgIcon) { }, async exec(node, view, dir) { const exAppFileActionHandler = generateAppAPIProxyUrl(fileAction.appid, fileAction.action_handler) - return axios.post(exAppFileActionHandler, { files: [buildNodeInfo(node)] }) - .then((response) => { - if ('redirect_handler' in response.data) { - const redirectPage = generateExAppUIPageUrl(fileAction.appid, response.data.redirect_handler) - window.location.assign(`${redirectPage}?fileIds=${node.fileid}`) + if ('version' in fileAction && fileAction.version === '2.0') { + return axios.post(exAppFileActionHandler, { files: [buildNodeInfo(node)] }) + .then((response) => { + if ('redirect_handler' in response.data) { + const redirectPage = generateExAppUIPageUrl(fileAction.appid, response.data.redirect_handler) + window.location.assign(`${redirectPage}?fileIds=${node.fileid}`) + return true + } return true - } + }).catch((error) => { + console.error('Failed to send FileAction request to ExApp', error) + return false + }) + } + return axios.post(exAppFileActionHandler, buildNodeInfo(node)) + .then((response) => { return true - }).catch((error) => { + }) + .catch((error) => { console.error('Failed to send FileAction request to ExApp', error) return false })