@crombolo/backoffice-host 0.66.0 → 0.67.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.66.0",
3
+ "version": "0.67.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",
@@ -34,7 +34,7 @@
34
34
  "access": "public"
35
35
  },
36
36
  "dependencies": {
37
- "@crombolo/core": "0.66.0",
38
- "@crombolo/backoffice-dist": "0.66.0"
37
+ "@crombolo/core": "0.67.0",
38
+ "@crombolo/backoffice-dist": "0.67.0"
39
39
  }
40
40
  }
@@ -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.66.0",
5
+ "version": "0.67.0",
6
6
  "allowPublicAccess": false,
7
7
  "extensions": [
8
8
  {
@@ -14,6 +14,12 @@ export function approvalsChanged() {
14
14
  for (const listener of listeners) listener()
15
15
  }
16
16
 
17
+ /** Calls `listener` each time approvals may have changed; answers how to stop. */
18
+ export function watchApprovals(listener) {
19
+ listeners.add(listener)
20
+ return () => listeners.delete(listener)
21
+ }
22
+
17
23
  export class CromboloApprovalsActiveCondition extends UmbConditionBase {
18
24
  #listener = () => this.#check()
19
25
 
@@ -0,0 +1,11 @@
1
+ /** What the Approvals section says (story 028). Pure. */
2
+
3
+ /**
4
+ * How many changes wait for approval: "You have 3 changes waiting for approval".
5
+ * @param {number} count
6
+ * @returns {string}
7
+ */
8
+ export function waitingLine(count) {
9
+ if (count === 0) return 'You have no changes waiting for approval.'
10
+ return `You have ${count} ${count === 1 ? 'change' : 'changes'} waiting for approval.`
11
+ }
@@ -31,13 +31,17 @@ const ITEMS = [
31
31
 
32
32
  /**
33
33
  * The items this user may open. One alone is no menu, so it offers none.
34
+ * Approvals is offered only while the site has a workflow or a request is open,
35
+ * as its section is (story 234).
34
36
  *
35
37
  * @param {{ allowedSections?: string[], fallbackPermissions?: string[], isAdmin?: boolean } | undefined} user
38
+ * @param {{ approvals?: boolean }} [site]
36
39
  */
37
- export function stripItems(user) {
40
+ export function stripItems(user, site = {}) {
38
41
  const allowed = user?.allowedSections ?? []
39
42
  const may = (verb) => user?.isAdmin === true || (user?.fallbackPermissions ?? []).includes(verb)
40
43
  const items = ITEMS.flatMap((item) => {
44
+ if (item.section === APPROVALS && site.approvals === false) return []
41
45
  if (allowed.includes(item.section)) return [item]
42
46
  const other = (item.or ?? []).find(
43
47
  (or) => allowed.includes(or.section) && (!or.verb || may(or.verb)),
@@ -5,7 +5,9 @@
5
5
  import { UMB_CURRENT_USER_CONTEXT } from '@umbraco-cms/backoffice/current-user'
6
6
  import { css, html, nothing } from '@umbraco-cms/backoffice/external/lit'
7
7
  import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'
8
+ import { watchApprovals } from './approvals-active.js'
8
9
  import { activeItem, stripItems } from './content-strip-items.js'
10
+ import { approvalsActive } from './workflow-client.js'
9
11
 
10
12
  const CONTENT = 'Umb.Section.Content'
11
13
  const ROW_HEIGHT = '--crombolo-content-strip-height'
@@ -24,6 +26,11 @@ export default class CromboloContentStripElement extends UmbLitElement {
24
26
  _active: { state: true },
25
27
  }
26
28
 
29
+ #user
30
+ /** Approvals waits for the site's answer, and stays offered if it can't be had. */
31
+ #approvals = false
32
+ #unwatch
33
+
27
34
  #follow = () => {
28
35
  this._active = activeItem(pathHere())
29
36
  this.#sync()
@@ -37,6 +44,17 @@ export default class CromboloContentStripElement extends UmbLitElement {
37
44
  else document.documentElement.style.removeProperty(ROW_HEIGHT)
38
45
  }
39
46
 
47
+ #offer() {
48
+ this._items = stripItems(this.#user, { approvals: this.#approvals })
49
+ this.#sync()
50
+ }
51
+
52
+ #checkApprovals = async () => {
53
+ const answer = await approvalsActive()
54
+ this.#approvals = answer.ok ? answer.active === true : true
55
+ this.#offer()
56
+ }
57
+
40
58
  #shown() {
41
59
  return this._items.length > 0 && this._active !== undefined
42
60
  }
@@ -46,8 +64,8 @@ export default class CromboloContentStripElement extends UmbLitElement {
46
64
  this._items = []
47
65
  this.consumeContext(UMB_CURRENT_USER_CONTEXT, (user) => {
48
66
  this.observe(user?.currentUser, (current) => {
49
- this._items = stripItems(current)
50
- this.#sync()
67
+ this.#user = current
68
+ this.#offer()
51
69
  })
52
70
  })
53
71
  }
@@ -55,6 +73,8 @@ export default class CromboloContentStripElement extends UmbLitElement {
55
73
  connectedCallback() {
56
74
  super.connectedCallback()
57
75
  this.#follow()
76
+ this.#checkApprovals()
77
+ this.#unwatch = watchApprovals(this.#checkApprovals)
58
78
  window.addEventListener('changestate', this.#follow)
59
79
  window.addEventListener('popstate', this.#follow)
60
80
  // A route the router settles on without a state change of its own, such as Home.
@@ -63,6 +83,7 @@ export default class CromboloContentStripElement extends UmbLitElement {
63
83
 
64
84
  disconnectedCallback() {
65
85
  super.disconnectedCallback()
86
+ this.#unwatch?.()
66
87
  window.removeEventListener('changestate', this.#follow)
67
88
  window.removeEventListener('popstate', this.#follow)
68
89
  window.removeEventListener('navigationend', this.#follow)
@@ -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.66.0",
5
+ "version": "0.67.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.66.0",
5
+ "version": "0.67.0",
6
6
  "allowPublicAccess": false,
7
7
  "extensions": [
8
8
  {
@@ -514,14 +514,7 @@ export class CromboloSettingsLandingElement extends UmbLitElement {
514
514
  }
515
515
 
516
516
  const TREE_HELP = {
517
- structure: html`<p>
518
- Choose a type, data type or language in the tree to edit it.
519
- </p>
520
- <p>
521
- Content types, data types and languages are <strong>files</strong>, in
522
- <code>schema/</code>, written as TOML. What you change here is written to the file, and the
523
- file is what a deploy and every other server reads, so a change can be reviewed like code.
524
- </p>`,
517
+ structure: html`<p>Choose a type, data type or language in the tree to edit it.</p>`,
525
518
  code: html`<p>Choose a component, stylesheet or script in the tree to edit it.</p>`,
526
519
  }
527
520
 
@@ -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.66.0",
5
+ "version": "0.67.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.66.0",
5
+ "version": "0.67.0",
6
6
  "allowPublicAccess": false,
7
7
  "extensions": [
8
8
  {
@@ -1,10 +1,12 @@
1
1
  /**
2
2
  * Approvals' list (story 028): the requests pending, and those decided when asked
3
3
  * for, a page at a time. Each row opens the page's Workflow tab, where a request
4
- * is acted on. With no workflow set up and no request open, it says so instead.
4
+ * is acted on. With no workflow set up and no request open, it says how many
5
+ * changes wait instead.
5
6
  */
6
7
  import { css, html, nothing } from '@umbraco-cms/backoffice/external/lit'
7
8
  import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'
9
+ import { waitingLine } from './approvals-words.js'
8
10
  import { approvalsActive, requestList } from './workflow-client.js'
9
11
  import { describeWhen } from './workflow-time.js'
10
12
 
@@ -53,6 +55,7 @@ class CromboloApprovalsListElement extends UmbLitElement {
53
55
  _pending: { state: true },
54
56
  _decided: { state: true },
55
57
  _inactive: { state: true },
58
+ _waiting: { state: true },
56
59
  }
57
60
 
58
61
  connectedCallback() {
@@ -70,6 +73,10 @@ class CromboloApprovalsListElement extends UmbLitElement {
70
73
  approvalsActive(),
71
74
  ])
72
75
  this._inactive = active.ok && active.active !== true
76
+ if (this._inactive) {
77
+ const waiting = await requestList({ pending: true, decided: false }, 0, 1)
78
+ this._waiting = waiting.ok ? waiting.total : 0
79
+ }
73
80
  if (!result.ok) {
74
81
  this._message = result.message
75
82
  return
@@ -153,7 +160,7 @@ class CromboloApprovalsListElement extends UmbLitElement {
153
160
  render() {
154
161
  if (this._inactive)
155
162
  return html`<uui-box headline="Approvals">
156
- <p>No approval workflows have been set up yet, so nothing waits for approval. Workflows are set up in Structure.</p>
163
+ <p>${waitingLine(this._waiting ?? 0)}</p>
157
164
  </uui-box>`
158
165
  const headline = listHeadline({ pending: this._pending, decided: this._decided })
159
166
  return html`<uui-box headline=${headline}>