@crombolo/backoffice-host 0.51.1 → 0.52.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/plugin/app-preview/umbraco-package.json +1 -1
- package/plugin/branding/localization-en.js +2 -8
- package/plugin/breadcrumb.js +6 -2
- package/plugin/content-home-dashboard.js +115 -0
- package/plugin/content-strip-items.js +50 -0
- package/plugin/content-strip.js +118 -0
- package/plugin/definition-tree-model.js +43 -0
- package/plugin/definition-tree.js +308 -0
- package/plugin/document-links.js +19 -0
- package/plugin/form-word-input-model.js +45 -0
- package/plugin/form-word-input.js +170 -0
- package/plugin/forms-client.js +21 -2
- package/plugin/forms-entries.js +77 -32
- package/plugin/forms-layout.js +6 -0
- package/plugin/forms-overview.js +200 -42
- package/plugin/localizations/umbraco-package.json +1 -1
- package/plugin/overview-dashboard.js +77 -7
- package/plugin/seo/umbraco-package.json +1 -1
- package/plugin/session-guard-model.js +54 -0
- package/plugin/session-guard.js +50 -0
- package/plugin/settings-cards.js +14 -31
- package/plugin/settings-section.js +103 -15
- package/plugin/sign-in/umbraco-package.json +1 -1
- package/plugin/theme-sync.js +69 -0
- package/plugin/tsx-editors.js +8 -5
- package/plugin/umbraco-package.json +92 -17
- package/plugin/view-parts.js +24 -0
- package/plugin/workflow-client.js +7 -2
- package/plugin/workflow-designer.js +44 -4
- package/src/paths.ts +1 -0
- package/plugin/theme-switch.js +0 -135
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crombolo/backoffice-host",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.52.2",
|
|
4
4
|
"description": "Internal to crombolo, with no compatibility promise: use @crombolo/crombolo. Serves the Umbraco backoffice SPA: shell HTML, import map and package manifests.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Crombolo",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@crombolo/core": "0.
|
|
36
|
-
"@crombolo/backoffice-dist": "0.
|
|
35
|
+
"@crombolo/core": "0.52.2",
|
|
36
|
+
"@crombolo/backoffice-dist": "0.52.2"
|
|
37
37
|
}
|
|
38
38
|
}
|
|
@@ -54,13 +54,6 @@ export default {
|
|
|
54
54
|
general: {
|
|
55
55
|
umbracoInfo: 'Crombolo info',
|
|
56
56
|
},
|
|
57
|
-
buttons: {
|
|
58
|
-
// The accessible name of the header logo button, on every page of the editor.
|
|
59
|
-
// Nothing renders it as visible text, which is why the first sweep through
|
|
60
|
-
// these dictionaries missed it; it surfaced in the accessibility snapshot
|
|
61
|
-
// attached to an unrelated Playwright failure.
|
|
62
|
-
viewSystemDetails: 'View Crombolo system information and version number',
|
|
63
|
-
},
|
|
64
57
|
visuallyHiddenTexts: {
|
|
65
58
|
searchOverlayTitle: 'Search the Crombolo backoffice',
|
|
66
59
|
},
|
|
@@ -92,7 +85,8 @@ export default {
|
|
|
92
85
|
create: {
|
|
93
86
|
// The create options on the Components tree. The folder option is Umbraco's
|
|
94
87
|
// own and already reads correctly.
|
|
95
|
-
newEmptyPartialView: '
|
|
88
|
+
newEmptyPartialView: 'Component',
|
|
89
|
+
newModule: 'Module',
|
|
96
90
|
newPartialViewFromSnippet: 'Component from snippet',
|
|
97
91
|
},
|
|
98
92
|
treeHeaders: {
|
package/plugin/breadcrumb.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Umbraco's own editors show them, given `items` of `{ label, href? }`. The last
|
|
4
4
|
* item is the page itself; an item without `href` is not a link.
|
|
5
5
|
*/
|
|
6
|
-
import { html, ifDefined } from '@umbraco-cms/backoffice/external/lit'
|
|
6
|
+
import { html, ifDefined, repeat } from '@umbraco-cms/backoffice/external/lit'
|
|
7
7
|
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'
|
|
8
8
|
|
|
9
9
|
export class CromboloBreadcrumbElement extends UmbLitElement {
|
|
@@ -17,7 +17,11 @@ export class CromboloBreadcrumbElement extends UmbLitElement {
|
|
|
17
17
|
render() {
|
|
18
18
|
return html`<nav aria-label="Breadcrumb">
|
|
19
19
|
<uui-breadcrumbs>
|
|
20
|
-
${
|
|
20
|
+
${repeat(
|
|
21
|
+
this.items,
|
|
22
|
+
// Keyed on the length: UUI marks the last crumb and never unmarks it, so one
|
|
23
|
+
// kept while the trail grows would stay the page itself and lose its link.
|
|
24
|
+
(_, index) => `${this.items.length}:${index}`,
|
|
21
25
|
(item) =>
|
|
22
26
|
html`<uui-breadcrumb-item href=${ifDefined(item.href)}>${item.label}</uui-breadcrumb-item>`,
|
|
23
27
|
)}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the Content section opens on (story 288): the first page in the tree this
|
|
3
|
+
* user may open, or a word saying there is none. The address is
|
|
4
|
+
* replaced, so the back button leaves the section rather than coming back here.
|
|
5
|
+
*/
|
|
6
|
+
import { UMB_CURRENT_USER_CONTEXT } from '@umbraco-cms/backoffice/current-user'
|
|
7
|
+
import {
|
|
8
|
+
UMB_DOCUMENT_CREATE_OPTIONS_MODAL,
|
|
9
|
+
UmbDocumentTreeRepository,
|
|
10
|
+
} from '@umbraco-cms/backoffice/document'
|
|
11
|
+
import { css, html, nothing } from '@umbraco-cms/backoffice/external/lit'
|
|
12
|
+
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'
|
|
13
|
+
import { umbOpenModal } from '@umbraco-cms/backoffice/modal'
|
|
14
|
+
|
|
15
|
+
const base = () =>
|
|
16
|
+
(document.querySelector('base')?.getAttribute('href') ?? '/umbraco/').replace(/\/$/, '')
|
|
17
|
+
|
|
18
|
+
const here = () => location.pathname.slice(base().length)
|
|
19
|
+
|
|
20
|
+
const CREATE = 'Umb.Document.Create'
|
|
21
|
+
const PAGE = 100
|
|
22
|
+
|
|
23
|
+
export default class CromboloContentHomeDashboardElement extends UmbLitElement {
|
|
24
|
+
static properties = {
|
|
25
|
+
_empty: { state: true },
|
|
26
|
+
_mayCreate: { state: true },
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
constructor() {
|
|
30
|
+
super()
|
|
31
|
+
this.consumeContext(UMB_CURRENT_USER_CONTEXT, (user) => {
|
|
32
|
+
this.observe(user?.currentUser, (current) => {
|
|
33
|
+
this._mayCreate = current?.fallbackPermissions.includes(CREATE) ?? false
|
|
34
|
+
})
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
connectedCallback() {
|
|
39
|
+
super.connectedCallback()
|
|
40
|
+
this.#open()
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The first page this user may open. The tree also lists the pages above their
|
|
45
|
+
* start node, marked `noAccess`, to show where it sits, so those are looked inside.
|
|
46
|
+
*/
|
|
47
|
+
async #firstPage(repository, parent) {
|
|
48
|
+
const page = { skip: 0, take: PAGE }
|
|
49
|
+
const { data } = await (parent
|
|
50
|
+
? repository.requestTreeItemsOf({ ...page, parent })
|
|
51
|
+
: repository.requestTreeRootItems(page))
|
|
52
|
+
const items = data?.items ?? []
|
|
53
|
+
const open = items.find((item) => !item.noAccess)
|
|
54
|
+
if (open) return open
|
|
55
|
+
for (const item of items) {
|
|
56
|
+
if (!item.hasChildren) continue
|
|
57
|
+
const found = await this.#firstPage(repository, {
|
|
58
|
+
unique: item.unique,
|
|
59
|
+
entityType: item.entityType,
|
|
60
|
+
})
|
|
61
|
+
if (found) return found
|
|
62
|
+
}
|
|
63
|
+
return undefined
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async #open() {
|
|
67
|
+
const home = await this.#firstPage(new UmbDocumentTreeRepository(this))
|
|
68
|
+
// Someone may have gone elsewhere from the menu while this was looking.
|
|
69
|
+
if (!this.isConnected || !/^\/section\/content(\/dashboard\/.*|\/)?$/.test(here())) return
|
|
70
|
+
if (!home) {
|
|
71
|
+
this._empty = true
|
|
72
|
+
return
|
|
73
|
+
}
|
|
74
|
+
history.replaceState(
|
|
75
|
+
null,
|
|
76
|
+
'',
|
|
77
|
+
`${base()}/section/content/workspace/document/edit/${home.unique}`,
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
#newPage() {
|
|
82
|
+
umbOpenModal(this, UMB_DOCUMENT_CREATE_OPTIONS_MODAL, {
|
|
83
|
+
data: { parent: { unique: null, entityType: 'document-root' }, documentType: null },
|
|
84
|
+
}).catch(() => undefined)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
render() {
|
|
88
|
+
if (!this._empty) return html`<uui-loader></uui-loader>`
|
|
89
|
+
return html`<uui-box>
|
|
90
|
+
<h2>No pages yet</h2>
|
|
91
|
+
<p>There are no pages here for you to open.</p>
|
|
92
|
+
${
|
|
93
|
+
this._mayCreate
|
|
94
|
+
? html`<uui-button
|
|
95
|
+
look="primary"
|
|
96
|
+
label="New content"
|
|
97
|
+
@click=${() => this.#newPage()}
|
|
98
|
+
></uui-button>`
|
|
99
|
+
: nothing
|
|
100
|
+
}
|
|
101
|
+
</uui-box>`
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
static styles = css`
|
|
105
|
+
:host {
|
|
106
|
+
display: block;
|
|
107
|
+
padding: var(--uui-size-layout-1);
|
|
108
|
+
max-width: 40rem;
|
|
109
|
+
}
|
|
110
|
+
h2 { margin: 0 0 var(--uui-size-space-3); }
|
|
111
|
+
p { margin: 0 0 var(--uui-size-space-5); color: var(--uui-color-text-alt); }
|
|
112
|
+
`
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
customElements.define('crombolo-content-home-dashboard', CromboloContentHomeDashboardElement)
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the menu under Content offers (story 289), and which item a page belongs
|
|
3
|
+
* to. Pure, so each is tested on its own. Structure and Components stay in
|
|
4
|
+
* Settings and forms in their section: the client links to them there, and the
|
|
5
|
+
* menu is what puts them together.
|
|
6
|
+
*/
|
|
7
|
+
import { treeFor } from './settings-cards.js'
|
|
8
|
+
|
|
9
|
+
const SETTINGS = 'Umb.Section.Settings'
|
|
10
|
+
const FORMS = 'Crombolo.Section.Forms'
|
|
11
|
+
const CONTENT = 'Umb.Section.Content'
|
|
12
|
+
|
|
13
|
+
const ITEMS = [
|
|
14
|
+
{ label: 'Pages', path: 'section/content', section: CONTENT },
|
|
15
|
+
{ label: 'Structure', path: 'section/settings/structure', section: SETTINGS },
|
|
16
|
+
{ label: 'Components', path: 'section/settings/code', section: SETTINGS },
|
|
17
|
+
{ label: 'Forms', path: 'section/forms', section: FORMS },
|
|
18
|
+
{ label: 'Workflows', path: 'section/forms/view/workflows', section: FORMS, admin: true },
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The items this user may open. One alone is no menu, so it offers none.
|
|
23
|
+
*
|
|
24
|
+
* @param {{ allowedSections?: string[], isAdmin?: boolean } | undefined} user
|
|
25
|
+
*/
|
|
26
|
+
export function stripItems(user) {
|
|
27
|
+
const allowed = user?.allowedSections ?? []
|
|
28
|
+
const items = ITEMS.filter(
|
|
29
|
+
(item) => allowed.includes(item.section) && (!item.admin || user?.isAdmin === true),
|
|
30
|
+
)
|
|
31
|
+
return items.length > 1 ? items : []
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The item a path below the back office belongs to, or undefined.
|
|
36
|
+
*
|
|
37
|
+
* @param {string} path e.g. `section/settings/workspace/document-type/edit/1`
|
|
38
|
+
*/
|
|
39
|
+
export function activeItem(path) {
|
|
40
|
+
const section = /^section\/([^/]+)(?:\/(.*))?$/.exec(path)
|
|
41
|
+
if (!section) return undefined
|
|
42
|
+
const [, name, rest = ''] = section
|
|
43
|
+
if (name === 'content') return 'Pages'
|
|
44
|
+
if (name === 'forms') return rest.startsWith('view/workflows') ? 'Workflows' : 'Forms'
|
|
45
|
+
if (name !== 'settings') return undefined
|
|
46
|
+
if (rest.startsWith('structure')) return 'Structure'
|
|
47
|
+
if (rest.startsWith('code')) return 'Components'
|
|
48
|
+
const tree = treeFor(/^workspace\/([^/]+)/.exec(rest)?.[1])
|
|
49
|
+
return tree === 'structure' ? 'Structure' : tree === 'code' ? 'Components' : undefined
|
|
50
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The menu under Content (story 289): Pages, Structure, Components, Forms and
|
|
3
|
+
* Workflows, for whoever may open them. A row of its own under the header, shown
|
|
4
|
+
* wherever one of them is open, and it keeps Content's tab marked while it shows.
|
|
5
|
+
*/
|
|
6
|
+
import { UMB_CURRENT_USER_CONTEXT } from '@umbraco-cms/backoffice/current-user'
|
|
7
|
+
import { css, html, nothing } from '@umbraco-cms/backoffice/external/lit'
|
|
8
|
+
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'
|
|
9
|
+
import { activeItem, stripItems } from './content-strip-items.js'
|
|
10
|
+
|
|
11
|
+
const CONTENT = 'Umb.Section.Content'
|
|
12
|
+
const ROW_HEIGHT = '--crombolo-content-strip-height'
|
|
13
|
+
|
|
14
|
+
const pathHere = () => {
|
|
15
|
+
const base = new URL(document.baseURI).pathname
|
|
16
|
+
return location.pathname.startsWith(base) ? location.pathname.slice(base.length) : ''
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const mark = (section) =>
|
|
20
|
+
window.dispatchEvent(new CustomEvent('crombolo:mark-section', { detail: section }))
|
|
21
|
+
|
|
22
|
+
export default class CromboloContentStripElement extends UmbLitElement {
|
|
23
|
+
static properties = {
|
|
24
|
+
_items: { state: true },
|
|
25
|
+
_active: { state: true },
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
#follow = () => {
|
|
29
|
+
this._active = activeItem(pathHere())
|
|
30
|
+
this.#sync()
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** The header marks Content, and the back office makes room, only while the row shows. */
|
|
34
|
+
#sync() {
|
|
35
|
+
const shown = this.#shown()
|
|
36
|
+
mark(shown ? CONTENT : undefined)
|
|
37
|
+
if (shown) document.documentElement.style.setProperty(ROW_HEIGHT, '41px')
|
|
38
|
+
else document.documentElement.style.removeProperty(ROW_HEIGHT)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
#shown() {
|
|
42
|
+
return this._items.length > 0 && this._active !== undefined
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
constructor() {
|
|
46
|
+
super()
|
|
47
|
+
this._items = []
|
|
48
|
+
this.consumeContext(UMB_CURRENT_USER_CONTEXT, (user) => {
|
|
49
|
+
this.observe(user?.currentUser, (current) => {
|
|
50
|
+
this._items = stripItems(current)
|
|
51
|
+
this.#sync()
|
|
52
|
+
})
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
connectedCallback() {
|
|
57
|
+
super.connectedCallback()
|
|
58
|
+
this.#follow()
|
|
59
|
+
window.addEventListener('changestate', this.#follow)
|
|
60
|
+
window.addEventListener('popstate', this.#follow)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
disconnectedCallback() {
|
|
64
|
+
super.disconnectedCallback()
|
|
65
|
+
window.removeEventListener('changestate', this.#follow)
|
|
66
|
+
window.removeEventListener('popstate', this.#follow)
|
|
67
|
+
mark(undefined)
|
|
68
|
+
document.documentElement.style.removeProperty(ROW_HEIGHT)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
render() {
|
|
72
|
+
if (!this.#shown()) return nothing
|
|
73
|
+
return html`<nav aria-label="Content">
|
|
74
|
+
${this._items.map(
|
|
75
|
+
(item) =>
|
|
76
|
+
html`<a
|
|
77
|
+
href=${new URL(item.path, document.baseURI).pathname}
|
|
78
|
+
aria-current=${item.label === this._active ? 'page' : 'false'}
|
|
79
|
+
>${item.label}</a
|
|
80
|
+
>`,
|
|
81
|
+
)}
|
|
82
|
+
</nav>`
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
static styles = css`
|
|
86
|
+
nav {
|
|
87
|
+
box-sizing: border-box;
|
|
88
|
+
display: flex;
|
|
89
|
+
align-items: center;
|
|
90
|
+
gap: var(--uui-size-space-2);
|
|
91
|
+
height: 41px;
|
|
92
|
+
padding: 0 var(--uui-size-space-5);
|
|
93
|
+
overflow-x: auto;
|
|
94
|
+
background: var(--uui-color-surface);
|
|
95
|
+
border-bottom: 1px solid var(--uui-color-border);
|
|
96
|
+
}
|
|
97
|
+
a {
|
|
98
|
+
padding: var(--uui-size-space-1) var(--uui-size-space-3);
|
|
99
|
+
white-space: nowrap;
|
|
100
|
+
border-radius: var(--uui-border-radius);
|
|
101
|
+
color: var(--uui-color-text);
|
|
102
|
+
font-size: var(--uui-type-small-size);
|
|
103
|
+
text-decoration: none;
|
|
104
|
+
}
|
|
105
|
+
a:hover {
|
|
106
|
+
background: var(--uui-color-surface-emphasis);
|
|
107
|
+
}
|
|
108
|
+
a[aria-current='page'] {
|
|
109
|
+
background: var(--crombolo-terracotta-tint, var(--uui-color-surface-alt));
|
|
110
|
+
font-weight: 700;
|
|
111
|
+
}
|
|
112
|
+
`
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
customElements.define('crombolo-content-strip', CromboloContentStripElement)
|
|
116
|
+
|
|
117
|
+
/** Loaded on its own so that the element the header draws is defined. */
|
|
118
|
+
export const onInit = () => {}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Forms and workflows as a tree (story 289): folders from their paths, each
|
|
3
|
+
* with its folders and its items. Pure, so it is tested on its own.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const byName = (a, b) => a.name.localeCompare(b.name)
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @param {{ alias: string, name: string, folder?: string }[]} items
|
|
10
|
+
* @param {string[]} folders every folder as `a/b`, empty ones included
|
|
11
|
+
* @returns {{ name: string, path: string, folders: any[], items: any[] }}
|
|
12
|
+
*/
|
|
13
|
+
export function definitionTree(items, folders) {
|
|
14
|
+
const root = { name: '', path: '', folders: [], items: [] }
|
|
15
|
+
const nodes = new Map([['', root]])
|
|
16
|
+
const nodeFor = (path) => {
|
|
17
|
+
const found = nodes.get(path)
|
|
18
|
+
if (found) return found
|
|
19
|
+
const slash = path.lastIndexOf('/')
|
|
20
|
+
const parent = nodeFor(slash === -1 ? '' : path.slice(0, slash))
|
|
21
|
+
const node = { name: path.slice(slash + 1), path, folders: [], items: [] }
|
|
22
|
+
parent.folders.push(node)
|
|
23
|
+
nodes.set(path, node)
|
|
24
|
+
return node
|
|
25
|
+
}
|
|
26
|
+
for (const folder of folders) nodeFor(folder)
|
|
27
|
+
for (const item of items) nodeFor(item.folder ?? '').items.push(item)
|
|
28
|
+
const sort = (node) => {
|
|
29
|
+
node.folders.sort(byName)
|
|
30
|
+
node.items.sort(byName)
|
|
31
|
+
node.folders.forEach(sort)
|
|
32
|
+
}
|
|
33
|
+
sort(root)
|
|
34
|
+
return root
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Why a kind cannot be changed here, in words for the person reading it, or undefined. */
|
|
38
|
+
export function readOnlyWords(kind, because) {
|
|
39
|
+
if (because === 'site')
|
|
40
|
+
return `${kind} are kept with this site's files, so they can't be changed here. To change one, edit it in the site's code and deploy it.`
|
|
41
|
+
if (because === 'permission') return `Only administrators can change ${kind.toLowerCase()}.`
|
|
42
|
+
return undefined
|
|
43
|
+
}
|