From 9d717091a22f6ecce2c78f9fc3d1adbdef05e114 Mon Sep 17 00:00:00 2001 From: sokumon Date: Mon, 17 Feb 2025 23:02:28 +0530 Subject: [PATCH] fix: cleanup view file button --- frappe/core/doctype/file/file.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/frappe/core/doctype/file/file.js b/frappe/core/doctype/file/file.js index b6385d68ff..015f89655d 100644 --- a/frappe/core/doctype/file/file.js +++ b/frappe/core/doctype/file/file.js @@ -1,10 +1,15 @@ frappe.ui.form.on("File", { refresh: function (frm) { - frm.add_custom_button(__("View File"), () => { - if (!frappe.utils.is_url(frm.doc.file_url)) { - window.open(window.location.origin + frm.doc.file_url); - } - }); + if (frm.doc.file_url) { + frm.add_custom_button(__("View File"), () => { + if (!frappe.utils.is_url(frm.doc.file_url)) { + window.open(window.location.origin + frm.doc.file_url); + } else { + window.open(frm.doc.file_url); + } + }); + } + if (!frm.doc.is_folder) { // add download button frm.add_custom_button(__("Download"), () => frm.trigger("download"), "fa fa-download"); @@ -32,9 +37,6 @@ frappe.ui.form.on("File", { if (frm.doc.file_name && frm.doc.file_name.split(".").splice(-1)[0] === "zip") { frm.add_custom_button(__("Unzip"), () => frm.trigger("unzip")); } - if (frm.doc.file_url) { - frm.add_web_link(frm.doc.file_url, __("View file")); - } }, preview_file: function (frm) {