@crombolo/backoffice-host 0.40.0 → 0.42.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/package.json +3 -3
  2. package/plugin/addresses-dashboard.js +3 -2
  3. package/plugin/app-preview/umbraco-package.json +1 -1
  4. package/plugin/audit-dashboard.js +3 -2
  5. package/plugin/branding/localization-en.js +9 -3
  6. package/plugin/branding/sign-in.js +0 -31
  7. package/plugin/bundle-editor-code.js +2 -0
  8. package/plugin/bundle-editor-content.js +2 -0
  9. package/plugin/bundle-editor-context.js +95 -0
  10. package/plugin/bundle-editor-forms.js +2 -0
  11. package/plugin/bundle-editor-language.js +2 -0
  12. package/plugin/bundle-editor-routing.js +13 -0
  13. package/plugin/bundle-editor-sections.js +389 -0
  14. package/plugin/bundle-editor-types.js +2 -0
  15. package/plugin/bundle-editor-user-groups.js +2 -0
  16. package/plugin/bundle-editor-workflows.js +2 -0
  17. package/plugin/bundle-editor.js +140 -0
  18. package/plugin/bundles-client.js +12 -0
  19. package/plugin/bundles-created.js +2 -1
  20. package/plugin/changes-dashboard.js +3 -2
  21. package/plugin/edit-conflicts.js +11 -21
  22. package/plugin/jobs-dashboard.js +3 -2
  23. package/plugin/localizations/umbraco-package.json +1 -1
  24. package/plugin/notifications-dialog.js +8 -35
  25. package/plugin/seo/umbraco-package.json +1 -1
  26. package/plugin/side-panel/host.js +7 -63
  27. package/plugin/side-panel/layout.js +0 -15
  28. package/plugin/sign-in/umbraco-package.json +1 -1
  29. package/plugin/tsx-editors.js +56 -164
  30. package/plugin/umbraco-package.json +138 -32
  31. package/plugin/branding/branding.js +0 -188
  32. package/plugin/branding/bundle-builder-labels.js +0 -92
  33. package/plugin/branding/client-credentials.js +0 -49
  34. package/plugin/branding/log-viewer-menu.js +0 -70
  35. package/plugin/branding/query-builder.js +0 -28
@@ -0,0 +1,140 @@
1
+ /**
2
+ * The Bundle Editor (story 233), in place of Umbraco's package builder: its
3
+ * manifest declares `overwrites: ['Umb.Workspace.PackageBuilder']`, so the
4
+ * Created view's routes open this one. Umbraco's builder draws its form as the
5
+ * workspace editor's default content, which no added tab can sit beside; here
6
+ * every part of the bundle is a workspace view, so another tab is one more
7
+ * registration (docs/bundles.md, "Created packages").
8
+ */
9
+ import { UmbContextBase } from '@umbraco-cms/backoffice/class-api'
10
+ import { css, html, ifDefined, nothing } from '@umbraco-cms/backoffice/external/lit'
11
+ import { UmbLitElement, umbFocus } from '@umbraco-cms/backoffice/lit-element'
12
+ import { UMB_NOTIFICATION_CONTEXT } from '@umbraco-cms/backoffice/notification'
13
+ import { UmbTextStyles } from '@umbraco-cms/backoffice/style'
14
+ import { UMB_WORKSPACE_CONTEXT } from '@umbraco-cms/backoffice/workspace'
15
+ import { CromboloBundleEditorContext } from './bundle-editor-context.js'
16
+ import { BUNDLE_EDITOR_ALIAS } from './bundle-editor-routing.js'
17
+
18
+ /** The workspace this is, as the views' conditions and Umbraco's workspace editor read it. */
19
+ class CromboloBundleWorkspaceContext extends UmbContextBase {
20
+ workspaceAlias = BUNDLE_EDITOR_ALIAS
21
+ #unique
22
+
23
+ constructor(host, unique) {
24
+ super(host, UMB_WORKSPACE_CONTEXT)
25
+ this.#unique = unique
26
+ }
27
+
28
+ getEntityType() {
29
+ return 'package-builder'
30
+ }
31
+
32
+ getUnique() {
33
+ return this.#unique()
34
+ }
35
+ }
36
+
37
+ export default class CromboloBundleEditorElement extends UmbLitElement {
38
+ static properties = {
39
+ entityUnique: { type: String },
40
+ _definition: { state: true },
41
+ _submitState: { state: true },
42
+ }
43
+
44
+ #context = new CromboloBundleEditorContext(this)
45
+ #notifications
46
+
47
+ constructor() {
48
+ super()
49
+ // What a workspace view's `Umb.Condition.WorkspaceAlias` reads, so the tabs
50
+ // registered for this workspace are shown.
51
+ new CromboloBundleWorkspaceContext(this, () => this.#context.value?.unique)
52
+ this.consumeContext(UMB_NOTIFICATION_CONTEXT, (context) => {
53
+ this.#notifications = context
54
+ })
55
+ this.observe(this.#context.definition, (definition) => {
56
+ this._definition = definition
57
+ })
58
+ }
59
+
60
+ connectedCallback() {
61
+ super.connectedCallback()
62
+ void this.#context.load(this.entityUnique)
63
+ }
64
+
65
+ async #save() {
66
+ if (!this._definition?.name?.trim()) {
67
+ this.#notifications?.peek('danger', { data: { message: 'Give the bundle a name first' } })
68
+ return
69
+ }
70
+ const created = !this._definition.unique
71
+ this._submitState = 'waiting'
72
+ try {
73
+ const unique = await this.#context.save()
74
+ if (!unique) throw new Error('not saved')
75
+ this._submitState = 'success'
76
+ this.#notifications?.peek('positive', {
77
+ data: { message: created ? 'Bundle created' : 'Bundle saved' },
78
+ })
79
+ } catch {
80
+ this._submitState = 'failed'
81
+ }
82
+ }
83
+
84
+ render() {
85
+ return html`
86
+ <umb-workspace-editor back-path="section/packages/view/created">
87
+ ${
88
+ this._definition
89
+ ? html`<div id="header" slot="header">
90
+ <uui-input
91
+ id="name"
92
+ required
93
+ label="Name of the bundle"
94
+ placeholder="Enter a name"
95
+ ${umbFocus()}
96
+ .value=${this._definition.name ?? ''}
97
+ @input=${(event) => this.#context.update({ name: event.target.value })}></uui-input>
98
+ </div>`
99
+ : nothing
100
+ }
101
+ <div slot="actions">
102
+ ${
103
+ this._definition?.unique
104
+ ? html`<uui-button
105
+ look="secondary"
106
+ label="Download"
107
+ @click=${() => this.#context.download()}></uui-button>`
108
+ : nothing
109
+ }
110
+ <uui-button
111
+ color="positive"
112
+ look="primary"
113
+ state=${ifDefined(this._submitState)}
114
+ label=${this._definition?.unique ? 'Save' : 'Create'}
115
+ @click=${this.#save}></uui-button>
116
+ </div>
117
+ </umb-workspace-editor>
118
+ `
119
+ }
120
+
121
+ static styles = [
122
+ UmbTextStyles,
123
+ css`
124
+ :host {
125
+ display: block;
126
+ height: 100%;
127
+ }
128
+ #header {
129
+ display: flex;
130
+ width: 100%;
131
+ margin-right: var(--uui-size-layout-1);
132
+ }
133
+ uui-input {
134
+ width: 100%;
135
+ }
136
+ `,
137
+ ]
138
+ }
139
+
140
+ customElements.define('crombolo-bundle-editor', CromboloBundleEditorElement)
@@ -59,3 +59,15 @@ export const readCreatedPackage = (id) => json(`/created/${encodeURIComponent(id
59
59
 
60
60
  export const saveCreatedPackage = (id, pkg) =>
61
61
  json(`/created/${encodeURIComponent(id)}/package`, { method: 'PUT', body: JSON.stringify(pkg) })
62
+
63
+ /** The site's forms, approval workflows and user groups a created bundle can carry (story 226). */
64
+ export const schemaChoices = () => json('/schema')
65
+
66
+ /** What a set of picks carries: the picks, and what they bring. */
67
+ export const carriedSchema = (picks) =>
68
+ json('/schema/carried', { method: 'POST', body: JSON.stringify(picks) })
69
+
70
+ export const readSchemaPicks = (id) => json(`/created/${encodeURIComponent(id)}/schema`)
71
+
72
+ export const saveSchemaPicks = (id, picks) =>
73
+ json(`/created/${encodeURIComponent(id)}/schema`, { method: 'PUT', body: JSON.stringify(picks) })
@@ -14,6 +14,7 @@ import { createExtensionElement } from '@umbraco-cms/backoffice/extension-api'
14
14
  import { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry'
15
15
  import { html } from '@umbraco-cms/backoffice/external/lit'
16
16
  import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'
17
+ import { editorsOf } from './bundle-editor-routing.js'
17
18
 
18
19
  /** The entity type Umbraco's builder workspace declares, and the route segment. */
19
20
  export const BUILDER_ENTITY_TYPE = 'package-builder'
@@ -46,7 +47,7 @@ export default class CromboloBundlesCreatedElement extends UmbLitElement {
46
47
  /** Umbraco's own route table, with our overview in place of its own. */
47
48
  export function routesFor(workspaces) {
48
49
  const routes = [{ path: 'overview', component: () => import('./bundles-created-overview.js') }]
49
- for (const workspace of workspaces) {
50
+ for (const workspace of editorsOf(workspaces)) {
50
51
  routes.push({
51
52
  path: `${workspace.meta.entityType}/edit/:unique`,
52
53
  component: () => createExtensionElement(workspace),
@@ -14,7 +14,8 @@
14
14
  * by those allowed to install packages: each finding offers the answers its
15
15
  * kind allows, and the import runs once nothing is outstanding.
16
16
  */
17
- import { css, html, LitElement, nothing } from '@umbraco-cms/backoffice/external/lit'
17
+ import { css, html, nothing } from '@umbraco-cms/backoffice/external/lit'
18
+ import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'
18
19
  import { downloadFile } from './download.js'
19
20
  import { answersUrl, fetchReport, transferAction } from './report-client.js'
20
21
 
@@ -32,7 +33,7 @@ const ANSWERED_LABEL = {
32
33
  skip: 'is left out',
33
34
  }
34
35
 
35
- export default class CromboloChangesDashboardElement extends LitElement {
36
+ export default class CromboloChangesDashboardElement extends UmbLitElement {
36
37
  static properties = {
37
38
  _report: { state: true },
38
39
  _error: { state: true },
@@ -92,37 +92,27 @@ export const CONFLICT_BANNER = {
92
92
  }
93
93
 
94
94
  /**
95
- * Wraps a workspace's `load` and `reload` so the tracker knows the page's read
96
- * is the editor's own. Patched on the shared base class, for documents only.
95
+ * What the fork's `onEntityLoad` seam calls as an editor reads its entity: for a
96
+ * page, the tracker knows the read is the editor's own until it ends.
97
97
  */
98
- export function watchLoads(base, revisions = tracker) {
99
- for (const method of ['load', 'reload']) {
100
- const original = base.prototype[method]
101
- if (typeof original !== 'function' || original.cromboloRevisions) continue
102
- const wrapped = async function (unique) {
103
- const key = String(unique ?? this.getUnique?.() ?? '').toLowerCase()
104
- if (this.getEntityType?.() !== 'document' || !key) return original.call(this, unique)
105
- revisions.beginLoad(key)
106
- try {
107
- return await original.call(this, unique)
108
- } finally {
109
- revisions.endLoad(key)
110
- }
111
- }
112
- wrapped.cromboloRevisions = true
113
- base.prototype[method] = wrapped
98
+ export function entityLoads(revisions = tracker) {
99
+ return (entityType, unique) => {
100
+ const key = String(unique ?? '').toLowerCase()
101
+ if (entityType !== 'document' || !key) return undefined
102
+ revisions.beginLoad(key)
103
+ return () => revisions.endLoad(key)
114
104
  }
115
105
  }
116
106
 
117
107
  export const onInit = async (_host, extensionRegistry) => {
118
- const [{ umbHttpClient }, { UmbEntityDetailWorkspaceContextBase }] = await Promise.all([
108
+ const [{ umbHttpClient }, { umbCromboloHooks }] = await Promise.all([
119
109
  import('@umbraco-cms/backoffice/http-client'),
120
- import('@umbraco-cms/backoffice/workspace'),
110
+ import('@umbraco-cms/backoffice/extension-registry'),
121
111
  ])
122
112
  umbHttpClient.interceptors.request.use((request) => tracker.onRequest(request))
123
113
  umbHttpClient.interceptors.response.use((response, request) =>
124
114
  tracker.onResponse(response, request),
125
115
  )
126
- watchLoads(UmbEntityDetailWorkspaceContextBase)
116
+ umbCromboloHooks.onEntityLoad = entityLoads()
127
117
  extensionRegistry.register(CONFLICT_BANNER)
128
118
  }
@@ -3,7 +3,8 @@
3
3
  * bundles' jobs, newest first, filtered by state, each with how far it got and
4
4
  * why it failed, and a failed one run again by hand.
5
5
  */
6
- import { css, html, LitElement, nothing } from '@umbraco-cms/backoffice/external/lit'
6
+ import { css, html, nothing } from '@umbraco-cms/backoffice/external/lit'
7
+ import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'
7
8
 
8
9
  const PAGE_SIZE = 50
9
10
 
@@ -45,7 +46,7 @@ function progressOf(job) {
45
46
  return p.note ? `${count}: ${p.note}` : count
46
47
  }
47
48
 
48
- export default class CromboloJobsDashboardElement extends LitElement {
49
+ export default class CromboloJobsDashboardElement extends UmbLitElement {
49
50
  static properties = {
50
51
  _items: { state: true },
51
52
  _total: { state: true },
@@ -2,7 +2,7 @@
2
2
  "$schema": "../../../backoffice-dist/dist/umbraco-package-schema.json",
3
3
  "name": "Crombolo Localizations",
4
4
  "id": "Crombolo.Localizations",
5
- "version": "0.40.0",
5
+ "version": "0.42.1",
6
6
  "allowPublicAccess": true,
7
7
  "extensions": [
8
8
  {
@@ -1,17 +1,10 @@
1
1
  /**
2
2
  * Umbraco's notifications dialog, on a site that cannot send e-mail (story
3
3
  * 045): a banner saying so, and every toggle disabled, rather than choices
4
- * saved for e-mails that never come.
5
- *
6
- * The dialog is not an extension point and its class is not exported, so it is
7
- * patched rather than replaced, as the log viewer's menu is: once the element
8
- * is defined, each update disables its toggles and Save and puts the banner
9
- * above them. `tests/notifications-dialog.test.ts` pins the vendored dialog
10
- * this relies on, so a re-vendor that moves it fails the suite rather than the
11
- * editor. The server refuses a new subscription regardless.
4
+ * saved for e-mails that never come. The dialog asks the fork's
5
+ * `notificationsUnavailable` seam, which this answers. The server refuses a new
6
+ * subscription regardless.
12
7
  */
13
- const TAG = 'umb-document-notifications-modal'
14
- export const BANNER_CLASS = 'crombolo-notifications-unavailable'
15
8
  export const UNAVAILABLE =
16
9
  "This site can't send e-mail yet, so it can't tell you when this page changes. Ask an administrator to set up e-mail, then come back to choose what to hear about."
17
10
 
@@ -31,32 +24,12 @@ export function canSendNotifications(fetcher = fetch) {
31
24
  return answer
32
25
  }
33
26
 
34
- /** Disables the dialog's choices and says why. Safe to call on every update. */
35
- export function markUnavailable(root, message = UNAVAILABLE) {
36
- for (const toggle of root.querySelectorAll('uui-toggle')) toggle.disabled = true
37
- for (const button of root.querySelectorAll('uui-button[color="positive"]')) button.disabled = true
38
- const box = root.querySelector('uui-box')
39
- if (!box || box.querySelector(`.${BANNER_CLASS}`)) return
40
- const banner = box.ownerDocument.createElement('p')
41
- banner.className = BANNER_CLASS
42
- banner.setAttribute('role', 'status')
43
- banner.setAttribute(
44
- 'style',
45
- 'margin: 0 0 var(--uui-size-space-4); color: var(--uui-color-text-alt);',
46
- )
47
- banner.textContent = message
48
- box.prepend(banner)
27
+ /** Why the dialog's choices are off, or undefined when this site can send them. */
28
+ export async function notificationsUnavailable(fetcher = fetch) {
29
+ return (await canSendNotifications(fetcher)) ? undefined : UNAVAILABLE
49
30
  }
50
31
 
51
32
  export const onInit = async () => {
52
- // The dialog is loaded the first time someone opens it.
53
- const element = await customElements.whenDefined(TAG)
54
- const prototype = element.prototype
55
- const original = prototype.updated
56
- prototype.updated = function patched(changed) {
57
- original?.call(this, changed)
58
- void canSendNotifications().then((ok) => {
59
- if (!ok && this.renderRoot) markUnavailable(this.renderRoot)
60
- })
61
- }
33
+ const { umbCromboloHooks } = await import('@umbraco-cms/backoffice/extension-registry')
34
+ umbCromboloHooks.notificationsUnavailable = () => notificationsUnavailable()
62
35
  }
@@ -2,7 +2,7 @@
2
2
  "$schema": "../../../backoffice-dist/dist/umbraco-package-schema.json",
3
3
  "name": "Crombolo Search & sharing",
4
4
  "id": "Crombolo.Seo",
5
- "version": "0.40.0",
5
+ "version": "0.42.1",
6
6
  "allowPublicAccess": false,
7
7
  "extensions": [
8
8
  {
@@ -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.40.0",
5
+ "version": "0.42.1",
6
6
  "allowPublicAccess": true,
7
7
  "extensions": [
8
8
  {