@crombolo/backoffice-host 0.33.1 → 0.34.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/README.md ADDED
@@ -0,0 +1,14 @@
1
+ # @crombolo/backoffice-host
2
+
3
+ **Internal to crombolo.** This package is published because
4
+ [`@crombolo/crombolo`](https://www.npmjs.com/package/@crombolo/crombolo)
5
+ depends on it, and its exports can change in any release, a patch included.
6
+
7
+ Import from `@crombolo/crombolo` instead:
8
+
9
+ - `@crombolo/crombolo` for a site: its config, its boot and its views.
10
+ - `@crombolo/crombolo/bundle` for a server bundle's author.
11
+ - `@crombolo/crombolo/host` for whoever runs sites.
12
+
13
+ Those three entry points carry the compatibility promise in
14
+ [`docs/api.md`](https://github.com/kineco-au/crombolo-cms/blob/main/docs/api.md).
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@crombolo/backoffice-host",
3
- "version": "0.33.1",
4
- "description": "Serves the Umbraco backoffice SPA: shell HTML, import map and package manifests.",
3
+ "version": "0.34.0",
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",
7
7
  "homepage": "https://github.com/kineco-au/crombolo-cms#readme",
@@ -31,7 +31,7 @@
31
31
  "access": "public"
32
32
  },
33
33
  "dependencies": {
34
- "@crombolo/core": "0.33.1",
34
+ "@crombolo/core": "0.34.0",
35
35
  "@crombolo/backoffice-dist": "18.2.0"
36
36
  }
37
37
  }
@@ -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.33.1",
5
+ "version": "0.34.0",
6
6
  "allowPublicAccess": false,
7
7
  "extensions": [
8
8
  {
@@ -7,10 +7,15 @@ import { html } from '@umbraco-cms/backoffice/external/lit'
7
7
  export const CARRIES_LABELS = {
8
8
  extensions: 'Screens',
9
9
  content: 'Content',
10
- server: 'Server features',
10
+ server: 'Runs code on the server',
11
11
  }
12
12
 
13
+ /** Server code is a different kind of thing to add, so it looks like one (story 194). */
13
14
  export const carriesTags = (carries) =>
14
15
  Object.entries(CARRIES_LABELS)
15
16
  .filter(([key]) => carries?.[key])
16
- .map(([, label]) => html`<uui-tag look="secondary">${label}</uui-tag>`)
17
+ .map(([key, label]) =>
18
+ key === 'server'
19
+ ? html`<uui-tag look="primary" color="warning">${label}</uui-tag>`
20
+ : html`<uui-tag look="secondary">${label}</uui-tag>`,
21
+ )
@@ -27,8 +27,11 @@ export const searchMarketplace = (query) =>
27
27
 
28
28
  export const listInstalled = () => json('/installed')
29
29
 
30
- export const installBundle = (name, version, applyContent = true) =>
31
- json('/install', { method: 'POST', body: JSON.stringify({ name, version, applyContent }) })
30
+ export const installBundle = (name, version, applyContent = true, acceptServerCode = false) =>
31
+ json('/install', {
32
+ method: 'POST',
33
+ body: JSON.stringify({ name, version, applyContent, acceptServerCode }),
34
+ })
32
35
 
33
36
  export const uninstallBundle = (name) =>
34
37
  json('/uninstall', { method: 'POST', body: JSON.stringify({ name }) })
@@ -9,7 +9,9 @@
9
9
  * What it shows instead is the npm registry, searched for the keyword a crombolo
10
10
  * bundle publishes, and filtered to the ones whose manifest is a valid bundle.
11
11
  * Installing runs `bun add` on the server, then adds the content the bundle
12
- * carries unless the site or the person installing declines it.
12
+ * carries unless the site or the person installing declines it. A bundle that
13
+ * runs code on the server installs only after an explicit yes in its card,
14
+ * which the server insists on too (story 194).
13
15
  */
14
16
  import { css, html, nothing, repeat } from '@umbraco-cms/backoffice/external/lit'
15
17
  import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'
@@ -29,6 +31,8 @@ export default class CromboloBundlesMarketplaceElement extends UmbLitElement {
29
31
  _declined: { state: true },
30
32
  _installs: { state: true },
31
33
  _elsewhere: { state: true },
34
+ _consenting: { state: true },
35
+ _trusted: { state: true },
32
36
  }
33
37
 
34
38
  constructor() {
@@ -45,6 +49,8 @@ export default class CromboloBundlesMarketplaceElement extends UmbLitElement {
45
49
  this._declined = new Set()
46
50
  this._installs = true
47
51
  this._elsewhere = null
52
+ this._consenting = ''
53
+ this._trusted = false
48
54
  }
49
55
 
50
56
  connectedCallback() {
@@ -81,11 +87,40 @@ export default class CromboloBundlesMarketplaceElement extends UmbLitElement {
81
87
  this.#load()
82
88
  }
83
89
 
84
- async #install(item) {
90
+ /** Asks first when the bundle runs code on the server; installs otherwise. */
91
+ #requestInstall(item) {
92
+ if (item.carries?.server) this.#askConsent(item)
93
+ else this.#install(item, false)
94
+ }
95
+
96
+ #askConsent(item) {
97
+ this._consenting = item.name
98
+ this._trusted = false
99
+ }
100
+
101
+ #cancelConsent() {
102
+ this._consenting = ''
103
+ this._trusted = false
104
+ }
105
+
106
+ async #install(item, acceptServerCode) {
85
107
  this._busy = item.name
86
108
  this._notice = ''
87
109
  try {
88
- const outcome = await installBundle(item.name, item.version, !this._declined.has(item.name))
110
+ const outcome = await installBundle(
111
+ item.name,
112
+ item.version,
113
+ !this._declined.has(item.name),
114
+ acceptServerCode,
115
+ )
116
+ // The version that would install may have gained server code since the
117
+ // list was read: the server says so, and the card asks.
118
+ if (outcome.needsServerConsent && !acceptServerCode) {
119
+ this._notice = outcome.message ?? ''
120
+ this.#askConsent({ ...item, carries: { ...item.carries, server: true } })
121
+ return
122
+ }
123
+ this._consenting = ''
89
124
  // The dependency line is what there is to commit, so it is shown rather
90
125
  // than described: the install lives in this node's node_modules until it
91
126
  // is in the site's repository.
@@ -120,6 +155,43 @@ export default class CromboloBundlesMarketplaceElement extends UmbLitElement {
120
155
  `
121
156
  }
122
157
 
158
+ /** The explicit yes a bundle that runs code on the server needs, in its own card. */
159
+ #consent(item) {
160
+ return html`
161
+ <div class="consent" role="group" aria-label="Install code that runs on the server">
162
+ <p>
163
+ <strong>This bundle runs code on the server.</strong> Once your site's developers turn
164
+ it on, its code can read and change the site's data, files and settings.
165
+ </p>
166
+ <p class="meta">
167
+ <span>Published by ${item.publisher ?? 'an unnamed publisher'}</span>
168
+ <a href=${item.links.npm} target="_blank" rel="noopener">npm</a>
169
+ ${
170
+ item.links.repository
171
+ ? html`<a href=${item.links.repository} target="_blank" rel="noopener">source</a>`
172
+ : nothing
173
+ }
174
+ </p>
175
+ <uui-checkbox
176
+ label="I trust this publisher with the site's server"
177
+ .checked=${this._trusted}
178
+ @change=${(event) => {
179
+ this._trusted = event.target.checked
180
+ }}></uui-checkbox>
181
+ <div class="actions">
182
+ <uui-button
183
+ look="primary"
184
+ color="warning"
185
+ label="Install server code"
186
+ ?disabled=${!this._trusted}
187
+ .state=${this._busy === item.name ? 'waiting' : undefined}
188
+ @click=${() => this.#install(item, true)}></uui-button>
189
+ <uui-button look="secondary" label="Cancel" @click=${this.#cancelConsent}></uui-button>
190
+ </div>
191
+ </div>
192
+ `
193
+ }
194
+
123
195
  #empty() {
124
196
  return html`
125
197
  <uui-box headline="No bundles published yet">
@@ -184,12 +256,14 @@ export default class CromboloBundlesMarketplaceElement extends UmbLitElement {
184
256
  ? this._elsewhere
185
257
  ? html`<p class="meta">${this.#elsewhereLink() || this._elsewhere.message}</p>`
186
258
  : html`<p class="meta">Add it to the site with <code>bun add ${item.name}</code>, then deploy.</p>`
187
- : html`
259
+ : this._consenting === item.name
260
+ ? this.#consent(item)
261
+ : html`
188
262
  <uui-button
189
263
  look="primary"
190
264
  label="Install"
191
265
  .state=${this._busy === item.name ? 'waiting' : undefined}
192
- @click=${() => this.#install(item)}></uui-button>
266
+ @click=${() => this.#requestInstall(item)}></uui-button>
193
267
  `
194
268
  }
195
269
  </uui-box>
@@ -253,6 +327,16 @@ export default class CromboloBundlesMarketplaceElement extends UmbLitElement {
253
327
  display: block;
254
328
  margin-bottom: var(--uui-size-space-4, 12px);
255
329
  }
330
+ .consent {
331
+ padding: var(--uui-size-space-4, 12px);
332
+ border-left: 3px solid var(--uui-color-warning, #f0ac00);
333
+ background: var(--uui-color-surface-alt, #f3f3f5);
334
+ }
335
+ .consent .actions {
336
+ display: flex;
337
+ gap: var(--uui-size-space-3, 9px);
338
+ margin-top: var(--uui-size-space-4, 12px);
339
+ }
256
340
  `
257
341
  }
258
342
 
@@ -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.33.1",
5
+ "version": "0.34.0",
6
6
  "allowPublicAccess": true,
7
7
  "extensions": [
8
8
  {
@@ -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.33.1",
5
+ "version": "0.34.0",
6
6
  "allowPublicAccess": false,
7
7
  "extensions": [
8
8
  {
@@ -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.33.1",
5
+ "version": "0.34.0",
6
6
  "allowPublicAccess": true,
7
7
  "extensions": [
8
8
  {
@@ -2,7 +2,7 @@
2
2
  "$schema": "../../backoffice-dist/dist/umbraco-package-schema.json",
3
3
  "name": "Crombolo",
4
4
  "id": "Crombolo.Core",
5
- "version": "0.33.1",
5
+ "version": "0.34.0",
6
6
  "allowPublicAccess": false,
7
7
  "extensions": [
8
8
  {