@crombolo/backoffice-host 0.56.0 → 0.58.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crombolo/backoffice-host",
3
- "version": "0.56.0",
3
+ "version": "0.58.0",
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.56.0",
36
- "@crombolo/backoffice-dist": "0.56.0"
35
+ "@crombolo/core": "0.58.0",
36
+ "@crombolo/backoffice-dist": "0.58.0"
37
37
  }
38
38
  }
@@ -2,7 +2,7 @@
2
2
  "$schema": "../../../backoffice-dist/dist/umbraco-package-schema.json",
3
3
  "name": "Crombolo App Preview",
4
4
  "id": "Crombolo.AppPreview",
5
- "version": "0.56.0",
5
+ "version": "0.58.0",
6
6
  "allowPublicAccess": false,
7
7
  "extensions": [
8
8
  {
@@ -61,8 +61,10 @@
61
61
  --crombolo-header-line: #3b2e25;
62
62
  --crombolo-section-sidebar-background: var(--crombolo-night-surface);
63
63
  --crombolo-card-shadow: none;
64
- --crombolo-card-header-background: #4a2a1a;
65
- --crombolo-card-header-text: #ffffff;
64
+ --crombolo-card-header-background: #3a2c23;
65
+ --crombolo-card-header-text: var(--crombolo-ink);
66
+ --uui-box-header-background: var(--crombolo-card-header-background);
67
+ --uui-box-header-color: var(--crombolo-card-header-text);
66
68
  --crombolo-terracotta-tint: var(--crombolo-night-alt);
67
69
 
68
70
  /* The SEO view's search-result preview, in Google's dark-mode link blue. */
@@ -93,8 +93,11 @@
93
93
  --crombolo-section-sidebar-background: #fff;
94
94
  /* Crombolo's own cards (the Overview, Settings) stand off the page; Umbraco's stay flat. */
95
95
  /* A Settings card's title sits on a dark band. */
96
- --crombolo-card-header-background: var(--crombolo-cocoa);
97
- --crombolo-card-header-text: #fff;
96
+ --crombolo-card-header-background: #e8d5c6;
97
+ --crombolo-card-header-text: var(--crombolo-cocoa);
98
+ /* Every box's header, Umbraco's and ours, through the vendoring's patch to UUI's box. */
99
+ --uui-box-header-background: var(--crombolo-card-header-background);
100
+ --uui-box-header-color: var(--crombolo-card-header-text);
98
101
  --crombolo-card-shadow: 0 1px 2px rgb(84 50 31 / 6%), 0 10px 28px -18px rgb(84 50 31 / 30%);
99
102
 
100
103
  /* Pure white panels on a warm off-white page, so cards still separate. */
@@ -184,6 +184,11 @@ export class CromboloBundleCodeView extends CromboloBundleEditorView {
184
184
  'Partial views',
185
185
  filePicker(this, d, 'partialViews', 'icon-document-html', UmbPartialViewPickerInputContext),
186
186
  )}
187
+ <p class="note">
188
+ In an extension, the templates and partial views picked here render in its own process on
189
+ the sites that install it. In a site bundle they become the other site's own. Which this is
190
+ is chosen beside its package name, under Created.
191
+ </p>
187
192
  ${field('Stylesheets', filePicker(this, d, 'stylesheets', 'icon-palette', UmbStylesheetPickerInputContext))}
188
193
  ${field('Scripts', filePicker(this, d, 'scripts', 'icon-document-js', UmbScriptPickerInputContext))}
189
194
  `
@@ -83,7 +83,7 @@ export default class CromboloBundleEditorElement extends UmbLitElement {
83
83
 
84
84
  render() {
85
85
  return html`
86
- <umb-workspace-editor back-path="section/settings/dashboard/bundles/created">
86
+ <umb-workspace-editor back-path="section/settings/dashboard/extensions/created">
87
87
  ${
88
88
  this._definition
89
89
  ? html`<div id="header" slot="header">
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * Reads and drives the Bundles endpoints the server keeps at
3
- * <backoffice>/crombolo/api/bundles/*. The session cookie carries the auth.
3
+ * <backoffice>/crombolo/api/extensions/*. The session cookie carries the auth.
4
4
  */
5
5
  const base = () => {
6
6
  const href = document.querySelector('base')?.getAttribute('href') ?? '/umbraco/'
7
- return `${href.replace(/\/$/, '')}/crombolo/api/bundles`
7
+ return `${href.replace(/\/$/, '')}/crombolo/api/extensions`
8
8
  }
9
9
 
10
10
  const json = async (path, init) => {
@@ -33,22 +33,32 @@ export const bundleSignature = (name, version) =>
33
33
  `/signature?name=${encodeURIComponent(name)}${version ? `&version=${encodeURIComponent(version)}` : ''}`,
34
34
  )
35
35
 
36
+ /** `settings` are saved once it is installed: the layout picked for its page templates (story 312). */
36
37
  export const installBundle = (
37
38
  name,
38
39
  version,
39
40
  applyContent = true,
40
- acceptServerCode = false,
41
41
  grant = [],
42
+ actAs = undefined,
43
+ settings = undefined,
42
44
  ) =>
43
45
  json('/install', {
44
46
  method: 'POST',
45
- body: JSON.stringify({ name, version, applyContent, acceptServerCode, grant }),
47
+ body: JSON.stringify({ name, version, applyContent, grant, actAs, settings }),
46
48
  })
47
49
 
48
50
  /** Turns an installed bundle's server features off until it is enabled again (story 225). */
49
51
  export const disableBundle = (id) =>
50
52
  json('/disable', { method: 'POST', body: JSON.stringify({ id }) })
51
53
 
54
+ /** Grants an installed extension exactly what it asks for, and whom it acts for (story 309). */
55
+ export const grantBundle = (id, grant, actAs = undefined) =>
56
+ json('/grant', { method: 'POST', body: JSON.stringify({ id, grant, actAs }) })
57
+
58
+ /** Saves an extension's settings: `null` takes one back to its default (story 310). */
59
+ export const saveSettings = (id, values) =>
60
+ json('/settings', { method: 'POST', body: JSON.stringify({ id, values }) })
61
+
52
62
  /** Turns a disabled bundle's server features back on. */
53
63
  export const enableBundle = (id) =>
54
64
  json('/enable', { method: 'POST', body: JSON.stringify({ id }) })
@@ -20,7 +20,7 @@ import { downloadFile } from './download.js'
20
20
  const TAKE = 10
21
21
 
22
22
  /** Where the builder lives, which is Umbraco's route and not ours to rename. */
23
- export const BUILDER_PATH = 'section/settings/dashboard/bundles/created/package-builder'
23
+ export const BUILDER_PATH = 'section/settings/dashboard/extensions/created/package-builder'
24
24
 
25
25
  export default class CromboloBundlesCreatedOverviewElement extends UmbLitElement {
26
26
  static properties = {
@@ -80,6 +80,7 @@ export default class CromboloBundlesCreatedOverviewElement extends UmbLitElement
80
80
  this._draft = {
81
81
  name: pkg?.set?.name ? pkg.name : '',
82
82
  version: pkg?.set?.version ? pkg.version : '',
83
+ kind: pkg?.kind ?? 'extension',
83
84
  }
84
85
  }
85
86
 
@@ -103,6 +104,30 @@ export default class CromboloBundlesCreatedOverviewElement extends UmbLitElement
103
104
  Leave a field empty to go back to the name taken from the bundle's own name, and
104
105
  version 1.0.0.
105
106
  </p>
107
+ <uui-select
108
+ label="What it is for"
109
+ .options=${[
110
+ {
111
+ name: 'An extension, for other sites to install',
112
+ value: 'extension',
113
+ selected: this._draft.kind !== 'site',
114
+ },
115
+ {
116
+ name: 'A site bundle, to move this site to another environment',
117
+ value: 'site',
118
+ selected: this._draft.kind === 'site',
119
+ },
120
+ ]}
121
+ @change=${(event) => (this._draft = { ...this._draft, kind: event.target.value })}></uui-select>
122
+ <p class="note">
123
+ ${
124
+ this._draft.kind === 'site'
125
+ ? html`A site bundle carries its templates and partial views as the other site's own,
126
+ and is applied there with <code>crombolo site apply</code>. It is never installed.`
127
+ : html`An extension's templates and partial views render in its own process on the
128
+ sites that install it, which grant it permission to.`
129
+ }
130
+ </p>
106
131
  <uui-input
107
132
  label="Name"
108
133
  placeholder=${pkg?.name ?? ''}
@@ -155,7 +180,7 @@ export default class CromboloBundlesCreatedOverviewElement extends UmbLitElement
155
180
 
156
181
  #detail(item) {
157
182
  const pkg = this._packages[item.unique]
158
- return pkg ? `${pkg.name}@${pkg.version}` : ''
183
+ return pkg ? `${pkg.name}@${pkg.version}${pkg.kind === 'site' ? ', a site bundle' : ''}` : ''
159
184
  }
160
185
 
161
186
  #onPageChange(event) {
@@ -288,6 +313,9 @@ export default class CromboloBundlesCreatedOverviewElement extends UmbLitElement
288
313
  .problem {
289
314
  color: var(--uui-color-danger);
290
315
  }
316
+ .note {
317
+ color: var(--uui-color-text-alt);
318
+ }
291
319
  .buttons {
292
320
  white-space: nowrap;
293
321
  text-align: right;
@@ -16,7 +16,14 @@
16
16
  import { css, html, nothing, repeat } from '@umbraco-cms/backoffice/external/lit'
17
17
  import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'
18
18
  import { carriesTags } from './bundles-carries.js'
19
- import { disableBundle, enableBundle, listInstalled, uninstallBundle } from './bundles-client.js'
19
+ import {
20
+ disableBundle,
21
+ enableBundle,
22
+ grantBundle,
23
+ listInstalled,
24
+ saveSettings,
25
+ uninstallBundle,
26
+ } from './bundles-client.js'
20
27
  import { signatureBlock, signatureStyles, signatureWords } from './bundles-signature.js'
21
28
 
22
29
  /** Where each part of a bundle stands on this site, in the words of someone running it. */
@@ -28,7 +35,11 @@ function status(item) {
28
35
  ? html`<span>Content added (${item.contentApplied})</span>`
29
36
  : html`<span>Content not added yet</span>`,
30
37
  )
31
- if (item.carries?.server)
38
+ // Story 309: it runs on its grant. Story 311: and only once it has started.
39
+ if (item.couldNotStart) parts.push(html`<span>Could not start</span>`)
40
+ else if (item.status === 'waiting') parts.push(html`<span>Waiting for a grant</span>`)
41
+ else if (item.status === 'not-granted') parts.push(html`<span>Not granted</span>`)
42
+ else if (item.carries?.server)
32
43
  parts.push(
33
44
  !item.on
34
45
  ? html`<span>Server features turned off by ${item.disabledBy ?? 'an administrator'}</span>`
@@ -50,6 +61,8 @@ export default class CromboloBundlesInstalledElement extends UmbLitElement {
50
61
  _filter: { state: true },
51
62
  _selected: { state: true },
52
63
  _policy: { state: true },
64
+ _actAs: { state: true },
65
+ _edits: { state: true },
53
66
  }
54
67
 
55
68
  constructor() {
@@ -61,8 +74,13 @@ export default class CromboloBundlesInstalledElement extends UmbLitElement {
61
74
  this._installs = true
62
75
  this._restartPending = false
63
76
  this._filter = ''
77
+ this._actAs = 'installer'
78
+ this._edits = {}
64
79
  // Settings links a bundle's cards here, naming it in `?bundle=`.
65
- this._selected = new URLSearchParams(window.location.search).get('bundle') ?? ''
80
+ this._selected =
81
+ new URLSearchParams(window.location.search).get('extension') ??
82
+ new URLSearchParams(window.location.search).get('bundle') ??
83
+ ''
66
84
  }
67
85
 
68
86
  connectedCallback() {
@@ -100,6 +118,106 @@ export default class CromboloBundlesInstalledElement extends UmbLitElement {
100
118
  }
101
119
  }
102
120
 
121
+ /** Saves the settings changed in its form (story 310). */
122
+ async #saveSettings(item) {
123
+ this._busy = item.packageName
124
+ try {
125
+ const outcome = await saveSettings(item.id, this._edits)
126
+ this._notice = outcome.message ?? ''
127
+ if (outcome.ok) {
128
+ this._edits = {}
129
+ await this.#load()
130
+ }
131
+ } catch (error) {
132
+ this._notice = error instanceof Error ? error.message : String(error)
133
+ } finally {
134
+ this._busy = ''
135
+ }
136
+ }
137
+
138
+ #edit(key, value) {
139
+ this._edits = { ...this._edits, [key]: value }
140
+ }
141
+
142
+ /** Its settings: the config's locked, the rest edited here (story 310). */
143
+ #settings(item) {
144
+ const settings = item.settings ?? []
145
+ if (settings.length === 0) return nothing
146
+ const field = (setting) => {
147
+ const value = setting.key in this._edits ? this._edits[setting.key] : setting.value
148
+ if (setting.type === 'boolean')
149
+ return html`<uui-toggle
150
+ label=${setting.label}
151
+ ?disabled=${setting.locked}
152
+ .checked=${value === true}
153
+ @change=${(event) => this.#edit(setting.key, event.target.checked)}></uui-toggle>`
154
+ // Story 312: the site layout its page templates sit in, or none.
155
+ if (setting.type === 'layout')
156
+ return html`<uui-select
157
+ label=${setting.label}
158
+ ?disabled=${setting.locked}
159
+ .options=${[
160
+ { name: 'None: a page of its own', value: '', selected: !value },
161
+ ...setting.values.map((layout) => ({
162
+ name: layout,
163
+ value: layout,
164
+ selected: layout === value,
165
+ })),
166
+ ]}
167
+ @change=${(event) => this.#edit(setting.key, event.target.value || null)}></uui-select>`
168
+ if (setting.type === 'choice')
169
+ return html`<uui-select
170
+ label=${setting.label}
171
+ ?disabled=${setting.locked}
172
+ .options=${setting.values.map((choice) => ({ name: choice, value: choice, selected: choice === value }))}
173
+ @change=${(event) => this.#edit(setting.key, event.target.value)}></uui-select>`
174
+ return html`<uui-input
175
+ label=${setting.label}
176
+ type=${setting.secret ? 'password' : setting.type === 'number' ? 'number' : 'text'}
177
+ ?disabled=${setting.locked}
178
+ .value=${value ?? ''}
179
+ @change=${(event) =>
180
+ this.#edit(
181
+ setting.key,
182
+ setting.type === 'number' ? Number(event.target.value) : event.target.value,
183
+ )}></uui-input>`
184
+ }
185
+ return html`
186
+ <h4>Settings</h4>
187
+ ${settings.map(
188
+ (setting) => html`<div class="setting">
189
+ <span>${setting.label}</span>
190
+ ${field(setting)}
191
+ ${setting.locked ? html`<span class="note">Set in the site's configuration.</span>` : nothing}
192
+ </div>`,
193
+ )}
194
+ <uui-button
195
+ look="primary"
196
+ label="Save settings"
197
+ ?disabled=${Object.keys(this._edits).length === 0}
198
+ .state=${this._busy === item.packageName ? 'waiting' : undefined}
199
+ @click=${() => this.#saveSettings(item)}></uui-button>
200
+ `
201
+ }
202
+
203
+ /** Grants what its installed version asks for (story 309). */
204
+ async #grant(item) {
205
+ this._busy = item.packageName
206
+ try {
207
+ const outcome = await grantBundle(
208
+ item.id,
209
+ (item.permissions ?? []).map((ask) => ask.permission),
210
+ item.asksActAs ? this._actAs : undefined,
211
+ )
212
+ this._notice = outcome.message ?? ''
213
+ if (outcome.ok) await this.#load()
214
+ } catch (error) {
215
+ this._notice = error instanceof Error ? error.message : String(error)
216
+ } finally {
217
+ this._busy = ''
218
+ }
219
+ }
220
+
103
221
  /** Turns its server features off, or back on (story 225). */
104
222
  async #setEnabled(item, enabled) {
105
223
  this._busy = item.packageName
@@ -116,10 +234,11 @@ export default class CromboloBundlesInstalledElement extends UmbLitElement {
116
234
 
117
235
  /** What it may do with the site, who approved it, and the button that turns it off or on. */
118
236
  #permissions(item) {
119
- if (!item.carries?.server) return nothing
120
237
  const asks = item.permissions ?? []
121
238
  const approved = item.granted
122
- ? `Approved by ${item.granted.by ?? 'an administrator'} on ${new Date(item.granted.at).toLocaleDateString()}.`
239
+ ? item.granted.by === "the site's code"
240
+ ? `Developer installed, on ${new Date(item.granted.at).toLocaleDateString()}.`
241
+ : `Approved by ${item.granted.by ?? 'an administrator'} on ${new Date(item.granted.at).toLocaleDateString()}.`
123
242
  : ''
124
243
  return html`
125
244
  <h4>What it may do</h4>
@@ -127,19 +246,76 @@ export default class CromboloBundlesInstalledElement extends UmbLitElement {
127
246
  asks.length === 0
128
247
  ? html`<p>Nothing beyond its own data: it asks for no access to the site's content, members or settings.</p>`
129
248
  : html`<ul class="asks">
130
- ${asks.map((ask) => html`<li>${ask.allows}</li>`)}
249
+ ${asks.map(
250
+ (ask) =>
251
+ html`<li>
252
+ ${ask.allows}${ask.origins?.length ? html`: ${ask.origins.join(', ')}` : nothing}
253
+ ${ask.reason ? html`<span class="reason">${ask.reason}</span>` : nothing}
254
+ </li>`,
255
+ )}
131
256
  </ul>`
132
257
  }
133
258
  ${
134
- item.on
135
- ? html`${approved ? html`<p class="note">${approved}</p>` : nothing}
259
+ item.schema3
260
+ ? html`<p class="note">
261
+ It asks for these without saying why: it was written before extensions gave a
262
+ reason for each. A new install of a version like it is refused.
263
+ </p>`
264
+ : nothing
265
+ }
266
+ ${
267
+ item.couldNotStart
268
+ ? html`<p class="note">It is granted, but could not start: ${item.couldNotStart}</p>`
269
+ : nothing
270
+ }
271
+ ${
272
+ item.copiedComponents
273
+ ? html`<p class="note">
274
+ An earlier install copied these into the site's components, where they are the
275
+ site's own now. Review them: ${item.copiedComponents.join(', ')}
276
+ </p>`
277
+ : nothing
278
+ }
279
+ ${
280
+ item.status === 'waiting' || item.status === 'not-granted'
281
+ ? html`<p class="note">
282
+ ${
283
+ item.status === 'waiting'
284
+ ? html`Waiting for a grant: it now asks for ${item.missing.join(', ')}, which was not granted.`
285
+ : 'Not granted: it does nothing until it is granted what it asks for.'
286
+ }
287
+ </p>
288
+ ${
289
+ item.asksActAs
290
+ ? html`<uui-select
291
+ label="Acts for"
292
+ .options=${[
293
+ { name: 'You', value: 'installer', selected: this._actAs === 'installer' },
294
+ {
295
+ name: 'Whoever uses it',
296
+ value: 'caller',
297
+ selected: this._actAs === 'caller',
298
+ },
299
+ ]}
300
+ @change=${(event) => {
301
+ this._actAs = event.target.value
302
+ }}></uui-select>`
303
+ : nothing
304
+ }
305
+ <uui-button
306
+ look="primary"
307
+ label="Grant"
308
+ .state=${this._busy === item.packageName ? 'waiting' : undefined}
309
+ @click=${() => this.#grant(item)}></uui-button>`
310
+ : item.on
311
+ ? html`${approved ? html`<p class="note">${approved}</p>` : nothing}
136
312
  <uui-button
137
313
  look="secondary"
138
314
  color="danger"
139
315
  label="Disable"
140
316
  .state=${this._busy === item.packageName ? 'waiting' : undefined}
141
317
  @click=${() => this.#setEnabled(item, false)}></uui-button>`
142
- : html`<p class="note">
318
+ : html`<p class="note">
143
319
  Turned off by ${item.disabledBy ?? 'an administrator'}: its pages, jobs and screens
144
320
  stay off, through updates, until it is enabled again.
145
321
  </p>
@@ -172,7 +348,7 @@ export default class CromboloBundlesInstalledElement extends UmbLitElement {
172
348
  if (this._items.length === 0)
173
349
  return html`
174
350
  ${this._notice ? html`<div id="notice">${this._notice}</div>` : nothing}
175
- <uui-box headline="No bundles installed">
351
+ <uui-box headline="No extensions installed">
176
352
  <p>Install one from the Marketplace tab, and it appears here.</p>
177
353
  </uui-box>
178
354
  `
@@ -186,7 +362,7 @@ export default class CromboloBundlesInstalledElement extends UmbLitElement {
186
362
  : nothing
187
363
  }
188
364
  <div id="columns">
189
- <uui-box headline="Installed bundles" style="--uui-box-default-padding:0;">
365
+ <uui-box headline="Installed extensions" style="--uui-box-default-padding:0;">
190
366
  <div id="filter">
191
367
  <uui-input
192
368
  label="Filter"
@@ -200,7 +376,7 @@ export default class CromboloBundlesInstalledElement extends UmbLitElement {
200
376
  </div>
201
377
  ${
202
378
  shown.length === 0
203
- ? html`<p class="empty">No bundle matches.</p>`
379
+ ? html`<p class="empty">No extension matches.</p>`
204
380
  : html`<uui-ref-list>
205
381
  ${repeat(
206
382
  shown,
@@ -248,6 +424,7 @@ export default class CromboloBundlesInstalledElement extends UmbLitElement {
248
424
  <dd>${signatureBlock(this.#words(item))}</dd>
249
425
  </dl>
250
426
  ${this.#permissions(item)}
427
+ ${this.#settings(item)}
251
428
  ${
252
429
  this._installs
253
430
  ? html`<uui-button
@@ -256,7 +433,7 @@ export default class CromboloBundlesInstalledElement extends UmbLitElement {
256
433
  label="Uninstall"
257
434
  .state=${this._busy === item.packageName ? 'waiting' : undefined}
258
435
  @click=${() => this.#uninstall(item)}></uui-button>`
259
- : html`<p class="note">This site adds and removes bundles with a deploy, so every server has the same ones.</p>`
436
+ : html`<p class="note">This site adds and removes extensions with a deploy, so every server has the same ones.</p>`
260
437
  }
261
438
  </uui-box>`
262
439
  }
@@ -267,6 +444,15 @@ export default class CromboloBundlesInstalledElement extends UmbLitElement {
267
444
  .asks {
268
445
  padding-left: 1.25em;
269
446
  }
447
+ .setting {
448
+ display: grid;
449
+ gap: var(--uui-size-space-1);
450
+ margin-bottom: var(--uui-size-space-3);
451
+ }
452
+ .asks .reason {
453
+ display: block;
454
+ color: var(--uui-color-text-alt);
455
+ }
270
456
  :host {
271
457
  display: block;
272
458
  padding: var(--uui-size-layout-1, 24px);