@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
|
@@ -15,22 +15,26 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { css, html, nothing, repeat } from '@umbraco-cms/backoffice/external/lit'
|
|
17
17
|
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'
|
|
18
|
-
import {
|
|
19
|
-
import { backOfficeCodeWords, splitBackOfficeCode } from './bundles-backoffice-code-words.js'
|
|
18
|
+
import { umbConfirmModal } from '@umbraco-cms/backoffice/modal'
|
|
20
19
|
import { carriesTags } from './bundles-carries.js'
|
|
21
20
|
import {
|
|
22
21
|
disableBundle,
|
|
22
|
+
dropLeftData,
|
|
23
23
|
enableBundle,
|
|
24
24
|
grantBundle,
|
|
25
25
|
listInstalled,
|
|
26
26
|
saveSettings,
|
|
27
27
|
uninstallBundle,
|
|
28
28
|
} from './bundles-client.js'
|
|
29
|
+
import './bundles-activity.js'
|
|
30
|
+
import { levelBlock, levelStyles } from './bundles-level.js'
|
|
31
|
+
import { configSnippet, grantChoice, levelWords, unvouchedLine } from './bundles-level-words.js'
|
|
29
32
|
import { signatureBlock, signatureStyles, signatureWords } from './bundles-signature.js'
|
|
30
33
|
|
|
31
34
|
/** Where each part of a bundle stands on this site, in the words of someone running it. */
|
|
32
35
|
function status(item) {
|
|
33
|
-
|
|
36
|
+
// Story 324: how far it reaches, on every row.
|
|
37
|
+
const parts = [html`<span class="badge">${levelWords(item.level).label}</span>`]
|
|
34
38
|
if (item.carries?.content)
|
|
35
39
|
parts.push(
|
|
36
40
|
item.contentApplied
|
|
@@ -39,7 +43,7 @@ function status(item) {
|
|
|
39
43
|
)
|
|
40
44
|
// Story 309: it runs on its grant. Story 311: and only once it has started.
|
|
41
45
|
if (item.couldNotStart) parts.push(html`<span>Could not start</span>`)
|
|
42
|
-
else if (item.status === 'waiting') parts.push(html`<span>
|
|
46
|
+
else if (item.status === 'waiting') parts.push(html`<span>Off · asks for more</span>`)
|
|
43
47
|
else if (item.status === 'not-granted') parts.push(html`<span>Not granted</span>`)
|
|
44
48
|
else if (item.carries?.server)
|
|
45
49
|
parts.push(
|
|
@@ -49,11 +53,16 @@ function status(item) {
|
|
|
49
53
|
? html`<span>Server features on</span>`
|
|
50
54
|
: html`<span>Server features off until the site's configuration includes it</span>`,
|
|
51
55
|
)
|
|
52
|
-
return parts.length >
|
|
56
|
+
return parts.length > 1 ? parts : [...parts, html`<span>Ready</span>`]
|
|
53
57
|
}
|
|
54
58
|
|
|
55
59
|
export default class CromboloBundlesInstalledElement extends UmbLitElement {
|
|
56
60
|
static properties = {
|
|
61
|
+
_removing: { state: true },
|
|
62
|
+
_dropData: { state: true },
|
|
63
|
+
_dropContent: { state: true },
|
|
64
|
+
_left: { state: true },
|
|
65
|
+
_watching: { state: true },
|
|
57
66
|
_items: { state: true },
|
|
58
67
|
_loading: { state: true },
|
|
59
68
|
_busy: { state: true },
|
|
@@ -63,9 +72,7 @@ export default class CromboloBundlesInstalledElement extends UmbLitElement {
|
|
|
63
72
|
_filter: { state: true },
|
|
64
73
|
_selected: { state: true },
|
|
65
74
|
_policy: { state: true },
|
|
66
|
-
_actAs: { state: true },
|
|
67
75
|
_edits: { state: true },
|
|
68
|
-
_trustsCode: { state: true },
|
|
69
76
|
}
|
|
70
77
|
|
|
71
78
|
constructor() {
|
|
@@ -77,7 +84,6 @@ export default class CromboloBundlesInstalledElement extends UmbLitElement {
|
|
|
77
84
|
this._installs = true
|
|
78
85
|
this._restartPending = false
|
|
79
86
|
this._filter = ''
|
|
80
|
-
this._actAs = 'installer'
|
|
81
87
|
this._edits = {}
|
|
82
88
|
// Settings links a bundle's cards here, naming it in `?bundle=`.
|
|
83
89
|
this._selected =
|
|
@@ -99,6 +105,9 @@ export default class CromboloBundlesInstalledElement extends UmbLitElement {
|
|
|
99
105
|
this._installs = result.installs !== false
|
|
100
106
|
this._restartPending = Boolean(result.restartPending)
|
|
101
107
|
this._policy = result.policy
|
|
108
|
+
this._mayGrant = result.mayGrant ?? {}
|
|
109
|
+
this._left = result.left ?? []
|
|
110
|
+
this._isAdmin = this._mayGrant.limited === 'yes'
|
|
102
111
|
if (!this._items.some((item) => item.packageName === this._selected))
|
|
103
112
|
this._selected = this._items[0]?.packageName ?? ''
|
|
104
113
|
} catch (error) {
|
|
@@ -108,10 +117,21 @@ export default class CromboloBundlesInstalledElement extends UmbLitElement {
|
|
|
108
117
|
}
|
|
109
118
|
}
|
|
110
119
|
|
|
120
|
+
/** Story 328: asked first, its data and the content it added kept unless ticked. */
|
|
111
121
|
async #uninstall(item) {
|
|
122
|
+
this._removing = this._removing === item.packageName ? '' : item.packageName
|
|
123
|
+
this._dropData = false
|
|
124
|
+
this._dropContent = false
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
async #remove(item) {
|
|
112
128
|
this._busy = item.packageName
|
|
113
129
|
try {
|
|
114
|
-
const outcome = await uninstallBundle(item.packageName
|
|
130
|
+
const outcome = await uninstallBundle(item.packageName, {
|
|
131
|
+
dropData: this._dropData,
|
|
132
|
+
dropContent: this._dropContent,
|
|
133
|
+
})
|
|
134
|
+
this._removing = ''
|
|
115
135
|
this._notice = outcome.message ?? ''
|
|
116
136
|
if (outcome.ok) await this.#load()
|
|
117
137
|
} catch (error) {
|
|
@@ -210,7 +230,6 @@ export default class CromboloBundlesInstalledElement extends UmbLitElement {
|
|
|
210
230
|
const outcome = await grantBundle(
|
|
211
231
|
item.id,
|
|
212
232
|
(item.permissions ?? []).map((ask) => ask.permission),
|
|
213
|
-
item.asksActAs ? this._actAs : undefined,
|
|
214
233
|
)
|
|
215
234
|
this._notice = outcome.message ?? ''
|
|
216
235
|
if (outcome.ok) await this.#load()
|
|
@@ -237,43 +256,31 @@ export default class CromboloBundlesInstalledElement extends UmbLitElement {
|
|
|
237
256
|
|
|
238
257
|
/** What it may do with the site, who approved it, and the button that turns it off or on. */
|
|
239
258
|
#permissions(item) {
|
|
240
|
-
|
|
241
|
-
const
|
|
242
|
-
const granting = item.status === 'waiting' || item.status === 'not-granted'
|
|
243
|
-
const confirmed = this._trustsCode === item.packageName
|
|
259
|
+
const state = item.provenance?.state
|
|
260
|
+
const choice = grantChoice(item.level, this._mayGrant, state)
|
|
244
261
|
const approved = item.granted
|
|
245
262
|
? item.granted.by === "the site's code"
|
|
246
263
|
? `Developer installed, on ${new Date(item.granted.at).toLocaleDateString()}.`
|
|
247
264
|
: `Approved by ${item.granted.by ?? 'an administrator'} on ${new Date(item.granted.at).toLocaleDateString()}.`
|
|
248
265
|
: ''
|
|
266
|
+
// Story 324: a version that moved up a level, or asks for anything new, is reviewed under this.
|
|
267
|
+
const movedUp =
|
|
268
|
+
item.status === 'waiting' && item.grantedLevel && item.grantedLevel !== item.level
|
|
269
|
+
? `This version asks for more: it is ${levelWords(item.level).label} now, where it was ${levelWords(item.grantedLevel).label}.`
|
|
270
|
+
: item.status === 'waiting'
|
|
271
|
+
? 'This version asks for more.'
|
|
272
|
+
: undefined
|
|
249
273
|
return html`
|
|
250
274
|
<h4>What it may do</h4>
|
|
251
|
-
${
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
: undefined,
|
|
261
|
-
)
|
|
262
|
-
: nothing
|
|
263
|
-
}
|
|
264
|
-
${
|
|
265
|
-
asks.length === 0 && !code
|
|
266
|
-
? html`<p>Nothing beyond its own data: it asks for no access to the site's content, members or settings.</p>`
|
|
267
|
-
: html`<ul class="asks">
|
|
268
|
-
${asks.map(
|
|
269
|
-
(ask) =>
|
|
270
|
-
html`<li>
|
|
271
|
-
${ask.allows}${ask.origins?.length ? html`: ${ask.origins.join(', ')}` : nothing}
|
|
272
|
-
${ask.reason ? html`<span class="reason">${ask.reason}</span>` : nothing}
|
|
273
|
-
</li>`,
|
|
274
|
-
)}
|
|
275
|
-
</ul>`
|
|
276
|
-
}
|
|
275
|
+
${levelBlock(
|
|
276
|
+
{
|
|
277
|
+
level: item.level,
|
|
278
|
+
groups: item.groups,
|
|
279
|
+
permissions: item.permissions,
|
|
280
|
+
unvouched: unvouchedLine(item.level, state),
|
|
281
|
+
},
|
|
282
|
+
{ heading: movedUp },
|
|
283
|
+
)}
|
|
277
284
|
${
|
|
278
285
|
item.schema3
|
|
279
286
|
? html`<p class="note">
|
|
@@ -305,28 +312,24 @@ export default class CromboloBundlesInstalledElement extends UmbLitElement {
|
|
|
305
312
|
}
|
|
306
313
|
</p>
|
|
307
314
|
${
|
|
308
|
-
|
|
309
|
-
? html`<uui-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
label="Grant"
|
|
327
|
-
?disabled=${Boolean(code) && !confirmed}
|
|
328
|
-
.state=${this._busy === item.packageName ? 'waiting' : undefined}
|
|
329
|
-
@click=${() => this.#grant(item)}></uui-button>`
|
|
315
|
+
choice.grant
|
|
316
|
+
? html`<uui-button
|
|
317
|
+
look="primary"
|
|
318
|
+
label="Grant"
|
|
319
|
+
.state=${this._busy === item.packageName ? 'waiting' : undefined}
|
|
320
|
+
@click=${() => this.#grant(item)}></uui-button>`
|
|
321
|
+
: choice.snippet
|
|
322
|
+
? html`<p class="note">
|
|
323
|
+
This site turns on Unrestricted extensions only in its configuration. Your
|
|
324
|
+
developers add this to crombolo.config.ts:
|
|
325
|
+
</p>
|
|
326
|
+
<pre class="snippet">${configSnippet(
|
|
327
|
+
item.id,
|
|
328
|
+
(item.permissions ?? []).map((ask) => ask.permission),
|
|
329
|
+
(item.permissions ?? []).flatMap((ask) => ask.origins ?? []),
|
|
330
|
+
)}</pre>`
|
|
331
|
+
: html`<p class="note">${choice.sentence}</p>`
|
|
332
|
+
}`
|
|
330
333
|
: item.on
|
|
331
334
|
? html`${approved ? html`<p class="note">${approved}</p>` : nothing}
|
|
332
335
|
<uui-button
|
|
@@ -403,7 +406,7 @@ export default class CromboloBundlesInstalledElement extends UmbLitElement {
|
|
|
403
406
|
(item) => item.packageName,
|
|
404
407
|
(item) => html`<uui-ref-node
|
|
405
408
|
name=${item.name}
|
|
406
|
-
detail=${`${item.packageName} ${item.version} · ${this.#words(item).label}`}
|
|
409
|
+
detail=${`${item.packageName} ${item.version} · ${levelWords(item.level).label} · ${this.#words(item).label}`}
|
|
407
410
|
selectable
|
|
408
411
|
select-only
|
|
409
412
|
?selected=${item.packageName === this._selected}
|
|
@@ -415,6 +418,7 @@ export default class CromboloBundlesInstalledElement extends UmbLitElement {
|
|
|
415
418
|
}
|
|
416
419
|
</uui-box>
|
|
417
420
|
${selected ? this.#details(selected) : nothing}
|
|
421
|
+
${this.#left()}
|
|
418
422
|
</div>
|
|
419
423
|
`
|
|
420
424
|
}
|
|
@@ -426,7 +430,102 @@ export default class CromboloBundlesInstalledElement extends UmbLitElement {
|
|
|
426
430
|
return signatureWords(item.provenance, unsignedRefused ? 'unsigned' : null, this._policy)
|
|
427
431
|
}
|
|
428
432
|
|
|
433
|
+
/** What removing it takes, and the two things it keeps unless asked. */
|
|
434
|
+
#removeDialog(item) {
|
|
435
|
+
return html`<div class="remove" role="group" aria-label="Remove it">
|
|
436
|
+
<p>
|
|
437
|
+
Removing ${item.name} stops it, forgets what it was granted, and deletes its files. Its
|
|
438
|
+
data and any content it added stay unless you tick them here.
|
|
439
|
+
</p>
|
|
440
|
+
<uui-checkbox
|
|
441
|
+
label="Also delete its data. Nothing is backed up first."
|
|
442
|
+
.checked=${this._dropData}
|
|
443
|
+
@change=${(event) => {
|
|
444
|
+
this._dropData = event.target.checked
|
|
445
|
+
}}></uui-checkbox>
|
|
446
|
+
${
|
|
447
|
+
item.carries?.content
|
|
448
|
+
? html`<uui-checkbox
|
|
449
|
+
label="Also take out the content it added"
|
|
450
|
+
.checked=${this._dropContent}
|
|
451
|
+
@change=${(event) => {
|
|
452
|
+
this._dropContent = event.target.checked
|
|
453
|
+
}}></uui-checkbox>`
|
|
454
|
+
: nothing
|
|
455
|
+
}
|
|
456
|
+
<div class="actions">
|
|
457
|
+
<uui-button
|
|
458
|
+
look="primary"
|
|
459
|
+
color="danger"
|
|
460
|
+
label="Remove"
|
|
461
|
+
.state=${this._busy === item.packageName ? 'waiting' : undefined}
|
|
462
|
+
@click=${() => this.#remove(item)}></uui-button>
|
|
463
|
+
<uui-button
|
|
464
|
+
look="secondary"
|
|
465
|
+
label="Cancel"
|
|
466
|
+
@click=${() => {
|
|
467
|
+
this._removing = ''
|
|
468
|
+
}}></uui-button>
|
|
469
|
+
</div>
|
|
470
|
+
</div>`
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/** Data removed extensions left, each with a delete of its own (story 328). */
|
|
474
|
+
#left() {
|
|
475
|
+
if ((this._left ?? []).length === 0) return nothing
|
|
476
|
+
return html`<uui-box headline="Data left by extensions you removed">
|
|
477
|
+
<p>Kept in case they are installed again, which picks it back up.</p>
|
|
478
|
+
<uui-ref-list>
|
|
479
|
+
${this._left.map(
|
|
480
|
+
(left) => html`<div class="left">
|
|
481
|
+
<span><strong>${left.id}</strong>: ${left.tables.length > 0 ? left.tables.join(', ') : 'no tables'}</span>
|
|
482
|
+
${
|
|
483
|
+
this._isAdmin
|
|
484
|
+
? html`<uui-button
|
|
485
|
+
look="secondary"
|
|
486
|
+
color="danger"
|
|
487
|
+
label="Delete its data"
|
|
488
|
+
.state=${this._busy === left.id ? 'waiting' : undefined}
|
|
489
|
+
@click=${() => this.#dropLeft(left.id)}></uui-button>`
|
|
490
|
+
: nothing
|
|
491
|
+
}
|
|
492
|
+
</div>`,
|
|
493
|
+
)}
|
|
494
|
+
</uui-ref-list>
|
|
495
|
+
</uui-box>`
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
async #dropLeft(id) {
|
|
499
|
+
try {
|
|
500
|
+
await umbConfirmModal(this, {
|
|
501
|
+
color: 'danger',
|
|
502
|
+
headline: `Delete the data ${id} left?`,
|
|
503
|
+
content: 'Its tables and its data folder are deleted, and nothing is backed up first.',
|
|
504
|
+
confirmLabel: 'Delete',
|
|
505
|
+
})
|
|
506
|
+
} catch {
|
|
507
|
+
return
|
|
508
|
+
}
|
|
509
|
+
this._busy = id
|
|
510
|
+
try {
|
|
511
|
+
const outcome = await dropLeftData(id)
|
|
512
|
+
this._notice = outcome.message ?? ''
|
|
513
|
+
await this.#load()
|
|
514
|
+
} catch (error) {
|
|
515
|
+
this._notice = error instanceof Error ? error.message : String(error)
|
|
516
|
+
} finally {
|
|
517
|
+
this._busy = ''
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
|
|
429
521
|
#details(item) {
|
|
522
|
+
// Story 327: what it did, in place of its details while it is open.
|
|
523
|
+
if (this._watching === item.packageName)
|
|
524
|
+
return html`<crombolo-bundles-activity
|
|
525
|
+
.extension=${item}
|
|
526
|
+
@close=${() => {
|
|
527
|
+
this._watching = ''
|
|
528
|
+
}}></crombolo-bundles-activity>`
|
|
430
529
|
return html`<uui-box headline=${item.name}>
|
|
431
530
|
${item.description ? html`<p>${item.description}</p>` : nothing}
|
|
432
531
|
<dl>
|
|
@@ -444,23 +543,34 @@ export default class CromboloBundlesInstalledElement extends UmbLitElement {
|
|
|
444
543
|
<dd>${signatureBlock(this.#words(item))}</dd>
|
|
445
544
|
</dl>
|
|
446
545
|
${this.#permissions(item)}
|
|
546
|
+
<h4>Activity</h4>
|
|
547
|
+
<p>
|
|
548
|
+
<uui-button
|
|
549
|
+
look="secondary"
|
|
550
|
+
label="See what it did"
|
|
551
|
+
@click=${() => {
|
|
552
|
+
this._watching = item.packageName
|
|
553
|
+
}}></uui-button>
|
|
554
|
+
</p>
|
|
447
555
|
${this.#settings(item)}
|
|
448
556
|
${
|
|
449
|
-
this._installs
|
|
450
|
-
? html`<
|
|
557
|
+
this._installs && !this._isAdmin
|
|
558
|
+
? html`<p class="note">An administrator can remove this.</p>`
|
|
559
|
+
: this._installs
|
|
560
|
+
? html`<uui-button
|
|
451
561
|
look="primary"
|
|
452
562
|
color="danger"
|
|
453
563
|
label="Uninstall"
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
564
|
+
@click=${() => this.#uninstall(item)}></uui-button>
|
|
565
|
+
${this._removing === item.packageName ? this.#removeDialog(item) : nothing}`
|
|
566
|
+
: html`<p class="note">This site adds and removes extensions with a deploy, so every server has the same ones.</p>`
|
|
457
567
|
}
|
|
458
568
|
</uui-box>`
|
|
459
569
|
}
|
|
460
570
|
|
|
461
571
|
static styles = [
|
|
462
572
|
signatureStyles,
|
|
463
|
-
|
|
573
|
+
levelStyles,
|
|
464
574
|
css`
|
|
465
575
|
.asks {
|
|
466
576
|
padding-left: 1.25em;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the install panel and Installed say about how far an extension reaches
|
|
3
|
+
* (story 324): its level's badge and sentence, the four groups, and whether
|
|
4
|
+
* this person may turn it on here. The server says the level, the groups and
|
|
5
|
+
* what the person may grant; this only words them. Pure, so it is tested
|
|
6
|
+
* without a browser.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** Each level's badge, its sentence, and the colour the badge and its line take. */
|
|
10
|
+
export const LEVELS = {
|
|
11
|
+
limited: {
|
|
12
|
+
label: 'Limited',
|
|
13
|
+
sentence:
|
|
14
|
+
'Works through the site with only the access below. You can see everything it does and undo it.',
|
|
15
|
+
color: 'default',
|
|
16
|
+
},
|
|
17
|
+
'acts-as-you': {
|
|
18
|
+
label: 'Acts as you',
|
|
19
|
+
sentence:
|
|
20
|
+
'Can do anything on this site that the person using it can do. Everything it does is recorded against them.',
|
|
21
|
+
color: 'warning',
|
|
22
|
+
},
|
|
23
|
+
unrestricted: {
|
|
24
|
+
label: 'Unrestricted',
|
|
25
|
+
sentence:
|
|
26
|
+
"Runs its own code inside your back office, with the same access as the site's own code. Nothing it does there can be watched or limited. Only install this from a publisher you trust as you trust your own developers.",
|
|
27
|
+
color: 'danger',
|
|
28
|
+
},
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const levelWords = (level) => LEVELS[level] ?? LEVELS.limited
|
|
32
|
+
|
|
33
|
+
const GROUPS = [
|
|
34
|
+
['sees', 'Sees'],
|
|
35
|
+
['changes', 'Changes'],
|
|
36
|
+
['sendsTo', 'Sends to'],
|
|
37
|
+
['adds', 'Adds'],
|
|
38
|
+
['actsAs', 'Acts as'],
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
/** The groups as lines, each a label and what is in it; an empty group says nothing beyond its own data. */
|
|
42
|
+
export function groupLines(groups) {
|
|
43
|
+
const lines = GROUPS.filter(([key]) => key !== 'actsAs' || (groups?.actsAs ?? []).length > 0).map(
|
|
44
|
+
([key, label]) => ({
|
|
45
|
+
label,
|
|
46
|
+
text: (groups?.[key] ?? []).length > 0 ? groups[key].join(', ') : 'nothing',
|
|
47
|
+
}),
|
|
48
|
+
)
|
|
49
|
+
return lines
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export const NOBODY_VOUCHED = 'Nobody has vouched for who built this'
|
|
53
|
+
const VOUCHED = new Set(['signed', 'vouched', 'local'])
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Whether this person may turn it on here, and if not what to show in place of
|
|
57
|
+
* the button: an administrator's sentence, the unvouched sentence, or the
|
|
58
|
+
* config snippet. `may` is the server's `mayGrant`.
|
|
59
|
+
*/
|
|
60
|
+
export function grantChoice(level, may, provenanceState) {
|
|
61
|
+
const rule = may?.[level ?? 'limited'] ?? 'administrator'
|
|
62
|
+
if (rule === 'config') return { snippet: true }
|
|
63
|
+
if (rule !== 'yes') return { sentence: 'An administrator can turn this on.' }
|
|
64
|
+
if (level === 'limited' || !level) return { grant: true }
|
|
65
|
+
if (!VOUCHED.has(provenanceState))
|
|
66
|
+
return { sentence: `${NOBODY_VOUCHED}, so it can't be turned on here.` }
|
|
67
|
+
return { grant: true }
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** The line that stands in for the build line when a Limited extension is unsigned. */
|
|
71
|
+
export const unvouchedLine = (level, provenanceState) =>
|
|
72
|
+
level === 'limited' && !VOUCHED.has(provenanceState) ? NOBODY_VOUCHED : undefined
|
|
73
|
+
|
|
74
|
+
/** What a developer adds to `crombolo.config.ts` to grant it there. */
|
|
75
|
+
export function configSnippet(id, permissions, origins = []) {
|
|
76
|
+
const grant = permissions.map((permission) => `'${permission}'`).join(', ')
|
|
77
|
+
const reach = origins.length > 0 ? `, origins: [${origins.map((o) => `'${o}'`).join(', ')}]` : ''
|
|
78
|
+
return `extensions: {\n '${id}': { grant: [${grant}]${reach} },\n},`
|
|
79
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How far an extension reaches, at a glance (story 324), shared by the
|
|
3
|
+
* Marketplace's install and Installed: the level's badge and sentence, the
|
|
4
|
+
* four groups, and each permission with its reason only when asked for.
|
|
5
|
+
*/
|
|
6
|
+
import { css, html, nothing } from '@umbraco-cms/backoffice/external/lit'
|
|
7
|
+
import { groupLines, levelWords } from './bundles-level-words.js'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @param {{ level?: string, groups?: object, permissions?: { allows: string, reason?: string | null, origins?: string[] }[], unvouched?: string }} item
|
|
11
|
+
* @param {{ heading?: string }} options
|
|
12
|
+
*/
|
|
13
|
+
export function levelBlock(item, options = {}) {
|
|
14
|
+
const words = levelWords(item.level)
|
|
15
|
+
return html`<div class="level level-${words.color}" role="group" aria-label="What it can reach">
|
|
16
|
+
${options.heading ? html`<p class="level-heading">${options.heading}</p>` : nothing}
|
|
17
|
+
<p class="level-badge">
|
|
18
|
+
<uui-tag color=${words.color} look="primary">${words.label}</uui-tag>
|
|
19
|
+
<span>${words.sentence}</span>
|
|
20
|
+
</p>
|
|
21
|
+
${item.unvouched ? html`<p class="level-unvouched">${item.unvouched}</p>` : nothing}
|
|
22
|
+
<dl class="level-groups">
|
|
23
|
+
${groupLines(item.groups).map(
|
|
24
|
+
(line) => html`<dt>${line.label}</dt>
|
|
25
|
+
<dd>${line.text}</dd>`,
|
|
26
|
+
)}
|
|
27
|
+
</dl>
|
|
28
|
+
${
|
|
29
|
+
(item.permissions ?? []).length > 0
|
|
30
|
+
? html`<details class="level-detail">
|
|
31
|
+
<summary>Show each permission and why it asks</summary>
|
|
32
|
+
<ul>
|
|
33
|
+
${item.permissions.map(
|
|
34
|
+
(ask) =>
|
|
35
|
+
html`<li>
|
|
36
|
+
${ask.allows}${ask.origins?.length ? html`: ${ask.origins.join(', ')}` : nothing}
|
|
37
|
+
${ask.reason ? html`<span class="reason">${ask.reason}</span>` : nothing}
|
|
38
|
+
${ask.warning ? html`<span class="reason">${ask.warning}</span>` : nothing}
|
|
39
|
+
</li>`,
|
|
40
|
+
)}
|
|
41
|
+
</ul>
|
|
42
|
+
</details>`
|
|
43
|
+
: nothing
|
|
44
|
+
}
|
|
45
|
+
</div>`
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const levelStyles = css`
|
|
49
|
+
.level {
|
|
50
|
+
margin: var(--uui-size-space-3) 0;
|
|
51
|
+
padding: var(--uui-size-space-4);
|
|
52
|
+
border: 1px solid var(--uui-color-border);
|
|
53
|
+
border-radius: var(--uui-border-radius);
|
|
54
|
+
}
|
|
55
|
+
.level-warning {
|
|
56
|
+
border-color: var(--uui-color-warning-standalone, var(--uui-color-warning));
|
|
57
|
+
}
|
|
58
|
+
.level-danger {
|
|
59
|
+
border-color: var(--uui-color-danger-standalone, var(--uui-color-danger));
|
|
60
|
+
}
|
|
61
|
+
.level p {
|
|
62
|
+
margin: 0 0 var(--uui-size-space-3);
|
|
63
|
+
}
|
|
64
|
+
.level-badge {
|
|
65
|
+
display: flex;
|
|
66
|
+
align-items: baseline;
|
|
67
|
+
gap: var(--uui-size-space-3);
|
|
68
|
+
}
|
|
69
|
+
.level-unvouched {
|
|
70
|
+
color: var(--uui-color-danger-standalone, var(--uui-color-danger));
|
|
71
|
+
}
|
|
72
|
+
.level-groups {
|
|
73
|
+
display: grid;
|
|
74
|
+
grid-template-columns: max-content 1fr;
|
|
75
|
+
gap: var(--uui-size-space-1) var(--uui-size-space-4);
|
|
76
|
+
margin: 0 0 var(--uui-size-space-3);
|
|
77
|
+
}
|
|
78
|
+
.level-groups dt {
|
|
79
|
+
font-weight: bold;
|
|
80
|
+
}
|
|
81
|
+
.level-groups dd {
|
|
82
|
+
margin: 0;
|
|
83
|
+
}
|
|
84
|
+
.level-detail summary {
|
|
85
|
+
cursor: pointer;
|
|
86
|
+
}
|
|
87
|
+
.level-detail .reason {
|
|
88
|
+
display: block;
|
|
89
|
+
color: var(--uui-color-text-alt);
|
|
90
|
+
}
|
|
91
|
+
`
|