@crombolo/backoffice-host 0.52.2 → 0.53.2

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.52.2",
3
+ "version": "0.53.2",
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.52.2",
36
- "@crombolo/backoffice-dist": "0.52.2"
35
+ "@crombolo/core": "0.53.2",
36
+ "@crombolo/backoffice-dist": "0.53.2"
37
37
  }
38
38
  }
@@ -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.52.2",
5
+ "version": "0.53.2",
6
6
  "allowPublicAccess": false,
7
7
  "extensions": [
8
8
  {
@@ -32,6 +32,8 @@ export default {
32
32
  'Welcome to Crombolo! Unfortunately your invite has expired. Please contact your administrator to get a new one.',
33
33
  },
34
34
  user: {
35
+ sectionsHelp:
36
+ 'Pages needs Content. Structure, Components and Workflow setup change the whole site, so give them with care.',
35
37
  changePasswordDescription:
36
38
  "You can change your password for accessing the Crombolo backoffice by filling out the form below and click the 'Change Password' button",
37
39
  createUserHelp:
@@ -90,6 +92,8 @@ export default {
90
92
  newPartialViewFromSnippet: 'Component from snippet',
91
93
  },
92
94
  treeHeaders: {
95
+ // Components, modules, stylesheets and scripts: more than templates.
96
+ templatingGroup: 'Code',
93
97
  // One tree over one directory: templates and partial views are the same
94
98
  // kind of file here, and what makes one a template is that a content type
95
99
  // names it, not where it sits.
@@ -1,33 +1,48 @@
1
1
  /**
2
2
  * What the menu under Content offers (story 289), and which item a page belongs
3
- * to. Pure, so each is tested on its own. Structure and Components stay in
4
- * Settings and forms in their section: the client links to them there, and the
5
- * menu is what puts them together.
3
+ * to. Pure, so each is tested on its own. Structure and Code stay in
4
+ * Settings: the client links to them there, and the menu is what puts them
5
+ * together. Forms is a node in Structure, and Workflows stays in the Forms section.
6
6
  */
7
7
  import { treeFor } from './settings-cards.js'
8
8
 
9
- const SETTINGS = 'Umb.Section.Settings'
9
+ const STRUCTURE = 'Crombolo.Section.Structure'
10
+ const COMPONENTS = 'Crombolo.Section.Components'
11
+ const WORKFLOW_SETUP = 'Crombolo.Section.WorkflowSetup'
12
+ /** Reading forms, which is what a group's Forms comes to. */
13
+ const FORM_READ = 'Crombolo.Form.Read'
10
14
  const FORMS = 'Crombolo.Section.Forms'
11
15
  const CONTENT = 'Umb.Section.Content'
12
16
 
17
+ /** Forms is a node in Structure; someone with Forms alone gets it where it always was. */
18
+ const STRUCTURE_FORMS = { path: 'section/forms', section: FORMS, verb: FORM_READ }
19
+
13
20
  const ITEMS = [
14
21
  { label: 'Pages', path: 'section/content', section: CONTENT },
15
- { label: 'Structure', path: 'section/settings/structure', section: SETTINGS },
16
- { label: 'Components', path: 'section/settings/code', section: SETTINGS },
17
- { label: 'Forms', path: 'section/forms', section: FORMS },
18
- { label: 'Workflows', path: 'section/forms/view/workflows', section: FORMS, admin: true },
22
+ {
23
+ label: 'Structure',
24
+ path: 'section/settings/structure',
25
+ section: STRUCTURE,
26
+ or: STRUCTURE_FORMS,
27
+ },
28
+ { label: 'Code', path: 'section/settings/code', section: COMPONENTS },
29
+ { label: 'Workflows', path: 'section/forms/view/workflows', section: WORKFLOW_SETUP },
19
30
  ]
20
31
 
21
32
  /**
22
33
  * The items this user may open. One alone is no menu, so it offers none.
23
34
  *
24
- * @param {{ allowedSections?: string[], isAdmin?: boolean } | undefined} user
35
+ * @param {{ allowedSections?: string[], fallbackPermissions?: string[], isAdmin?: boolean } | undefined} user
25
36
  */
26
37
  export function stripItems(user) {
27
38
  const allowed = user?.allowedSections ?? []
28
- const items = ITEMS.filter(
29
- (item) => allowed.includes(item.section) && (!item.admin || user?.isAdmin === true),
30
- )
39
+ const may = (verb) => user?.isAdmin === true || (user?.fallbackPermissions ?? []).includes(verb)
40
+ const items = ITEMS.flatMap((item) => {
41
+ if (allowed.includes(item.section)) return [item]
42
+ return item.or && allowed.includes(item.or.section) && may(item.or.verb)
43
+ ? [{ ...item, ...item.or }]
44
+ : []
45
+ })
31
46
  return items.length > 1 ? items : []
32
47
  }
33
48
 
@@ -41,10 +56,10 @@ export function activeItem(path) {
41
56
  if (!section) return undefined
42
57
  const [, name, rest = ''] = section
43
58
  if (name === 'content') return 'Pages'
44
- if (name === 'forms') return rest.startsWith('view/workflows') ? 'Workflows' : 'Forms'
59
+ if (name === 'forms') return rest.startsWith('view/workflows') ? 'Workflows' : 'Structure'
45
60
  if (name !== 'settings') return undefined
46
- if (rest.startsWith('structure')) return 'Structure'
47
- if (rest.startsWith('code')) return 'Components'
61
+ if (rest.startsWith('structure') || rest.startsWith('forms')) return 'Structure'
62
+ if (rest.startsWith('code')) return 'Code'
48
63
  const tree = treeFor(/^workspace\/([^/]+)/.exec(rest)?.[1])
49
- return tree === 'structure' ? 'Structure' : tree === 'code' ? 'Components' : undefined
64
+ return tree === 'structure' ? 'Structure' : tree === 'code' ? 'Code' : undefined
50
65
  }
@@ -1,6 +1,5 @@
1
1
  /**
2
- * The menu under Content (story 289): Pages, Structure, Components, Forms and
3
- * Workflows, for whoever may open them. A row of its own under the header, shown
2
+ * The menu under Content (story 289): Pages, Structure, Code and Workflows, for whoever may open them. A row of its own under the header, shown
4
3
  * wherever one of them is open, and it keeps Content's tab marked while it shows.
5
4
  */
6
5
  import { UMB_CURRENT_USER_CONTEXT } from '@umbraco-cms/backoffice/current-user'
@@ -58,12 +57,15 @@ export default class CromboloContentStripElement extends UmbLitElement {
58
57
  this.#follow()
59
58
  window.addEventListener('changestate', this.#follow)
60
59
  window.addEventListener('popstate', this.#follow)
60
+ // A route the router settles on without a state change of its own, such as Home.
61
+ window.addEventListener('navigationend', this.#follow)
61
62
  }
62
63
 
63
64
  disconnectedCallback() {
64
65
  super.disconnectedCallback()
65
66
  window.removeEventListener('changestate', this.#follow)
66
67
  window.removeEventListener('popstate', this.#follow)
68
+ window.removeEventListener('navigationend', this.#follow)
67
69
  mark(undefined)
68
70
  document.documentElement.style.removeProperty(ROW_HEIGHT)
69
71
  }
@@ -38,6 +38,6 @@ export function definitionTree(items, folders) {
38
38
  export function readOnlyWords(kind, because) {
39
39
  if (because === 'site')
40
40
  return `${kind} are kept with this site's files, so they can't be changed here. To change one, edit it in the site's code and deploy it.`
41
- if (because === 'permission') return `Only administrators can change ${kind.toLowerCase()}.`
41
+ if (because === 'permission') return `Your group can't change ${kind.toLowerCase()}.`
42
42
  return undefined
43
43
  }
@@ -15,13 +15,21 @@ const here = () => {
15
15
  return location.pathname.startsWith(base) ? location.pathname.slice(base.length) : ''
16
16
  }
17
17
 
18
+ /** A form's screens, in Structure for those who have it, else in the Forms section. */
19
+ const formsAt = (view) =>
20
+ here().startsWith('section/settings')
21
+ ? `section/settings/forms${view === 'entries' ? '/entries' : ''}`
22
+ : `section/forms/view/${view}`
23
+
18
24
  const KINDS = {
19
25
  Forms: {
20
26
  label: 'Forms',
21
- root: 'section/forms/view/entries',
27
+ get root() {
28
+ return formsAt('entries')
29
+ },
22
30
  rootLabel: 'Forms',
23
- open: (item) => `section/forms/view/forms?form=${encodeURIComponent(item.key)}`,
24
- create: (folder) => `section/forms/view/forms?new=${encodeURIComponent(folder)}`,
31
+ open: (item) => `${formsAt('forms')}?form=${encodeURIComponent(item.key)}`,
32
+ create: (folder) => `${formsAt('forms')}?new=${encodeURIComponent(folder)}`,
25
33
  load: formsTree,
26
34
  folder: sendFormFolder,
27
35
  move: moveForm,
@@ -50,6 +58,8 @@ const url = (path) =>
50
58
 
51
59
  export default class CromboloDefinitionTreeElement extends UmbLitElement {
52
60
  static properties = {
61
+ /** The tree to show; without it, whichever the address belongs to. */
62
+ kind: { type: String },
53
63
  _kind: { state: true },
54
64
  _tree: { state: true },
55
65
  _because: { state: true },
@@ -58,7 +68,7 @@ export default class CromboloDefinitionTreeElement extends UmbLitElement {
58
68
  }
59
69
 
60
70
  #follow = () => {
61
- const kind = activeItem(here()) === 'Workflows' ? 'Workflows' : 'Forms'
71
+ const kind = this.kind ?? (activeItem(here()) === 'Workflows' ? 'Workflows' : 'Forms')
62
72
  if (kind === this._kind) return
63
73
  this._kind = kind
64
74
  this.#load()
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Form, in the Create menu of Content Types: forms sit beside content types in
3
+ * Structure, so a new one starts from the same place. It is saved under Forms.
4
+ */
5
+ import { UmbEntityCreateOptionActionBase } from '@umbraco-cms/backoffice/entity-create-option-action'
6
+
7
+ export class CromboloFormCreateOptionAction extends UmbEntityCreateOptionActionBase {
8
+ async getHref() {
9
+ return 'section/settings/forms?new='
10
+ }
11
+ }
12
+
13
+ export { CromboloFormCreateOptionAction as api }
@@ -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.52.2",
5
+ "version": "0.53.2",
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.52.2",
5
+ "version": "0.53.2",
6
6
  "allowPublicAccess": false,
7
7
  "extensions": [
8
8
  {
@@ -6,6 +6,7 @@
6
6
  * manifest.
7
7
  */
8
8
 
9
+ import { UMB_CURRENT_USER_CONTEXT } from '@umbraco-cms/backoffice/current-user'
9
10
  import {
10
11
  createExtensionApi,
11
12
  createExtensionElement,
@@ -30,6 +31,7 @@ import {
30
31
  treeFor,
31
32
  } from './settings-cards.js'
32
33
  import './breadcrumb.js'
34
+ import './definition-tree.js'
33
35
  import { readOnlyWords } from './definition-tree-model.js'
34
36
  import './settings-card.js'
35
37
 
@@ -48,8 +50,15 @@ const emailStatus = async () => {
48
50
 
49
51
  const menuOf = (manifest, menu) => manifest.meta?.menus?.includes(menu) === true
50
52
 
53
+ /** Each tree, and the part of Settings that opens it. */
54
+ const TREE_SECTIONS = [
55
+ ['structure', 'Crombolo.Section.Structure'],
56
+ ['code', 'Crombolo.Section.Components'],
57
+ ]
58
+
51
59
  export class CromboloSettingsSectionElement extends UmbLitElement {
52
60
  static properties = {
61
+ _mayForms: { state: true },
53
62
  _routes: { state: true },
54
63
  _sidebarApps: { state: true },
55
64
  _tree: { state: true },
@@ -58,6 +67,8 @@ export class CromboloSettingsSectionElement extends UmbLitElement {
58
67
  }
59
68
 
60
69
  #dashboards = []
70
+ /** The sections the current user holds, which say how much of Settings they have. */
71
+ #held
61
72
  #menuItems = []
62
73
  #sectionRoutes = []
63
74
  #landing
@@ -66,6 +77,15 @@ export class CromboloSettingsSectionElement extends UmbLitElement {
66
77
 
67
78
  constructor() {
68
79
  super()
80
+ this.consumeContext(UMB_CURRENT_USER_CONTEXT, (user) => {
81
+ this.observe(user?.currentUser, (current) => {
82
+ this._mayForms =
83
+ current?.isAdmin === true ||
84
+ (current?.fallbackPermissions ?? []).includes('Crombolo.Form.Read')
85
+ this.#held = current?.allowedSections ?? []
86
+ this.#createRoutes()
87
+ })
88
+ })
69
89
  // An explanation, not a control: a failure leaves it out.
70
90
  fetch(`${base()}/crombolo/api/site-files`, { credentials: 'include' })
71
91
  .then((response) => (response.ok ? response.json() : { writable: true }))
@@ -202,9 +222,20 @@ export class CromboloSettingsSectionElement extends UmbLitElement {
202
222
  }
203
223
 
204
224
  #createRoutes() {
225
+ // Someone with a part of Settings has its tree, and not the cards or the tools.
226
+ const whole = this.#held?.includes('Crombolo.Section.AllSettings') ?? false
227
+ const mine = TREE_SECTIONS.filter(([, section]) => this.#held?.includes(section)).map(
228
+ ([tree]) => tree,
229
+ )
230
+ const toTree = (name) =>
231
+ history.replaceState(null, '', new URL(`section/settings/${name}`, document.baseURI).pathname)
205
232
  const landing = {
206
233
  component: () => document.createElement('crombolo-settings-landing'),
207
234
  setup: (element) => {
235
+ if (this.#held && !whole && mine[0]) {
236
+ toTree(mine[0])
237
+ return
238
+ }
208
239
  this.#landing = element
209
240
  this.#refreshLanding()
210
241
  this.#showing(undefined)
@@ -214,6 +245,10 @@ export class CromboloSettingsSectionElement extends UmbLitElement {
214
245
  path: name,
215
246
  component: () => document.createElement('crombolo-settings-tree-start'),
216
247
  setup: (element) => {
248
+ if (this.#held && !mine.includes(name) && mine[0]) {
249
+ toTree(mine[0])
250
+ return
251
+ }
217
252
  element.tree = name
218
253
  this.#showing(name)
219
254
  },
@@ -232,7 +267,18 @@ export class CromboloSettingsSectionElement extends UmbLitElement {
232
267
  this.#showing(undefined, { title: this.#label(manifest) })
233
268
  },
234
269
  }))
270
+ // Forms is a node in Structure, so its tree stays on screen beside the form.
271
+ const forms = (path, tag, load) => ({
272
+ path,
273
+ component: async () => {
274
+ await load()
275
+ return document.createElement(tag)
276
+ },
277
+ setup: () => this.#showing('structure'),
278
+ })
235
279
  this._routes = [
280
+ forms('forms/entries', 'crombolo-forms-entries', () => import('./forms-entries.js')),
281
+ forms('forms', 'crombolo-forms-overview', () => import('./forms-overview.js')),
236
282
  tree('structure'),
237
283
  tree('code'),
238
284
  // Umbraco's welcome, which this page replaces: an address people have.
@@ -249,11 +295,13 @@ export class CromboloSettingsSectionElement extends UmbLitElement {
249
295
  )
250
296
  },
251
297
  },
252
- ...dashboards,
298
+ ...(this.#held && !whole ? [] : dashboards),
253
299
  ...this.#sectionRoutes,
254
300
  { path: '', pathMatch: 'full', ...landing },
255
301
  { path: '**', component: UmbRouteNotFoundElement },
256
302
  ]
303
+ // The router keeps a page it already shows, so the cards need telling.
304
+ this.#refreshLanding()
257
305
  }
258
306
 
259
307
  #sectionPath() {
@@ -295,6 +343,11 @@ export class CromboloSettingsSectionElement extends UmbLitElement {
295
343
  ${(this._sidebarApps ?? []).map(
296
344
  (app) => html`<div class="tree" ?hidden=${app.alias !== shown}>${app.component}</div>`,
297
345
  )}
346
+ ${
347
+ this._tree === 'structure' && this._mayForms
348
+ ? html`<crombolo-definition-tree kind="Forms"></crombolo-definition-tree>`
349
+ : nothing
350
+ }
298
351
  </umb-section-sidebar>
299
352
  ${main}`
300
353
  }
@@ -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.52.2",
5
+ "version": "0.53.2",
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.52.2",
5
+ "version": "0.53.2",
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,15 @@
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
+ },
607
616
  {
608
617
  "type": "sectionSidebarApp",
609
618
  "alias": "Crombolo.SectionSidebarApp.DefinitionTree",
@@ -712,6 +721,36 @@
712
721
  "name": "Crombolo Approvals Active Condition",
713
722
  "api": "/crombolo-plugin/approvals-active.js"
714
723
  },
724
+ {
725
+ "type": "section",
726
+ "alias": "Crombolo.Section.Structure",
727
+ "name": "Crombolo Structure Section",
728
+ "weight": 30,
729
+ "meta": {
730
+ "label": "Structure",
731
+ "pathname": "structure"
732
+ }
733
+ },
734
+ {
735
+ "type": "section",
736
+ "alias": "Crombolo.Section.Components",
737
+ "name": "Crombolo Code Section",
738
+ "weight": 29,
739
+ "meta": {
740
+ "label": "Code",
741
+ "pathname": "components"
742
+ }
743
+ },
744
+ {
745
+ "type": "section",
746
+ "alias": "Crombolo.Section.WorkflowSetup",
747
+ "name": "Crombolo Workflow setup Section",
748
+ "weight": 28,
749
+ "meta": {
750
+ "label": "Workflow setup",
751
+ "pathname": "workflow-setup"
752
+ }
753
+ },
715
754
  {
716
755
  "type": "section",
717
756
  "alias": "Crombolo.Section.Workflow",