emailengine-app 2.79.0 → 2.79.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/.release-please-manifest.json +1 -1
  2. package/CHANGELOG.md +79 -0
  3. package/bin/emailengine.js +8 -1
  4. package/config/default.toml +6 -0
  5. package/data/google-crawlers.json +1 -1
  6. package/lib/account.js +137 -19
  7. package/lib/api-routes/account-routes.js +13 -1
  8. package/lib/api-routes/index.js +12 -0
  9. package/lib/api-routes/mailbox-routes.js +6 -0
  10. package/lib/api-routes/mcp-oauth-routes.js +259 -0
  11. package/lib/api-routes/mcp-routes.js +172 -0
  12. package/lib/api-routes/message-routes.js +125 -4
  13. package/lib/api-routes/outbox-routes.js +7 -0
  14. package/lib/api-routes/permission-map.js +101 -1
  15. package/lib/api-routes/route-helpers.js +87 -4
  16. package/lib/api-routes/route-metadata.js +24 -4
  17. package/lib/api-routes/settings-routes.js +37 -14
  18. package/lib/api-routes/submit-routes.js +41 -0
  19. package/lib/api-routes/template-routes.js +7 -0
  20. package/lib/api-routes/token-routes.js +292 -122
  21. package/lib/arf-detect.js +17 -4
  22. package/lib/bounce-detect.js +28 -17
  23. package/lib/consts.js +36 -1
  24. package/lib/db.js +6 -0
  25. package/lib/email-client/base-client.js +102 -117
  26. package/lib/email-client/gmail-client.js +91 -29
  27. package/lib/email-client/imap/mailbox.js +175 -101
  28. package/lib/email-client/imap-client.js +49 -2
  29. package/lib/email-client/outlook-client.js +20 -24
  30. package/lib/enum-descriptions.js +2 -1
  31. package/lib/field-usage.js +17 -1
  32. package/lib/lua/h-set-new-mark.lua +36 -0
  33. package/lib/lua/s-list-accounts.lua +5 -2
  34. package/lib/mcp/index.js +29 -0
  35. package/lib/mcp/inject.js +70 -0
  36. package/lib/mcp/json-schema.js +120 -0
  37. package/lib/mcp/listen.js +171 -0
  38. package/lib/mcp/oauth.js +324 -0
  39. package/lib/mcp/protocol.js +489 -0
  40. package/lib/mcp/resources.js +139 -0
  41. package/lib/mcp/tools.js +655 -0
  42. package/lib/message-port-stream.js +84 -1
  43. package/lib/oauth2-apps.js +84 -15
  44. package/lib/openapi/build-document.js +5 -1
  45. package/lib/openapi/index.js +3 -1
  46. package/lib/response-stream.js +52 -21
  47. package/lib/routes-ui.js +4 -0
  48. package/lib/schemas.js +26 -5
  49. package/lib/settings.js +23 -9
  50. package/lib/token-audit-log.js +32 -9
  51. package/lib/token-permission-view.js +104 -8
  52. package/lib/tokens.js +194 -68
  53. package/lib/tools.js +96 -0
  54. package/lib/ui-routes/account-routes.js +55 -6
  55. package/lib/ui-routes/admin-config-routes.js +114 -1
  56. package/lib/ui-routes/admin-entities-routes.js +103 -19
  57. package/lib/ui-routes/auth-routes.js +13 -0
  58. package/lib/ui-routes/mcp-consent-routes.js +330 -0
  59. package/lib/ui-routes/oauth-config-routes.js +7 -7
  60. package/lib/ui-routes/route-helpers.js +143 -1
  61. package/lib/ui-routes/suppression-list-routes.js +14 -9
  62. package/lib/utils/decode-headers.js +42 -0
  63. package/lib/utils/header-map.js +48 -0
  64. package/lib/utils/network.js +9 -1
  65. package/lib/utils/unsafe-key.js +59 -0
  66. package/lib/web-safe-html.js +61 -0
  67. package/lib/webhook-routing.js +6 -2
  68. package/lib/webhooks.js +31 -8
  69. package/package.json +9 -8
  70. package/sbom.json +1 -1
  71. package/scripts/README.md +25 -0
  72. package/scripts/build-icon.js +77 -0
  73. package/server.js +39 -17
  74. package/static/css/flyonui.css +1 -1
  75. package/static/css/src/app.tailwind.css +98 -0
  76. package/static/emailengine.ico +0 -0
  77. package/static/js/ui.js +465 -1
  78. package/static/licenses.html +42 -22
  79. package/translations/messages.pot +57 -57
  80. package/views/accounts/account.hbs +8 -8
  81. package/views/accounts/browse.hbs +1 -1
  82. package/views/accounts/edit.hbs +2 -2
  83. package/views/config/mcp.hbs +361 -0
  84. package/views/config/oauth/index.hbs +7 -0
  85. package/views/gateways/edit.hbs +1 -1
  86. package/views/gateways/gateway.hbs +2 -2
  87. package/views/gateways/index.hbs +7 -7
  88. package/views/layout/prompt.hbs +62 -0
  89. package/views/mcp/authorize.hbs +136 -0
  90. package/views/partials/accounts_table.hbs +7 -7
  91. package/views/partials/head_assets.hbs +3 -3
  92. package/views/partials/mcp_access_levels.hbs +13 -0
  93. package/views/partials/mcp_account_limit.hbs +14 -0
  94. package/views/partials/mcp_tool_count.hbs +19 -0
  95. package/views/partials/side_menu.hbs +1 -0
  96. package/views/partials/ui/account-picker.hbs +59 -0
  97. package/views/partials/ui/code-block.hbs +26 -0
  98. package/views/partials/ui/menu-item.hbs +5 -0
  99. package/views/partials/ui/radio.hbs +41 -0
  100. package/views/partials/ui/tab.hbs +15 -10
  101. package/views/partials/ui/tabs.hbs +8 -5
  102. package/views/suppression-lists/list.hbs +1 -1
  103. package/views/templates/index.hbs +2 -2
  104. package/views/templates/template.hbs +5 -4
  105. package/views/tokens/index.hbs +30 -4
  106. package/views/tokens/new.hbs +517 -239
  107. package/winconf.js +148 -48
  108. package/workers/api.js +239 -95
  109. package/workers/imap.js +65 -72
  110. package/workers/webhooks.js +21 -1
@@ -29,16 +29,16 @@
29
29
  {{#each accounts}}
30
30
  <tr class="hover:bg-base-200/60">
31
31
  <td class="relative">
32
- {{> ui/row-link href=(concat "/admin/accounts/" account) label="Open account"}}
32
+ {{> ui/row-link href=(concat "/admin/accounts/" (urlpart account)) label="Open account"}}
33
33
  <div><strong>{{name}}</strong></div>
34
34
  {{> ui/entity-id id=account label="Account ID"}}
35
35
  </td>
36
36
  <td class="relative">
37
- {{> ui/row-link href=(concat "/admin/accounts/" account)}}{{email}}
37
+ {{> ui/row-link href=(concat "/admin/accounts/" (urlpart account))}}{{email}}
38
38
  </td>
39
39
 
40
40
  <td class="relative">
41
- {{> ui/row-link href=(concat "/admin/accounts/" account)}}
41
+ {{> ui/row-link href=(concat "/admin/accounts/" (urlpart account))}}
42
42
  {{#if type.icon}}
43
43
  {{!-- relative z-[1] lifts the tooltip trigger above the row link --}}
44
44
  {{#> ui/tooltip text=type.label class="relative z-[1]"}}
@@ -53,13 +53,13 @@
53
53
  </td>
54
54
 
55
55
  <td class="relative w-32">
56
- {{> ui/row-link href=(concat "/admin/accounts/" account)}}
56
+ {{> ui/row-link href=(concat "/admin/accounts/" (urlpart account))}}
57
57
  {{!-- live state badge: app.js updates the badge-{type} class,
58
58
  text and error tooltip through the /admin/changes SSE
59
59
  feed. The wrapping link lifts the badge above the row
60
60
  overlay so the tooltip fires while clicks still
61
61
  navigate. --}}
62
- <a href="/admin/accounts/{{account}}" class="relative z-[1] inline-flex">
62
+ <a href="/admin/accounts/{{urlpart account}}" class="relative z-[1] inline-flex">
63
63
  {{> ui/state-badge label=stateLabel account=account pointer=true}}
64
64
  </a>
65
65
  </td>
@@ -68,8 +68,8 @@
68
68
  row, not the partial params, so the cell silently vanished (phantom column) --}}
69
69
  {{#if ../showActions}}
70
70
  <td class="relative text-end">
71
- {{> ui/row-actions openHref=(concat "/admin/accounts/" account) label="Account actions"
72
- deleteModal="#deleteAccount" deleteName=(when name name email) deleteAction=(concat "/admin/accounts/" account "/delete")}}
71
+ {{> ui/row-actions openHref=(concat "/admin/accounts/" (urlpart account)) label="Account actions"
72
+ deleteModal="#deleteAccount" deleteName=(when name name email) deleteAction=(concat "/admin/accounts/" (urlpart account) "/delete")}}
73
73
  </td>
74
74
  {{/if}}
75
75
  </tr>
@@ -1,6 +1,6 @@
1
- {{!-- Shared head assets for the admin layouts (app/login/main): favicons, the
2
- pre-paint theme script, and the self-hosted PT Sans font. Stylesheets stay
3
- in the layouts - their order relative to page-specific CSS matters. --}}
1
+ {{!-- Shared head assets for the admin layouts (app/login/main/prompt): favicons,
2
+ the pre-paint theme script, and the self-hosted PT Sans font. Stylesheets
3
+ stay in the layouts - their order relative to page-specific CSS matters. --}}
4
4
  <link rel="apple-touch-icon" href="/static/favicon/apple-touch-icon.png" sizes="180x180" />
5
5
  <link rel="icon" href="/static/favicon/favicon-32x32.png" sizes="32x32" type="image/png" />
6
6
  <link rel="icon" href="/static/favicon/favicon-16x16.png" sizes="16x16" type="image/png" />
@@ -0,0 +1,13 @@
1
+ {{!--
2
+ The MCP access-level radio group, rendered identically by the OAuth consent prompt and the
3
+ admin token generator so the two cannot drift on what each level promises. The options come
4
+ from MCP_ACCESS_LEVEL_OPTIONS (lib/token-permission-view.js) through the accessOptions
5
+ context value.
6
+ Params:
7
+ name - input name shared by the radio group (required)
8
+ idPrefix - per-page prefix for the input ids (required)
9
+ selected - the selected value (required; pass "read" for the static default)
10
+ --}}
11
+ {{#each accessOptions}}
12
+ {{> ui/radio id=(concat ../idPrefix value) name=../name value=value label=label selected=../selected hint=hint}}
13
+ {{/each}}
@@ -0,0 +1,14 @@
1
+ {{!--
2
+ The "Limit to one account" field, offered identically by the OAuth consent prompt and the
3
+ admin token generator so the two cannot drift on the wording - the same reason
4
+ mcp_access_levels.hbs exists. The control itself is the shared ui/account-picker; only the
5
+ label and the hint, which are about what the binding means for an MCP client, live here.
6
+ Params:
7
+ id - input id, also the posted field name (required)
8
+ value - current value, for validation re-renders (optional)
9
+ selected - picker entry for that value (optional)
10
+ error - validation error message (optional)
11
+ --}}
12
+ {{> ui/account-picker id=id value=value selected=selected error=error label="Limit to one account"
13
+ placeholder="Search by name, address or account id"
14
+ hint="Recommended. The client then only reaches this account, and its tools stop asking which account to act on. Leave empty to allow every account on the instance."}}
@@ -0,0 +1,19 @@
1
+ {{!--
2
+ The "N of M MCP tools available" line, shown by every page that mints an mcp-scoped token so
3
+ the three cannot disagree about what a credential will actually be offered. The counting rule
4
+ is uiMcpToolCount() in static/js/ui.js - the browser's copy of toolVisibleTo(), pinned to it by
5
+ test/mcp-tools-test.js. Reads mcpTools (and mcpAccessPresets, when auto-wired) from the
6
+ page context.
7
+
8
+ Pass levelName to have ui.js drive the count from a named access level (the MCP config
9
+ generator and the consent prompt); leave it out and the page repaints the element itself,
10
+ which is what the access-token form does for its custom-permissions option.
11
+ Params:
12
+ id - element id (required; the page's own script needs it, and so does nothing else)
13
+ levelName - the radio group name to follow, for the auto-wired pages (optional)
14
+ accountId - id of the "limit to one account" field to follow (optional, with levelName)
15
+ class - extra classes on the wrapper (optional)
16
+ --}}
17
+ <div id="{{id}}" class="text-sm space-y-1{{#if class}} {{class}}{{/if}}" data-mcp-tools="{{json mcpTools}}"
18
+ {{#if levelName}}data-mcp-level-name="{{levelName}}" data-mcp-account-id="{{accountId}}"
19
+ data-mcp-presets="{{json mcpAccessPresets}}"{{/if}}></div>
@@ -27,6 +27,7 @@
27
27
  {{> ui/menu-item href="/admin/config/email-processing" label="Email Processing" active=menuConfigEmailProcessing}}
28
28
  {{> ui/menu-item href="/admin/config/webhooks" label="Webhooks" active=menuConfigWebhooks}}
29
29
  {{> ui/menu-item href="/admin/config/ai" label="AI Processing" active=menuConfigAi}}
30
+ {{> ui/menu-item href="/admin/config/mcp" label="MCP" badge="Beta" active=menuConfigMcp}}
30
31
  {{> ui/menu-item href="/admin/config/network" label="Network" active=menuConfigNetwork}}
31
32
  {{> ui/menu-item href="/admin/config/smtp" label="SMTP Server" active=menuConfigSmtp}}
32
33
  {{> ui/menu-item href="/admin/config/imap-proxy" label="IMAP Proxy" active=menuConfigImapProxy}}
@@ -0,0 +1,59 @@
1
+ {{!--
2
+ ui/account-picker - the "which account" field.
3
+
4
+ A free-text account id is a field only the person who already knows the id can fill in, and the
5
+ id is the one thing about an account nobody remembers. This is a search box instead: type any
6
+ part of an id, a name or an address, pick from the suggestions, and the box is replaced by a
7
+ card naming the account that was picked, with a button to clear it again.
8
+
9
+ The posted value stays a plain account id in a hidden input carrying the given id, so a page
10
+ that already reads or watches that field keeps working - static/js/ui.js fires `input` and
11
+ `change` on it whenever the choice changes, exactly as typing into a text field would.
12
+
13
+ Suggestions come from GET /admin/accounts/suggestions; the card is painted by ui.js from the
14
+ same JSON shape, so a server-rendered selection and a just-picked one cannot look different.
15
+
16
+ Hand-rolled rather than FlyonUI's HSComboBox, which the vendored bundle does carry: that
17
+ component renders items from template strings, and every field on a row here (a display name,
18
+ an address) arrives from a mail provider, so the rows are built as text nodes instead. The
19
+ hidden-id-plus-card shape is not one of its modes either.
20
+ {{> ui/account-picker id="account" label="Account" value=values.account selected=selectedAccount}}
21
+ Params:
22
+ id - hidden input id, also the default posted name and what page scripts read (required)
23
+ name - posted field name (defaults to id)
24
+ label - field label (optional)
25
+ hint - muted helper text under the control (optional)
26
+ error - validation error message (optional)
27
+ value - current account id (optional)
28
+ selected - picker entry for `value`: {account, name, email, state} (optional; without it a
29
+ value renders as an id the picker could not resolve, which is what a deleted
30
+ account looks like)
31
+ placeholder - search box placeholder (optional)
32
+ --}}
33
+ <div class="w-full">
34
+ {{#if label}}
35
+ <label class="label-text" for="{{id}}-search">{{label}}</label>
36
+ {{/if}}
37
+ <div data-account-picker data-input="{{id}}" {{#if selected}}data-selected="{{json selected}}" {{/if}}>
38
+ <input type="hidden" id="{{id}}" name="{{#if name}}{{name}}{{else}}{{id}}{{/if}}" {{#if value}}value="{{value}}" {{/if}}>
39
+
40
+ {{!-- The picked account. Empty until ui.js paints it, and hidden whenever nothing is picked. --}}
41
+ <div class="ee-account-picker-card hidden" data-picker-card></div>
42
+
43
+ <div class="ee-account-picker-search" data-picker-search>
44
+ <div class="input{{#if error}} is-invalid{{/if}}">
45
+ <span class="icon-[tabler--search] text-base-content/60 my-auto me-2 size-4 shrink-0"></span>
46
+ <input type="text" class="grow" id="{{id}}-search" role="combobox" aria-expanded="false" aria-autocomplete="list"
47
+ aria-controls="{{id}}-results" autocomplete="off" data-lpignore="true"
48
+ placeholder="{{#if placeholder}}{{placeholder}}{{else}}Search by name, address or account id{{/if}}">
49
+ </div>
50
+ <div class="ee-account-picker-results hidden" id="{{id}}-results" role="listbox" data-picker-results></div>
51
+ </div>
52
+ </div>
53
+ {{#if error}}
54
+ <span class="helper-text text-error">{{error}}</span>
55
+ {{/if}}
56
+ {{#if hint}}
57
+ <span class="helper-text">{{hint}}</span>
58
+ {{/if}}
59
+ </div>
@@ -0,0 +1,26 @@
1
+ {{!--
2
+ ui/code-block - labeled preformatted code block with an optional copy button (handled
3
+ centrally by the .copy-btn listener in static/js/ui.js). The <code> element renders empty -
4
+ pages fill it by id from their script. Optional block content renders as muted helper text
5
+ under the block; it is block content rather than a hash param so it can carry inline markup.
6
+ {{> ui/code-block id="x" label="..." copy=true}}
7
+ {{#> ui/code-block id="x" label="..."}}helper text{{/ui/code-block}}
8
+ Params:
9
+ id - id of the inner <code> element (required; also the copy target)
10
+ label - label text above the block (required)
11
+ copy - true to render a copy-to-clipboard button
12
+ --}}
13
+ <div>
14
+ {{#if copy}}
15
+ <div class="flex items-center justify-between gap-2 mb-1">
16
+ <span class="label-text">{{label}}</span>
17
+ {{> ui/copy-btn target=id small=true}}
18
+ </div>
19
+ {{else}}
20
+ <span class="label-text">{{label}}</span>
21
+ {{/if}}
22
+ <pre class="ee-code-block"><code id="{{id}}"></code></pre>
23
+ {{#if @partial-block}}
24
+ <span class="helper-text">{{> @partial-block id="" label="" copy=""}}</span>
25
+ {{/if}}
26
+ </div>
@@ -5,6 +5,7 @@
5
5
  label - link text (required)
6
6
  icon - full iconify class incl. size, e.g. "icon-[tabler--users] size-4.5" (optional)
7
7
  active - true to highlight as the current page
8
+ badge - small soft badge text after the label, e.g. "Beta" (optional)
8
9
  warnText - when non-empty, renders a trailing warning icon whose tooltip
9
10
  shows this text (optional)
10
11
  --}}
@@ -13,9 +14,13 @@
13
14
  {{#if icon}}<span class="{{icon}}"></span>{{/if}}
14
15
  {{#if warnText}}
15
16
  <span class="grow">{{label}}</span>
17
+ {{#if badge}}{{> ui/badge label=badge variant="info" soft=true class="badge-sm shrink-0" icon="" elId=""}}{{/if}}
16
18
  {{#> ui/tooltip text=warnText class="shrink-0"}}
17
19
  <span class="icon-[tabler--alert-triangle] text-warning size-4 shrink-0"></span>
18
20
  {{/ui/tooltip}}
21
+ {{else if badge}}
22
+ <span class="grow">{{label}}</span>
23
+ {{> ui/badge label=badge variant="info" soft=true class="badge-sm shrink-0" icon="" elId=""}}
19
24
  {{else}}
20
25
  <span>{{label}}</span>
21
26
  {{/if}}</a>
@@ -0,0 +1,41 @@
1
+ {{!--
2
+ ui/radio - one radio option with label, optional help tooltip, hint and error.
3
+ Emits no outer margin (caller owns spacing, same as ui/checkbox). Options
4
+ group by sharing a name; render one partial per option.
5
+ Usage:
6
+ {{> ui/radio id="accessRead" name="access" value="read" label="Read-only" checked=true hint="Recommended."}}
7
+ Params:
8
+ id - control id (required)
9
+ name - input name shared by the group (required; radios group by name)
10
+ value - the value this option posts (required)
11
+ label - label text (required)
12
+ labelTitle - title attribute on the label, shown on hover (optional)
13
+ selected - the group's selected value; this option renders checked when
14
+ it equals value (the natural API for a radio group)
15
+ checked - true to render checked (alternative to selected, for a
16
+ static default)
17
+ tooltip - help text shown on hover behind a question icon (optional)
18
+ hint - muted helper text under the control (optional)
19
+ error - validation error message (optional)
20
+ disabled - true to render the input disabled (optional)
21
+ class - extra classes on the input (optional)
22
+ --}}
23
+ <div class="w-full">
24
+ <div class="flex items-center gap-2">
25
+ <input type="radio" class="radio radio-sm{{#if error}} is-invalid{{/if}}{{#if class}} {{class}}{{/if}}" id="{{id}}" name="{{name}}" value="{{value}}"
26
+ {{#if checked}}checked {{else}}{{#equals selected value}}checked {{/equals}}{{/if}}{{#if disabled}}disabled {{/if}}>
27
+ <label class="label-text p-0" for="{{id}}" {{#if labelTitle}}title="{{labelTitle}}" {{/if}}>{{label}}</label>
28
+ {{#if tooltip}}
29
+ {{!-- class="" blocks this partial's own class param (meant for the
30
+ input) from falling through onto the tooltip wrapper --}}
31
+ {{#> ui/tooltip text=tooltip class=""}}<span
32
+ class="icon-[tabler--help-circle] size-4 text-base-content/50"></span>{{/ui/tooltip}}
33
+ {{/if}}
34
+ </div>
35
+ {{#if error}}
36
+ <span class="helper-text text-error">{{error}}</span>
37
+ {{/if}}
38
+ {{#if hint}}
39
+ <span class="helper-text">{{hint}}</span>
40
+ {{/if}}
41
+ </div>
@@ -1,14 +1,19 @@
1
1
  {{!--
2
2
  ui/tab - one tab button inside a ui/tabs strip.
3
3
  Params:
4
- target - id of the tabpanel this button controls; the button id becomes
5
- "<target>-tab" (required)
6
- label - button text (required)
7
- active - true for the initially selected tab
8
- key - stable identity for this tab within its strip, emitted as
9
- data-tab-key (optional). For scripts that reselect a tab across
10
- pages: `target` carries the operation id so it cannot match
11
- anywhere else, and the label is display text that changes when
12
- the wording does.
4
+ target - id of the tabpanel this button controls; the button id
5
+ becomes "<target>-tab" (required)
6
+ label - button text (required)
7
+ active - true for the initially selected tab
8
+ badgeLabel - short state badge rendered after the label, e.g.
9
+ "not enabled" on a method that needs setup first; the tab
10
+ stays clickable so its panel can explain how to enable it
11
+ (optional)
12
+ badgeVariant - color of that badge (ui/badge variant, default neutral)
13
+ key - stable identity for this tab within its strip, emitted as
14
+ data-tab-key (optional). For scripts that reselect a tab
15
+ across pages: `target` carries the operation id so it
16
+ cannot match anywhere else, and the label is display text
17
+ that changes when the wording does.
13
18
  --}}
14
- <button type="button" class="tab active-tab:tab-active{{#if active}} active{{/if}}" id="{{target}}-tab" data-tab="#{{target}}" role="tab" aria-controls="{{target}}" aria-selected="{{#if active}}true{{else}}false{{/if}}"{{#if key}} data-tab-key="{{key}}"{{/if}}>{{label}}</button>
19
+ <button type="button" class="tab active-tab:tab-active{{#if active}} active{{/if}}" id="{{target}}-tab" data-tab="#{{target}}" role="tab" aria-controls="{{target}}" aria-selected="{{#if active}}true{{else}}false{{/if}}"{{#if key}} data-tab-key="{{key}}"{{/if}}>{{label}}{{#if badgeLabel}} {{> ui/badge label=badgeLabel variant=badgeVariant soft=true class="" icon="" elId=""}}{{/if}}</button>
@@ -5,9 +5,12 @@
5
5
  {{> ui/tab target="text" label="Plain text"}}
6
6
  {{/ui/tabs}}
7
7
  Params:
8
- label - aria-label describing the strip (required)
9
- elId - element id (optional; see ui/badge for why it is not called `id`)
10
- class - extra classes on the nav, e.g. "mb-4" (optional)
8
+ label - aria-label describing the strip (required)
9
+ elId - element id (optional; see ui/badge for why it is not called `id`)
10
+ class - extra classes on the nav, e.g. "mb-4" (optional)
11
+ variant - "segment" for the pill/segmented style (.tabs-segment in
12
+ app.tailwind.css), for a choice nested inside a page that
13
+ already has a bordered strip at the top; default bordered
11
14
  flex-wrap because FlyonUI lays the strip out as a nowrap flex row with no overflow
12
15
  handling, so one wider than its column pushes the whole page sideways instead of
13
16
  adapting: an API reference operation documents up to eight status codes, which is 464px
@@ -19,7 +22,7 @@
19
22
  The auth-method tabs in oauth_form.hbs intentionally do NOT use this partial -
20
23
  they run a custom script instead of the FlyonUI data-tabs plugin.
21
24
  --}}
22
- <nav class="tabs tabs-bordered flex-wrap{{#if class}} {{class}}{{/if}}" aria-label="{{label}}" role="tablist"{{#if elId}} id="{{elId}}"{{/if}} data-tabs>
25
+ <nav class="tabs {{#equals variant 'segment'}}tabs-segment{{else}}tabs-bordered{{/equals}} flex-wrap{{#if class}} {{class}}{{/if}}" aria-label="{{label}}" role="tablist"{{#if elId}} id="{{elId}}"{{/if}} data-tabs>
23
26
  {{!-- own hash params neutralized against fallthrough into the block --}}
24
- {{> @partial-block label="" id="" class=""}}
27
+ {{> @partial-block label="" elId="" class="" variant=""}}
25
28
  </nav>
@@ -31,7 +31,7 @@
31
31
  <td>{{source}}</td>
32
32
  <td>
33
33
  {{#if account}}
34
- <a href="/admin/accounts/{{account}}" class="link link-primary">{{account}}</a>
34
+ <a href="/admin/accounts/{{urlpart account}}" class="link link-primary">{{account}}</a>
35
35
  {{else}}
36
36
  <span class="text-base-content/60">-</span>
37
37
  {{/if}}
@@ -13,7 +13,7 @@
13
13
  {{#if account}}
14
14
  <div class="card-body">
15
15
  <div>
16
- Currently showing email templates for <strong><a href="/admin/accounts/{{account.account}}"
16
+ Currently showing email templates for <strong><a href="/admin/accounts/{{urlpart account.account}}"
17
17
  class="link link-animated">{{account.name}}</a></strong>. These templates cannot be
18
18
  used by other accounts.
19
19
  </div>
@@ -64,7 +64,7 @@
64
64
  {{#if account}}
65
65
  {{#> ui/list-empty noun="templates" query=query firstPage=firstPage createHref=newLink createLabel="Create your first template" clearHref="/admin/templates"}}
66
66
  <div class="mb-2">
67
- Currently showing email templates for <strong><a href="/admin/accounts/{{account.account}}"
67
+ Currently showing email templates for <strong><a href="/admin/accounts/{{urlpart account.account}}"
68
68
  class="link link-animated">{{#if account.name}}{{account.name}}{{else}}{{account.email}}{{/if}}</a></strong>.
69
69
  These templates cannot be used by other accounts.
70
70
  </div>
@@ -38,7 +38,7 @@
38
38
  {{#if account}}
39
39
 
40
40
  <dt>Account</dt>
41
- <dd><a href="/admin/accounts/{{account.account}}" class="link link-animated">{{account.name}}</a></dd>
41
+ <dd><a href="/admin/accounts/{{urlpart account.account}}" class="link link-animated">{{account.name}}</a></dd>
42
42
 
43
43
  {{/if}}
44
44
 
@@ -97,7 +97,7 @@ fieldName="template" fieldValue=template.id submitLabel="Delete template"}}
97
97
  <div class="modal-body space-y-4">
98
98
 
99
99
  {{#unless account}}
100
- {{> ui/form-field id="inputAccount" name="account" label="Account ID" required=true hint="The account ID to send email as."}}
100
+ {{> ui/account-picker id="inputAccount" name="account" label="Account" hint="The account to send the test email as."}}
101
101
  {{/unless}}
102
102
 
103
103
  {{> ui/form-field id="inputTo" name="inputTo" type="email" label="Recipient's email address" required=true hint="Where to send the test email to."}}
@@ -153,7 +153,7 @@ fieldName="template" fieldValue=template.id submitLabel="Delete template"}}
153
153
  editorJson.session.setValue('{\n "keyName": "value"\n}');
154
154
 
155
155
  if (inputAccount) {
156
- inputAccount.value = '';
156
+ uiAccountPickerClear(inputAccount);
157
157
  }
158
158
  inputTo.value = '';
159
159
 
@@ -194,9 +194,10 @@ fieldName="template" fieldValue=template.id submitLabel="Delete template"}}
194
194
  });
195
195
 
196
196
  if (inputAccount) {
197
+ // The picker fires both on the hidden input whenever the choice changes. No keyup:
198
+ // the field cannot be typed into.
197
199
  inputAccount.addEventListener('input', setStateUpdate);
198
200
  inputAccount.addEventListener('change', setStateUpdate);
199
- inputAccount.addEventListener('keyup', setStateUpdate);
200
201
  }
201
202
 
202
203
  inputTo.addEventListener('input', setStateUpdate);
@@ -13,12 +13,18 @@
13
13
 
14
14
  {{> ui/search-crumb parentHref="/admin/tokens" parentLabel="Access Tokens" query=query}}
15
15
 
16
+ {{!-- The scope deep-link filter (the MCP pages link here with ?scope=mcp): named the same way an
17
+ active search is, with the parent crumb as the way out of it --}}
18
+ {{#if scopeFilter}}
19
+ {{> ui/breadcrumb parentHref="/admin/tokens" parentLabel="Access Tokens" current=(concat 'Tokens with the "' scopeFilter '" scope') class="mb-6"}}
20
+ {{/if}}
21
+
16
22
  {{#if data.tokens}}
17
23
  <div class="card bg-base-100 shadow-md mb-6">
18
24
  {{#if account}}
19
25
  <div class="card-body">
20
26
  <div>
21
- Currently showing tokens for <strong><a href="/admin/accounts/{{account.account}}"
27
+ Currently showing tokens for <strong><a href="/admin/accounts/{{urlpart account.account}}"
22
28
  class="link link-animated">{{account.name}}</a></strong>. These tokens cannot be
23
29
  used by other accounts.
24
30
  </div>
@@ -29,6 +35,9 @@
29
35
  <thead>
30
36
  <tr>
31
37
  <th>Description</th>
38
+ {{#if showAccountColumn}}
39
+ <th>Bound to</th>
40
+ {{/if}}
32
41
  <th>Scopes</th>
33
42
  <th>Last used</th>
34
43
  <th class="w-12"><span class="sr-only">Actions</span></th>
@@ -51,6 +60,23 @@
51
60
  {{/if}}
52
61
  </td>
53
62
 
63
+ {{#if ../showAccountColumn}}
64
+ <td class="align-top">
65
+ {{#if account}}
66
+ {{#if accountKnown}}
67
+ <a href="/admin/accounts/{{urlpart account}}" class="link link-animated">{{account}}</a>
68
+ {{else}}
69
+ <div>{{account}}</div>
70
+ {{!-- Deleting an account leaves its tokens behind and they still
71
+ authenticate, so this is a state to act on, not a rendering accident --}}
72
+ {{> ui/badge label="Account deleted" variant="warning" soft=true icon="" class="mt-1"}}
73
+ {{/if}}
74
+ {{else}}
75
+ <span class="text-base-content/60">All accounts</span>
76
+ {{/if}}
77
+ </td>
78
+ {{/if}}
79
+
54
80
  <td class="align-top">
55
81
  {{#if scopes}}
56
82
  <div class="max-w-xs whitespace-normal">{{#each scopes}}{{#unless first}}, {{/unless}}{{name}}{{/each}}</div>
@@ -96,15 +122,15 @@
96
122
  program-association bug (the account note never rendered). Keep the block's first
97
123
  content token a static element. --}}
98
124
  {{#if account}}
99
- {{#> ui/list-empty noun="access tokens" query=query firstPage=firstPage createHref=newLink createLabel="Create your first access token" clearHref="/admin/tokens"}}
125
+ {{#> ui/list-empty noun="access tokens" query=query filterActive=scopeFilter firstPage=firstPage createHref=newLink createLabel="Create your first access token" clearHref="/admin/tokens"}}
100
126
  <div class="mb-2">
101
- Currently showing tokens for <strong><a href="/admin/accounts/{{account.account}}"
127
+ Currently showing tokens for <strong><a href="/admin/accounts/{{urlpart account.account}}"
102
128
  class="link link-animated">{{#if account.name}}{{account.name}}{{else}}{{account.email}}{{/if}}</a></strong>.
103
129
  These tokens cannot be used by other accounts.
104
130
  </div>
105
131
  {{/ui/list-empty}}
106
132
  {{else}}
107
- {{> ui/list-empty noun="access tokens" query=query firstPage=firstPage createHref=newLink createLabel="Create your first access token" clearHref="/admin/tokens"}}
133
+ {{> ui/list-empty noun="access tokens" query=query filterActive=scopeFilter firstPage=firstPage createHref=newLink createLabel="Create your first access token" clearHref="/admin/tokens"}}
108
134
  {{/if}}
109
135
  {{/if}}
110
136