RealRaven2000 / SmartTemplates

Thunderbird Add-on: SmartTemplates
http://smarttemplates.quickfolders.org/
Other
25 stars 15 forks source link

Tb 115: rewrite (template) menus using API methods #253

Closed RealRaven2000 closed 4 months ago

RealRaven2000 commented 11 months ago

In order to better support the new SuperNova environment, the popup menus showing the commands / templates have to be built in the background page using API code.

Steps to implementation

-- in the background page, create the menu and then update on shown

// in main():
messenger.menus.create();  // load menu data from the experiment (or use cached data)

messenger.menus.onShown(info, tab) {
  //   get the tab  
  messenger.messageDisplay.getDisplayedMessage(tab) // => gives tab + messageDisplay
  messenger.menus.update(); // (from json data)

  messenger.menus.refresh()  // to rebuild the menu.
}

Christopher Leidigh suggested to look at ImportExport tools ng for example code for vuilding menus, see: https://github.com/thundernest/import-export-tools-ng/blob/v14.0.0/src/wextMenus.js

RealRaven2000 commented 4 months ago

1st (semi stable) Test version:

smartTemplate-fx-4.4pre132.zip

To activate the new menu system (only affects the message action menu above the message preview), select this from the Test menu:

image

To do:

RealRaven2000 commented 4 months ago

Next version, this one is able to correctly update the MRU items. It also has the "configure menu items" command. You still have to activate the mechanism from the test menu (see previous comment) Test / Create message Actions (API). Once you use a template from the dropdowns, the MRU items will update.

smartTemplate-fx-4.4pre135.zip

The menus reply all and reply list may not work on certain mails, they should ideally be hidden in the future depending on whether a controller for the command exists - see fileTemplates.fireComposeCommand(). We need a way to do (somthing like) this based on the selected email when the action menu is opened and then hide those particular submenus, using the API.

Legacy code:

// Possible commands :  
 const ControllerMap = new Map([
  ["cmd_newMessage", "new"], 
  ["cmd_reply", "rsp"],
  ["cmd_replyAll", "rsp"],
  ["cmd_replyList", "rsp"],
  ["cmd_forward", "fwd"]
]);

    let controller = getEnabledControllerForCommand(entry.command);
    if (!controller) {
      SmartTemplate4.Util.logDebug(`No controller exists for the command ${entry.command} `);
    } else {
      if (controller.isCommandEnabled(entry.command)) {
        controller.doCommand(entry.command);
      } else {
        SmartTemplate4.Util.logToConsole(`Cannot call command ${entry.command} as it is disabled.`);
      }
    }
RealRaven2000 commented 4 months ago

Here is the latest version (removed the legacy part for the action menu)

smartTemplate-fx-4.4pre143.zip

One main problem is that the "last template" currently is moved to the bottom of the menu (although it should remain at the same position when calling menus.udpate() - I suppose this may be a bug in the menus API.

image

RealRaven2000 commented 4 months ago

In this latest version, I diversified the "Last Template" items so that there are separate items for reply, reply all and reply list. This seems to be more user friendly, as these are also separate items when listed in the MRU menu.

smartTemplate-fx-4.4pre144.zip

I also removed the remaining obsolete sections of legacy code that manipulated the message action menus - this is now fully based on the API. The next big step would be to do the same for all menus in the unified toolbar, which will probably be handled in a separate issue.


To install version above download zip file and drag the file into Thunderbird Add-ons Manager (do not extract contents, it won't install like that)

RealRaven2000 commented 4 months ago

Latest version - I added the license based restrictions and message that explains license tiers, also made the categories case insensitive so that different-cased categories, e..g quickfilters + quickFilters will show under the same child menu:.

image

restrictions for free + Standard version: max 3 categories (items cats are gathered under "other") restrictions for free version: 5 templates max restrictions for Standard version: 25 templates max no restrictions for Pro version.

smartTemplate-fx-4.4pre164.zip


To install version above download zip file and drag the file into Thunderbird Add-ons Manager (do not extract contents, it won't install like that)

RealRaven2000 commented 4 months ago

Added warning item for when too many categories are defined. Also added a warning icon for all menu items that explain restrictions.

image

this particular item will now open the SmartTemplates licenses dialog so users can go to the feature comparison page and / or obtain a license.

smartTemplate-fx-4.4pre167.zip


To install version above download zip file and drag the file into Thunderbird Add-ons Manager (do not extract contents, it won't install like that)

RealRaven2000 commented 4 months ago

Implemented in 4.4 - published 28/03/2024