@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.
@@ -10,8 +10,8 @@
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
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
+ * asks for permissions installs only once someone grants each one, as it
14
+ * asks, in its card, which the server insists on too (stories 222, 308).
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'
@@ -35,6 +35,10 @@ export default class CromboloBundlesMarketplaceElement extends UmbLitElement {
35
35
  _consenting: { state: true },
36
36
  _trusted: { state: true },
37
37
  _asks: { state: true },
38
+ _asksActAs: { state: true },
39
+ _layout: { state: true },
40
+ _layoutChoice: { state: true },
41
+ _actAs: { state: true },
38
42
  _reviewing: { state: true },
39
43
  _signatures: { state: true },
40
44
  }
@@ -46,7 +50,7 @@ export default class CromboloBundlesMarketplaceElement extends UmbLitElement {
46
50
  this._error = ''
47
51
  this._busy = ''
48
52
  this._notice = ''
49
- this._keyword = 'crombolo-bundle'
53
+ this._keyword = 'crombolo-extension'
50
54
  this._url = ''
51
55
  this._query = ''
52
56
  this._appliesContent = true
@@ -56,6 +60,8 @@ export default class CromboloBundlesMarketplaceElement extends UmbLitElement {
56
60
  this._consenting = ''
57
61
  this._trusted = false
58
62
  this._asks = []
63
+ this._asksActAs = false
64
+ this._actAs = 'installer'
59
65
  this._reviewing = ''
60
66
  this._signatures = new Map()
61
67
  }
@@ -86,7 +92,7 @@ export default class CromboloBundlesMarketplaceElement extends UmbLitElement {
86
92
  /** The host's own place for installs, when it gave one. */
87
93
  #elsewhereLink() {
88
94
  const url = this._elsewhere?.url
89
- return url ? html`<a href=${url} target="_blank" rel="noopener">Add bundles</a>` : ''
95
+ return url ? html`<a href=${url} target="_blank" rel="noopener">Add extensions</a>` : ''
90
96
  }
91
97
 
92
98
  #search(event) {
@@ -152,10 +158,14 @@ export default class CromboloBundlesMarketplaceElement extends UmbLitElement {
152
158
  `
153
159
  }
154
160
 
155
- #askConsent(item, asks) {
161
+ #askConsent(item, outcome) {
156
162
  this._consenting = item.name
157
163
  this._trusted = false
158
- this._asks = asks ?? []
164
+ this._asks = outcome.permissions ?? []
165
+ this._asksActAs = outcome.asksActAs === true
166
+ // Story 312: the site layout its page templates sit in, its suggestion first.
167
+ this._layout = outcome.layout
168
+ this._layoutChoice = outcome.layout?.suggested ?? ''
159
169
  }
160
170
 
161
171
  #cancelConsent() {
@@ -164,7 +174,7 @@ export default class CromboloBundlesMarketplaceElement extends UmbLitElement {
164
174
  this._asks = []
165
175
  }
166
176
 
167
- async #install(item, acceptServerCode) {
177
+ async #install(item, granting) {
168
178
  this._busy = item.name
169
179
  this._notice = ''
170
180
  try {
@@ -172,14 +182,17 @@ export default class CromboloBundlesMarketplaceElement extends UmbLitElement {
172
182
  item.name,
173
183
  item.version,
174
184
  !this._declined.has(item.name),
175
- acceptServerCode,
176
- acceptServerCode ? this._asks.map((ask) => ask.permission) : [],
185
+ granting ? this._asks.map((ask) => ask.permission) : [],
186
+ granting && this._asksActAs ? this._actAs : undefined,
187
+ granting && this._layout && this._layoutChoice
188
+ ? { [this._layout.key]: this._layoutChoice }
189
+ : undefined,
177
190
  )
178
- // Server code, or a version that asks for more than was approved: the
179
- // server says what it asks to do, and the card asks.
180
- if (outcome.needsServerConsent) {
181
- if (acceptServerCode) this._notice = outcome.message ?? ''
182
- this.#askConsent(item, outcome.permissions)
191
+ // It asks for permissions, or a version asks for more than was granted:
192
+ // the server says what, with the reasons, and the card asks.
193
+ if (outcome.needsGrant) {
194
+ if (granting) this._notice = outcome.message ?? ''
195
+ this.#askConsent(item, outcome)
183
196
  return
184
197
  }
185
198
  this._consenting = ''
@@ -218,22 +231,57 @@ export default class CromboloBundlesMarketplaceElement extends UmbLitElement {
218
231
  `
219
232
  }
220
233
 
221
- /** The explicit yes a bundle that runs code on the server needs, in its own card. */
234
+ /** What it asks for, each permission with its reason, granted together in its own card. */
222
235
  #consent(item) {
223
236
  return html`
224
- <div class="consent" role="group" aria-label="Install code that runs on the server">
237
+ <div class="consent" role="group" aria-label="What it asks for">
225
238
  ${this.#signature(item)}
226
239
  <p>
227
- <strong>This bundle runs code on the server.</strong> Once your site's developers turn
228
- it on, its code can read and change the site's data, files and settings.
240
+ <strong>It asks for these permissions.</strong> Grant them to install it: it may do only
241
+ this, and its screens act as whoever is signed in.
229
242
  </p>
243
+ <ul class="asks">
244
+ ${this._asks.map(
245
+ (ask) =>
246
+ html`<li>
247
+ ${ask.allows}${ask.origins?.length ? html`: ${ask.origins.join(', ')}` : nothing}
248
+ ${ask.reason ? html`<span class="reason">${ask.reason}</span>` : nothing}
249
+ </li>`,
250
+ )}
251
+ </ul>
230
252
  ${
231
- this._asks.length > 0
232
- ? html`<p>It asks to:</p>
233
- <ul class="asks">
234
- ${this._asks.map((ask) => html`<li>${ask.allows}</li>`)}
235
- </ul>`
236
- : html`<p>It asks for no access to the site's content, members or settings.</p>`
253
+ this._asksActAs
254
+ ? html`<uui-select
255
+ label="Acts for"
256
+ .options=${[
257
+ {
258
+ name: 'You, who install it',
259
+ value: 'installer',
260
+ selected: this._actAs === 'installer',
261
+ },
262
+ { name: 'Whoever uses it', value: 'caller', selected: this._actAs === 'caller' },
263
+ ]}
264
+ @change=${(event) => {
265
+ this._actAs = event.target.value
266
+ }}></uui-select>`
267
+ : nothing
268
+ }
269
+ ${
270
+ this._layout
271
+ ? html`<uui-select
272
+ label=${this._layout.label}
273
+ .options=${[
274
+ { name: 'None: a page of its own', value: '', selected: !this._layoutChoice },
275
+ ...this._layout.values.map((layout) => ({
276
+ name: layout,
277
+ value: layout,
278
+ selected: layout === this._layoutChoice,
279
+ })),
280
+ ]}
281
+ @change=${(event) => {
282
+ this._layoutChoice = event.target.value
283
+ }}></uui-select>`
284
+ : nothing
237
285
  }
238
286
  <p class="meta">
239
287
  <span>Published by ${item.publisher ?? 'an unnamed publisher'}</span>
@@ -245,7 +293,7 @@ export default class CromboloBundlesMarketplaceElement extends UmbLitElement {
245
293
  }
246
294
  </p>
247
295
  <uui-checkbox
248
- label="I trust this publisher, and approve what it asks to do"
296
+ label="I trust this publisher, and grant what it asks for"
249
297
  .checked=${this._trusted}
250
298
  @change=${(event) => {
251
299
  this._trusted = event.target.checked
@@ -254,7 +302,7 @@ export default class CromboloBundlesMarketplaceElement extends UmbLitElement {
254
302
  <uui-button
255
303
  look="primary"
256
304
  color="warning"
257
- label="Approve and install"
305
+ label="Grant and install"
258
306
  ?disabled=${!this._trusted}
259
307
  .state=${this._busy === item.name ? 'waiting' : undefined}
260
308
  @click=${() => this.#install(item, true)}></uui-button>
@@ -266,7 +314,7 @@ export default class CromboloBundlesMarketplaceElement extends UmbLitElement {
266
314
 
267
315
  #empty() {
268
316
  return html`
269
- <uui-box headline="No bundles published yet">
317
+ <uui-box headline="No extensions published yet">
270
318
  <p>Nothing on npm carries the <code>${this._keyword}</code> keyword yet.</p>
271
319
  </uui-box>
272
320
  `
@@ -280,8 +328,8 @@ export default class CromboloBundlesMarketplaceElement extends UmbLitElement {
280
328
  <div id="head">
281
329
  <uui-input
282
330
  type="search"
283
- label="Search bundles"
284
- placeholder="Search npm for bundles"
331
+ label="Search extensions"
332
+ placeholder="Search npm for extensions"
285
333
  @change=${this.#search}></uui-input>
286
334
  ${
287
335
  this._url
@@ -296,7 +344,7 @@ export default class CromboloBundlesMarketplaceElement extends UmbLitElement {
296
344
  ? nothing
297
345
  : this._elsewhere
298
346
  ? html`<div id="notice">${this._elsewhere.message} ${this.#elsewhereLink()}</div>`
299
- : html`<div id="notice">Bundles are added to this site by a deploy, so that every server has them: add one to the site's <code>package.json</code> and deploy it.</div>`
347
+ : html`<div id="notice">Extensions are added to this site by a deploy, so that every server has them: add one to the site's <code>package.json</code> and deploy it.</div>`
300
348
  }
301
349
  ${
302
350
  this._items.length === 0 && !this._error
@@ -408,6 +456,10 @@ export default class CromboloBundlesMarketplaceElement extends UmbLitElement {
408
456
  border-left: 3px solid var(--uui-color-warning, #f0ac00);
409
457
  background: var(--uui-color-surface-alt, #f3f3f5);
410
458
  }
459
+ .consent .reason {
460
+ display: block;
461
+ color: var(--uui-color-text-alt);
462
+ }
411
463
  .consent .asks {
412
464
  margin: 0 0 var(--uui-size-space-3, 9px);
413
465
  padding-left: 1.25em;
@@ -28,6 +28,9 @@ export function signatureWords(provenance, refused, policy) {
28
28
  } else if (provenance?.state === 'local') {
29
29
  label = 'From this site'
30
30
  detail = "Linked from this site's own code, not from a package registry."
31
+ } else if (provenance?.state === 'vouched') {
32
+ label = 'From the host'
33
+ detail = 'Applied by the platform that runs this site, which checked where it came from.'
31
34
  } else if (provenance?.state === 'unchecked') {
32
35
  tone = 'warning'
33
36
  label = "Couldn't be checked right now"
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Bundles, a Settings tool (story 238): Marketplace, Installed and Created as
3
- * tabs, each at an address of its own under `dashboard/bundles/`. The views
3
+ * tabs, each at an address of its own under `dashboard/extensions/`. The views
4
4
  * are the ones Umbraco's Packages section showed, which this replaces.
5
5
  */
6
6
  import { css, html } from '@umbraco-cms/backoffice/external/lit'
@@ -14,7 +14,7 @@ export const BUNDLE_TABS = [
14
14
  ]
15
15
 
16
16
  /** Where the tool is, relative to the back office. */
17
- export const BUNDLES_PATH = 'section/settings/dashboard/bundles'
17
+ export const BUNDLES_PATH = 'section/settings/dashboard/extensions'
18
18
 
19
19
  export default class CromboloBundlesToolElement extends UmbLitElement {
20
20
  static properties = { _routerPath: { state: true }, _active: { state: true } }
@@ -207,7 +207,13 @@ export default class CromboloChangesDashboardElement extends UmbLitElement {
207
207
  <h4>
208
208
  ${SOURCE_LABEL[group.source] ?? group.source}
209
209
  ${pending?.label ? html`<strong>${pending.label}</strong>` : group.scope ? html`<code>${group.scope}</code>` : nothing}
210
+ ${pending?.sitePackage ? html`<uui-tag look="secondary">Site package</uui-tag>` : nothing}
210
211
  </h4>
212
+ ${
213
+ pending?.sitePackage
214
+ ? html`<p class="note">Applying it replaces this site's code, settings and installed extensions with the ones it carries.</p>`
215
+ : nothing
216
+ }
211
217
  ${
212
218
  group.findings.length === 0
213
219
  ? nothing
@@ -27,7 +27,7 @@ export const CI_PERMISSIONS = [
27
27
  verb: 'Crombolo.Remote.InstallCode',
28
28
  label: 'Install code',
29
29
  explain:
30
- 'Install bundles and the code a bundle carries, which runs on the server after a restart.',
30
+ 'Install extensions, and the code a site package carries, which runs on the server after a restart.',
31
31
  },
32
32
  ]
33
33
 
@@ -151,9 +151,24 @@ export default class CromboloCiAccessElement extends UmbLitElement {
151
151
  ${
152
152
  state.remoteEnabled
153
153
  ? nothing
154
- : html`<p class="notice" role="status">
155
- This site does not take pulls or pushes yet, so these rules do nothing until it does.
156
- </p>`
154
+ : html`<div class="notice" role="status">
155
+ <p>Pull and push is disabled on this site.</p>
156
+ <details>
157
+ <summary>How to enable it</summary>
158
+ <ol>
159
+ <li>
160
+ On the server, set <code>CROMBOLO_REMOTE_ACCESS</code>: <code>read</code> to let
161
+ others pull, <code>content</code> to also take content, or <code>all</code> to
162
+ take whole-site pushes and deploys.
163
+ </li>
164
+ <li>Restart the site.</li>
165
+ <li>
166
+ Trust the CI jobs that may reach it below, and give people the pull and push
167
+ permissions they need on their user groups.
168
+ </li>
169
+ </ol>
170
+ </details>
171
+ </div>`
157
172
  }
158
173
  ${this._draft ? this.#form() : nothing}
159
174
  <uui-box headline="Trusted CI jobs">
@@ -219,6 +234,15 @@ export default class CromboloCiAccessElement extends UmbLitElement {
219
234
  uui-box + uui-box {
220
235
  margin-top: var(--uui-size-layout-1);
221
236
  }
237
+ .notice p {
238
+ margin: 0;
239
+ }
240
+ .notice details {
241
+ margin-top: var(--uui-size-space-3);
242
+ }
243
+ .notice summary {
244
+ cursor: pointer;
245
+ }
222
246
  .notice {
223
247
  padding: var(--uui-size-space-4) var(--uui-size-space-5);
224
248
  border-left: 4px solid var(--uui-color-warning);
@@ -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.56.0",
5
+ "version": "0.58.0",
6
6
  "allowPublicAccess": true,
7
7
  "extensions": [
8
8
  {
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Search, a Settings tool: what pages say in search results and when shared,
3
+ * and the back office's search indexes, as two tabs at addresses of their own
4
+ * under `dashboard/search-and-sharing/`. The indexes tab is Umbraco's own
5
+ * screen, whose routes for one index sit below it.
6
+ */
7
+ import { loadManifestElement } from '@umbraco-cms/backoffice/extension-api'
8
+ import { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry'
9
+ import { css, html } from '@umbraco-cms/backoffice/external/lit'
10
+ import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'
11
+
12
+ /** Umbraco's search indexes screen, loaded as its own dashboard, which this tool overwrites, would be. */
13
+ async function indexesScreen() {
14
+ const manifest = umbExtensionsRegistry.getByAlias('Umb.Dashboard.ExamineManagement')
15
+ return { default: await loadManifestElement(manifest.element) }
16
+ }
17
+
18
+ /** The tabs, in order: each one's segment, its label, and its view. */
19
+ export const SEARCH_TABS = [
20
+ { path: 'settings', label: 'Search settings', load: () => import('./seo/dashboard.js') },
21
+ { path: 'indexes', label: 'Search indexes', load: indexesScreen },
22
+ ]
23
+
24
+ /** Where the tool is, relative to the back office. */
25
+ export const SEARCH_PATH = 'section/settings/dashboard/search-and-sharing'
26
+
27
+ export default class CromboloSearchToolElement extends UmbLitElement {
28
+ static properties = { _routerPath: { state: true }, _active: { state: true } }
29
+
30
+ constructor() {
31
+ super()
32
+ this._routerPath = SEARCH_PATH
33
+ this._active = SEARCH_TABS[0].path
34
+ }
35
+
36
+ #routes = [
37
+ ...SEARCH_TABS.map((tab) => ({ path: tab.path, component: tab.load })),
38
+ { path: '', pathMatch: 'full', redirectTo: SEARCH_TABS[0].path },
39
+ ]
40
+
41
+ render() {
42
+ return html`
43
+ <uui-tab-group>
44
+ ${SEARCH_TABS.map(
45
+ (tab) => html`<uui-tab
46
+ label=${tab.label}
47
+ href=${`${this._routerPath}/${tab.path}`}
48
+ ?active=${this._active === tab.path}
49
+ >${tab.label}</uui-tab>`,
50
+ )}
51
+ </uui-tab-group>
52
+ <umb-router-slot
53
+ .routes=${this.#routes}
54
+ @init=${(event) => {
55
+ this._routerPath = event.target.absoluteRouterPath
56
+ }}
57
+ @change=${(event) => {
58
+ const active = event.target.absoluteActiveViewPath ?? ''
59
+ // An index's own page sits below its tab, at indexes/index/<name>.
60
+ this._active =
61
+ SEARCH_TABS.find((tab) => active.includes(`/${tab.path}`))?.path ?? SEARCH_TABS[0].path
62
+ }}
63
+ ></umb-router-slot>
64
+ `
65
+ }
66
+
67
+ static styles = css`
68
+ :host {
69
+ display: flex;
70
+ flex-direction: column;
71
+ height: 100%;
72
+ }
73
+ uui-tab-group {
74
+ flex: none;
75
+ height: auto;
76
+ padding: 0 var(--uui-size-layout-1);
77
+ border-bottom: 1px solid var(--uui-color-border);
78
+ --uui-tab-divider: transparent;
79
+ }
80
+ umb-router-slot {
81
+ display: block;
82
+ flex: 1 1 auto;
83
+ min-height: 0;
84
+ }
85
+ `
86
+ }
87
+
88
+ customElements.define('crombolo-search-tool', CromboloSearchToolElement)
@@ -33,3 +33,7 @@ export const readPreview = (documentKey, culture) => {
33
33
  if (culture) query.set('culture', culture)
34
34
  return json(`/preview?${query}`)
35
35
  }
36
+
37
+ /** Every page of a type's values (story 317): `{ title, description, image, canonical }`. */
38
+ export const saveTypeValues = (contentType, seo) =>
39
+ json('/type', { method: 'PUT', body: JSON.stringify({ contentType, seo }) })