Skip to content

Commit

Permalink
change registration of actions
Browse files Browse the repository at this point in the history
  • Loading branch information
LinneyS committed May 14, 2021
1 parent 71ccce8 commit 219de40
Showing 1 changed file with 31 additions and 36 deletions.
67 changes: 31 additions & 36 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,47 +208,41 @@
}
};

OCA.Onlyoffice.FileList = {
attach: function (fileList) {
if (fileList.id == "trashbin") {
return;
}
OCA.Onlyoffice.registerAction = function () {
var register = function () {
var formats = OCA.Onlyoffice.setting.formats;

var register = function () {
var formats = OCA.Onlyoffice.setting.formats;
$.each(formats, function (ext, config) {
if (!config.mime) {
return true;
}
OCA.Files.fileActions.registerAction({
name: "onlyofficeOpen",
displayName: t(OCA.Onlyoffice.AppName, "Open in ONLYOFFICE"),
mime: config.mime,
permissions: OC.PERMISSION_READ,
iconClass: "icon-onlyoffice-open",
actionHandler: OCA.Onlyoffice.FileClick
});

$.each(formats, function (ext, config) {
if (!config.mime) {
return true;
}
if (config.def) {
OCA.Files.fileActions.setDefault(config.mime, "onlyofficeOpen");
}

if (config.conv) {
OCA.Files.fileActions.registerAction({
name: "onlyofficeOpen",
displayName: t(OCA.Onlyoffice.AppName, "Open in ONLYOFFICE"),
name: "onlyofficeConvert",
displayName: t(OCA.Onlyoffice.AppName, "Convert with ONLYOFFICE"),
mime: config.mime,
permissions: OC.PERMISSION_READ,
iconClass: "icon-onlyoffice-open",
actionHandler: OCA.Onlyoffice.FileClick
permissions: ($("#isPublic").val() ? OC.PERMISSION_UPDATE : OC.PERMISSION_READ),
iconClass: "icon-onlyoffice-convert",
actionHandler: OCA.Onlyoffice.FileConvertClick
});

if (config.def) {
OCA.Files.fileActions.setDefault(config.mime, "onlyofficeOpen");
}

if (config.conv) {
OCA.Files.fileActions.registerAction({
name: "onlyofficeConvert",
displayName: t(OCA.Onlyoffice.AppName, "Convert with ONLYOFFICE"),
mime: config.mime,
permissions: ($("#isPublic").val() ? OC.PERMISSION_UPDATE : OC.PERMISSION_READ),
iconClass: "icon-onlyoffice-convert",
actionHandler: OCA.Onlyoffice.FileConvertClick
});
}
});
}

OCA.Onlyoffice.GetSettings(register);
}
});
}

OCA.Onlyoffice.GetSettings(register);
};

OCA.Onlyoffice.NewFileMenu = {
Expand Down Expand Up @@ -378,9 +372,10 @@

OCA.Onlyoffice.GetSettings(initSharedButton);
} else {
OC.Plugins.register("OCA.Files.FileList", OCA.Onlyoffice.FileList);
OC.Plugins.register("OCA.Files.NewFileMenu", OCA.Onlyoffice.NewFileMenu);

OCA.Onlyoffice.registerAction();

OCA.Onlyoffice.bindVersionClick();

if (OCA.Onlyoffice.Share) {
Expand Down

0 comments on commit 219de40

Please sign in to comment.