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

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

Closed
RealRaven2000 opened this issue Aug 10, 2023 · 7 comments
Closed

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

RealRaven2000 opened this issue Aug 10, 2023 · 7 comments
Assignees
Labels
enhancement ESR 115 Changes for Thunderbird SuperNova UI

Comments

@RealRaven2000
Copy link
Owner

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

  • make an experimental API for loading the template file (using legacy method)
  • use LegacyPrefs as a template for this - clone that

--
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 RealRaven2000 added enhancement ESR 115 Changes for Thunderbird SuperNova UI labels Aug 10, 2023
@RealRaven2000 RealRaven2000 self-assigned this Aug 10, 2023
@RealRaven2000 RealRaven2000 changed the title Tb 115: rewrite smarttempltes / (template) menus using API methods Tb 115: rewrite all (template) menus using API methods Aug 16, 2023
@RealRaven2000
Copy link
Owner Author

RealRaven2000 commented Mar 14, 2024

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:

  • "configure menu items" commands are missing.
  • test all MRU items. (including Last template for each composeCase)
  • implement license type based restrictions (max 3 categories etc.)

@RealRaven2000
Copy link
Owner Author

RealRaven2000 commented Mar 15, 2024

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 RealRaven2000 changed the title Tb 115: rewrite all (template) menus using API methods Tb 115: rewrite (template) menus using API methods Mar 18, 2024
@RealRaven2000
Copy link
Owner Author

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 added a commit that referenced this issue Mar 20, 2024
- added support for refreshing from settings
- update the "Last item" and MRU list to be always current
- improved css selector for hidden label
RealRaven2000 added a commit that referenced this issue Mar 20, 2024
- added separate "Last Template" items for reply, reply all, reply list
- removed obsolete legacy header customization code
@RealRaven2000
Copy link
Owner Author

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 RealRaven2000 pinned this issue Mar 23, 2024
RealRaven2000 added a commit that referenced this issue Mar 27, 2024
Added SmartTemplates Message handler to communicate from background script
RealRaven2000 added a commit that referenced this issue Mar 27, 2024
- Added SmartTemplates Message handler to communicate from background script
- added restrictions (license based)
- made categories case insensitive
@RealRaven2000
Copy link
Owner Author

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 added a commit that referenced this issue Mar 27, 2024
- added category warning
- added warning icon
@RealRaven2000
Copy link
Owner Author

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
Copy link
Owner Author

Implemented in 4.4 - published 28/03/2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ESR 115 Changes for Thunderbird SuperNova UI
Projects
None yet
Development

No branches or pull requests

1 participant