@crombolo/backoffice-host 0.52.2 → 0.54.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.
@@ -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.52.2",
5
+ "version": "0.54.1",
6
6
  "allowPublicAccess": false,
7
7
  "extensions": [
8
8
  {
@@ -512,7 +512,7 @@
512
512
  "conditions": [
513
513
  {
514
514
  "alias": "Umb.Condition.SectionUserPermission",
515
- "match": "Umb.Section.Settings"
515
+ "match": "Crombolo.Section.AllSettings"
516
516
  }
517
517
  ]
518
518
  },
@@ -604,6 +604,50 @@
604
604
  "name": "Crombolo Menu Under Content",
605
605
  "js": "/crombolo-plugin/content-strip.js"
606
606
  },
607
+ {
608
+ "type": "entityCreateOptionAction",
609
+ "alias": "Crombolo.EntityCreateOptionAction.DocumentType.Form",
610
+ "name": "Crombolo Form Create Option",
611
+ "weight": 100,
612
+ "api": "/crombolo-plugin/form-create-option.js",
613
+ "forEntityTypes": ["document-type-root", "document-type-folder"],
614
+ "meta": { "icon": "icon-autofill", "label": "Form" }
615
+ },
616
+ {
617
+ "type": "menuItem",
618
+ "alias": "Crombolo.MenuItem.Forms",
619
+ "name": "Crombolo Forms In Structure",
620
+ "weight": 500,
621
+ "element": "/crombolo-plugin/definition-tree.js",
622
+ "meta": {
623
+ "menus": ["Umb.Menu.StructureSettings"],
624
+ "label": "Forms",
625
+ "icon": "icon-autofill",
626
+ "kind": "Forms"
627
+ },
628
+ "conditions": [
629
+ { "alias": "Umb.Condition.SectionUserPermission", "match": "Crombolo.Section.Forms" }
630
+ ]
631
+ },
632
+ {
633
+ "type": "menuItem",
634
+ "alias": "Crombolo.MenuItem.Workflows",
635
+ "name": "Crombolo Workflows In Structure",
636
+ "weight": 450,
637
+ "element": "/crombolo-plugin/definition-tree.js",
638
+ "meta": {
639
+ "menus": ["Umb.Menu.StructureSettings"],
640
+ "label": "Workflows",
641
+ "icon": "icon-mindmap",
642
+ "kind": "Workflows"
643
+ },
644
+ "conditions": [
645
+ {
646
+ "alias": "Umb.Condition.SectionUserPermission",
647
+ "match": "Crombolo.Section.WorkflowSetup"
648
+ }
649
+ ]
650
+ },
607
651
  {
608
652
  "type": "sectionSidebarApp",
609
653
  "alias": "Crombolo.SectionSidebarApp.DefinitionTree",
@@ -693,6 +737,18 @@
693
737
  "name": "Crombolo Sign-in Button",
694
738
  "js": "/crombolo-plugin/branding/sign-in.js"
695
739
  },
740
+ {
741
+ "type": "backofficeEntryPoint",
742
+ "alias": "Crombolo.EntryPoint.TemplatePicker",
743
+ "name": "Crombolo Template Picker In Folders",
744
+ "js": "/crombolo-plugin/template-picker.js"
745
+ },
746
+ {
747
+ "type": "backofficeEntryPoint",
748
+ "alias": "Crombolo.EntryPoint.DictionaryWords",
749
+ "name": "Crombolo Dictionary Words As Chips",
750
+ "js": "/crombolo-plugin/dictionary-words.js"
751
+ },
696
752
  {
697
753
  "type": "backofficeEntryPoint",
698
754
  "alias": "Crombolo.EntryPoint.NotificationsDialog",
@@ -712,6 +768,36 @@
712
768
  "name": "Crombolo Approvals Active Condition",
713
769
  "api": "/crombolo-plugin/approvals-active.js"
714
770
  },
771
+ {
772
+ "type": "section",
773
+ "alias": "Crombolo.Section.Structure",
774
+ "name": "Crombolo Structure Section",
775
+ "weight": 30,
776
+ "meta": {
777
+ "label": "Structure",
778
+ "pathname": "structure"
779
+ }
780
+ },
781
+ {
782
+ "type": "section",
783
+ "alias": "Crombolo.Section.Components",
784
+ "name": "Crombolo Code Section",
785
+ "weight": 29,
786
+ "meta": {
787
+ "label": "Code",
788
+ "pathname": "components"
789
+ }
790
+ },
791
+ {
792
+ "type": "section",
793
+ "alias": "Crombolo.Section.WorkflowSetup",
794
+ "name": "Crombolo Workflow setup Section",
795
+ "weight": 28,
796
+ "meta": {
797
+ "label": "Workflow setup",
798
+ "pathname": "workflow-setup"
799
+ }
800
+ },
715
801
  {
716
802
  "type": "section",
717
803
  "alias": "Crombolo.Section.Workflow",
@@ -720,40 +806,14 @@
720
806
  "meta": {
721
807
  "label": "Approvals",
722
808
  "pathname": "workflow"
723
- },
724
- "conditions": [{ "alias": "Crombolo.Condition.ApprovalsActive" }]
725
- },
726
- {
727
- "type": "sectionView",
728
- "alias": "Crombolo.SectionView.Workflow.Waiting",
729
- "name": "Crombolo Workflow Waiting",
730
- "element": "/crombolo-plugin/workflow-requests.js",
731
- "elementName": "crombolo-workflow-waiting",
732
- "weight": 400,
733
- "meta": {
734
- "label": "Waiting for me",
735
- "pathname": "waiting",
736
- "icon": "icon-inbox"
737
- },
738
- "conditions": [
739
- {
740
- "alias": "Umb.Condition.SectionAlias",
741
- "match": "Crombolo.Section.Workflow"
742
- }
743
- ]
809
+ }
744
810
  },
745
811
  {
746
- "type": "sectionView",
747
- "alias": "Crombolo.SectionView.Workflow.InFlight",
748
- "name": "Crombolo Workflow In Flight",
749
- "element": "/crombolo-plugin/workflow-requests.js",
750
- "elementName": "crombolo-workflow-in-flight",
751
- "weight": 300,
752
- "meta": {
753
- "label": "In flight",
754
- "pathname": "in-flight",
755
- "icon": "icon-time"
756
- },
812
+ "type": "sectionSidebarApp",
813
+ "alias": "Crombolo.SectionSidebarApp.ApprovalsTree",
814
+ "name": "Crombolo Approvals Tree",
815
+ "element": "/crombolo-plugin/approvals-tree.js",
816
+ "weight": 100,
757
817
  "conditions": [
758
818
  {
759
819
  "alias": "Umb.Condition.SectionAlias",
@@ -763,15 +823,16 @@
763
823
  },
764
824
  {
765
825
  "type": "sectionView",
766
- "alias": "Crombolo.SectionView.Workflow.History",
767
- "name": "Crombolo Workflow History",
826
+ "alias": "Crombolo.SectionView.Workflow.Requests",
827
+ "name": "Crombolo Approvals List",
768
828
  "element": "/crombolo-plugin/workflow-requests.js",
769
- "elementName": "crombolo-workflow-history",
770
- "weight": 200,
829
+ "elementName": "crombolo-approvals-list",
830
+ "weight": 400,
771
831
  "meta": {
772
- "label": "Decided",
773
- "pathname": "history",
774
- "icon": "icon-check"
832
+ "label": "Approvals",
833
+ "pathname": "approvals",
834
+ "noTab": true,
835
+ "icon": "icon-inbox"
775
836
  },
776
837
  "conditions": [
777
838
  {
@@ -798,10 +859,43 @@
798
859
  "match": "Crombolo.Section.Forms"
799
860
  },
800
861
  {
801
- "alias": "Umb.Condition.CurrentUser.IsAdmin"
862
+ "alias": "Umb.Condition.SectionUserPermission",
863
+ "match": "Crombolo.Section.WorkflowSetup"
802
864
  }
803
865
  ]
804
866
  },
867
+ {
868
+ "type": "condition",
869
+ "alias": "Crombolo.Condition.Document.MaySendForApproval",
870
+ "name": "Crombolo May Send For Approval Condition",
871
+ "api": "/crombolo-plugin/workflow-send-condition.js"
872
+ },
873
+ {
874
+ "type": "workspaceAction",
875
+ "kind": "default",
876
+ "alias": "Crombolo.WorkspaceAction.Document.SendForApproval",
877
+ "name": "Crombolo Send For Approval",
878
+ "weight": 75,
879
+ "api": "/crombolo-plugin/workflow-send.js",
880
+ "meta": { "label": "Send for approval", "look": "secondary" },
881
+ "conditions": [
882
+ { "alias": "Umb.Condition.WorkspaceAlias", "match": "Umb.Workspace.Document" },
883
+ { "alias": "Crombolo.Condition.Document.MaySendForApproval", "action": "publish" }
884
+ ]
885
+ },
886
+ {
887
+ "type": "workspaceActionMenuItem",
888
+ "kind": "default",
889
+ "alias": "Crombolo.WorkspaceActionMenuItem.Document.RequestUnpublish",
890
+ "name": "Crombolo Request Unpublish",
891
+ "weight": 5,
892
+ "api": "/crombolo-plugin/workflow-send-unpublish.js",
893
+ "forWorkspaceActions": "Umb.WorkspaceAction.Document.SaveAndPublish",
894
+ "meta": { "label": "Request unpublish", "icon": "icon-globe" },
895
+ "conditions": [
896
+ { "alias": "Crombolo.Condition.Document.MaySendForApproval", "action": "unpublish" }
897
+ ]
898
+ },
805
899
  {
806
900
  "type": "workspaceView",
807
901
  "alias": "Crombolo.WorkspaceView.Document.Workflow",
@@ -28,6 +28,9 @@ export const decide = (requestKey, verb, body) =>
28
28
  export const waitingForMe = () => call('waiting')
29
29
  export const inFlight = () => call('in-flight')
30
30
  export const finished = (skip = 0, take = 25) => call(`history?skip=${skip}&take=${take}`)
31
+ /** A page of requests: the pending, the decided, or both. */
32
+ export const requestList = ({ pending, decided }, skip = 0, take = 25) =>
33
+ call(`requests?pending=${pending}&decided=${decided}&skip=${skip}&take=${take}`)
31
34
  export const listWorkflows = () => call('workflows')
32
35
  export const previewWorkflow = (alias, workflow) =>
33
36
  post(`workflows/${encodeURIComponent(alias)}/preview`, { workflow })
@@ -358,13 +358,7 @@ export default class CromboloWorkflowDesignerElement extends UmbLitElement {
358
358
 
359
359
  #renderList() {
360
360
  const { items, editable } = this._list
361
- // The create button above the list, as the Created bundles view has it.
362
361
  return html`<div class="list">
363
- ${
364
- editable
365
- ? html`<uui-button class="create" color="default" look="outline" label="Create" @click=${() => this.#edit(blank())}>Create</uui-button>`
366
- : nothing
367
- }
368
362
  ${this._message ? html`<uui-box><p class="message">${this._message}</p></uui-box>` : nothing}
369
363
  <uui-box headline="Workflows">
370
364
  ${this.#readOnly()}
@@ -669,7 +663,6 @@ export default class CromboloWorkflowDesignerElement extends UmbLitElement {
669
663
  static styles = css`
670
664
  :host { display: block; height: 100%; container-type: inline-size; }
671
665
  .list { padding: var(--uui-size-layout-1); }
672
- .create { margin-bottom: var(--uui-size-space-5); }
673
666
  .actions { text-align: right; white-space: nowrap; }
674
667
  uui-tab-group { --uui-tab-divider: var(--uui-color-border); border-left: 1px solid var(--uui-color-border); border-right: 1px solid var(--uui-color-border); }
675
668
  .notice { margin-bottom: var(--uui-size-layout-1); }
@@ -1,11 +1,11 @@
1
1
  /**
2
- * The Workflows section's lists (story 028): what waits for the reader's
3
- * approval, every request in flight, and those decided. Each row links to the
4
- * page, whose Workflow tab is where a request is acted on.
2
+ * Approvals' list (story 028): the requests pending, and those decided when asked
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.
5
5
  */
6
6
  import { css, html, nothing } from '@umbraco-cms/backoffice/external/lit'
7
7
  import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'
8
- import { finished, inFlight, waitingForMe } from './workflow-client.js'
8
+ import { approvalsActive, requestList } from './workflow-client.js'
9
9
  import { describeWhen } from './workflow-time.js'
10
10
 
11
11
  const STATE = {
@@ -18,7 +18,7 @@ const STATE = {
18
18
  }
19
19
 
20
20
  /** The page's Workflow tab: the editor's route is `edit/<key>/<variant>/view/<tab>`. */
21
- const pageLink = (item) => {
21
+ export const pageLink = (item) => {
22
22
  const base = (document.querySelector('base')?.getAttribute('href') ?? '/umbraco/').replace(
23
23
  /\/$/,
24
24
  '',
@@ -37,133 +37,139 @@ function openInBackoffice(event, href) {
37
37
  history.pushState(null, '', href)
38
38
  }
39
39
 
40
- class CromboloWorkflowListElement extends UmbLitElement {
40
+ /** Rows a page of the list holds. */
41
+ export const PAGE_SIZE = 25
42
+
43
+ /** What a list of requests is called, by what it includes. Pure. */
44
+ export const listHeadline = ({ pending, decided }) =>
45
+ pending && decided ? 'Pending and decided' : decided ? 'Decided' : 'Pending'
46
+
47
+ class CromboloApprovalsListElement extends UmbLitElement {
41
48
  static properties = {
42
49
  _items: { state: true },
43
50
  _message: { state: true },
44
51
  _total: { state: true },
45
- _skip: { state: true },
46
- }
47
-
48
- /** Overridden: what this list is, and how it loads. */
49
- get headline() {
50
- return ''
51
- }
52
- get empty() {
53
- return ''
54
- }
55
- async fetch(_skip) {
56
- return { ok: true, items: [] }
52
+ _page: { state: true },
53
+ _pending: { state: true },
54
+ _decided: { state: true },
55
+ _inactive: { state: true },
57
56
  }
58
57
 
59
58
  connectedCallback() {
60
59
  super.connectedCallback()
61
- this._skip = 0
60
+ this._page = 1
61
+ this._pending = true
62
+ this._decided = false
62
63
  this.#load()
63
64
  }
64
65
 
65
66
  async #load() {
66
- const result = await this.fetch(this._skip)
67
+ const include = { pending: this._pending, decided: this._decided }
68
+ const [result, active] = await Promise.all([
69
+ requestList(include, (this._page - 1) * PAGE_SIZE, PAGE_SIZE),
70
+ approvalsActive(),
71
+ ])
72
+ this._inactive = active.ok && active.active !== true
67
73
  if (!result.ok) {
68
74
  this._message = result.message
69
75
  return
70
76
  }
77
+ this._message = undefined
71
78
  this._items = result.items
72
79
  this._total = result.total
73
80
  }
74
81
 
82
+ #include(name, checked) {
83
+ this[name] = checked
84
+ this._page = 1
85
+ this._items = undefined
86
+ this.#load()
87
+ }
88
+
89
+ #filters() {
90
+ return html`<div class="filters" role="group" aria-label="Show">
91
+ <uui-checkbox
92
+ label="Pending"
93
+ ?checked=${this._pending}
94
+ @change=${(e) => this.#include('_pending', e.target.checked)}
95
+ ></uui-checkbox>
96
+ <uui-checkbox
97
+ label="Decided"
98
+ ?checked=${this._decided}
99
+ @change=${(e) => this.#include('_decided', e.target.checked)}
100
+ ></uui-checkbox>
101
+ </div>`
102
+ }
103
+
104
+ #pages() {
105
+ const total = Math.ceil((this._total ?? 0) / PAGE_SIZE)
106
+ if (total <= 1) return nothing
107
+ return html`<uui-pagination
108
+ .current=${this._page}
109
+ .total=${total}
110
+ @change=${(e) => {
111
+ this._page = e.target.current
112
+ this.#load()
113
+ }}
114
+ ></uui-pagination>`
115
+ }
116
+
117
+ #table() {
118
+ if (!this._items) return html`<uui-loader></uui-loader>`
119
+ if (this._items.length === 0)
120
+ return html`<p>${
121
+ this._pending || this._decided
122
+ ? `No request is ${listHeadline({ pending: this._pending, decided: this._decided }).toLowerCase()}.`
123
+ : 'Choose pending or decided requests to see them.'
124
+ }</p>`
125
+ return html`<uui-table>
126
+ <uui-table-head>
127
+ <uui-table-head-cell>Page</uui-table-head-cell>
128
+ <uui-table-head-cell>Workflow</uui-table-head-cell>
129
+ <uui-table-head-cell>Asked for</uui-table-head-cell>
130
+ <uui-table-head-cell>When</uui-table-head-cell>
131
+ <uui-table-head-cell>Where it stands</uui-table-head-cell>
132
+ <uui-table-head-cell>Sent</uui-table-head-cell>
133
+ </uui-table-head>
134
+ ${this._items.map((item) => {
135
+ const [color, label] = STATE[item.state] ?? ['default', item.state]
136
+ const waiting = item.stages.filter((s) => s.state === 'waiting').map((s) => s.alias)
137
+ const href = pageLink(item)
138
+ return html`<uui-table-row class="row" @click=${(e) => openInBackoffice(e, href)}>
139
+ <uui-table-cell><a href=${href} @click=${(e) => openInBackoffice(e, href)}>${item.nodeName}</a></uui-table-cell>
140
+ <uui-table-cell>${item.workflow.name}</uui-table-cell>
141
+ <uui-table-cell>${item.action === 'unpublish' ? 'Taking it down' : 'Publishing'}</uui-table-cell>
142
+ <uui-table-cell>${describeWhen(item.action, item.schedule) || 'On approval'}</uui-table-cell>
143
+ <uui-table-cell>
144
+ <uui-tag color=${color}>${label}</uui-tag>
145
+ ${waiting.length > 0 ? html`<small>at ${waiting.join(', ')}</small>` : nothing}
146
+ </uui-table-cell>
147
+ <uui-table-cell>${new Date(item.requestedAt).toLocaleString()}</uui-table-cell>
148
+ </uui-table-row>`
149
+ })}
150
+ </uui-table>`
151
+ }
152
+
75
153
  render() {
76
- if (this._message) return html`<uui-box headline=${this.headline}>${this._message}</uui-box>`
77
- if (!this._items)
78
- return html`<uui-box headline=${this.headline}><uui-loader></uui-loader></uui-box>`
79
- return html`<uui-box headline=${this.headline}>
80
- ${
81
- this._items.length === 0
82
- ? html`<p>${this.empty}</p>`
83
- : html`<uui-table>
84
- <uui-table-head>
85
- <uui-table-head-cell>Page</uui-table-head-cell>
86
- <uui-table-head-cell>Workflow</uui-table-head-cell>
87
- <uui-table-head-cell>Asked for</uui-table-head-cell>
88
- <uui-table-head-cell>When</uui-table-head-cell>
89
- <uui-table-head-cell>Where it stands</uui-table-head-cell>
90
- <uui-table-head-cell>Sent</uui-table-head-cell>
91
- </uui-table-head>
92
- ${this._items.map((item) => {
93
- const [color, label] = STATE[item.state] ?? ['default', item.state]
94
- const waiting = item.stages.filter((s) => s.state === 'waiting').map((s) => s.alias)
95
- return html`<uui-table-row>
96
- <uui-table-cell><a href=${pageLink(item)} @click=${(e) => openInBackoffice(e, pageLink(item))}>${item.nodeName}</a></uui-table-cell>
97
- <uui-table-cell>${item.workflow.name}</uui-table-cell>
98
- <uui-table-cell>${item.action === 'unpublish' ? 'Taking it down' : 'Publishing'}</uui-table-cell>
99
- <uui-table-cell>${describeWhen(item.action, item.schedule) || 'On approval'}</uui-table-cell>
100
- <uui-table-cell>
101
- <uui-tag color=${color}>${label}</uui-tag>
102
- ${waiting.length > 0 ? html`<small>at ${waiting.join(', ')}</small>` : nothing}
103
- </uui-table-cell>
104
- <uui-table-cell>${new Date(item.requestedAt).toLocaleString()}</uui-table-cell>
105
- </uui-table-row>`
106
- })}
107
- </uui-table>`
108
- }
109
- ${
110
- this._total !== undefined && this._total > this._items.length + this._skip
111
- ? html`<uui-button look="secondary" label="Older" @click=${() => {
112
- this._skip += this._items.length
113
- this.#load()
114
- }}>Older</uui-button>`
115
- : nothing
116
- }
154
+ if (this._inactive)
155
+ 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>
157
+ </uui-box>`
158
+ const headline = listHeadline({ pending: this._pending, decided: this._decided })
159
+ return html`<uui-box headline=${headline}>
160
+ ${this.#filters()}
161
+ ${this._message ? html`<p role="alert">${this._message}</p>` : this.#table()}
162
+ ${this.#pages()}
117
163
  </uui-box>`
118
164
  }
119
165
 
120
166
  static styles = css`
121
167
  :host { display: block; padding: var(--uui-size-layout-1); }
122
168
  small { margin-left: var(--uui-size-space-2); opacity: 0.8; }
169
+ .filters { display: flex; gap: var(--uui-size-space-5); margin-bottom: var(--uui-size-space-4); }
170
+ .row { cursor: pointer; }
171
+ uui-pagination { display: block; margin-top: var(--uui-size-space-4); }
123
172
  `
124
173
  }
125
174
 
126
- customElements.define(
127
- 'crombolo-workflow-waiting',
128
- class extends CromboloWorkflowListElement {
129
- get headline() {
130
- return 'Waiting for my approval'
131
- }
132
- get empty() {
133
- return 'Nothing is waiting for your approval.'
134
- }
135
- fetch() {
136
- return waitingForMe()
137
- }
138
- },
139
- )
140
-
141
- customElements.define(
142
- 'crombolo-workflow-in-flight',
143
- class extends CromboloWorkflowListElement {
144
- get headline() {
145
- return 'In flight'
146
- }
147
- get empty() {
148
- return 'No page is waiting for approval or for its time.'
149
- }
150
- fetch() {
151
- return inFlight()
152
- }
153
- },
154
- )
155
-
156
- customElements.define(
157
- 'crombolo-workflow-history',
158
- class extends CromboloWorkflowListElement {
159
- get headline() {
160
- return 'Decided'
161
- }
162
- get empty() {
163
- return 'No request has been decided yet.'
164
- }
165
- fetch(skip) {
166
- return finished(skip, 25)
167
- }
168
- },
169
- )
175
+ customElements.define('crombolo-approvals-list', CromboloApprovalsListElement)
@@ -0,0 +1,2 @@
1
+ /** `Crombolo.Condition.Document.MaySendForApproval`: `workflow-send.js`. */
2
+ export { CromboloMaySendCondition as api } from './workflow-send.js'
@@ -0,0 +1,20 @@
1
+ /**
2
+ * What the bottom bar's "Send for approval" and "Request unpublish" decide
3
+ * (`workflow-send.js`). Pure, so each is tested on its own.
4
+ */
5
+ import { fromLocalInput } from './workflow-time.js'
6
+
7
+ /** What the reader may send now: `publish`, `unpublish`, both or neither. Pure. */
8
+ export function maySend(approval, action) {
9
+ if (!approval?.ok || !approval.workflow || approval.request) return false
10
+ return action === 'unpublish'
11
+ ? approval.can?.requestUnpublish === true
12
+ : approval.can?.send === true
13
+ }
14
+
15
+ /** The schedule a request carries for the times given, or undefined for none. Pure. */
16
+ export function scheduleFor(action, publishAt, unpublishAt) {
17
+ const publishTime = action === 'publish' ? fromLocalInput(publishAt) : null
18
+ const unpublishTime = fromLocalInput(unpublishAt)
19
+ return publishTime || unpublishTime ? [{ culture: null, publishTime, unpublishTime }] : undefined
20
+ }
@@ -0,0 +1,2 @@
1
+ /** "Request unpublish" in the "Save and publish" menu: `workflow-send.js`. */
2
+ export { CromboloRequestUnpublishAction as api } from './workflow-send.js'