Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: file extension to lowercase when action detect #945

Merged
merged 1 commit into from
Feb 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading