@crombolo/backoffice-host 0.40.0 → 0.42.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/package.json +3 -3
  2. package/plugin/addresses-dashboard.js +3 -2
  3. package/plugin/app-preview/umbraco-package.json +1 -1
  4. package/plugin/audit-dashboard.js +3 -2
  5. package/plugin/branding/localization-en.js +9 -3
  6. package/plugin/branding/sign-in.js +0 -31
  7. package/plugin/bundle-editor-code.js +2 -0
  8. package/plugin/bundle-editor-content.js +2 -0
  9. package/plugin/bundle-editor-context.js +95 -0
  10. package/plugin/bundle-editor-forms.js +2 -0
  11. package/plugin/bundle-editor-language.js +2 -0
  12. package/plugin/bundle-editor-routing.js +13 -0
  13. package/plugin/bundle-editor-sections.js +389 -0
  14. package/plugin/bundle-editor-types.js +2 -0
  15. package/plugin/bundle-editor-user-groups.js +2 -0
  16. package/plugin/bundle-editor-workflows.js +2 -0
  17. package/plugin/bundle-editor.js +140 -0
  18. package/plugin/bundles-client.js +12 -0
  19. package/plugin/bundles-created.js +2 -1
  20. package/plugin/changes-dashboard.js +3 -2
  21. package/plugin/edit-conflicts.js +11 -21
  22. package/plugin/jobs-dashboard.js +3 -2
  23. package/plugin/localizations/umbraco-package.json +1 -1
  24. package/plugin/notifications-dialog.js +8 -35
  25. package/plugin/seo/umbraco-package.json +1 -1
  26. package/plugin/side-panel/host.js +7 -63
  27. package/plugin/side-panel/layout.js +0 -15
  28. package/plugin/sign-in/umbraco-package.json +1 -1
  29. package/plugin/tsx-editors.js +56 -164
  30. package/plugin/umbraco-package.json +138 -32
  31. package/plugin/branding/branding.js +0 -188
  32. package/plugin/branding/bundle-builder-labels.js +0 -92
  33. package/plugin/branding/client-credentials.js +0 -49
  34. package/plugin/branding/log-viewer-menu.js +0 -70
  35. package/plugin/branding/query-builder.js +0 -28
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crombolo/backoffice-host",
3
- "version": "0.40.0",
3
+ "version": "0.42.1",
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",
@@ -32,7 +32,7 @@
32
32
  "access": "public"
33
33
  },
34
34
  "dependencies": {
35
- "@crombolo/core": "0.40.0",
36
- "@crombolo/backoffice-dist": "18.2.0"
35
+ "@crombolo/core": "0.42.1",
36
+ "@crombolo/backoffice-dist": "0.42.1"
37
37
  }
38
38
  }
@@ -3,12 +3,13 @@
3
3
  * below it, as Umbraco's `HideTopLevelNodeFromPath` sets it. Saving moves the
4
4
  * addresses, and the old ones redirect to the new. docs/rendering.md, "URLs".
5
5
  */
6
- import { css, html, LitElement, nothing } from '@umbraco-cms/backoffice/external/lit'
6
+ import { css, html, nothing } from '@umbraco-cms/backoffice/external/lit'
7
+ import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'
7
8
 
8
9
  const endpoint = () =>
9
10
  `${(document.querySelector('base')?.getAttribute('href') ?? '/umbraco/').replace(/\/$/, '')}/crombolo/api/url-options`
10
11
 
11
- export default class CromboloAddressesDashboardElement extends LitElement {
12
+ export default class CromboloAddressesDashboardElement extends UmbLitElement {
12
13
  static properties = {
13
14
  _settings: { state: true },
14
15
  _showTopLevel: { state: true },
@@ -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.40.0",
5
+ "version": "0.42.1",
6
6
  "allowPublicAccess": false,
7
7
  "extensions": [
8
8
  {
@@ -3,7 +3,8 @@
3
3
  * newest first, filtered by person, kind of change, words and dates.
4
4
  * docs/audit-log.md.
5
5
  */
6
- import { css, html, LitElement, nothing } from '@umbraco-cms/backoffice/external/lit'
6
+ import { css, html, nothing } from '@umbraco-cms/backoffice/external/lit'
7
+ import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'
7
8
 
8
9
  const PAGE_SIZE = 50
9
10
 
@@ -133,7 +134,7 @@ function fromWhere(entry) {
133
134
  return forwarded || entry.ipAddress || '—'
134
135
  }
135
136
 
136
- export default class CromboloAuditDashboardElement extends LitElement {
137
+ export default class CromboloAuditDashboardElement extends UmbLitElement {
137
138
  static properties = {
138
139
  _page: { state: true },
139
140
  _users: { state: true },
@@ -11,9 +11,10 @@
11
11
  * one that wins. See `localization.registry.js`: `$weight: extension.weight ?? 100`.
12
12
  *
13
13
  * Only what a person reads in a flow this CMS implements. Strings about
14
- * `appsettings.json`, IIS permissions, Examine or the .NET installer are left
15
- * alone: they name real things that are not ours to rename, and the features they
16
- * belong to are not built.
14
+ * `appsettings.json`, IIS permissions or the .NET installer are left alone: they
15
+ * name real things that are not ours to rename, and the features they belong to
16
+ * are not built. Examine is the exception: the search dashboard is built, over
17
+ * the database's own indexes, so its tab and heading say what it is.
17
18
  *
18
19
  * `sections` and `packager` are the other kind of rename: not the product's name
19
20
  * but a feature's. Umbraco's Packages section builds a `.umb` file; the artifact
@@ -65,6 +66,11 @@ export default {
65
66
  },
66
67
  dashboardTabs: {
67
68
  contentIntro: 'Welcome to Crombolo',
69
+ // Search here is the database's own (docs/search.md), not Examine.
70
+ settingsExamine: 'Search indexes',
71
+ },
72
+ examineManagement: {
73
+ manageIndexes: 'Manage search indexes',
68
74
  },
69
75
  languages: {
70
76
  defaultLanguageHelp: 'A Crombolo site can only have one default language set.',
@@ -66,38 +66,7 @@ class CromboloAuthProviderElement extends LitElement {
66
66
 
67
67
  if (!customElements.get(TAG)) customElements.define(TAG, CromboloAuthProviderElement)
68
68
 
69
- /**
70
- * Signing in again after a timeout closes its modal twice.
71
- *
72
- * `umb-app-auth-modal` submits when the session reports itself authorised, and
73
- * `umb-auth-view` calls the same submit as its `onSuccess` once
74
- * `makeAuthorizationRequest` returns. Whichever runs first closes the modal and
75
- * destroys its value state, so the second's `value = { success: true }` throws
76
- * `_subject is undefined` — and the view shows that as a sign-in error, though
77
- * the editor is signed in. The second assignment has nothing left to say, so it
78
- * is dropped. Patched on the element's prototype, as `tsx-editors.js` patches
79
- * upstream, rather than in the vendored bundle.
80
- */
81
- async function guardTimedOutSignIn() {
82
- const Modal = await customElements.whenDefined('umb-app-auth-modal')
83
- let descriptor
84
- for (let proto = Modal.prototype; proto && !descriptor; proto = Object.getPrototypeOf(proto))
85
- descriptor = Object.getOwnPropertyDescriptor(proto, 'value')
86
- if (!descriptor?.set) return
87
- const { get, set } = descriptor
88
- Object.defineProperty(Modal.prototype, 'value', {
89
- configurable: true,
90
- get,
91
- set(value) {
92
- if (this.__cromboloSubmitted) return
93
- set.call(this, value)
94
- this.__cromboloSubmitted = true
95
- },
96
- })
97
- }
98
-
99
69
  export const onInit = (_host, extensionRegistry) => {
100
- void guardTimedOutSignIn()
101
70
  extensionRegistry.unregister(VENDORED)
102
71
  extensionRegistry.register({
103
72
  type: 'authProvider',
@@ -0,0 +1,2 @@
1
+ /** The Bundle Editor's code tab (story 233). */
2
+ export { CromboloBundleCodeView as default } from './bundle-editor-sections.js'
@@ -0,0 +1,2 @@
1
+ /** The Bundle Editor's content tab (story 233). */
2
+ export { CromboloBundleContentView as default } from './bundle-editor-sections.js'
@@ -0,0 +1,95 @@
1
+ /**
2
+ * What the Bundle Editor's tabs share (story 233): the bundle's definition as
3
+ * Umbraco's package repository reads and saves it, so a definition made in
4
+ * Umbraco's builder opens here unchanged; and its forms, workflows and user
5
+ * groups (story 226), which Umbraco's definition has no fields for.
6
+ */
7
+ import { UmbContextBase } from '@umbraco-cms/backoffice/class-api'
8
+ import { UmbContextToken } from '@umbraco-cms/backoffice/context-api'
9
+ import { UmbObjectState } from '@umbraco-cms/backoffice/observable-api'
10
+ import { UmbPackageRepository } from '@umbraco-cms/backoffice/package'
11
+ import { blobDownload } from '@umbraco-cms/backoffice/utils'
12
+ import { carriedSchema, readSchemaPicks, saveSchemaPicks, schemaChoices } from './bundles-client.js'
13
+
14
+ const NO_PICKS = { forms: [], workflows: [], userGroups: [], excluded: [] }
15
+
16
+ export const CROMBOLO_BUNDLE_EDITOR_CONTEXT = new UmbContextToken('CromboloBundleEditorContext')
17
+
18
+ /** Provides itself to the editor's tabs, as Umbraco's contexts do. */
19
+ export class CromboloBundleEditorContext extends UmbContextBase {
20
+ #repository
21
+ #state = new UmbObjectState(undefined)
22
+ /** The definition, as it stands in the editor. */
23
+ definition = this.#state.asObservable()
24
+ #picks = new UmbObjectState(NO_PICKS)
25
+ /** The forms, workflows and user groups picked, and the dependencies unticked. */
26
+ picks = this.#picks.asObservable()
27
+ #carried = new UmbObjectState([])
28
+ #asked = 0
29
+ /** What the picks carry: each pick, and what it brings and why. */
30
+ carried = this.#carried.asObservable()
31
+ #choices = new UmbObjectState({ forms: [], workflows: [], userGroups: [] })
32
+ /** The site's forms, workflows and user groups. */
33
+ choices = this.#choices.asObservable()
34
+
35
+ constructor(host) {
36
+ super(host, CROMBOLO_BUNDLE_EDITOR_CONTEXT)
37
+ this.#repository = new UmbPackageRepository(host)
38
+ }
39
+
40
+ /** Reads a saved definition, or a new one when `unique` is undefined. */
41
+ async load(unique) {
42
+ this.#state.setValue(await this.#repository.getCreatedPackage(unique))
43
+ const [choices, picks] = await Promise.all([
44
+ schemaChoices().catch(() => undefined),
45
+ unique ? readSchemaPicks(unique).catch(() => undefined) : undefined,
46
+ ])
47
+ if (choices) this.#choices.setValue(choices)
48
+ await this.updatePicks(picks ?? NO_PICKS)
49
+ }
50
+
51
+ /** Changes some of the picks, and works out again what they carry. */
52
+ async updatePicks(patch) {
53
+ const picks = { ...this.#picks.getValue(), ...patch }
54
+ this.#picks.setValue(picks)
55
+ const asked = ++this.#asked
56
+ const { carried } = await carriedSchema(picks).catch(() => ({ carried: [] }))
57
+ if (asked === this.#asked) this.#carried.setValue(carried ?? [])
58
+ }
59
+
60
+ get value() {
61
+ return this.#state.getValue()
62
+ }
63
+
64
+ /** Changes some of the definition's fields. */
65
+ update(patch) {
66
+ const current = this.#state.getValue()
67
+ if (current) this.#state.setValue({ ...current, ...patch })
68
+ }
69
+
70
+ /** Saves it, creating it the first time; resolves to its unique, or undefined. */
71
+ async save() {
72
+ const current = this.#state.getValue()
73
+ if (!current) return undefined
74
+ let unique = current.unique
75
+ if (unique) {
76
+ if (!(await this.#repository.updateCreatedPackage(current))) return undefined
77
+ } else {
78
+ unique = await this.#repository.saveCreatedPackage(current)
79
+ if (!unique || typeof unique !== 'string') return undefined
80
+ this.update({ unique })
81
+ }
82
+ await saveSchemaPicks(unique, this.#picks.getValue())
83
+ return unique
84
+ }
85
+
86
+ /** Downloads the built bundle. */
87
+ async download() {
88
+ const unique = this.#state.getValue()?.unique
89
+ if (!unique) return
90
+ const data = await this.#repository.getCreatePackageDownload(unique)
91
+ if (!data) return
92
+ const zip = typeof data === 'object'
93
+ blobDownload(data, zip ? 'bundle.zip' : 'bundle.xml', zip ? 'application/zip' : 'text/xml')
94
+ }
95
+ }
@@ -0,0 +1,2 @@
1
+ /** The Bundle Editor's forms tab (story 226). */
2
+ export { CromboloBundleFormsView as default } from './bundle-editor-sections.js'
@@ -0,0 +1,2 @@
1
+ /** The Bundle Editor's language tab (story 233). */
2
+ export { CromboloBundleLanguageView as default } from './bundle-editor-sections.js'
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Which workspace the Created view opens (story 233): Crombolo's Bundle Editor
3
+ * alone when it is registered. Its manifest overwrites Umbraco's builder, but
4
+ * the routes are ours, so they do not rely on that alone. Pure, for a test.
5
+ */
6
+ export const BUNDLE_EDITOR_ALIAS = 'Crombolo.Workspace.BundleEditor'
7
+ export const UMBRACO_BUILDER_ALIAS = 'Umb.Workspace.PackageBuilder'
8
+
9
+ export function editorsOf(workspaces) {
10
+ return workspaces.some((workspace) => workspace.alias === BUNDLE_EDITOR_ALIAS)
11
+ ? workspaces.filter((workspace) => workspace.alias !== UMBRACO_BUILDER_ALIAS)
12
+ : workspaces
13
+ }
@@ -0,0 +1,389 @@
1
+ /**
2
+ * The Bundle Editor's tabs (story 233): each a workspace view drawing part of
3
+ * the definition with the inputs Umbraco's own package builder is made of, and
4
+ * writing back through the editor's context.
5
+ */
6
+ import { UmbDictionaryPickerInputContext } from '@umbraco-cms/backoffice/dictionary'
7
+ import { css, html, nothing } from '@umbraco-cms/backoffice/external/lit'
8
+ import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'
9
+ import { UmbPartialViewPickerInputContext } from '@umbraco-cms/backoffice/partial-view'
10
+ import { UmbScriptPickerInputContext } from '@umbraco-cms/backoffice/script'
11
+ import { UmbServerFilePathUniqueSerializer } from '@umbraco-cms/backoffice/server-file-system'
12
+ import { UmbTextStyles } from '@umbraco-cms/backoffice/style'
13
+ import { UmbStylesheetPickerInputContext } from '@umbraco-cms/backoffice/stylesheet'
14
+ import { UmbTemplatePickerInputContext } from '@umbraco-cms/backoffice/template'
15
+ import { CROMBOLO_BUNDLE_EDITOR_CONTEXT } from './bundle-editor-context.js'
16
+
17
+ const paths = new UmbServerFilePathUniqueSerializer()
18
+
19
+ /** One tab: the definition from the editor's context, and a box of fields. */
20
+ export class CromboloBundleEditorView extends UmbLitElement {
21
+ static properties = { _definition: { state: true } }
22
+
23
+ /** The tab's headline. */
24
+ headline = ''
25
+
26
+ constructor() {
27
+ super()
28
+ this.consumeContext(CROMBOLO_BUNDLE_EDITOR_CONTEXT, (context) => {
29
+ this.context = context
30
+ // Called again with nothing as the tab is taken down.
31
+ if (!context) return
32
+ this.observe(context.definition, (definition) => {
33
+ this._definition = definition
34
+ })
35
+ })
36
+ }
37
+
38
+ /** Writes part of the definition back. */
39
+ set(patch) {
40
+ this.context?.update(patch)
41
+ }
42
+
43
+ /** The tab's fields, given the definition. */
44
+ fields() {
45
+ return nothing
46
+ }
47
+
48
+ render() {
49
+ if (!this._definition) return nothing
50
+ return html`<uui-box headline=${this.headline}>${this.fields(this._definition)}</uui-box>`
51
+ }
52
+
53
+ static styles = [
54
+ UmbTextStyles,
55
+ css`
56
+ :host {
57
+ display: block;
58
+ padding: var(--uui-size-layout-1);
59
+ }
60
+ uui-checkbox {
61
+ margin-top: var(--uui-size-space-4);
62
+ }
63
+ `,
64
+ ]
65
+ }
66
+
67
+ const field = (label, editor, description) =>
68
+ html`<umb-property-layout label=${label} description=${description ?? ''}>
69
+ <div slot="editor">${editor}</div>
70
+ </umb-property-layout>`
71
+
72
+ /** Content: a page and optionally its children, media, and Library elements. */
73
+ export class CromboloBundleContentView extends CromboloBundleEditorView {
74
+ headline = 'Content'
75
+
76
+ fields(d) {
77
+ return html`
78
+ ${field(
79
+ 'Content',
80
+ html`<umb-input-document
81
+ max="1"
82
+ .value=${d.contentNodeId ?? undefined}
83
+ @change=${(event) => {
84
+ const contentNodeId = event.target.selection[0]
85
+ this.set({
86
+ contentNodeId,
87
+ contentLoadChildNodes: contentNodeId ? d.contentLoadChildNodes : false,
88
+ })
89
+ }}></umb-input-document>
90
+ <uui-checkbox
91
+ label="Include the pages below it"
92
+ .checked=${d.contentLoadChildNodes ?? false}
93
+ .disabled=${!d.contentNodeId}
94
+ @change=${(event) => this.set({ contentLoadChildNodes: event.target.checked })}
95
+ >Include the pages below it</uui-checkbox
96
+ >`,
97
+ 'The page the bundle starts from',
98
+ )}
99
+ ${field(
100
+ 'Media',
101
+ html`<umb-input-media
102
+ multiple
103
+ .selection=${d.mediaIds ?? []}
104
+ @change=${(event) => {
105
+ const mediaIds = event.target.selection ?? []
106
+ this.set({
107
+ mediaIds,
108
+ mediaLoadChildNodes: mediaIds.length ? d.mediaLoadChildNodes : false,
109
+ })
110
+ }}></umb-input-media>
111
+ <uui-checkbox
112
+ label="Include what is inside them"
113
+ .checked=${d.mediaLoadChildNodes ?? false}
114
+ .disabled=${!d.mediaIds?.length}
115
+ @change=${(event) => this.set({ mediaLoadChildNodes: event.target.checked })}
116
+ >Include what is inside them</uui-checkbox
117
+ >`,
118
+ )}
119
+ ${field(
120
+ 'Library elements',
121
+ html`<umb-input-element
122
+ .selection=${d.elementIds ?? []}
123
+ @change=${(event) => this.set({ elementIds: event.target.selection ?? [] })}></umb-input-element>`,
124
+ )}
125
+ `
126
+ }
127
+ }
128
+
129
+ /** Types: document, media and data types. */
130
+ export class CromboloBundleTypesView extends CromboloBundleEditorView {
131
+ headline = 'Types'
132
+
133
+ fields(d) {
134
+ return html`
135
+ ${field(
136
+ 'Document types',
137
+ html`<umb-input-document-type
138
+ .selection=${d.documentTypes ?? []}
139
+ @change=${(event) => this.set({ documentTypes: event.target.selection ?? [] })}></umb-input-document-type>`,
140
+ )}
141
+ ${field(
142
+ 'Media types',
143
+ html`<umb-input-media-type
144
+ .selection=${d.mediaTypes ?? []}
145
+ @change=${(event) => this.set({ mediaTypes: event.target.selection ?? [] })}></umb-input-media-type>`,
146
+ )}
147
+ ${field(
148
+ 'Data types',
149
+ html`<umb-data-type-input
150
+ .selection=${d.dataTypes ?? []}
151
+ @change=${(event) => this.set({ dataTypes: event.target.selection ?? [] })}></umb-data-type-input>`,
152
+ )}
153
+ <crombolo-bundle-brought-types></crombolo-bundle-brought-types>
154
+ `
155
+ }
156
+ }
157
+
158
+ /** A list of server files (stylesheets, scripts, partial views) as the builder keeps them. */
159
+ const filePicker = (view, d, key, icon, pickerContext) =>
160
+ html`<umb-input-entity
161
+ .getIcon=${() => icon}
162
+ .pickerContext=${pickerContext}
163
+ .selection=${(d[key] ?? []).map((path) => paths.toUnique(path))}
164
+ @change=${(event) =>
165
+ view.set({
166
+ [key]: (event.target.selection ?? []).map((unique) => paths.toServerPath(unique)),
167
+ })}></umb-input-entity>`
168
+
169
+ /** Code: templates, partial views, stylesheets and scripts. */
170
+ export class CromboloBundleCodeView extends CromboloBundleEditorView {
171
+ headline = 'Code'
172
+
173
+ fields(d) {
174
+ return html`
175
+ ${field(
176
+ 'Templates',
177
+ html`<umb-input-entity
178
+ .getIcon=${() => 'icon-document-html'}
179
+ .pickerContext=${UmbTemplatePickerInputContext}
180
+ .selection=${d.templates ?? []}
181
+ @change=${(event) => this.set({ templates: event.target.selection ?? [] })}></umb-input-entity>`,
182
+ )}
183
+ ${field(
184
+ 'Partial views',
185
+ filePicker(this, d, 'partialViews', 'icon-document-html', UmbPartialViewPickerInputContext),
186
+ )}
187
+ ${field('Stylesheets', filePicker(this, d, 'stylesheets', 'icon-palette', UmbStylesheetPickerInputContext))}
188
+ ${field('Scripts', filePicker(this, d, 'scripts', 'icon-document-js', UmbScriptPickerInputContext))}
189
+ `
190
+ }
191
+ }
192
+
193
+ /** Language: languages and dictionary items. */
194
+ export class CromboloBundleLanguageView extends CromboloBundleEditorView {
195
+ headline = 'Language'
196
+
197
+ fields(d) {
198
+ return html`
199
+ ${field(
200
+ 'Languages',
201
+ html`<umb-input-language
202
+ .value=${(d.languages ?? []).join(',')}
203
+ @change=${(event) => this.set({ languages: event.target.selection ?? [] })}></umb-input-language>`,
204
+ )}
205
+ ${field(
206
+ 'Dictionary',
207
+ html`<umb-input-entity
208
+ .getIcon=${() => 'icon-book-alt'}
209
+ .pickerContext=${UmbDictionaryPickerInputContext}
210
+ .selection=${d.dictionaryItems ?? []}
211
+ @change=${(event) => this.set({ dictionaryItems: event.target.selection ?? [] })}></umb-input-entity>`,
212
+ )}
213
+ `
214
+ }
215
+ }
216
+
217
+ const LISTS = { form: 'forms', workflow: 'workflows', userGroup: 'userGroups' }
218
+
219
+ const KEY = (kind, alias) => `${kind}:${alias}`.toLowerCase()
220
+
221
+ /** Why a dependency matters, said where it can be unticked. */
222
+ const NEEDS = {
223
+ userGroup: (by) => `${by} needs this group`,
224
+ documentType: (by) => `${by} needs this document type`,
225
+ }
226
+
227
+ /**
228
+ * The forms, approval workflows and user groups tabs (story 226): the site's
229
+ * own, ticked to carry them. What a ticked one needs is ticked with it, saying
230
+ * why; unticking that leaves it out, with a warning.
231
+ */
232
+ class CromboloBundleSchemaView extends CromboloBundleEditorView {
233
+ static properties = {
234
+ ...CromboloBundleEditorView.properties,
235
+ _picks: { state: true },
236
+ _carried: { state: true },
237
+ _choices: { state: true },
238
+ }
239
+
240
+ /** `form`, `workflow` or `userGroup`. */
241
+ kind = ''
242
+ /** Said when the site has none to pick. */
243
+ empty = ''
244
+
245
+ constructor() {
246
+ super()
247
+ this.consumeContext(CROMBOLO_BUNDLE_EDITOR_CONTEXT, (context) => {
248
+ if (!context) return
249
+ this.observe(context.picks, (picks) => {
250
+ this._picks = picks
251
+ })
252
+ this.observe(context.carried, (carried) => {
253
+ this._carried = carried
254
+ })
255
+ this.observe(context.choices, (choices) => {
256
+ this._choices = choices
257
+ })
258
+ })
259
+ }
260
+
261
+ /** Ticks or unticks one, as a pick or as something a pick brought. */
262
+ toggle(kind, alias, on) {
263
+ const picks = this._picks
264
+ const key = KEY(kind, alias)
265
+ const list = LISTS[kind]
266
+ const brought = (this._carried ?? []).some((c) => c.for && KEY(c.kind, c.alias) === key)
267
+ const excluded = picks.excluded.filter((entry) => entry.toLowerCase() !== key)
268
+ if (on) {
269
+ const listed = list ? picks[list] : []
270
+ this.context?.updatePicks({
271
+ excluded,
272
+ ...(list && !brought && !listed.includes(alias) ? { [list]: [...listed, alias] } : {}),
273
+ })
274
+ return
275
+ }
276
+ this.context?.updatePicks({
277
+ ...(list ? { [list]: picks[list].filter((a) => a !== alias) } : {}),
278
+ excluded: brought ? [...excluded, KEY(kind, alias)] : excluded,
279
+ })
280
+ }
281
+
282
+ /** One row: a checkbox, and why it is ticked or what leaving it out means. */
283
+ row(kind, alias, name) {
284
+ const key = KEY(kind, alias)
285
+ const carried = (this._carried ?? []).filter((c) => KEY(c.kind, c.alias) === key)
286
+ const picked = carried.some((c) => !c.for)
287
+ const brought = carried.find((c) => c.for)
288
+ const ticked = picked || (brought && !brought.excluded)
289
+ const note =
290
+ !picked && brought
291
+ ? brought.excluded
292
+ ? html`<p class="warning">${NEEDS[kind]?.(brought.for.name)}. Leave it out only if the site that installs the bundle already has it.</p>`
293
+ : html`<p class="note">Added for ${brought.for.name}</p>`
294
+ : nothing
295
+ return html`<div class="row">
296
+ <uui-checkbox
297
+ label=${name}
298
+ .checked=${Boolean(ticked)}
299
+ @change=${(event) => this.toggle(kind, alias, event.target.checked)}
300
+ >${name}</uui-checkbox
301
+ >${note}
302
+ </div>`
303
+ }
304
+
305
+ fields() {
306
+ if (!this._picks || !this._choices) return nothing
307
+ const choices = this._choices[LISTS[this.kind]] ?? []
308
+ if (choices.length === 0) return html`<p>${this.empty}</p>`
309
+ return choices.map((choice) => this.row(this.kind, choice.alias, choice.name))
310
+ }
311
+
312
+ static styles = [
313
+ ...CromboloBundleEditorView.styles,
314
+ css`
315
+ .row {
316
+ margin-bottom: var(--uui-size-space-4);
317
+ }
318
+ .row uui-checkbox {
319
+ margin-top: 0;
320
+ }
321
+ .note,
322
+ .warning {
323
+ margin: var(--uui-size-space-1) 0 0 var(--uui-size-space-6);
324
+ font-size: var(--uui-type-small-size);
325
+ }
326
+ .note {
327
+ color: var(--uui-color-text-alt);
328
+ }
329
+ .warning {
330
+ color: var(--uui-color-warning-standalone);
331
+ }
332
+ `,
333
+ ]
334
+ }
335
+
336
+ export class CromboloBundleFormsView extends CromboloBundleSchemaView {
337
+ headline = 'Forms'
338
+ kind = 'form'
339
+ empty = 'This site has no forms.'
340
+ }
341
+
342
+ export class CromboloBundleWorkflowsView extends CromboloBundleSchemaView {
343
+ headline = 'Approval workflows'
344
+ kind = 'workflow'
345
+ empty = 'This site has no approval workflows.'
346
+ }
347
+
348
+ export class CromboloBundleUserGroupsView extends CromboloBundleSchemaView {
349
+ headline = 'User groups'
350
+ kind = 'userGroup'
351
+ empty = 'This site declares no user groups of its own.'
352
+ }
353
+
354
+ /** The document types the forms and workflows bring, on the Types tab. */
355
+ class CromboloBundleBroughtTypes extends CromboloBundleSchemaView {
356
+ kind = 'documentType'
357
+
358
+ fields() {
359
+ const brought = (this._carried ?? []).filter((c) => c.kind === 'documentType')
360
+ if (brought.length === 0) return nothing
361
+ return field(
362
+ 'Added for forms and workflows',
363
+ brought.map((c) => this.row('documentType', c.alias, c.alias)),
364
+ 'Carried as well as the document types picked above',
365
+ )
366
+ }
367
+
368
+ render() {
369
+ return this.fields()
370
+ }
371
+
372
+ static styles = [
373
+ ...CromboloBundleSchemaView.styles,
374
+ css`
375
+ :host {
376
+ padding: 0;
377
+ }
378
+ `,
379
+ ]
380
+ }
381
+
382
+ customElements.define('crombolo-bundle-content-view', CromboloBundleContentView)
383
+ customElements.define('crombolo-bundle-types-view', CromboloBundleTypesView)
384
+ customElements.define('crombolo-bundle-code-view', CromboloBundleCodeView)
385
+ customElements.define('crombolo-bundle-language-view', CromboloBundleLanguageView)
386
+ customElements.define('crombolo-bundle-forms-view', CromboloBundleFormsView)
387
+ customElements.define('crombolo-bundle-workflows-view', CromboloBundleWorkflowsView)
388
+ customElements.define('crombolo-bundle-user-groups-view', CromboloBundleUserGroupsView)
389
+ customElements.define('crombolo-bundle-brought-types', CromboloBundleBroughtTypes)
@@ -0,0 +1,2 @@
1
+ /** The Bundle Editor's types tab (story 233). */
2
+ export { CromboloBundleTypesView as default } from './bundle-editor-sections.js'
@@ -0,0 +1,2 @@
1
+ /** The Bundle Editor's user groups tab (story 226). */
2
+ export { CromboloBundleUserGroupsView as default } from './bundle-editor-sections.js'
@@ -0,0 +1,2 @@
1
+ /** The Bundle Editor's approval workflows tab (story 226). */
2
+ export { CromboloBundleWorkflowsView as default } from './bundle-editor-sections.js'