@crombolo/backoffice-host 0.41.1 → 0.43.1

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.
Files changed (35) hide show
  1. package/NOTICE +9 -0
  2. package/package.json +3 -3
  3. package/plugin/addresses-dashboard.js +3 -2
  4. package/plugin/app-preview/umbraco-package.json +1 -1
  5. package/plugin/approvals-active.js +40 -0
  6. package/plugin/audit-dashboard.js +3 -2
  7. package/plugin/branding/localization-en.js +9 -3
  8. package/plugin/branding/sign-in.js +0 -31
  9. package/plugin/branding/theme-dark.css +19 -5
  10. package/plugin/branding/theme.css +41 -19
  11. package/plugin/breadcrumb.js +29 -0
  12. package/plugin/changes-dashboard.js +3 -2
  13. package/plugin/edit-conflicts.js +11 -21
  14. package/plugin/jobs-dashboard.js +3 -2
  15. package/plugin/localizations/umbraco-package.json +1 -1
  16. package/plugin/notifications-dialog.js +8 -35
  17. package/plugin/overview-dashboard.js +412 -0
  18. package/plugin/overview-format.js +71 -0
  19. package/plugin/seo/umbraco-package.json +1 -1
  20. package/plugin/settings-cards.js +189 -0
  21. package/plugin/settings-section.js +436 -0
  22. package/plugin/side-panel/host.js +7 -63
  23. package/plugin/side-panel/layout.js +0 -15
  24. package/plugin/sign-in/umbraco-package.json +1 -1
  25. package/plugin/tsx-editors.js +56 -164
  26. package/plugin/umbraco-package.json +26 -55
  27. package/plugin/workflow-client.js +3 -0
  28. package/plugin/workflow-designer.js +17 -2
  29. package/src/branding.ts +4 -0
  30. package/plugin/branding/branding.js +0 -188
  31. package/plugin/branding/client-credentials.js +0 -49
  32. package/plugin/branding/log-viewer-menu.js +0 -70
  33. package/plugin/branding/query-builder.js +0 -28
  34. package/plugin/settings-dashboard.js +0 -123
  35. package/plugin/welcome-dashboard.js +0 -103
@@ -1,26 +1,16 @@
1
1
  /**
2
2
  * Makes Umbraco's template and partial view editors write and read TSX instead
3
- * of Razor. Umbraco's client hard-codes a Razor scaffold for a new template,
4
- * writes a Razor `Layout = "x.cshtml"` block when a master template is chosen,
5
- * starts a new partial view empty, and opens both in an editor configured for
6
- * Razor. This entry point changes the methods that do so — the template
7
- * repository's scaffold, the template workspace's master-template update, the
8
- * partial view repository's scaffold and the code editor's own language — to
9
- * write what a crombolo view is: a default-exported component, with
10
- * `export const layout = '<alias>'` for its master, and for a partial view the
11
- * server's `Empty` snippet. Snippets inserted into a view are translated to TSX
12
- * (`tsx-snippets.js`), and the inserts that have no TSX equivalent — a partial
13
- * view, which needs an import as well as a tag, and Razor's sections — are hidden.
14
- *
15
- * The methods are patched on Umbraco's own classes rather than the extensions
16
- * re-registered: changing the registry once the backoffice is rendering makes
17
- * every open section re-evaluate its extensions, and a route set up in that
18
- * window throws inside Umbraco's code.
3
+ * of Razor. Umbraco's client starts a template with a Razor scaffold, writes a
4
+ * Razor `Layout = "x.cshtml"` block for a master template, starts a partial view
5
+ * empty, and opens both in an editor configured for Razor. The fork of the
6
+ * client (story 235) asks `umbCromboloHooks` at each of those places, and this
7
+ * answers: a default-exported component, `export const layout = '<alias>'` for
8
+ * its master, the server's `Empty` snippet for a partial view, and monaco's
9
+ * TypeScript on a `.tsx` model. Snippets inserted into a view are translated to
10
+ * TSX (`tsx-snippets.js`), and the inserts with no TSX equivalent, a partial view
11
+ * (an import as well as a tag) and Razor's sections, are hidden.
19
12
  */
20
- import { UmbCodeEditorElement } from '@umbraco-cms/backoffice/code-editor'
21
13
  import { PartialViewService } from '@umbraco-cms/backoffice/external/backend-api'
22
- import { UmbPartialViewDetailRepository } from '@umbraco-cms/backoffice/partial-view'
23
- import { UmbTemplateDetailRepository } from '@umbraco-cms/backoffice/template'
24
14
  import { toTsxSnippet } from './tsx-snippets.js'
25
15
 
26
16
  export const SCAFFOLD = `import type { PageProps } from '@crombolo/crombolo'
@@ -87,9 +77,6 @@ const COMPONENTS = 'file:///components'
87
77
  */
88
78
  const BUNDLER = 100
89
79
 
90
- /** Code editors showing a view, rather than a stylesheet, a script or JSON. */
91
- const views = new WeakSet()
92
-
93
80
  let opened = 0
94
81
 
95
82
  function pluginApi() {
@@ -184,154 +171,59 @@ async function configureTsx() {
184
171
  }
185
172
 
186
173
  /**
187
- * Teaches `umb-code-editor` the dialect: `language="tsx"`, and Umbraco's own
188
- * hard-coded `razor`, become monaco's `typescript` on a `.tsx` model.
189
- *
190
- * `language` is a Lit property, so the accessor to wrap is the one Lit defined
191
- * on the prototype. If a future version of either defines it elsewhere, the
192
- * editor keeps Umbraco's Razor rather than this entry point throwing on the way
193
- * in and taking the TSX scaffolds down with it.
174
+ * How a view's code editor works, for the fork's `viewEditor` seam: monaco's
175
+ * `typescript` on a model named as a `.tsx` file, configured before the editor is
176
+ * made, with inserted snippets translated.
194
177
  */
195
- function teachDialect(editors) {
196
- const language = Object.getOwnPropertyDescriptor(editors, 'language')
197
- if (!language?.set) return
198
- Object.defineProperty(editors, 'language', {
199
- ...language,
200
- set(value) {
201
- const view = value === TSX || value === 'razor'
202
- if (view) views.add(this)
203
- else views.delete(this)
204
- language.set.call(this, view ? 'typescript' : value)
178
+ function viewEditor() {
179
+ let configured = { monaco: undefined, ok: false }
180
+ return {
181
+ language: 'typescript',
182
+ async prepare() {
183
+ configured = await configureTsx()
205
184
  },
206
- })
207
-
208
- const firstUpdated = editors.firstUpdated
209
- editors.firstUpdated = async function (changed) {
210
- if (!views.has(this)) return await firstUpdated.call(this, changed)
211
- const { monaco, ok } = await configureTsx()
212
- await firstUpdated.call(this, changed)
213
- const editor = this.editor?.monacoEditor
214
- const created = editor?.getModel()
215
- if (!monaco || !editor || !created) return
216
- if (!ok) {
217
- // Without the dialect, TypeScript reads a view as a plain `.ts` file and
218
- // underlines every tag in it. Plain text says less and lies less.
219
- monaco.editor.setModelLanguage(created, 'plaintext')
220
- return
221
- }
222
- // monaco names the model it creates `inmemory://model/1`, and a name with no
223
- // `.tsx` on it is a file TypeScript refuses to read JSX in — every tag in
224
- // the view would be a syntax error. So the model is replaced by one named
225
- // as the file it is.
226
- const model = monaco.editor.createModel(
227
- created.getValue(),
228
- 'typescript',
229
- monaco.Uri.parse(`${COMPONENTS}/view-${++opened}.tsx`),
230
- )
231
- editor.setModel(model)
232
- created.dispose()
233
- editor.onDidDispose(() => model.dispose())
234
- }
235
-
236
- const insert = editors.insert
237
- editors.insert = function (text) {
238
- return insert.call(this, views.has(this) ? toTsxSnippet(text) : text)
185
+ created(editor) {
186
+ const { monaco, ok } = configured
187
+ const created = editor?.getModel?.()
188
+ if (!monaco || !created) return
189
+ if (!ok) {
190
+ // Without the dialect, TypeScript reads a view as a plain `.ts` file and
191
+ // underlines every tag in it. Plain text says less and lies less.
192
+ monaco.editor.setModelLanguage(created, 'plaintext')
193
+ return
194
+ }
195
+ // monaco names the model it creates `inmemory://model/1`, and a name with no
196
+ // `.tsx` on it is a file TypeScript refuses to read JSX in: every tag in the
197
+ // view would be a syntax error. So the model is replaced by one named as the
198
+ // file it is.
199
+ const model = monaco.editor.createModel(
200
+ created.getValue(),
201
+ 'typescript',
202
+ monaco.Uri.parse(`${COMPONENTS}/view-${++opened}.tsx`),
203
+ )
204
+ editor.setModel(model)
205
+ created.dispose()
206
+ editor.onDidDispose(() => model.dispose())
207
+ },
208
+ insert: toTsxSnippet,
239
209
  }
240
210
  }
241
211
 
242
- /**
243
- * The template editor's inserts that cannot become TSX. A partial view is an
244
- * import as well as a tag, which an insert at the cursor cannot write, and
245
- * sections are Razor's way for a layout to take content from a page, where a
246
- * TSX layout takes props.
247
- */
248
- async function hideRazorInserts() {
249
- const menu = (await customElements.whenDefined('umb-templating-insert-menu')).prototype
250
- Object.defineProperty(menu, 'hidePartialViews', {
251
- configurable: true,
252
- get: () => true,
253
- set: () => {},
254
- })
255
-
256
- const editor = (await customElements.whenDefined('umb-template-workspace-editor')).prototype
257
- const updated = editor.updated
258
- editor.updated = function (changed) {
259
- updated?.call(this, changed)
260
- const sections = this.shadowRoot?.querySelector('#sections-button')
261
- if (sections) sections.style.display = 'none'
262
- }
263
- }
264
-
265
- /**
266
- * The value builder's preview shows the snippet it will insert, so it shows the
267
- * TSX one. Its output is still Umbraco's, and is translated on insert with the rest.
268
- */
269
- async function previewFieldsAsTsx() {
270
- const modal = (await customElements.whenDefined('umb-templating-page-field-builder-modal'))
271
- .prototype
272
- const render = modal.render
273
- modal.render = function () {
274
- const result = render.call(this)
275
- if (Array.isArray(result?.values)) result.values = result.values.map(toTsxSnippet)
276
- return result
277
- }
278
- const updated = modal.updated
279
- modal.updated = function (changed) {
280
- updated?.call(this, changed)
281
- const block = this.shadowRoot?.querySelector('umb-code-block')
282
- if (block && block.getAttribute('language') !== 'TypeScript') {
283
- block.setAttribute('language', 'TypeScript')
284
- block.language = 'TypeScript'
285
- }
286
- }
212
+ /** The fork's seams, answered for TSX views. */
213
+ export const TSX_HOOKS = {
214
+ viewEditor: (language) => (language === TSX || language === 'razor' ? viewEditor() : undefined),
215
+ templateScaffold: () => SCAFFOLD,
216
+ async partialViewScaffold() {
217
+ const { data } = await PartialViewService.getPartialViewSnippetById({ path: { id: 'Empty' } })
218
+ return data?.content
219
+ },
220
+ writeLayout: withLayout,
221
+ translateSnippet: toTsxSnippet,
222
+ viewLanguageLabel: 'TypeScript',
223
+ hideRazorInserts: true,
287
224
  }
288
225
 
289
226
  export const onInit = async () => {
290
- teachDialect(UmbCodeEditorElement.prototype)
291
- // Registered lazily, so these wait for the editor to be opened
292
- hideRazorInserts()
293
- previewFieldsAsTsx()
294
-
295
- const repository = UmbTemplateDetailRepository.prototype
296
- const createScaffold = repository.createScaffold
297
- repository.createScaffold = async function (preset) {
298
- const result = await createScaffold.call(this, preset)
299
- if (result.data) result.data.content = SCAFFOLD
300
- return result
301
- }
302
-
303
- const partialViews = UmbPartialViewDetailRepository.prototype
304
- const createPartialViewScaffold = partialViews.createScaffold
305
- partialViews.createScaffold = async function (preset) {
306
- const result = await createPartialViewScaffold.call(this, preset)
307
- // Started from a snippet it has content already; empty, it gets the skeleton
308
- if (result.data && !result.data.content) {
309
- const { data } = await PartialViewService.getPartialViewSnippetById({ path: { id: 'Empty' } })
310
- if (data?.content) result.data.content = data.content
311
- }
312
- return result
313
- }
314
-
315
- // The workspace context is not exported; it is the module beside the package's
316
- // entry, which the import map resolves to the very module Umbraco loads
317
- const { UmbTemplateWorkspaceContext } = await import(
318
- new URL(
319
- './workspace/template-workspace.context.js',
320
- import.meta.resolve('@umbraco-cms/backoffice/template'),
321
- ).href
322
- )
323
- const workspace = UmbTemplateWorkspaceContext.prototype
324
- const setLayoutTemplate = workspace.setLayoutTemplate
325
- workspace.setLayoutTemplate = async function (unique, updateLayoutBlock) {
326
- // Umbraco's own update writes Razor; the state it keeps is what we want
327
- await setLayoutTemplate.call(this, unique, false)
328
- if (!updateLayoutBlock) return unique
329
- const items = unique ? (await this.itemRepository.requestItems([unique])).data : []
330
- const content = this._data.getCurrent()?.content ?? ''
331
- this._data.updateCurrent({
332
- content: withLayout(content, items?.[0]?.alias ?? null),
333
- layoutTemplate: unique ? { unique } : null,
334
- })
335
- return unique
336
- }
227
+ const { umbCromboloHooks } = await import('@umbraco-cms/backoffice/extension-registry')
228
+ Object.assign(umbCromboloHooks, TSX_HOOKS)
337
229
  }
@@ -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.41.1",
5
+ "version": "0.43.1",
6
6
  "allowPublicAccess": false,
7
7
  "extensions": [
8
8
  {
@@ -413,14 +413,14 @@
413
413
  },
414
414
  {
415
415
  "type": "dashboard",
416
- "alias": "Crombolo.Dashboard.Welcome",
417
- "name": "Crombolo Welcome Dashboard",
418
- "element": "/crombolo-plugin/welcome-dashboard.js",
416
+ "alias": "Crombolo.Dashboard.Overview",
417
+ "name": "Crombolo Overview Dashboard",
418
+ "element": "/crombolo-plugin/overview-dashboard.js",
419
419
  "weight": 20,
420
420
  "overwrites": ["Umb.Dashboard.UmbracoNews"],
421
421
  "meta": {
422
- "label": "Welcome",
423
- "pathname": "welcome"
422
+ "label": "Overview",
423
+ "pathname": "overview"
424
424
  },
425
425
  "conditions": [
426
426
  {
@@ -430,22 +430,11 @@
430
430
  ]
431
431
  },
432
432
  {
433
- "type": "dashboard",
434
- "alias": "Crombolo.Dashboard.Settings",
435
- "name": "Crombolo Settings Dashboard",
436
- "element": "/crombolo-plugin/settings-dashboard.js",
437
- "weight": 500,
438
- "overwrites": ["Umb.Dashboard.SettingsWelcome"],
439
- "meta": {
440
- "label": "Welcome",
441
- "pathname": "welcome"
442
- },
443
- "conditions": [
444
- {
445
- "alias": "Umb.Condition.SectionAlias",
446
- "match": "Umb.Section.Settings"
447
- }
448
- ]
433
+ "type": "sectionLayout",
434
+ "alias": "Crombolo.SectionLayout.Settings",
435
+ "name": "Crombolo Settings Layout",
436
+ "forSection": "Umb.Section.Settings",
437
+ "element": "/crombolo-plugin/settings-section.js"
449
438
  },
450
439
  {
451
440
  "type": "backofficeEntryPoint",
@@ -510,12 +499,6 @@
510
499
  }
511
500
  ]
512
501
  },
513
- {
514
- "type": "backofficeEntryPoint",
515
- "alias": "Crombolo.EntryPoint.Branding",
516
- "name": "Crombolo Branding",
517
- "js": "/crombolo-plugin/branding/branding.js"
518
- },
519
502
  {
520
503
  "type": "backofficeEntryPoint",
521
504
  "alias": "Crombolo.EntryPoint.HelpMenu",
@@ -588,12 +571,6 @@
588
571
  "propertyEditorSchemaAlias": "Crombolo.FormPicker"
589
572
  }
590
573
  },
591
- {
592
- "type": "backofficeEntryPoint",
593
- "alias": "Crombolo.EntryPoint.ClientCredentials",
594
- "name": "Crombolo Client Credential Prefix",
595
- "js": "/crombolo-plugin/branding/client-credentials.js"
596
- },
597
574
  {
598
575
  "type": "backofficeEntryPoint",
599
576
  "alias": "Crombolo.EntryPoint.ComponentsTree",
@@ -606,24 +583,12 @@
606
583
  "name": "Crombolo Content Type Labels",
607
584
  "js": "/crombolo-plugin/branding/content-type-labels.js"
608
585
  },
609
- {
610
- "type": "backofficeEntryPoint",
611
- "alias": "Crombolo.EntryPoint.QueryBuilder",
612
- "name": "Crombolo Query Builder Language",
613
- "js": "/crombolo-plugin/branding/query-builder.js"
614
- },
615
586
  {
616
587
  "type": "backofficeEntryPoint",
617
588
  "alias": "Crombolo.EntryPoint.SignIn",
618
589
  "name": "Crombolo Sign-in Button",
619
590
  "js": "/crombolo-plugin/branding/sign-in.js"
620
591
  },
621
- {
622
- "type": "backofficeEntryPoint",
623
- "alias": "Crombolo.EntryPoint.LogViewerMenu",
624
- "name": "Crombolo Log Viewer Search Menu",
625
- "js": "/crombolo-plugin/branding/log-viewer-menu.js"
626
- },
627
592
  {
628
593
  "type": "backofficeEntryPoint",
629
594
  "alias": "Crombolo.EntryPoint.NotificationsDialog",
@@ -637,15 +602,22 @@
637
602
  "overwrites": ["Umb.GlobalContext.Icons"],
638
603
  "api": "/crombolo-plugin/branding/icon-registry.js"
639
604
  },
605
+ {
606
+ "type": "condition",
607
+ "alias": "Crombolo.Condition.ApprovalsActive",
608
+ "name": "Crombolo Approvals Active Condition",
609
+ "api": "/crombolo-plugin/approvals-active.js"
610
+ },
640
611
  {
641
612
  "type": "section",
642
613
  "alias": "Crombolo.Section.Workflow",
643
614
  "name": "Crombolo Workflow Section",
644
615
  "weight": 40,
645
616
  "meta": {
646
- "label": "Workflows",
617
+ "label": "Approvals",
647
618
  "pathname": "workflow"
648
- }
619
+ },
620
+ "conditions": [{ "alias": "Crombolo.Condition.ApprovalsActive" }]
649
621
  },
650
622
  {
651
623
  "type": "sectionView",
@@ -705,20 +677,18 @@
705
677
  ]
706
678
  },
707
679
  {
708
- "type": "sectionView",
709
- "alias": "Crombolo.SectionView.Workflow.Designer",
680
+ "type": "dashboard",
681
+ "alias": "Crombolo.Dashboard.Workflows",
710
682
  "name": "Crombolo Workflow Designer",
711
683
  "element": "/crombolo-plugin/workflow-designer.js",
712
- "weight": 100,
713
684
  "meta": {
714
685
  "label": "Workflows",
715
- "pathname": "workflows",
716
- "icon": "icon-mindmap"
686
+ "pathname": "workflows"
717
687
  },
718
688
  "conditions": [
719
689
  {
720
690
  "alias": "Umb.Condition.SectionAlias",
721
- "match": "Crombolo.Section.Workflow"
691
+ "match": "Umb.Section.Settings"
722
692
  },
723
693
  {
724
694
  "alias": "Umb.Condition.CurrentUser.IsAdmin"
@@ -740,7 +710,8 @@
740
710
  {
741
711
  "alias": "Umb.Condition.WorkspaceAlias",
742
712
  "match": "Umb.Workspace.Document"
743
- }
713
+ },
714
+ { "alias": "Crombolo.Condition.ApprovalsActive" }
744
715
  ]
745
716
  }
746
717
  ]
@@ -38,3 +38,6 @@ export const saveWorkflow = (alias, workflow) =>
38
38
  })
39
39
  export const deleteWorkflow = (alias) =>
40
40
  call(`workflows/${encodeURIComponent(alias)}`, { method: 'DELETE' })
41
+ export const previewDelete = (alias) =>
42
+ call(`workflows/${encodeURIComponent(alias)}/preview`, { method: 'DELETE' })
43
+ export const approvalsActive = () => call('active')
@@ -12,7 +12,14 @@ import '@umbraco-cms/backoffice/document'
12
12
  import { css, html, nothing, unsafeCSS } from '@umbraco-cms/backoffice/external/lit'
13
13
  import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'
14
14
  import { UMB_NOTIFICATION_CONTEXT } from '@umbraco-cms/backoffice/notification'
15
- import { deleteWorkflow, listWorkflows, previewWorkflow, saveWorkflow } from './workflow-client.js'
15
+ import { approvalsChanged } from './approvals-active.js'
16
+ import {
17
+ deleteWorkflow,
18
+ listWorkflows,
19
+ previewDelete,
20
+ previewWorkflow,
21
+ saveWorkflow,
22
+ } from './workflow-client.js'
16
23
  import { ancestors, BOX, drawGraph, GRAPH_STYLES, layout, wouldLoop } from './workflow-graph.js'
17
24
 
18
25
  const ON_EDIT = {
@@ -273,14 +280,21 @@ export default class CromboloWorkflowDesignerElement extends UmbLitElement {
273
280
  // The green toast every workspace shows on a save.
274
281
  this.#notifications?.peek('positive', { data: { message: 'Workflow saved' } })
275
282
  this._originalAlias = this._editing.alias
283
+ approvalsChanged()
276
284
  await this.#load()
277
285
  }
278
286
 
279
287
  /** From the list or the editor: the workflow by its name and the alias its file has. */
280
288
  async #delete(name, alias) {
289
+ const preview = await previewDelete(alias)
290
+ const waiting = preview.ok ? preview.affected : []
291
+ const withdrawn =
292
+ waiting.length > 0
293
+ ? `\n\nThe requests for these pages, waiting for approval, are withdrawn:\n${waiting.map((a) => `- ${a.page}`).join('\n')}`
294
+ : ''
281
295
  if (
282
296
  !window.confirm(
283
- `Delete the workflow "${name}"? Pages it covers will publish without approval.`,
297
+ `Delete the workflow "${name}"? Pages it covers will publish without approval.${withdrawn}`,
284
298
  )
285
299
  )
286
300
  return
@@ -290,6 +304,7 @@ export default class CromboloWorkflowDesignerElement extends UmbLitElement {
290
304
  return
291
305
  }
292
306
  this._editing = undefined
307
+ approvalsChanged()
293
308
  await this.#load()
294
309
  }
295
310
 
package/src/branding.ts CHANGED
@@ -15,11 +15,15 @@
15
15
  /// <reference path="./text-imports.d.ts" />
16
16
  import faviconText from '../plugin/branding/favicon.svg' with { type: 'text' }
17
17
  import logoText from '../plugin/branding/logo-header.svg' with { type: 'text' }
18
+ import logoDarkText from '../plugin/branding/logo-header-dark.svg' with { type: 'text' }
18
19
  import themeText from '../plugin/branding/theme.css' with { type: 'text' }
19
20
 
20
21
  /** The mark and wordmark, for a header or a sign-in card. */
21
22
  export const logoSvg: string = logoText.trim()
22
23
 
24
+ /** The same logo with cream lettering, for a dark ground. */
25
+ export const logoDarkSvg: string = logoDarkText.trim()
26
+
23
27
  /** The mark alone, square, for a tab icon. */
24
28
  export const faviconSvg: string = faviconText.trim()
25
29