@crombolo/backoffice-host 0.60.0 → 0.61.0
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 +1 -2
- package/plugin/bundles-activity-words.js +72 -0
- package/plugin/bundles-activity.js +171 -0
- package/plugin/bundles-client.js +30 -6
- package/plugin/bundles-installed.js +179 -69
- package/plugin/bundles-level-words.js +79 -0
- package/plugin/bundles-level.js +91 -0
- package/plugin/bundles-marketplace.js +64 -84
- package/plugin/content-strip-items.js +5 -13
- package/plugin/extension-screen-model.js +124 -0
- package/plugin/extension-screen.js +551 -0
- package/plugin/localizations/umbraco-package.json +1 -1
- package/plugin/seo/umbraco-package.json +1 -1
- package/plugin/settings-section.js +1 -31
- package/plugin/sign-in/umbraco-package.json +1 -1
- package/plugin/template-picker.js +3 -3
- package/plugin/umbraco-package.json +4 -34
- package/src/bundle-package.ts +105 -13
- package/src/bundle-permissions.ts +152 -6
- package/src/extension-roots.ts +128 -0
- package/src/extensions.ts +24 -1
- package/src/index.ts +1 -0
- package/src/manifests.ts +12 -1
- package/src/registry.ts +1 -0
- package/plugin/bundles-backoffice-code-words.js +0 -34
- package/plugin/bundles-backoffice-code.js +0 -51
|
@@ -0,0 +1,551 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Draws a screen an extension describes (story 323), wherever its manifest
|
|
3
|
+
* places one: a workspace, a dashboard, a side panel or an action's dialog.
|
|
4
|
+
*
|
|
5
|
+
* The extension's server half answers a tree from a small catalogue, and this
|
|
6
|
+
* element renders it with the back office's own components. Every string the
|
|
7
|
+
* extension supplies is set as text and every link checked, so nothing of the
|
|
8
|
+
* extension's runs here. Typing stays in the browser; a button, a row's action
|
|
9
|
+
* or a search is one call, answered with the next screen. docs/extensions.md,
|
|
10
|
+
* "Screens".
|
|
11
|
+
*/
|
|
12
|
+
// For their side effects: the layout and the three pickers are defined in
|
|
13
|
+
// chunks the shell loads lazily.
|
|
14
|
+
import '@umbraco-cms/backoffice/components'
|
|
15
|
+
import '@umbraco-cms/backoffice/document'
|
|
16
|
+
import '@umbraco-cms/backoffice/media'
|
|
17
|
+
import '@umbraco-cms/backoffice/member'
|
|
18
|
+
import { css, html, nothing, repeat } from '@umbraco-cms/backoffice/external/lit'
|
|
19
|
+
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'
|
|
20
|
+
import { umbConfirmModal } from '@umbraco-cms/backoffice/modal'
|
|
21
|
+
import {
|
|
22
|
+
actionBody,
|
|
23
|
+
fieldProblems,
|
|
24
|
+
hintsFor,
|
|
25
|
+
linkTarget,
|
|
26
|
+
screenUrl,
|
|
27
|
+
sentValues,
|
|
28
|
+
visibleFields,
|
|
29
|
+
} from './extension-screen-model.js'
|
|
30
|
+
|
|
31
|
+
const backOfficeBase = () => document.querySelector('base')?.getAttribute('href') ?? '/umbraco/'
|
|
32
|
+
|
|
33
|
+
const LOOKS = {
|
|
34
|
+
primary: { look: 'primary', color: 'default' },
|
|
35
|
+
secondary: { look: 'secondary', color: 'default' },
|
|
36
|
+
danger: { look: 'primary', color: 'danger' },
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default class CromboloExtensionScreenElement extends UmbLitElement {
|
|
40
|
+
static properties = {
|
|
41
|
+
manifest: { attribute: false },
|
|
42
|
+
_screen: { state: true },
|
|
43
|
+
_loading: { state: true },
|
|
44
|
+
_busy: { state: true },
|
|
45
|
+
_problem: { state: true },
|
|
46
|
+
_notice: { state: true },
|
|
47
|
+
_values: { state: true },
|
|
48
|
+
_fieldProblems: { state: true },
|
|
49
|
+
_tabs: { state: true },
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
constructor() {
|
|
53
|
+
super()
|
|
54
|
+
this._screen = undefined
|
|
55
|
+
this._loading = true
|
|
56
|
+
this._busy = false
|
|
57
|
+
this._problem = ''
|
|
58
|
+
this._notice = ''
|
|
59
|
+
this._state = {}
|
|
60
|
+
/** Each form's values, by the form as the last answer gave it. */
|
|
61
|
+
this._values = new Map()
|
|
62
|
+
this._typed = new Map()
|
|
63
|
+
this._fieldProblems = new Map()
|
|
64
|
+
this._tabs = new Map()
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
connectedCallback() {
|
|
68
|
+
super.connectedCallback()
|
|
69
|
+
this.#call({})
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
get #target() {
|
|
73
|
+
return this.manifest?.meta?.cromboloScreen ?? {}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async #call(body) {
|
|
77
|
+
const { bundle, screen } = this.#target
|
|
78
|
+
if (!bundle || !screen) {
|
|
79
|
+
this._problem = 'This screen does not say which extension draws it.'
|
|
80
|
+
this._loading = false
|
|
81
|
+
return
|
|
82
|
+
}
|
|
83
|
+
this._busy = true
|
|
84
|
+
try {
|
|
85
|
+
const response = await fetch(screenUrl(backOfficeBase(), bundle, screen), {
|
|
86
|
+
method: 'POST',
|
|
87
|
+
credentials: 'include',
|
|
88
|
+
headers: { accept: 'application/json', 'content-type': 'application/json' },
|
|
89
|
+
body: JSON.stringify({ state: this._state, ...body }),
|
|
90
|
+
})
|
|
91
|
+
const answer = await response.json().catch(() => ({}))
|
|
92
|
+
if (!response.ok) {
|
|
93
|
+
this._problem =
|
|
94
|
+
typeof answer?.message === 'string'
|
|
95
|
+
? answer.message
|
|
96
|
+
: `The extension's screen answered ${response.status}.`
|
|
97
|
+
return
|
|
98
|
+
}
|
|
99
|
+
if (typeof answer.problem === 'string') {
|
|
100
|
+
this._problem = answer.problem
|
|
101
|
+
this._notice = ''
|
|
102
|
+
return
|
|
103
|
+
}
|
|
104
|
+
this.#show(answer)
|
|
105
|
+
} catch (error) {
|
|
106
|
+
this._problem = error instanceof Error ? error.message : String(error)
|
|
107
|
+
} finally {
|
|
108
|
+
this._busy = false
|
|
109
|
+
this._loading = false
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
#show(answer) {
|
|
114
|
+
this._screen = answer.screen
|
|
115
|
+
this._state = answer.state ?? this._state
|
|
116
|
+
this._notice = answer.notice ?? ''
|
|
117
|
+
this._problem = ''
|
|
118
|
+
const values = new Map()
|
|
119
|
+
const walk = (nodes) => {
|
|
120
|
+
for (const node of nodes ?? []) {
|
|
121
|
+
if (node.type === 'form') values.set(node, { ...(node.values ?? {}) })
|
|
122
|
+
if (node.type === 'tabs') for (const tab of node.tabs ?? []) walk(tab.body)
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
walk(answer.screen?.body)
|
|
126
|
+
this._values = values
|
|
127
|
+
this._typed = new Map()
|
|
128
|
+
this._fieldProblems = new Map()
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
#set(form, field, value) {
|
|
132
|
+
const next = new Map(this._values)
|
|
133
|
+
next.set(form, { ...(next.get(form) ?? {}), [field.name]: value })
|
|
134
|
+
this._values = next
|
|
135
|
+
if (field.kind === 'secret') {
|
|
136
|
+
const typed = new Set(this._typed.get(form) ?? [])
|
|
137
|
+
typed.add(field.name)
|
|
138
|
+
this._typed.set(form, typed)
|
|
139
|
+
}
|
|
140
|
+
if (this._fieldProblems.get(form)?.[field.name]) {
|
|
141
|
+
const problems = new Map(this._fieldProblems)
|
|
142
|
+
const { [field.name]: _, ...rest } = problems.get(form) ?? {}
|
|
143
|
+
problems.set(form, rest)
|
|
144
|
+
this._fieldProblems = problems
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
async #press(button, form) {
|
|
149
|
+
if (button.disabled || this._busy) return
|
|
150
|
+
let values
|
|
151
|
+
if (button.submit && form) {
|
|
152
|
+
const current = this._values.get(form) ?? {}
|
|
153
|
+
const problems = fieldProblems(form.fields, current)
|
|
154
|
+
if (Object.keys(problems).length > 0) {
|
|
155
|
+
this._fieldProblems = new Map(this._fieldProblems).set(form, problems)
|
|
156
|
+
return
|
|
157
|
+
}
|
|
158
|
+
values = sentValues(form.fields, current, this._typed.get(form))
|
|
159
|
+
}
|
|
160
|
+
if (button.confirm) {
|
|
161
|
+
try {
|
|
162
|
+
await umbConfirmModal(this, {
|
|
163
|
+
color: button.look === 'danger' ? 'danger' : 'default',
|
|
164
|
+
headline: button.label,
|
|
165
|
+
content: button.confirm,
|
|
166
|
+
confirmLabel: button.label,
|
|
167
|
+
})
|
|
168
|
+
} catch {
|
|
169
|
+
return
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
await this.#call(actionBody(button, this._state, values))
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
#button(button, form) {
|
|
176
|
+
const look = LOOKS[button.look ?? 'secondary'] ?? LOOKS.secondary
|
|
177
|
+
return html`<uui-button
|
|
178
|
+
look=${look.look}
|
|
179
|
+
color=${look.color}
|
|
180
|
+
label=${button.label}
|
|
181
|
+
?disabled=${button.disabled || this._busy}
|
|
182
|
+
@click=${() => this.#press(button, form)}></uui-button>`
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
#search(item) {
|
|
186
|
+
return html`<uui-input
|
|
187
|
+
type="search"
|
|
188
|
+
label=${item.placeholder ?? 'Search'}
|
|
189
|
+
placeholder=${item.placeholder ?? ''}
|
|
190
|
+
.value=${item.value ?? ''}
|
|
191
|
+
@change=${(event) =>
|
|
192
|
+
this.#call({
|
|
193
|
+
action: item.action,
|
|
194
|
+
input: { query: event.target.value ?? '' },
|
|
195
|
+
})}></uui-input>`
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
#cell(cell) {
|
|
199
|
+
switch (cell.type) {
|
|
200
|
+
case 'code':
|
|
201
|
+
return html`<code>${cell.text}</code>`
|
|
202
|
+
case 'tag':
|
|
203
|
+
return html`<uui-tag look=${cell.look ?? 'default'} size="s">${cell.text}</uui-tag>`
|
|
204
|
+
case 'link': {
|
|
205
|
+
const href = linkTarget(cell.href, backOfficeBase())
|
|
206
|
+
if (!href) return html`${cell.text}`
|
|
207
|
+
const external = /^https?:/i.test(href)
|
|
208
|
+
return html`<a
|
|
209
|
+
href=${href}
|
|
210
|
+
target=${external ? '_blank' : nothing}
|
|
211
|
+
rel=${external ? 'noopener noreferrer' : nothing}
|
|
212
|
+
>${cell.text}</a
|
|
213
|
+
>`
|
|
214
|
+
}
|
|
215
|
+
case 'date': {
|
|
216
|
+
const at = new Date(cell.value)
|
|
217
|
+
return html`${Number.isNaN(at.getTime()) ? '' : at.toLocaleString()}`
|
|
218
|
+
}
|
|
219
|
+
default:
|
|
220
|
+
return html`${cell.text ?? ''}`
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
#table(node) {
|
|
225
|
+
const actions = node.rows.some((row) => (row.actions ?? []).length > 0)
|
|
226
|
+
return html`<uui-table>
|
|
227
|
+
<uui-table-head>
|
|
228
|
+
${node.columns.map((column) => html`<uui-table-head-cell>${column}</uui-table-head-cell>`)}
|
|
229
|
+
${actions ? html`<uui-table-head-cell></uui-table-head-cell>` : nothing}
|
|
230
|
+
</uui-table-head>
|
|
231
|
+
${repeat(
|
|
232
|
+
node.rows,
|
|
233
|
+
(row) => row.key,
|
|
234
|
+
(row) => html`<uui-table-row>
|
|
235
|
+
${row.cells.map((cell) => html`<uui-table-cell>${this.#cell(cell)}</uui-table-cell>`)}
|
|
236
|
+
${
|
|
237
|
+
actions
|
|
238
|
+
? html`<uui-table-cell class="actions">
|
|
239
|
+
${(row.actions ?? []).map((button) => this.#button(button))}
|
|
240
|
+
</uui-table-cell>`
|
|
241
|
+
: nothing
|
|
242
|
+
}
|
|
243
|
+
</uui-table-row>`,
|
|
244
|
+
)}
|
|
245
|
+
</uui-table>`
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/** A list's rows, each sub-field drawn as its own field, with add and remove (story 329). */
|
|
249
|
+
#list(form, field, value) {
|
|
250
|
+
const rows = Array.isArray(value) ? value : []
|
|
251
|
+
const set = (next) => this.#set(form, field, next)
|
|
252
|
+
const blank = Object.fromEntries(
|
|
253
|
+
field.fields.map((sub) => [
|
|
254
|
+
sub.name,
|
|
255
|
+
sub.kind === 'boolean' ? false : sub.kind === 'number' ? null : '',
|
|
256
|
+
]),
|
|
257
|
+
)
|
|
258
|
+
const canAdd = !field.readOnly && (field.max === undefined || rows.length < field.max)
|
|
259
|
+
const canRemove = !field.readOnly && (field.min === undefined || rows.length > field.min)
|
|
260
|
+
return html`<div class="list">
|
|
261
|
+
${rows.map(
|
|
262
|
+
(row, index) => html`<div class="list-row">
|
|
263
|
+
${field.fields.map((sub) =>
|
|
264
|
+
this.#input(
|
|
265
|
+
form,
|
|
266
|
+
{ ...sub, readOnly: field.readOnly || sub.readOnly },
|
|
267
|
+
row[sub.name],
|
|
268
|
+
(next) =>
|
|
269
|
+
set(
|
|
270
|
+
rows.map((other, at) => (at === index ? { ...other, [sub.name]: next } : other)),
|
|
271
|
+
),
|
|
272
|
+
),
|
|
273
|
+
)}
|
|
274
|
+
${
|
|
275
|
+
canRemove
|
|
276
|
+
? html`<uui-button
|
|
277
|
+
look="secondary"
|
|
278
|
+
compact
|
|
279
|
+
label="Remove"
|
|
280
|
+
@click=${() => set(rows.filter((_, at) => at !== index))}></uui-button>`
|
|
281
|
+
: nothing
|
|
282
|
+
}
|
|
283
|
+
</div>`,
|
|
284
|
+
)}
|
|
285
|
+
${
|
|
286
|
+
canAdd
|
|
287
|
+
? html`<uui-button
|
|
288
|
+
look="secondary"
|
|
289
|
+
label=${field.addLabel ?? 'Add'}
|
|
290
|
+
@click=${() => set([...rows, { ...blank }])}></uui-button>`
|
|
291
|
+
: nothing
|
|
292
|
+
}
|
|
293
|
+
</div>`
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
#input(form, field, value, onChange) {
|
|
297
|
+
const set = onChange ?? ((next) => this.#set(form, field, next))
|
|
298
|
+
const locked = field.readOnly === true
|
|
299
|
+
switch (field.kind) {
|
|
300
|
+
case 'list':
|
|
301
|
+
return this.#list(form, field, value)
|
|
302
|
+
case 'boolean':
|
|
303
|
+
return html`<uui-toggle
|
|
304
|
+
label=${field.label}
|
|
305
|
+
?disabled=${locked}
|
|
306
|
+
.checked=${value === true}
|
|
307
|
+
@change=${(event) => set(event.target.checked === true)}></uui-toggle>`
|
|
308
|
+
case 'choice':
|
|
309
|
+
return html`<uui-select
|
|
310
|
+
label=${field.label}
|
|
311
|
+
?disabled=${locked}
|
|
312
|
+
.options=${(field.options ?? []).map((option) => ({
|
|
313
|
+
value: option.value,
|
|
314
|
+
name: option.label,
|
|
315
|
+
selected: option.value === value,
|
|
316
|
+
}))}
|
|
317
|
+
@change=${(event) => set(event.target.value)}></uui-select>`
|
|
318
|
+
case 'page':
|
|
319
|
+
return html`<umb-input-document
|
|
320
|
+
?readonly=${locked}
|
|
321
|
+
max="1"
|
|
322
|
+
.selection=${value ? [value] : []}
|
|
323
|
+
@change=${(event) => set(event.target.selection?.[0] ?? '')}></umb-input-document>`
|
|
324
|
+
case 'media':
|
|
325
|
+
return html`<umb-input-media
|
|
326
|
+
?readonly=${locked}
|
|
327
|
+
max="1"
|
|
328
|
+
.selection=${value ? [value] : []}
|
|
329
|
+
@change=${(event) => set(event.target.selection?.[0] ?? '')}></umb-input-media>`
|
|
330
|
+
case 'member':
|
|
331
|
+
return html`<umb-input-member
|
|
332
|
+
?readonly=${locked}
|
|
333
|
+
max="1"
|
|
334
|
+
.selection=${value ? [value] : []}
|
|
335
|
+
@change=${(event) => set(event.target.selection?.[0] ?? '')}></umb-input-member>`
|
|
336
|
+
case 'text':
|
|
337
|
+
if (field.multiline)
|
|
338
|
+
return html`<uui-textarea
|
|
339
|
+
label=${field.label}
|
|
340
|
+
?readonly=${locked}
|
|
341
|
+
placeholder=${field.placeholder ?? ''}
|
|
342
|
+
.value=${value ?? ''}
|
|
343
|
+
@input=${(event) => set(event.target.value)}></uui-textarea>`
|
|
344
|
+
break
|
|
345
|
+
}
|
|
346
|
+
return html`<uui-input
|
|
347
|
+
label=${field.label}
|
|
348
|
+
?readonly=${locked}
|
|
349
|
+
type=${field.kind === 'secret' ? 'password' : field.kind === 'number' ? 'number' : 'text'}
|
|
350
|
+
placeholder=${field.placeholder ?? ''}
|
|
351
|
+
.value=${value ?? ''}
|
|
352
|
+
@input=${(event) =>
|
|
353
|
+
set(
|
|
354
|
+
field.kind === 'number' && event.target.value !== ''
|
|
355
|
+
? Number(event.target.value)
|
|
356
|
+
: event.target.value,
|
|
357
|
+
)}></uui-input>`
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
#form(node) {
|
|
361
|
+
const values = this._values.get(node) ?? {}
|
|
362
|
+
const problems = this._fieldProblems.get(node) ?? {}
|
|
363
|
+
return html`<uui-box headline=${node.title ?? nothing}>
|
|
364
|
+
${visibleFields(node.fields, values).map(
|
|
365
|
+
(field) => html`<div class="field">
|
|
366
|
+
<label>${field.label}${field.required ? html`<span class="required">*</span>` : nothing}</label>
|
|
367
|
+
${this.#input(node, field, values[field.name])}
|
|
368
|
+
${hintsFor(field, values).map((hint) => html`<small>${hint}</small>`)}
|
|
369
|
+
${problems[field.name] ? html`<small class="invalid">${problems[field.name]}</small>` : nothing}
|
|
370
|
+
</div>`,
|
|
371
|
+
)}
|
|
372
|
+
<div class="form-actions">${node.actions.map((button) => this.#button(button, node))}</div>
|
|
373
|
+
</uui-box>`
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
#tabs(node) {
|
|
377
|
+
const active = this._tabs.get(node) ?? node.tabs[0]?.id
|
|
378
|
+
const shown = node.tabs.find((tab) => tab.id === active) ?? node.tabs[0]
|
|
379
|
+
return html`<uui-tab-group>
|
|
380
|
+
${node.tabs.map(
|
|
381
|
+
(tab) => html`<uui-tab
|
|
382
|
+
label=${tab.label}
|
|
383
|
+
?active=${tab.id === shown?.id}
|
|
384
|
+
@click=${() => {
|
|
385
|
+
this._tabs = new Map(this._tabs).set(node, tab.id)
|
|
386
|
+
}}>${tab.label}</uui-tab>`,
|
|
387
|
+
)}
|
|
388
|
+
</uui-tab-group>
|
|
389
|
+
<div class="tab">${this.#nodes(shown?.body ?? [])}</div>`
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
#node(node) {
|
|
393
|
+
switch (node.type) {
|
|
394
|
+
case 'table':
|
|
395
|
+
return this.#table(node)
|
|
396
|
+
case 'form':
|
|
397
|
+
return this.#form(node)
|
|
398
|
+
case 'button':
|
|
399
|
+
return html`<div>${this.#button(node)}</div>`
|
|
400
|
+
case 'notice':
|
|
401
|
+
return html`<div class="banner notice">${node.text}</div>`
|
|
402
|
+
case 'problem':
|
|
403
|
+
return html`<div class="banner problem">${node.text}</div>`
|
|
404
|
+
case 'empty':
|
|
405
|
+
return html`<uui-box headline=${node.title}>
|
|
406
|
+
${node.text ? html`<p>${node.text}</p>` : nothing}
|
|
407
|
+
${(node.actions ?? []).map((button) => this.#button(button))}
|
|
408
|
+
</uui-box>`
|
|
409
|
+
case 'progress':
|
|
410
|
+
return html`<div class="progress">
|
|
411
|
+
${node.label ? html`<span>${node.label}</span>` : nothing}
|
|
412
|
+
${
|
|
413
|
+
typeof node.value === 'number'
|
|
414
|
+
? html`<uui-progress-bar progress=${node.value}></uui-progress-bar>`
|
|
415
|
+
: html`<uui-loader-bar></uui-loader-bar>`
|
|
416
|
+
}
|
|
417
|
+
</div>`
|
|
418
|
+
case 'tabs':
|
|
419
|
+
return this.#tabs(node)
|
|
420
|
+
default:
|
|
421
|
+
return nothing
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
#nodes(nodes) {
|
|
426
|
+
return nodes.map((node) => this.#node(node))
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
render() {
|
|
430
|
+
const screen = this._screen
|
|
431
|
+
return html`<umb-body-layout headline=${screen?.title ?? ''}>
|
|
432
|
+
<div id="content">
|
|
433
|
+
${
|
|
434
|
+
(screen?.toolbar ?? []).length > 0
|
|
435
|
+
? html`<div id="toolbar">
|
|
436
|
+
${screen.toolbar.map((item) =>
|
|
437
|
+
item.type === 'search' ? this.#search(item) : this.#button(item),
|
|
438
|
+
)}
|
|
439
|
+
</div>`
|
|
440
|
+
: nothing
|
|
441
|
+
}
|
|
442
|
+
${this._problem ? html`<div class="banner problem">${this._problem}</div>` : nothing}
|
|
443
|
+
${this._notice ? html`<div class="banner notice">${this._notice}</div>` : nothing}
|
|
444
|
+
${
|
|
445
|
+
this._loading
|
|
446
|
+
? html`<div id="loader"><uui-loader></uui-loader></div>`
|
|
447
|
+
: this.#nodes(screen?.body ?? [])
|
|
448
|
+
}
|
|
449
|
+
</div>
|
|
450
|
+
</umb-body-layout>`
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
static styles = css`
|
|
454
|
+
:host {
|
|
455
|
+
display: block;
|
|
456
|
+
width: 100%;
|
|
457
|
+
height: 100%;
|
|
458
|
+
}
|
|
459
|
+
#content {
|
|
460
|
+
padding: var(--uui-size-layout-1, 24px);
|
|
461
|
+
display: flex;
|
|
462
|
+
flex-direction: column;
|
|
463
|
+
gap: var(--uui-size-space-5, 18px);
|
|
464
|
+
}
|
|
465
|
+
#toolbar {
|
|
466
|
+
display: flex;
|
|
467
|
+
align-items: center;
|
|
468
|
+
gap: var(--uui-size-space-4, 12px);
|
|
469
|
+
}
|
|
470
|
+
#toolbar uui-input {
|
|
471
|
+
flex: 1;
|
|
472
|
+
}
|
|
473
|
+
#loader {
|
|
474
|
+
display: flex;
|
|
475
|
+
justify-content: center;
|
|
476
|
+
padding: var(--uui-size-layout-3, 48px);
|
|
477
|
+
}
|
|
478
|
+
.field {
|
|
479
|
+
display: flex;
|
|
480
|
+
flex-direction: column;
|
|
481
|
+
gap: var(--uui-size-space-2, 6px);
|
|
482
|
+
margin-bottom: var(--uui-size-space-5, 18px);
|
|
483
|
+
max-width: 48rem;
|
|
484
|
+
}
|
|
485
|
+
.field label {
|
|
486
|
+
font-weight: bold;
|
|
487
|
+
}
|
|
488
|
+
.field small {
|
|
489
|
+
opacity: 0.8;
|
|
490
|
+
line-height: 1.5;
|
|
491
|
+
}
|
|
492
|
+
.field small.invalid {
|
|
493
|
+
color: var(--uui-color-danger, #d42054);
|
|
494
|
+
opacity: 1;
|
|
495
|
+
}
|
|
496
|
+
.required {
|
|
497
|
+
color: var(--uui-color-danger, #d42054);
|
|
498
|
+
margin-left: 2px;
|
|
499
|
+
}
|
|
500
|
+
.form-actions,
|
|
501
|
+
.actions {
|
|
502
|
+
display: flex;
|
|
503
|
+
gap: var(--uui-size-space-2, 6px);
|
|
504
|
+
}
|
|
505
|
+
.actions {
|
|
506
|
+
justify-content: flex-end;
|
|
507
|
+
}
|
|
508
|
+
.banner {
|
|
509
|
+
padding: var(--uui-size-space-4, 12px);
|
|
510
|
+
border-left: 3px solid var(--uui-color-default, #3544b1);
|
|
511
|
+
background: var(--uui-color-surface-alt, #f3f3f5);
|
|
512
|
+
}
|
|
513
|
+
.banner.problem {
|
|
514
|
+
border-left-color: var(--uui-color-danger, #d42054);
|
|
515
|
+
}
|
|
516
|
+
.banner.notice {
|
|
517
|
+
border-left-color: var(--uui-color-positive, #2bc37c);
|
|
518
|
+
}
|
|
519
|
+
.progress {
|
|
520
|
+
display: flex;
|
|
521
|
+
flex-direction: column;
|
|
522
|
+
gap: var(--uui-size-space-2, 6px);
|
|
523
|
+
}
|
|
524
|
+
.list {
|
|
525
|
+
display: flex;
|
|
526
|
+
flex-direction: column;
|
|
527
|
+
gap: var(--uui-size-space-2, 6px);
|
|
528
|
+
}
|
|
529
|
+
.list-row {
|
|
530
|
+
display: flex;
|
|
531
|
+
gap: var(--uui-size-space-2, 6px);
|
|
532
|
+
align-items: center;
|
|
533
|
+
}
|
|
534
|
+
.tab {
|
|
535
|
+
display: flex;
|
|
536
|
+
flex-direction: column;
|
|
537
|
+
gap: var(--uui-size-space-5, 18px);
|
|
538
|
+
padding-top: var(--uui-size-space-4, 12px);
|
|
539
|
+
}
|
|
540
|
+
code {
|
|
541
|
+
word-break: break-all;
|
|
542
|
+
}
|
|
543
|
+
p {
|
|
544
|
+
max-width: 60ch;
|
|
545
|
+
line-height: 1.5;
|
|
546
|
+
}
|
|
547
|
+
`
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
if (!customElements.get('crombolo-extension-screen'))
|
|
551
|
+
customElements.define('crombolo-extension-screen', CromboloExtensionScreenElement)
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
* manifest.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { UMB_CURRENT_USER_CONTEXT } from '@umbraco-cms/backoffice/current-user'
|
|
10
9
|
import {
|
|
11
10
|
createExtensionApi,
|
|
12
11
|
createExtensionElement,
|
|
@@ -70,12 +69,6 @@ const savePosition = (event) => {
|
|
|
70
69
|
|
|
71
70
|
const menuOf = (manifest, menu) => manifest.meta?.menus?.includes(menu) === true
|
|
72
71
|
|
|
73
|
-
/** Each tree, and the part of Settings that opens it. */
|
|
74
|
-
const TREE_SECTIONS = [
|
|
75
|
-
['structure', 'Crombolo.Section.Structure'],
|
|
76
|
-
['code', 'Crombolo.Section.Components'],
|
|
77
|
-
]
|
|
78
|
-
|
|
79
72
|
export class CromboloSettingsSectionElement extends UmbLitElement {
|
|
80
73
|
static properties = {
|
|
81
74
|
_routes: { state: true },
|
|
@@ -87,8 +80,6 @@ export class CromboloSettingsSectionElement extends UmbLitElement {
|
|
|
87
80
|
}
|
|
88
81
|
|
|
89
82
|
#dashboards = []
|
|
90
|
-
/** The sections the current user holds, which say how much of Settings they have. */
|
|
91
|
-
#held
|
|
92
83
|
#menuItems = []
|
|
93
84
|
#sectionRoutes = []
|
|
94
85
|
#landing
|
|
@@ -97,12 +88,6 @@ export class CromboloSettingsSectionElement extends UmbLitElement {
|
|
|
97
88
|
|
|
98
89
|
constructor() {
|
|
99
90
|
super()
|
|
100
|
-
this.consumeContext(UMB_CURRENT_USER_CONTEXT, (user) => {
|
|
101
|
-
this.observe(user?.currentUser, (current) => {
|
|
102
|
-
this.#held = current?.allowedSections ?? []
|
|
103
|
-
this.#createRoutes()
|
|
104
|
-
})
|
|
105
|
-
})
|
|
106
91
|
// An explanation, not a control: a failure leaves it out.
|
|
107
92
|
fetch(`${base()}/crombolo/api/site-files`, { credentials: 'include' })
|
|
108
93
|
.then((response) => (response.ok ? response.json() : { writable: true }))
|
|
@@ -240,20 +225,9 @@ export class CromboloSettingsSectionElement extends UmbLitElement {
|
|
|
240
225
|
}
|
|
241
226
|
|
|
242
227
|
#createRoutes() {
|
|
243
|
-
// Someone with a part of Settings has its tree, and not the cards or the tools.
|
|
244
|
-
const whole = this.#held?.includes('Crombolo.Section.AllSettings') ?? false
|
|
245
|
-
const mine = TREE_SECTIONS.filter(([, section]) => this.#held?.includes(section)).map(
|
|
246
|
-
([tree]) => tree,
|
|
247
|
-
)
|
|
248
|
-
const toTree = (name) =>
|
|
249
|
-
history.replaceState(null, '', new URL(`section/settings/${name}`, document.baseURI).pathname)
|
|
250
228
|
const landing = {
|
|
251
229
|
component: () => document.createElement('crombolo-settings-landing'),
|
|
252
230
|
setup: (element) => {
|
|
253
|
-
if (this.#held && !whole && mine[0]) {
|
|
254
|
-
toTree(mine[0])
|
|
255
|
-
return
|
|
256
|
-
}
|
|
257
231
|
this.#landing = element
|
|
258
232
|
this.#refreshLanding()
|
|
259
233
|
this.#showing(undefined)
|
|
@@ -263,10 +237,6 @@ export class CromboloSettingsSectionElement extends UmbLitElement {
|
|
|
263
237
|
path: name,
|
|
264
238
|
component: () => document.createElement('crombolo-settings-tree-start'),
|
|
265
239
|
setup: (element) => {
|
|
266
|
-
if (this.#held && !mine.includes(name) && mine[0]) {
|
|
267
|
-
toTree(mine[0])
|
|
268
|
-
return
|
|
269
|
-
}
|
|
270
240
|
element.tree = name
|
|
271
241
|
this.#showing(name)
|
|
272
242
|
},
|
|
@@ -331,7 +301,7 @@ export class CromboloSettingsSectionElement extends UmbLitElement {
|
|
|
331
301
|
)
|
|
332
302
|
},
|
|
333
303
|
},
|
|
334
|
-
...
|
|
304
|
+
...dashboards,
|
|
335
305
|
...this.#sectionRoutes,
|
|
336
306
|
{ path: '', pathMatch: 'full', ...landing },
|
|
337
307
|
{ path: '**', component: UmbRouteNotFoundElement },
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
import { UMB_CURRENT_USER_CONTEXT } from '@umbraco-cms/backoffice/current-user'
|
|
8
8
|
|
|
9
9
|
export const TEMPLATE_PICKER_MODAL = 'Crombolo.Modal.TemplatePicker'
|
|
10
|
-
const
|
|
10
|
+
const SETTINGS = 'Umb.Section.Settings'
|
|
11
11
|
|
|
12
|
-
/** Whether the reader may change a content type:
|
|
12
|
+
/** Whether the reader may change a content type: Settings. */
|
|
13
13
|
async function mayChangeTypes(host) {
|
|
14
14
|
const context = await host.getContext?.(UMB_CURRENT_USER_CONTEXT).catch(() => undefined)
|
|
15
15
|
if (!context) return false
|
|
@@ -19,7 +19,7 @@ async function mayChangeTypes(host) {
|
|
|
19
19
|
queueMicrotask(() => subscription.unsubscribe())
|
|
20
20
|
})
|
|
21
21
|
})
|
|
22
|
-
return user?.isAdmin === true || (user?.allowedSections ?? []).includes(
|
|
22
|
+
return user?.isAdmin === true || (user?.allowedSections ?? []).includes(SETTINGS)
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export const onInit = async (_host, extensionRegistry) => {
|