@skillcdn/console 0.4.3 → 0.4.5

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 (268) hide show
  1. package/README.md +6 -6
  2. package/dist/api.d.ts +4 -4
  3. package/dist/api.d.ts.map +1 -1
  4. package/dist/api.js +4 -4
  5. package/dist/api.js.map +1 -1
  6. package/dist/cli/cli.d.ts.map +1 -1
  7. package/dist/cli/cli.js +255 -33
  8. package/dist/cli/cli.js.map +1 -1
  9. package/dist/cli/format.d.ts +20 -5
  10. package/dist/cli/format.d.ts.map +1 -1
  11. package/dist/cli/format.js +98 -26
  12. package/dist/cli/format.js.map +1 -1
  13. package/dist/cli/help.d.ts.map +1 -1
  14. package/dist/cli/help.js +39 -15
  15. package/dist/cli/help.js.map +1 -1
  16. package/dist/cli/plugin-check.d.ts +5 -1
  17. package/dist/cli/plugin-check.d.ts.map +1 -1
  18. package/dist/cli/plugin-check.js +23 -4
  19. package/dist/cli/plugin-check.js.map +1 -1
  20. package/dist/cli/plugin-cli.d.ts.map +1 -1
  21. package/dist/cli/plugin-cli.js +10 -1
  22. package/dist/cli/plugin-cli.js.map +1 -1
  23. package/dist/cli/plugin-init.d.ts +2 -0
  24. package/dist/cli/plugin-init.d.ts.map +1 -1
  25. package/dist/cli/plugin-init.js +6 -0
  26. package/dist/cli/plugin-init.js.map +1 -1
  27. package/dist/client.d.ts +32 -1
  28. package/dist/client.d.ts.map +1 -1
  29. package/dist/client.js +14 -2
  30. package/dist/client.js.map +1 -1
  31. package/dist/compat.js +1 -1
  32. package/dist/components/board.d.ts +8 -0
  33. package/dist/components/board.d.ts.map +1 -1
  34. package/dist/components/board.js +49 -18
  35. package/dist/components/board.js.map +1 -1
  36. package/dist/components/decision-form.d.ts +6 -3
  37. package/dist/components/decision-form.d.ts.map +1 -1
  38. package/dist/components/decision-form.js +24 -18
  39. package/dist/components/decision-form.js.map +1 -1
  40. package/dist/components/decision-list.d.ts +5 -1
  41. package/dist/components/decision-list.d.ts.map +1 -1
  42. package/dist/components/decision-list.js +25 -5
  43. package/dist/components/decision-list.js.map +1 -1
  44. package/dist/components/event-feed.d.ts.map +1 -1
  45. package/dist/components/event-feed.js +34 -8
  46. package/dist/components/event-feed.js.map +1 -1
  47. package/dist/components/goals.d.ts.map +1 -1
  48. package/dist/components/goals.js +2 -2
  49. package/dist/components/goals.js.map +1 -1
  50. package/dist/components/home.d.ts +35 -0
  51. package/dist/components/home.d.ts.map +1 -0
  52. package/dist/components/home.js +326 -0
  53. package/dist/components/home.js.map +1 -0
  54. package/dist/components/my-decisions.d.ts +20 -3
  55. package/dist/components/my-decisions.d.ts.map +1 -1
  56. package/dist/components/my-decisions.js +14 -1
  57. package/dist/components/my-decisions.js.map +1 -1
  58. package/dist/components/pack-connect.d.ts.map +1 -1
  59. package/dist/components/pack-connect.js +5 -4
  60. package/dist/components/pack-connect.js.map +1 -1
  61. package/dist/components/people.d.ts +45 -1
  62. package/dist/components/people.d.ts.map +1 -1
  63. package/dist/components/people.js +125 -4
  64. package/dist/components/people.js.map +1 -1
  65. package/dist/components/picker.d.ts +8 -0
  66. package/dist/components/picker.d.ts.map +1 -1
  67. package/dist/components/picker.js +2 -2
  68. package/dist/components/picker.js.map +1 -1
  69. package/dist/components/plugin-frame.d.ts +3 -13
  70. package/dist/components/plugin-frame.d.ts.map +1 -1
  71. package/dist/components/plugin-frame.js +75 -21
  72. package/dist/components/plugin-frame.js.map +1 -1
  73. package/dist/components/plugin-settings.d.ts +5 -1
  74. package/dist/components/plugin-settings.d.ts.map +1 -1
  75. package/dist/components/plugin-settings.js +283 -45
  76. package/dist/components/plugin-settings.js.map +1 -1
  77. package/dist/components/projects.d.ts +0 -8
  78. package/dist/components/projects.d.ts.map +1 -1
  79. package/dist/components/projects.js +4 -14
  80. package/dist/components/projects.js.map +1 -1
  81. package/dist/components/searches.d.ts +11 -0
  82. package/dist/components/searches.d.ts.map +1 -0
  83. package/dist/components/searches.js +30 -0
  84. package/dist/components/searches.js.map +1 -0
  85. package/dist/components/task-form.d.ts.map +1 -1
  86. package/dist/components/task-form.js +6 -5
  87. package/dist/components/task-form.js.map +1 -1
  88. package/dist/components/task-view.d.ts.map +1 -1
  89. package/dist/components/task-view.js +2 -1
  90. package/dist/components/task-view.js.map +1 -1
  91. package/dist/components/ui.d.ts +16 -0
  92. package/dist/components/ui.d.ts.map +1 -1
  93. package/dist/components/ui.js +15 -2
  94. package/dist/components/ui.js.map +1 -1
  95. package/dist/connect-page.d.ts.map +1 -1
  96. package/dist/connect-page.js +5 -6
  97. package/dist/connect-page.js.map +1 -1
  98. package/dist/console.css +1123 -258
  99. package/dist/console.d.ts +12 -4
  100. package/dist/console.d.ts.map +1 -1
  101. package/dist/console.js +123 -27
  102. package/dist/console.js.map +1 -1
  103. package/dist/data.d.ts +18 -3
  104. package/dist/data.d.ts.map +1 -1
  105. package/dist/data.js +41 -1
  106. package/dist/data.js.map +1 -1
  107. package/dist/docs-page.d.ts.map +1 -1
  108. package/dist/docs-page.js +6 -5
  109. package/dist/docs-page.js.map +1 -1
  110. package/dist/home-tiles.d.ts +92 -0
  111. package/dist/home-tiles.d.ts.map +1 -0
  112. package/dist/home-tiles.js +294 -0
  113. package/dist/home-tiles.js.map +1 -0
  114. package/dist/i18n/en.d.ts +264 -1
  115. package/dist/i18n/en.d.ts.map +1 -1
  116. package/dist/i18n/en.js +260 -1
  117. package/dist/i18n/en.js.map +1 -1
  118. package/dist/i18n/index.d.ts +4 -2
  119. package/dist/i18n/index.d.ts.map +1 -1
  120. package/dist/i18n/index.js +10 -11
  121. package/dist/i18n/index.js.map +1 -1
  122. package/dist/i18n/ko.d.ts.map +1 -1
  123. package/dist/i18n/ko.js +255 -4
  124. package/dist/i18n/ko.js.map +1 -1
  125. package/dist/index.d.ts +7 -5
  126. package/dist/index.d.ts.map +1 -1
  127. package/dist/index.js +7 -5
  128. package/dist/index.js.map +1 -1
  129. package/dist/limits.d.ts +12 -0
  130. package/dist/limits.d.ts.map +1 -1
  131. package/dist/limits.js +12 -0
  132. package/dist/limits.js.map +1 -1
  133. package/dist/plugin/args.d.ts +6 -1
  134. package/dist/plugin/args.d.ts.map +1 -1
  135. package/dist/plugin/args.js +16 -11
  136. package/dist/plugin/args.js.map +1 -1
  137. package/dist/plugin/bridge.d.ts +63 -3
  138. package/dist/plugin/bridge.d.ts.map +1 -1
  139. package/dist/plugin/bridge.js +54 -0
  140. package/dist/plugin/bridge.js.map +1 -1
  141. package/dist/plugin/capabilities.d.ts +7 -1
  142. package/dist/plugin/capabilities.d.ts.map +1 -1
  143. package/dist/plugin/capabilities.js +24 -1
  144. package/dist/plugin/capabilities.js.map +1 -1
  145. package/dist/plugin/context.d.ts +174 -12
  146. package/dist/plugin/context.d.ts.map +1 -1
  147. package/dist/plugin/define.d.ts +14 -1
  148. package/dist/plugin/define.d.ts.map +1 -1
  149. package/dist/plugin/define.js +18 -2
  150. package/dist/plugin/define.js.map +1 -1
  151. package/dist/plugin/limits.d.ts +9 -2
  152. package/dist/plugin/limits.d.ts.map +1 -1
  153. package/dist/plugin/limits.js +9 -2
  154. package/dist/plugin/limits.js.map +1 -1
  155. package/dist/plugin/manifest.d.ts +98 -6
  156. package/dist/plugin/manifest.d.ts.map +1 -1
  157. package/dist/plugin/manifest.js +171 -10
  158. package/dist/plugin/manifest.js.map +1 -1
  159. package/dist/plugin/rest-schemas.d.ts +120 -0
  160. package/dist/plugin/rest-schemas.d.ts.map +1 -1
  161. package/dist/plugin/rest-schemas.js +78 -5
  162. package/dist/plugin/rest-schemas.js.map +1 -1
  163. package/dist/plugin/sandbox.d.ts +4 -3
  164. package/dist/plugin/sandbox.d.ts.map +1 -1
  165. package/dist/plugin/sandbox.js +33 -6
  166. package/dist/plugin/sandbox.js.map +1 -1
  167. package/dist/plugin/semver.d.ts +26 -0
  168. package/dist/plugin/semver.d.ts.map +1 -0
  169. package/dist/plugin/semver.js +76 -0
  170. package/dist/plugin/semver.js.map +1 -0
  171. package/dist/plugin/testing.d.ts +15 -1
  172. package/dist/plugin/testing.d.ts.map +1 -1
  173. package/dist/plugin/testing.js +42 -5
  174. package/dist/plugin/testing.js.map +1 -1
  175. package/dist/plugin/web.d.ts +16 -1
  176. package/dist/plugin/web.d.ts.map +1 -1
  177. package/dist/plugin/web.js +44 -1
  178. package/dist/plugin/web.js.map +1 -1
  179. package/dist/plugin.d.ts +3 -2
  180. package/dist/plugin.d.ts.map +1 -1
  181. package/dist/plugin.js +3 -2
  182. package/dist/plugin.js.map +1 -1
  183. package/dist/router.d.ts +19 -0
  184. package/dist/router.d.ts.map +1 -1
  185. package/dist/router.js +18 -0
  186. package/dist/router.js.map +1 -1
  187. package/dist/routes.d.ts +11 -2
  188. package/dist/routes.d.ts.map +1 -1
  189. package/dist/routes.js +14 -1
  190. package/dist/routes.js.map +1 -1
  191. package/dist/rules.d.ts +2 -2
  192. package/dist/rules.js +3 -3
  193. package/dist/schemas.d.ts +864 -2
  194. package/dist/schemas.d.ts.map +1 -1
  195. package/dist/schemas.js +156 -9
  196. package/dist/schemas.js.map +1 -1
  197. package/dist/use-action.d.ts +8 -2
  198. package/dist/use-action.d.ts.map +1 -1
  199. package/dist/use-action.js +13 -6
  200. package/dist/use-action.js.map +1 -1
  201. package/dist/vocabulary.d.ts +3 -1
  202. package/dist/vocabulary.d.ts.map +1 -1
  203. package/dist/vocabulary.js +9 -0
  204. package/dist/vocabulary.js.map +1 -1
  205. package/docs/specs/cli.md +10 -6
  206. package/docs/specs/plugins.md +83 -62
  207. package/docs/specs/rest.md +34 -16
  208. package/package.json +1 -1
  209. package/skills/building-a-plugin/SKILL.md +15 -12
  210. package/skills/planning-the-board/references/setting-up.md +2 -1
  211. package/skills/working-the-board/SKILL.md +3 -3
  212. package/src/api.ts +23 -0
  213. package/src/cli/cli.ts +323 -30
  214. package/src/cli/format.ts +122 -26
  215. package/src/cli/help.ts +43 -14
  216. package/src/cli/plugin-check.ts +41 -2
  217. package/src/cli/plugin-cli.ts +10 -1
  218. package/src/cli/plugin-init.ts +8 -0
  219. package/src/client.ts +78 -0
  220. package/src/compat.ts +1 -1
  221. package/src/components/board.tsx +86 -45
  222. package/src/components/decision-form.tsx +73 -36
  223. package/src/components/decision-list.tsx +45 -13
  224. package/src/components/event-feed.tsx +40 -7
  225. package/src/components/goals.tsx +4 -1
  226. package/src/components/home.tsx +615 -0
  227. package/src/components/my-decisions.tsx +50 -5
  228. package/src/components/pack-connect.tsx +5 -4
  229. package/src/components/people.tsx +500 -61
  230. package/src/components/picker.tsx +11 -2
  231. package/src/components/plugin-frame.tsx +85 -63
  232. package/src/components/plugin-settings.tsx +735 -185
  233. package/src/components/projects.tsx +14 -69
  234. package/src/components/searches.ts +47 -0
  235. package/src/components/task-form.tsx +23 -28
  236. package/src/components/task-view.tsx +7 -0
  237. package/src/components/ui.tsx +42 -2
  238. package/src/connect-page.tsx +5 -6
  239. package/src/console.tsx +303 -64
  240. package/src/data.ts +62 -3
  241. package/src/docs-page.tsx +6 -5
  242. package/src/home-tiles.ts +438 -0
  243. package/src/i18n/en.ts +274 -0
  244. package/src/i18n/index.ts +17 -14
  245. package/src/i18n/ko.ts +267 -4
  246. package/src/index.ts +18 -5
  247. package/src/limits.ts +12 -0
  248. package/src/plugin/args.ts +16 -11
  249. package/src/plugin/bridge.ts +122 -1
  250. package/src/plugin/capabilities.ts +28 -1
  251. package/src/plugin/context.ts +186 -9
  252. package/src/plugin/define.ts +38 -1
  253. package/src/plugin/limits.ts +9 -2
  254. package/src/plugin/manifest.ts +228 -13
  255. package/src/plugin/rest-schemas.ts +89 -6
  256. package/src/plugin/sandbox.ts +36 -8
  257. package/src/plugin/semver.ts +89 -0
  258. package/src/plugin/testing.ts +63 -6
  259. package/src/plugin/web.ts +66 -0
  260. package/src/plugin.ts +19 -0
  261. package/src/router.ts +25 -0
  262. package/src/routes.ts +17 -2
  263. package/src/rules.ts +3 -3
  264. package/src/schemas.ts +197 -10
  265. package/src/styles/console.css +1123 -258
  266. package/src/use-action.ts +16 -7
  267. package/src/vocabulary.ts +10 -0
  268. package/template/plugin/console-plugin.json +3 -1
@@ -2,9 +2,12 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
2
2
  import { useEffect, useId, useMemo, useState } from "react";
3
3
  import { useWords } from "../i18n/index.js";
4
4
  import { PLUGIN_CAPABILITIES } from "../plugin/capabilities.js";
5
+ import { settingsHref } from "../router.js";
5
6
  import { useAction } from "../use-action.js";
6
7
  import { EventFeed } from "./event-feed.js";
7
- import { Badge, Button, Callout, EmptyState, formatInstant, LinkButton, personName, Spinner, } from "./ui.js";
8
+ import { Picker } from "./picker.js";
9
+ import { listSearch, peopleSearch, projectsSearch } from "./searches.js";
10
+ import { Badge, Button, Callout, Chip, cx, EmptyState, formatInstant, LinkButton, personName, Spinner, } from "./ui.js";
8
11
  // The plugins' settings (docs/specs/plugins.md, "The settings pages"): what is installed and how
9
12
  // each stands; and one plugin, read at a glance: its state in the head with the way to disable
10
13
  // it, what it is on and holds a row each, the form that enables it (the capabilities to consent
@@ -56,7 +59,7 @@ export function PluginSettingsList(props) {
56
59
  if (props.plugins.length === 0) {
57
60
  return _jsx(EmptyState, { title: settings.empty.title, body: settings.empty.body });
58
61
  }
59
- return (_jsx("ul", { className: "sc-task-rows", "aria-label": settings.title, children: props.plugins.map((plugin) => (_jsxs("li", { className: "sc-task-row", children: [_jsxs("a", { className: "sc-task-row-title", href: props.href(plugin), children: [pluginWord(plugin.name, props.language), " ", _jsxs("span", { className: "sc-muted", children: [plugin.key, " ", plugin.version] })] }), _jsx("span", { className: "sc-task-row-meta", children: _jsx(Badge, { tone: STATE_TONES[plugin.state], children: words.vocabulary.pluginState[plugin.state] ?? plugin.state }) })] }, plugin.key))) }));
62
+ return (_jsx("ul", { className: "sc-task-rows", "aria-label": settings.title, children: props.plugins.map((plugin) => (_jsxs("li", { className: "sc-task-row", children: [_jsxs("a", { className: "sc-task-row-title", href: props.href(plugin), children: [pluginWord(plugin.name, props.language), " ", _jsxs("span", { className: "sc-muted", children: [plugin.key, " ", plugin.version, plugin.console !== null && plugin.console !== undefined && (_jsxs(_Fragment, { children: [" \u00B7 ", settings.consoleRange(plugin.console)] }))] })] }), _jsx("span", { className: "sc-task-row-meta", children: _jsx(Badge, { tone: STATE_TONES[plugin.state], children: words.vocabulary.pluginState[plugin.state] ?? plugin.state }) })] }, plugin.key))) }));
60
63
  }
61
64
  /** A set with a value put in or taken out. */
62
65
  function toggled(set, value, on) {
@@ -71,7 +74,7 @@ function toggled(set, value, on) {
71
74
  }
72
75
  /** A row of a list to tick: the box, a name, a word under it. */
73
76
  function TickRow(props) {
74
- return (_jsx("li", { children: _jsxs("label", { className: "sc-plugin-tick", children: [_jsx("input", { type: "checkbox", checked: props.checked, onChange: (event) => props.onChange(event.target.checked) }), _jsxs("span", { className: "sc-plugin-tick-words", children: [_jsx("span", { className: "sc-plugin-tick-name", children: props.name }), props.under !== undefined && props.under !== "" && (_jsx("span", { className: "sc-plugin-tick-under", children: props.under }))] })] }) }));
77
+ return (_jsx("li", { children: _jsxs("label", { className: cx("sc-plugin-tick", props.locked === true && "sc-plugin-tick-locked"), children: [_jsx("input", { type: "checkbox", checked: props.checked, disabled: props.locked === true, onChange: (event) => props.onChange?.(event.target.checked) }), _jsxs("span", { className: "sc-plugin-tick-words", children: [_jsxs("span", { className: "sc-plugin-tick-name", children: [props.name, props.tag !== undefined && _jsx(Badge, { tone: "warning", children: props.tag })] }), props.under !== undefined && props.under !== "" && (_jsx("span", { className: "sc-plugin-tick-under", children: props.under }))] })] }) }));
75
78
  }
76
79
  /** What the plugin is on and holds, a row each; nothing where there is nothing to say yet. */
77
80
  function Overview(props) {
@@ -80,6 +83,9 @@ function Overview(props) {
80
83
  const { detail, language } = props;
81
84
  const enabled = detail.state === "enabled";
82
85
  const rows = [];
86
+ if (detail.console !== null && detail.console !== undefined) {
87
+ rows.push({ key: "console", name: settings.console, value: _jsx("code", { children: detail.console }) });
88
+ }
83
89
  if (detail.board !== null) {
84
90
  rows.push({
85
91
  key: "board",
@@ -90,6 +96,13 @@ function Overview(props) {
90
96
  else if (enabled && detail.boardNeeds !== "none") {
91
97
  rows.push({ key: "board", name: settings.board, value: settings.nothing });
92
98
  }
99
+ if (detail.keeps !== undefined && detail.keeps.length > 0) {
100
+ rows.push({
101
+ key: "keeps",
102
+ name: settings.keeps,
103
+ value: detail.keeps.map((kept) => settings.keepsFor(kept.collection, kept.days)).join(", "),
104
+ });
105
+ }
93
106
  if (enabled && detail.projects !== null) {
94
107
  const names = detail.projects;
95
108
  rows.push({
@@ -106,13 +119,20 @@ function Overview(props) {
106
119
  }
107
120
  if (enabled && detail.consent !== null) {
108
121
  const consent = detail.consent;
122
+ const optional = detail.optionalCapabilities ?? [];
123
+ const required = consent.filter((capability) => !optional.includes(capability));
109
124
  rows.push({
110
125
  key: "capabilities",
111
126
  name: settings.capabilities,
112
- value: consent.length === 0 ? (settings.nothing) : (_jsx("ul", { className: "sc-plugin-held", children: consent.map((capability) => {
113
- const text = capabilityText(words, capability);
114
- return (_jsxs("li", { children: [_jsx("span", { className: "sc-plugin-tick-name", children: text.name }), text.opens !== "" && _jsxs("span", { className: "sc-plugin-tick-under", children: [" ", text.opens] })] }, capability));
115
- }) })),
127
+ value: consent.length === 0 && optional.length === 0 ? (settings.nothing) : (_jsxs(_Fragment, { children: [required.length > 0 && (_jsx("ul", { className: "sc-plugin-held", children: required.map((capability) => {
128
+ const text = capabilityText(words, capability);
129
+ return (_jsxs("li", { children: [_jsx("span", { className: "sc-plugin-tick-name", children: text.name }), text.opens !== "" && (_jsxs("span", { className: "sc-plugin-tick-under", children: [" ", text.opens] }))] }, capability));
130
+ }) })), optional.length > 0 && (_jsxs("div", { className: "sc-plugin-optional", children: [_jsx("span", { className: "sc-field-label", children: settings.optional }), _jsx("ul", { className: "sc-plugin-held", children: optional.map((capability) => {
131
+ const text = capabilityText(words, capability);
132
+ return (_jsx("li", { children: _jsxs("label", { className: "sc-check", children: [_jsx("input", { type: "checkbox", checked: consent.includes(capability), disabled: props.busy, onChange: (event) => props.onConsent(event.target.checked
133
+ ? [...consent, capability]
134
+ : consent.filter((held) => held !== capability)) }), _jsxs("span", { children: [_jsx("span", { className: "sc-plugin-tick-name", children: text.name }), text.opens !== "" && (_jsxs("span", { className: "sc-plugin-tick-under", children: [" ", text.opens] }))] })] }) }, capability));
135
+ }) })] }))] })),
116
136
  });
117
137
  }
118
138
  if (detail.operations.length > 0) {
@@ -134,22 +154,120 @@ function Overview(props) {
134
154
  }
135
155
  return (_jsx("section", { className: "sc-panel", "aria-label": settings.about, children: _jsx("dl", { className: "sc-settings-list", children: rows.map((row) => (_jsxs("div", { className: "sc-settings-item", children: [_jsx("dt", { children: row.name }), _jsx("dd", { children: row.value })] }, row.key))) }) }));
136
156
  }
157
+ /** How many choices a list of an enum shows as pills before it becomes a column of boxes. */
158
+ const PILLS_AT_MOST = 8;
159
+ /** The control of one item of a list, as a text field: a number, a day, a time or words. */
160
+ function itemInputType(of) {
161
+ switch (of) {
162
+ case "number":
163
+ return "number";
164
+ case "day":
165
+ return "date";
166
+ case "time":
167
+ return "time";
168
+ default:
169
+ return "text";
170
+ }
171
+ }
172
+ /** The items of a list setting as the form holds them. */
173
+ function itemsOf(value) {
174
+ return Array.isArray(value)
175
+ ? value.filter((item) => typeof item === "string" || typeof item === "number")
176
+ : [];
177
+ }
178
+ /**
179
+ * A list of an enum: a pill per choice while they are few, lit while chosen, else a column of
180
+ * boxes; either way the value is the chosen values, in the options' order.
181
+ */
182
+ function EnumListControl(props) {
183
+ const options = props.setting.options ?? [];
184
+ const chosen = new Set(itemsOf(props.value).map(String));
185
+ const toggle = (option, on) => {
186
+ const next = options
187
+ .map((candidate) => candidate.value)
188
+ .filter((candidate) => (candidate === option ? on : chosen.has(candidate)));
189
+ props.onChange(next.length === 0 ? null : next);
190
+ };
191
+ const pills = options.length <= PILLS_AT_MOST;
192
+ const name = pluginWord(props.setting.name, props.language);
193
+ const choices = options.map((option) => (_jsxs("label", { className: pills ? "sc-toggle-chip" : "sc-check", children: [_jsx("input", { type: "checkbox", checked: chosen.has(option.value), onChange: (event) => toggle(option.value, event.target.checked) }), pluginWord(option.name, props.language)] }, option.value)));
194
+ return pills ? (_jsx("fieldset", { className: "sc-toggle-chips", "aria-label": name, children: choices })) : (_jsx("ul", { className: "sc-check-list", "aria-label": name, children: choices.map((choice) => (_jsx("li", { children: choice }, choice.key))) }));
195
+ }
196
+ /**
197
+ * A list of people or of projects: each chosen one a chip with the way to take it out, and one
198
+ * choice to add another among those not chosen yet; the value is their ids.
199
+ */
200
+ function RefListControl(props) {
201
+ const words = useWords();
202
+ const chosen = itemsOf(props.value).map(String);
203
+ const candidates = props.setting.of === "person"
204
+ ? props.people
205
+ .filter((person) => person.status === "active" || chosen.includes(person.id))
206
+ .map((person) => ({ id: person.id, label: personChoice(person) }))
207
+ : props.projects.map((project) => ({
208
+ id: project.id,
209
+ label: `${project.name} (${project.key})`,
210
+ }));
211
+ const labelOf = (id) => candidates.find((candidate) => candidate.id === id)?.label ?? id;
212
+ const set = (next) => props.onChange(next.length === 0 ? null : next);
213
+ const full = props.setting.max !== null && chosen.length >= props.setting.max;
214
+ return (_jsxs("div", { className: "sc-chips", children: [chosen.map((id) => (_jsx(Chip, { onRemove: () => set(chosen.filter((kept) => kept !== id)), removeLabel: `${words.common.remove}: ${labelOf(id)}`, children: labelOf(id) }, id))), !full && (_jsx(Picker, { id: props.id, className: "sc-picker-add", value: undefined, search: listSearch(candidates.filter((candidate) => !chosen.includes(candidate.id)), (candidate, typed) => candidate.label.toLowerCase().includes(typed)), keyOf: (candidate) => candidate.id, render: (candidate) => candidate.label, label: pluginWord(props.setting.name, props.language), placeholder: words.plugins.settings.addOne, onChange: (candidate) => {
215
+ if (candidate !== undefined) {
216
+ set([...chosen, candidate.id]);
217
+ }
218
+ } }))] }));
219
+ }
220
+ /**
221
+ * A list of texts, numbers, days or times: each item a chip with the way to take it out, and a
222
+ * field that adds one on Enter or with the button; `min` and `max` bound how many.
223
+ */
224
+ function ItemListControl(props) {
225
+ const words = useWords();
226
+ const [draft, setDraft] = useState("");
227
+ const items = itemsOf(props.value);
228
+ const set = (next) => props.onChange(next.length === 0 ? null : next);
229
+ const full = props.setting.max !== null && items.length >= props.setting.max;
230
+ const add = () => {
231
+ const word = draft.trim();
232
+ if (word.length === 0 || full) {
233
+ return;
234
+ }
235
+ const item = props.setting.of === "number" ? Number(word) : word;
236
+ if (typeof item === "number" && !Number.isFinite(item)) {
237
+ return;
238
+ }
239
+ set([...items, item]);
240
+ setDraft("");
241
+ };
242
+ return (_jsxs("div", { className: "sc-chips", children: [items.map((item, index) => (_jsx(Chip
243
+ // biome-ignore lint/suspicious/noArrayIndexKey: an item may be typed twice
244
+ , { onRemove: () => set(items.filter((_, at) => at !== index)), removeLabel: `${words.common.remove}: ${String(item)}`, children: String(item) }, `${index}-${String(item)}`))), !full && (_jsxs("div", { className: "sc-chip-input", children: [_jsx("input", { id: props.id, className: "sc-input", type: itemInputType(props.setting.of), value: draft, placeholder: words.plugins.settings.itemPlaceholder, onChange: (event) => setDraft(event.target.value), onKeyDown: (event) => {
245
+ if (event.key === "Enter") {
246
+ event.preventDefault();
247
+ add();
248
+ }
249
+ } }), _jsx(Button, { type: "button", size: "sm", disabled: draft.trim().length === 0, onClick: add, children: words.plugins.settings.addItem })] }))] }));
250
+ }
137
251
  /**
138
252
  * A setting's control, by its type: a person or a project is chosen among the workspace's, by
139
- * name, and held as its id; a secret has a row of its own below.
253
+ * name, and held as its id; a time of day is read in the workspace's time zone; a list has a
254
+ * control per kind of item; a secret has a row of its own below.
140
255
  */
141
256
  function SettingControl(props) {
257
+ const words = useWords();
142
258
  const { setting, value, onChange, id } = props;
143
259
  const chosen = typeof value === "string" ? value : "";
144
- const choose = (event) => onChange(event.target.value === "" ? null : event.target.value);
145
260
  switch (setting.type) {
146
261
  case "person": {
147
262
  // The people in; the one chosen stays listed when they have left, so that the value shows.
148
263
  const people = props.people.filter((person) => person.status === "active" || person.id === chosen);
149
- return (_jsxs("select", { id: id, className: "sc-input", value: chosen, onChange: choose, children: [_jsx("option", { value: "", children: "\u2014" }), people.map((person) => (_jsx("option", { value: person.id, children: personChoice(person) }, person.id))), chosen !== "" && !people.some((person) => person.id === chosen) && (_jsx("option", { value: chosen, children: chosen }))] }));
264
+ const current = people.find((person) => person.id === chosen);
265
+ return (_jsx(Picker, { id: id, value: current, held: chosen !== "" && current === undefined ? chosen : undefined, search: peopleSearch(people), keyOf: (person) => person.id, render: personChoice, label: pluginWord(setting.name, props.language), placeholder: words.plugins.settings.choose, onChange: (person) => onChange(person?.id ?? null) }));
266
+ }
267
+ case "project": {
268
+ const current = props.projects.find((project) => project.id === chosen);
269
+ return (_jsx(Picker, { id: id, value: current, held: chosen !== "" && current === undefined ? chosen : undefined, search: projectsSearch(props.projects), keyOf: (project) => project.id, render: (project) => `${project.name} (${project.key})`, label: pluginWord(setting.name, props.language), placeholder: words.plugins.settings.choose, onChange: (project) => onChange(project?.id ?? null) }));
150
270
  }
151
- case "project":
152
- return (_jsxs("select", { id: id, className: "sc-input", value: chosen, onChange: choose, children: [_jsx("option", { value: "", children: "\u2014" }), props.projects.map((project) => (_jsxs("option", { value: project.id, children: [project.name, " (", project.key, ")"] }, project.id))), chosen !== "" && !props.projects.some((project) => project.id === chosen) && (_jsx("option", { value: chosen, children: chosen }))] }));
153
271
  case "boolean":
154
272
  return (_jsx("input", { id: id, type: "checkbox", checked: value === true, onChange: (event) => onChange(event.target.checked) }));
155
273
  case "number":
@@ -158,14 +276,16 @@ function SettingControl(props) {
158
276
  return (_jsxs("select", { id: id, className: "sc-input", value: typeof value === "string" ? value : "", onChange: (event) => onChange(event.target.value === "" ? null : event.target.value), children: [_jsx("option", { value: "", children: "\u2014" }), (setting.options ?? []).map((option) => (_jsx("option", { value: option.value, children: pluginWord(option.name, props.language) }, option.value)))] }));
159
277
  case "markdown":
160
278
  return (_jsx("textarea", { id: id, className: "sc-input", rows: 4, value: typeof value === "string" ? value : "", onChange: (event) => onChange(event.target.value === "" ? null : event.target.value) }));
279
+ case "time":
280
+ return (_jsxs(_Fragment, { children: [_jsx("input", { id: id, className: "sc-input", type: "time", value: typeof value === "string" ? value : "", onChange: (event) => onChange(event.target.value === "" ? null : event.target.value) }), _jsx("p", { className: "sc-settings-hint", children: words.plugins.settings.timeZoneHint })] }));
161
281
  case "list":
162
- return (_jsx("input", { id: id, className: "sc-input", value: Array.isArray(value) ? value.join(", ") : "", onChange: (event) => onChange(event.target.value.trim() === ""
163
- ? null
164
- : event.target.value
165
- .split(",")
166
- .map((item) => item.trim())
167
- .filter((item) => item.length > 0)
168
- .map((item) => (setting.of === "number" ? Number(item) : item))) }));
282
+ if (setting.of === "enum") {
283
+ return (_jsx(EnumListControl, { setting: setting, value: value, onChange: onChange, language: props.language }));
284
+ }
285
+ if (setting.of === "person" || setting.of === "project") {
286
+ return (_jsx(RefListControl, { language: props.language, setting: setting, value: value, onChange: onChange, id: id, people: props.people, projects: props.projects }));
287
+ }
288
+ return _jsx(ItemListControl, { setting: setting, value: value, onChange: onChange, id: id });
169
289
  default:
170
290
  return (_jsx("input", { id: id, className: "sc-input", type: setting.type === "day" ? "date" : "text", value: typeof value === "string" ? value : "", maxLength: setting.max ?? undefined, onChange: (event) => onChange(event.target.value === "" ? null : event.target.value) }));
171
291
  }
@@ -183,7 +303,32 @@ function SettingsForm(props) {
183
303
  event.preventDefault();
184
304
  props.onSave(values);
185
305
  };
186
- return (_jsxs("form", { className: "sc-form sc-settings-form", onSubmit: submit, "aria-label": words.plugins.settings.settingsForm, children: [settings.map((setting) => (_jsxs("div", { className: "sc-settings-row", children: [_jsxs("div", { className: "sc-settings-words", children: [_jsxs("label", { className: "sc-settings-label", htmlFor: `${prefix}-${setting.key}`, children: [pluginWord(setting.name, props.language), setting.required && " *"] }), setting.description !== null && (_jsx("p", { className: "sc-settings-hint", children: pluginWord(setting.description, props.language) }))] }), _jsx("div", { className: "sc-settings-control", children: _jsx(SettingControl, { setting: setting, value: values[setting.key], id: `${prefix}-${setting.key}`, language: props.language, people: props.people, projects: props.projects, onChange: (value) => setValues((current) => ({ ...current, [setting.key]: value })) }) })] }, setting.key))), _jsx("div", { className: "sc-form-actions", children: _jsx(Button, { type: "submit", variant: "primary", disabled: props.busy, children: words.common.save }) })] }));
306
+ /** A row per setting: the name and the hint on the left, the control on the right. */
307
+ const rows = (shown) => shown.map((setting) => (_jsxs("div", { className: "sc-settings-row", children: [_jsxs("div", { className: "sc-settings-words", children: [_jsxs("label", { className: "sc-settings-label", htmlFor: `${prefix}-${setting.key}`, children: [pluginWord(setting.name, props.language), setting.required && " *"] }), setting.description !== null && (_jsx("p", { className: "sc-settings-hint", children: pluginWord(setting.description, props.language) }))] }), _jsx("div", { className: "sc-settings-control", children: _jsx(SettingControl, { setting: setting, value: values[setting.key], id: `${prefix}-${setting.key}`, language: props.language, people: props.people, projects: props.projects, onChange: (value) => setValues((current) => ({ ...current, [setting.key]: value })) }) })] }, setting.key)));
308
+ return (_jsxs("form", { className: "sc-form sc-settings-form", onSubmit: submit, "aria-label": words.plugins.settings.settingsForm, children: [rows(settings.filter((setting) => setting.group === null || setting.group === undefined)), (props.detail.settingGroups ?? []).map((group) => {
309
+ const grouped = settings.filter((setting) => setting.group === group.key);
310
+ if (grouped.length === 0) {
311
+ return null;
312
+ }
313
+ const description = pluginWord(group.description, props.language);
314
+ return (_jsxs("section", { className: "sc-settings-group", "aria-label": pluginWord(group.name, props.language), children: [_jsx("h3", { className: "sc-settings-group-title", children: pluginWord(group.name, props.language) }), description !== "" && _jsx("p", { className: "sc-settings-hint", children: description }), rows(grouped)] }, group.key));
315
+ }), _jsx("div", { className: "sc-form-actions", children: _jsx(Button, { type: "submit", variant: "primary", disabled: props.busy, children: words.common.save }) })] }));
316
+ }
317
+ /**
318
+ * How a secret stands, in a line (ADR-0070): set by an administrator, or sealed from an answer
319
+ * of a host, when; and when it expires, or that it has.
320
+ */
321
+ function secretStanding(settings, setting, language) {
322
+ const when = formatInstant(setting.setAt ?? "", language);
323
+ const source = setting.source ?? "administrator";
324
+ const set = source === "administrator" ? settings.secretSet(when) : settings.secretSealedFrom(source, when);
325
+ if (setting.expiresAt === null || setting.expiresAt === undefined) {
326
+ return set;
327
+ }
328
+ const expires = formatInstant(setting.expiresAt, language);
329
+ return `${set} · ${Date.parse(setting.expiresAt) <= Date.now()
330
+ ? settings.secretExpired(expires)
331
+ : settings.secretExpires(expires)}`;
187
332
  }
188
333
  /** One secret: whether and when it is set, a field to set it anew with its buttons on the line. */
189
334
  function SecretRow(props) {
@@ -193,21 +338,30 @@ function SecretRow(props) {
193
338
  const id = useId();
194
339
  const { setting } = props;
195
340
  return (_jsxs("div", { className: "sc-settings-row", children: [_jsxs("div", { className: "sc-settings-words", children: [_jsxs("label", { className: "sc-settings-label", htmlFor: id, children: [pluginWord(setting.name, props.language), setting.required && " *"] }), _jsx("p", { className: "sc-settings-hint", children: setting.set && setting.setAt !== null
196
- ? settings.secretSet(formatInstant(setting.setAt, props.language))
197
- : settings.secretUnset }), setting.description !== null && (_jsx("p", { className: "sc-settings-hint", children: pluginWord(setting.description, props.language) }))] }), _jsx("div", { className: "sc-settings-control", children: _jsxs("div", { className: "sc-plugin-line", children: [_jsx("input", { id: id, className: "sc-input sc-plugin-line-input", type: "password", autoComplete: "off", placeholder: settings.secretNew, value: value, onChange: (event) => setValue(event.target.value) }), _jsx(Button, { disabled: props.busy || value.length === 0, onClick: () => {
341
+ ? secretStanding(settings, setting, props.language)
342
+ : settings.secretUnset }), setting.hosts !== null && setting.hosts !== undefined && setting.hosts.length > 0 && (_jsx("p", { className: "sc-settings-hint", children: settings.secretHosts(setting.hosts.join(", ")) })), setting.description !== null && (_jsx("p", { className: "sc-settings-hint", children: pluginWord(setting.description, props.language) }))] }), _jsx("div", { className: "sc-settings-control", children: _jsxs("div", { className: "sc-plugin-line", children: [_jsx("input", { id: id, className: "sc-input sc-plugin-line-input", type: "password", autoComplete: "off", placeholder: settings.secretNew, value: value, onChange: (event) => setValue(event.target.value) }), _jsx(Button, { disabled: props.busy || value.length === 0, onClick: () => {
198
343
  props.onSet(value);
199
344
  setValue("");
200
345
  }, children: words.common.save }), setting.set && (_jsx(Button, { variant: "ghost", disabled: props.busy, onClick: props.onRemove, children: words.common.remove }))] }) })] }));
201
346
  }
202
347
  /**
203
- * Enabling: the capabilities to consent to, one by one, those consented to before ticked
204
- * already; the board project, the one it had chosen already; the projects, as they were.
348
+ * Enabling: the capabilities the plugin requires, on and not the administrator's to turn off, and
349
+ * those it can go without, off until chosen, those consented to before on already (ADR-0060); the
350
+ * board project, the one it had chosen already; the projects, as they were.
205
351
  */
206
352
  function EnableForm(props) {
207
353
  const words = useWords();
208
354
  const settings = words.plugins.settings;
209
355
  const { detail, language } = props;
210
- const [consented, setConsented] = useState(() => new Set((detail.consent ?? []).filter((capability) => detail.capabilities.includes(capability))));
356
+ const optional = detail.optionalCapabilities ?? [];
357
+ // The roles the plugin asks of other plugins (ADR-0072): granted on the way where ticked.
358
+ const asks = (detail.asks ?? []).filter((ask) => ask.state !== "granted");
359
+ const [askedNow, setAskedNow] = useState(() => new Set());
360
+ const [consented, setConsented] = useState(() => new Set((detail.consent ?? []).filter((capability) => optional.includes(capability))));
361
+ /** A capability a new version asks and nobody has consented to yet is said to be new. */
362
+ const tagOf = (capability) => detail.state === "needs_consent" && !(detail.consent ?? []).includes(capability)
363
+ ? settings.newCapability
364
+ : undefined;
211
365
  const needsBoard = detail.boardNeeds !== "none";
212
366
  const [boardMode, setBoardMode] = useState(detail.boardNeeds === "none"
213
367
  ? "none"
@@ -222,7 +376,6 @@ function EnableForm(props) {
222
376
  const [allProjects, setAllProjects] = useState(!Array.isArray(before) || before.length === 0);
223
377
  const [onProjects, setOnProjects] = useState(() => new Set(Array.isArray(before) ? before : []));
224
378
  const ids = { key: useId(), name: useId(), description: useId(), choose: useId() };
225
- const everyCapability = detail.capabilities.every((capability) => consented.has(capability));
226
379
  const boardReady = boardMode === "none"
227
380
  ? detail.boardNeeds !== "required"
228
381
  : boardMode === "create"
@@ -231,19 +384,40 @@ function EnableForm(props) {
231
384
  const submit = (event) => {
232
385
  event.preventDefault();
233
386
  props.onEnable({
234
- consent: [...consented],
387
+ consent: [...detail.capabilities, ...consented],
235
388
  board: boardMode === "none"
236
389
  ? null
237
390
  : boardMode === "create"
238
391
  ? { create: { key: boardKey, name: boardName, description: boardDescription } }
239
392
  : { project: chosen },
240
393
  projects: allProjects ? "all" : [...onProjects],
241
- });
394
+ }, asks
395
+ .filter((ask) => ask.state === "ungranted" && askedNow.has(`${ask.plugin}:${ask.role}`))
396
+ .map((ask) => ({ plugin: ask.plugin, role: ask.role })));
242
397
  };
243
- return (_jsxs("form", { className: "sc-form sc-plugin-enable", onSubmit: submit, "aria-label": settings.enable, children: [detail.capabilities.length > 0 && (_jsxs("div", { className: "sc-plugin-group", children: [_jsx("h3", { className: "sc-plugin-group-title", children: settings.capabilities }), _jsx("ul", { className: "sc-plugin-ticks", children: detail.capabilities.map((capability) => {
244
- const text = capabilityText(words, capability);
245
- return (_jsx(TickRow, { checked: consented.has(capability), onChange: (on) => setConsented((current) => toggled(current, capability, on)), name: text.name, under: text.opens }, capability));
246
- }) })] })), needsBoard && (_jsxs("div", { className: "sc-plugin-group", children: [_jsx("h3", { className: "sc-plugin-group-title", children: settings.board }), _jsx("p", { className: "sc-settings-hint", children: settings.boardHint }), _jsxs("div", { className: "sc-radio-row", children: [detail.boardNeeds === "optional" && (_jsxs("label", { className: "sc-check", children: [_jsx("input", { type: "radio", name: "board", checked: boardMode === "none", onChange: () => setBoardMode("none") }), settings.boardNone] })), _jsxs("label", { className: "sc-check", children: [_jsx("input", { type: "radio", name: "board", checked: boardMode === "create", onChange: () => setBoardMode("create") }), settings.boardCreate] }), _jsxs("label", { className: "sc-check", children: [_jsx("input", { type: "radio", name: "board", checked: boardMode === "choose", onChange: () => setBoardMode("choose") }), settings.boardChoose] })] }), boardMode === "create" && (_jsxs("div", { className: "sc-plugin-fields", children: [_jsxs("div", { className: "sc-field", children: [_jsx("label", { className: "sc-field-label", htmlFor: ids.key, children: settings.boardKey }), _jsx("input", { id: ids.key, className: "sc-input", value: boardKey, onChange: (event) => setBoardKey(event.target.value) })] }), _jsxs("div", { className: "sc-field", children: [_jsx("label", { className: "sc-field-label", htmlFor: ids.name, children: settings.boardName }), _jsx("input", { id: ids.name, className: "sc-input", value: boardName, onChange: (event) => setBoardName(event.target.value) })] }), _jsxs("div", { className: "sc-field", children: [_jsx("label", { className: "sc-field-label", htmlFor: ids.description, children: settings.boardDescription }), _jsx("input", { id: ids.description, className: "sc-input", value: boardDescription, onChange: (event) => setBoardDescription(event.target.value) })] })] })), boardMode === "choose" && (_jsx("div", { className: "sc-plugin-fields", children: _jsxs("div", { className: "sc-field", children: [_jsx("label", { className: "sc-field-label", htmlFor: ids.choose, children: settings.boardChoose }), _jsx("select", { id: ids.choose, className: "sc-input", value: chosen, onChange: (event) => setChosen(event.target.value), children: props.projects.map((project) => (_jsxs("option", { value: project.key, children: [project.name, " (", project.key, ")"] }, project.key))) })] }) }))] })), _jsxs("div", { className: "sc-plugin-group", children: [_jsx("h3", { className: "sc-plugin-group-title", children: settings.projects }), _jsxs("div", { className: "sc-radio-row", children: [_jsxs("label", { className: "sc-check", children: [_jsx("input", { type: "radio", name: "projects", checked: allProjects, onChange: () => setAllProjects(true) }), settings.projectsAll] }), _jsxs("label", { className: "sc-check", children: [_jsx("input", { type: "radio", name: "projects", checked: !allProjects, onChange: () => setAllProjects(false) }), settings.projectsSome] })] }), !allProjects && (_jsx("ul", { className: "sc-plugin-ticks", children: props.projects.map((project) => (_jsx(TickRow, { checked: onProjects.has(project.key), onChange: (on) => setOnProjects((current) => toggled(current, project.key, on)), name: project.name, under: project.key }, project.key))) }))] }), _jsx("div", { className: "sc-plugin-group", children: _jsx("div", { className: "sc-form-actions", children: _jsx(Button, { type: "submit", variant: "primary", disabled: props.busy || !everyCapability || !boardReady, children: settings.enable }) }) })] }));
398
+ return (_jsxs("form", { className: "sc-form sc-plugin-enable", onSubmit: submit, "aria-label": settings.enable, children: [detail.capabilities.length + optional.length > 0 && (_jsxs("div", { className: "sc-plugin-group", children: [_jsx("h3", { className: "sc-plugin-group-title", children: settings.capabilities }), detail.capabilities.length > 0 && (_jsxs("div", { className: "sc-plugin-capabilities", children: [_jsxs("p", { className: "sc-plugin-capabilities-head", children: [_jsx("span", { className: "sc-plugin-capabilities-name", children: settings.required }), _jsx("span", { className: "sc-settings-hint", children: settings.requiredHint })] }), _jsx("ul", { className: "sc-plugin-ticks", children: detail.capabilities.map((capability) => {
399
+ const text = capabilityText(words, capability);
400
+ return (_jsx(TickRow, { checked: true, locked: true, name: text.name, under: text.opens, tag: tagOf(capability) }, capability));
401
+ }) })] })), optional.length > 0 && (_jsxs("div", { className: "sc-plugin-capabilities", children: [_jsxs("p", { className: "sc-plugin-capabilities-head", children: [_jsx("span", { className: "sc-plugin-capabilities-name", children: settings.optional }), _jsx("span", { className: "sc-settings-hint", children: settings.optionalHint })] }), _jsx("ul", { className: "sc-plugin-ticks", children: optional.map((capability) => {
402
+ const text = capabilityText(words, capability);
403
+ return (_jsx(TickRow, { checked: consented.has(capability), onChange: (on) => setConsented((current) => toggled(current, capability, on)), name: text.name, under: text.opens }, capability));
404
+ }) })] }))] })), needsBoard && (_jsxs("div", { className: "sc-plugin-group", children: [_jsx("h3", { className: "sc-plugin-group-title", children: settings.board }), _jsx("p", { className: "sc-settings-hint", children: settings.boardHint }), _jsxs("div", { className: "sc-radio-row", children: [detail.boardNeeds === "optional" && (_jsxs("label", { className: "sc-check", children: [_jsx("input", { type: "radio", name: "board", checked: boardMode === "none", onChange: () => setBoardMode("none") }), settings.boardNone] })), _jsxs("label", { className: "sc-check", children: [_jsx("input", { type: "radio", name: "board", checked: boardMode === "create", onChange: () => setBoardMode("create") }), settings.boardCreate] }), _jsxs("label", { className: "sc-check", children: [_jsx("input", { type: "radio", name: "board", checked: boardMode === "choose", onChange: () => setBoardMode("choose") }), settings.boardChoose] })] }), boardMode === "create" && (_jsxs("div", { className: "sc-plugin-fields", children: [_jsxs("div", { className: "sc-field", children: [_jsx("label", { className: "sc-field-label", htmlFor: ids.key, children: settings.boardKey }), _jsx("input", { id: ids.key, className: "sc-input", value: boardKey, onChange: (event) => setBoardKey(event.target.value) })] }), _jsxs("div", { className: "sc-field", children: [_jsx("label", { className: "sc-field-label", htmlFor: ids.name, children: settings.boardName }), _jsx("input", { id: ids.name, className: "sc-input", value: boardName, onChange: (event) => setBoardName(event.target.value) })] }), _jsxs("div", { className: "sc-field", children: [_jsx("label", { className: "sc-field-label", htmlFor: ids.description, children: settings.boardDescription }), _jsx("input", { id: ids.description, className: "sc-input", value: boardDescription, onChange: (event) => setBoardDescription(event.target.value) })] })] })), boardMode === "choose" && (_jsx("div", { className: "sc-plugin-fields", children: _jsxs("div", { className: "sc-field", children: [_jsx("label", { className: "sc-field-label", htmlFor: ids.choose, children: settings.boardChoose }), _jsx(Picker, { id: ids.choose, value: props.projects.find((project) => project.key === chosen), search: projectsSearch(props.projects), keyOf: (project) => project.key, render: (project) => `${project.name} (${project.key})`, label: settings.boardChoose, placeholder: settings.boardChoose, onChange: (project) => setChosen(project?.key ?? "") })] }) }))] })), _jsxs("div", { className: "sc-plugin-group", children: [_jsx("h3", { className: "sc-plugin-group-title", children: settings.projects }), _jsxs("div", { className: "sc-radio-row", children: [_jsxs("label", { className: "sc-check", children: [_jsx("input", { type: "radio", name: "projects", checked: allProjects, onChange: () => setAllProjects(true) }), settings.projectsAll] }), _jsxs("label", { className: "sc-check", children: [_jsx("input", { type: "radio", name: "projects", checked: !allProjects, onChange: () => setAllProjects(false) }), settings.projectsSome] })] }), !allProjects && (_jsx("ul", { className: "sc-plugin-ticks", children: props.projects.map((project) => (_jsx(TickRow, { checked: onProjects.has(project.key), onChange: (on) => setOnProjects((current) => toggled(current, project.key, on)), name: project.name, under: project.key }, project.key))) }))] }), _jsxs("div", { className: "sc-plugin-group", children: [asks.length > 0 && (_jsxs("div", { className: "sc-plugin-group", children: [_jsx("h3", { className: "sc-plugin-group-title", children: settings.asks }), _jsx("p", { className: "sc-settings-hint", children: settings.asksHint }), _jsx("ul", { className: "sc-plugin-ticks", children: asks.map((ask) => {
405
+ const id = `${ask.plugin}:${ask.role}`;
406
+ return (_jsx(TickRow, { checked: ask.state === "ungranted" && askedNow.has(id), onChange: ask.state === "ungranted"
407
+ ? (checked) => setAskedNow((current) => {
408
+ const next = new Set(current);
409
+ if (checked) {
410
+ next.add(id);
411
+ }
412
+ else {
413
+ next.delete(id);
414
+ }
415
+ return next;
416
+ })
417
+ : undefined, locked: ask.state === "unavailable", name: `${ask.role} (${ask.plugin})`, under: ask.state === "unavailable"
418
+ ? settings.askUnavailable(ask.plugin)
419
+ : pluginWord(ask.why, language) }, id));
420
+ }) })] })), _jsx("div", { className: "sc-form-actions", children: _jsx(Button, { type: "submit", variant: "primary", disabled: props.busy || !boardReady, children: settings.enable }) })] })] }));
247
421
  }
248
422
  /** Who a grant is to, as the chip says it. */
249
423
  function holderOf(grant, words) {
@@ -253,6 +427,12 @@ function holderOf(grant, words) {
253
427
  if (grant.project !== null) {
254
428
  return words.grantMembersOf(grant.project.name);
255
429
  }
430
+ if (grant.plugin !== null && grant.plugin !== undefined) {
431
+ return words.grantPlugin(grant.plugin);
432
+ }
433
+ if (grant.team !== null && grant.team !== undefined) {
434
+ return words.grantTeam(grant.team.name);
435
+ }
256
436
  if (grant.person !== null) {
257
437
  return personName(grant.person);
258
438
  }
@@ -270,39 +450,92 @@ function personChoice(person) {
270
450
  */
271
451
  function RoleRow(props) {
272
452
  const settings = useWords().plugins.settings;
273
- const [whom, setWhom] = useState("");
453
+ const [whom, setWhom] = useState(undefined);
274
454
  const id = useId();
275
455
  const { role, grants } = props;
276
456
  const everyoneHas = grants.some((grant) => grant.everyone);
277
457
  const projectsWith = new Set(grants.flatMap((grant) => (grant.project === null ? [] : [grant.project.key])));
278
458
  const peopleWith = new Set(grants.flatMap((grant) => (grant.person === null ? [] : [grant.person.id])));
459
+ const pluginsWith = new Set(grants.flatMap((grant) => grant.plugin === null || grant.plugin === undefined ? [] : [grant.plugin]));
460
+ const plugins = props.plugins.filter((plugin) => !pluginsWith.has(plugin.key));
461
+ const teamsWith = new Set(grants.flatMap((grant) => grant.team === null || grant.team === undefined ? [] : [grant.team.key]));
462
+ const teams = props.teams.filter((team) => !teamsWith.has(team.key));
279
463
  const projects = props.projects.filter((project) => !projectsWith.has(project.key));
280
464
  const people = props.people.filter((person) => person.status === "active" && !peopleWith.has(person.id));
281
465
  const description = pluginWord(role.description, props.language);
466
+ // Whom the role may go to, searched for as one list (ADR-0037): everyone where it may, then
467
+ // the projects, the people and the plugins without it.
468
+ const choices = [
469
+ ...(!props.isDefault && !everyoneHas ? [{ kind: "everyone" }] : []),
470
+ ...projects.map((project) => ({ kind: "project", project })),
471
+ ...people.map((person) => ({ kind: "person", person })),
472
+ ...plugins.map((plugin) => ({ kind: "plugin", plugin })),
473
+ ...teams.map((team) => ({ kind: "team", team })),
474
+ ];
475
+ const choiceWords = (choice) => {
476
+ switch (choice.kind) {
477
+ case "everyone":
478
+ return settings.grantEveryone;
479
+ case "project":
480
+ return settings.grantMembersOf(choice.project.name);
481
+ case "person":
482
+ return personChoice(choice.person);
483
+ case "team":
484
+ return settings.grantTeam(choice.team.name);
485
+ case "plugin":
486
+ return `${settings.grantPlugin(choice.plugin.key)} · ${pluginWord(choice.plugin.name, props.language)}`;
487
+ }
488
+ };
489
+ const findWhom = listSearch(choices, (choice, typed) => choiceWords(choice).toLowerCase().includes(typed));
490
+ const keyOfChoice = (choice) => choice.kind === "everyone"
491
+ ? "everyone"
492
+ : choice.kind === "project"
493
+ ? `project:${choice.project.key}`
494
+ : choice.kind === "person"
495
+ ? `person:${choice.person.id}`
496
+ : choice.kind === "team"
497
+ ? `team:${choice.team.key}`
498
+ : `plugin:${choice.plugin.key}`;
282
499
  const submit = (event) => {
283
500
  event.preventDefault();
284
- if (whom === "everyone") {
501
+ if (whom === undefined) {
502
+ return;
503
+ }
504
+ if (whom.kind === "everyone") {
285
505
  props.onGrant({ role: role.key, everyone: true });
286
506
  }
287
- else if (whom.startsWith("project:")) {
288
- props.onGrant({ role: role.key, project: whom.slice("project:".length) });
507
+ else if (whom.kind === "project") {
508
+ props.onGrant({ role: role.key, project: whom.project.key });
509
+ }
510
+ else if (whom.kind === "person") {
511
+ props.onGrant({ role: role.key, person: whom.person.id });
289
512
  }
290
- else if (whom.startsWith("person:")) {
291
- props.onGrant({ role: role.key, person: whom.slice("person:".length) });
513
+ else if (whom.kind === "team") {
514
+ props.onGrant({ role: role.key, team: whom.team.key });
292
515
  }
293
- setWhom("");
516
+ else {
517
+ props.onGrant({ role: role.key, plugin: whom.plugin.key });
518
+ }
519
+ setWhom(undefined);
294
520
  };
295
- return (_jsxs("li", { className: "sc-plugin-role", children: [_jsxs("div", { children: [_jsxs("p", { className: "sc-plugin-role-name", children: [pluginWord(role.name, props.language), _jsx("code", { className: "sc-plugin-role-key", children: role.key }), props.isDefault && _jsx(Badge, { tone: "accent", children: settings.roleDefault })] }), description !== "" && _jsx("p", { className: "sc-settings-hint", children: description })] }), _jsxs("div", { children: [_jsxs("div", { className: "sc-plugin-holders", children: [props.isDefault && (_jsx("span", { className: "sc-plugin-holder sc-plugin-holder-fixed", children: settings.everyMember })), grants.map((grant) => {
521
+ return (_jsxs("li", { className: "sc-plugin-role", children: [_jsxs("div", { children: [_jsxs("p", { className: "sc-plugin-role-name", children: [pluginWord(role.name, props.language), _jsx("code", { className: "sc-plugin-role-key", children: role.key }), props.isDefault && _jsx(Badge, { tone: "accent", children: settings.roleDefault }), role.follows === "reports" && _jsx(Badge, { tone: "accent", children: settings.roleManagers })] }), description !== "" && _jsx("p", { className: "sc-settings-hint", children: description })] }), _jsxs("div", { children: [_jsxs("div", { className: "sc-chips sc-plugin-holders", children: [props.isDefault && _jsx(Chip, { className: "sc-plugin-holder", children: settings.everyMember }), role.follows === "reports" && (_jsx(Chip, { className: "sc-plugin-holder", children: settings.whoeverManages })), grants.map((grant) => {
296
522
  const holder = holderOf(grant, settings);
297
- return (_jsxs("span", { className: "sc-plugin-holder", children: [holder, _jsx(Button, { size: "sm", variant: "ghost", disabled: props.busy, onClick: () => props.onRevoke(grant.id), "aria-label": `${settings.revoke}: ${holder}`, title: settings.revoke, children: "\u00D7" })] }, grant.id));
298
- })] }), _jsxs("form", { className: "sc-plugin-grant", onSubmit: submit, children: [_jsx("label", { htmlFor: id, className: "sc-visually-hidden", children: settings.grantWhom }), _jsxs("select", { id: id, className: "sc-input sc-plugin-grant-input", value: whom, onChange: (event) => setWhom(event.target.value), children: [_jsx("option", { value: "", children: settings.grantWhom }), !props.isDefault && !everyoneHas && (_jsx("option", { value: "everyone", children: settings.grantEveryone })), projects.length > 0 && (_jsx("optgroup", { label: settings.grantProjects, children: projects.map((project) => (_jsx("option", { value: `project:${project.key}`, children: project.name }, project.key))) })), people.length > 0 && (_jsx("optgroup", { label: settings.grantPeople, children: people.map((person) => (_jsx("option", { value: `person:${person.id}`, children: personChoice(person) }, person.id))) }))] }), _jsx(Button, { type: "submit", disabled: props.busy || whom === "", children: settings.grant })] })] })] }));
523
+ return (_jsx(Chip, { className: "sc-plugin-holder", onRemove: () => props.onRevoke(grant.id), removeLabel: `${settings.revoke}: ${holder}`, disabled: props.busy, children: holder }, grant.id));
524
+ })] }), _jsxs("form", { className: "sc-plugin-grant", onSubmit: submit, children: [_jsx("label", { htmlFor: id, className: "sc-visually-hidden", children: settings.grantWhom }), _jsx(Picker, { id: id, value: whom, search: findWhom, keyOf: keyOfChoice, render: choiceWords, label: settings.grantWhom, placeholder: settings.grantWhom, disabled: props.busy, onChange: setWhom }), _jsx(Button, { type: "submit", disabled: props.busy || whom === undefined, children: settings.grant })] })] })] }));
525
+ }
526
+ /** Another plugin by the name it gives itself in the person's language, or its key where the page does not know it. */
527
+ function pluginNameOf(plugins, key, language) {
528
+ const found = plugins.find((plugin) => plugin.key === key);
529
+ return found === undefined ? key : pluginWord(found.name, language);
299
530
  }
300
531
  /** The roles the plugin declares, each with who holds it; a plugin without roles is every member's. */
301
532
  function RolesSection(props) {
302
533
  const settings = useWords().plugins.settings;
303
534
  const { detail } = props;
304
535
  const grants = detail.grants ?? [];
305
- return (_jsxs("section", { className: "sc-panel", "aria-label": settings.roles, children: [_jsx("h2", { className: "sc-section-title", children: settings.roles }), detail.declaredRoles.length === 0 ? (_jsx("p", { className: "sc-settings-hint", children: settings.rolesNone })) : (_jsx("ul", { className: "sc-plugin-roles", children: detail.declaredRoles.map((role) => (_jsx(RoleRow, { role: role, isDefault: detail.defaultRole === role.key, grants: grants.filter((grant) => grant.role === role.key), projects: props.projects, people: props.people, language: props.language, busy: props.busy, onGrant: props.onGrant, onRevoke: props.onRevoke }, role.key))) }))] }));
536
+ const others = props.plugins.filter((plugin) => plugin.state === "enabled" && plugin.key !== detail.key);
537
+ const asks = detail.asks ?? [];
538
+ return (_jsxs("section", { className: "sc-panel", "aria-label": settings.roles, children: [_jsx("h2", { className: "sc-section-title", children: settings.roles }), detail.declaredRoles.length === 0 ? (_jsx("p", { className: "sc-settings-hint", children: settings.rolesNone })) : (_jsx("ul", { className: "sc-plugin-roles", children: detail.declaredRoles.map((role) => (_jsx(RoleRow, { role: role, isDefault: detail.defaultRole === role.key, grants: grants.filter((grant) => grant.role === role.key), projects: props.projects, people: props.people, plugins: others, teams: props.teams, language: props.language, busy: props.busy, onGrant: props.onGrant, onRevoke: props.onRevoke }, role.key))) })), asks.length > 0 && (_jsxs("div", { className: "sc-plugin-group", children: [_jsx("h3", { className: "sc-plugin-group-title", children: settings.asks }), _jsx("p", { className: "sc-settings-hint", children: settings.asksHint }), _jsx("ul", { className: "sc-plugin-roles", children: asks.map((ask) => (_jsxs("li", { className: "sc-plugin-role", children: [_jsxs("div", { children: [_jsxs("p", { className: "sc-plugin-role-name", children: [pluginNameOf(props.plugins, ask.plugin, props.language), _jsx("code", { className: "sc-plugin-role-key", children: ask.role }), ask.state === "granted" && _jsx(Badge, { tone: "accent", children: settings.askGranted })] }), _jsx("p", { className: "sc-settings-hint", children: pluginWord(ask.why, props.language) })] }), _jsx("div", { children: ask.state === "unavailable" ? (_jsx("span", { className: "sc-settings-hint", children: settings.askUnavailable(ask.plugin) })) : ask.state === "ungranted" ? (_jsx(Button, { size: "sm", disabled: props.busy, onClick: () => props.onGrantAsked(ask.plugin, ask.role), children: settings.askGrantNow })) : null })] }, `${ask.plugin}:${ask.role}`))) })] }))] }));
306
539
  }
307
540
  /** One plugin, whole, for an administrator. */
308
541
  export function PluginSettingsView(props) {
@@ -334,9 +567,14 @@ export function PluginSettingsView(props) {
334
567
  });
335
568
  const enabled = detail.state === "enabled";
336
569
  const canEnable = detail.state === "installed" || detail.state === "disabled" || detail.state === "needs_consent";
337
- return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "sc-page-head", children: [_jsxs("div", { className: "sc-page-heading", children: [_jsx("h1", { className: "sc-page-title", children: pluginWord(detail.name, language) }), _jsx(Badge, { tone: STATE_TONES[detail.state], children: words.vocabulary.pluginState[detail.state] ?? detail.state }), _jsxs("span", { className: "sc-muted", children: [_jsx("code", { children: detail.key }), " ", detail.version] })] }), enabled && (_jsx("div", { className: "sc-page-actions", children: _jsx(Button, { size: "sm", disabled: busy, onClick: () => change(() => plugin.disable()), children: settings.disable }) }))] }), _jsx("p", { className: "sc-lead", children: pluginWord(detail.description, language) }), error !== undefined && _jsx(Callout, { tone: "danger", children: error }), detail.problems.length > 0 && (_jsx(Callout, { tone: "danger", title: settings.problems, children: _jsx("ul", { className: "sc-plugin-problems", children: detail.problems.map((problem) => (_jsx("li", { children: problem }, problem))) }) })), _jsx(Overview, { detail: detail, projects: props.projects, language: language }), canEnable && (_jsxs("section", { className: "sc-panel sc-panel-form", "aria-label": settings.enable, children: [_jsx("h2", { className: "sc-section-title", children: settings.enable }), _jsx(EnableForm, { detail: detail, projects: props.projects, language: language, busy: busy, onEnable: (input) => change(() => plugin.enable(input)) })] })), enabled && detail.settings.length > 0 && (_jsxs("section", { className: "sc-panel sc-panel-form", "aria-label": settings.settingsForm, children: [_jsx("h2", { className: "sc-section-title", children: settings.settingsForm }), _jsxs("div", { children: [_jsx(SettingsForm, { detail: detail, language: language, busy: busy, people: props.people, projects: props.projects, onSave: (values) => change(() => plugin.updateSettings({ values })) }), detail.settings
570
+ return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "sc-page-head", children: [_jsxs("div", { className: "sc-page-heading", children: [_jsx("h1", { className: "sc-page-title", children: pluginWord(detail.name, language) }), _jsx(Badge, { tone: STATE_TONES[detail.state], children: words.vocabulary.pluginState[detail.state] ?? detail.state }), _jsxs("span", { className: "sc-muted", children: [_jsx("code", { children: detail.key }), " ", detail.version] })] }), enabled && (_jsx("div", { className: "sc-page-actions", children: _jsx(Button, { size: "sm", disabled: busy, onClick: () => change(() => plugin.disable()), children: settings.disable }) }))] }), _jsx("p", { className: "sc-lead", children: pluginWord(detail.description, language) }), error !== undefined && _jsx(Callout, { tone: "danger", children: error }), detail.problems.length > 0 && (_jsx(Callout, { tone: "danger", title: settings.problems, children: _jsx("ul", { className: "sc-plugin-problems", children: detail.problems.map((problem) => (_jsx("li", { children: problem }, problem))) }) })), detail.needsTimeZone === true && (_jsx(Callout, { tone: "warning", action: _jsx(LinkButton, { href: settingsHref("workspace"), children: settings.setTimeZone }), children: settings.needsTimeZone })), _jsx(Overview, { detail: detail, projects: props.projects, language: language, busy: busy, onConsent: (consent) => change(() => plugin.updateConsent(consent)) }), canEnable && (_jsxs("section", { className: "sc-panel sc-panel-form", "aria-label": settings.enable, children: [_jsx("h2", { className: "sc-section-title", children: settings.enable }), _jsx(EnableForm, { detail: detail, projects: props.projects, language: language, busy: busy, onEnable: (input, grants) => change(async () => {
571
+ await plugin.enable(input);
572
+ for (const grant of grants) {
573
+ await client.plugin(grant.plugin).grant({ role: grant.role, plugin: detail.key });
574
+ }
575
+ }) })] })), enabled && detail.settings.length > 0 && (_jsxs("section", { className: "sc-panel sc-panel-form", "aria-label": settings.settingsForm, children: [_jsx("h2", { className: "sc-section-title", children: settings.settingsForm }), _jsxs("div", { children: [_jsx(SettingsForm, { detail: detail, language: language, busy: busy, people: props.people, projects: props.projects, onSave: (values) => change(() => plugin.updateSettings({ values })) }), detail.settings
338
576
  .filter((setting) => setting.type === "secret")
339
- .map((setting) => (_jsx(SecretRow, { setting: setting, language: language, busy: busy, onSet: (value) => change(() => plugin.setSecret(setting.key, value)), onRemove: () => change(() => plugin.removeSecret(setting.key)) }, setting.key)))] })] })), detail.grants !== null && (_jsx(RolesSection, { detail: detail, projects: props.projects, people: props.people, language: language, busy: busy, onGrant: (input) => change(() => plugin.grant(input)), onRevoke: (id) => change(() => plugin.revoke(id)) })), _jsxs("section", { className: "sc-panel", "aria-label": settings.events, children: [_jsx("h2", { className: "sc-section-title", children: settings.events }), events === undefined ? (_jsx(Spinner, { label: words.common.loading })) : (_jsx(EventFeed, { events: events, empty: _jsx("p", { className: "sc-muted", children: settings.noEvents }) }))] }), _jsxs("section", { className: "sc-panel sc-panel-form", "aria-label": settings.data, children: [_jsx("h2", { className: "sc-section-title", children: settings.data }), _jsxs("div", { children: [_jsxs("div", { className: "sc-settings-row", children: [_jsxs("div", { className: "sc-settings-words", children: [_jsx("p", { className: "sc-settings-label", children: settings.export }), _jsx("p", { className: "sc-settings-hint", children: settings.exportHint })] }), _jsx("div", { className: "sc-settings-control", children: _jsx(LinkButton, { href: `/api/v1/plugins/${detail.key}/export`, children: settings.exportLink }) })] }), _jsxs("div", { className: "sc-settings-row", children: [_jsxs("div", { className: "sc-settings-words", children: [_jsx("p", { className: "sc-settings-label", children: settings.purge }), _jsx("p", { className: "sc-settings-hint", children: settings.purgeHint })] }), _jsx("div", { className: "sc-settings-control", children: purged ? (_jsx("p", { className: "sc-settings-hint", children: settings.purged })) : enabled ? (_jsx("p", { className: "sc-settings-hint", children: settings.purgeDisabledFirst })) : (_jsxs("form", { className: "sc-plugin-line", onSubmit: (event) => {
577
+ .map((setting) => (_jsx(SecretRow, { setting: setting, language: language, busy: busy, onSet: (value) => change(() => plugin.setSecret(setting.key, value)), onRemove: () => change(() => plugin.removeSecret(setting.key)) }, setting.key)))] })] })), detail.grants !== null && (_jsx(RolesSection, { detail: detail, plugins: props.plugins ?? [], teams: props.teams ?? [], onGrantAsked: (other, role) => change(() => client.plugin(other).grant({ role, plugin: detail.key })), projects: props.projects, people: props.people, language: language, busy: busy, onGrant: (input) => change(() => plugin.grant(input)), onRevoke: (id) => change(() => plugin.revoke(id)) })), _jsxs("section", { className: "sc-panel", "aria-label": settings.events, children: [_jsx("h2", { className: "sc-section-title", children: settings.events }), events === undefined ? (_jsx(Spinner, { label: words.common.loading })) : (_jsx(EventFeed, { events: events, empty: _jsx("p", { className: "sc-muted", children: settings.noEvents }) }))] }), _jsxs("section", { className: "sc-panel sc-panel-form", "aria-label": settings.data, children: [_jsx("h2", { className: "sc-section-title", children: settings.data }), _jsxs("div", { children: [_jsxs("div", { className: "sc-settings-row", children: [_jsxs("div", { className: "sc-settings-words", children: [_jsx("p", { className: "sc-settings-label", children: settings.export }), _jsx("p", { className: "sc-settings-hint", children: settings.exportHint })] }), _jsx("div", { className: "sc-settings-control", children: _jsx(LinkButton, { href: `/api/v1/plugins/${detail.key}/export`, children: settings.exportLink }) })] }), _jsxs("div", { className: "sc-settings-row", children: [_jsxs("div", { className: "sc-settings-words", children: [_jsx("p", { className: "sc-settings-label", children: settings.purge }), _jsx("p", { className: "sc-settings-hint", children: settings.purgeHint })] }), _jsx("div", { className: "sc-settings-control", children: purged ? (_jsx("p", { className: "sc-settings-hint", children: settings.purged })) : enabled ? (_jsx("p", { className: "sc-settings-hint", children: settings.purgeDisabledFirst })) : (_jsxs("form", { className: "sc-plugin-line", onSubmit: (event) => {
340
578
  event.preventDefault();
341
579
  void act(async () => {
342
580
  await plugin.purge(confirm);