Skip to content

Commit

Permalink
Merge pull request #945 from ONLYOFFICE/hotfix/actions-extension
Browse files Browse the repository at this point in the history
fix: file extension to lowercase when action detect
  • Loading branch information
LinneyS authored Feb 16, 2024
2 parents d20b985 + bcaed97 commit d908e46
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,13 @@ import NewDocxfSvg from "!!raw-loader!../img/new-docxf.svg";
OCA.Onlyoffice.registerAction = function() {
var formats = OCA.Onlyoffice.setting.formats;

var getConfig = function (file) {
var fileExt = file?.extension?.toLowerCase()?.replace(".", "");
var config = formats[fileExt];

return config;
};

if (OCA.Files && OCA.Files.fileActions) {
$.each(formats, function (ext, config) {
if (!config.mime) {
Expand Down Expand Up @@ -508,7 +515,7 @@ import NewDocxfSvg from "!!raw-loader!../img/new-docxf.svg";
displayName: () => t(OCA.Onlyoffice.AppName, "Open in ONLYOFFICE"),
iconSvgInline: () => AppDarkSvg,
enabled: (files) => {
var config = formats[files[0]?.extension?.replace(".", "")];
var config = getConfig(files[0]);

if (!config) return;
if (!config.def) return;
Expand All @@ -527,7 +534,7 @@ import NewDocxfSvg from "!!raw-loader!../img/new-docxf.svg";
displayName: () => t(OCA.Onlyoffice.AppName, "Open in ONLYOFFICE"),
iconSvgInline: () => AppDarkSvg,
enabled: (files) => {
var config = formats[files[0]?.extension?.replace(".", "")];
var config = getConfig(files[0]);

if (!config) return false;
if (config.def) return false;
Expand All @@ -545,7 +552,7 @@ import NewDocxfSvg from "!!raw-loader!../img/new-docxf.svg";
displayName: () => t(OCA.Onlyoffice.AppName, "Convert with ONLYOFFICE"),
iconSvgInline: () => AppDarkSvg,
enabled: (files) => {
var config = formats[files[0]?.extension?.replace(".", "")];
var config = getConfig(files[0]);

if (!config) return;
if (!config.conv) return false;
Expand Down Expand Up @@ -574,7 +581,7 @@ import NewDocxfSvg from "!!raw-loader!../img/new-docxf.svg";
displayName: () => t(OCA.Onlyoffice.AppName, "Fill in form in ONLYOFFICE"),
iconSvgInline: () => AppDarkSvg,
enabled: (files) => {
var config = formats[files[0]?.extension?.replace(".", "")];
var config = getConfig(files[0]);

if (!config) return;
if (!config.fillForms) return false;
Expand All @@ -596,7 +603,7 @@ import NewDocxfSvg from "!!raw-loader!../img/new-docxf.svg";
displayName: () => t(OCA.Onlyoffice.AppName, "Create form"),
iconSvgInline: () => AppDarkSvg,
enabled: (files) => {
var config = formats[files[0]?.extension?.replace(".", "")];
var config = getConfig(files[0]);

if (!config) return;
if (!config.createForm) return false;
Expand Down Expand Up @@ -626,7 +633,7 @@ import NewDocxfSvg from "!!raw-loader!../img/new-docxf.svg";
displayName: () => t(OCA.Onlyoffice.AppName, "Download as"),
iconSvgInline: () => AppDarkSvg,
enabled: (files) => {
var config = formats[files[0]?.extension?.replace(".", "")];
var config = getConfig(files[0]);

if (!config) return;
if (!config.saveas) return false;
Expand Down

0 comments on commit d908e46

Please sign in to comment.