@crombolo/backoffice-host 0.41.1 → 0.43.1

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 (35) hide show
  1. package/NOTICE +9 -0
  2. package/package.json +3 -3
  3. package/plugin/addresses-dashboard.js +3 -2
  4. package/plugin/app-preview/umbraco-package.json +1 -1
  5. package/plugin/approvals-active.js +40 -0
  6. package/plugin/audit-dashboard.js +3 -2
  7. package/plugin/branding/localization-en.js +9 -3
  8. package/plugin/branding/sign-in.js +0 -31
  9. package/plugin/branding/theme-dark.css +19 -5
  10. package/plugin/branding/theme.css +41 -19
  11. package/plugin/breadcrumb.js +29 -0
  12. package/plugin/changes-dashboard.js +3 -2
  13. package/plugin/edit-conflicts.js +11 -21
  14. package/plugin/jobs-dashboard.js +3 -2
  15. package/plugin/localizations/umbraco-package.json +1 -1
  16. package/plugin/notifications-dialog.js +8 -35
  17. package/plugin/overview-dashboard.js +412 -0
  18. package/plugin/overview-format.js +71 -0
  19. package/plugin/seo/umbraco-package.json +1 -1
  20. package/plugin/settings-cards.js +189 -0
  21. package/plugin/settings-section.js +436 -0
  22. package/plugin/side-panel/host.js +7 -63
  23. package/plugin/side-panel/layout.js +0 -15
  24. package/plugin/sign-in/umbraco-package.json +1 -1
  25. package/plugin/tsx-editors.js +56 -164
  26. package/plugin/umbraco-package.json +26 -55
  27. package/plugin/workflow-client.js +3 -0
  28. package/plugin/workflow-designer.js +17 -2
  29. package/src/branding.ts +4 -0
  30. package/plugin/branding/branding.js +0 -188
  31. package/plugin/branding/client-credentials.js +0 -49
  32. package/plugin/branding/log-viewer-menu.js +0 -70
  33. package/plugin/branding/query-builder.js +0 -28
  34. package/plugin/settings-dashboard.js +0 -123
  35. package/plugin/welcome-dashboard.js +0 -103
@@ -0,0 +1,436 @@
1
+ /**
2
+ * Settings, laid out as Crombolo's (story 234): a landing page of cards, each
3
+ * tool on its own without a tab bar, and the Structure or Code tree only beside
4
+ * the editors it opens. Built from the pieces Umbraco's `umb-section-default`
5
+ * uses, and drawn in its place through the `Crombolo.SectionLayout.Settings`
6
+ * manifest.
7
+ */
8
+
9
+ import {
10
+ createExtensionApi,
11
+ createExtensionElement,
12
+ UmbExtensionsElementInitializer,
13
+ UmbExtensionsManifestInitializer,
14
+ } from '@umbraco-cms/backoffice/extension-api'
15
+ import { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry'
16
+ import { css, html, nothing } from '@umbraco-cms/backoffice/external/lit'
17
+ import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'
18
+ import { UmbRouteNotFoundElement } from '@umbraco-cms/backoffice/router'
19
+ import { UmbTextStyles } from '@umbraco-cms/backoffice/style'
20
+ import { aliasToPath, pathFolderName } from '@umbraco-cms/backoffice/utils'
21
+ import { UmbViewController } from '@umbraco-cms/backoffice/view'
22
+ import {
23
+ ADVANCED_MENU,
24
+ advancedToolTitle,
25
+ CODE_MENU,
26
+ crumbsFor,
27
+ SIDEBAR_APPS,
28
+ STRUCTURE_MENU,
29
+ settingsCards,
30
+ treeFor,
31
+ } from './settings-cards.js'
32
+ import './breadcrumb.js'
33
+
34
+ const base = () =>
35
+ (document.querySelector('base')?.getAttribute('href') ?? '/umbraco/').replace(/\/$/, '')
36
+
37
+ /** Whether this site can send e-mail; the server answers with the reason. */
38
+ const emailStatus = async () => {
39
+ const response = await fetch(`${base()}/crombolo/api/email`, {
40
+ credentials: 'include',
41
+ headers: { accept: 'application/json' },
42
+ })
43
+ if (!response.ok) throw new Error(`email responded ${response.status}`)
44
+ return response.json()
45
+ }
46
+
47
+ const menuOf = (manifest, menu) => manifest.meta?.menus?.includes(menu) === true
48
+
49
+ export class CromboloSettingsSectionElement extends UmbLitElement {
50
+ static properties = {
51
+ _routes: { state: true },
52
+ _sidebarApps: { state: true },
53
+ _tree: { state: true },
54
+ _crumbs: { state: true },
55
+ }
56
+
57
+ #dashboards = []
58
+ #menuItems = []
59
+ #sectionRoutes = []
60
+ #landing
61
+ #viewContexts = new Map()
62
+ #providedView
63
+
64
+ constructor() {
65
+ super()
66
+ new UmbExtensionsElementInitializer(
67
+ this,
68
+ umbExtensionsRegistry,
69
+ 'sectionSidebarApp',
70
+ null,
71
+ (apps) => {
72
+ // Marked as Umbraco's section marks them, which tests and tours find them by.
73
+ for (const app of apps)
74
+ app.component?.setAttribute('data-mark', `section-sidebar:${app.manifest.alias}`)
75
+ this._sidebarApps = apps.filter((a) => Object.values(SIDEBAR_APPS).includes(a.alias))
76
+ },
77
+ )
78
+ new UmbExtensionsManifestInitializer(
79
+ this,
80
+ umbExtensionsRegistry,
81
+ 'dashboard',
82
+ null,
83
+ (dashboards) => {
84
+ this.#dashboards = dashboards.map((d) => d.manifest)
85
+ this.#createRoutes()
86
+ },
87
+ )
88
+ new UmbExtensionsManifestInitializer(
89
+ this,
90
+ umbExtensionsRegistry,
91
+ 'menuItem',
92
+ (m) => menuOf(m, STRUCTURE_MENU) || menuOf(m, CODE_MENU) || menuOf(m, ADVANCED_MENU),
93
+ (items) => {
94
+ this.#menuItems = items.map((i) => i.manifest)
95
+ this.#refreshLanding()
96
+ },
97
+ )
98
+ new UmbExtensionsManifestInitializer(
99
+ this,
100
+ umbExtensionsRegistry,
101
+ 'sectionRoute',
102
+ null,
103
+ async (extensions) => {
104
+ this.#sectionRoutes = await Promise.all(
105
+ extensions
106
+ .filter((extension) => extension.manifest.element)
107
+ .map(async (extension) => {
108
+ const api = await createExtensionApi(this, extension.manifest)
109
+ if (api) api.manifest = extension.manifest
110
+ return {
111
+ path:
112
+ api?.getPath?.() ||
113
+ extension.manifest.meta?.path ||
114
+ aliasToPath(extension.manifest.alias),
115
+ component: () => createExtensionElement(extension.manifest),
116
+ setup: (element, info) => {
117
+ api?.setup?.(element, info)
118
+ const entityType = info?.match?.params?.entityType
119
+ const tree = treeFor(entityType)
120
+ this.#showing(tree, {
121
+ title: tree ? undefined : advancedToolTitle(this.#advanced(), entityType),
122
+ })
123
+ },
124
+ }
125
+ }),
126
+ )
127
+ this.#createRoutes()
128
+ },
129
+ )
130
+ }
131
+
132
+ #label(manifest) {
133
+ const label = manifest.meta?.label ?? manifest.name ?? manifest.alias
134
+ return this.localize.string(label)
135
+ }
136
+
137
+ #dashboardPath(manifest) {
138
+ return `dashboard/${manifest.meta?.pathname || pathFolderName(manifest.meta?.label ?? manifest.name ?? manifest.alias)}`
139
+ }
140
+
141
+ #cards() {
142
+ return settingsCards({
143
+ dashboards: this.#dashboards.map((d) => ({
144
+ alias: d.alias,
145
+ label: this.#label(d),
146
+ path: this.#dashboardPath(d),
147
+ })),
148
+ advanced: this.#advanced(),
149
+ structure: this.#menuItems.some((m) => menuOf(m, STRUCTURE_MENU)),
150
+ code: this.#menuItems.some((m) => menuOf(m, CODE_MENU)),
151
+ })
152
+ }
153
+
154
+ #refreshLanding() {
155
+ if (this.#landing) this.#landing.groups = this.#cards()
156
+ }
157
+
158
+ /** Which tree shows, and the trail that heads the page. */
159
+ #showing(tree, { title } = {}) {
160
+ this._tree = tree
161
+ this._crumbs = crumbsFor({ tree, title })
162
+ }
163
+
164
+ #advanced() {
165
+ return this.#menuItems
166
+ .filter((m) => menuOf(m, ADVANCED_MENU))
167
+ .map((m) => ({ alias: m.alias, label: this.#label(m), entityType: m.meta?.entityType }))
168
+ }
169
+
170
+ #viewContext(manifest) {
171
+ let context = this.#viewContexts.get(manifest.alias)
172
+ if (!context) {
173
+ context = new UmbViewController(this, manifest.alias)
174
+ context.inherit()
175
+ this.#viewContexts.set(manifest.alias, context)
176
+ }
177
+ context.setTitle(this.#label(manifest))
178
+ return context
179
+ }
180
+
181
+ #createRoutes() {
182
+ const landing = {
183
+ component: () => document.createElement('crombolo-settings-landing'),
184
+ setup: (element) => {
185
+ this.#landing = element
186
+ this.#refreshLanding()
187
+ this.#showing(undefined)
188
+ },
189
+ }
190
+ const tree = (name) => ({
191
+ path: name,
192
+ component: () => document.createElement('crombolo-settings-tree-start'),
193
+ setup: (element) => {
194
+ element.tree = name
195
+ this.#showing(name)
196
+ },
197
+ })
198
+ const dashboards = this.#dashboards.map((manifest) => ({
199
+ path: this.#dashboardPath(manifest),
200
+ component: () => createExtensionElement(manifest),
201
+ setup: (component) => {
202
+ const context = this.#viewContext(manifest)
203
+ if (this.#providedView !== context) this.#providedView?.unprovide()
204
+ if (component) {
205
+ this.#providedView = context
206
+ context.provideAt(component)
207
+ component.manifest = manifest
208
+ }
209
+ this.#showing(undefined, { title: this.#label(manifest) })
210
+ },
211
+ }))
212
+ this._routes = [
213
+ tree('structure'),
214
+ tree('code'),
215
+ // Umbraco's welcome, which this page replaces: an address people have.
216
+ { path: 'dashboard/welcome', ...landing },
217
+ ...dashboards,
218
+ ...this.#sectionRoutes,
219
+ { path: '', pathMatch: 'full', ...landing },
220
+ { path: '**', component: UmbRouteNotFoundElement },
221
+ ]
222
+ }
223
+
224
+ #sectionPath() {
225
+ return `section/${this.manifest?.meta?.pathname ?? 'settings'}`
226
+ }
227
+
228
+ render() {
229
+ const shown = this._tree ? SIDEBAR_APPS[this._tree] : undefined
230
+ const section = this.#sectionPath()
231
+ const crumbs = (this._crumbs ?? []).map((c) => ({
232
+ label: c.label,
233
+ href: c.path === undefined ? undefined : c.path ? `${section}/${c.path}` : section,
234
+ }))
235
+ const main = html`<umb-section-main>
236
+ ${
237
+ crumbs.length > 0
238
+ ? html`<crombolo-breadcrumb class="crumbs" .items=${crumbs}></crombolo-breadcrumb>`
239
+ : nothing
240
+ }
241
+ ${this._routes ? html`<umb-router-slot .routes=${this._routes}></umb-router-slot>` : nothing}
242
+ </umb-section-main>`
243
+ // Both trees stay in the page, the one not in use hidden, as Umbraco's own
244
+ // Settings keeps its menus. A tree taken out and put back breaks: the trees
245
+ // share the section's expansion state, and a detached one still answers it.
246
+ return html`<umb-section-sidebar ?hidden=${!shown}>
247
+ ${(this._sidebarApps ?? []).map(
248
+ (app) => html`<div class="tree" ?hidden=${app.alias !== shown}>${app.component}</div>`,
249
+ )}
250
+ </umb-section-sidebar>
251
+ ${main}`
252
+ }
253
+
254
+ static styles = [
255
+ UmbTextStyles,
256
+ css`
257
+ :host {
258
+ flex: 1 1 auto;
259
+ height: 100%;
260
+ display: flex;
261
+ }
262
+ umb-section-sidebar {
263
+ --umb-section-sidebar-width: 300px;
264
+ }
265
+ umb-section-sidebar[hidden],
266
+ .tree[hidden] {
267
+ display: none;
268
+ }
269
+ umb-section-main {
270
+ flex: 1 1 auto;
271
+ }
272
+ .crumbs {
273
+ display: block;
274
+ padding: var(--uui-size-space-4) var(--uui-size-layout-1) 0;
275
+ }
276
+ `,
277
+ ]
278
+ }
279
+
280
+ /** The landing page: a box of cards per group, and e-mail when it is not set up. */
281
+ export class CromboloSettingsLandingElement extends UmbLitElement {
282
+ static properties = { groups: { attribute: false }, _email: { state: true } }
283
+
284
+ connectedCallback() {
285
+ super.connectedCallback()
286
+ // An explanation, not a control: a failure leaves it out.
287
+ emailStatus().then(
288
+ (status) => {
289
+ this._email = status
290
+ },
291
+ () => {},
292
+ )
293
+ }
294
+
295
+ #email() {
296
+ const status = this._email
297
+ if (!status || status.available) return nothing
298
+ return html`<div class="banner" role="status">
299
+ <uui-icon name="icon-alert"></uui-icon>
300
+ <p>
301
+ <strong>E-mail is not set up.</strong>
302
+ ${status.reason}
303
+ ${
304
+ status.affects?.length > 0
305
+ ? html`Until it is, these are unavailable: ${status.affects.join(', ')}.`
306
+ : nothing
307
+ }
308
+ </p>
309
+ </div>`
310
+ }
311
+
312
+ render() {
313
+ return html`
314
+ ${this.#email()}
315
+ ${(this.groups ?? []).map(
316
+ ({ group, cards }) => html`<section>
317
+ <h2>${group}</h2>
318
+ <div class="cards">
319
+ ${cards.map(
320
+ (card) => html`<a class="card" href=${`section/settings/${card.path}`}>
321
+ <strong>${card.title}</strong>
322
+ ${card.description ? html`<span>${card.description}</span>` : nothing}
323
+ </a>`,
324
+ )}
325
+ </div>
326
+ </section>`,
327
+ )}
328
+ `
329
+ }
330
+
331
+ static styles = [
332
+ UmbTextStyles,
333
+ css`
334
+ :host {
335
+ display: block;
336
+ padding: var(--uui-size-layout-1);
337
+ max-width: 72rem;
338
+ }
339
+ section + section {
340
+ margin-top: var(--uui-size-layout-2);
341
+ }
342
+ h2 {
343
+ font-size: var(--uui-type-h5-size);
344
+ font-weight: 800;
345
+ letter-spacing: -0.01em;
346
+ margin: 0 0 var(--uui-size-space-4);
347
+ }
348
+ .cards {
349
+ display: grid;
350
+ grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
351
+ gap: var(--uui-size-space-5);
352
+ }
353
+ .card {
354
+ display: flex;
355
+ flex-direction: column;
356
+ gap: var(--uui-size-space-2);
357
+ padding: var(--uui-size-space-5);
358
+ background: var(--uui-color-surface);
359
+ border: 1px solid var(--uui-color-border);
360
+ border-radius: 12px;
361
+ box-shadow: var(--crombolo-card-shadow, none);
362
+ color: var(--uui-color-text);
363
+ text-decoration: none;
364
+ }
365
+ .card:hover,
366
+ .card:focus-visible {
367
+ border-color: var(--uui-color-interactive-emphasis);
368
+ }
369
+ .card span {
370
+ color: var(--uui-color-text-alt);
371
+ font-size: var(--uui-type-small-size);
372
+ }
373
+ .banner {
374
+ display: flex;
375
+ gap: var(--uui-size-space-4);
376
+ align-items: flex-start;
377
+ margin-bottom: var(--uui-size-layout-1);
378
+ padding: var(--uui-size-space-4) var(--uui-size-space-5);
379
+ border: 1px solid color-mix(in srgb, var(--uui-color-warning) 45%, transparent);
380
+ border-left-width: 4px;
381
+ border-radius: 8px;
382
+ background: color-mix(in srgb, var(--uui-color-warning) 12%, var(--uui-color-surface));
383
+ color: var(--uui-color-text);
384
+ }
385
+ .banner uui-icon {
386
+ flex: none;
387
+ margin-top: 0.15em;
388
+ color: var(--uui-color-warning-standalone, var(--uui-color-warning));
389
+ }
390
+ .banner p {
391
+ margin: 0;
392
+ line-height: 1.5;
393
+ }
394
+ `,
395
+ ]
396
+ }
397
+
398
+ const TREE_HELP = {
399
+ structure: html`<p>
400
+ Choose a type, data type or language in the tree to edit it.
401
+ </p>
402
+ <p>
403
+ Content types, data types and languages are <strong>files</strong>, in
404
+ <code>schema/</code>, written as TOML. What you change here is written to the file, and the
405
+ file is what a deploy and every other server reads, so a change can be reviewed like code.
406
+ </p>`,
407
+ code: html`<p>Choose a component, stylesheet or script in the tree to edit it.</p>`,
408
+ }
409
+
410
+ /** What Structure or Code shows until something in its tree is chosen. */
411
+ export class CromboloSettingsTreeStartElement extends UmbLitElement {
412
+ static properties = { tree: { attribute: false } }
413
+
414
+ render() {
415
+ return html`<uui-box headline=${this.tree === 'code' ? 'Code' : 'Structure'}
416
+ >${TREE_HELP[this.tree] ?? nothing}</uui-box
417
+ >`
418
+ }
419
+
420
+ static styles = [
421
+ UmbTextStyles,
422
+ css`
423
+ :host {
424
+ display: block;
425
+ padding: var(--uui-size-layout-1);
426
+ max-width: 48rem;
427
+ }
428
+ `,
429
+ ]
430
+ }
431
+
432
+ customElements.define('crombolo-settings-section', CromboloSettingsSectionElement)
433
+ customElements.define('crombolo-settings-landing', CromboloSettingsLandingElement)
434
+ customElements.define('crombolo-settings-tree-start', CromboloSettingsTreeStartElement)
435
+
436
+ export default CromboloSettingsSectionElement
@@ -1,69 +1,17 @@
1
1
  /**
2
2
  * Side panels (story 182): a column beside the back office's main view that an
3
- * extension's `sidePanel` docks into. `umb-backoffice` renders its header, main
4
- * and a slot in a column. This adds the panel host beside main inside the
5
- * shell's shadow root, and a grid stylesheet that puts main and the panel side
6
- * by side under the header. Main is never re-rendered or moved, so its router
7
- * and everything open in it carry on; the panel sits outside the router, so
8
- * moving around keeps it.
9
- *
10
- * When the shell no longer has its header and main as expected, nothing is
11
- * changed: a back office without panels rather than a broken one.
12
- * `tests/side-panel-plugin.test.ts` fails first.
3
+ * extension's `sidePanel` docks into. The shell (`umb-backoffice`, in the fork of
4
+ * Umbraco's client, story 235) renders `<crombolo-side-panel-host>` beside main
5
+ * on a grid under the header; this defines it. It sits outside main's router, so
6
+ * moving around keeps a panel open.
13
7
  */
14
8
  import { UmbElementMixin } from '@umbraco-cms/backoffice/element-api'
15
9
  import { UmbExtensionsElementInitializer } from '@umbraco-cms/backoffice/extension-api'
16
10
  import { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry'
17
11
  import { css, html, LitElement, nothing } from '@umbraco-cms/backoffice/external/lit'
18
- import {
19
- modeFor,
20
- SIDE_PANEL_CONTEXT,
21
- SIDE_PANEL_TYPE,
22
- shellIsAsExpected,
23
- widthForKey,
24
- } from './layout.js'
12
+ import { modeFor, SIDE_PANEL_CONTEXT, SIDE_PANEL_TYPE, widthForKey } from './layout.js'
25
13
  import './toggle.js'
26
14
 
27
- const SHELL_STYLES = css`
28
- :host {
29
- display: grid;
30
- grid-template-columns: minmax(0, 1fr) auto;
31
- grid-template-rows: auto minmax(0, 1fr);
32
- }
33
- umb-backoffice-header {
34
- grid-column: 1 / -1;
35
- }
36
- umb-backoffice-main {
37
- grid-column: 1;
38
- grid-row: 2;
39
- height: 100%;
40
- min-width: 0;
41
- }
42
- crombolo-side-panel-host {
43
- grid-column: 2;
44
- grid-row: 2;
45
- min-height: 0;
46
- }
47
- `
48
-
49
- /** Docks the panel host into a live shell once; true when this call did. */
50
- export function dockInto(shell) {
51
- const root = shell?.shadowRoot
52
- if (!root || root.querySelector('crombolo-side-panel-host')) return false
53
- const children = [...root.children].map((child) => `<${child.localName}`)
54
- // `:scope` matches nothing on a shadow root, so main is found among its children.
55
- const main = [...root.children].find((child) => child.localName === 'umb-backoffice-main')
56
- if (!main || !shellIsAsExpected(children)) {
57
- console.warn('Side panels are off: the back office shell no longer renders as expected.')
58
- return false
59
- }
60
- const sheet = SHELL_STYLES.styleSheet
61
- if (sheet && !root.adoptedStyleSheets.includes(sheet))
62
- root.adoptedStyleSheets = [...root.adoptedStyleSheets, sheet]
63
- main.after(document.createElement('crombolo-side-panel-host'))
64
- return true
65
- }
66
-
67
15
  /** The header toggles registered for panels that asked for one, by panel alias. */
68
16
  const toggles = new Map()
69
17
 
@@ -325,9 +273,5 @@ export class CromboloSidePanelHostElement extends UmbElementMixin(LitElement) {
325
273
 
326
274
  customElements.define('crombolo-side-panel-host', CromboloSidePanelHostElement)
327
275
 
328
- // A back-office entry point's host is the live `umb-backoffice`, rendered by
329
- // the time this module loads; a new shell (after signing in again) runs it again.
330
- export const onInit = async (host) => {
331
- await host?.updateComplete
332
- dockInto(host)
333
- }
276
+ // Loading this module defines the host the shell renders; nothing else to start.
277
+ export const onInit = () => {}
@@ -77,18 +77,3 @@ export function store(userKey, state, storage = globalThis.localStorage) {
77
77
  // Private windows and blocked storage: the panel simply is not remembered.
78
78
  }
79
79
  }
80
-
81
- /** The children `umb-backoffice` renders, in order; the layout patch needs all three. */
82
- export const SHELL = ['<umb-backoffice-header', '<umb-backoffice-main', '<slot']
83
-
84
- /** Whether a rendered template still has the shell's children in order. */
85
- export function shellIsAsExpected(strings) {
86
- const text = Array.isArray(strings) ? strings.join('') : String(strings ?? '')
87
- let at = -1
88
- for (const tag of SHELL) {
89
- const next = text.indexOf(tag, at + 1)
90
- if (next < 0) return false
91
- at = next
92
- }
93
- return true
94
- }
@@ -2,7 +2,7 @@
2
2
  "$schema": "../../../backoffice-dist/dist/umbraco-package-schema.json",
3
3
  "name": "Crombolo Sign-in Dialog",
4
4
  "id": "Crombolo.SignInDialog",
5
- "version": "0.41.1",
5
+ "version": "0.43.1",
6
6
  "allowPublicAccess": true,
7
7
  "extensions": [
8
8
  {