@crombolo/core 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/core",
3
- "version": "0.52.2",
3
+ "version": "0.53.2",
4
4
  "description": "Internal to crombolo, with no compatibility promise: use @crombolo/crombolo. Domain model, entity keys and shared contracts for crombolo. No I/O.",
5
5
  "license": "MIT",
6
6
  "author": "Crombolo",
@@ -28,6 +28,6 @@
28
28
  "access": "public"
29
29
  },
30
30
  "dependencies": {
31
- "@crombolo/common": "0.52.2"
31
+ "@crombolo/common": "0.53.2"
32
32
  }
33
33
  }
@@ -142,6 +142,12 @@ export const SECTION_NAMES: ReadonlyArray<{ name: keyof typeof SECTION_ALIASES;
142
142
  { name: 'users', says: 'The people who work in the back office, and their groups' },
143
143
  { name: 'translation', says: 'Dictionary items: words the site shows in each language' },
144
144
  { name: 'workflow', says: 'Approvals: pages waiting for someone to approve them' },
145
+ {
146
+ name: 'structure',
147
+ says: 'Content types, data types and languages, which shape the whole site',
148
+ },
149
+ { name: 'components', says: 'Templates, components, stylesheets and scripts' },
150
+ { name: 'workflowSetup', says: 'Setting up approval workflows, not deciding on them' },
145
151
  { name: 'settings', says: 'Types, templates, languages, bundles and the rest of the setup' },
146
152
  ]
147
153
 
package/src/sections.ts CHANGED
@@ -27,8 +27,41 @@ export const SECTION_ALIASES = {
27
27
  forms: 'Crombolo.Section.Forms',
28
28
  // Approval workflows: Umbraco Workflow's section, in core here (story 028).
29
29
  workflow: 'Crombolo.Section.Workflow',
30
+ // Parts of Settings a group can be given without the rest (story 296). None has
31
+ // a header tab: each is a choice in a group, and an item in the menu under Content.
32
+ structure: 'Crombolo.Section.Structure',
33
+ components: 'Crombolo.Section.Components',
34
+ workflowSetup: 'Crombolo.Section.WorkflowSetup',
30
35
  } as const
31
36
 
37
+ /** Told to the client when someone has the whole of Settings, not only a part of it. */
38
+ export const ALL_SETTINGS = 'Crombolo.Section.AllSettings'
39
+
40
+ /**
41
+ * The sections the client is told of, which aren't quite those a user holds. The
42
+ * client opens Settings' screens only for someone with Settings, so a part of it
43
+ * says Settings too, and `ALL_SETTINGS` marks those with the whole of it. The server
44
+ * goes by what the user really holds, whatever the client is told.
45
+ */
46
+ export function clientSections(user: {
47
+ allowedSections: readonly string[]
48
+ isAdmin: boolean
49
+ }): string[] {
50
+ const held = new Set(user.allowedSections.map(sectionKey))
51
+ const out = new Set(user.allowedSections)
52
+ if (held.has('settings')) {
53
+ out.add(ALL_SETTINGS)
54
+ out.add(SECTION_ALIASES.structure)
55
+ out.add(SECTION_ALIASES.components)
56
+ }
57
+ if (held.has('structure') || held.has('components')) out.add(SECTION_ALIASES.settings)
58
+ if (user.isAdmin || held.has(sectionKey(SECTION_ALIASES.workflowSetup))) {
59
+ out.add(SECTION_ALIASES.workflowSetup)
60
+ out.add(SECTION_ALIASES.forms)
61
+ }
62
+ return [...out]
63
+ }
64
+
32
65
  export type AppAlias = keyof typeof SECTION_ALIASES
33
66
  export type SectionAlias = (typeof SECTION_ALIASES)[AppAlias]
34
67