From 60a486298cf002c059ef2e15d17501bc6d34832b Mon Sep 17 00:00:00 2001 From: nathangray Date: Tue, 23 Feb 2021 11:39:36 -0700 Subject: [PATCH] Calendar: Disable convert actions if they don't support integrated app --- calendar/inc/class.calendar_uilist.inc.php | 6 ++++++ calendar/js/app.js | 19 ++++++++++++++++++ calendar/js/app.ts | 23 ++++++++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/calendar/inc/class.calendar_uilist.inc.php b/calendar/inc/class.calendar_uilist.inc.php index 52ecbf0ca9..e20c759e42 100644 --- a/calendar/inc/class.calendar_uilist.inc.php +++ b/calendar/inc/class.calendar_uilist.inc.php @@ -1017,6 +1017,9 @@ class calendar_uilist extends calendar_ui 'allowOnMultiple' => false, 'url' => 'menuaction=infolog.infolog_ui.edit&type=task&action=calendar&action_id=$id', 'popup' => Link::get_registry('infolog', 'add_popup'), + // Limit infolog convert to only the apps that support it (some entries may be other apps via integration) + 'enabled' => 'javaScript:app.calendar.action_convert_enabled_check', + 'convert_apps' => Api\Hooks::implemented('infolog_set') ); } if($GLOBALS['egw_info']['user']['apps']['mail']) @@ -1063,6 +1066,9 @@ class calendar_uilist extends calendar_ui 'onExecute' => 'javaScript:app.calendar.action_open', 'open' => '{"app": "timesheet", "type": "add", "extra": "link_app[]=$app&link_id[]=$app_id"}', 'popup' => Link::get_registry('timesheet', 'add_popup'), + // Limit timesheet convert to only the apps that support it (some entries may be other apps via integration) + 'enabled' => 'javaScript:app.calendar.action_convert_enabled_check', + 'convert_apps' => Api\Hooks::implemented('timesheet_set') ); $actions['timesheet-add'] = array( // automatic add for multiple events 'icon' => 'timesheet/navbar', diff --git a/calendar/js/app.js b/calendar/js/app.js index 864dbc0f67..a85caf6e55 100644 --- a/calendar/js/app.js +++ b/calendar/js/app.js @@ -1667,6 +1667,25 @@ var CalendarApp = /** @class */ (function (_super) { this.egw.open_link(url, _action.data.target, _action.data.popup); } }; + /** + * Check to see if we know how to convert this entry to the given app + * + * The current entry may not be an actual calendar event, it may be some other app + * that is participating via integration hook. This is determined by checking the + * hooks defined for _set, indicating that the app knows how to provide + * information for that application + * + * @param {egwAction} _action + * @param {egwActionObject[]} _events + */ + CalendarApp.prototype.action_convert_enabled_check = function (_action, _events) { + var supported_apps = _action.data.convert_apps || []; + var entry = egw.dataGetUIDdata(_events[0].id); + if (supported_apps && entry && entry.data) { + return supported_apps.length > 0 && supported_apps.indexOf(entry.data.app) >= 0; + } + return true; + }; /** * Context menu action (on a single event) in non-listview to generate ical * diff --git a/calendar/js/app.ts b/calendar/js/app.ts index 8b908a8ade..362c51c6de 100644 --- a/calendar/js/app.ts +++ b/calendar/js/app.ts @@ -1816,6 +1816,29 @@ class CalendarApp extends EgwApp } } + /** + * Check to see if we know how to convert this entry to the given app + * + * The current entry may not be an actual calendar event, it may be some other app + * that is participating via integration hook. This is determined by checking the + * hooks defined for _set, indicating that the app knows how to provide + * information for that application + * + * @param {egwAction} _action + * @param {egwActionObject[]} _events + */ + action_convert_enabled_check(_action, _events) : boolean + { + let supported_apps = _action.data.convert_apps || []; + let entry = egw.dataGetUIDdata(_events[0].id); + + if(supported_apps && entry && entry.data) + { + return supported_apps.length > 0 && supported_apps.indexOf(entry.data.app) >= 0; + } + return true; + } + /** * Context menu action (on a single event) in non-listview to generate ical *